Hi,
I am trying to use prosemirror to show inserted and deleted contents by editor/s. To record all changes I have used prosemirror-changeset. Now I am writing a plugin to display these changes with decorations to clearly indicate the inserts and deletions.
Inserts appear to work fine. For deletes, I have the below piece of code:
if (changeset.deleted) {
// changeset.deleted.forEach(() => {
const updated_doc = fbSchema.nodeFromJSON(JSON.parse(previous[1].doc))
const fragment = updated_doc.content
console.log('change_set 1', fragment)
const toPosition = changeset.toA > fragment.size ? fragment.size : changeset.toA
const slice = fragment.cut(changeset.fromA, toPosition)
const doc_fragment = DOMSerializer.fromSchema(fbSchema).serializeFragment(slice)
console.log('change_set 2', slice)
let element = document.createElement("span");
element.appendChild(doc_fragment);
element.style.color = `${userColor}`
element.style.textDecoration = `line-through`
decorations.push(Decoration.widget(changeset.fromA, element))
// })
}
All looks almost ok, except that when i create a slice using Fragment.cut(), I get the fragment inside a paragraph node, which makes the text move to the next line. How can I avoid this?