From cf5d610b8608668af0ca7a9ea8a2892261bcc50b Mon Sep 17 00:00:00 2001 From: madhawa97 Date: Mon, 27 Oct 2025 19:57:38 +0530 Subject: [PATCH] Rebuild changeSet before fixing inconsistencies to prevent nested marks --- src/plugin.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugin.ts b/src/plugin.ts index ad90689..30a05cf 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { Plugin, PluginKey, Transaction } from 'prosemirror-state' +import { EditorState, Plugin, PluginKey, Transaction } from 'prosemirror-state' import type { EditorProps, EditorView } from 'prosemirror-view' import { getAction, hasAction, setAction, TrackChangesAction } from './actions' @@ -141,9 +141,14 @@ export const trackChangesPlugin = ( setAction(createdTr, TrackChangesAction.refreshChanges, true) } }) + + const currentChangeSet = createdTr.docChanged + ? findChanges(EditorState.create({ doc: createdTr.doc, schema: oldState.schema })) + : pluginState.changeSet + const changed = - pluginState.changeSet.hasInconsistentData && - fixInconsistentChanges(pluginState.changeSet, userID, createdTr, oldState.schema) + currentChangeSet.hasInconsistentData && + fixInconsistentChanges(currentChangeSet, userID, createdTr, oldState.schema) if (changed) { log.warn('had to fix inconsistent changes in', createdTr) }