@superdoc-dev/cli 0.8.0-next.13 → 0.8.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/index.js +279 -86
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -65535,7 +65535,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
|
|
|
65535
65535
|
emptyOptions2 = {};
|
|
65536
65536
|
});
|
|
65537
65537
|
|
|
65538
|
-
// ../../packages/superdoc/dist/chunks/SuperConverter-
|
|
65538
|
+
// ../../packages/superdoc/dist/chunks/SuperConverter-kY_NnfwW.es.js
|
|
65539
65539
|
function getExtensionConfigField(extension$1, field, context = { name: "" }) {
|
|
65540
65540
|
const fieldValue = extension$1.config[field];
|
|
65541
65541
|
if (typeof fieldValue === "function")
|
|
@@ -98963,7 +98963,8 @@ function syncConverterBodySection(editor, sectPr) {
|
|
|
98963
98963
|
function getConverter$2(editor) {
|
|
98964
98964
|
return editor.converter;
|
|
98965
98965
|
}
|
|
98966
|
-
function applySectPrToProjection(editor, projection, sectPr) {
|
|
98966
|
+
function applySectPrToProjection(editor, projection, sectPr, options) {
|
|
98967
|
+
const addToHistory = options?.addToHistory ?? true;
|
|
98967
98968
|
if (projection.target.kind === "paragraph") {
|
|
98968
98969
|
const paragraph2 = projection.target.node;
|
|
98969
98970
|
const attrs = paragraph2.attrs ?? {};
|
|
@@ -98978,12 +98979,16 @@ function applySectPrToProjection(editor, projection, sectPr) {
|
|
|
98978
98979
|
sectionMargins: buildSectionMarginsForAttrs(sectPr)
|
|
98979
98980
|
};
|
|
98980
98981
|
const tr$1 = applyDirectMutationMeta(editor.state.tr);
|
|
98982
|
+
if (!addToHistory)
|
|
98983
|
+
tr$1.setMeta("addToHistory", false);
|
|
98981
98984
|
tr$1.setNodeMarkup(projection.target.pos, undefined, nextAttrs, paragraph2.marks);
|
|
98982
98985
|
tr$1.setMeta("forceUpdatePagination", true);
|
|
98983
98986
|
editor.dispatch(tr$1);
|
|
98984
98987
|
return;
|
|
98985
98988
|
}
|
|
98986
98989
|
const tr = applyDirectMutationMeta(editor.state.tr);
|
|
98990
|
+
if (!addToHistory)
|
|
98991
|
+
tr.setMeta("addToHistory", false);
|
|
98987
98992
|
tr.setDocAttribute("bodySectPr", sectPr);
|
|
98988
98993
|
tr.setMeta("forceUpdatePagination", true);
|
|
98989
98994
|
editor.dispatch(tr);
|
|
@@ -99027,7 +99032,7 @@ function cleanupCreatedPart(editor, partPath) {
|
|
|
99027
99032
|
removePart(editor, relsPath);
|
|
99028
99033
|
}
|
|
99029
99034
|
function ensureExplicitHeaderFooterSlot(editor, input) {
|
|
99030
|
-
const { sectionId, kind, variant, sourceRefId } = input;
|
|
99035
|
+
const { sectionId, kind, variant, sourceRefId, addToHistory = true } = input;
|
|
99031
99036
|
const sections = resolveSectionProjections(editor);
|
|
99032
99037
|
const projection = sections.find((s) => s.sectionId === sectionId);
|
|
99033
99038
|
if (!projection) {
|
|
@@ -99069,7 +99074,7 @@ function ensureExplicitHeaderFooterSlot(editor, input) {
|
|
|
99069
99074
|
try {
|
|
99070
99075
|
const nextSectPr = ensureSectPrElement(currentSectPr);
|
|
99071
99076
|
setSectPrHeaderFooterRef(nextSectPr, kind, variant, created.refId);
|
|
99072
|
-
applySectPrToProjection(editor, projection, nextSectPr);
|
|
99077
|
+
applySectPrToProjection(editor, projection, nextSectPr, { addToHistory });
|
|
99073
99078
|
} catch {
|
|
99074
99079
|
cleanupCreatedPart(editor, created.relationshipTarget);
|
|
99075
99080
|
return false;
|
|
@@ -117743,7 +117748,7 @@ var isRegExp = (value) => {
|
|
|
117743
117748
|
state.kern = kernNode.attributes["w:val"];
|
|
117744
117749
|
}
|
|
117745
117750
|
}, SuperConverter;
|
|
117746
|
-
var
|
|
117751
|
+
var init_SuperConverter_kY_NnfwW_es = __esm(() => {
|
|
117747
117752
|
init_rolldown_runtime_Bg48TavK_es();
|
|
117748
117753
|
init_jszip_C49i9kUs_es();
|
|
117749
117754
|
init_xml_js_CqGKpaft_es();
|
|
@@ -155159,7 +155164,7 @@ var init_SuperConverter_aq0iFjuQ_es = __esm(() => {
|
|
|
155159
155164
|
};
|
|
155160
155165
|
});
|
|
155161
155166
|
|
|
155162
|
-
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-
|
|
155167
|
+
// ../../packages/superdoc/dist/chunks/create-headless-toolbar-5SsdVL-D.es.js
|
|
155163
155168
|
function parseSizeUnit(val = "0") {
|
|
155164
155169
|
const length3 = val.toString() || "0";
|
|
155165
155170
|
const value = Number.parseFloat(length3);
|
|
@@ -157751,8 +157756,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
|
|
|
157751
157756
|
}
|
|
157752
157757
|
};
|
|
157753
157758
|
};
|
|
157754
|
-
var
|
|
157755
|
-
|
|
157759
|
+
var init_create_headless_toolbar_5SsdVL_D_es = __esm(() => {
|
|
157760
|
+
init_SuperConverter_kY_NnfwW_es();
|
|
157756
157761
|
init_constants_CGhJRd87_es();
|
|
157757
157762
|
init_dist_B8HfvhaK_es();
|
|
157758
157763
|
CSS_DIMENSION_REGEX = /[\d-.]+(\w+)$/;
|
|
@@ -206439,7 +206444,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
|
|
|
206439
206444
|
init_remark_gfm_BhnWr3yf_es();
|
|
206440
206445
|
});
|
|
206441
206446
|
|
|
206442
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
206447
|
+
// ../../packages/superdoc/dist/chunks/src-Bn82VlNp.es.js
|
|
206443
206448
|
function deleteProps(obj, propOrProps) {
|
|
206444
206449
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
206445
206450
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -207177,11 +207182,14 @@ function applySelectionCleanup(editor, tr) {
|
|
|
207177
207182
|
});
|
|
207178
207183
|
return cleaned;
|
|
207179
207184
|
}
|
|
207180
|
-
function createHistoryDispatch(editor, dispatch) {
|
|
207185
|
+
function createHistoryDispatch(editor, dispatch, inputType) {
|
|
207181
207186
|
if (!dispatch)
|
|
207182
207187
|
return dispatch;
|
|
207183
207188
|
return (historyTr) => {
|
|
207184
|
-
|
|
207189
|
+
let cleaned = applySelectionCleanup(editor, historyTr);
|
|
207190
|
+
if (inputType)
|
|
207191
|
+
cleaned = cleaned.setMeta("inputType", inputType);
|
|
207192
|
+
dispatch(cleaned);
|
|
207185
207193
|
};
|
|
207186
207194
|
}
|
|
207187
207195
|
function runSelectionCleanupAfterCollabHistory(editor) {
|
|
@@ -207193,6 +207201,49 @@ function runSelectionCleanupAfterCollabHistory(editor) {
|
|
|
207193
207201
|
tr = tr.setMeta("addToHistory", false);
|
|
207194
207202
|
view.dispatch(tr);
|
|
207195
207203
|
}
|
|
207204
|
+
function getPresentationHistoryProxy(editor) {
|
|
207205
|
+
const presentationEditor = editor?.presentationEditor ?? editor?._presentationEditor ?? null;
|
|
207206
|
+
if (!presentationEditor || typeof presentationEditor.getActiveEditor !== "function")
|
|
207207
|
+
return null;
|
|
207208
|
+
return presentationEditor.getActiveEditor() === editor ? presentationEditor : null;
|
|
207209
|
+
}
|
|
207210
|
+
function resolveHistoryDispatch(editor, allowDispatch) {
|
|
207211
|
+
if (!allowDispatch)
|
|
207212
|
+
return;
|
|
207213
|
+
return editor?.view?.dispatch?.bind(editor.view) ?? editor?.dispatch?.bind(editor);
|
|
207214
|
+
}
|
|
207215
|
+
function runEditorUndo(editor, options = {}) {
|
|
207216
|
+
const state = editor?.state;
|
|
207217
|
+
const tr = state?.tr;
|
|
207218
|
+
const allowDispatch = options.allowDispatch !== false;
|
|
207219
|
+
const inputType = "historyUndo";
|
|
207220
|
+
if (!state || !tr)
|
|
207221
|
+
return false;
|
|
207222
|
+
const dispatch = resolveHistoryDispatch(editor, allowDispatch);
|
|
207223
|
+
if (editor.options.collaborationProvider && editor.options.ydoc) {
|
|
207224
|
+
const result = undo$1(state, dispatch);
|
|
207225
|
+
if (allowDispatch && result)
|
|
207226
|
+
runSelectionCleanupAfterCollabHistory(editor);
|
|
207227
|
+
return result;
|
|
207228
|
+
}
|
|
207229
|
+
return undo(state, createHistoryDispatch(editor, dispatch, allowDispatch ? inputType : undefined));
|
|
207230
|
+
}
|
|
207231
|
+
function runEditorRedo(editor, options = {}) {
|
|
207232
|
+
const state = editor?.state;
|
|
207233
|
+
const tr = state?.tr;
|
|
207234
|
+
const allowDispatch = options.allowDispatch !== false;
|
|
207235
|
+
const inputType = "historyRedo";
|
|
207236
|
+
if (!state || !tr)
|
|
207237
|
+
return false;
|
|
207238
|
+
const dispatch = resolveHistoryDispatch(editor, allowDispatch);
|
|
207239
|
+
if (editor.options.collaborationProvider && editor.options.ydoc) {
|
|
207240
|
+
const result = redo$1(state, dispatch);
|
|
207241
|
+
if (allowDispatch && result)
|
|
207242
|
+
runSelectionCleanupAfterCollabHistory(editor);
|
|
207243
|
+
return result;
|
|
207244
|
+
}
|
|
207245
|
+
return redo(state, createHistoryDispatch(editor, dispatch, allowDispatch ? inputType : undefined));
|
|
207246
|
+
}
|
|
207196
207247
|
function isRunPropertyEnabled(value) {
|
|
207197
207248
|
if (value == null)
|
|
207198
207249
|
return false;
|
|
@@ -265430,6 +265481,28 @@ function ensureEditorFieldAnnotationInteractionStyles(doc$12) {
|
|
|
265430
265481
|
doc$12.head?.appendChild(styleEl);
|
|
265431
265482
|
fieldAnnotationInteractionStylesInjected = true;
|
|
265432
265483
|
}
|
|
265484
|
+
function stripVolatileHistoryAttrs(value) {
|
|
265485
|
+
if (Array.isArray(value))
|
|
265486
|
+
return value.map((item) => stripVolatileHistoryAttrs(item));
|
|
265487
|
+
if (!value || typeof value !== "object")
|
|
265488
|
+
return value;
|
|
265489
|
+
const result = {};
|
|
265490
|
+
for (const [key2, entryValue] of Object.entries(value)) {
|
|
265491
|
+
if (VOLATILE_HISTORY_ATTR_KEYS.has(key2))
|
|
265492
|
+
continue;
|
|
265493
|
+
result[key2] = stripVolatileHistoryAttrs(entryValue);
|
|
265494
|
+
}
|
|
265495
|
+
return result;
|
|
265496
|
+
}
|
|
265497
|
+
function docsEqualIgnoringVolatileHistoryAttrs(before2, after2) {
|
|
265498
|
+
if (!before2 || !after2)
|
|
265499
|
+
return false;
|
|
265500
|
+
if (typeof before2.eq === "function" && before2.eq(after2))
|
|
265501
|
+
return true;
|
|
265502
|
+
const beforeJson = typeof before2.toJSON === "function" ? before2.toJSON() : before2;
|
|
265503
|
+
const afterJson = typeof after2.toJSON === "function" ? after2.toJSON() : after2;
|
|
265504
|
+
return JSON.stringify(stripVolatileHistoryAttrs(beforeJson)) === JSON.stringify(stripVolatileHistoryAttrs(afterJson));
|
|
265505
|
+
}
|
|
265433
265506
|
function parseRenderedNoteTarget(blockId) {
|
|
265434
265507
|
if (typeof blockId !== "string" || blockId.length === 0)
|
|
265435
265508
|
return null;
|
|
@@ -277517,14 +277590,14 @@ var Node$13 = class Node$14 {
|
|
|
277517
277590
|
() => commands$1.joinForward(),
|
|
277518
277591
|
() => commands$1.selectNodeForward()
|
|
277519
277592
|
]);
|
|
277520
|
-
}, Keymap,
|
|
277593
|
+
}, Keymap, handleInsertTextBeforeInput = (view, event) => {
|
|
277521
277594
|
const isInsertTextInput = event?.inputType === "insertText";
|
|
277522
277595
|
const hasTextData = typeof event?.data === "string" && event.data.length > 0;
|
|
277523
|
-
const
|
|
277524
|
-
if (!isInsertTextInput || !hasTextData ||
|
|
277596
|
+
const isComposing = event?.isComposing === true;
|
|
277597
|
+
if (!isInsertTextInput || !hasTextData || isComposing)
|
|
277525
277598
|
return false;
|
|
277526
277599
|
const selection = view.state.selection;
|
|
277527
|
-
if (
|
|
277600
|
+
if (selection.empty)
|
|
277528
277601
|
return false;
|
|
277529
277602
|
const tr = view.state.tr.insertText(event.data, selection.from, selection.to);
|
|
277530
277603
|
tr.setMeta("inputType", "insertText");
|
|
@@ -292366,7 +292439,7 @@ menclose::after {
|
|
|
292366
292439
|
};
|
|
292367
292440
|
const bodyPageCount = this.#deps?.getBodyPageCount() ?? 1;
|
|
292368
292441
|
return storySessionManager.activate(locator, {
|
|
292369
|
-
commitPolicy: "
|
|
292442
|
+
commitPolicy: "onExit",
|
|
292370
292443
|
preferHiddenHost: true,
|
|
292371
292444
|
hostWidthPx: Math.max(1, region.width),
|
|
292372
292445
|
editorContext: {
|
|
@@ -292397,7 +292470,8 @@ menclose::after {
|
|
|
292397
292470
|
const materializationResult = ensureExplicitHeaderFooterSlot(this.#options.editor, {
|
|
292398
292471
|
sectionId: region.sectionId,
|
|
292399
292472
|
kind: region.kind,
|
|
292400
|
-
variant: normalizeVariant(region.sectionType ?? "default")
|
|
292473
|
+
variant: normalizeVariant(region.sectionType ?? "default"),
|
|
292474
|
+
addToHistory: false
|
|
292401
292475
|
});
|
|
292402
292476
|
if (materializationResult) {
|
|
292403
292477
|
this.#headerFooterManager.refresh();
|
|
@@ -293620,17 +293694,17 @@ menclose::after {
|
|
|
293620
293694
|
pointer-events: none;
|
|
293621
293695
|
z-index: 1000;
|
|
293622
293696
|
}
|
|
293623
|
-
`, fieldAnnotationInteractionStylesInjected = false, DOCUMENT_RELS_PART_ID = "word/_rels/document.xml.rels", DEFAULT_PAGE_SIZE, DEFAULT_MARGINS, DEFAULT_PAGE_GAP = 24, DEFAULT_HORIZONTAL_PAGE_GAP = 20, layoutDebugEnabled, perfLog = (...args$1) => {
|
|
293697
|
+
`, fieldAnnotationInteractionStylesInjected = false, VOLATILE_HISTORY_ATTR_KEYS, DOCUMENT_RELS_PART_ID = "word/_rels/document.xml.rels", DEFAULT_PAGE_SIZE, DEFAULT_MARGINS, DEFAULT_PAGE_GAP = 24, DEFAULT_HORIZONTAL_PAGE_GAP = 20, layoutDebugEnabled, perfLog = (...args$1) => {
|
|
293624
293698
|
if (!layoutDebugEnabled)
|
|
293625
293699
|
return;
|
|
293626
293700
|
console.log(...args$1);
|
|
293627
293701
|
}, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
|
|
293628
|
-
var
|
|
293702
|
+
var init_src_Bn82VlNp_es = __esm(() => {
|
|
293629
293703
|
init_rolldown_runtime_Bg48TavK_es();
|
|
293630
|
-
|
|
293704
|
+
init_SuperConverter_kY_NnfwW_es();
|
|
293631
293705
|
init_jszip_C49i9kUs_es();
|
|
293632
293706
|
init_uuid_qzgm05fK_es();
|
|
293633
|
-
|
|
293707
|
+
init_create_headless_toolbar_5SsdVL_D_es();
|
|
293634
293708
|
init_constants_CGhJRd87_es();
|
|
293635
293709
|
init_dist_B8HfvhaK_es();
|
|
293636
293710
|
init_unified_Dsuw2be5_es();
|
|
@@ -294397,25 +294471,27 @@ ${err.toString()}`);
|
|
|
294397
294471
|
},
|
|
294398
294472
|
addCommands() {
|
|
294399
294473
|
return {
|
|
294400
|
-
undo: () => ({
|
|
294401
|
-
|
|
294402
|
-
|
|
294403
|
-
|
|
294404
|
-
|
|
294405
|
-
|
|
294474
|
+
undo: () => ({ tr, dispatch }) => {
|
|
294475
|
+
tr?.setMeta("preventDispatch", true);
|
|
294476
|
+
const allowDispatch = typeof dispatch === "function";
|
|
294477
|
+
const presentationEditor = getPresentationHistoryProxy(this.editor);
|
|
294478
|
+
if (presentationEditor) {
|
|
294479
|
+
if (allowDispatch && typeof presentationEditor.undo === "function")
|
|
294480
|
+
return Boolean(presentationEditor.undo());
|
|
294481
|
+
return typeof presentationEditor.canUndo === "function" ? Boolean(presentationEditor.canUndo()) : false;
|
|
294406
294482
|
}
|
|
294407
|
-
|
|
294408
|
-
return undo(state, createHistoryDispatch(this.editor, dispatch));
|
|
294483
|
+
return runEditorUndo(this.editor, { allowDispatch });
|
|
294409
294484
|
},
|
|
294410
|
-
redo: () => ({
|
|
294411
|
-
|
|
294412
|
-
|
|
294413
|
-
|
|
294414
|
-
|
|
294415
|
-
|
|
294485
|
+
redo: () => ({ tr, dispatch }) => {
|
|
294486
|
+
tr?.setMeta("preventDispatch", true);
|
|
294487
|
+
const allowDispatch = typeof dispatch === "function";
|
|
294488
|
+
const presentationEditor = getPresentationHistoryProxy(this.editor);
|
|
294489
|
+
if (presentationEditor) {
|
|
294490
|
+
if (allowDispatch && typeof presentationEditor.redo === "function")
|
|
294491
|
+
return Boolean(presentationEditor.redo());
|
|
294492
|
+
return typeof presentationEditor.canRedo === "function" ? Boolean(presentationEditor.canRedo()) : false;
|
|
294416
294493
|
}
|
|
294417
|
-
|
|
294418
|
-
return redo(state, createHistoryDispatch(this.editor, dispatch));
|
|
294494
|
+
return runEditorRedo(this.editor, { allowDispatch });
|
|
294419
294495
|
}
|
|
294420
294496
|
};
|
|
294421
294497
|
},
|
|
@@ -315475,7 +315551,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
315475
315551
|
}
|
|
315476
315552
|
if (shouldForceEndStaleComposition(view, event))
|
|
315477
315553
|
__endComposition(view);
|
|
315478
|
-
if (
|
|
315554
|
+
if (handleInsertTextBeforeInput(view, event))
|
|
315479
315555
|
return true;
|
|
315480
315556
|
return false;
|
|
315481
315557
|
},
|
|
@@ -317866,7 +317942,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
317866
317942
|
if (!editable && this.view.dom)
|
|
317867
317943
|
this.view.dom.blur();
|
|
317868
317944
|
}
|
|
317869
|
-
if (emitUpdate)
|
|
317945
|
+
if (emitUpdate && this.state)
|
|
317870
317946
|
this.emit("update", {
|
|
317871
317947
|
editor: this,
|
|
317872
317948
|
transaction: this.state.tr
|
|
@@ -323964,25 +324040,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
323964
324040
|
error: error3
|
|
323965
324041
|
});
|
|
323966
324042
|
});
|
|
323967
|
-
|
|
323968
|
-
if (existing.container.parentElement !== options.editorHost)
|
|
323969
|
-
options.editorHost.appendChild(existing.container);
|
|
323970
|
-
}
|
|
323971
|
-
if (existing.editor && options) {
|
|
323972
|
-
const updateOptions = {};
|
|
323973
|
-
if (options.currentPageNumber !== undefined)
|
|
323974
|
-
updateOptions.currentPageNumber = options.currentPageNumber;
|
|
323975
|
-
if (options.totalPageCount !== undefined)
|
|
323976
|
-
updateOptions.totalPageCount = options.totalPageCount;
|
|
323977
|
-
if (options.availableWidth !== undefined)
|
|
323978
|
-
updateOptions.availableWidth = options.availableWidth;
|
|
323979
|
-
if (options.availableHeight !== undefined)
|
|
323980
|
-
updateOptions.availableHeight = options.availableHeight;
|
|
323981
|
-
if (Object.keys(updateOptions).length > 0) {
|
|
323982
|
-
existing.editor.setOptions(updateOptions);
|
|
323983
|
-
this.#refreshPageNumberDisplay(existing.editor);
|
|
323984
|
-
}
|
|
323985
|
-
}
|
|
324043
|
+
this.#mountAndUpdateEntry(existing, options);
|
|
323986
324044
|
return existing.editor;
|
|
323987
324045
|
}
|
|
323988
324046
|
const pending = this.#pendingCreations.get(descriptor.id);
|
|
@@ -323991,7 +324049,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
323991
324049
|
this.#cacheMisses += 1;
|
|
323992
324050
|
const creationPromise = (async () => {
|
|
323993
324051
|
try {
|
|
323994
|
-
const entry =
|
|
324052
|
+
const entry = this.#createEditorEntry(descriptor, options);
|
|
323995
324053
|
if (!entry)
|
|
323996
324054
|
return null;
|
|
323997
324055
|
this.#editorEntries.set(descriptor.id, entry);
|
|
@@ -324012,6 +324070,25 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
324012
324070
|
this.#pendingCreations.set(descriptor.id, creationPromise);
|
|
324013
324071
|
return creationPromise;
|
|
324014
324072
|
}
|
|
324073
|
+
ensureEditorSync(descriptor, options) {
|
|
324074
|
+
if (!descriptor?.id)
|
|
324075
|
+
return null;
|
|
324076
|
+
const existing = this.#editorEntries.get(descriptor.id);
|
|
324077
|
+
if (existing) {
|
|
324078
|
+
this.#cacheHits += 1;
|
|
324079
|
+
this.#updateAccessOrder(descriptor.id);
|
|
324080
|
+
this.#mountAndUpdateEntry(existing, options);
|
|
324081
|
+
return existing.editor;
|
|
324082
|
+
}
|
|
324083
|
+
const entry = this.#createEditorEntry(descriptor, options);
|
|
324084
|
+
if (!entry)
|
|
324085
|
+
return null;
|
|
324086
|
+
this.#cacheMisses += 1;
|
|
324087
|
+
this.#editorEntries.set(descriptor.id, entry);
|
|
324088
|
+
this.#updateAccessOrder(descriptor.id);
|
|
324089
|
+
this.#enforceCacheSizeLimit();
|
|
324090
|
+
return entry.editor;
|
|
324091
|
+
}
|
|
324015
324092
|
#refreshPageNumberDisplay(editor) {
|
|
324016
324093
|
const container = editor.view?.dom;
|
|
324017
324094
|
if (!container)
|
|
@@ -324150,7 +324227,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
324150
324227
|
});
|
|
324151
324228
|
this.#editorEntries.clear();
|
|
324152
324229
|
}
|
|
324153
|
-
|
|
324230
|
+
#createEditorEntry(descriptor, options) {
|
|
324154
324231
|
const json = this.getDocumentJson(descriptor);
|
|
324155
324232
|
if (!json)
|
|
324156
324233
|
return null;
|
|
@@ -324248,6 +324325,25 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
324248
324325
|
ready
|
|
324249
324326
|
};
|
|
324250
324327
|
}
|
|
324328
|
+
#mountAndUpdateEntry(entry, options) {
|
|
324329
|
+
if (entry.container && options?.editorHost && entry.container.parentElement !== options.editorHost)
|
|
324330
|
+
options.editorHost.appendChild(entry.container);
|
|
324331
|
+
if (!options)
|
|
324332
|
+
return;
|
|
324333
|
+
const updateOptions = {};
|
|
324334
|
+
if (options.currentPageNumber !== undefined)
|
|
324335
|
+
updateOptions.currentPageNumber = options.currentPageNumber;
|
|
324336
|
+
if (options.totalPageCount !== undefined)
|
|
324337
|
+
updateOptions.totalPageCount = options.totalPageCount;
|
|
324338
|
+
if (options.availableWidth !== undefined)
|
|
324339
|
+
updateOptions.availableWidth = options.availableWidth;
|
|
324340
|
+
if (options.availableHeight !== undefined)
|
|
324341
|
+
updateOptions.availableHeight = options.availableHeight;
|
|
324342
|
+
if (Object.keys(updateOptions).length > 0) {
|
|
324343
|
+
entry.editor.setOptions(updateOptions);
|
|
324344
|
+
this.#refreshPageNumberDisplay(entry.editor);
|
|
324345
|
+
}
|
|
324346
|
+
}
|
|
324251
324347
|
#createEditorContainer() {
|
|
324252
324348
|
return (this.#editor.options?.element?.ownerDocument ?? globalThis.document ?? undefined)?.createElement("div") ?? document.createElement("div");
|
|
324253
324349
|
}
|
|
@@ -324376,6 +324472,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
324376
324472
|
after: 12
|
|
324377
324473
|
}
|
|
324378
324474
|
};
|
|
324475
|
+
VOLATILE_HISTORY_ATTR_KEYS = new Set(["sdBlockId", "sdBlockRev"]);
|
|
324379
324476
|
DEFAULT_PAGE_SIZE = {
|
|
324380
324477
|
w: 612,
|
|
324381
324478
|
h: 792
|
|
@@ -324494,6 +324591,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
324494
324591
|
#storySessionSelectionHandler = null;
|
|
324495
324592
|
#storySessionTransactionHandler = null;
|
|
324496
324593
|
#storySessionEditor = null;
|
|
324594
|
+
#persistentStorySessionEditors = /* @__PURE__ */ new WeakSet;
|
|
324595
|
+
#lastPersistentStoryHistoryEditor = null;
|
|
324497
324596
|
#activeSurfaceUiEventEditor = null;
|
|
324498
324597
|
#activeSurfaceUiUpdateHandler = null;
|
|
324499
324598
|
#activeSurfaceUiContextMenuOpenHandler = null;
|
|
@@ -324989,16 +325088,93 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
324989
325088
|
range: activeEditor.getEffectiveSelectionRange()
|
|
324990
325089
|
};
|
|
324991
325090
|
}
|
|
325091
|
+
#runEditorHistoryCommand(editor, command$1) {
|
|
325092
|
+
if (!editor)
|
|
325093
|
+
return {
|
|
325094
|
+
didRun: false,
|
|
325095
|
+
didChangeDoc: false
|
|
325096
|
+
};
|
|
325097
|
+
const beforeDoc = editor.state?.doc ?? null;
|
|
325098
|
+
try {
|
|
325099
|
+
const didRun = command$1 === "undo" ? runEditorUndo(editor) : runEditorRedo(editor);
|
|
325100
|
+
const rawDidChangeDoc = beforeDoc && editor.state?.doc && typeof editor.state.doc.eq === "function" ? !editor.state.doc.eq(beforeDoc) : didRun;
|
|
325101
|
+
const didChangeDoc = editor === this.#editor && rawDidChangeDoc && docsEqualIgnoringVolatileHistoryAttrs(beforeDoc, editor.state?.doc) ? false : rawDidChangeDoc;
|
|
325102
|
+
if (didRun && this.#persistentStorySessionEditors.has(editor))
|
|
325103
|
+
this.#lastPersistentStoryHistoryEditor = editor;
|
|
325104
|
+
return {
|
|
325105
|
+
didRun,
|
|
325106
|
+
didChangeDoc
|
|
325107
|
+
};
|
|
325108
|
+
} catch {
|
|
325109
|
+
return {
|
|
325110
|
+
didRun: false,
|
|
325111
|
+
didChangeDoc: false
|
|
325112
|
+
};
|
|
325113
|
+
}
|
|
325114
|
+
}
|
|
325115
|
+
#runPersistentStoryHistoryCommand(command$1) {
|
|
325116
|
+
const editor = this.#lastPersistentStoryHistoryEditor;
|
|
325117
|
+
if (!editor || !this.#persistentStorySessionEditors.has(editor))
|
|
325118
|
+
return false;
|
|
325119
|
+
const handler2 = command$1 === "undo" ? editor.commands?.undo : editor.commands?.redo;
|
|
325120
|
+
if (typeof handler2 !== "function")
|
|
325121
|
+
return false;
|
|
325122
|
+
try {
|
|
325123
|
+
const didRun = Boolean(handler2());
|
|
325124
|
+
if (didRun)
|
|
325125
|
+
this.#lastPersistentStoryHistoryEditor = editor;
|
|
325126
|
+
return didRun;
|
|
325127
|
+
} catch {
|
|
325128
|
+
return false;
|
|
325129
|
+
}
|
|
325130
|
+
}
|
|
325131
|
+
#canRunEditorHistoryCommand(editor, command$1) {
|
|
325132
|
+
if (!editor)
|
|
325133
|
+
return false;
|
|
325134
|
+
try {
|
|
325135
|
+
return Boolean(command$1 === "undo" ? runEditorUndo(editor, { allowDispatch: false }) : runEditorRedo(editor, { allowDispatch: false }));
|
|
325136
|
+
} catch {
|
|
325137
|
+
return false;
|
|
325138
|
+
}
|
|
325139
|
+
}
|
|
325140
|
+
#canRunPersistentStoryHistoryCommand(command$1) {
|
|
325141
|
+
const editor = this.#lastPersistentStoryHistoryEditor;
|
|
325142
|
+
if (!editor || !this.#persistentStorySessionEditors.has(editor))
|
|
325143
|
+
return false;
|
|
325144
|
+
return this.#canRunEditorHistoryCommand(editor, command$1);
|
|
325145
|
+
}
|
|
325146
|
+
canUndo() {
|
|
325147
|
+
const editor = this.getActiveEditor();
|
|
325148
|
+
if (this.#canRunEditorHistoryCommand(editor, "undo"))
|
|
325149
|
+
return true;
|
|
325150
|
+
if (editor === this.#editor)
|
|
325151
|
+
return this.#canRunPersistentStoryHistoryCommand("undo");
|
|
325152
|
+
return false;
|
|
325153
|
+
}
|
|
325154
|
+
canRedo() {
|
|
325155
|
+
const editor = this.getActiveEditor();
|
|
325156
|
+
if (this.#canRunEditorHistoryCommand(editor, "redo"))
|
|
325157
|
+
return true;
|
|
325158
|
+
if (editor === this.#editor)
|
|
325159
|
+
return this.#canRunPersistentStoryHistoryCommand("redo");
|
|
325160
|
+
return false;
|
|
325161
|
+
}
|
|
324992
325162
|
undo() {
|
|
324993
325163
|
const editor = this.getActiveEditor();
|
|
324994
|
-
|
|
324995
|
-
|
|
325164
|
+
const { didRun, didChangeDoc } = this.#runEditorHistoryCommand(editor, "undo");
|
|
325165
|
+
if (didRun && (editor !== this.#editor || didChangeDoc))
|
|
325166
|
+
return true;
|
|
325167
|
+
if (editor === this.#editor)
|
|
325168
|
+
return this.#runPersistentStoryHistoryCommand("undo");
|
|
324996
325169
|
return false;
|
|
324997
325170
|
}
|
|
324998
325171
|
redo() {
|
|
324999
325172
|
const editor = this.getActiveEditor();
|
|
325000
|
-
|
|
325001
|
-
|
|
325173
|
+
const { didRun, didChangeDoc } = this.#runEditorHistoryCommand(editor, "redo");
|
|
325174
|
+
if (didRun && (editor !== this.#editor || didChangeDoc))
|
|
325175
|
+
return true;
|
|
325176
|
+
if (editor === this.#editor)
|
|
325177
|
+
return this.#runPersistentStoryHistoryCommand("redo");
|
|
325002
325178
|
return false;
|
|
325003
325179
|
}
|
|
325004
325180
|
dispatchInActiveEditor(callback) {
|
|
@@ -325658,22 +325834,34 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
325658
325834
|
const normalized = this.#normalizeClientPoint(clientX, clientY);
|
|
325659
325835
|
if (!normalized)
|
|
325660
325836
|
return null;
|
|
325837
|
+
const noteContext = this.#buildActiveNoteLayoutContext();
|
|
325838
|
+
if (noteContext) {
|
|
325839
|
+
const rawHit$1 = this.#resolveNoteDomHit(noteContext, clientX, clientY) ?? clickToPositionGeometry(this.#layoutState.layout, noteContext.blocks, noteContext.measures, normalized, { geometryHelper: this.#pageGeometryHelper ?? undefined });
|
|
325840
|
+
if (!rawHit$1)
|
|
325841
|
+
return null;
|
|
325842
|
+
const doc$2 = this.getActiveEditor().state?.doc;
|
|
325843
|
+
if (!doc$2)
|
|
325844
|
+
return rawHit$1;
|
|
325845
|
+
return {
|
|
325846
|
+
...rawHit$1,
|
|
325847
|
+
pos: Math.max(0, Math.min(rawHit$1.pos, doc$2.content.size))
|
|
325848
|
+
};
|
|
325849
|
+
}
|
|
325661
325850
|
if ((this.#headerFooterSession?.session?.mode ?? "body") !== "body") {
|
|
325662
325851
|
const context = this.#getHeaderFooterContext();
|
|
325663
325852
|
if (!context)
|
|
325664
325853
|
return null;
|
|
325665
|
-
const
|
|
325854
|
+
const pageGap = this.#layoutState.layout?.pageGap ?? this.#getEffectivePageGap();
|
|
325666
325855
|
const bodyPageHeight = this.#getBodyPageHeight();
|
|
325667
|
-
if (Math.max(0, Math.floor(normalized.y / bodyPageHeight)) !== context.region.pageIndex)
|
|
325856
|
+
if ((normalized.pageIndex ?? Math.max(0, Math.floor(normalized.y / (bodyPageHeight + pageGap)))) !== context.region.pageIndex)
|
|
325668
325857
|
return null;
|
|
325669
325858
|
const localX = normalized.x - context.region.localX;
|
|
325670
|
-
const localY = normalized.y - context.region.pageIndex * bodyPageHeight - context.region.localY;
|
|
325859
|
+
const localY = (normalized.pageLocalY ?? normalized.y - context.region.pageIndex * (bodyPageHeight + pageGap)) - context.region.localY;
|
|
325671
325860
|
if (localX < 0 || localY < 0 || localX > context.region.width || localY > context.region.height)
|
|
325672
325861
|
return null;
|
|
325673
|
-
const headerPageIndex = Math.floor(localY / headerPageHeight);
|
|
325674
325862
|
const headerPoint = {
|
|
325675
325863
|
x: localX,
|
|
325676
|
-
y:
|
|
325864
|
+
y: localY
|
|
325677
325865
|
};
|
|
325678
325866
|
const hit = clickToPositionGeometry(context.layout, context.blocks, context.measures, headerPoint) ?? null;
|
|
325679
325867
|
if (!hit)
|
|
@@ -325686,19 +325874,6 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
325686
325874
|
pos: Math.max(0, Math.min(hit.pos, doc$2.content.size))
|
|
325687
325875
|
};
|
|
325688
325876
|
}
|
|
325689
|
-
const noteContext = this.#buildActiveNoteLayoutContext();
|
|
325690
|
-
if (noteContext) {
|
|
325691
|
-
const rawHit$1 = this.#resolveNoteDomHit(noteContext, clientX, clientY) ?? clickToPositionGeometry(this.#layoutState.layout, noteContext.blocks, noteContext.measures, normalized, { geometryHelper: this.#pageGeometryHelper ?? undefined });
|
|
325692
|
-
if (!rawHit$1)
|
|
325693
|
-
return null;
|
|
325694
|
-
const doc$2 = this.getActiveEditor().state?.doc;
|
|
325695
|
-
if (!doc$2)
|
|
325696
|
-
return rawHit$1;
|
|
325697
|
-
return {
|
|
325698
|
-
...rawHit$1,
|
|
325699
|
-
pos: Math.max(0, Math.min(rawHit$1.pos, doc$2.content.size))
|
|
325700
|
-
};
|
|
325701
|
-
}
|
|
325702
325877
|
if (!this.#layoutState.layout)
|
|
325703
325878
|
return null;
|
|
325704
325879
|
const rawHit = resolvePointerPositionHit({
|
|
@@ -326974,6 +327149,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
326974
327149
|
const transactionHandler = ({ transaction }) => {
|
|
326975
327150
|
if (!transaction?.docChanged)
|
|
326976
327151
|
return;
|
|
327152
|
+
if (this.#persistentStorySessionEditors.has(session.editor))
|
|
327153
|
+
this.#lastPersistentStoryHistoryEditor = session.editor;
|
|
326977
327154
|
if (session.kind === "note") {
|
|
326978
327155
|
this.#invalidateTrackedChangesForStory(session.locator);
|
|
326979
327156
|
this.#pendingDocChange = true;
|
|
@@ -327014,8 +327191,22 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
327014
327191
|
return this.#visibleHost?.ownerDocument?.body ?? this.#visibleHost ?? null;
|
|
327015
327192
|
},
|
|
327016
327193
|
editorFactory: ({ runtime, hostElement, activationOptions }) => {
|
|
327017
|
-
const pmJson = runtime.editor.getJSON();
|
|
327018
327194
|
const editorContext = activationOptions.editorContext ?? {};
|
|
327195
|
+
if (runtime.kind === "headerFooter" && runtime.locator.storyType === "headerFooterPart") {
|
|
327196
|
+
const descriptor = this.#headerFooterSession?.manager?.getDescriptorById(runtime.locator.refId) ?? null;
|
|
327197
|
+
const persisted = descriptor ? this.#headerFooterSession?.manager?.ensureEditorSync(descriptor, {
|
|
327198
|
+
editorHost: hostElement,
|
|
327199
|
+
availableWidth: editorContext.availableWidth,
|
|
327200
|
+
availableHeight: editorContext.availableHeight,
|
|
327201
|
+
currentPageNumber: editorContext.currentPageNumber,
|
|
327202
|
+
totalPageCount: editorContext.totalPageCount
|
|
327203
|
+
}) ?? null : null;
|
|
327204
|
+
if (persisted) {
|
|
327205
|
+
this.#persistentStorySessionEditors.add(persisted);
|
|
327206
|
+
return { editor: persisted };
|
|
327207
|
+
}
|
|
327208
|
+
}
|
|
327209
|
+
const pmJson = runtime.editor.getJSON();
|
|
327019
327210
|
const fresh = createStoryEditor(this.#editor, pmJson, {
|
|
327020
327211
|
documentId: runtime.storyKey,
|
|
327021
327212
|
isHeaderOrFooter: runtime.kind === "headerFooter",
|
|
@@ -328326,6 +328517,8 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
328326
328517
|
return Selection.near(doc$12.resolve(clampedPos), bias);
|
|
328327
328518
|
}
|
|
328328
328519
|
#activateRenderedNoteSession(target, options) {
|
|
328520
|
+
if ((this.#headerFooterSession?.session?.mode ?? "body") !== "body")
|
|
328521
|
+
this.#headerFooterSession?.exitMode();
|
|
328329
328522
|
const storySessionManager = this.#ensureStorySessionManager();
|
|
328330
328523
|
if (target.storyType !== "footnote" && target.storyType !== "endnote")
|
|
328331
328524
|
return false;
|
|
@@ -329658,11 +329851,11 @@ var init_zipper_DbkgrypV_es = __esm(() => {
|
|
|
329658
329851
|
|
|
329659
329852
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
329660
329853
|
var init_super_editor_es = __esm(() => {
|
|
329661
|
-
|
|
329662
|
-
|
|
329854
|
+
init_src_Bn82VlNp_es();
|
|
329855
|
+
init_SuperConverter_kY_NnfwW_es();
|
|
329663
329856
|
init_jszip_C49i9kUs_es();
|
|
329664
329857
|
init_xml_js_CqGKpaft_es();
|
|
329665
|
-
|
|
329858
|
+
init_create_headless_toolbar_5SsdVL_D_es();
|
|
329666
329859
|
init_constants_CGhJRd87_es();
|
|
329667
329860
|
init_dist_B8HfvhaK_es();
|
|
329668
329861
|
init_unified_Dsuw2be5_es();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc-dev/cli",
|
|
3
|
-
"version": "0.8.0-next.
|
|
3
|
+
"version": "0.8.0-next.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superdoc": "./dist/index.js"
|
|
@@ -26,19 +26,19 @@
|
|
|
26
26
|
"typescript": "^5.9.2",
|
|
27
27
|
"@superdoc/document-api": "0.0.1",
|
|
28
28
|
"@superdoc/pm-adapter": "0.0.0",
|
|
29
|
-
"superdoc": "
|
|
30
|
-
"
|
|
29
|
+
"@superdoc/super-editor": "0.0.1",
|
|
30
|
+
"superdoc": "1.28.0"
|
|
31
31
|
},
|
|
32
32
|
"module": "src/index.ts",
|
|
33
33
|
"publishConfig": {
|
|
34
34
|
"access": "public"
|
|
35
35
|
},
|
|
36
36
|
"optionalDependencies": {
|
|
37
|
-
"@superdoc-dev/cli-darwin-arm64": "0.8.0-next.
|
|
38
|
-
"@superdoc-dev/cli-darwin-x64": "0.8.0-next.
|
|
39
|
-
"@superdoc-dev/cli-linux-arm64": "0.8.0-next.
|
|
40
|
-
"@superdoc-dev/cli-windows-x64": "0.8.0-next.
|
|
41
|
-
"@superdoc-dev/cli-linux-x64": "0.8.0-next.
|
|
37
|
+
"@superdoc-dev/cli-darwin-arm64": "0.8.0-next.15",
|
|
38
|
+
"@superdoc-dev/cli-darwin-x64": "0.8.0-next.15",
|
|
39
|
+
"@superdoc-dev/cli-linux-arm64": "0.8.0-next.15",
|
|
40
|
+
"@superdoc-dev/cli-windows-x64": "0.8.0-next.15",
|
|
41
|
+
"@superdoc-dev/cli-linux-x64": "0.8.0-next.15"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"predev": "node scripts/ensure-superdoc-build.js",
|