Add an update method to custom mark views #197

Merged
marijn merged 4 commits from ocavue/prosemirror-view:mark-view-update into main 2026-07-01 17:48:52 +02:00
Contributor

Add a new method MarkView.update(), similar to existing NodeView.update().

This can avoid DOM rebuilds for some expensive custom mark views (imagine a custom link mark view that needs to render the favicon and OG image).

Add a new method `MarkView.update()`, similar to existing [`NodeView.update()`](https://prosemirror.net/docs/ref/#view.NodeView.update). This can avoid DOM rebuilds for some expensive custom mark views (imagine a custom `link` mark view that needs to render the favicon and OG image).
src/viewdesc.ts Outdated
@ -1220,0 +1227,4 @@
// When nothing matches, try to update the mark view at this position
// in place, so a custom mark view can adapt to a changed mark without
// re-creating its DOM.
if (found < 0) {
Owner

could you add an && this.index < this.top.children.length here to avoid out-of-bounds access? (Which would be caught by the instanceof check but could still cause deoptimization.)

could you add an `&& this.index < this.top.children.length` here to avoid out-of-bounds access? (Which would be caught by the `instanceof` check but could still cause deoptimization.)
Author
Contributor

done.

done.
marijn merged commit e6323215ac into main 2026-07-01 17:48:52 +02:00
Owner

Thanks!

Thanks!
Owner

Shall I tag a release or are you planning more PRs?

Shall I tag a release or are you planning more PRs?
Author
Contributor

@marijn wrote in #197 (comment):

Shall I tag a release or are you planning more PRs?

You can tag a release. I don’t have any planning PRs for now.

@marijn wrote in https://code.haverbeke.berlin/prosemirror/prosemirror-view/pulls/197#issuecomment-70218: > Shall I tag a release or are you planning more PRs? You can tag a release. I don’t have any planning PRs for now.
Owner

Done (1.42.0)

Done (1.42.0)
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-view!197
No description provided.