From d23082c00b359c97bef57c6220b2095c2268f3ec Mon Sep 17 00:00:00 2001 From: Elad Barack Date: Mon, 10 Apr 2023 16:37:22 +0300 Subject: [PATCH] feat: addToYDoc new plugin state --- src/plugins/sync-plugin.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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) + }) + } } } },