@pixerate/editor 0.25.0 → 0.26.0
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.
- package/README.md +30 -0
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/dist/agent/index.cjs +174 -11
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +18 -4
- package/dist/agent/index.d.ts +18 -4
- package/dist/agent/index.js +167 -4
- package/dist/agent/index.js.map +1 -1
- package/dist/{arrangeShortcuts-B8O3f8-P.d.cts → arrange-BICutYPk.d.cts} +243 -29
- package/dist/{arrangeShortcuts-sLlD2rSX.d.ts → arrange-BICutYPk.d.ts} +243 -29
- package/dist/builtins-CdPcLwwF.d.cts +176 -0
- package/dist/builtins-Chj6zv_O.d.ts +176 -0
- package/dist/canvas/index.cjs +3917 -19
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +1232 -7
- package/dist/canvas/index.d.ts +1232 -7
- package/dist/canvas/index.js +3916 -18
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-3CC7OPUQ.cjs +831 -0
- package/dist/chunk-3CC7OPUQ.cjs.map +1 -0
- package/dist/{chunk-AL6JMGWW.cjs → chunk-CS6NZWWA.cjs} +24 -24
- package/dist/{chunk-AL6JMGWW.cjs.map → chunk-CS6NZWWA.cjs.map} +1 -1
- package/dist/{chunk-C7P22VIP.cjs → chunk-EWCOFSCQ.cjs} +17 -6
- package/dist/chunk-EWCOFSCQ.cjs.map +1 -0
- package/dist/chunk-HDYMLS3X.cjs +409 -0
- package/dist/chunk-HDYMLS3X.cjs.map +1 -0
- package/dist/{chunk-X4N4WUKB.cjs → chunk-IFHKKVXH.cjs} +150 -38
- package/dist/chunk-IFHKKVXH.cjs.map +1 -0
- package/dist/{chunk-ECCCYKGL.js → chunk-JOIREKL7.js} +63 -39
- package/dist/chunk-JOIREKL7.js.map +1 -0
- package/dist/chunk-KRGXUQ2Y.js +1696 -0
- package/dist/chunk-KRGXUQ2Y.js.map +1 -0
- package/dist/{chunk-QGYDWPRM.js → chunk-MHEPLBFB.js} +2 -2
- package/dist/chunk-MR2764X2.js +831 -0
- package/dist/chunk-MR2764X2.js.map +1 -0
- package/dist/{chunk-7WISYZFO.cjs → chunk-NFVBT3UZ.cjs} +67 -43
- package/dist/chunk-NFVBT3UZ.cjs.map +1 -0
- package/dist/{chunk-WSQKHXW7.cjs → chunk-NQF32I6Z.cjs} +1209 -457
- package/dist/chunk-NQF32I6Z.cjs.map +1 -0
- package/dist/{chunk-IXHSYOVY.js → chunk-Q2OHWD2A.js} +638 -866
- package/dist/chunk-Q2OHWD2A.js.map +1 -0
- package/dist/{chunk-NAXVVS5I.js → chunk-QJSOZFCZ.js} +2 -2
- package/dist/{chunk-V3CHHWOE.cjs → chunk-RRREAOVM.cjs} +4 -4
- package/dist/{chunk-V3CHHWOE.cjs.map → chunk-RRREAOVM.cjs.map} +1 -1
- package/dist/{chunk-UAKDG62Z.js → chunk-SWE3NPOU.js} +116 -4
- package/dist/chunk-SWE3NPOU.js.map +1 -0
- package/dist/chunk-TXXNBDQX.cjs +1696 -0
- package/dist/chunk-TXXNBDQX.cjs.map +1 -0
- package/dist/chunk-UBCFIABU.js +409 -0
- package/dist/chunk-UBCFIABU.js.map +1 -0
- package/dist/{chunk-RR7F5GUM.js → chunk-X7HXL2SB.js} +941 -189
- package/dist/chunk-X7HXL2SB.js.map +1 -0
- package/dist/{chunk-PO6A6QQH.cjs → chunk-YOMYSFJU.cjs} +742 -970
- package/dist/chunk-YOMYSFJU.cjs.map +1 -0
- package/dist/{chunk-FH6F67DN.js → chunk-ZRNHGAQT.js} +17 -6
- package/dist/{chunk-FH6F67DN.js.map → chunk-ZRNHGAQT.js.map} +1 -1
- package/dist/commands/index.cjs +352 -4
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +37 -108
- package/dist/commands/index.d.ts +37 -108
- package/dist/commands/index.js +351 -3
- package/dist/commands/index.js.map +1 -1
- package/dist/compare/index.cjs +3 -3
- package/dist/compare/index.js +2 -2
- package/dist/{controller-BIJiNoVs.d.cts → controller-CxXGOEmy.d.cts} +209 -13
- package/dist/{controller-BIJiNoVs.d.ts → controller-CxXGOEmy.d.ts} +209 -13
- package/dist/export/index.cjs +36 -0
- package/dist/export/index.cjs.map +1 -0
- package/dist/export/index.d.cts +243 -0
- package/dist/export/index.d.ts +243 -0
- package/dist/export/index.js +36 -0
- package/dist/export/index.js.map +1 -0
- package/dist/extensions/index.cjs +54 -6
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +7 -2
- package/dist/extensions/index.d.ts +7 -2
- package/dist/extensions/index.js +59 -11
- package/dist/{index-7a6bHTLy.d.ts → index-B273Zllk.d.ts} +211 -207
- package/dist/{index-Csd5qI8u.d.cts → index-jcJwmBYt.d.cts} +211 -207
- package/dist/index.cjs +144 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +49 -13
- package/dist/index.d.ts +49 -13
- package/dist/index.js +136 -24
- package/dist/index.js.map +1 -1
- package/dist/registry-CED5C0lA.d.cts +204 -0
- package/dist/registry-CED5C0lA.d.ts +204 -0
- package/dist/{registry-D32LpIc4.d.cts → registry-D0GADKc7.d.cts} +1 -1
- package/dist/{registry-evKTP4ls.d.ts → registry-DhVUZioj.d.ts} +1 -1
- package/dist/serializers/index.cjs +4 -4
- package/dist/serializers/index.d.cts +2 -1
- package/dist/serializers/index.d.ts +2 -1
- package/dist/serializers/index.js +3 -3
- package/dist/spreadsheet/index.cjs +33 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +106 -3
- package/dist/spreadsheet/index.d.ts +106 -3
- package/dist/spreadsheet/index.js +32 -2
- package/package.json +10 -1
- package/dist/chunk-7WISYZFO.cjs.map +0 -1
- package/dist/chunk-C7P22VIP.cjs.map +0 -1
- package/dist/chunk-ECCCYKGL.js.map +0 -1
- package/dist/chunk-IXHSYOVY.js.map +0 -1
- package/dist/chunk-PO6A6QQH.cjs.map +0 -1
- package/dist/chunk-RR7F5GUM.js.map +0 -1
- package/dist/chunk-UAKDG62Z.js.map +0 -1
- package/dist/chunk-WSQKHXW7.cjs.map +0 -1
- package/dist/chunk-X4N4WUKB.cjs.map +0 -1
- package/dist/types-DX4Mh4SL.d.cts +0 -217
- package/dist/types-DX4Mh4SL.d.ts +0 -217
- /package/dist/{chunk-QGYDWPRM.js.map → chunk-MHEPLBFB.js.map} +0 -0
- /package/dist/{chunk-NAXVVS5I.js.map → chunk-QJSOZFCZ.js.map} +0 -0
|
@@ -661,10 +661,22 @@ function getTrackedChanges(source) {
|
|
|
661
661
|
return change;
|
|
662
662
|
};
|
|
663
663
|
const blockCounts = /* @__PURE__ */ new Map();
|
|
664
|
+
const blockCells = /* @__PURE__ */ new Map();
|
|
664
665
|
doc.descendants((node, pos) => {
|
|
665
666
|
const block = _optionalChain([node, 'access', _14 => _14.attrs, 'optionalAccess', _15 => _15[BLOCK_CHANGE_ATTRIBUTE]]);
|
|
666
667
|
if (_optionalChain([block, 'optionalAccess', _16 => _16.changeId]) && node.isTextblock) {
|
|
667
668
|
blockCounts.set(block.changeId, (_nullishCoalesce(blockCounts.get(block.changeId), () => ( 0))) + 1);
|
|
669
|
+
if (block.operation && blockCells.get(block.changeId) !== null) {
|
|
670
|
+
const $pos = doc.resolve(pos);
|
|
671
|
+
let cell = -1;
|
|
672
|
+
for (let depth = $pos.depth; depth > 0 && cell < 0; depth--) {
|
|
673
|
+
const role = $pos.node(depth).type.spec.tableRole;
|
|
674
|
+
if (role === "cell" || role === "header_cell") cell = $pos.before(depth);
|
|
675
|
+
}
|
|
676
|
+
const cells = _nullishCoalesce(blockCells.get(block.changeId), () => ( /* @__PURE__ */ new Set()));
|
|
677
|
+
if (cell < 0) blockCells.set(block.changeId, null);
|
|
678
|
+
else blockCells.set(block.changeId, cells.add(cell));
|
|
679
|
+
}
|
|
668
680
|
const change = add(
|
|
669
681
|
`block:${block.changeId}`,
|
|
670
682
|
"block",
|
|
@@ -740,7 +752,8 @@ function getTrackedChanges(source) {
|
|
|
740
752
|
if (operation) {
|
|
741
753
|
const count = _nullishCoalesce(blockCounts.get(change.id), () => ( 1));
|
|
742
754
|
const verb = operation === "insert" ? "Inserted" : "Deleted";
|
|
743
|
-
|
|
755
|
+
const cells = _optionalChain([blockCells, 'access', _17 => _17.get, 'call', _18 => _18(change.id), 'optionalAccess', _19 => _19.size]);
|
|
756
|
+
change.description = cells ? `${verb} ${cells === 1 ? "a table cell" : `${cells} table cells`}` : count > 1 ? `${verb} ${count} blocks` : `${verb} ${blockLabel(current.type, current.attrs)}`;
|
|
744
757
|
} else {
|
|
745
758
|
change.description = describeBlockChange(previous, current);
|
|
746
759
|
}
|
|
@@ -770,12 +783,12 @@ function selectionRange(change) {
|
|
|
770
783
|
return [change.from, change.to];
|
|
771
784
|
}
|
|
772
785
|
function isTrackChangesEnabled(source) {
|
|
773
|
-
const state = _nullishCoalesce(_optionalChain([source, 'optionalAccess',
|
|
786
|
+
const state = _nullishCoalesce(_optionalChain([source, 'optionalAccess', _20 => _20.state]), () => ( source));
|
|
774
787
|
if (!state || typeof state.plugins === "undefined") return false;
|
|
775
|
-
return _nullishCoalesce(_optionalChain([trackChangesPluginKey, 'access',
|
|
788
|
+
return _nullishCoalesce(_optionalChain([trackChangesPluginKey, 'access', _21 => _21.getState, 'call', _22 => _22(state), 'optionalAccess', _23 => _23.enabled]), () => ( false));
|
|
776
789
|
}
|
|
777
790
|
function getTrackChangesStore(editor) {
|
|
778
|
-
return _nullishCoalesce(_optionalChain([editor, 'optionalAccess',
|
|
791
|
+
return _nullishCoalesce(_optionalChain([editor, 'optionalAccess', _24 => _24.storage, 'optionalAccess', _25 => _25.trackChanges, 'optionalAccess', _26 => _26.store]), () => ( null));
|
|
779
792
|
}
|
|
780
793
|
function marksFromJSON(schema, marks) {
|
|
781
794
|
const result = [];
|
|
@@ -836,7 +849,7 @@ function sinkItem(tr, contentPos) {
|
|
|
836
849
|
const itemType = $pos.node(itemDepth).type;
|
|
837
850
|
if (index === 0 || list.child(index - 1).type !== itemType) return false;
|
|
838
851
|
const nodeBefore = list.child(index - 1);
|
|
839
|
-
const nestedBefore = _optionalChain([nodeBefore, 'access',
|
|
852
|
+
const nestedBefore = _optionalChain([nodeBefore, 'access', _27 => _27.lastChild, 'optionalAccess', _28 => _28.type]) === list.type;
|
|
840
853
|
const inner = _model.Fragment.from(nestedBefore ? itemType.create() : null);
|
|
841
854
|
const slice = new (0, _model.Slice)(
|
|
842
855
|
_model.Fragment.from(itemType.create(null, _model.Fragment.from(list.type.create(null, inner)))),
|
|
@@ -937,10 +950,10 @@ function restoreWrappers(tr, contentPos, wrappers) {
|
|
|
937
950
|
const wrapper = tr.doc.nodeAt(start);
|
|
938
951
|
if (!wrapper) return;
|
|
939
952
|
const end = start + wrapper.nodeSize;
|
|
940
|
-
if (_optionalChain([tr, 'access',
|
|
953
|
+
if (_optionalChain([tr, 'access', _29 => _29.doc, 'access', _30 => _30.resolve, 'call', _31 => _31(end), 'access', _32 => _32.nodeAfter, 'optionalAccess', _33 => _33.type]) === wrapper.type && _transform.canJoin.call(void 0, tr.doc, end)) {
|
|
941
954
|
step(() => tr.join(end));
|
|
942
955
|
}
|
|
943
|
-
if (_optionalChain([tr, 'access',
|
|
956
|
+
if (_optionalChain([tr, 'access', _34 => _34.doc, 'access', _35 => _35.resolve, 'call', _36 => _36(start), 'access', _37 => _37.nodeBefore, 'optionalAccess', _38 => _38.type]) === wrapper.type && _transform.canJoin.call(void 0, tr.doc, start)) {
|
|
944
957
|
step(() => tr.join(start));
|
|
945
958
|
}
|
|
946
959
|
return;
|
|
@@ -954,8 +967,8 @@ function removeBlocks(tr, ids, decision) {
|
|
|
954
967
|
if (cached !== void 0) return cached;
|
|
955
968
|
let result;
|
|
956
969
|
if (node.isTextblock) {
|
|
957
|
-
const record = _optionalChain([node, 'access',
|
|
958
|
-
result = !!_optionalChain([record, 'optionalAccess',
|
|
970
|
+
const record = _optionalChain([node, 'access', _39 => _39.attrs, 'optionalAccess', _40 => _40[BLOCK_CHANGE_ATTRIBUTE]]);
|
|
971
|
+
result = !!_optionalChain([record, 'optionalAccess', _41 => _41.changeId]) && record.operation === removed && ids.has(record.changeId);
|
|
959
972
|
} else if (node.isLeaf || node.childCount === 0) {
|
|
960
973
|
result = false;
|
|
961
974
|
} else {
|
|
@@ -967,7 +980,7 @@ function removeBlocks(tr, ids, decision) {
|
|
|
967
980
|
};
|
|
968
981
|
const doc = tr.doc;
|
|
969
982
|
if (removable(doc)) {
|
|
970
|
-
const filler = _optionalChain([doc, 'access',
|
|
983
|
+
const filler = _optionalChain([doc, 'access', _42 => _42.type, 'access', _43 => _43.contentMatch, 'access', _44 => _44.defaultType, 'optionalAccess', _45 => _45.createAndFill, 'call', _46 => _46()]);
|
|
971
984
|
if (filler) tr.replaceWith(0, doc.content.size, filler);
|
|
972
985
|
return;
|
|
973
986
|
}
|
|
@@ -998,8 +1011,8 @@ function decideBlocks(tr, changes, decision) {
|
|
|
998
1011
|
removeBlocks(tr, ids, decision);
|
|
999
1012
|
const items = [];
|
|
1000
1013
|
tr.doc.descendants((node, pos) => {
|
|
1001
|
-
const record = _optionalChain([node, 'access',
|
|
1002
|
-
if (node.isTextblock && _optionalChain([record, 'optionalAccess',
|
|
1014
|
+
const record = _optionalChain([node, 'access', _47 => _47.attrs, 'optionalAccess', _48 => _48[BLOCK_CHANGE_ATTRIBUTE]]);
|
|
1015
|
+
if (node.isTextblock && _optionalChain([record, 'optionalAccess', _49 => _49.changeId]) && ids.has(record.changeId)) {
|
|
1003
1016
|
items.push({ contentPos: pos + 1, record });
|
|
1004
1017
|
}
|
|
1005
1018
|
return !node.isTextblock;
|
|
@@ -1118,7 +1131,7 @@ function acceptSlice(slice, schema) {
|
|
|
1118
1131
|
if (insertion) marks = insertion.removeFromSet(marks);
|
|
1119
1132
|
if (format) marks = format.removeFromSet(marks);
|
|
1120
1133
|
children.push(marks === child.marks ? child : child.mark(marks));
|
|
1121
|
-
} else if (_optionalChain([child, 'access',
|
|
1134
|
+
} else if (_optionalChain([child, 'access', _50 => _50.attrs, 'optionalAccess', _51 => _51[BLOCK_CHANGE_ATTRIBUTE]])) {
|
|
1122
1135
|
children.push(
|
|
1123
1136
|
child.type.create(
|
|
1124
1137
|
{ ...child.attrs, [BLOCK_CHANGE_ATTRIBUTE]: null },
|
|
@@ -1338,8 +1351,8 @@ function trackBlocks(tr, pending, ctx) {
|
|
|
1338
1351
|
if (!node.isTextblock || $pos.parentOffset !== 0 || $pos.depth === 0) return;
|
|
1339
1352
|
if (!node.type.spec.attrs || !(BLOCK_CHANGE_ATTRIBUTE in node.type.spec.attrs)) return;
|
|
1340
1353
|
const pos = $pos.before();
|
|
1341
|
-
if (_optionalChain([existing, 'optionalAccess',
|
|
1342
|
-
const original = _nullishCoalesce(_optionalChain([existing, 'optionalAccess',
|
|
1354
|
+
if (_optionalChain([existing, 'optionalAccess', _52 => _52.operation]) || _optionalChain([node, 'access', _53 => _53.attrs, 'access', _54 => _54[BLOCK_CHANGE_ATTRIBUTE], 'optionalAccess', _55 => _55.operation])) return;
|
|
1355
|
+
const original = _nullishCoalesce(_optionalChain([existing, 'optionalAccess', _56 => _56.previous]), () => ( previous));
|
|
1343
1356
|
const current = blockSnapshot(tr.doc, pos);
|
|
1344
1357
|
if (sameBlock(original, current, ctx.ignoredAttributes)) {
|
|
1345
1358
|
if (node.attrs[BLOCK_CHANGE_ATTRIBUTE]) {
|
|
@@ -1371,7 +1384,7 @@ function collectBlockChanges(step, docBefore, docAfter, rest, pending, ctx) {
|
|
|
1371
1384
|
};
|
|
1372
1385
|
if (step instanceof _transform.AttrStep) {
|
|
1373
1386
|
const node = docBefore.nodeAt(step.pos);
|
|
1374
|
-
if (_optionalChain([node, 'optionalAccess',
|
|
1387
|
+
if (_optionalChain([node, 'optionalAccess', _57 => _57.isTextblock]) && step.attr !== BLOCK_CHANGE_ATTRIBUTE && !ctx.ignoredAttributes.has(step.attr)) {
|
|
1375
1388
|
record(step.pos, step.pos);
|
|
1376
1389
|
}
|
|
1377
1390
|
return;
|
|
@@ -1391,11 +1404,78 @@ function collectBlockChanges(step, docBefore, docAfter, rest, pending, ctx) {
|
|
|
1391
1404
|
return false;
|
|
1392
1405
|
});
|
|
1393
1406
|
}
|
|
1407
|
+
var TABLE_ROLES = /* @__PURE__ */ new Set(["table", "row", "cell", "header_cell"]);
|
|
1408
|
+
var isTableStructure = (node) => TABLE_ROLES.has(node.type.spec.tableRole);
|
|
1409
|
+
var supportsBlockChange = (node) => !!node.type.spec.attrs && BLOCK_CHANGE_ATTRIBUTE in node.type.spec.attrs;
|
|
1410
|
+
function isWholeTableSlice(slice) {
|
|
1411
|
+
if (slice.openStart !== 0 || slice.openEnd !== 0 || slice.content.childCount === 0) return false;
|
|
1412
|
+
let whole = true;
|
|
1413
|
+
slice.content.forEach((child) => {
|
|
1414
|
+
if (!isTableStructure(child)) whole = false;
|
|
1415
|
+
});
|
|
1416
|
+
return whole;
|
|
1417
|
+
}
|
|
1418
|
+
function canMarkTableBlocks(slice) {
|
|
1419
|
+
let ok = true;
|
|
1420
|
+
let any = false;
|
|
1421
|
+
slice.content.descendants((node) => {
|
|
1422
|
+
if (!ok) return false;
|
|
1423
|
+
if (node.isTextblock) {
|
|
1424
|
+
any = true;
|
|
1425
|
+
if (!supportsBlockChange(node)) ok = false;
|
|
1426
|
+
return false;
|
|
1427
|
+
}
|
|
1428
|
+
return true;
|
|
1429
|
+
});
|
|
1430
|
+
return ok && any;
|
|
1431
|
+
}
|
|
1432
|
+
function isOwnTableInsertion(slice, ctx) {
|
|
1433
|
+
let own = true;
|
|
1434
|
+
slice.content.descendants((node) => {
|
|
1435
|
+
if (!own) return false;
|
|
1436
|
+
if (node.isTextblock) {
|
|
1437
|
+
const record = node.attrs[BLOCK_CHANGE_ATTRIBUTE];
|
|
1438
|
+
if (_optionalChain([record, 'optionalAccess', _58 => _58.operation]) !== "insert" || record.authorId !== ctx.author.id) own = false;
|
|
1439
|
+
return false;
|
|
1440
|
+
}
|
|
1441
|
+
return true;
|
|
1442
|
+
});
|
|
1443
|
+
return own;
|
|
1444
|
+
}
|
|
1445
|
+
function collectInsertedTableNodes(slice, from, rest, out) {
|
|
1446
|
+
slice.content.descendants((node, offset) => {
|
|
1447
|
+
if (!isTableStructure(node)) return !node.isTextblock;
|
|
1448
|
+
const pos = from - slice.openStart + offset;
|
|
1449
|
+
if (pos < from) return true;
|
|
1450
|
+
const start = rest.map(pos, 1);
|
|
1451
|
+
const end = rest.map(pos + node.nodeSize, -1);
|
|
1452
|
+
if (end - start === node.nodeSize) out.push({ from: start, to: end });
|
|
1453
|
+
return false;
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
function markTableBlocks(tr, from, to, operation, attrs) {
|
|
1457
|
+
const positions = [];
|
|
1458
|
+
tr.doc.nodesBetween(from, to, (node, pos) => {
|
|
1459
|
+
if (!node.isTextblock) return true;
|
|
1460
|
+
if (pos >= from && pos + node.nodeSize <= to && supportsBlockChange(node)) positions.push(pos);
|
|
1461
|
+
return false;
|
|
1462
|
+
});
|
|
1463
|
+
positions.forEach((pos) => {
|
|
1464
|
+
const record = {
|
|
1465
|
+
...baseAttributes(attrs),
|
|
1466
|
+
previous: blockSnapshot(tr.doc, pos),
|
|
1467
|
+
operation
|
|
1468
|
+
};
|
|
1469
|
+
tr.setNodeAttribute(pos, BLOCK_CHANGE_ATTRIBUTE, record);
|
|
1470
|
+
});
|
|
1471
|
+
return positions.length > 0;
|
|
1472
|
+
}
|
|
1394
1473
|
function trackTransactions(transactions, oldState, newState, ctx) {
|
|
1395
1474
|
const maps = [];
|
|
1396
1475
|
transactions.forEach((t) => maps.push(...t.mapping.maps));
|
|
1397
1476
|
const inserted = [];
|
|
1398
1477
|
const restores = [];
|
|
1478
|
+
const tableInserts = [];
|
|
1399
1479
|
const formatRanges = [];
|
|
1400
1480
|
const blocks = /* @__PURE__ */ new Map();
|
|
1401
1481
|
let mapIndex = 0;
|
|
@@ -1432,6 +1512,9 @@ function trackTransactions(transactions, oldState, newState, ctx) {
|
|
|
1432
1512
|
return;
|
|
1433
1513
|
}
|
|
1434
1514
|
}
|
|
1515
|
+
if (ctx.trackBlocks && slice.size > 0) {
|
|
1516
|
+
collectInsertedTableNodes(slice, from, rest, tableInserts);
|
|
1517
|
+
}
|
|
1435
1518
|
if (slice.size > 0 && hasInlineContent(slice.content)) {
|
|
1436
1519
|
const start = rest.map(from, 1);
|
|
1437
1520
|
const end = rest.map(from + slice.size, -1);
|
|
@@ -1439,7 +1522,8 @@ function trackTransactions(transactions, oldState, newState, ctx) {
|
|
|
1439
1522
|
}
|
|
1440
1523
|
if (to > from) {
|
|
1441
1524
|
const deleted = docBefore.slice(from, to);
|
|
1442
|
-
|
|
1525
|
+
const wholeTable = ctx.trackBlocks && isWholeTableSlice(deleted);
|
|
1526
|
+
if (!wholeTable && !hasInlineContent(deleted.content)) return;
|
|
1443
1527
|
const $from = docBefore.resolve(from);
|
|
1444
1528
|
const before = i === 0 ? t.before : null;
|
|
1445
1529
|
const sel = before === oldState.doc ? oldState.selection : null;
|
|
@@ -1448,13 +1532,14 @@ function trackTransactions(transactions, oldState, newState, ctx) {
|
|
|
1448
1532
|
slice: deleted,
|
|
1449
1533
|
parentType: $from.node(Math.max(0, $from.depth - deleted.openStart)).type,
|
|
1450
1534
|
pureDelete: slice.size === 0,
|
|
1535
|
+
wholeTable,
|
|
1451
1536
|
backspace: single && slice.size === 0 && !!sel && sel.empty && sel.from === to
|
|
1452
1537
|
});
|
|
1453
1538
|
}
|
|
1454
1539
|
});
|
|
1455
1540
|
mapIndex += t.steps.length;
|
|
1456
1541
|
});
|
|
1457
|
-
if (inserted.length === 0 && restores.length === 0 && formatRanges.length === 0 && blocks.size === 0) {
|
|
1542
|
+
if (inserted.length === 0 && tableInserts.length === 0 && restores.length === 0 && formatRanges.length === 0 && blocks.size === 0) {
|
|
1458
1543
|
return null;
|
|
1459
1544
|
}
|
|
1460
1545
|
const tr = newState.tr;
|
|
@@ -1491,7 +1576,7 @@ function trackTransactions(transactions, oldState, newState, ctx) {
|
|
|
1491
1576
|
}
|
|
1492
1577
|
}
|
|
1493
1578
|
}
|
|
1494
|
-
if (_optionalChain([moves, 'optionalAccess',
|
|
1579
|
+
if (_optionalChain([moves, 'optionalAccess', _59 => _59.event]) === "cut" && restores.length) {
|
|
1495
1580
|
deleteAttrs = newAttributes(ctx);
|
|
1496
1581
|
const raw = restores.map((r) => deletedText(r.slice, ctx)).join("\n");
|
|
1497
1582
|
if (normalizeMoveText(raw) && moves.isMove(raw)) {
|
|
@@ -1507,16 +1592,43 @@ function trackTransactions(transactions, oldState, newState, ctx) {
|
|
|
1507
1592
|
changed = true;
|
|
1508
1593
|
});
|
|
1509
1594
|
if (insertAttrs) changed = true;
|
|
1595
|
+
if (tableInserts.length) {
|
|
1596
|
+
const attrs = newAttributes(ctx);
|
|
1597
|
+
tableInserts.forEach(({ from, to }) => {
|
|
1598
|
+
const start = tr.mapping.map(from, 1);
|
|
1599
|
+
const end = tr.mapping.map(to, -1);
|
|
1600
|
+
const node = tr.doc.nodeAt(start);
|
|
1601
|
+
if (end <= start || !node || !isTableStructure(node) || node.nodeSize !== end - start) return;
|
|
1602
|
+
tr.removeMark(start, end, ctx.insertion);
|
|
1603
|
+
changed = markTableBlocks(tr, start, end, "insert", attrs) || changed;
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
let tableDeleteAttrs = null;
|
|
1510
1607
|
let cursor = null;
|
|
1511
1608
|
restores.sort((a, b) => b.pos - a.pos).forEach((restore) => {
|
|
1512
1609
|
const pos = tr.mapping.map(restore.pos, -1);
|
|
1513
1610
|
const attrs = _nullishCoalesce(_nullishCoalesce(deleteAttrs, () => ( adjacentAttributes(tr.doc, pos, pos, ctx.deletion, ctx))), () => ( newAttributes(ctx)));
|
|
1611
|
+
if (restore.wholeTable && canMarkTableBlocks(restore.slice)) {
|
|
1612
|
+
if (isOwnTableInsertion(restore.slice, ctx)) return;
|
|
1613
|
+
tableDeleteAttrs = _nullishCoalesce(_nullishCoalesce(tableDeleteAttrs, () => ( deleteAttrs)), () => ( newAttributes(ctx)));
|
|
1614
|
+
const sizeBefore2 = tr.doc.content.size;
|
|
1615
|
+
try {
|
|
1616
|
+
tr.replace(pos, pos, restore.slice);
|
|
1617
|
+
} catch (e9) {
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
const end = pos + (tr.doc.content.size - sizeBefore2);
|
|
1621
|
+
markTableBlocks(tr, pos, end, "delete", tableDeleteAttrs);
|
|
1622
|
+
changed = true;
|
|
1623
|
+
return;
|
|
1624
|
+
}
|
|
1625
|
+
if (!hasInlineContent(restore.slice.content)) return;
|
|
1514
1626
|
const marked = markDeletedSlice(restore.slice, restore.parentType, attrs, ctx);
|
|
1515
1627
|
if (!marked || !marked.hasContent) return;
|
|
1516
1628
|
const sizeBefore = tr.doc.content.size;
|
|
1517
1629
|
try {
|
|
1518
1630
|
tr.replace(pos, pos, marked.slice);
|
|
1519
|
-
} catch (
|
|
1631
|
+
} catch (e10) {
|
|
1520
1632
|
return;
|
|
1521
1633
|
}
|
|
1522
1634
|
changed = true;
|
|
@@ -1528,7 +1640,7 @@ function trackTransactions(transactions, oldState, newState, ctx) {
|
|
|
1528
1640
|
if (cursor !== null) {
|
|
1529
1641
|
try {
|
|
1530
1642
|
tr.setSelection(_state.TextSelection.create(tr.doc, cursor));
|
|
1531
|
-
} catch (
|
|
1643
|
+
} catch (e11) {
|
|
1532
1644
|
}
|
|
1533
1645
|
}
|
|
1534
1646
|
tr.setMeta(TRACK_CHANGES_SKIP_META, true);
|
|
@@ -1538,10 +1650,10 @@ function buildSnapshot(state, author) {
|
|
|
1538
1650
|
const plugin = trackChangesPluginKey.getState(state);
|
|
1539
1651
|
const changes = getTrackedChanges(state.doc);
|
|
1540
1652
|
return {
|
|
1541
|
-
enabled: _nullishCoalesce(_optionalChain([plugin, 'optionalAccess',
|
|
1542
|
-
author: _nullishCoalesce(_optionalChain([plugin, 'optionalAccess',
|
|
1653
|
+
enabled: _nullishCoalesce(_optionalChain([plugin, 'optionalAccess', _60 => _60.enabled]), () => ( false)),
|
|
1654
|
+
author: _nullishCoalesce(_optionalChain([plugin, 'optionalAccess', _61 => _61.author]), () => ( author)),
|
|
1543
1655
|
changes,
|
|
1544
|
-
currentChangeId: _nullishCoalesce(_optionalChain([getTrackedChangeAt, 'call',
|
|
1656
|
+
currentChangeId: _nullishCoalesce(_optionalChain([getTrackedChangeAt, 'call', _62 => _62(state, state.selection.from, changes), 'optionalAccess', _63 => _63.id]), () => ( null))
|
|
1545
1657
|
};
|
|
1546
1658
|
}
|
|
1547
1659
|
function allowTrackingInCodeBlocks(schema) {
|
|
@@ -1593,13 +1705,13 @@ var TrackChanges = _core.Extension.create({
|
|
|
1593
1705
|
};
|
|
1594
1706
|
},
|
|
1595
1707
|
addGlobalAttributes() {
|
|
1596
|
-
if (_optionalChain([this, 'access',
|
|
1597
|
-
const blockClass = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1598
|
-
const insertedClass = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1599
|
-
const deletedClass = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1708
|
+
if (_optionalChain([this, 'access', _64 => _64.options, 'optionalAccess', _65 => _65.trackBlocks]) === false) return [];
|
|
1709
|
+
const blockClass = _nullishCoalesce(_optionalChain([this, 'access', _66 => _66.options, 'optionalAccess', _67 => _67.blockChangeClass]), () => ( ""));
|
|
1710
|
+
const insertedClass = _nullishCoalesce(_optionalChain([this, 'access', _68 => _68.options, 'optionalAccess', _69 => _69.blockInsertedClass]), () => ( ""));
|
|
1711
|
+
const deletedClass = _nullishCoalesce(_optionalChain([this, 'access', _70 => _70.options, 'optionalAccess', _71 => _71.blockDeletedClass]), () => ( ""));
|
|
1600
1712
|
return [
|
|
1601
1713
|
{
|
|
1602
|
-
types: _nullishCoalesce(_optionalChain([this, 'access',
|
|
1714
|
+
types: _nullishCoalesce(_optionalChain([this, 'access', _72 => _72.options, 'optionalAccess', _73 => _73.blockTypes]), () => ( ["paragraph", "heading", "codeBlock"])),
|
|
1603
1715
|
attributes: {
|
|
1604
1716
|
[BLOCK_CHANGE_ATTRIBUTE]: {
|
|
1605
1717
|
default: null,
|
|
@@ -1623,10 +1735,10 @@ var TrackChanges = _core.Extension.create({
|
|
|
1623
1735
|
];
|
|
1624
1736
|
},
|
|
1625
1737
|
addExtensions() {
|
|
1626
|
-
const insertionAttrs = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1627
|
-
const deletionAttrs = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1628
|
-
const formatAttrs = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1629
|
-
const moveAttrs = _nullishCoalesce(_optionalChain([this, 'access',
|
|
1738
|
+
const insertionAttrs = _nullishCoalesce(_optionalChain([this, 'access', _74 => _74.options, 'optionalAccess', _75 => _75.insertionHTMLAttributes]), () => ( {}));
|
|
1739
|
+
const deletionAttrs = _nullishCoalesce(_optionalChain([this, 'access', _76 => _76.options, 'optionalAccess', _77 => _77.deletionHTMLAttributes]), () => ( {}));
|
|
1740
|
+
const formatAttrs = _nullishCoalesce(_optionalChain([this, 'access', _78 => _78.options, 'optionalAccess', _79 => _79.formatChangeHTMLAttributes]), () => ( {}));
|
|
1741
|
+
const moveAttrs = _nullishCoalesce(_optionalChain([this, 'access', _80 => _80.options, 'optionalAccess', _81 => _81.moveHTMLAttributes]), () => ( {}));
|
|
1630
1742
|
const markOptions = (attrs) => ({
|
|
1631
1743
|
...Object.keys(attrs).length ? { HTMLAttributes: attrs } : {},
|
|
1632
1744
|
...Object.keys(moveAttrs).length ? { moveHTMLAttributes: moveAttrs } : {}
|
|
@@ -1741,12 +1853,12 @@ var TrackChanges = _core.Extension.create({
|
|
|
1741
1853
|
},
|
|
1742
1854
|
appendTransaction: (transactions, oldState, newState) => {
|
|
1743
1855
|
const plugin = trackChangesPluginKey.getState(oldState);
|
|
1744
|
-
const tracking = !!_optionalChain([plugin, 'optionalAccess',
|
|
1856
|
+
const tracking = !!_optionalChain([plugin, 'optionalAccess', _82 => _82.enabled]);
|
|
1745
1857
|
if (!tracking && !pending) {
|
|
1746
1858
|
if (transactions.some((t) => t.docChanged)) pendingMove = null;
|
|
1747
1859
|
return null;
|
|
1748
1860
|
}
|
|
1749
|
-
if (_optionalChain([editorView, 'optionalAccess',
|
|
1861
|
+
if (_optionalChain([editorView, 'optionalAccess', _83 => _83.composing]) && transactions.some((t) => t.docChanged)) {
|
|
1750
1862
|
if (tracking) {
|
|
1751
1863
|
if (!pending) pending = { oldState, transactions: [] };
|
|
1752
1864
|
pending.transactions.push(...transactions);
|
|
@@ -1761,7 +1873,7 @@ var TrackChanges = _core.Extension.create({
|
|
|
1761
1873
|
pending = null;
|
|
1762
1874
|
}
|
|
1763
1875
|
if (!tracking && trs === transactions) return null;
|
|
1764
|
-
const author = _nullishCoalesce(_optionalChain([plugin, 'optionalAccess',
|
|
1876
|
+
const author = _nullishCoalesce(_optionalChain([plugin, 'optionalAccess', _84 => _84.author]), () => ( options.author));
|
|
1765
1877
|
const userTransactions = trs.filter((t) => !shouldSkip(t));
|
|
1766
1878
|
let moves;
|
|
1767
1879
|
if (userTransactions.length) {
|
|
@@ -1784,7 +1896,7 @@ var TrackChanges = _core.Extension.create({
|
|
|
1784
1896
|
ignoredAttributes,
|
|
1785
1897
|
moves
|
|
1786
1898
|
});
|
|
1787
|
-
if (_optionalChain([moves, 'optionalAccess',
|
|
1899
|
+
if (_optionalChain([moves, 'optionalAccess', _85 => _85.cut])) pendingMove = moves.cut;
|
|
1788
1900
|
return result;
|
|
1789
1901
|
},
|
|
1790
1902
|
props: {
|
|
@@ -1847,4 +1959,4 @@ var TrackChanges = _core.Extension.create({
|
|
|
1847
1959
|
|
|
1848
1960
|
|
|
1849
1961
|
exports.createReviewId = createReviewId; exports.CommentStore = CommentStore; exports.createCommentStore = createCommentStore; exports.formatReviewTime = formatReviewTime; exports.INSERTION_MARK_NAME = INSERTION_MARK_NAME; exports.DELETION_MARK_NAME = DELETION_MARK_NAME; exports.FORMAT_CHANGE_MARK_NAME = FORMAT_CHANGE_MARK_NAME; exports.BLOCK_CHANGE_ATTRIBUTE = BLOCK_CHANGE_ATTRIBUTE; exports.MOVE_ID_ATTRIBUTE = MOVE_ID_ATTRIBUTE; exports.TRACK_CHANGES_SKIP_META = TRACK_CHANGES_SKIP_META; exports.TrackChangesStore = TrackChangesStore; exports.trackChangesPluginKey = trackChangesPluginKey; exports.MOVE_TO_CLASS = MOVE_TO_CLASS; exports.MOVE_FROM_CLASS = MOVE_FROM_CLASS; exports.TrackedInsertion = TrackedInsertion; exports.TrackedDeletion = TrackedDeletion; exports.TrackedFormatChange = TrackedFormatChange; exports.describeFormatChange = describeFormatChange; exports.describeBlockChange = describeBlockChange; exports.trackedChangeLabel = trackedChangeLabel; exports.getTrackedChanges = getTrackedChanges; exports.getTrackedChangeAt = getTrackedChangeAt; exports.isTrackChangesEnabled = isTrackChangesEnabled; exports.getTrackChangesStore = getTrackChangesStore; exports.resolveTrackedChanges = resolveTrackedChanges; exports.isMoveSized = isMoveSized; exports.TrackChanges = TrackChanges;
|
|
1850
|
-
//# sourceMappingURL=chunk-
|
|
1962
|
+
//# sourceMappingURL=chunk-IFHKKVXH.cjs.map
|