Giter VIP home page Giter VIP logo

Comments (3)

SamDuvall avatar SamDuvall commented on June 25, 2024 2

@BitPhinix, thank you. That was an excellent suggestion and worked beautifully.

I can't think of a good reason why one would want remote changes to creep into their local history. I wish there was an easy way to add this to slate-jys, but it feels wrong to require slate-history in slate-yjs even though I bet a large majority of people using slate-yjs use slate-history as well. Below is the code I added after creating the editor for anyone else who is interested:

  const { apply } = editor
  editor.apply = (...args) => {
    if (YjsEditor.isRemote(editor)) {
      HistoryEditor.withoutSaving(editor, () => {
        apply.apply(editor, args)
      })
    } else {
      apply.apply(editor, args)
    }
  }

from slate-yjs.

BitPhinix avatar BitPhinix commented on June 25, 2024

Hi @SamDuvall,

Another way you could solve this is by wrapping editor.apply with a handler that checks if YjsEditor.isRemote(editor) is true and then wrapping the next call with HistoryEditor.withoutSaving

I haven't actually tested it, but it should work 😄

from slate-yjs.

BitPhinix avatar BitPhinix commented on June 25, 2024

Awesome, glad I could help!

I haven't yet added this to slate-yjs because I'm planning to add another history handling plugin based on Y.UndoManager to have proper Yjs history support. I'm really busy at the moment but will get back to it in the coming months

from slate-yjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.