Duplicate link nodes as a result of `toggleMark` command

I am running a simple setup for ProseMirror and have got a serious issue which I do not know how to approach best. Basically whenever in the document model there is a link (a text node with a link mark) within a paragraph, if I toggle the mark of a selection starting at the beginning of the paragraph (for example to make it bold), and then remove the mark, the link is duplicated. For example, if the original paragraph is:

Hellow my name is Bob and I work here.

Making the Hellow part bold (using toggleMark() command) will (correctly) result in:

Hellow my name is Bob and I work here.

Now using toggleMark() one more time will update the state to:

Hellow my name is Bob Bob and I work here.

This will not happen if the range upon which toggleMark() is applied does not include the first character of the paragraph, so basically:

Hellow my name is Bob and I work here.

Works perfectly fine.

I am running ProseMirror within Angular (6.0.8), which might have an effect on the issue. Additionally, if I manually reconstruct the DOM representation of the document, the duplicate link will disappear:

this.view.dom.innerHTML = '';
const fragment = DOMSerializer.fromSchema(this.schema).serializeFragment(this.view.state.doc.content);
this.view.dom.appendChild(fragment);

Would cause the duplicate link to go away, which means the duplicate links seems like a residual element that ProseMirror’s view somehow did not clear up, and not present in the actual document model.

Any ideas?

This was a regression in prosemirror-view 1.14.3. I’ve fixed it in this patch.

1 Like

thanks a lot!

wait so should upgrading to prosemirror-view@1.14.5 suffice? cause I’m still getting the same issue on that version.

Check your build/cache/package lock etc. The issue was trivially reproduceable, and the new test is passing in 1.14.5

1 Like