@harbour-enterprises/superdoc 0.28.0-next.13 → 0.28.0-next.15
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/{PdfViewer-BsJq49rR.es.js → PdfViewer-C5N8ds3O.es.js} +1 -1
- package/dist/chunks/{PdfViewer-D8L8mpOs.cjs → PdfViewer-CTJIldpN.cjs} +1 -1
- package/dist/chunks/{index-BNr0wgOU-j0xGZdr7.es.js → index-BNr0wgOU-Bj1k6CCB.es.js} +1 -1
- package/dist/chunks/{index-BNr0wgOU-Bg5kSvF0.cjs → index-BNr0wgOU-DGdWV9Iz.cjs} +1 -1
- package/dist/chunks/{index-x4srxOl3.cjs → index-C2zCd-ai.cjs} +2 -2
- package/dist/chunks/{index-ByV1n--x.es.js → index-DOIFo7ao.es.js} +2 -2
- package/dist/chunks/{super-editor.es-C0LbO3l0.es.js → super-editor.es-CSyQAFrJ.es.js} +505 -89
- package/dist/chunks/{super-editor.es-CANt5-KH.cjs → super-editor.es-DAO9OQ4k.cjs} +505 -89
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +1 -1
- package/dist/super-editor/chunks/{editor-BwNyV6ke.js → editor-DSQC1des.js} +504 -88
- package/dist/super-editor/chunks/{toolbar-Bx1rJX7n.js → toolbar-Dq-rYRTG.js} +1 -1
- package/dist/super-editor/editor.es.js +1 -1
- package/dist/super-editor/super-editor/src/core/helpers/rangeUtils.d.ts +2 -0
- package/dist/super-editor/super-editor/src/extensions/field-annotation/FieldAnnotationPlugin.d.ts +5 -1
- package/dist/super-editor/super-editor/src/extensions/image/imageHelpers/imagePositionPlugin.d.ts +2 -0
- package/dist/super-editor/super-editor/src/extensions/list-item/helpers/listItemTypography.d.ts +5 -0
- package/dist/super-editor/super-editor/src/extensions/list-item/helpers/styledListMarkerPlugin.d.ts +11 -2
- package/dist/super-editor/super-editor.es.js +3 -3
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +504 -88
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -11302,17 +11302,7 @@ const TrackChangesBasePlugin = () => {
|
|
|
11302
11302
|
},
|
|
11303
11303
|
apply(tr, oldState, prevEditorState, newEditorState) {
|
|
11304
11304
|
const meta = tr.getMeta(TrackChangesBasePluginKey);
|
|
11305
|
-
if (
|
|
11306
|
-
return {
|
|
11307
|
-
...oldState,
|
|
11308
|
-
decorations: getTrackChangesDecorations(
|
|
11309
|
-
newEditorState,
|
|
11310
|
-
oldState.onlyOriginalShown,
|
|
11311
|
-
oldState.onlyModifiedShown
|
|
11312
|
-
)
|
|
11313
|
-
};
|
|
11314
|
-
}
|
|
11315
|
-
if (meta.type === "TRACK_CHANGES_ENABLE") {
|
|
11305
|
+
if (meta && meta.type === "TRACK_CHANGES_ENABLE") {
|
|
11316
11306
|
return {
|
|
11317
11307
|
...oldState,
|
|
11318
11308
|
isTrackChangesActive: meta.value === true,
|
|
@@ -11323,7 +11313,7 @@ const TrackChangesBasePlugin = () => {
|
|
|
11323
11313
|
)
|
|
11324
11314
|
};
|
|
11325
11315
|
}
|
|
11326
|
-
if (meta.type === "SHOW_ONLY_ORIGINAL") {
|
|
11316
|
+
if (meta && meta.type === "SHOW_ONLY_ORIGINAL") {
|
|
11327
11317
|
return {
|
|
11328
11318
|
...oldState,
|
|
11329
11319
|
onlyOriginalShown: meta.value === true,
|
|
@@ -11331,7 +11321,7 @@ const TrackChangesBasePlugin = () => {
|
|
|
11331
11321
|
decorations: getTrackChangesDecorations(newEditorState, meta.value === true, false)
|
|
11332
11322
|
};
|
|
11333
11323
|
}
|
|
11334
|
-
if (meta.type === "SHOW_ONLY_MODIFIED") {
|
|
11324
|
+
if (meta && meta.type === "SHOW_ONLY_MODIFIED") {
|
|
11335
11325
|
return {
|
|
11336
11326
|
...oldState,
|
|
11337
11327
|
onlyOriginalShown: false,
|
|
@@ -11339,6 +11329,31 @@ const TrackChangesBasePlugin = () => {
|
|
|
11339
11329
|
decorations: getTrackChangesDecorations(newEditorState, false, meta.value === true)
|
|
11340
11330
|
};
|
|
11341
11331
|
}
|
|
11332
|
+
if (!tr.docChanged) {
|
|
11333
|
+
return oldState;
|
|
11334
|
+
}
|
|
11335
|
+
if (!meta) {
|
|
11336
|
+
let mightAffectTrackChanges = false;
|
|
11337
|
+
tr.steps.forEach((step) => {
|
|
11338
|
+
if (step.slice || step.from !== step.to) {
|
|
11339
|
+
mightAffectTrackChanges = true;
|
|
11340
|
+
}
|
|
11341
|
+
});
|
|
11342
|
+
if (mightAffectTrackChanges) {
|
|
11343
|
+
return {
|
|
11344
|
+
...oldState,
|
|
11345
|
+
decorations: getTrackChangesDecorations(
|
|
11346
|
+
newEditorState,
|
|
11347
|
+
oldState.onlyOriginalShown,
|
|
11348
|
+
oldState.onlyModifiedShown
|
|
11349
|
+
)
|
|
11350
|
+
};
|
|
11351
|
+
}
|
|
11352
|
+
return {
|
|
11353
|
+
...oldState,
|
|
11354
|
+
decorations: oldState.decorations.map(tr.mapping, tr.doc)
|
|
11355
|
+
};
|
|
11356
|
+
}
|
|
11342
11357
|
return {
|
|
11343
11358
|
...oldState,
|
|
11344
11359
|
decorations: getTrackChangesDecorations(
|
|
@@ -12093,6 +12108,7 @@ const CommentsPlugin = Extension.create({
|
|
|
12093
12108
|
view() {
|
|
12094
12109
|
let prevDoc;
|
|
12095
12110
|
let prevActiveThreadId;
|
|
12111
|
+
let prevAllCommentPositions = {};
|
|
12096
12112
|
return {
|
|
12097
12113
|
update(view) {
|
|
12098
12114
|
const { state } = view;
|
|
@@ -12103,16 +12119,19 @@ const CommentsPlugin = Extension.create({
|
|
|
12103
12119
|
if (meta?.type === "setActiveComment" || meta?.forceUpdate) {
|
|
12104
12120
|
shouldUpdate = true;
|
|
12105
12121
|
}
|
|
12106
|
-
|
|
12107
|
-
if (
|
|
12122
|
+
const docChanged = prevDoc && !prevDoc.eq(doc2);
|
|
12123
|
+
if (docChanged) shouldUpdate = true;
|
|
12124
|
+
const activeThreadChanged = prevActiveThreadId !== currentActiveThreadId;
|
|
12125
|
+
if (activeThreadChanged) {
|
|
12108
12126
|
shouldUpdate = true;
|
|
12109
12127
|
prevActiveThreadId = currentActiveThreadId;
|
|
12110
12128
|
}
|
|
12129
|
+
const onlyActiveThreadChanged = !docChanged && activeThreadChanged;
|
|
12111
12130
|
if (!shouldUpdate) return;
|
|
12112
12131
|
prevDoc = doc2;
|
|
12113
12132
|
shouldUpdate = false;
|
|
12114
12133
|
const decorations = [];
|
|
12115
|
-
const allCommentPositions = {};
|
|
12134
|
+
const allCommentPositions = onlyActiveThreadChanged ? prevAllCommentPositions : {};
|
|
12116
12135
|
doc2.descendants((node, pos) => {
|
|
12117
12136
|
const { marks = [] } = node;
|
|
12118
12137
|
const commentMarks = marks.filter((mark) => mark.type.name === CommentMarkName);
|
|
@@ -12120,14 +12139,16 @@ const CommentsPlugin = Extension.create({
|
|
|
12120
12139
|
commentMarks.forEach((commentMark) => {
|
|
12121
12140
|
const { attrs } = commentMark;
|
|
12122
12141
|
const threadId = attrs.commentId || attrs.importedId;
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
|
|
12128
|
-
|
|
12129
|
-
|
|
12130
|
-
|
|
12142
|
+
if (!onlyActiveThreadChanged) {
|
|
12143
|
+
const currentBounds = view.coordsAtPos(pos);
|
|
12144
|
+
updatePosition({
|
|
12145
|
+
allCommentPositions,
|
|
12146
|
+
threadId,
|
|
12147
|
+
pos,
|
|
12148
|
+
currentBounds,
|
|
12149
|
+
node
|
|
12150
|
+
});
|
|
12151
|
+
}
|
|
12131
12152
|
const isInternal = attrs.internal;
|
|
12132
12153
|
if (!hasActive) hasActive = currentActiveThreadId === threadId;
|
|
12133
12154
|
let color = getHighlightColor({
|
|
@@ -12150,20 +12171,22 @@ const CommentsPlugin = Extension.create({
|
|
|
12150
12171
|
to: pos + node.nodeSize
|
|
12151
12172
|
});
|
|
12152
12173
|
if (trackedChangeMark) {
|
|
12153
|
-
|
|
12154
|
-
|
|
12155
|
-
|
|
12156
|
-
|
|
12157
|
-
|
|
12158
|
-
|
|
12159
|
-
|
|
12160
|
-
|
|
12161
|
-
|
|
12162
|
-
|
|
12174
|
+
if (!onlyActiveThreadChanged) {
|
|
12175
|
+
const currentBounds = view.coordsAtPos(pos);
|
|
12176
|
+
const { id } = trackedChangeMark.mark.attrs;
|
|
12177
|
+
updatePosition({
|
|
12178
|
+
allCommentPositions,
|
|
12179
|
+
threadId: id,
|
|
12180
|
+
pos,
|
|
12181
|
+
currentBounds,
|
|
12182
|
+
node
|
|
12183
|
+
});
|
|
12184
|
+
}
|
|
12185
|
+
const isActiveTrackedChange = currentActiveThreadId === trackedChangeMark.mark.attrs.id;
|
|
12163
12186
|
if (isActiveTrackedChange) {
|
|
12164
12187
|
const trackedChangeDeco = Decoration.inline(pos, pos + node.nodeSize, {
|
|
12165
12188
|
style: `border-width: 2px;`,
|
|
12166
|
-
"data-thread-id": id,
|
|
12189
|
+
"data-thread-id": trackedChangeMark.mark.attrs.id,
|
|
12167
12190
|
class: "sd-editor-tracked-change-highlight"
|
|
12168
12191
|
});
|
|
12169
12192
|
decorations.push(trackedChangeDeco);
|
|
@@ -12181,7 +12204,13 @@ const CommentsPlugin = Extension.create({
|
|
|
12181
12204
|
});
|
|
12182
12205
|
view.dispatch(tr2);
|
|
12183
12206
|
}
|
|
12184
|
-
|
|
12207
|
+
if (!onlyActiveThreadChanged) {
|
|
12208
|
+
const positionsChanged = hasPositionsChanged(prevAllCommentPositions, allCommentPositions);
|
|
12209
|
+
if (positionsChanged) {
|
|
12210
|
+
prevAllCommentPositions = allCommentPositions;
|
|
12211
|
+
editor.emit("comment-positions", { allCommentPositions });
|
|
12212
|
+
}
|
|
12213
|
+
}
|
|
12185
12214
|
}
|
|
12186
12215
|
};
|
|
12187
12216
|
}
|
|
@@ -12189,6 +12218,19 @@ const CommentsPlugin = Extension.create({
|
|
|
12189
12218
|
return [commentsPlugin];
|
|
12190
12219
|
}
|
|
12191
12220
|
});
|
|
12221
|
+
const hasPositionsChanged = (prevPositions, currPositions) => {
|
|
12222
|
+
const prevKeys = Object.keys(prevPositions);
|
|
12223
|
+
const currKeys = Object.keys(currPositions);
|
|
12224
|
+
if (prevKeys.length !== currKeys.length) return true;
|
|
12225
|
+
for (const key2 of currKeys) {
|
|
12226
|
+
const prev = prevPositions[key2];
|
|
12227
|
+
const curr = currPositions[key2];
|
|
12228
|
+
if (!prev || prev.top !== curr.top || prev.left !== curr.left) {
|
|
12229
|
+
return true;
|
|
12230
|
+
}
|
|
12231
|
+
}
|
|
12232
|
+
return false;
|
|
12233
|
+
};
|
|
12192
12234
|
const getActiveCommentId = (doc2, selection) => {
|
|
12193
12235
|
if (!selection) return;
|
|
12194
12236
|
const { $from, $to } = selection;
|
|
@@ -19561,8 +19603,36 @@ const createLinkedStylesPlugin = (editor) => {
|
|
|
19561
19603
|
if (!editor.converter || editor.options.mode !== "docx") return { ...prev };
|
|
19562
19604
|
let decorations = prev.decorations || DecorationSet.empty;
|
|
19563
19605
|
if (tr.docChanged) {
|
|
19564
|
-
|
|
19565
|
-
|
|
19606
|
+
let mightAffectStyles = false;
|
|
19607
|
+
const styleRelatedMarks = /* @__PURE__ */ new Set(["textStyle", "bold", "italic", "underline", "strike"]);
|
|
19608
|
+
tr.steps.forEach((step) => {
|
|
19609
|
+
if (step.slice) {
|
|
19610
|
+
step.slice.content.descendants((node) => {
|
|
19611
|
+
if (node.attrs?.styleId) {
|
|
19612
|
+
mightAffectStyles = true;
|
|
19613
|
+
return false;
|
|
19614
|
+
}
|
|
19615
|
+
if (node.marks.length > 0) {
|
|
19616
|
+
const hasStyleMarks = node.marks.some((mark) => styleRelatedMarks.has(mark.type.name));
|
|
19617
|
+
if (hasStyleMarks) {
|
|
19618
|
+
mightAffectStyles = true;
|
|
19619
|
+
return false;
|
|
19620
|
+
}
|
|
19621
|
+
}
|
|
19622
|
+
});
|
|
19623
|
+
}
|
|
19624
|
+
if (step.jsonID === "addMark" || step.jsonID === "removeMark") {
|
|
19625
|
+
if (step.mark && styleRelatedMarks.has(step.mark.type.name)) {
|
|
19626
|
+
mightAffectStyles = true;
|
|
19627
|
+
}
|
|
19628
|
+
}
|
|
19629
|
+
});
|
|
19630
|
+
if (mightAffectStyles) {
|
|
19631
|
+
const styles = LinkedStylesPluginKey.getState(editor.state).styles;
|
|
19632
|
+
decorations = generateDecorations(newEditorState, styles);
|
|
19633
|
+
} else {
|
|
19634
|
+
decorations = decorations.map(tr.mapping, tr.doc);
|
|
19635
|
+
}
|
|
19566
19636
|
}
|
|
19567
19637
|
return { ...prev, decorations };
|
|
19568
19638
|
}
|
|
@@ -19875,6 +19945,12 @@ function parseFontFamilyFromRunProperties(listRunProperties) {
|
|
|
19875
19945
|
const eastAsia = listRunProperties?.["w:eastAsia"];
|
|
19876
19946
|
return ascii || hAnsi || eastAsia || null;
|
|
19877
19947
|
}
|
|
19948
|
+
const computedStylesCache = /* @__PURE__ */ new WeakMap();
|
|
19949
|
+
function clearComputedStyleCache(domNode) {
|
|
19950
|
+
if (domNode) {
|
|
19951
|
+
computedStylesCache.delete(domNode);
|
|
19952
|
+
}
|
|
19953
|
+
}
|
|
19878
19954
|
function readNodeViewStyles(view) {
|
|
19879
19955
|
const fallback = { fontSize: null, fontFamily: null, lineHeight: null };
|
|
19880
19956
|
if (!view?.dom) return fallback;
|
|
@@ -19884,13 +19960,27 @@ function readNodeViewStyles(view) {
|
|
|
19884
19960
|
lineHeight: view.dom.style?.lineHeight || null
|
|
19885
19961
|
};
|
|
19886
19962
|
if (inline.fontSize && inline.fontFamily && inline.lineHeight) return inline;
|
|
19963
|
+
if (computedStylesCache.has(view.dom)) {
|
|
19964
|
+
const cached = computedStylesCache.get(view.dom);
|
|
19965
|
+
return {
|
|
19966
|
+
fontSize: inline.fontSize || cached.fontSize,
|
|
19967
|
+
fontFamily: inline.fontFamily || cached.fontFamily,
|
|
19968
|
+
lineHeight: inline.lineHeight || cached.lineHeight
|
|
19969
|
+
};
|
|
19970
|
+
}
|
|
19887
19971
|
const globalWindow = typeof window !== "undefined" ? window : void 0;
|
|
19888
19972
|
if (globalWindow?.getComputedStyle) {
|
|
19889
19973
|
const computed2 = globalWindow.getComputedStyle(view.dom);
|
|
19974
|
+
const computedStyles = {
|
|
19975
|
+
fontSize: computed2.fontSize,
|
|
19976
|
+
fontFamily: computed2.fontFamily,
|
|
19977
|
+
lineHeight: computed2.lineHeight
|
|
19978
|
+
};
|
|
19979
|
+
computedStylesCache.set(view.dom, computedStyles);
|
|
19890
19980
|
return {
|
|
19891
|
-
fontSize: inline.fontSize ||
|
|
19892
|
-
fontFamily: inline.fontFamily ||
|
|
19893
|
-
lineHeight: inline.lineHeight ||
|
|
19981
|
+
fontSize: inline.fontSize || computedStyles.fontSize,
|
|
19982
|
+
fontFamily: inline.fontFamily || computedStyles.fontFamily,
|
|
19983
|
+
lineHeight: inline.lineHeight || computedStyles.lineHeight
|
|
19894
19984
|
};
|
|
19895
19985
|
}
|
|
19896
19986
|
return inline;
|
|
@@ -20104,9 +20194,14 @@ class ListItemNodeView {
|
|
|
20104
20194
|
});
|
|
20105
20195
|
}
|
|
20106
20196
|
update(node, decorations) {
|
|
20197
|
+
const prevNode = this.node;
|
|
20107
20198
|
this.node = node;
|
|
20108
20199
|
this.decorations = decorations;
|
|
20109
20200
|
this.invalidateResolvedPos();
|
|
20201
|
+
const stylingAttrsChanged = !prevNode || prevNode.attrs.styleId !== node.attrs.styleId || prevNode.attrs.numId !== node.attrs.numId || prevNode.attrs.level !== node.attrs.level;
|
|
20202
|
+
if (stylingAttrsChanged) {
|
|
20203
|
+
clearComputedStyleCache(this.dom);
|
|
20204
|
+
}
|
|
20110
20205
|
const { fontSize, fontFamily, lineHeight } = resolveListItemTypography({
|
|
20111
20206
|
node,
|
|
20112
20207
|
pos: this.getResolvedPos(),
|
|
@@ -20117,11 +20212,15 @@ class ListItemNodeView {
|
|
|
20117
20212
|
this.dom.style.fontSize = fontSize;
|
|
20118
20213
|
this.dom.style.fontFamily = fontFamily || "inherit";
|
|
20119
20214
|
this.dom.style.lineHeight = lineHeight || "";
|
|
20120
|
-
|
|
20215
|
+
const attrsChanged = stylingAttrsChanged || prevNode?.attrs.indent !== node.attrs.indent;
|
|
20216
|
+
if (attrsChanged) {
|
|
20217
|
+
this.refreshIndentStyling();
|
|
20218
|
+
}
|
|
20121
20219
|
}
|
|
20122
20220
|
destroy() {
|
|
20123
20221
|
activeListItemNodeViews.delete(this);
|
|
20124
20222
|
this.numberingDOM.removeEventListener("click", this.handleNumberingClick);
|
|
20223
|
+
clearComputedStyleCache(this.dom);
|
|
20125
20224
|
const caf = typeof globalThis !== "undefined" ? globalThis.cancelAnimationFrame : void 0;
|
|
20126
20225
|
if (this._pendingIndentRefresh != null && typeof caf === "function") {
|
|
20127
20226
|
caf(this._pendingIndentRefresh);
|
|
@@ -20240,8 +20339,11 @@ function calculateMarkerWidth(dom, numberingDOM, editor, { withPadding = true }
|
|
|
20240
20339
|
if (!markerText.trim()) return 0;
|
|
20241
20340
|
try {
|
|
20242
20341
|
if (editor?.options?.isHeadless) return 0;
|
|
20342
|
+
if (typeof globalThis.CanvasRenderingContext2D === "undefined") return 0;
|
|
20243
20343
|
const canvas = document.createElement("canvas");
|
|
20344
|
+
if (typeof canvas.getContext !== "function") return 0;
|
|
20244
20345
|
const context = canvas.getContext("2d");
|
|
20346
|
+
if (!context) return 0;
|
|
20245
20347
|
const fontSizePx = fontSize.includes("pt") ? Number.parseFloat(fontSize) * POINT_TO_PIXEL_CONVERSION_FACTOR : Number.parseFloat(fontSize);
|
|
20246
20348
|
context.font = `${fontSizePx}px ${fontFamily}`;
|
|
20247
20349
|
const textWidth = context.measureText(markerText).width;
|
|
@@ -20260,7 +20362,9 @@ function orderedListSync(editor) {
|
|
|
20260
20362
|
appendTransaction(transactions, oldState, newState) {
|
|
20261
20363
|
if (transactions.every((tr2) => tr2.getMeta("y-sync$"))) return null;
|
|
20262
20364
|
const updateNodeViews = transactions.some((tr2) => tr2.getMeta("updatedListItemNodeViews"));
|
|
20263
|
-
if (updateNodeViews || !hasInitialized)
|
|
20365
|
+
if (updateNodeViews || !hasInitialized) {
|
|
20366
|
+
refreshAllListItemNodeViews();
|
|
20367
|
+
}
|
|
20264
20368
|
const isFromPlugin = transactions.some((tr2) => tr2.getMeta("orderedListSync"));
|
|
20265
20369
|
const docChanged = transactions.some((tr2) => tr2.docChanged) && !oldState.doc.eq(newState.doc);
|
|
20266
20370
|
if (isFromPlugin || !docChanged) {
|
|
@@ -20272,10 +20376,24 @@ function orderedListSync(editor) {
|
|
|
20272
20376
|
const listMap = /* @__PURE__ */ new Map();
|
|
20273
20377
|
const listInitialized = /* @__PURE__ */ new Map();
|
|
20274
20378
|
const shouldProcess = transactions.some((tr2) => {
|
|
20379
|
+
if (tr2.getMeta("updateListSync")) return true;
|
|
20275
20380
|
return tr2.steps.some((step) => {
|
|
20276
20381
|
const stepJSON = step.toJSON();
|
|
20277
|
-
|
|
20278
|
-
|
|
20382
|
+
if (step.slice?.content) {
|
|
20383
|
+
let hasListItem = false;
|
|
20384
|
+
step.slice.content.descendants((node) => {
|
|
20385
|
+
if (node.type.name === "listItem") {
|
|
20386
|
+
hasListItem = true;
|
|
20387
|
+
return false;
|
|
20388
|
+
}
|
|
20389
|
+
});
|
|
20390
|
+
if (hasListItem) return true;
|
|
20391
|
+
}
|
|
20392
|
+
if (stepJSON && stepJSON.slice) {
|
|
20393
|
+
const jsonStr = JSON.stringify(stepJSON);
|
|
20394
|
+
if (jsonStr.includes('"listItem"')) return true;
|
|
20395
|
+
}
|
|
20396
|
+
return false;
|
|
20279
20397
|
});
|
|
20280
20398
|
});
|
|
20281
20399
|
if (!shouldProcess) return null;
|
|
@@ -20745,17 +20863,68 @@ const Paragraph = OxmlNode.create({
|
|
|
20745
20863
|
},
|
|
20746
20864
|
addPmPlugins() {
|
|
20747
20865
|
const { view } = this.editor;
|
|
20866
|
+
const dropcapWidthCache = /* @__PURE__ */ new Map();
|
|
20867
|
+
const hasDropcapParagraph = (node) => node.type.name === "paragraph" && node.attrs.dropcap?.type === "margin";
|
|
20868
|
+
const invalidateCacheForRange = (from2, to) => {
|
|
20869
|
+
for (const [pos] of dropcapWidthCache) {
|
|
20870
|
+
if (pos >= from2 && pos <= to) {
|
|
20871
|
+
dropcapWidthCache.delete(pos);
|
|
20872
|
+
}
|
|
20873
|
+
}
|
|
20874
|
+
};
|
|
20748
20875
|
const dropcapPlugin = new Plugin({
|
|
20749
20876
|
name: "dropcapPlugin",
|
|
20750
20877
|
key: new PluginKey("dropcapPlugin"),
|
|
20751
20878
|
state: {
|
|
20752
20879
|
init(_, state) {
|
|
20753
|
-
|
|
20880
|
+
const decorations = getDropcapDecorations(state, view, dropcapWidthCache);
|
|
20754
20881
|
return DecorationSet.create(state.doc, decorations);
|
|
20755
20882
|
},
|
|
20756
20883
|
apply(tr, oldDecorationSet, oldState, newState) {
|
|
20757
20884
|
if (!tr.docChanged) return oldDecorationSet;
|
|
20758
|
-
|
|
20885
|
+
let hasDropcaps = false;
|
|
20886
|
+
newState.doc.descendants((node) => {
|
|
20887
|
+
if (hasDropcapParagraph(node)) {
|
|
20888
|
+
hasDropcaps = true;
|
|
20889
|
+
return false;
|
|
20890
|
+
}
|
|
20891
|
+
});
|
|
20892
|
+
if (!hasDropcaps) {
|
|
20893
|
+
dropcapWidthCache.clear();
|
|
20894
|
+
return DecorationSet.empty;
|
|
20895
|
+
}
|
|
20896
|
+
let affectsDropcaps = false;
|
|
20897
|
+
tr.steps.forEach((step) => {
|
|
20898
|
+
if (step.slice?.content) {
|
|
20899
|
+
step.slice.content.descendants((node) => {
|
|
20900
|
+
if (hasDropcapParagraph(node)) {
|
|
20901
|
+
affectsDropcaps = true;
|
|
20902
|
+
return false;
|
|
20903
|
+
}
|
|
20904
|
+
});
|
|
20905
|
+
}
|
|
20906
|
+
if (step.jsonID === "replace" && step.from !== void 0 && step.to !== void 0) {
|
|
20907
|
+
try {
|
|
20908
|
+
oldState.doc.nodesBetween(step.from, step.to, (node) => {
|
|
20909
|
+
if (hasDropcapParagraph(node)) {
|
|
20910
|
+
affectsDropcaps = true;
|
|
20911
|
+
return false;
|
|
20912
|
+
}
|
|
20913
|
+
});
|
|
20914
|
+
} catch {
|
|
20915
|
+
affectsDropcaps = true;
|
|
20916
|
+
}
|
|
20917
|
+
}
|
|
20918
|
+
});
|
|
20919
|
+
if (!affectsDropcaps) {
|
|
20920
|
+
return oldDecorationSet.map(tr.mapping, tr.doc);
|
|
20921
|
+
}
|
|
20922
|
+
tr.steps.forEach((step) => {
|
|
20923
|
+
if (step.from !== void 0 && step.to !== void 0) {
|
|
20924
|
+
invalidateCacheForRange(step.from, step.to);
|
|
20925
|
+
}
|
|
20926
|
+
});
|
|
20927
|
+
const decorations = getDropcapDecorations(newState, view, dropcapWidthCache);
|
|
20759
20928
|
return DecorationSet.create(newState.doc, decorations);
|
|
20760
20929
|
}
|
|
20761
20930
|
},
|
|
@@ -20768,12 +20937,12 @@ const Paragraph = OxmlNode.create({
|
|
|
20768
20937
|
return [dropcapPlugin];
|
|
20769
20938
|
}
|
|
20770
20939
|
});
|
|
20771
|
-
const getDropcapDecorations = (state, view) => {
|
|
20772
|
-
|
|
20940
|
+
const getDropcapDecorations = (state, view, widthCache) => {
|
|
20941
|
+
const decorations = [];
|
|
20773
20942
|
state.doc.descendants((node, pos) => {
|
|
20774
20943
|
if (node.type.name === "paragraph") {
|
|
20775
20944
|
if (node.attrs.dropcap?.type === "margin") {
|
|
20776
|
-
const width = getDropcapWidth(view, pos);
|
|
20945
|
+
const width = getDropcapWidth(view, pos, widthCache);
|
|
20777
20946
|
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style: `margin-left: -${width}px;` }));
|
|
20778
20947
|
}
|
|
20779
20948
|
return false;
|
|
@@ -20781,12 +20950,17 @@ const getDropcapDecorations = (state, view) => {
|
|
|
20781
20950
|
});
|
|
20782
20951
|
return decorations;
|
|
20783
20952
|
};
|
|
20784
|
-
function getDropcapWidth(view, pos) {
|
|
20953
|
+
function getDropcapWidth(view, pos, widthCache) {
|
|
20954
|
+
if (widthCache.has(pos)) {
|
|
20955
|
+
return widthCache.get(pos);
|
|
20956
|
+
}
|
|
20785
20957
|
const domNode = view.nodeDOM(pos);
|
|
20786
20958
|
if (domNode) {
|
|
20787
20959
|
const range = document.createRange();
|
|
20788
20960
|
range.selectNodeContents(domNode);
|
|
20789
|
-
|
|
20961
|
+
const width = range.getBoundingClientRect().width;
|
|
20962
|
+
widthCache.set(pos, width);
|
|
20963
|
+
return width;
|
|
20790
20964
|
}
|
|
20791
20965
|
return 0;
|
|
20792
20966
|
}
|
|
@@ -21248,7 +21422,7 @@ const TabNode = Node$1.create({
|
|
|
21248
21422
|
},
|
|
21249
21423
|
addPmPlugins() {
|
|
21250
21424
|
const { view, helpers: helpers2 } = this.editor;
|
|
21251
|
-
const
|
|
21425
|
+
const mergeRanges2 = (ranges) => {
|
|
21252
21426
|
if (ranges.length === 0) return [];
|
|
21253
21427
|
const sorted = ranges.slice().sort((a, b) => a[0] - b[0]);
|
|
21254
21428
|
const merged = [sorted[0]];
|
|
@@ -21321,7 +21495,7 @@ const TabNode = Node$1.create({
|
|
|
21321
21495
|
if (rangesToRecalculate.length === 0) {
|
|
21322
21496
|
return { decorations };
|
|
21323
21497
|
}
|
|
21324
|
-
const mergedRanges =
|
|
21498
|
+
const mergedRanges = mergeRanges2(rangesToRecalculate);
|
|
21325
21499
|
mergedRanges.forEach(([start2, end2]) => {
|
|
21326
21500
|
const oldDecorations = decorations.find(start2, end2);
|
|
21327
21501
|
decorations = decorations.remove(oldDecorations);
|
|
@@ -25224,6 +25398,29 @@ createAnnotation_fn = function({ displayLabel } = {}) {
|
|
|
25224
25398
|
content
|
|
25225
25399
|
};
|
|
25226
25400
|
};
|
|
25401
|
+
const mergeRanges = (ranges) => {
|
|
25402
|
+
if (ranges.length === 0) return [];
|
|
25403
|
+
const sorted = [...ranges].sort((a, b) => a[0] - b[0]).map((range) => [...range]);
|
|
25404
|
+
const merged = [sorted[0]];
|
|
25405
|
+
for (let i = 1; i < sorted.length; i++) {
|
|
25406
|
+
const current = sorted[i];
|
|
25407
|
+
const lastMerged = merged[merged.length - 1];
|
|
25408
|
+
if (current[0] <= lastMerged[1]) {
|
|
25409
|
+
lastMerged[1] = Math.max(lastMerged[1], current[1]);
|
|
25410
|
+
} else {
|
|
25411
|
+
merged.push(current);
|
|
25412
|
+
}
|
|
25413
|
+
}
|
|
25414
|
+
return merged;
|
|
25415
|
+
};
|
|
25416
|
+
const clampRange = (start2, end2, docSize) => {
|
|
25417
|
+
const safeStart = Math.max(0, Math.min(start2, docSize));
|
|
25418
|
+
const safeEnd = Math.max(0, Math.min(end2, docSize));
|
|
25419
|
+
if (safeStart >= safeEnd) {
|
|
25420
|
+
return null;
|
|
25421
|
+
}
|
|
25422
|
+
return [safeStart, safeEnd];
|
|
25423
|
+
};
|
|
25227
25424
|
const FieldAnnotationPlugin = (options = {}) => {
|
|
25228
25425
|
let { editor, annotationClass: annotationClass2 } = options;
|
|
25229
25426
|
return new Plugin({
|
|
@@ -25298,24 +25495,104 @@ const FieldAnnotationPlugin = (options = {}) => {
|
|
|
25298
25495
|
},
|
|
25299
25496
|
/// For y-prosemirror support.
|
|
25300
25497
|
appendTransaction: (transactions, oldState, newState) => {
|
|
25301
|
-
|
|
25498
|
+
const docChanges = transactions.some((tr2) => tr2.docChanged) && !oldState.doc.eq(newState.doc);
|
|
25302
25499
|
if (!docChanges) {
|
|
25303
25500
|
return;
|
|
25304
25501
|
}
|
|
25305
|
-
|
|
25306
|
-
let
|
|
25307
|
-
let
|
|
25308
|
-
|
|
25309
|
-
return;
|
|
25502
|
+
const affectedRanges = [];
|
|
25503
|
+
let hasFieldAnnotationsInSlice = false;
|
|
25504
|
+
let hasSteps = false;
|
|
25505
|
+
transactions.forEach((transaction) => {
|
|
25506
|
+
if (!transaction.steps) return;
|
|
25507
|
+
hasSteps = true;
|
|
25508
|
+
transaction.steps.forEach((step) => {
|
|
25509
|
+
if (step.slice?.content) {
|
|
25510
|
+
step.slice.content.descendants((node) => {
|
|
25511
|
+
if (node.type.name === "fieldAnnotation") {
|
|
25512
|
+
hasFieldAnnotationsInSlice = true;
|
|
25513
|
+
return false;
|
|
25514
|
+
}
|
|
25515
|
+
});
|
|
25516
|
+
}
|
|
25517
|
+
if (typeof step.from === "number" && typeof step.to === "number") {
|
|
25518
|
+
const from2 = step.from;
|
|
25519
|
+
const to = step.from === step.to && step.slice?.size ? step.from + step.slice.size : step.to;
|
|
25520
|
+
affectedRanges.push([from2, to]);
|
|
25521
|
+
}
|
|
25522
|
+
});
|
|
25523
|
+
});
|
|
25524
|
+
if (hasSteps && !hasFieldAnnotationsInSlice && affectedRanges.length > 0) {
|
|
25525
|
+
const mergedRanges = mergeRanges(affectedRanges);
|
|
25526
|
+
let hasExistingAnnotations = false;
|
|
25527
|
+
for (const [start2, end2] of mergedRanges) {
|
|
25528
|
+
const clampedRange = clampRange(start2, end2, newState.doc.content.size);
|
|
25529
|
+
if (!clampedRange) continue;
|
|
25530
|
+
const [validStart, validEnd] = clampedRange;
|
|
25531
|
+
try {
|
|
25532
|
+
newState.doc.nodesBetween(validStart, validEnd, (node) => {
|
|
25533
|
+
if (node.type.name === "fieldAnnotation") {
|
|
25534
|
+
hasExistingAnnotations = true;
|
|
25535
|
+
return false;
|
|
25536
|
+
}
|
|
25537
|
+
});
|
|
25538
|
+
} catch (error) {
|
|
25539
|
+
console.warn("FieldAnnotationPlugin: range check failed, assuming annotations exist", error);
|
|
25540
|
+
hasExistingAnnotations = true;
|
|
25541
|
+
break;
|
|
25542
|
+
}
|
|
25543
|
+
if (hasExistingAnnotations) break;
|
|
25544
|
+
}
|
|
25545
|
+
if (!hasExistingAnnotations) {
|
|
25546
|
+
return;
|
|
25547
|
+
}
|
|
25310
25548
|
}
|
|
25311
|
-
|
|
25312
|
-
|
|
25313
|
-
|
|
25549
|
+
const { tr } = newState;
|
|
25550
|
+
let changed = false;
|
|
25551
|
+
const removeMarksFromAnnotation = (node, pos) => {
|
|
25552
|
+
const { marks } = node;
|
|
25553
|
+
const currentNode = tr.doc.nodeAt(pos);
|
|
25314
25554
|
if (marks.length > 0 && node.eq(currentNode)) {
|
|
25315
25555
|
tr.removeMark(pos, pos + node.nodeSize, null);
|
|
25316
25556
|
changed = true;
|
|
25317
25557
|
}
|
|
25318
|
-
}
|
|
25558
|
+
};
|
|
25559
|
+
if (affectedRanges.length > 0) {
|
|
25560
|
+
const mergedRanges = mergeRanges(affectedRanges);
|
|
25561
|
+
let shouldFallbackToFullScan = false;
|
|
25562
|
+
for (const [start2, end2] of mergedRanges) {
|
|
25563
|
+
const clampedRange = clampRange(start2, end2, newState.doc.content.size);
|
|
25564
|
+
if (!clampedRange) continue;
|
|
25565
|
+
const [validStart, validEnd] = clampedRange;
|
|
25566
|
+
try {
|
|
25567
|
+
newState.doc.nodesBetween(validStart, validEnd, (node, pos) => {
|
|
25568
|
+
if (node.type.name === "fieldAnnotation") {
|
|
25569
|
+
removeMarksFromAnnotation(node, pos);
|
|
25570
|
+
}
|
|
25571
|
+
});
|
|
25572
|
+
} catch (error) {
|
|
25573
|
+
console.warn("FieldAnnotationPlugin: nodesBetween failed, falling back to full scan", error);
|
|
25574
|
+
shouldFallbackToFullScan = true;
|
|
25575
|
+
break;
|
|
25576
|
+
}
|
|
25577
|
+
}
|
|
25578
|
+
if (shouldFallbackToFullScan) {
|
|
25579
|
+
const annotations = getAllFieldAnnotations(newState);
|
|
25580
|
+
if (!annotations.length) {
|
|
25581
|
+
return changed ? tr : null;
|
|
25582
|
+
}
|
|
25583
|
+
annotations.forEach(({ node, pos }) => {
|
|
25584
|
+
removeMarksFromAnnotation(node, pos);
|
|
25585
|
+
});
|
|
25586
|
+
}
|
|
25587
|
+
} else {
|
|
25588
|
+
const annotations = getAllFieldAnnotations(newState);
|
|
25589
|
+
if (!annotations.length) {
|
|
25590
|
+
return;
|
|
25591
|
+
}
|
|
25592
|
+
annotations.forEach(({ node, pos }) => {
|
|
25593
|
+
removeMarksFromAnnotation(node, pos);
|
|
25594
|
+
});
|
|
25595
|
+
}
|
|
25319
25596
|
return changed ? tr : null;
|
|
25320
25597
|
}
|
|
25321
25598
|
///
|
|
@@ -27125,7 +27402,9 @@ const registerImages = async (foundImages, editor, view) => {
|
|
|
27125
27402
|
}
|
|
27126
27403
|
});
|
|
27127
27404
|
};
|
|
27405
|
+
const stepHasSlice = (step) => "slice" in step && Boolean(step.slice);
|
|
27128
27406
|
const ImagePositionPluginKey = new PluginKey("ImagePosition");
|
|
27407
|
+
const pageBreakPositionCache = /* @__PURE__ */ new WeakMap();
|
|
27129
27408
|
const ImagePositionPlugin = ({ editor }) => {
|
|
27130
27409
|
const { view } = editor;
|
|
27131
27410
|
let shouldUpdate = false;
|
|
@@ -27138,6 +27417,20 @@ const ImagePositionPlugin = ({ editor }) => {
|
|
|
27138
27417
|
},
|
|
27139
27418
|
apply(tr, oldDecorationSet, oldState, newState) {
|
|
27140
27419
|
if (!tr.docChanged && !shouldUpdate) return oldDecorationSet;
|
|
27420
|
+
let affectsImages = false;
|
|
27421
|
+
tr.steps.forEach((step) => {
|
|
27422
|
+
if (stepHasSlice(step)) {
|
|
27423
|
+
step.slice.content.descendants((node) => {
|
|
27424
|
+
if (node.type.name === "image" || node.attrs?.anchorData) {
|
|
27425
|
+
affectsImages = true;
|
|
27426
|
+
return false;
|
|
27427
|
+
}
|
|
27428
|
+
});
|
|
27429
|
+
}
|
|
27430
|
+
});
|
|
27431
|
+
if (!affectsImages && !shouldUpdate) {
|
|
27432
|
+
return oldDecorationSet.map(tr.mapping, tr.doc);
|
|
27433
|
+
}
|
|
27141
27434
|
const decorations = getImagePositionDecorations(newState, view);
|
|
27142
27435
|
shouldUpdate = false;
|
|
27143
27436
|
return DecorationSet.create(newState.doc, decorations);
|
|
@@ -27167,6 +27460,16 @@ const ImagePositionPlugin = ({ editor }) => {
|
|
|
27167
27460
|
};
|
|
27168
27461
|
const getImagePositionDecorations = (state, view) => {
|
|
27169
27462
|
let decorations = [];
|
|
27463
|
+
let hasAnchoredImages = false;
|
|
27464
|
+
state.doc.descendants((node) => {
|
|
27465
|
+
if (node.attrs?.anchorData) {
|
|
27466
|
+
hasAnchoredImages = true;
|
|
27467
|
+
return false;
|
|
27468
|
+
}
|
|
27469
|
+
});
|
|
27470
|
+
if (!hasAnchoredImages) {
|
|
27471
|
+
return decorations;
|
|
27472
|
+
}
|
|
27170
27473
|
state.doc.descendants((node, pos) => {
|
|
27171
27474
|
if (node.attrs.anchorData) {
|
|
27172
27475
|
let style = "";
|
|
@@ -27175,7 +27478,15 @@ const getImagePositionDecorations = (state, view) => {
|
|
|
27175
27478
|
const { size, padding } = node.attrs;
|
|
27176
27479
|
const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
|
|
27177
27480
|
if (pageBreak && vRelativeFrom === "margin" && alignH) {
|
|
27178
|
-
|
|
27481
|
+
let pageBreakPos = pageBreakPositionCache.get(pageBreak);
|
|
27482
|
+
if (!pageBreakPos) {
|
|
27483
|
+
pageBreakPos = {
|
|
27484
|
+
top: pageBreak.offsetTop,
|
|
27485
|
+
height: pageBreak.offsetHeight
|
|
27486
|
+
};
|
|
27487
|
+
pageBreakPositionCache.set(pageBreak, pageBreakPos);
|
|
27488
|
+
}
|
|
27489
|
+
const topPos = pageBreakPos.top + pageBreakPos.height;
|
|
27179
27490
|
let horizontalAlignment = `${alignH}: 0;`;
|
|
27180
27491
|
if (alignH === "center") horizontalAlignment = "left: 50%; transform: translateX(-50%);";
|
|
27181
27492
|
style += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ${horizontalAlignment}` : "";
|
|
@@ -28667,11 +28978,22 @@ const BlockNode = Extension.create({
|
|
|
28667
28978
|
},
|
|
28668
28979
|
addPmPlugins() {
|
|
28669
28980
|
let hasInitialized = false;
|
|
28981
|
+
const assignBlockId = (tr, node, pos) => {
|
|
28982
|
+
tr.setNodeMarkup(
|
|
28983
|
+
pos,
|
|
28984
|
+
void 0,
|
|
28985
|
+
{
|
|
28986
|
+
...node.attrs,
|
|
28987
|
+
sdBlockId: v4()
|
|
28988
|
+
},
|
|
28989
|
+
node.marks
|
|
28990
|
+
);
|
|
28991
|
+
};
|
|
28670
28992
|
return [
|
|
28671
28993
|
new Plugin({
|
|
28672
28994
|
key: BlockNodePluginKey,
|
|
28673
28995
|
appendTransaction: (transactions, oldState, newState) => {
|
|
28674
|
-
|
|
28996
|
+
const docChanges = transactions.some((tr2) => tr2.docChanged) && !oldState.doc.eq(newState.doc);
|
|
28675
28997
|
if (hasInitialized && !docChanges) {
|
|
28676
28998
|
return;
|
|
28677
28999
|
}
|
|
@@ -28680,21 +29002,87 @@ const BlockNode = Extension.create({
|
|
|
28680
29002
|
}
|
|
28681
29003
|
const { tr } = newState;
|
|
28682
29004
|
let changed = false;
|
|
28683
|
-
|
|
28684
|
-
|
|
28685
|
-
|
|
29005
|
+
if (!hasInitialized) {
|
|
29006
|
+
newState.doc.descendants((node, pos) => {
|
|
29007
|
+
if (nodeAllowsSdBlockIdAttr(node) && nodeNeedsSdBlockId(node)) {
|
|
29008
|
+
assignBlockId(tr, node, pos);
|
|
29009
|
+
changed = true;
|
|
29010
|
+
}
|
|
29011
|
+
});
|
|
29012
|
+
} else {
|
|
29013
|
+
const rangesToCheck = [];
|
|
29014
|
+
let shouldFallbackToFullTraversal = false;
|
|
29015
|
+
transactions.forEach((transaction, txIndex) => {
|
|
29016
|
+
transaction.steps.forEach((step, stepIndex) => {
|
|
29017
|
+
if (!(step instanceof ReplaceStep)) return;
|
|
29018
|
+
const hasNewBlockNodes = step.slice?.content?.content?.some((node) => nodeAllowsSdBlockIdAttr(node));
|
|
29019
|
+
if (!hasNewBlockNodes) return;
|
|
29020
|
+
const stepMap = step.getMap();
|
|
29021
|
+
stepMap.forEach((_oldStart, _oldEnd, newStart, newEnd) => {
|
|
29022
|
+
if (newEnd <= newStart) {
|
|
29023
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
29024
|
+
console.debug("Block node: invalid range in step map, falling back to full traversal");
|
|
29025
|
+
}
|
|
29026
|
+
shouldFallbackToFullTraversal = true;
|
|
29027
|
+
return;
|
|
29028
|
+
}
|
|
29029
|
+
let rangeStart = newStart;
|
|
29030
|
+
let rangeEnd = newEnd;
|
|
29031
|
+
for (let i = stepIndex + 1; i < transaction.steps.length; i++) {
|
|
29032
|
+
const laterStepMap = transaction.steps[i].getMap();
|
|
29033
|
+
rangeStart = laterStepMap.map(rangeStart, -1);
|
|
29034
|
+
rangeEnd = laterStepMap.map(rangeEnd, 1);
|
|
29035
|
+
}
|
|
29036
|
+
for (let i = txIndex + 1; i < transactions.length; i++) {
|
|
29037
|
+
const laterTx = transactions[i];
|
|
29038
|
+
rangeStart = laterTx.mapping.map(rangeStart, -1);
|
|
29039
|
+
rangeEnd = laterTx.mapping.map(rangeEnd, 1);
|
|
29040
|
+
}
|
|
29041
|
+
if (rangeEnd <= rangeStart) {
|
|
29042
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
29043
|
+
console.debug("Block node: invalid range after mapping, falling back to full traversal");
|
|
29044
|
+
}
|
|
29045
|
+
shouldFallbackToFullTraversal = true;
|
|
29046
|
+
return;
|
|
29047
|
+
}
|
|
29048
|
+
rangesToCheck.push([rangeStart, rangeEnd]);
|
|
29049
|
+
});
|
|
29050
|
+
});
|
|
29051
|
+
});
|
|
29052
|
+
const mergedRanges = mergeRanges(rangesToCheck);
|
|
29053
|
+
for (const [start2, end2] of mergedRanges) {
|
|
29054
|
+
const docSize = newState.doc.content.size;
|
|
29055
|
+
const clampedRange = clampRange(start2, end2, docSize);
|
|
29056
|
+
if (!clampedRange) {
|
|
29057
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
29058
|
+
console.debug("Block node: invalid range after clamping, falling back to full traversal");
|
|
29059
|
+
}
|
|
29060
|
+
shouldFallbackToFullTraversal = true;
|
|
29061
|
+
break;
|
|
29062
|
+
}
|
|
29063
|
+
const [safeStart, safeEnd] = clampedRange;
|
|
29064
|
+
try {
|
|
29065
|
+
newState.doc.nodesBetween(safeStart, safeEnd, (node, pos) => {
|
|
29066
|
+
if (nodeAllowsSdBlockIdAttr(node) && nodeNeedsSdBlockId(node)) {
|
|
29067
|
+
assignBlockId(tr, node, pos);
|
|
29068
|
+
changed = true;
|
|
29069
|
+
}
|
|
29070
|
+
});
|
|
29071
|
+
} catch (error) {
|
|
29072
|
+
console.warn("Block node plugin: nodesBetween failed, falling back to full traversal", error);
|
|
29073
|
+
shouldFallbackToFullTraversal = true;
|
|
29074
|
+
break;
|
|
29075
|
+
}
|
|
28686
29076
|
}
|
|
28687
|
-
|
|
28688
|
-
pos
|
|
28689
|
-
|
|
28690
|
-
|
|
28691
|
-
|
|
28692
|
-
|
|
28693
|
-
}
|
|
28694
|
-
|
|
28695
|
-
|
|
28696
|
-
changed = true;
|
|
28697
|
-
});
|
|
29077
|
+
if (shouldFallbackToFullTraversal) {
|
|
29078
|
+
newState.doc.descendants((node, pos) => {
|
|
29079
|
+
if (nodeAllowsSdBlockIdAttr(node) && nodeNeedsSdBlockId(node)) {
|
|
29080
|
+
assignBlockId(tr, node, pos);
|
|
29081
|
+
changed = true;
|
|
29082
|
+
}
|
|
29083
|
+
});
|
|
29084
|
+
}
|
|
29085
|
+
}
|
|
28698
29086
|
if (changed && !hasInitialized) {
|
|
28699
29087
|
hasInitialized = true;
|
|
28700
29088
|
tr.setMeta("blockNodeInitialUpdate", true);
|
|
@@ -35170,8 +35558,8 @@ const PopoverPlugin = Extension.create({
|
|
|
35170
35558
|
return {};
|
|
35171
35559
|
},
|
|
35172
35560
|
apply: (tr, value) => {
|
|
35173
|
-
|
|
35174
|
-
if (tr.docChanged) {
|
|
35561
|
+
const newValue = { ...value };
|
|
35562
|
+
if (tr.docChanged || tr.selectionSet) {
|
|
35175
35563
|
newValue.shouldUpdate = true;
|
|
35176
35564
|
} else {
|
|
35177
35565
|
newValue.shouldUpdate = false;
|
|
@@ -36426,6 +36814,8 @@ const Pagination = Extension.create({
|
|
|
36426
36814
|
let shouldUpdate = false;
|
|
36427
36815
|
let hasInitialized = false;
|
|
36428
36816
|
let shouldInitialize = false;
|
|
36817
|
+
let paginationTimeout = null;
|
|
36818
|
+
const PAGINATION_DEBOUNCE_MS = 150;
|
|
36429
36819
|
const paginationPlugin = new Plugin({
|
|
36430
36820
|
key: PaginationPluginKey,
|
|
36431
36821
|
state: {
|
|
@@ -36453,6 +36843,9 @@ const Pagination = Extension.create({
|
|
|
36453
36843
|
shouldUpdate = true;
|
|
36454
36844
|
shouldInitialize = meta.isReadyToInit;
|
|
36455
36845
|
}
|
|
36846
|
+
if (meta && meta.skipPagination) {
|
|
36847
|
+
return { ...oldState };
|
|
36848
|
+
}
|
|
36456
36849
|
const syncMeta = tr.getMeta("y-sync$");
|
|
36457
36850
|
const listSyncMeta = tr.getMeta("orderedListSync");
|
|
36458
36851
|
if (syncMeta && syncMeta.isChangeOrigin || listSyncMeta) {
|
|
@@ -36484,11 +36877,23 @@ const Pagination = Extension.create({
|
|
|
36484
36877
|
shouldUpdate = false;
|
|
36485
36878
|
return { ...oldState };
|
|
36486
36879
|
}
|
|
36880
|
+
if (!isForceUpdate && hasInitialized && tr.docChanged) {
|
|
36881
|
+
let isMarkOnlyChange = true;
|
|
36882
|
+
tr.steps.forEach((step) => {
|
|
36883
|
+
if (step.jsonID !== "addMark" && step.jsonID !== "removeMark") {
|
|
36884
|
+
isMarkOnlyChange = false;
|
|
36885
|
+
}
|
|
36886
|
+
});
|
|
36887
|
+
if (isMarkOnlyChange) {
|
|
36888
|
+
shouldUpdate = false;
|
|
36889
|
+
return { ...oldState };
|
|
36890
|
+
}
|
|
36891
|
+
}
|
|
36487
36892
|
shouldUpdate = true;
|
|
36488
36893
|
if (isForceUpdate) shouldUpdate = true;
|
|
36489
36894
|
return {
|
|
36490
36895
|
...oldState,
|
|
36491
|
-
decorations: meta?.decorations?.map(tr.mapping, tr.doc) ||
|
|
36896
|
+
decorations: meta?.decorations?.map(tr.mapping, tr.doc) || oldState.decorations.map(tr.mapping, tr.doc),
|
|
36492
36897
|
isReadyToInit: shouldInitialize
|
|
36493
36898
|
};
|
|
36494
36899
|
}
|
|
@@ -36500,11 +36905,22 @@ const Pagination = Extension.create({
|
|
|
36500
36905
|
update: (view) => {
|
|
36501
36906
|
if (!PaginationPluginKey.getState(view.state)?.isEnabled) return;
|
|
36502
36907
|
if (!shouldUpdate || isUpdating) return;
|
|
36503
|
-
|
|
36504
|
-
|
|
36505
|
-
|
|
36506
|
-
|
|
36507
|
-
|
|
36908
|
+
const performPaginationUpdate = () => {
|
|
36909
|
+
if (!shouldUpdate) return;
|
|
36910
|
+
isUpdating = true;
|
|
36911
|
+
hasInitialized = true;
|
|
36912
|
+
performUpdate(editor, view, previousDecorations);
|
|
36913
|
+
isUpdating = false;
|
|
36914
|
+
shouldUpdate = false;
|
|
36915
|
+
};
|
|
36916
|
+
if (!hasInitialized) {
|
|
36917
|
+
performPaginationUpdate();
|
|
36918
|
+
return;
|
|
36919
|
+
}
|
|
36920
|
+
if (paginationTimeout) {
|
|
36921
|
+
clearTimeout(paginationTimeout);
|
|
36922
|
+
}
|
|
36923
|
+
paginationTimeout = setTimeout(performPaginationUpdate, PAGINATION_DEBOUNCE_MS);
|
|
36508
36924
|
}
|
|
36509
36925
|
};
|
|
36510
36926
|
},
|