From c5b94e50dfe2f8163004b56ad9031a925b92ee04 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 2 Jul 2024 18:24:23 -0400 Subject: [PATCH] fix: RangeError when resolving or removing comment across marks, closes #7182 --- app/editor/index.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/editor/index.tsx b/app/editor/index.tsx index 27ea8d007..d1210e5bd 100644 --- a/app/editor/index.tsx +++ b/app/editor/index.tsx @@ -646,6 +646,7 @@ export class Editor extends React.PureComponent< */ public removeComment = (commentId: string) => { const { state, dispatch } = this.view; + const tr = state.tr; state.doc.descendants((node, pos) => { if (!node.isInline) { @@ -657,9 +658,11 @@ export class Editor extends React.PureComponent< ); if (mark) { - dispatch(state.tr.removeMark(pos, pos + node.nodeSize, mark)); + tr.removeMark(pos, pos + node.nodeSize, mark); } }); + + dispatch(tr); }; /** @@ -670,6 +673,7 @@ export class Editor extends React.PureComponent< */ public updateComment = (commentId: string, attrs: { resolved: boolean }) => { const { state, dispatch } = this.view; + const tr = state.tr; state.doc.descendants((node, pos) => { if (!node.isInline) { @@ -687,11 +691,12 @@ export class Editor extends React.PureComponent< ...mark.attrs, ...attrs, }); - dispatch( - state.tr.removeMark(from, to, mark).addMark(from, to, newMark) - ); + + tr.removeMark(from, to, mark).addMark(from, to, newMark); } }); + + dispatch(tr); }; /**