How to compare the differences between different texts(No Steps)?

I’ve read a lot of posts, and it seems that they are all compared in the case of steps, I store through state.toJSON(), and then I want to compare the record with the current document by storing it, and then add the markup that is deleted and added, no idea, is there any good way to do it now, I need to make a time machine for novel writing, thank you for your excellent project

The library doesn’t really have anything for that, unless you just want to find a single changed range (in which case you can use findDiffStart/End from both sides of the document.

Thank you for your reply, I have good news, I have solved it, I use this open source libraryhttps://github.com/hamflx/prosemirror-diff/blob/master/src/diff.js, I use [diff-match-patch], the effect is as follows:

thank you again for your timely reply, leave a footprint here for more people in need to help

If anyone has searched for this issue and might be helpful, I’d be willing to share the code used:

import { diffEditor, DiffType } from './diff/index.js'
const diffSchema = new Schema({
    nodes,
    marks: {
        diffMark: {
            //这里定义标记的属性和行为
            attrs: {
                type: { default: '' },
            },
            // 定义渲染 HTML 的方法
            toDOM(type) {
                // 处理属性未定义的情况
                if (!type || type.attrs === undefined) {
                    type = { attrs: { type: DiffType.Unchanged } }; // 默认值
                }
                const color = {
                    [DiffType.Inserted]: '#bcf5bc',
                    [DiffType.Deleted]: '#ff8989'
                }[type.attrs.type] || 'transparent'; // 处理属性不存在的情况,默认为透明色

                // 返回 HTML 渲染规则
                const styleAttr = `background-color: ${color}`;
                return ['span', { style: styleAttr }, 0] as DOMOutputSpecArray;
            }
        }
    }
});
    const docNode = diffEditor(diffSchema, historyState.doc, nowState.doc)
    const diffState = EditorState.create({
        schema: diffSchema,
        doc: Node.fromJSON(diffSchema, docNode.toJSON()),
    })
    diffEditorView = new EditorView(editor, {
        state: diffState,
        editable() {
            return false
        },

    })
    return diffEditorView

Good luck in your work! :grinning: