diff --git a/src/plugins/sync-plugin.js b/src/plugins/sync-plugin.js index e4d5163..a1ab651 100644 --- a/src/plugins/sync-plugin.js +++ b/src/plugins/sync-plugin.js @@ -113,6 +113,7 @@ export const ySyncPlugin = (yXmlFragment, { isChangeOrigin: false, isUndoRedoOperation: false, addToHistory: true, + addToYDoc: true, colors, colorMapping, permanentUserData @@ -127,6 +128,7 @@ export const ySyncPlugin = (yXmlFragment, { } } pluginState.addToHistory = tr.getMeta('addToHistory') !== false + pluginState.addToYDoc = tr.getMeta('addToYDoc') !== false // always set isChangeOrigin. If undefined, this is not change origin. pluginState.isChangeOrigin = change !== undefined && !!change.isChangeOrigin @@ -208,12 +210,15 @@ export const ySyncPlugin = (yXmlFragment, { um.stopCapturing() } } - binding.mux(() => { - /** @type {Y.Doc} */ (pluginState.doc).transact((tr) => { - tr.meta.set('addToHistory', pluginState.addToHistory) - binding._prosemirrorChanged(view.state.doc) - }, ySyncPluginKey) - }) + + if (pluginState.addToYDoc) { + binding.mux(() => { + /** @type {Y.Doc} */ (pluginState.doc).transact((tr) => { + tr.meta.set('addToHistory', pluginState.addToHistory) + binding._prosemirrorChanged(view.state.doc) + }, ySyncPluginKey) + }) + } } } },