Y.XmlText delta with format, does not give ychange

I’m trying out the editor tiptap (instead of slate) that is on top of ProseMirror and benefit of the official binding support.

I have the issue that I cannot have the delta of a format in the text. I have two snapshots, call text.toDelta(nextSnapshot, prevSnapshot, (type, { client }) => ({ type, client })) but do not get the ychange on a format change :thinking:

output

Note: I’m using the latest version yjs@npm:13.5.38

Hi @Hideman85,

could you please create a concrete example that does not work?

I’m noticing that you also need a PermanentUserMapping for this to work.

FYI: The ychange is not supposed to be public. Anyone reading this: I don’t recommend using this at this time.

Hi @dmonad,

I tried to extract the very minimum code for reproduction please have a look here

FYI: The ychange is not supposed to be public. Anyone reading this: I don’t recommend using this at this time.

I do not quite understand it is part of the public api :thinking:

    /**
     * Returns the Delta representation of this YText type.
     *
     * @param {Snapshot} [snapshot]
     * @param {Snapshot} [prevSnapshot]
     * @param {function('removed' | 'added', ID):any} [computeYChange]
     * @return {any} The Delta representation of this type.
     *
     * @public
     */
    public toDelta(snapshot?: Snapshot | undefined, prevSnapshot?: Snapshot | undefined, computeYChange?: ((arg0: 'removed' | 'added', arg1: ID) => any) | undefined): any;

Then you should have access to delta.attributes.ychange isnt?

Yes, there is typing information on it. But as you probably noticed, there is no documentation for the snapshot API.

I can only tell you that the next release will probably change the snapshot API to something more usable with an easier interface.

That would be awesome, in my case I strongly need this snapshot/delta feature (even more that realtime aspect) since in our app it is important to have a fully versioned document with who made what where.

My goal is to have prosemirror decorations that show the delta from the last update and also when you have a look the the version history.

Today I’m computing the changes on XmlFragment, XmlElement and XmlText via the snapshot and the clock dictionary. I was using toDelta on the text to simplify my life but since it is missing for format changes I would have to have a manual implementation I guess.

Is it actually a bug that this value is not there for format? :thinking:
I would love to have a have a workaround to finish my migration to the tiptap/prosemirror :slight_smile:

Hi @dmonad, sorry to at you, I would love to have a way to finish this. If you see anything I can do to detect a format changes on a XmlText made by a clientID that would be awesome, otherwise I think I would have to dig down in the internals to make something out of it.

Thanks in advance for your help.

If you want to implement this now, you definitely have to work your way through it. I currently have time for this. Maybe start with the prosemirror-versions demo.