@harbour-enterprises/superdoc 0.8.11 → 0.8.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.
- package/dist/chunks/{super-editor.es-DIeHC3Si.js → super-editor.es-D8IC7SPE.js} +239 -211
- package/dist/chunks/{super-editor.es-DIeHC3Si.js.map → super-editor.es-D8IC7SPE.js.map} +1 -1
- package/dist/super-editor/chunks/{converter-CVSaF15S.js → converter-vMwuPcFT.js} +3 -3
- package/dist/super-editor/chunks/{converter-CVSaF15S.js.map → converter-vMwuPcFT.js.map} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-BHwY_rz6.js → docx-zipper-CNguQWs9.js} +2 -2
- package/dist/super-editor/chunks/{docx-zipper-BHwY_rz6.js.map → docx-zipper-CNguQWs9.js.map} +1 -1
- package/dist/super-editor/chunks/{editor-H6Apbtdi.js → editor-aREw3zbp.js} +239 -211
- package/dist/super-editor/chunks/editor-aREw3zbp.js.map +1 -0
- package/dist/super-editor/chunks/{toolbar-D9ELD8Tt.js → toolbar-BQJNZhd8.js} +3 -3
- package/dist/super-editor/chunks/{toolbar-D9ELD8Tt.js.map → toolbar-BQJNZhd8.js.map} +1 -1
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/extensions/comment/comments-plugin.d.ts.map +1 -1
- package/dist/super-editor/extensions/track-changes/trackChangesHelpers/addMarkStep.d.ts.map +1 -1
- package/dist/super-editor/extensions/track-changes/trackChangesHelpers/removeMarkStep.d.ts.map +1 -1
- package/dist/super-editor/extensions/track-changes/trackChangesHelpers/replaceStep.d.ts.map +1 -1
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.es.js +3 -3
- package/dist/superdoc.umd.js +239 -211
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/chunks/editor-H6Apbtdi.js.map +0 -1
|
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
12
12
|
var _events, _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _commandService, _css, _Editor_instances, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, _FieldAnnotationView_instances, createAnnotation_fn;
|
|
13
13
|
import * as Y from "yjs";
|
|
14
14
|
import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement } from "yjs";
|
|
15
|
-
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, f as Schema$1, i as isRegExp, g as canSplit, l as liftTarget, h as canJoin, j as joinPoint, r as replaceStep$1, R as ReplaceAroundStep, o as objectIncludes, k as ReplaceStep, m as NodeRange, n as findWrapping, q as TrackDeleteMarkName, s as TrackInsertMarkName, v as v4, t as generateDocxRandomId, u as generateRandom32BitHex, w as TrackFormatMarkName, x as comments_module_events, y as AddMarkStep, z as RemoveMarkStep, B as twipsToLines, C as pixelsToTwips, E as SuperConverter, G as EditorState, H as toKebabCase, I as kebabCase, J as SelectionRange, K as Transform } from "./converter-
|
|
15
|
+
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, f as Schema$1, i as isRegExp, g as canSplit, l as liftTarget, h as canJoin, j as joinPoint, r as replaceStep$1, R as ReplaceAroundStep, o as objectIncludes, k as ReplaceStep, m as NodeRange, n as findWrapping, q as TrackDeleteMarkName, s as TrackInsertMarkName, v as v4, t as generateDocxRandomId, u as generateRandom32BitHex, w as TrackFormatMarkName, x as comments_module_events, y as AddMarkStep, z as RemoveMarkStep, B as twipsToLines, C as pixelsToTwips, E as SuperConverter, G as EditorState, H as toKebabCase, I as kebabCase, J as SelectionRange, K as Transform } from "./converter-vMwuPcFT.js";
|
|
16
16
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
17
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
17
|
+
import { D as DocxZipper } from "./docx-zipper-CNguQWs9.js";
|
|
18
18
|
function getMarksFromSelection(state) {
|
|
19
19
|
const { from: from2, to, empty: empty2 } = state.selection;
|
|
20
20
|
const marks = [];
|
|
@@ -10558,199 +10558,6 @@ const getTrackChangesDecorations = (state, onlyOriginalShown, onlyModifiedShown)
|
|
|
10558
10558
|
});
|
|
10559
10559
|
return DecorationSet.create(state.doc, decorations);
|
|
10560
10560
|
};
|
|
10561
|
-
const replaceStep = ({ state, tr, step, newTr, map: map2, doc: doc2, user, date, originalStep, originalStepIndex }) => {
|
|
10562
|
-
const deletionMarkSchema = state.schema.marks[TrackDeleteMarkName];
|
|
10563
|
-
const deletionMark = findMark(state, deletionMarkSchema, false);
|
|
10564
|
-
const positionTo = deletionMark ? deletionMark.to : step.to;
|
|
10565
|
-
const newStep = new ReplaceStep(
|
|
10566
|
-
positionTo,
|
|
10567
|
-
// We insert all the same steps, but with "from"/"to" both set to "to" in order not to delete content. Mapped as needed.
|
|
10568
|
-
positionTo,
|
|
10569
|
-
step.slice,
|
|
10570
|
-
step.structure
|
|
10571
|
-
);
|
|
10572
|
-
const invertStep = originalStep.invert(tr.docs[originalStepIndex]).map(map2);
|
|
10573
|
-
map2.appendMap(invertStep.getMap());
|
|
10574
|
-
const meta = {};
|
|
10575
|
-
if (newStep) {
|
|
10576
|
-
const trTemp = state.apply(newTr).tr;
|
|
10577
|
-
if (trTemp.maybeStep(newStep).failed) {
|
|
10578
|
-
return;
|
|
10579
|
-
}
|
|
10580
|
-
const mappedNewStepTo = newStep.getMap().map(newStep.to);
|
|
10581
|
-
const insertedMark = markInsertion({
|
|
10582
|
-
tr: trTemp,
|
|
10583
|
-
from: newStep.from,
|
|
10584
|
-
to: mappedNewStepTo,
|
|
10585
|
-
user,
|
|
10586
|
-
date
|
|
10587
|
-
});
|
|
10588
|
-
const condensedStep = new ReplaceStep(newStep.from, newStep.to, trTemp.doc.slice(newStep.from, mappedNewStepTo));
|
|
10589
|
-
newTr.step(condensedStep);
|
|
10590
|
-
const mirrorIndex = map2.maps.length - 1;
|
|
10591
|
-
map2.appendMap(condensedStep.getMap(), mirrorIndex);
|
|
10592
|
-
if (newStep.from !== mappedNewStepTo) {
|
|
10593
|
-
meta.insertedMark = insertedMark;
|
|
10594
|
-
meta.step = condensedStep;
|
|
10595
|
-
}
|
|
10596
|
-
if (!newTr.selection.eq(trTemp.selection)) {
|
|
10597
|
-
newTr.setSelection(trTemp.selection);
|
|
10598
|
-
}
|
|
10599
|
-
}
|
|
10600
|
-
if (step.from !== step.to) {
|
|
10601
|
-
const { deletionMark: deletionMark2, deletionMap, nodes: deletionNodes } = markDeletion({
|
|
10602
|
-
tr: newTr,
|
|
10603
|
-
from: step.from,
|
|
10604
|
-
to: step.to,
|
|
10605
|
-
user,
|
|
10606
|
-
date
|
|
10607
|
-
});
|
|
10608
|
-
meta.deletionNodes = deletionNodes;
|
|
10609
|
-
meta.deletionMark = deletionMark2;
|
|
10610
|
-
map2.appendMapping(deletionMap);
|
|
10611
|
-
}
|
|
10612
|
-
newTr.setMeta(TrackChangesBasePluginKey, meta);
|
|
10613
|
-
};
|
|
10614
|
-
const markWrapping = () => {
|
|
10615
|
-
};
|
|
10616
|
-
const replaceAroundStep = () => {
|
|
10617
|
-
};
|
|
10618
|
-
const addMarkStep = ({ state, tr, step, newTr, map: map2, doc: doc2, user, date }) => {
|
|
10619
|
-
const meta = {};
|
|
10620
|
-
doc2.nodesBetween(step.from, step.to, (node, pos) => {
|
|
10621
|
-
if (!node.isInline) {
|
|
10622
|
-
return;
|
|
10623
|
-
}
|
|
10624
|
-
if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
|
|
10625
|
-
return false;
|
|
10626
|
-
}
|
|
10627
|
-
const existingChangeMark = node.marks.find((mark) => [TrackDeleteMarkName, TrackFormatMarkName].includes(mark.type.name));
|
|
10628
|
-
const wid = existingChangeMark ? existingChangeMark.attrs.id : v4();
|
|
10629
|
-
newTr.addMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), step.mark);
|
|
10630
|
-
const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
|
|
10631
|
-
if (allowedMarks.includes(step.mark.type.name) && !node.marks.find((mark) => mark.type === step.mark.type)) {
|
|
10632
|
-
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
|
|
10633
|
-
let after = [];
|
|
10634
|
-
let before = [];
|
|
10635
|
-
if (formatChangeMark) {
|
|
10636
|
-
let foundBefore = formatChangeMark.attrs.before.find((mark) => {
|
|
10637
|
-
if (mark.type === "textStyle") {
|
|
10638
|
-
return mark.type === step.mark.type.name && objectIncludes(mark.attrs, step.mark.attrs);
|
|
10639
|
-
}
|
|
10640
|
-
return mark.type === step.mark.type.name;
|
|
10641
|
-
});
|
|
10642
|
-
if (foundBefore) {
|
|
10643
|
-
before = [...formatChangeMark.attrs.before.filter((mark) => mark.type !== step.mark.type.name)];
|
|
10644
|
-
after = [...formatChangeMark.attrs.after];
|
|
10645
|
-
} else {
|
|
10646
|
-
before = [...formatChangeMark.attrs.before];
|
|
10647
|
-
after = [
|
|
10648
|
-
...formatChangeMark.attrs.after,
|
|
10649
|
-
{
|
|
10650
|
-
type: step.mark.type.name,
|
|
10651
|
-
attrs: { ...step.mark.attrs }
|
|
10652
|
-
}
|
|
10653
|
-
];
|
|
10654
|
-
}
|
|
10655
|
-
} else {
|
|
10656
|
-
before = node.marks.map((mark) => ({
|
|
10657
|
-
type: mark.type.name,
|
|
10658
|
-
attrs: { ...mark.attrs }
|
|
10659
|
-
}));
|
|
10660
|
-
after = [
|
|
10661
|
-
{
|
|
10662
|
-
type: step.mark.type.name,
|
|
10663
|
-
attrs: { ...step.mark.attrs }
|
|
10664
|
-
}
|
|
10665
|
-
];
|
|
10666
|
-
}
|
|
10667
|
-
if (after.length || before.length) {
|
|
10668
|
-
const newFormatMark = state.schema.marks[TrackFormatMarkName].create({
|
|
10669
|
-
id: wid,
|
|
10670
|
-
author: user.name,
|
|
10671
|
-
authorEmail: user.email,
|
|
10672
|
-
date,
|
|
10673
|
-
before,
|
|
10674
|
-
after
|
|
10675
|
-
});
|
|
10676
|
-
newTr.addMark(
|
|
10677
|
-
step.from,
|
|
10678
|
-
// Math.max(step.from, pos)
|
|
10679
|
-
step.to,
|
|
10680
|
-
// Math.min(step.to, pos + node.nodeSize),
|
|
10681
|
-
newFormatMark
|
|
10682
|
-
);
|
|
10683
|
-
meta.formatMark = newFormatMark;
|
|
10684
|
-
meta.step = step;
|
|
10685
|
-
newTr.setMeta(TrackChangesBasePluginKey, meta);
|
|
10686
|
-
} else if (formatChangeMark) {
|
|
10687
|
-
newTr.removeMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), formatChangeMark);
|
|
10688
|
-
}
|
|
10689
|
-
}
|
|
10690
|
-
});
|
|
10691
|
-
};
|
|
10692
|
-
const removeMarkStep = ({ state, tr, step, newTr, map: map2, doc: doc2, user, date }) => {
|
|
10693
|
-
const meta = {};
|
|
10694
|
-
doc2.nodesBetween(step.from, step.to, (node, pos) => {
|
|
10695
|
-
if (!node.isInline) {
|
|
10696
|
-
return true;
|
|
10697
|
-
}
|
|
10698
|
-
if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
|
|
10699
|
-
return false;
|
|
10700
|
-
}
|
|
10701
|
-
newTr.removeMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), step.mark);
|
|
10702
|
-
const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
|
|
10703
|
-
if (allowedMarks.includes(step.mark.type.name) && node.marks.find((mark) => mark.type === step.mark.type)) {
|
|
10704
|
-
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
|
|
10705
|
-
let after = [];
|
|
10706
|
-
let before = [];
|
|
10707
|
-
if (formatChangeMark) {
|
|
10708
|
-
let foundAfter = formatChangeMark.attrs.after.find((mark) => mark.type === step.mark.type.name);
|
|
10709
|
-
if (foundAfter) {
|
|
10710
|
-
after = [...formatChangeMark.attrs.after.filter((mark) => mark.type !== step.mark.type.name)];
|
|
10711
|
-
before = [...formatChangeMark.attrs.before];
|
|
10712
|
-
} else {
|
|
10713
|
-
after = [...formatChangeMark.attrs.after];
|
|
10714
|
-
before = [
|
|
10715
|
-
...formatChangeMark.attrs.before,
|
|
10716
|
-
{
|
|
10717
|
-
type: step.mark.type.name,
|
|
10718
|
-
attrs: { ...step.mark.attrs }
|
|
10719
|
-
}
|
|
10720
|
-
];
|
|
10721
|
-
}
|
|
10722
|
-
} else {
|
|
10723
|
-
after = [];
|
|
10724
|
-
before = [
|
|
10725
|
-
{
|
|
10726
|
-
type: step.mark.type.name,
|
|
10727
|
-
attrs: { ...step.mark.attrs }
|
|
10728
|
-
}
|
|
10729
|
-
];
|
|
10730
|
-
}
|
|
10731
|
-
if (after.length || before.length) {
|
|
10732
|
-
const newFormatMark = state.schema.marks[TrackFormatMarkName].create({
|
|
10733
|
-
id: v4(),
|
|
10734
|
-
author: user.name,
|
|
10735
|
-
authorEmail: user.email,
|
|
10736
|
-
date,
|
|
10737
|
-
before,
|
|
10738
|
-
after
|
|
10739
|
-
});
|
|
10740
|
-
newTr.addMark(
|
|
10741
|
-
Math.max(step.from, pos),
|
|
10742
|
-
Math.min(step.to, pos + node.nodeSize),
|
|
10743
|
-
newFormatMark
|
|
10744
|
-
);
|
|
10745
|
-
meta.formatMark = newFormatMark;
|
|
10746
|
-
meta.step = step;
|
|
10747
|
-
newTr.setMeta(TrackChangesBasePluginKey, meta);
|
|
10748
|
-
} else if (formatChangeMark) {
|
|
10749
|
-
newTr.removeMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), formatChangeMark);
|
|
10750
|
-
}
|
|
10751
|
-
}
|
|
10752
|
-
});
|
|
10753
|
-
};
|
|
10754
10561
|
const CommentMarkName = "commentMark";
|
|
10755
10562
|
const removeCommentsById = ({ commentId, state, tr, dispatch }) => {
|
|
10756
10563
|
const positions = getCommentPositionsById(commentId, state.doc);
|
|
@@ -11157,7 +10964,7 @@ const CommentsPlugin = Extension.create({
|
|
|
11157
10964
|
update(view, prevState) {
|
|
11158
10965
|
const { state } = view;
|
|
11159
10966
|
const { doc: doc2, tr } = state;
|
|
11160
|
-
if (prevDoc && prevDoc.eq(doc2)) shouldUpdate = true;
|
|
10967
|
+
if (prevDoc && !prevDoc.eq(doc2)) shouldUpdate = true;
|
|
11161
10968
|
if (!shouldUpdate) return;
|
|
11162
10969
|
prevDoc = doc2;
|
|
11163
10970
|
shouldUpdate = false;
|
|
@@ -11191,10 +10998,14 @@ const CommentsPlugin = Extension.create({
|
|
|
11191
10998
|
if (hasActive && activeThreadId !== threadId) return;
|
|
11192
10999
|
decorations.push(deco);
|
|
11193
11000
|
});
|
|
11194
|
-
const
|
|
11195
|
-
|
|
11001
|
+
const trackedChangeMark = findTrackedMark({
|
|
11002
|
+
doc: doc2,
|
|
11003
|
+
from: pos,
|
|
11004
|
+
to: pos + node.nodeSize
|
|
11005
|
+
});
|
|
11006
|
+
if (trackedChangeMark) {
|
|
11196
11007
|
const currentBounds = view.coordsAtPos(pos);
|
|
11197
|
-
const { id } =
|
|
11008
|
+
const { id } = trackedChangeMark.mark.attrs;
|
|
11198
11009
|
updatePosition({
|
|
11199
11010
|
allCommentPositions,
|
|
11200
11011
|
threadId: id,
|
|
@@ -11262,9 +11073,13 @@ const getActiveCommentId = (doc2, selection) => {
|
|
|
11262
11073
|
if ($from.pos !== $to.pos) return;
|
|
11263
11074
|
const nodeAtPos = doc2.nodeAt($from.pos);
|
|
11264
11075
|
if (!nodeAtPos) return;
|
|
11265
|
-
const
|
|
11266
|
-
|
|
11267
|
-
|
|
11076
|
+
const trackedChangeMark = findTrackedMark({
|
|
11077
|
+
doc: doc2,
|
|
11078
|
+
from: $from.pos,
|
|
11079
|
+
to: $to.pos
|
|
11080
|
+
});
|
|
11081
|
+
if (trackedChangeMark) {
|
|
11082
|
+
return trackedChangeMark.mark.attrs.id;
|
|
11268
11083
|
}
|
|
11269
11084
|
const overlaps = [];
|
|
11270
11085
|
let found = false;
|
|
@@ -11301,13 +11116,30 @@ const getActiveCommentId = (doc2, selection) => {
|
|
|
11301
11116
|
const closestCommentMark = closestMarks.find((mark) => mark.type.name === CommentMarkName);
|
|
11302
11117
|
return closestCommentMark?.attrs?.commentId || closestCommentMark?.attrs?.importedId;
|
|
11303
11118
|
};
|
|
11304
|
-
const
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
11310
|
-
|
|
11119
|
+
const findTrackedMark = ({
|
|
11120
|
+
doc: doc2,
|
|
11121
|
+
from: from2,
|
|
11122
|
+
to,
|
|
11123
|
+
offset: offset2 = 1
|
|
11124
|
+
// To get non-inclusive marks.
|
|
11125
|
+
}) => {
|
|
11126
|
+
const startPos = Math.max(from2 - offset2, 0);
|
|
11127
|
+
const endPos = Math.min(to + offset2, doc2.content.size);
|
|
11128
|
+
let markFound;
|
|
11129
|
+
doc2.nodesBetween(startPos, endPos, (node, pos) => {
|
|
11130
|
+
if (!node || node?.nodeSize === void 0) {
|
|
11131
|
+
return;
|
|
11132
|
+
}
|
|
11133
|
+
const mark = node.marks.find((mark2) => TRACK_CHANGE_MARKS.includes(mark2.type.name));
|
|
11134
|
+
if (mark && !markFound) {
|
|
11135
|
+
markFound = {
|
|
11136
|
+
from: pos,
|
|
11137
|
+
to: pos + node.nodeSize,
|
|
11138
|
+
mark
|
|
11139
|
+
};
|
|
11140
|
+
}
|
|
11141
|
+
});
|
|
11142
|
+
return markFound;
|
|
11311
11143
|
};
|
|
11312
11144
|
const handleTrackedChangeTransaction = (trackedChangeMeta, trackedChanges, newEditorState, editor) => {
|
|
11313
11145
|
const {
|
|
@@ -11447,6 +11279,202 @@ function findNode$1(node, predicate) {
|
|
|
11447
11279
|
});
|
|
11448
11280
|
return found;
|
|
11449
11281
|
}
|
|
11282
|
+
const replaceStep = ({ state, tr, step, newTr, map: map2, doc: doc2, user, date, originalStep, originalStepIndex }) => {
|
|
11283
|
+
const deletionMarkSchema = state.schema.marks[TrackDeleteMarkName];
|
|
11284
|
+
const deletionMark = findMark(state, deletionMarkSchema, false);
|
|
11285
|
+
const positionTo = deletionMark ? deletionMark.to : step.to;
|
|
11286
|
+
const newStep = new ReplaceStep(
|
|
11287
|
+
positionTo,
|
|
11288
|
+
// We insert all the same steps, but with "from"/"to" both set to "to" in order not to delete content. Mapped as needed.
|
|
11289
|
+
positionTo,
|
|
11290
|
+
step.slice,
|
|
11291
|
+
step.structure
|
|
11292
|
+
);
|
|
11293
|
+
const invertStep = originalStep.invert(tr.docs[originalStepIndex]).map(map2);
|
|
11294
|
+
map2.appendMap(invertStep.getMap());
|
|
11295
|
+
const meta = {};
|
|
11296
|
+
if (newStep) {
|
|
11297
|
+
const trTemp = state.apply(newTr).tr;
|
|
11298
|
+
if (trTemp.maybeStep(newStep).failed) {
|
|
11299
|
+
return;
|
|
11300
|
+
}
|
|
11301
|
+
const mappedNewStepTo = newStep.getMap().map(newStep.to);
|
|
11302
|
+
const insertedMark = markInsertion({
|
|
11303
|
+
tr: trTemp,
|
|
11304
|
+
from: newStep.from,
|
|
11305
|
+
to: mappedNewStepTo,
|
|
11306
|
+
user,
|
|
11307
|
+
date
|
|
11308
|
+
});
|
|
11309
|
+
const condensedStep = new ReplaceStep(newStep.from, newStep.to, trTemp.doc.slice(newStep.from, mappedNewStepTo));
|
|
11310
|
+
newTr.step(condensedStep);
|
|
11311
|
+
const mirrorIndex = map2.maps.length - 1;
|
|
11312
|
+
map2.appendMap(condensedStep.getMap(), mirrorIndex);
|
|
11313
|
+
if (newStep.from !== mappedNewStepTo) {
|
|
11314
|
+
meta.insertedMark = insertedMark;
|
|
11315
|
+
meta.step = condensedStep;
|
|
11316
|
+
}
|
|
11317
|
+
if (!newTr.selection.eq(trTemp.selection)) {
|
|
11318
|
+
newTr.setSelection(trTemp.selection);
|
|
11319
|
+
}
|
|
11320
|
+
}
|
|
11321
|
+
if (step.from !== step.to) {
|
|
11322
|
+
const { deletionMark: deletionMark2, deletionMap, nodes: deletionNodes } = markDeletion({
|
|
11323
|
+
tr: newTr,
|
|
11324
|
+
from: step.from,
|
|
11325
|
+
to: step.to,
|
|
11326
|
+
user,
|
|
11327
|
+
date
|
|
11328
|
+
});
|
|
11329
|
+
meta.deletionNodes = deletionNodes;
|
|
11330
|
+
meta.deletionMark = deletionMark2;
|
|
11331
|
+
map2.appendMapping(deletionMap);
|
|
11332
|
+
}
|
|
11333
|
+
newTr.setMeta(TrackChangesBasePluginKey, meta);
|
|
11334
|
+
newTr.setMeta(CommentsPluginKey, { type: "force" });
|
|
11335
|
+
};
|
|
11336
|
+
const markWrapping = () => {
|
|
11337
|
+
};
|
|
11338
|
+
const replaceAroundStep = () => {
|
|
11339
|
+
};
|
|
11340
|
+
const addMarkStep = ({ state, tr, step, newTr, map: map2, doc: doc2, user, date }) => {
|
|
11341
|
+
const meta = {};
|
|
11342
|
+
doc2.nodesBetween(step.from, step.to, (node, pos) => {
|
|
11343
|
+
if (!node.isInline) {
|
|
11344
|
+
return;
|
|
11345
|
+
}
|
|
11346
|
+
if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
|
|
11347
|
+
return false;
|
|
11348
|
+
}
|
|
11349
|
+
const existingChangeMark = node.marks.find((mark) => [TrackDeleteMarkName, TrackFormatMarkName].includes(mark.type.name));
|
|
11350
|
+
const wid = existingChangeMark ? existingChangeMark.attrs.id : v4();
|
|
11351
|
+
newTr.addMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), step.mark);
|
|
11352
|
+
const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
|
|
11353
|
+
if (allowedMarks.includes(step.mark.type.name) && !node.marks.find((mark) => mark.type === step.mark.type)) {
|
|
11354
|
+
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
|
|
11355
|
+
let after = [];
|
|
11356
|
+
let before = [];
|
|
11357
|
+
if (formatChangeMark) {
|
|
11358
|
+
let foundBefore = formatChangeMark.attrs.before.find((mark) => {
|
|
11359
|
+
if (mark.type === "textStyle") {
|
|
11360
|
+
return mark.type === step.mark.type.name && objectIncludes(mark.attrs, step.mark.attrs);
|
|
11361
|
+
}
|
|
11362
|
+
return mark.type === step.mark.type.name;
|
|
11363
|
+
});
|
|
11364
|
+
if (foundBefore) {
|
|
11365
|
+
before = [...formatChangeMark.attrs.before.filter((mark) => mark.type !== step.mark.type.name)];
|
|
11366
|
+
after = [...formatChangeMark.attrs.after];
|
|
11367
|
+
} else {
|
|
11368
|
+
before = [...formatChangeMark.attrs.before];
|
|
11369
|
+
after = [
|
|
11370
|
+
...formatChangeMark.attrs.after,
|
|
11371
|
+
{
|
|
11372
|
+
type: step.mark.type.name,
|
|
11373
|
+
attrs: { ...step.mark.attrs }
|
|
11374
|
+
}
|
|
11375
|
+
];
|
|
11376
|
+
}
|
|
11377
|
+
} else {
|
|
11378
|
+
before = node.marks.map((mark) => ({
|
|
11379
|
+
type: mark.type.name,
|
|
11380
|
+
attrs: { ...mark.attrs }
|
|
11381
|
+
}));
|
|
11382
|
+
after = [
|
|
11383
|
+
{
|
|
11384
|
+
type: step.mark.type.name,
|
|
11385
|
+
attrs: { ...step.mark.attrs }
|
|
11386
|
+
}
|
|
11387
|
+
];
|
|
11388
|
+
}
|
|
11389
|
+
if (after.length || before.length) {
|
|
11390
|
+
const newFormatMark = state.schema.marks[TrackFormatMarkName].create({
|
|
11391
|
+
id: wid,
|
|
11392
|
+
author: user.name,
|
|
11393
|
+
authorEmail: user.email,
|
|
11394
|
+
date,
|
|
11395
|
+
before,
|
|
11396
|
+
after
|
|
11397
|
+
});
|
|
11398
|
+
newTr.addMark(
|
|
11399
|
+
step.from,
|
|
11400
|
+
// Math.max(step.from, pos)
|
|
11401
|
+
step.to,
|
|
11402
|
+
// Math.min(step.to, pos + node.nodeSize),
|
|
11403
|
+
newFormatMark
|
|
11404
|
+
);
|
|
11405
|
+
meta.formatMark = newFormatMark;
|
|
11406
|
+
meta.step = step;
|
|
11407
|
+
newTr.setMeta(TrackChangesBasePluginKey, meta);
|
|
11408
|
+
newTr.setMeta(CommentsPluginKey, { type: "force" });
|
|
11409
|
+
} else if (formatChangeMark) {
|
|
11410
|
+
newTr.removeMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), formatChangeMark);
|
|
11411
|
+
}
|
|
11412
|
+
}
|
|
11413
|
+
});
|
|
11414
|
+
};
|
|
11415
|
+
const removeMarkStep = ({ state, tr, step, newTr, map: map2, doc: doc2, user, date }) => {
|
|
11416
|
+
const meta = {};
|
|
11417
|
+
doc2.nodesBetween(step.from, step.to, (node, pos) => {
|
|
11418
|
+
if (!node.isInline) {
|
|
11419
|
+
return true;
|
|
11420
|
+
}
|
|
11421
|
+
if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
|
|
11422
|
+
return false;
|
|
11423
|
+
}
|
|
11424
|
+
newTr.removeMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), step.mark);
|
|
11425
|
+
const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
|
|
11426
|
+
if (allowedMarks.includes(step.mark.type.name) && node.marks.find((mark) => mark.type === step.mark.type)) {
|
|
11427
|
+
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
|
|
11428
|
+
let after = [];
|
|
11429
|
+
let before = [];
|
|
11430
|
+
if (formatChangeMark) {
|
|
11431
|
+
let foundAfter = formatChangeMark.attrs.after.find((mark) => mark.type === step.mark.type.name);
|
|
11432
|
+
if (foundAfter) {
|
|
11433
|
+
after = [...formatChangeMark.attrs.after.filter((mark) => mark.type !== step.mark.type.name)];
|
|
11434
|
+
before = [...formatChangeMark.attrs.before];
|
|
11435
|
+
} else {
|
|
11436
|
+
after = [...formatChangeMark.attrs.after];
|
|
11437
|
+
before = [
|
|
11438
|
+
...formatChangeMark.attrs.before,
|
|
11439
|
+
{
|
|
11440
|
+
type: step.mark.type.name,
|
|
11441
|
+
attrs: { ...step.mark.attrs }
|
|
11442
|
+
}
|
|
11443
|
+
];
|
|
11444
|
+
}
|
|
11445
|
+
} else {
|
|
11446
|
+
after = [];
|
|
11447
|
+
before = [
|
|
11448
|
+
{
|
|
11449
|
+
type: step.mark.type.name,
|
|
11450
|
+
attrs: { ...step.mark.attrs }
|
|
11451
|
+
}
|
|
11452
|
+
];
|
|
11453
|
+
}
|
|
11454
|
+
if (after.length || before.length) {
|
|
11455
|
+
const newFormatMark = state.schema.marks[TrackFormatMarkName].create({
|
|
11456
|
+
id: v4(),
|
|
11457
|
+
author: user.name,
|
|
11458
|
+
authorEmail: user.email,
|
|
11459
|
+
date,
|
|
11460
|
+
before,
|
|
11461
|
+
after
|
|
11462
|
+
});
|
|
11463
|
+
newTr.addMark(
|
|
11464
|
+
Math.max(step.from, pos),
|
|
11465
|
+
Math.min(step.to, pos + node.nodeSize),
|
|
11466
|
+
newFormatMark
|
|
11467
|
+
);
|
|
11468
|
+
meta.formatMark = newFormatMark;
|
|
11469
|
+
meta.step = step;
|
|
11470
|
+
newTr.setMeta(TrackChangesBasePluginKey, meta);
|
|
11471
|
+
newTr.setMeta(CommentsPluginKey, { type: "force" });
|
|
11472
|
+
} else if (formatChangeMark) {
|
|
11473
|
+
newTr.removeMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), formatChangeMark);
|
|
11474
|
+
}
|
|
11475
|
+
}
|
|
11476
|
+
});
|
|
11477
|
+
};
|
|
11450
11478
|
const trackedTransaction = ({ tr, state, user }) => {
|
|
11451
11479
|
const onlyInputTypeMeta = ["inputType", "uiEvent", "paste", "pointer"];
|
|
11452
11480
|
const notAllowedMeta = ["historyUndo", "historyRedo", "acceptReject"];
|
|
@@ -12044,7 +12072,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
12044
12072
|
* @returns {Y.Doc | undefined} Updated Y.Doc if any, otherwise undefined
|
|
12045
12073
|
*/
|
|
12046
12074
|
processCollaborationMigrations() {
|
|
12047
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.8.
|
|
12075
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.8.12");
|
|
12048
12076
|
if (!this.options.ydoc) return;
|
|
12049
12077
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
12050
12078
|
let docVersion = metaMap.get("version");
|
|
@@ -23068,4 +23096,4 @@ export {
|
|
|
23068
23096
|
redoDepth as r,
|
|
23069
23097
|
undoDepth as u
|
|
23070
23098
|
};
|
|
23071
|
-
//# sourceMappingURL=editor-
|
|
23099
|
+
//# sourceMappingURL=editor-aREw3zbp.js.map
|