@magic-marker/prosemirror-suggest-changes 0.3.3-wrap-unwrap.11 → 0.3.3-wrap-unwrap.12
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.
|
@@ -136,7 +136,14 @@ function addMarks(ops, tr, suggestionId) {
|
|
|
136
136
|
if (nodeId == null) return true;
|
|
137
137
|
const op = ops.get(nodeId);
|
|
138
138
|
if (op == null) return true;
|
|
139
|
-
if (op.op === "move"
|
|
139
|
+
if (op.op === "move") {
|
|
140
|
+
if (hasStructureAddMark(node)) return true;
|
|
141
|
+
const inverseMoveMark = findInverseStructureMoveMark(node, op);
|
|
142
|
+
if (inverseMoveMark) {
|
|
143
|
+
tr.removeNodeMark(pos, inverseMoveMark);
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
140
147
|
tr.addNodeMark(pos, structure.create({
|
|
141
148
|
id: suggestionId,
|
|
142
149
|
data: {
|
|
@@ -147,6 +154,16 @@ function addMarks(ops, tr, suggestionId) {
|
|
|
147
154
|
});
|
|
148
155
|
trace("perf", "addMarks", "took", Number((performance.now() - perfAddMarks).toFixed(2)), "ms");
|
|
149
156
|
}
|
|
157
|
+
function findInverseStructureMoveMark(node, op) {
|
|
158
|
+
const { structure } = getSuggestionMarks(node.type.schema);
|
|
159
|
+
return node.marks.find((mark)=>{
|
|
160
|
+
if (mark.type !== structure) return false;
|
|
161
|
+
if (!guardStructureMarkAttrs(mark.attrs)) return false;
|
|
162
|
+
const existingOp = mark.attrs.data.op;
|
|
163
|
+
if (existingOp.op !== "move") return false;
|
|
164
|
+
return sameParentChain(existingOp.from, op.to) && sameParentChain(existingOp.to, op.from);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
150
167
|
function hasStructureAddMark(node) {
|
|
151
168
|
const { structure } = getSuggestionMarks(node.type.schema);
|
|
152
169
|
return node.marks.some((mark)=>{
|