@magic-marker/prosemirror-suggest-changes 0.3.3-wrap-unwrap.2 → 0.3.3-wrap-unwrap.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -120,15 +120,15 @@ function getStepHandler(step) {
|
|
|
120
120
|
let transaction = tr;
|
|
121
121
|
if (isEnabled) {
|
|
122
122
|
let structureChangesTransform = null;
|
|
123
|
-
const docBefore =
|
|
124
|
-
if (
|
|
123
|
+
const docBefore = transaction.docs[0];
|
|
124
|
+
if (transaction.docChanged && docBefore && opts?.experimental_trackStructureChanges && typeof opts.experimental_ensureUniqueNodeIds === "function") {
|
|
125
125
|
trace("trying to track structure changes first...");
|
|
126
126
|
// after a transaction, some nodes may not yet have unique ids (they were just added, and the unique id plugin has not yet run)
|
|
127
127
|
// this hook allows to "post-process" the transaction and add the missing ids
|
|
128
128
|
// basically it allows to run the core logic of the unique ids plugin earlier
|
|
129
129
|
const uniqueNodeIdsTransform = opts.experimental_ensureUniqueNodeIds([
|
|
130
|
-
|
|
131
|
-
], docBefore,
|
|
130
|
+
transaction
|
|
131
|
+
], docBefore, transaction.doc);
|
|
132
132
|
const docAfter = uniqueNodeIdsTransform.doc;
|
|
133
133
|
trace("unique node ids set", docAfter);
|
|
134
134
|
// try running structure changes first
|
|
@@ -146,7 +146,7 @@ function getStepHandler(step) {
|
|
|
146
146
|
trace("applied unique id transform and structure changes transform to the transaction", transaction);
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
|
-
if (structureChangesTransform == null || structureChangesTransform.steps.length === 0) {
|
|
149
|
+
if (transaction.docChanged && (structureChangesTransform == null || structureChangesTransform.steps.length === 0)) {
|
|
150
150
|
trace("running the main suggestions plugin...");
|
|
151
151
|
transaction = transformToSuggestionTransaction(tr, this.state, generateId);
|
|
152
152
|
trace("main suggestions plugin completed", transaction);
|