@superdoc-dev/cli 0.2.0-next.122 → 0.2.0-next.123
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 +1148 -436
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -38237,7 +38237,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
|
|
|
38237
38237
|
emptyOptions2 = {};
|
|
38238
38238
|
});
|
|
38239
38239
|
|
|
38240
|
-
// ../../packages/superdoc/dist/chunks/SuperConverter-
|
|
38240
|
+
// ../../packages/superdoc/dist/chunks/SuperConverter-BeR1rqZz.es.js
|
|
38241
38241
|
function getExtensionConfigField(extension$1, field, context = { name: "" }) {
|
|
38242
38242
|
const fieldValue = extension$1.config[field];
|
|
38243
38243
|
if (typeof fieldValue === "function")
|
|
@@ -58454,19 +58454,18 @@ function importCommentData({ docx, editor, converter }) {
|
|
|
58454
58454
|
}
|
|
58455
58455
|
return extendedComments;
|
|
58456
58456
|
}
|
|
58457
|
-
function
|
|
58457
|
+
function importNoteEntries({ partXml, childElementName, filename, docx, editor, converter, nodeListHandler, numbering }) {
|
|
58458
58458
|
const handler$1 = nodeListHandler || defaultNodeListHandler();
|
|
58459
|
-
|
|
58460
|
-
if (!footnotes?.elements?.length)
|
|
58459
|
+
if (!partXml?.elements?.length)
|
|
58461
58460
|
return [];
|
|
58462
|
-
const root2 =
|
|
58463
|
-
const
|
|
58464
|
-
if (
|
|
58461
|
+
const root2 = partXml.elements[0];
|
|
58462
|
+
const noteElements = (Array.isArray(root2?.elements) ? root2.elements : []).filter((el) => el?.name === childElementName);
|
|
58463
|
+
if (noteElements.length === 0)
|
|
58465
58464
|
return [];
|
|
58466
58465
|
const results = [];
|
|
58467
58466
|
const lists = {};
|
|
58468
58467
|
const inlineDocumentFonts = [];
|
|
58469
|
-
|
|
58468
|
+
noteElements.forEach((el) => {
|
|
58470
58469
|
const idRaw = el?.attributes?.["w:id"];
|
|
58471
58470
|
if (idRaw === undefined || idRaw === null)
|
|
58472
58471
|
return;
|
|
@@ -58495,7 +58494,7 @@ function importFootnoteData({ docx, editor, converter, nodeListHandler, numberin
|
|
|
58495
58494
|
numbering,
|
|
58496
58495
|
lists,
|
|
58497
58496
|
inlineDocumentFonts,
|
|
58498
|
-
filename
|
|
58497
|
+
filename,
|
|
58499
58498
|
path: [el]
|
|
58500
58499
|
}));
|
|
58501
58500
|
results.push({
|
|
@@ -58507,6 +58506,30 @@ function importFootnoteData({ docx, editor, converter, nodeListHandler, numberin
|
|
|
58507
58506
|
});
|
|
58508
58507
|
return results;
|
|
58509
58508
|
}
|
|
58509
|
+
function importFootnoteData({ docx, editor, converter, nodeListHandler, numbering } = {}) {
|
|
58510
|
+
return importNoteEntries({
|
|
58511
|
+
partXml: docx?.["word/footnotes.xml"],
|
|
58512
|
+
childElementName: "w:footnote",
|
|
58513
|
+
filename: "footnotes.xml",
|
|
58514
|
+
docx,
|
|
58515
|
+
editor,
|
|
58516
|
+
converter,
|
|
58517
|
+
nodeListHandler,
|
|
58518
|
+
numbering
|
|
58519
|
+
});
|
|
58520
|
+
}
|
|
58521
|
+
function importEndnoteData({ docx, editor, converter, nodeListHandler, numbering } = {}) {
|
|
58522
|
+
return importNoteEntries({
|
|
58523
|
+
partXml: docx?.["word/endnotes.xml"],
|
|
58524
|
+
childElementName: "w:endnote",
|
|
58525
|
+
filename: "endnotes.xml",
|
|
58526
|
+
docx,
|
|
58527
|
+
editor,
|
|
58528
|
+
converter,
|
|
58529
|
+
nodeListHandler,
|
|
58530
|
+
numbering
|
|
58531
|
+
});
|
|
58532
|
+
}
|
|
58510
58533
|
function toIdentityValue(value) {
|
|
58511
58534
|
if (typeof value === "string" && value.length > 0)
|
|
58512
58535
|
return value;
|
|
@@ -73633,6 +73656,13 @@ var isRegExp = (value) => {
|
|
|
73633
73656
|
editor,
|
|
73634
73657
|
numbering
|
|
73635
73658
|
});
|
|
73659
|
+
const endnotes = importEndnoteData({
|
|
73660
|
+
docx,
|
|
73661
|
+
nodeListHandler,
|
|
73662
|
+
converter,
|
|
73663
|
+
editor,
|
|
73664
|
+
numbering
|
|
73665
|
+
});
|
|
73636
73666
|
const translatedLinkedStyles = translateStyleDefinitions(docx);
|
|
73637
73667
|
const translatedNumbering = translateNumberingDefinitions(docx);
|
|
73638
73668
|
const importDiagnosticsCollectionId = startCollection();
|
|
@@ -73668,6 +73698,7 @@ var isRegExp = (value) => {
|
|
|
73668
73698
|
pageStyles: getDocumentStyles(node3, docx, converter, editor, numbering, translatedNumbering, translatedLinkedStyles),
|
|
73669
73699
|
comments,
|
|
73670
73700
|
footnotes,
|
|
73701
|
+
endnotes,
|
|
73671
73702
|
inlineDocumentFonts,
|
|
73672
73703
|
linkedStyles: getStyleDefinitions(docx, converter, editor),
|
|
73673
73704
|
translatedLinkedStyles,
|
|
@@ -74570,7 +74601,7 @@ var isRegExp = (value) => {
|
|
|
74570
74601
|
state.kern = kernNode.attributes["w:val"];
|
|
74571
74602
|
}
|
|
74572
74603
|
}, SuperConverter;
|
|
74573
|
-
var
|
|
74604
|
+
var init_SuperConverter_BeR1rqZz_es = __esm(() => {
|
|
74574
74605
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
74575
74606
|
init_jszip_ChlR43oI_es();
|
|
74576
74607
|
init_xml_js_DLE8mr0n_es();
|
|
@@ -107945,6 +107976,7 @@ var init_SuperConverter_BBGfKYpx_es = __esm(() => {
|
|
|
107945
107976
|
this.numbering = result.numbering;
|
|
107946
107977
|
this.comments = result.comments;
|
|
107947
107978
|
this.footnotes = result.footnotes;
|
|
107979
|
+
this.endnotes = result.endnotes ?? [];
|
|
107948
107980
|
this.linkedStyles = result.linkedStyles;
|
|
107949
107981
|
this.translatedLinkedStyles = result.translatedLinkedStyles;
|
|
107950
107982
|
this.translatedNumbering = result.translatedNumbering;
|
|
@@ -108247,6 +108279,16 @@ var init_SuperConverter_BBGfKYpx_es = __esm(() => {
|
|
|
108247
108279
|
content: [...schema]
|
|
108248
108280
|
};
|
|
108249
108281
|
}
|
|
108282
|
+
reimportNotePart(partId) {
|
|
108283
|
+
if (!this.convertedXml?.[partId])
|
|
108284
|
+
return [];
|
|
108285
|
+
return (partId === "word/endnotes.xml" ? importEndnoteData : importFootnoteData)({
|
|
108286
|
+
docx: this.convertedXml,
|
|
108287
|
+
editor: {},
|
|
108288
|
+
converter: this,
|
|
108289
|
+
numbering: this.numbering
|
|
108290
|
+
});
|
|
108291
|
+
}
|
|
108250
108292
|
createDefaultHeader(variant = "default") {
|
|
108251
108293
|
if (typeof variant !== "string")
|
|
108252
108294
|
throw new TypeError(`variant must be a string, received ${typeof variant}`);
|
|
@@ -134644,7 +134686,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
|
|
|
134644
134686
|
init_remark_gfm_z_sDF4ss_es();
|
|
134645
134687
|
});
|
|
134646
134688
|
|
|
134647
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
134689
|
+
// ../../packages/superdoc/dist/chunks/src-BnjrN0Yi.es.js
|
|
134648
134690
|
function deleteProps(obj, propOrProps) {
|
|
134649
134691
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
134650
134692
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -140516,7 +140558,7 @@ function createPartPublisher(editor, ydoc, options = {}) {
|
|
|
140516
140558
|
destroy
|
|
140517
140559
|
};
|
|
140518
140560
|
}
|
|
140519
|
-
function getConverter$
|
|
140561
|
+
function getConverter$12(editor) {
|
|
140520
140562
|
return editor.converter;
|
|
140521
140563
|
}
|
|
140522
140564
|
function isHeaderPartId(partId) {
|
|
@@ -140551,7 +140593,7 @@ function ensureHeaderFooterDescriptor(partId, sectionId) {
|
|
|
140551
140593
|
};
|
|
140552
140594
|
},
|
|
140553
140595
|
afterCommit(ctx$1) {
|
|
140554
|
-
const converter = getConverter$
|
|
140596
|
+
const converter = getConverter$12(ctx$1.editor);
|
|
140555
140597
|
if (!converter)
|
|
140556
140598
|
return;
|
|
140557
140599
|
const resolvedSectionId = ctx$1.sectionId ?? sectionId;
|
|
@@ -140571,7 +140613,7 @@ function ensureHeaderFooterDescriptor(partId, sectionId) {
|
|
|
140571
140613
|
refreshActiveSubEditors(converter, type, resolvedSectionId);
|
|
140572
140614
|
},
|
|
140573
140615
|
onDelete(ctx$1) {
|
|
140574
|
-
const converter = getConverter$
|
|
140616
|
+
const converter = getConverter$12(ctx$1.editor);
|
|
140575
140617
|
if (!converter)
|
|
140576
140618
|
return;
|
|
140577
140619
|
const resolvedSectionId = ctx$1.sectionId ?? sectionId;
|
|
@@ -140618,11 +140660,11 @@ function registerHeaderFooterInvalidationHandler(partId) {
|
|
|
140618
140660
|
} catch {}
|
|
140619
140661
|
});
|
|
140620
140662
|
}
|
|
140621
|
-
function getConverter$
|
|
140663
|
+
function getConverter$11(editor) {
|
|
140622
140664
|
return editor.converter;
|
|
140623
140665
|
}
|
|
140624
140666
|
function resolvePartIdFromSectionId(editor, sectionId) {
|
|
140625
|
-
const relsRoot = getConverter$
|
|
140667
|
+
const relsRoot = getConverter$11(editor)?.convertedXml?.["word/_rels/document.xml.rels"]?.elements?.find((el) => el.name === "Relationships");
|
|
140626
140668
|
if (!relsRoot?.elements)
|
|
140627
140669
|
return null;
|
|
140628
140670
|
for (const el of relsRoot.elements) {
|
|
@@ -140664,14 +140706,14 @@ function resolveHeaderFooterRId(partId, relsData, editor) {
|
|
|
140664
140706
|
return rId;
|
|
140665
140707
|
}
|
|
140666
140708
|
if (editor) {
|
|
140667
|
-
const localRels = getConverter$
|
|
140709
|
+
const localRels = getConverter$11(editor)?.convertedXml?.["word/_rels/document.xml.rels"];
|
|
140668
140710
|
if (localRels)
|
|
140669
140711
|
return resolveRIdFromRelsData(localRels, partId);
|
|
140670
140712
|
}
|
|
140671
140713
|
return null;
|
|
140672
140714
|
}
|
|
140673
140715
|
function exportSubEditorToPart(mainEditor, subEditor, sectionId, type) {
|
|
140674
|
-
const converter = getConverter$
|
|
140716
|
+
const converter = getConverter$11(mainEditor);
|
|
140675
140717
|
if (!converter?.exportToXmlJson)
|
|
140676
140718
|
return false;
|
|
140677
140719
|
const partId = resolvePartIdFromSectionId(mainEditor, sectionId);
|
|
@@ -140734,7 +140776,7 @@ function exportSubEditorToPart(mainEditor, subEditor, sectionId, type) {
|
|
|
140734
140776
|
}
|
|
140735
140777
|
}
|
|
140736
140778
|
function registerExistingHeaderFooterDescriptors(editor) {
|
|
140737
|
-
const converter = getConverter$
|
|
140779
|
+
const converter = getConverter$11(editor);
|
|
140738
140780
|
if (!converter?.convertedXml)
|
|
140739
140781
|
return;
|
|
140740
140782
|
const relsRoot = converter.convertedXml["word/_rels/document.xml.rels"]?.elements?.find((el) => el.name === "Relationships");
|
|
@@ -143875,11 +143917,11 @@ function pxToInches$1(value) {
|
|
|
143875
143917
|
function buildSectionId(index2) {
|
|
143876
143918
|
return `section-${index2}`;
|
|
143877
143919
|
}
|
|
143878
|
-
function getConverter$
|
|
143920
|
+
function getConverter$10(editor) {
|
|
143879
143921
|
return editor.converter;
|
|
143880
143922
|
}
|
|
143881
143923
|
function getBodySectPrFromEditor(editor) {
|
|
143882
|
-
const converter = getConverter$
|
|
143924
|
+
const converter = getConverter$10(editor);
|
|
143883
143925
|
if (isSectPrElement$1(converter?.bodySectPr))
|
|
143884
143926
|
return cloneXmlElement(converter.bodySectPr);
|
|
143885
143927
|
const docAttrs = editor.state.doc.attrs ?? {};
|
|
@@ -143928,7 +143970,7 @@ function resolveAnalysisDoc(editor, paragraphs) {
|
|
|
143928
143970
|
return buildAnalysisDocFromParagraphs(paragraphs);
|
|
143929
143971
|
}
|
|
143930
143972
|
function getSettingsRoot(editor) {
|
|
143931
|
-
const settingsPart = getConverter$
|
|
143973
|
+
const settingsPart = getConverter$10(editor)?.convertedXml?.["word/settings.xml"];
|
|
143932
143974
|
if (!settingsPart)
|
|
143933
143975
|
return null;
|
|
143934
143976
|
if (settingsPart.name === "w:settings")
|
|
@@ -143938,7 +143980,7 @@ function getSettingsRoot(editor) {
|
|
|
143938
143980
|
return settingsPart.elements.find((entry) => entry.name === "w:settings") ?? null;
|
|
143939
143981
|
}
|
|
143940
143982
|
function readOddEvenHeadersFlag(editor) {
|
|
143941
|
-
const converter = getConverter$
|
|
143983
|
+
const converter = getConverter$10(editor);
|
|
143942
143984
|
if (converter?.pageStyles?.alternateHeaders != null)
|
|
143943
143985
|
return converter.pageStyles.alternateHeaders === true;
|
|
143944
143986
|
const settingsRoot = getSettingsRoot(editor);
|
|
@@ -148983,11 +149025,11 @@ function executePlan(editor, input2) {
|
|
|
148983
149025
|
expectedRevision: input2.expectedRevision
|
|
148984
149026
|
});
|
|
148985
149027
|
}
|
|
148986
|
-
function getConverter$
|
|
149028
|
+
function getConverter$9(editor) {
|
|
148987
149029
|
return editor.converter;
|
|
148988
149030
|
}
|
|
148989
149031
|
function takeSnapshot(editor, partIds) {
|
|
148990
|
-
const converter = getConverter$
|
|
149032
|
+
const converter = getConverter$9(editor);
|
|
148991
149033
|
const partEntries = /* @__PURE__ */ new Map;
|
|
148992
149034
|
if (converter?.convertedXml)
|
|
148993
149035
|
for (const partId of partIds) {
|
|
@@ -149002,13 +149044,16 @@ function takeSnapshot(editor, partIds) {
|
|
|
149002
149044
|
partEntries,
|
|
149003
149045
|
numbering: converter?.numbering ? clonePart(converter.numbering) : undefined,
|
|
149004
149046
|
translatedNumbering: converter?.translatedNumbering ? clonePart(converter.translatedNumbering) : undefined,
|
|
149047
|
+
footnotes: converter?.footnotes ? clonePart(converter.footnotes) : undefined,
|
|
149048
|
+
endnotes: converter?.endnotes ? clonePart(converter.endnotes) : undefined,
|
|
149049
|
+
footnoteProperties: converter?.footnoteProperties ? clonePart(converter.footnoteProperties) : undefined,
|
|
149005
149050
|
revision: getRevision(editor),
|
|
149006
149051
|
documentModified: converter?.documentModified ?? false,
|
|
149007
149052
|
documentGuid: converter?.documentGuid ?? null
|
|
149008
149053
|
};
|
|
149009
149054
|
}
|
|
149010
149055
|
function restoreFromSnapshot(editor, snapshot2) {
|
|
149011
|
-
const converter = getConverter$
|
|
149056
|
+
const converter = getConverter$9(editor);
|
|
149012
149057
|
if (!converter)
|
|
149013
149058
|
return;
|
|
149014
149059
|
if (converter.convertedXml)
|
|
@@ -149023,6 +149068,12 @@ function restoreFromSnapshot(editor, snapshot2) {
|
|
|
149023
149068
|
converter.numbering = snapshot2.numbering;
|
|
149024
149069
|
if (snapshot2.translatedNumbering !== undefined)
|
|
149025
149070
|
converter.translatedNumbering = snapshot2.translatedNumbering;
|
|
149071
|
+
if (snapshot2.footnotes !== undefined)
|
|
149072
|
+
converter.footnotes = snapshot2.footnotes;
|
|
149073
|
+
if (snapshot2.endnotes !== undefined)
|
|
149074
|
+
converter.endnotes = snapshot2.endnotes;
|
|
149075
|
+
if (snapshot2.footnoteProperties !== undefined)
|
|
149076
|
+
converter.footnoteProperties = snapshot2.footnoteProperties;
|
|
149026
149077
|
converter.documentModified = snapshot2.documentModified;
|
|
149027
149078
|
converter.documentGuid = snapshot2.documentGuid;
|
|
149028
149079
|
restoreRevision(editor, snapshot2.revision);
|
|
@@ -154683,11 +154734,11 @@ function assertRunTilingInvariant(runs2, blockRange, blockId) {
|
|
|
154683
154734
|
if (runs2[i$1].range.end !== runs2[i$1 + 1].range.start)
|
|
154684
154735
|
throw planError("INTERNAL_ERROR", `run-tiling: gap or overlap between runs[${i$1}] and runs[${i$1 + 1}] in block ${blockId}`);
|
|
154685
154736
|
}
|
|
154686
|
-
function getConverter$
|
|
154737
|
+
function getConverter$8(editor) {
|
|
154687
154738
|
return editor.converter;
|
|
154688
154739
|
}
|
|
154689
154740
|
function readTranslatedLinkedStyles(editor) {
|
|
154690
|
-
return getConverter$
|
|
154741
|
+
return getConverter$8(editor)?.translatedLinkedStyles ?? null;
|
|
154691
154742
|
}
|
|
154692
154743
|
function encodeV3Ref(payload) {
|
|
154693
154744
|
return `text:${btoa(JSON.stringify(payload))}`;
|
|
@@ -158220,10 +158271,10 @@ function registerBuiltInExecutors() {
|
|
|
158220
158271
|
};
|
|
158221
158272
|
} });
|
|
158222
158273
|
}
|
|
158223
|
-
function getConverter$
|
|
158274
|
+
function getConverter$7(editor) {
|
|
158224
158275
|
return editor.converter;
|
|
158225
158276
|
}
|
|
158226
|
-
function getConverter$
|
|
158277
|
+
function getConverter$6(editor) {
|
|
158227
158278
|
return editor.converter;
|
|
158228
158279
|
}
|
|
158229
158280
|
function createEmptyHeaderFooterJson() {
|
|
@@ -158236,7 +158287,7 @@ function createEmptyHeaderFooterJson() {
|
|
|
158236
158287
|
};
|
|
158237
158288
|
}
|
|
158238
158289
|
function syncHeaderFooterCaches(editor, part) {
|
|
158239
|
-
const converter = getConverter$
|
|
158290
|
+
const converter = getConverter$6(editor);
|
|
158240
158291
|
if (!converter)
|
|
158241
158292
|
return;
|
|
158242
158293
|
const relsRoot = part?.elements?.find((el) => el.name === "Relationships");
|
|
@@ -158311,9 +158362,18 @@ function handleHeaderFooterInvalidation(editor, _event) {
|
|
|
158311
158362
|
editor.view?.dispatch?.(tr);
|
|
158312
158363
|
} catch {}
|
|
158313
158364
|
}
|
|
158365
|
+
function handleNotesInvalidation(editor, _event) {
|
|
158366
|
+
try {
|
|
158367
|
+
const tr = editor.state.tr;
|
|
158368
|
+
tr.setMeta("forceUpdatePagination", true);
|
|
158369
|
+
editor.view?.dispatch?.(tr);
|
|
158370
|
+
} catch {}
|
|
158371
|
+
}
|
|
158314
158372
|
function registerStaticInvalidationHandlers() {
|
|
158315
158373
|
registerInvalidationHandler("word/numbering.xml", handleNumberingInvalidation);
|
|
158316
158374
|
registerInvalidationHandler("word/_rels/document.xml.rels", handleRelationshipsInvalidation);
|
|
158375
|
+
registerInvalidationHandler("word/footnotes.xml", handleNotesInvalidation);
|
|
158376
|
+
registerInvalidationHandler("word/endnotes.xml", handleNotesInvalidation);
|
|
158317
158377
|
}
|
|
158318
158378
|
function registerHeaderFooterInvalidation(partId) {
|
|
158319
158379
|
registerInvalidationHandler(partId, handleHeaderFooterInvalidation);
|
|
@@ -158578,7 +158638,7 @@ function resolveEffectiveRef(editor, sections, startSectionIndex, kind, variant)
|
|
|
158578
158638
|
}
|
|
158579
158639
|
return null;
|
|
158580
158640
|
}
|
|
158581
|
-
function getConverter$
|
|
158641
|
+
function getConverter$5(editor) {
|
|
158582
158642
|
return editor.converter;
|
|
158583
158643
|
}
|
|
158584
158644
|
function setHeaderFooterRefMutation(sectPr, kind, variant, refId, converter, operationName, dryRun = false) {
|
|
@@ -158639,7 +158699,7 @@ function setLinkedToPreviousMutation(sectPr, projection, sections, kind, variant
|
|
|
158639
158699
|
}
|
|
158640
158700
|
};
|
|
158641
158701
|
if (!dryRun && clearedRef) {
|
|
158642
|
-
const converter$1 = getConverter$
|
|
158702
|
+
const converter$1 = getConverter$5(editor);
|
|
158643
158703
|
if (converter$1)
|
|
158644
158704
|
reconcileVariantPointerOnClear(converter$1, kind, clearedRef);
|
|
158645
158705
|
}
|
|
@@ -158676,12 +158736,12 @@ function setLinkedToPreviousMutation(sectPr, projection, sections, kind, variant
|
|
|
158676
158736
|
};
|
|
158677
158737
|
}
|
|
158678
158738
|
setSectPrHeaderFooterRef(sectPr, kind, variant, explicitRefId);
|
|
158679
|
-
const converter = getConverter$
|
|
158739
|
+
const converter = getConverter$5(editor);
|
|
158680
158740
|
if (converter)
|
|
158681
158741
|
reconcileVariantPointerOnSet(converter, kind, variant, explicitRefId);
|
|
158682
158742
|
}
|
|
158683
158743
|
function createExplicitHeaderFooterReference(editor, input2) {
|
|
158684
|
-
if (!getConverter$
|
|
158744
|
+
if (!getConverter$5(editor))
|
|
158685
158745
|
return null;
|
|
158686
158746
|
try {
|
|
158687
158747
|
const { refId } = createHeaderFooterPart(editor, {
|
|
@@ -158719,7 +158779,7 @@ function reconcileVariantPointerOnClear(converter, kind, clearedRefId) {
|
|
|
158719
158779
|
if (variantIds[key$1] === clearedRefId)
|
|
158720
158780
|
variantIds[key$1] = null;
|
|
158721
158781
|
}
|
|
158722
|
-
function getConverter$
|
|
158782
|
+
function getConverter$4(editor) {
|
|
158723
158783
|
return editor.converter;
|
|
158724
158784
|
}
|
|
158725
158785
|
function toSectionFailure$1(code$1, message) {
|
|
@@ -158787,7 +158847,7 @@ function buildSectionMarginsForAttrs$1(sectPr) {
|
|
|
158787
158847
|
};
|
|
158788
158848
|
}
|
|
158789
158849
|
function syncConverterBodySection$1(editor, sectPr) {
|
|
158790
|
-
const converter = getConverter$
|
|
158850
|
+
const converter = getConverter$4(editor);
|
|
158791
158851
|
if (!converter)
|
|
158792
158852
|
return;
|
|
158793
158853
|
converter.bodySectPr = cloneXmlElement(sectPr);
|
|
@@ -158907,7 +158967,7 @@ function createSectionBreakNode(editor, breakParagraphId, input2) {
|
|
|
158907
158967
|
return paragraphNode;
|
|
158908
158968
|
}
|
|
158909
158969
|
function updateGlobalTitlePageFlag(editor) {
|
|
158910
|
-
const converter = getConverter$
|
|
158970
|
+
const converter = getConverter$4(editor);
|
|
158911
158971
|
if (!converter)
|
|
158912
158972
|
return;
|
|
158913
158973
|
const anyTitlePage = resolveSectionProjections(editor).some((entry) => entry.domain.titlePage === true);
|
|
@@ -158991,7 +159051,7 @@ function sectionsSetTitlePageAdapter(editor, input2, options) {
|
|
|
158991
159051
|
}
|
|
158992
159052
|
function sectionsSetOddEvenHeadersFootersAdapter(editor, input2, options) {
|
|
158993
159053
|
rejectTrackedMode("sections.setOddEvenHeadersFooters", options);
|
|
158994
|
-
const converter = getConverter$
|
|
159054
|
+
const converter = getConverter$4(editor);
|
|
158995
159055
|
if (!converter)
|
|
158996
159056
|
throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", "sections.setOddEvenHeadersFooters requires an active document converter.");
|
|
158997
159057
|
return mutatePart({
|
|
@@ -159027,13 +159087,13 @@ function sectionsSetSectionDirectionAdapter(editor, input2, options) {
|
|
|
159027
159087
|
}
|
|
159028
159088
|
function sectionsSetHeaderFooterRefAdapter(editor, input2, options) {
|
|
159029
159089
|
return sectionMutationBySectPr$1(editor, input2, options, "sections.setHeaderFooterRef", (sectPr, _projection, _sections, dryRun) => {
|
|
159030
|
-
const converter = getConverter$
|
|
159090
|
+
const converter = getConverter$4(editor) ?? null;
|
|
159031
159091
|
return setHeaderFooterRefMutation(sectPr, input2.kind, input2.variant, input2.refId, converter, "sections.setHeaderFooterRef", dryRun);
|
|
159032
159092
|
});
|
|
159033
159093
|
}
|
|
159034
159094
|
function sectionsClearHeaderFooterRefAdapter(editor, input2, options) {
|
|
159035
159095
|
return sectionMutationBySectPr$1(editor, input2, options, "sections.clearHeaderFooterRef", (sectPr, _projection, _sections, dryRun) => {
|
|
159036
|
-
const converter = getConverter$
|
|
159096
|
+
const converter = getConverter$4(editor) ?? null;
|
|
159037
159097
|
clearHeaderFooterRefMutation(sectPr, input2.kind, input2.variant, converter, dryRun);
|
|
159038
159098
|
});
|
|
159039
159099
|
}
|
|
@@ -159623,7 +159683,7 @@ function dispatchEditorTransaction(editor, tr) {
|
|
|
159623
159683
|
}
|
|
159624
159684
|
throw new Error("No transaction dispatcher available.");
|
|
159625
159685
|
}
|
|
159626
|
-
function receiptApplied$
|
|
159686
|
+
function receiptApplied$9(receipt2) {
|
|
159627
159687
|
return receipt2.steps[0]?.effect === "changed";
|
|
159628
159688
|
}
|
|
159629
159689
|
function isTocContentUnchanged(existingNode, newContent) {
|
|
@@ -159718,7 +159778,7 @@ function tocConfigureWrapper(editor, input2, options) {
|
|
|
159718
159778
|
const shouldRefreshContent = !isTocContentUnchanged(resolved.node, nextContent);
|
|
159719
159779
|
const command$1 = editor.commands?.setTableOfContentsInstructionById;
|
|
159720
159780
|
const commandNodeId = resolved.commandNodeId ?? resolved.nodeId;
|
|
159721
|
-
if (!receiptApplied$
|
|
159781
|
+
if (!receiptApplied$9(typeof command$1 === "function" ? runTocCommand(editor, command$1, {
|
|
159722
159782
|
sdBlockId: commandNodeId,
|
|
159723
159783
|
instruction,
|
|
159724
159784
|
...shouldRefreshContent ? { content: nextContent } : {},
|
|
@@ -159761,7 +159821,7 @@ function tocUpdateAll(editor, input2, options) {
|
|
|
159761
159821
|
if (options?.dryRun)
|
|
159762
159822
|
return tocSuccess(resolved.nodeId);
|
|
159763
159823
|
const command$1 = editor.commands?.replaceTableOfContentsContentById;
|
|
159764
|
-
return receiptApplied$
|
|
159824
|
+
return receiptApplied$9(typeof command$1 === "function" ? runTocCommand(editor, command$1, {
|
|
159765
159825
|
sdBlockId: resolved.commandNodeId ?? resolved.nodeId,
|
|
159766
159826
|
content: content3
|
|
159767
159827
|
}, options?.expectedRevision) : runTocAction(editor, () => {
|
|
@@ -159804,7 +159864,7 @@ function tocUpdatePageNumbers(editor, input2, options) {
|
|
|
159804
159864
|
if (options?.dryRun)
|
|
159805
159865
|
return tocSuccess(resolved.nodeId);
|
|
159806
159866
|
const command$1 = editor.commands?.replaceTableOfContentsContentById;
|
|
159807
|
-
return receiptApplied$
|
|
159867
|
+
return receiptApplied$9(typeof command$1 === "function" ? runTocCommand(editor, command$1, {
|
|
159808
159868
|
sdBlockId: resolved.commandNodeId ?? resolved.nodeId,
|
|
159809
159869
|
content: updatedContent
|
|
159810
159870
|
}, options?.expectedRevision) : runTocAction(editor, () => {
|
|
@@ -159871,7 +159931,7 @@ function tocRemoveWrapper(editor, input2, options) {
|
|
|
159871
159931
|
if (options?.dryRun)
|
|
159872
159932
|
return tocSuccess(resolved.nodeId);
|
|
159873
159933
|
const command$1 = editor.commands?.deleteTableOfContentsById;
|
|
159874
|
-
return receiptApplied$
|
|
159934
|
+
return receiptApplied$9(typeof command$1 === "function" ? runTocCommand(editor, command$1, { sdBlockId: resolved.commandNodeId ?? resolved.nodeId }, options?.expectedRevision) : runTocAction(editor, () => {
|
|
159875
159935
|
try {
|
|
159876
159936
|
const { tr } = editor.state;
|
|
159877
159937
|
tr.delete(resolved.pos, resolved.pos + resolved.node.nodeSize);
|
|
@@ -159902,7 +159962,7 @@ function createTableOfContentsWrapper(editor, input2, options) {
|
|
|
159902
159962
|
toc: buildTocAddress("(dry-run)")
|
|
159903
159963
|
};
|
|
159904
159964
|
const command$1 = editor.commands?.insertTableOfContentsAt;
|
|
159905
|
-
if (!receiptApplied$
|
|
159965
|
+
if (!receiptApplied$9(typeof command$1 === "function" ? runTocCommand(editor, command$1, {
|
|
159906
159966
|
pos,
|
|
159907
159967
|
instruction,
|
|
159908
159968
|
sdBlockId,
|
|
@@ -160097,7 +160157,7 @@ function runEntryCommand(editor, command$1, args$1, expectedRevision) {
|
|
|
160097
160157
|
const executeCommand = toEntryEditorCommand(command$1);
|
|
160098
160158
|
return runEntryAction(editor, () => executeCommand(args$1), expectedRevision);
|
|
160099
160159
|
}
|
|
160100
|
-
function receiptApplied$
|
|
160160
|
+
function receiptApplied$8(receipt2) {
|
|
160101
160161
|
return receipt2.steps[0]?.effect === "changed";
|
|
160102
160162
|
}
|
|
160103
160163
|
function tocListEntriesWrapper(editor, query2) {
|
|
@@ -160144,7 +160204,7 @@ function tocMarkEntryWrapper(editor, input2, options) {
|
|
|
160144
160204
|
const pos = (input2.target.position ?? "end") === "start" ? paragraph2.pos + 1 : paragraph2.pos + paragraph2.node.nodeSize - 1;
|
|
160145
160205
|
if (options?.dryRun)
|
|
160146
160206
|
return entrySuccess$2("(dry-run)");
|
|
160147
|
-
if (!receiptApplied$
|
|
160207
|
+
if (!receiptApplied$8(runEntryCommand(editor, command$1, {
|
|
160148
160208
|
pos,
|
|
160149
160209
|
instruction
|
|
160150
160210
|
}, options?.expectedRevision)))
|
|
@@ -160166,7 +160226,7 @@ function tocUnmarkEntryWrapper(editor, input2, options) {
|
|
|
160166
160226
|
const resolved = resolveTcEntryTarget(editor.state.doc, input2.target);
|
|
160167
160227
|
if (options?.dryRun)
|
|
160168
160228
|
return entrySuccess$2(resolved.nodeId);
|
|
160169
|
-
return receiptApplied$
|
|
160229
|
+
return receiptApplied$8(runEntryCommand(editor, command$1, { pos: resolved.pos }, options?.expectedRevision)) ? entrySuccess$2(resolved.nodeId) : entryFailure$2("NO_OP", "TC entry removal produced no change.");
|
|
160170
160230
|
}
|
|
160171
160231
|
function tocEditEntryWrapper(editor, input2, options) {
|
|
160172
160232
|
rejectTrackedMode("toc.editEntry", options);
|
|
@@ -160179,7 +160239,7 @@ function tocEditEntryWrapper(editor, input2, options) {
|
|
|
160179
160239
|
return entryFailure$2("NO_OP", "Edit patch produced no change.");
|
|
160180
160240
|
if (options?.dryRun)
|
|
160181
160241
|
return entrySuccess$2(resolved.nodeId);
|
|
160182
|
-
if (!receiptApplied$
|
|
160242
|
+
if (!receiptApplied$8(runEntryCommand(editor, command$1, {
|
|
160183
160243
|
pos: resolved.pos,
|
|
160184
160244
|
instruction: serializeTcInstruction(patched)
|
|
160185
160245
|
}, options?.expectedRevision)))
|
|
@@ -161512,7 +161572,7 @@ function hyperlinkFailure(code$1, message) {
|
|
|
161512
161572
|
}
|
|
161513
161573
|
};
|
|
161514
161574
|
}
|
|
161515
|
-
function receiptApplied$
|
|
161575
|
+
function receiptApplied$7(receipt2) {
|
|
161516
161576
|
return receipt2.steps[0]?.effect === "changed";
|
|
161517
161577
|
}
|
|
161518
161578
|
function matchesListQuery(candidate, query2, editor) {
|
|
@@ -161611,7 +161671,7 @@ function hyperlinksWrapWrapper(editor, input2, options) {
|
|
|
161611
161671
|
}
|
|
161612
161672
|
});
|
|
161613
161673
|
const spec = specFromInput(input2.link);
|
|
161614
|
-
if (!receiptApplied$
|
|
161674
|
+
if (!receiptApplied$7(executeDomainCommand(editor, () => {
|
|
161615
161675
|
const result = wrapWithLink(editor, resolved.from, resolved.to, spec);
|
|
161616
161676
|
if (result)
|
|
161617
161677
|
clearIndexCache(editor);
|
|
@@ -161681,7 +161741,7 @@ function hyperlinksInsertWrapper(editor, input2, options) {
|
|
|
161681
161741
|
}
|
|
161682
161742
|
});
|
|
161683
161743
|
const spec = specFromInput(input2.link);
|
|
161684
|
-
if (!receiptApplied$
|
|
161744
|
+
if (!receiptApplied$7(executeDomainCommand(editor, () => {
|
|
161685
161745
|
if (structuralEnd) {
|
|
161686
161746
|
insertParagraphAtEnd(editor, insertPos, input2.text);
|
|
161687
161747
|
clearIndexCache(editor);
|
|
@@ -161742,7 +161802,7 @@ function hyperlinksPatchWrapper(editor, input2, options) {
|
|
|
161742
161802
|
return hyperlinkFailure("NO_OP", "Patch produces no change — all values already match.");
|
|
161743
161803
|
if (options?.dryRun)
|
|
161744
161804
|
return hyperlinkSuccess(candidateToTarget(candidate));
|
|
161745
|
-
if (!receiptApplied$
|
|
161805
|
+
if (!receiptApplied$7(executeDomainCommand(editor, () => {
|
|
161746
161806
|
const result = patchLinkMark(editor, resolvedRange.from, resolvedRange.to, existingMark, input2.patch);
|
|
161747
161807
|
if (result)
|
|
161748
161808
|
clearIndexCache(editor);
|
|
@@ -161761,7 +161821,7 @@ function hyperlinksRemoveWrapper(editor, input2, options) {
|
|
|
161761
161821
|
const targetAddress = candidateToTarget(candidate);
|
|
161762
161822
|
if (options?.dryRun)
|
|
161763
161823
|
return hyperlinkSuccess(targetAddress);
|
|
161764
|
-
if (!receiptApplied$
|
|
161824
|
+
if (!receiptApplied$7(executeDomainCommand(editor, () => {
|
|
161765
161825
|
const result = mode === "unwrap" ? unwrapLink(editor, resolvedRange.from, resolvedRange.to) : deleteLinkedText(editor, resolvedRange.from, resolvedRange.to);
|
|
161766
161826
|
if (result)
|
|
161767
161827
|
clearIndexCache(editor);
|
|
@@ -163059,7 +163119,7 @@ function buildSectionMarginsForAttrs(sectPr) {
|
|
|
163059
163119
|
};
|
|
163060
163120
|
}
|
|
163061
163121
|
function syncConverterBodySection(editor, sectPr) {
|
|
163062
|
-
const converter = getConverter$
|
|
163122
|
+
const converter = getConverter$3(editor);
|
|
163063
163123
|
if (!converter)
|
|
163064
163124
|
return;
|
|
163065
163125
|
converter.bodySectPr = cloneXmlElement(sectPr);
|
|
@@ -163097,7 +163157,7 @@ function syncConverterBodySection(editor, sectPr) {
|
|
|
163097
163157
|
if (margins.gutter !== undefined)
|
|
163098
163158
|
pageMargins.gutter = margins.gutter;
|
|
163099
163159
|
}
|
|
163100
|
-
function getConverter$
|
|
163160
|
+
function getConverter$3(editor) {
|
|
163101
163161
|
return editor.converter;
|
|
163102
163162
|
}
|
|
163103
163163
|
function applySectPrToProjection(editor, projection, sectPr) {
|
|
@@ -163147,11 +163207,11 @@ function sectionMutationBySectPr(editor, input2, options, operationName, mutate)
|
|
|
163147
163207
|
clearIndexCache(editor);
|
|
163148
163208
|
return toSectionSuccess(projection.address);
|
|
163149
163209
|
}
|
|
163150
|
-
function
|
|
163210
|
+
function getConverter$2(editor) {
|
|
163151
163211
|
return editor.converter;
|
|
163152
163212
|
}
|
|
163153
163213
|
function requireConverter(editor, operationName) {
|
|
163154
|
-
const converter =
|
|
163214
|
+
const converter = getConverter$2(editor);
|
|
163155
163215
|
if (!converter)
|
|
163156
163216
|
throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", `${operationName} requires an active document converter.`);
|
|
163157
163217
|
return converter;
|
|
@@ -163250,14 +163310,14 @@ function headerFootersResolveAdapter(editor, input2) {
|
|
|
163250
163310
|
function headerFootersRefsSetAdapter(editor, input2, options) {
|
|
163251
163311
|
const { section, headerFooterKind, variant } = input2.target;
|
|
163252
163312
|
return sectionMutationBySectPr(editor, { target: section }, options, "headerFooters.refs.set", (sectPr, _projection, _sections, dryRun) => {
|
|
163253
|
-
const converter =
|
|
163313
|
+
const converter = getConverter$2(editor) ?? null;
|
|
163254
163314
|
return setHeaderFooterRefMutation(sectPr, headerFooterKind, variant, input2.refId, converter, "headerFooters.refs.set", dryRun);
|
|
163255
163315
|
});
|
|
163256
163316
|
}
|
|
163257
163317
|
function headerFootersRefsClearAdapter(editor, input2, options) {
|
|
163258
163318
|
const { section, headerFooterKind, variant } = input2.target;
|
|
163259
163319
|
return sectionMutationBySectPr(editor, { target: section }, options, "headerFooters.refs.clear", (sectPr, _projection, _sections, dryRun) => {
|
|
163260
|
-
clearHeaderFooterRefMutation(sectPr, headerFooterKind, variant,
|
|
163320
|
+
clearHeaderFooterRefMutation(sectPr, headerFooterKind, variant, getConverter$2(editor) ?? null, dryRun);
|
|
163261
163321
|
});
|
|
163262
163322
|
}
|
|
163263
163323
|
function headerFootersRefsSetLinkedToPreviousAdapter(editor, input2, options) {
|
|
@@ -163611,7 +163671,7 @@ function bookmarkFailure(code$1, message) {
|
|
|
163611
163671
|
}
|
|
163612
163672
|
};
|
|
163613
163673
|
}
|
|
163614
|
-
function receiptApplied$
|
|
163674
|
+
function receiptApplied$6(receipt2) {
|
|
163615
163675
|
return receipt2.steps[0]?.effect === "changed";
|
|
163616
163676
|
}
|
|
163617
163677
|
function parseBookmarkId(raw) {
|
|
@@ -163671,7 +163731,7 @@ function bookmarksInsertWrapper(editor, input2, options) {
|
|
|
163671
163731
|
if (!bookmarkStartType || !bookmarkEndType)
|
|
163672
163732
|
throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", "bookmarks.insert requires bookmarkStart and bookmarkEnd node types in the schema.");
|
|
163673
163733
|
const resolved = resolveInlineInsertPosition(editor, input2.at, "bookmarks.insert");
|
|
163674
|
-
if (!receiptApplied$
|
|
163734
|
+
if (!receiptApplied$6(executeDomainCommand(editor, () => {
|
|
163675
163735
|
const bookmarkId = allocateBookmarkId(editor.state.doc);
|
|
163676
163736
|
const startAttrs = {
|
|
163677
163737
|
name: input2.name,
|
|
@@ -163707,7 +163767,7 @@ function bookmarksRenameWrapper(editor, input2, options) {
|
|
|
163707
163767
|
};
|
|
163708
163768
|
if (options?.dryRun)
|
|
163709
163769
|
return bookmarkSuccess(newAddress);
|
|
163710
|
-
if (!receiptApplied$
|
|
163770
|
+
if (!receiptApplied$6(executeDomainCommand(editor, () => {
|
|
163711
163771
|
const { tr } = editor.state;
|
|
163712
163772
|
tr.setNodeMarkup(resolved.pos, undefined, {
|
|
163713
163773
|
...resolved.node.attrs,
|
|
@@ -163730,7 +163790,7 @@ function bookmarksRemoveWrapper(editor, input2, options) {
|
|
|
163730
163790
|
};
|
|
163731
163791
|
if (options?.dryRun)
|
|
163732
163792
|
return bookmarkSuccess(address2);
|
|
163733
|
-
if (!receiptApplied$
|
|
163793
|
+
if (!receiptApplied$6(executeDomainCommand(editor, () => {
|
|
163734
163794
|
const { tr } = editor.state;
|
|
163735
163795
|
if (resolved.endPos !== null && resolved.endPos > resolved.pos) {
|
|
163736
163796
|
const endNode = tr.doc.nodeAt(resolved.endPos);
|
|
@@ -163747,6 +163807,22 @@ function bookmarksRemoveWrapper(editor, input2, options) {
|
|
|
163747
163807
|
return bookmarkFailure("NO_OP", "Remove operation produced no change.");
|
|
163748
163808
|
return bookmarkSuccess(address2);
|
|
163749
163809
|
}
|
|
163810
|
+
function isSpecialEntry(entry) {
|
|
163811
|
+
return SPECIAL_NOTE_TYPES.has(entry.type ?? "");
|
|
163812
|
+
}
|
|
163813
|
+
function findNoteEntryById(entries, noteId) {
|
|
163814
|
+
if (!Array.isArray(entries))
|
|
163815
|
+
return;
|
|
163816
|
+
let fallback;
|
|
163817
|
+
for (const entry of entries) {
|
|
163818
|
+
if (String(entry.id ?? "") !== noteId)
|
|
163819
|
+
continue;
|
|
163820
|
+
if (!isSpecialEntry(entry))
|
|
163821
|
+
return entry;
|
|
163822
|
+
fallback ??= entry;
|
|
163823
|
+
}
|
|
163824
|
+
return fallback;
|
|
163825
|
+
}
|
|
163750
163826
|
function getConverterStore(editor) {
|
|
163751
163827
|
return editor.converter ?? {};
|
|
163752
163828
|
}
|
|
@@ -163779,7 +163855,7 @@ function resolveCollectionContent(collection, noteId) {
|
|
|
163779
163855
|
if (!collection)
|
|
163780
163856
|
return "";
|
|
163781
163857
|
if (Array.isArray(collection))
|
|
163782
|
-
return extractTextFromContent(collection
|
|
163858
|
+
return extractTextFromContent(findNoteEntryById(collection, noteId)?.content);
|
|
163783
163859
|
if (isLegacyFootnoteMap(collection))
|
|
163784
163860
|
return collection[noteId]?.content ?? "";
|
|
163785
163861
|
return "";
|
|
@@ -163857,28 +163933,221 @@ function buildFootnoteDiscoveryItem(editor, resolved, evaluatedRevision) {
|
|
|
163857
163933
|
const handle3 = buildResolvedHandle2(resolved.noteId, "stable", "node");
|
|
163858
163934
|
return buildDiscoveryItem2(`footnote:${resolved.noteId}:${evaluatedRevision}`, handle3, domain2);
|
|
163859
163935
|
}
|
|
163860
|
-
function
|
|
163861
|
-
|
|
163862
|
-
|
|
163863
|
-
|
|
163864
|
-
|
|
163865
|
-
|
|
163866
|
-
|
|
163867
|
-
|
|
163868
|
-
|
|
163869
|
-
|
|
163870
|
-
|
|
163871
|
-
|
|
163872
|
-
|
|
163873
|
-
|
|
163874
|
-
|
|
163875
|
-
|
|
163876
|
-
|
|
163877
|
-
|
|
163936
|
+
function getConverter$13(editor) {
|
|
163937
|
+
return editor.converter;
|
|
163938
|
+
}
|
|
163939
|
+
function getRootElement(part) {
|
|
163940
|
+
return part?.elements?.[0];
|
|
163941
|
+
}
|
|
163942
|
+
function getNoteElements(part, childElementName) {
|
|
163943
|
+
const root3 = getRootElement(part);
|
|
163944
|
+
if (!root3?.elements)
|
|
163945
|
+
return [];
|
|
163946
|
+
return root3.elements.filter((el) => el.name === childElementName);
|
|
163947
|
+
}
|
|
163948
|
+
function textToNoteOoxmlParagraphs(text5) {
|
|
163949
|
+
return text5.split(/\r?\n/).map((line) => ({
|
|
163950
|
+
type: "element",
|
|
163951
|
+
name: "w:p",
|
|
163952
|
+
elements: line.length > 0 ? [{
|
|
163953
|
+
type: "element",
|
|
163954
|
+
name: "w:r",
|
|
163955
|
+
elements: [{
|
|
163956
|
+
type: "element",
|
|
163957
|
+
name: "w:t",
|
|
163958
|
+
attributes: { "xml:space": "preserve" },
|
|
163959
|
+
elements: [{
|
|
163960
|
+
type: "text",
|
|
163961
|
+
text: line
|
|
163962
|
+
}]
|
|
163963
|
+
}]
|
|
163964
|
+
}] : []
|
|
163965
|
+
}));
|
|
163966
|
+
}
|
|
163967
|
+
function ensureFootnoteRefRun(paragraphs, childElementName) {
|
|
163968
|
+
if (paragraphs.length === 0)
|
|
163969
|
+
return;
|
|
163970
|
+
const refName = childElementName === "w:footnote" ? "w:footnoteRef" : "w:endnoteRef";
|
|
163971
|
+
const styleName = childElementName === "w:footnote" ? "FootnoteReference" : "EndnoteReference";
|
|
163972
|
+
const firstParagraph = paragraphs[0];
|
|
163973
|
+
if (!firstParagraph.elements)
|
|
163974
|
+
firstParagraph.elements = [];
|
|
163975
|
+
const refRun = {
|
|
163976
|
+
type: "element",
|
|
163977
|
+
name: "w:r",
|
|
163978
|
+
elements: [{
|
|
163979
|
+
type: "element",
|
|
163980
|
+
name: "w:rPr",
|
|
163981
|
+
elements: [{
|
|
163982
|
+
type: "element",
|
|
163983
|
+
name: "w:rStyle",
|
|
163984
|
+
attributes: { "w:val": styleName }
|
|
163985
|
+
}, {
|
|
163986
|
+
type: "element",
|
|
163987
|
+
name: "w:vertAlign",
|
|
163988
|
+
attributes: { "w:val": "superscript" }
|
|
163989
|
+
}]
|
|
163990
|
+
}, {
|
|
163991
|
+
type: "element",
|
|
163992
|
+
name: refName,
|
|
163993
|
+
elements: []
|
|
163994
|
+
}]
|
|
163995
|
+
};
|
|
163996
|
+
const pPrIndex = firstParagraph.elements.findIndex((el) => el?.name === "w:pPr");
|
|
163997
|
+
firstParagraph.elements.splice(pPrIndex >= 0 ? pPrIndex + 1 : 0, 0, refRun);
|
|
163998
|
+
}
|
|
163999
|
+
function addNoteElement(part, config2, noteId, text5) {
|
|
164000
|
+
const root3 = getRootElement(part);
|
|
164001
|
+
if (!root3)
|
|
164002
|
+
throw new Error(`addNoteElement: missing root element in ${config2.partId}`);
|
|
164003
|
+
if (!root3.elements)
|
|
164004
|
+
root3.elements = [];
|
|
164005
|
+
if (root3.elements.find((el) => el.name === config2.childElementName && el.attributes?.["w:id"] === noteId))
|
|
164006
|
+
throw new Error(`addNoteElement: note id "${noteId}" already exists in ${config2.partId}`);
|
|
164007
|
+
const paragraphs = textToNoteOoxmlParagraphs(text5);
|
|
164008
|
+
ensureFootnoteRefRun(paragraphs, config2.childElementName);
|
|
164009
|
+
const noteElement = {
|
|
164010
|
+
type: "element",
|
|
164011
|
+
name: config2.childElementName,
|
|
164012
|
+
attributes: { "w:id": noteId },
|
|
164013
|
+
elements: paragraphs
|
|
164014
|
+
};
|
|
164015
|
+
root3.elements.push(noteElement);
|
|
164016
|
+
return noteElement;
|
|
164017
|
+
}
|
|
164018
|
+
function updateNoteElement(part, config2, noteId, text5) {
|
|
164019
|
+
const target = getNoteElements(part, config2.childElementName).find((el) => el.attributes?.["w:id"] === noteId);
|
|
164020
|
+
if (!target)
|
|
164021
|
+
return false;
|
|
164022
|
+
const paragraphs = textToNoteOoxmlParagraphs(text5);
|
|
164023
|
+
ensureFootnoteRefRun(paragraphs, config2.childElementName);
|
|
164024
|
+
target.elements = paragraphs;
|
|
164025
|
+
return true;
|
|
164026
|
+
}
|
|
164027
|
+
function removeNoteElement(part, config2, noteId) {
|
|
164028
|
+
const root3 = getRootElement(part);
|
|
164029
|
+
if (!root3?.elements)
|
|
164030
|
+
return false;
|
|
164031
|
+
const index2 = root3.elements.findIndex((el) => el.name === config2.childElementName && el.attributes?.["w:id"] === noteId);
|
|
164032
|
+
if (index2 < 0)
|
|
164033
|
+
return false;
|
|
164034
|
+
root3.elements.splice(index2, 1);
|
|
164035
|
+
return true;
|
|
164036
|
+
}
|
|
164037
|
+
function rebuildDerivedCache(editor, config2, part) {
|
|
164038
|
+
const converter = getConverter$13(editor);
|
|
164039
|
+
if (!converter)
|
|
164040
|
+
return;
|
|
164041
|
+
if (typeof converter.reimportNotePart === "function")
|
|
164042
|
+
try {
|
|
164043
|
+
converter[config2.converterKey] = converter.reimportNotePart(config2.partId);
|
|
164044
|
+
return;
|
|
164045
|
+
} catch (err) {
|
|
164046
|
+
console.warn(`[parts] reimportNotePart failed for ${config2.partId}, using fallback:`, err);
|
|
163878
164047
|
}
|
|
163879
|
-
|
|
163880
|
-
|
|
163881
|
-
|
|
164048
|
+
const entries = getNoteElements(part, config2.childElementName).map((el) => ({
|
|
164049
|
+
id: String(el.attributes?.["w:id"] ?? ""),
|
|
164050
|
+
type: el.attributes?.["w:type"] ?? null,
|
|
164051
|
+
content: [],
|
|
164052
|
+
originalXml: structuredClone(el)
|
|
164053
|
+
}));
|
|
164054
|
+
converter[config2.converterKey] = entries;
|
|
164055
|
+
}
|
|
164056
|
+
function createInitialNotesPart(config2) {
|
|
164057
|
+
return {
|
|
164058
|
+
declaration: { attributes: {
|
|
164059
|
+
version: "1.0",
|
|
164060
|
+
encoding: "UTF-8",
|
|
164061
|
+
standalone: "yes"
|
|
164062
|
+
} },
|
|
164063
|
+
elements: [{
|
|
164064
|
+
type: "element",
|
|
164065
|
+
name: config2.rootElementName,
|
|
164066
|
+
attributes: { ...NOTES_XMLNS },
|
|
164067
|
+
elements: [{
|
|
164068
|
+
type: "element",
|
|
164069
|
+
name: config2.childElementName,
|
|
164070
|
+
attributes: {
|
|
164071
|
+
"w:type": "separator",
|
|
164072
|
+
"w:id": "-1"
|
|
164073
|
+
},
|
|
164074
|
+
elements: [{
|
|
164075
|
+
type: "element",
|
|
164076
|
+
name: "w:p",
|
|
164077
|
+
elements: [{
|
|
164078
|
+
type: "element",
|
|
164079
|
+
name: "w:r",
|
|
164080
|
+
elements: [{
|
|
164081
|
+
type: "element",
|
|
164082
|
+
name: "w:separator",
|
|
164083
|
+
elements: []
|
|
164084
|
+
}]
|
|
164085
|
+
}]
|
|
164086
|
+
}]
|
|
164087
|
+
}, {
|
|
164088
|
+
type: "element",
|
|
164089
|
+
name: config2.childElementName,
|
|
164090
|
+
attributes: {
|
|
164091
|
+
"w:type": "continuationSeparator",
|
|
164092
|
+
"w:id": "0"
|
|
164093
|
+
},
|
|
164094
|
+
elements: [{
|
|
164095
|
+
type: "element",
|
|
164096
|
+
name: "w:p",
|
|
164097
|
+
elements: [{
|
|
164098
|
+
type: "element",
|
|
164099
|
+
name: "w:r",
|
|
164100
|
+
elements: [{
|
|
164101
|
+
type: "element",
|
|
164102
|
+
name: "w:continuationSeparator",
|
|
164103
|
+
elements: []
|
|
164104
|
+
}]
|
|
164105
|
+
}]
|
|
164106
|
+
}]
|
|
164107
|
+
}]
|
|
164108
|
+
}]
|
|
164109
|
+
};
|
|
164110
|
+
}
|
|
164111
|
+
function createNotePartDescriptor(config2) {
|
|
164112
|
+
return {
|
|
164113
|
+
id: config2.partId,
|
|
164114
|
+
ensurePart() {
|
|
164115
|
+
return createInitialNotesPart(config2);
|
|
164116
|
+
},
|
|
164117
|
+
normalizePart(part) {
|
|
164118
|
+
const root3 = getRootElement(part);
|
|
164119
|
+
if (!root3?.elements)
|
|
164120
|
+
return;
|
|
164121
|
+
root3.elements.sort((a2, b$1) => {
|
|
164122
|
+
const aType = a2.attributes?.["w:type"];
|
|
164123
|
+
const bType = b$1.attributes?.["w:type"];
|
|
164124
|
+
const aIsSpecial = aType === "separator" || aType === "continuationSeparator";
|
|
164125
|
+
if (aIsSpecial !== (bType === "separator" || bType === "continuationSeparator"))
|
|
164126
|
+
return aIsSpecial ? -1 : 1;
|
|
164127
|
+
return Number(a2.attributes?.["w:id"] ?? 0) - Number(b$1.attributes?.["w:id"] ?? 0);
|
|
164128
|
+
});
|
|
164129
|
+
},
|
|
164130
|
+
afterCommit({ editor, part, source }) {
|
|
164131
|
+
rebuildDerivedCache(editor, config2, part);
|
|
164132
|
+
clearPartCacheStale(editor, config2.partId);
|
|
164133
|
+
editor.emit("notes-part-changed", {
|
|
164134
|
+
partId: config2.partId,
|
|
164135
|
+
source
|
|
164136
|
+
});
|
|
164137
|
+
}
|
|
164138
|
+
};
|
|
164139
|
+
}
|
|
164140
|
+
function getNotesConfig(type) {
|
|
164141
|
+
return type === "endnote" ? ENDNOTES_CONFIG : FOOTNOTES_CONFIG;
|
|
164142
|
+
}
|
|
164143
|
+
function bootstrapNotesPart(editor, type) {
|
|
164144
|
+
const converter = editor.converter;
|
|
164145
|
+
if (!converter?.convertedXml)
|
|
164146
|
+
return;
|
|
164147
|
+
const config2 = getNotesConfig(type);
|
|
164148
|
+
if (converter.convertedXml[config2.partId] !== undefined)
|
|
164149
|
+
return;
|
|
164150
|
+
converter.convertedXml[config2.partId] = createInitialNotesPart(config2);
|
|
163882
164151
|
}
|
|
163883
164152
|
function footnoteSuccess(address2) {
|
|
163884
164153
|
return {
|
|
@@ -163898,39 +164167,11 @@ function footnoteFailure(code$1, message) {
|
|
|
163898
164167
|
function configSuccess$1() {
|
|
163899
164168
|
return { success: true };
|
|
163900
164169
|
}
|
|
163901
|
-
function
|
|
163902
|
-
|
|
163903
|
-
|
|
163904
|
-
|
|
163905
|
-
return
|
|
163906
|
-
}
|
|
163907
|
-
function textToFootnoteContentNodes(text5) {
|
|
163908
|
-
return text5.split(/\r?\n/).map((line) => ({
|
|
163909
|
-
type: "paragraph",
|
|
163910
|
-
content: line.length > 0 ? [{
|
|
163911
|
-
type: "text",
|
|
163912
|
-
text: line
|
|
163913
|
-
}] : []
|
|
163914
|
-
}));
|
|
163915
|
-
}
|
|
163916
|
-
function normalizeLegacyNoteMap(map$12) {
|
|
163917
|
-
return Object.entries(map$12).map(([id2, value]) => ({
|
|
163918
|
-
id: String(id2),
|
|
163919
|
-
content: textToFootnoteContentNodes(value?.content ?? "")
|
|
163920
|
-
}));
|
|
163921
|
-
}
|
|
163922
|
-
function ensureNoteEntries(converter, kind) {
|
|
163923
|
-
const current = converter[kind];
|
|
163924
|
-
if (Array.isArray(current))
|
|
163925
|
-
return current;
|
|
163926
|
-
if (isLegacyNoteMap(current)) {
|
|
163927
|
-
const normalized = normalizeLegacyNoteMap(current);
|
|
163928
|
-
converter[kind] = normalized;
|
|
163929
|
-
return normalized;
|
|
163930
|
-
}
|
|
163931
|
-
const initialized = [];
|
|
163932
|
-
converter[kind] = initialized;
|
|
163933
|
-
return initialized;
|
|
164170
|
+
function getConverter2(editor) {
|
|
164171
|
+
const converter = editor.converter;
|
|
164172
|
+
if (!converter)
|
|
164173
|
+
throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", "converter not available.");
|
|
164174
|
+
return converter;
|
|
163934
164175
|
}
|
|
163935
164176
|
function toNonNegativeInteger(value) {
|
|
163936
164177
|
const num = Number(value);
|
|
@@ -163938,35 +164179,36 @@ function toNonNegativeInteger(value) {
|
|
|
163938
164179
|
return null;
|
|
163939
164180
|
return num;
|
|
163940
164181
|
}
|
|
163941
|
-
function
|
|
163942
|
-
|
|
164182
|
+
function collectUsedNoteIds(editor, converter, type) {
|
|
164183
|
+
const used = /* @__PURE__ */ new Set;
|
|
164184
|
+
const config2 = getNotesConfig(type);
|
|
163943
164185
|
for (const ref$1 of findAllFootnotes(editor.state.doc, type)) {
|
|
163944
164186
|
const parsed = toNonNegativeInteger(ref$1.noteId);
|
|
163945
164187
|
if (parsed != null)
|
|
163946
|
-
|
|
163947
|
-
}
|
|
163948
|
-
|
|
163949
|
-
|
|
163950
|
-
|
|
163951
|
-
|
|
163952
|
-
|
|
163953
|
-
|
|
163954
|
-
}
|
|
163955
|
-
|
|
163956
|
-
|
|
163957
|
-
|
|
163958
|
-
|
|
163959
|
-
|
|
163960
|
-
|
|
163961
|
-
|
|
163962
|
-
|
|
163963
|
-
|
|
163964
|
-
|
|
163965
|
-
|
|
163966
|
-
|
|
163967
|
-
|
|
163968
|
-
|
|
163969
|
-
|
|
164188
|
+
used.add(parsed);
|
|
164189
|
+
}
|
|
164190
|
+
const ooxmlPart = converter.convertedXml?.[config2.partId];
|
|
164191
|
+
if (ooxmlPart)
|
|
164192
|
+
for (const el of getNoteElements(ooxmlPart, config2.childElementName)) {
|
|
164193
|
+
const parsed = toNonNegativeInteger(el.attributes?.["w:id"]);
|
|
164194
|
+
if (parsed != null)
|
|
164195
|
+
used.add(parsed);
|
|
164196
|
+
}
|
|
164197
|
+
const cache$2 = converter[config2.converterKey];
|
|
164198
|
+
if (Array.isArray(cache$2))
|
|
164199
|
+
for (const entry of cache$2) {
|
|
164200
|
+
const parsed = toNonNegativeInteger(entry.id);
|
|
164201
|
+
if (parsed != null)
|
|
164202
|
+
used.add(parsed);
|
|
164203
|
+
}
|
|
164204
|
+
return used;
|
|
164205
|
+
}
|
|
164206
|
+
function allocateNextNoteId(editor, converter, type) {
|
|
164207
|
+
const used = collectUsedNoteIds(editor, converter, type);
|
|
164208
|
+
let candidate = 1;
|
|
164209
|
+
while (used.has(candidate))
|
|
164210
|
+
candidate += 1;
|
|
164211
|
+
return String(candidate);
|
|
163970
164212
|
}
|
|
163971
164213
|
function footnotesListWrapper(editor, query2) {
|
|
163972
164214
|
const doc$2 = editor.state.doc;
|
|
@@ -163988,11 +164230,10 @@ function footnotesGetWrapper(editor, input2) {
|
|
|
163988
164230
|
}
|
|
163989
164231
|
function footnotesInsertWrapper(editor, input2, options) {
|
|
163990
164232
|
rejectTrackedMode("footnotes.insert", options);
|
|
163991
|
-
|
|
163992
|
-
|
|
163993
|
-
|
|
163994
|
-
const
|
|
163995
|
-
const noteId = allocateNextNoteId(editor, input2.type, noteEntries);
|
|
164233
|
+
checkRevision(editor, options?.expectedRevision);
|
|
164234
|
+
const converter = getConverter2(editor);
|
|
164235
|
+
const notesConfig = getNotesConfig(input2.type);
|
|
164236
|
+
const noteId = allocateNextNoteId(editor, converter, input2.type);
|
|
163996
164237
|
const address2 = {
|
|
163997
164238
|
kind: "entity",
|
|
163998
164239
|
entityType: "footnote",
|
|
@@ -164005,15 +164246,30 @@ function footnotesInsertWrapper(editor, input2, options) {
|
|
|
164005
164246
|
if (!nodeType)
|
|
164006
164247
|
throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", `footnotes.insert: node type "${nodeTypeName}" is not registered in the schema.`);
|
|
164007
164248
|
const resolved = resolveInlineInsertPosition(editor, input2.at, "footnotes.insert");
|
|
164008
|
-
|
|
164009
|
-
|
|
164010
|
-
|
|
164011
|
-
|
|
164012
|
-
|
|
164013
|
-
|
|
164014
|
-
|
|
164015
|
-
|
|
164016
|
-
|
|
164249
|
+
const { success } = compoundMutation({
|
|
164250
|
+
editor,
|
|
164251
|
+
source: `footnotes.insert:${input2.type}`,
|
|
164252
|
+
affectedParts: [notesConfig.partId],
|
|
164253
|
+
execute: () => {
|
|
164254
|
+
bootstrapNotesPart(editor, input2.type);
|
|
164255
|
+
mutatePart({
|
|
164256
|
+
editor,
|
|
164257
|
+
partId: notesConfig.partId,
|
|
164258
|
+
operation: "mutate",
|
|
164259
|
+
source: `footnotes.insert:${input2.type}`,
|
|
164260
|
+
mutate({ part }) {
|
|
164261
|
+
addNoteElement(part, notesConfig, noteId, input2.content);
|
|
164262
|
+
}
|
|
164263
|
+
});
|
|
164264
|
+
const node3 = nodeType.create({ id: noteId });
|
|
164265
|
+
const { tr } = editor.state;
|
|
164266
|
+
tr.insert(resolved.from, node3);
|
|
164267
|
+
editor.dispatch(tr);
|
|
164268
|
+
clearIndexCache(editor);
|
|
164269
|
+
return true;
|
|
164270
|
+
}
|
|
164271
|
+
});
|
|
164272
|
+
if (!success)
|
|
164017
164273
|
return footnoteFailure("NO_OP", "Insert operation produced no change.");
|
|
164018
164274
|
return footnoteSuccess(address2);
|
|
164019
164275
|
}
|
|
@@ -164025,32 +164281,24 @@ function footnotesUpdateWrapper(editor, input2, options) {
|
|
|
164025
164281
|
entityType: "footnote",
|
|
164026
164282
|
noteId: resolved.noteId
|
|
164027
164283
|
};
|
|
164028
|
-
if (options?.dryRun)
|
|
164284
|
+
if (options?.dryRun || input2.patch.content === undefined)
|
|
164029
164285
|
return footnoteSuccess(address2);
|
|
164030
|
-
const
|
|
164031
|
-
|
|
164032
|
-
|
|
164033
|
-
|
|
164034
|
-
|
|
164035
|
-
|
|
164036
|
-
|
|
164037
|
-
|
|
164038
|
-
|
|
164039
|
-
|
|
164040
|
-
if (!dryRun)
|
|
164041
|
-
upsertNoteEntry(noteEntries, resolved.noteId, input2.patch.content);
|
|
164042
|
-
return {
|
|
164043
|
-
changed: true,
|
|
164044
|
-
payload: undefined
|
|
164045
|
-
};
|
|
164046
|
-
}, {
|
|
164047
|
-
dryRun: options?.dryRun ?? false,
|
|
164048
|
-
expectedRevision: options?.expectedRevision
|
|
164286
|
+
const notesConfig = getNotesConfig(resolved.type);
|
|
164287
|
+
mutatePart({
|
|
164288
|
+
editor,
|
|
164289
|
+
partId: notesConfig.partId,
|
|
164290
|
+
operation: "mutate",
|
|
164291
|
+
source: `footnotes.update:${resolved.type}`,
|
|
164292
|
+
expectedRevision: options?.expectedRevision,
|
|
164293
|
+
mutate({ part }) {
|
|
164294
|
+
updateNoteElement(part, notesConfig, resolved.noteId, input2.patch.content);
|
|
164295
|
+
}
|
|
164049
164296
|
});
|
|
164050
164297
|
return footnoteSuccess(address2);
|
|
164051
164298
|
}
|
|
164052
164299
|
function footnotesRemoveWrapper(editor, input2, options) {
|
|
164053
164300
|
rejectTrackedMode("footnotes.remove", options);
|
|
164301
|
+
checkRevision(editor, options?.expectedRevision);
|
|
164054
164302
|
const resolved = resolveFootnoteTarget(editor.state.doc, input2.target);
|
|
164055
164303
|
const address2 = {
|
|
164056
164304
|
kind: "entity",
|
|
@@ -164059,63 +164307,102 @@ function footnotesRemoveWrapper(editor, input2, options) {
|
|
|
164059
164307
|
};
|
|
164060
164308
|
if (options?.dryRun)
|
|
164061
164309
|
return footnoteSuccess(address2);
|
|
164062
|
-
|
|
164063
|
-
|
|
164064
|
-
|
|
164065
|
-
|
|
164310
|
+
const notesConfig = getNotesConfig(resolved.type);
|
|
164311
|
+
const { success } = compoundMutation({
|
|
164312
|
+
editor,
|
|
164313
|
+
source: `footnotes.remove:${resolved.type}`,
|
|
164314
|
+
affectedParts: [notesConfig.partId],
|
|
164315
|
+
execute: () => {
|
|
164316
|
+
const { tr } = editor.state;
|
|
164317
|
+
const node3 = tr.doc.nodeAt(resolved.pos);
|
|
164318
|
+
if (!node3)
|
|
164319
|
+
return false;
|
|
164066
164320
|
tr.delete(resolved.pos, resolved.pos + node3.nodeSize);
|
|
164067
164321
|
editor.dispatch(tr);
|
|
164068
|
-
|
|
164069
|
-
|
|
164070
|
-
|
|
164071
|
-
|
|
164072
|
-
|
|
164073
|
-
|
|
164322
|
+
if (!findAllFootnotes(editor.state.doc, resolved.type).some((f2) => f2.noteId === resolved.noteId))
|
|
164323
|
+
mutatePart({
|
|
164324
|
+
editor,
|
|
164325
|
+
partId: notesConfig.partId,
|
|
164326
|
+
operation: "mutate",
|
|
164327
|
+
source: `footnotes.remove:${resolved.type}`,
|
|
164328
|
+
mutate({ part }) {
|
|
164329
|
+
removeNoteElement(part, notesConfig, resolved.noteId);
|
|
164330
|
+
}
|
|
164331
|
+
});
|
|
164074
164332
|
clearIndexCache(editor);
|
|
164075
164333
|
return true;
|
|
164076
164334
|
}
|
|
164077
|
-
|
|
164078
|
-
|
|
164335
|
+
});
|
|
164336
|
+
if (!success)
|
|
164079
164337
|
return footnoteFailure("NO_OP", "Remove operation produced no change.");
|
|
164080
164338
|
return footnoteSuccess(address2);
|
|
164081
164339
|
}
|
|
164082
164340
|
function footnotesConfigureWrapper(editor, input2, options) {
|
|
164083
164341
|
rejectTrackedMode("footnotes.configure", options);
|
|
164084
|
-
const
|
|
164085
|
-
|
|
164086
|
-
|
|
164087
|
-
|
|
164088
|
-
|
|
164089
|
-
|
|
164090
|
-
|
|
164091
|
-
|
|
164092
|
-
|
|
164093
|
-
|
|
164094
|
-
|
|
164095
|
-
|
|
164096
|
-
|
|
164097
|
-
|
|
164098
|
-
|
|
164099
|
-
|
|
164100
|
-
|
|
164342
|
+
const prElementName = input2.type === "endnote" ? "w:endnotePr" : "w:footnotePr";
|
|
164343
|
+
mutatePart({
|
|
164344
|
+
editor,
|
|
164345
|
+
partId: "word/settings.xml",
|
|
164346
|
+
operation: "mutate",
|
|
164347
|
+
source: `footnotes.configure:${input2.type}`,
|
|
164348
|
+
dryRun: options?.dryRun,
|
|
164349
|
+
expectedRevision: options?.expectedRevision,
|
|
164350
|
+
mutate({ part }) {
|
|
164351
|
+
const root3 = part?.elements?.[0];
|
|
164352
|
+
if (!root3)
|
|
164353
|
+
return;
|
|
164354
|
+
if (!root3.elements)
|
|
164355
|
+
root3.elements = [];
|
|
164356
|
+
const elements = root3.elements;
|
|
164357
|
+
let prElement = elements.find((el) => el.name === prElementName);
|
|
164358
|
+
if (!prElement) {
|
|
164359
|
+
prElement = {
|
|
164360
|
+
type: "element",
|
|
164361
|
+
name: prElementName,
|
|
164362
|
+
elements: []
|
|
164363
|
+
};
|
|
164364
|
+
elements.push(prElement);
|
|
164365
|
+
}
|
|
164366
|
+
if (!prElement.elements)
|
|
164367
|
+
prElement.elements = [];
|
|
164368
|
+
if (!input2.numbering)
|
|
164369
|
+
return;
|
|
164370
|
+
const setOrRemoveChild = (name, value) => {
|
|
164371
|
+
if (value === undefined)
|
|
164372
|
+
return;
|
|
164373
|
+
const children = prElement.elements;
|
|
164374
|
+
const existing = children.findIndex((el) => el.name === name);
|
|
164375
|
+
const newEl = {
|
|
164376
|
+
type: "element",
|
|
164377
|
+
name,
|
|
164378
|
+
attributes: { "w:val": value }
|
|
164379
|
+
};
|
|
164380
|
+
if (existing >= 0)
|
|
164381
|
+
children[existing] = newEl;
|
|
164382
|
+
else
|
|
164383
|
+
children.push(newEl);
|
|
164384
|
+
};
|
|
164385
|
+
setOrRemoveChild("w:numFmt", input2.numbering.format);
|
|
164386
|
+
setOrRemoveChild("w:numStart", input2.numbering.start !== undefined ? String(input2.numbering.start) : undefined);
|
|
164101
164387
|
if (input2.numbering.restartPolicy !== undefined)
|
|
164102
|
-
|
|
164103
|
-
|
|
164104
|
-
props.pos = input2.numbering.position;
|
|
164388
|
+
setOrRemoveChild("w:numRestart", RESTART_POLICY_TO_OOXML[input2.numbering.restartPolicy] ?? input2.numbering.restartPolicy);
|
|
164389
|
+
setOrRemoveChild("w:pos", input2.numbering.position);
|
|
164105
164390
|
}
|
|
164106
|
-
props.noteType = input2.type;
|
|
164107
|
-
if (input2.scope)
|
|
164108
|
-
props.scope = input2.scope;
|
|
164109
|
-
return {
|
|
164110
|
-
changed: true,
|
|
164111
|
-
payload: undefined
|
|
164112
|
-
};
|
|
164113
|
-
}, {
|
|
164114
|
-
dryRun: options?.dryRun ?? false,
|
|
164115
|
-
expectedRevision: options?.expectedRevision
|
|
164116
164391
|
});
|
|
164392
|
+
if (!options?.dryRun && prElementName === "w:footnotePr")
|
|
164393
|
+
syncFootnotePropertiesCache(editor);
|
|
164117
164394
|
return configSuccess$1();
|
|
164118
164395
|
}
|
|
164396
|
+
function syncFootnotePropertiesCache(editor) {
|
|
164397
|
+
const converter = getConverter2(editor);
|
|
164398
|
+
if (!converter?.footnoteProperties || converter.footnoteProperties.source !== "settings")
|
|
164399
|
+
return;
|
|
164400
|
+
const prElement = (converter.convertedXml?.["word/settings.xml"]?.elements?.[0]?.elements ?? []).find((el) => el.name === "w:footnotePr");
|
|
164401
|
+
if (prElement)
|
|
164402
|
+
converter.footnoteProperties.originalXml = structuredClone(prElement);
|
|
164403
|
+
else
|
|
164404
|
+
converter.footnoteProperties = null;
|
|
164405
|
+
}
|
|
164119
164406
|
function findAllCrossRefs(doc$2) {
|
|
164120
164407
|
const results = [];
|
|
164121
164408
|
doc$2.descendants((node3, pos) => {
|
|
@@ -165662,6 +165949,29 @@ function buildCitationAddress(doc$2, resolved) {
|
|
|
165662
165949
|
}
|
|
165663
165950
|
};
|
|
165664
165951
|
}
|
|
165952
|
+
function executeOutOfBandMutation(editor, mutateFn, options) {
|
|
165953
|
+
if (!options.dryRun)
|
|
165954
|
+
if (editor.options?.collaborationProvider && editor.options?.ydoc)
|
|
165955
|
+
try {
|
|
165956
|
+
yUndoPluginKey.getState(editor.state)?.undoManager?.stopCapturing();
|
|
165957
|
+
} catch {}
|
|
165958
|
+
else
|
|
165959
|
+
try {
|
|
165960
|
+
editor.view?.dispatch?.(closeHistory(editor.state.tr));
|
|
165961
|
+
} catch {}
|
|
165962
|
+
checkRevision(editor, options.expectedRevision);
|
|
165963
|
+
const result = mutateFn(options.dryRun);
|
|
165964
|
+
if (result.changed && !options.dryRun) {
|
|
165965
|
+
const converter = editor.converter;
|
|
165966
|
+
if (converter) {
|
|
165967
|
+
converter.documentModified = true;
|
|
165968
|
+
if (!converter.documentGuid && typeof converter.promoteToGuid === "function")
|
|
165969
|
+
converter.promoteToGuid();
|
|
165970
|
+
}
|
|
165971
|
+
incrementRevision(editor);
|
|
165972
|
+
}
|
|
165973
|
+
return result.payload;
|
|
165974
|
+
}
|
|
165665
165975
|
function citationSuccess(address2) {
|
|
165666
165976
|
return {
|
|
165667
165977
|
success: true,
|
|
@@ -166943,6 +167253,8 @@ function initPartsRuntime(editor) {
|
|
|
166943
167253
|
registerPartDescriptor(relsPartDescriptor);
|
|
166944
167254
|
registerPartDescriptor(numberingPartDescriptor);
|
|
166945
167255
|
registerPartDescriptor(contentTypesPartDescriptor);
|
|
167256
|
+
registerPartDescriptor(footnotesPartDescriptor);
|
|
167257
|
+
registerPartDescriptor(endnotesPartDescriptor);
|
|
166946
167258
|
registerStaticInvalidationHandlers();
|
|
166947
167259
|
initRevision(editor);
|
|
166948
167260
|
trackRevisions(editor);
|
|
@@ -179198,7 +179510,7 @@ function buildFootnotesInput(editorState, converter, converterContext, themeColo
|
|
|
179198
179510
|
return null;
|
|
179199
179511
|
const blocksById = /* @__PURE__ */ new Map;
|
|
179200
179512
|
idsInUse.forEach((id2) => {
|
|
179201
|
-
const content3 = importedFootnotes
|
|
179513
|
+
const content3 = findNoteEntryById(importedFootnotes, id2)?.content;
|
|
179202
179514
|
if (!Array.isArray(content3) || content3.length === 0)
|
|
179203
179515
|
return;
|
|
179204
179516
|
try {
|
|
@@ -190707,14 +191019,7 @@ var Node$13 = class Node$14 {
|
|
|
190707
191019
|
typeOver = true;
|
|
190708
191020
|
}
|
|
190709
191021
|
}
|
|
190710
|
-
if (
|
|
190711
|
-
for (let node3 of added)
|
|
190712
|
-
if (node3.nodeName == "BR" && node3.parentNode) {
|
|
190713
|
-
let after = node3.nextSibling;
|
|
190714
|
-
if (after && after.nodeType == 1 && after.contentEditable == "false")
|
|
190715
|
-
node3.parentNode.removeChild(node3);
|
|
190716
|
-
}
|
|
190717
|
-
} else if (gecko && added.length) {
|
|
191022
|
+
if (gecko && added.length) {
|
|
190718
191023
|
let brs = added.filter((n) => n.nodeName == "BR");
|
|
190719
191024
|
if (brs.length == 2) {
|
|
190720
191025
|
let [a2, b$1] = brs;
|
|
@@ -190730,6 +191035,13 @@ var Node$13 = class Node$14 {
|
|
|
190730
191035
|
br2.remove();
|
|
190731
191036
|
}
|
|
190732
191037
|
}
|
|
191038
|
+
} else if ((chrome || safari) && added.some((n) => n.nodeName == "BR") && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46)) {
|
|
191039
|
+
for (let node3 of added)
|
|
191040
|
+
if (node3.nodeName == "BR" && node3.parentNode) {
|
|
191041
|
+
let after = node3.nextSibling;
|
|
191042
|
+
if (after && after.nodeType == 1 && after.contentEditable == "false")
|
|
191043
|
+
node3.parentNode.removeChild(node3);
|
|
191044
|
+
}
|
|
190733
191045
|
}
|
|
190734
191046
|
let readSel = null;
|
|
190735
191047
|
if (from$1 < 0 && newSel && view.input.lastFocus > Date.now() - 200 && Math.max(view.input.lastTouch, view.input.lastClick.time) < Date.now() - 300 && selectionCollapsed(sel) && (readSel = selectionFromDOM(view)) && readSel.eq(Selection.near(view.state.doc.resolve(0), 1))) {
|
|
@@ -198613,7 +198925,7 @@ var Node$13 = class Node$14 {
|
|
|
198613
198925
|
candidate = String(parseInt(hex, 16));
|
|
198614
198926
|
} while (!candidate || existingIds.has(candidate));
|
|
198615
198927
|
return candidate;
|
|
198616
|
-
}, ALLOWED_WRAP_ATTRS, WRAP_TYPES_SUPPORTING_SIDE, WRAP_TYPES_SUPPORTING_DISTANCES, RELATIVE_HEIGHT_MIN = 0, RELATIVE_HEIGHT_MAX = 4294967295, FORBIDDEN_RAW_PATCH_NAMES, CONTROL_TYPE_SDT_PR_ELEMENTS, DEFAULT_CHECKBOX_SYMBOL_FONT2 = "MS Gothic", DEFAULT_CHECKBOX_CHECKED_HEX2 = "2612", DEFAULT_CHECKBOX_UNCHECKED_HEX2 = "2610", VARIANT_ORDER, KIND_ORDER, HEADER_RELATIONSHIP_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", DOCUMENT_RELS_PATH = "word/_rels/document.xml.rels", HEADER_FILE_PATTERN, FOOTER_FILE_PATTERN, RESTART_POLICY_TO_OOXML, VALID_DISPLAYS, CAPTION_STYLE_NAMES, CAPTION_PARAGRAPH_STYLE_ID = "Caption", CAPTION_FORMAT_TO_OOXML, FIELD_NODE_TYPES, TOA_LEADER_REVERSE_MAP, CONTENT_TYPES_PART_ID = "[Content_Types].xml", CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types", contentTypesPartDescriptor, empty_exports, init_empty, PIXELS_PER_INCH$1 = 96, MAX_HEIGHT_BUFFER_PX = 50, MAX_WIDTH_BUFFER_PX = 20, Editor, ContextMenuPluginKey, MENU_OFFSET_X = 0, MENU_OFFSET_Y = 28, CONTEXT_MENU_OFFSET_X = 10, CONTEXT_MENU_OFFSET_Y = 10, SLASH_COOLDOWN_MS = 5000, ContextMenu, SearchQuery = class {
|
|
198928
|
+
}, ALLOWED_WRAP_ATTRS, WRAP_TYPES_SUPPORTING_SIDE, WRAP_TYPES_SUPPORTING_DISTANCES, RELATIVE_HEIGHT_MIN = 0, RELATIVE_HEIGHT_MAX = 4294967295, FORBIDDEN_RAW_PATCH_NAMES, CONTROL_TYPE_SDT_PR_ELEMENTS, DEFAULT_CHECKBOX_SYMBOL_FONT2 = "MS Gothic", DEFAULT_CHECKBOX_CHECKED_HEX2 = "2612", DEFAULT_CHECKBOX_UNCHECKED_HEX2 = "2610", VARIANT_ORDER, KIND_ORDER, HEADER_RELATIONSHIP_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", DOCUMENT_RELS_PATH = "word/_rels/document.xml.rels", HEADER_FILE_PATTERN, FOOTER_FILE_PATTERN, SPECIAL_NOTE_TYPES, FOOTNOTES_PART_ID = "word/footnotes.xml", ENDNOTES_PART_ID = "word/endnotes.xml", FOOTNOTES_CONFIG, ENDNOTES_CONFIG, NOTES_XMLNS, footnotesPartDescriptor, endnotesPartDescriptor, RESTART_POLICY_TO_OOXML, VALID_DISPLAYS, CAPTION_STYLE_NAMES, CAPTION_PARAGRAPH_STYLE_ID = "Caption", CAPTION_FORMAT_TO_OOXML, FIELD_NODE_TYPES, TOA_LEADER_REVERSE_MAP, CONTENT_TYPES_PART_ID = "[Content_Types].xml", CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types", contentTypesPartDescriptor, empty_exports, init_empty, PIXELS_PER_INCH$1 = 96, MAX_HEIGHT_BUFFER_PX = 50, MAX_WIDTH_BUFFER_PX = 20, Editor, ContextMenuPluginKey, MENU_OFFSET_X = 0, MENU_OFFSET_Y = 28, CONTEXT_MENU_OFFSET_X = 10, CONTEXT_MENU_OFFSET_Y = 10, SLASH_COOLDOWN_MS = 5000, ContextMenu, SearchQuery = class {
|
|
198617
198929
|
constructor(config2) {
|
|
198618
198930
|
this.search = config2.search;
|
|
198619
198931
|
this.caseSensitive = !!config2.caseSensitive;
|
|
@@ -216826,9 +217138,9 @@ var Node$13 = class Node$14 {
|
|
|
216826
217138
|
return false;
|
|
216827
217139
|
return Boolean(checker(attrs));
|
|
216828
217140
|
}, SuperToolbar, ICONS, TEXTS, tableActionsOptions;
|
|
216829
|
-
var
|
|
217141
|
+
var init_src_BnjrN0Yi_es = __esm(() => {
|
|
216830
217142
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
216831
|
-
|
|
217143
|
+
init_SuperConverter_BeR1rqZz_es();
|
|
216832
217144
|
init_jszip_ChlR43oI_es();
|
|
216833
217145
|
init_uuid_qzgm05fK_es();
|
|
216834
217146
|
init_constants_CMPtQbp7_es();
|
|
@@ -225662,7 +225974,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
225662
225974
|
stylesPartDescriptor = {
|
|
225663
225975
|
id: STYLES_PART_ID,
|
|
225664
225976
|
ensurePart(editor) {
|
|
225665
|
-
const converter = getConverter$
|
|
225977
|
+
const converter = getConverter$7(editor);
|
|
225666
225978
|
if (converter?.convertedXml[STYLES_PART_ID])
|
|
225667
225979
|
return converter.convertedXml[STYLES_PART_ID];
|
|
225668
225980
|
return {
|
|
@@ -225677,7 +225989,7 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
225677
225989
|
},
|
|
225678
225990
|
afterCommit(ctx$1) {
|
|
225679
225991
|
if (ctx$1.source.startsWith("collab:remote:")) {
|
|
225680
|
-
const converter = getConverter$
|
|
225992
|
+
const converter = getConverter$7(ctx$1.editor);
|
|
225681
225993
|
if (converter)
|
|
225682
225994
|
try {
|
|
225683
225995
|
converter.translatedLinkedStyles = translateStyleDefinitions(converter.convertedXml);
|
|
@@ -225802,6 +226114,38 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
225802
226114
|
KIND_ORDER = ["header", "footer"];
|
|
225803
226115
|
HEADER_FILE_PATTERN = /header(\d+)\.xml$/;
|
|
225804
226116
|
FOOTER_FILE_PATTERN = /footer(\d+)\.xml$/;
|
|
226117
|
+
SPECIAL_NOTE_TYPES = new Set(["separator", "continuationSeparator"]);
|
|
226118
|
+
FOOTNOTES_CONFIG = {
|
|
226119
|
+
partId: FOOTNOTES_PART_ID,
|
|
226120
|
+
rootElementName: "w:footnotes",
|
|
226121
|
+
childElementName: "w:footnote",
|
|
226122
|
+
converterKey: "footnotes"
|
|
226123
|
+
};
|
|
226124
|
+
ENDNOTES_CONFIG = {
|
|
226125
|
+
partId: ENDNOTES_PART_ID,
|
|
226126
|
+
rootElementName: "w:endnotes",
|
|
226127
|
+
childElementName: "w:endnote",
|
|
226128
|
+
converterKey: "endnotes"
|
|
226129
|
+
};
|
|
226130
|
+
NOTES_XMLNS = {
|
|
226131
|
+
"xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
226132
|
+
"xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
|
226133
|
+
"xmlns:o": "urn:schemas-microsoft-com:office:office",
|
|
226134
|
+
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
226135
|
+
"xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
226136
|
+
"xmlns:v": "urn:schemas-microsoft-com:vml",
|
|
226137
|
+
"xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
|
|
226138
|
+
"xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
226139
|
+
"xmlns:w10": "urn:schemas-microsoft-com:office:word",
|
|
226140
|
+
"xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
226141
|
+
"xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
|
|
226142
|
+
"xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",
|
|
226143
|
+
"xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
|
|
226144
|
+
"xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml",
|
|
226145
|
+
"xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
|
|
226146
|
+
};
|
|
226147
|
+
footnotesPartDescriptor = createNotePartDescriptor(FOOTNOTES_CONFIG);
|
|
226148
|
+
endnotesPartDescriptor = createNotePartDescriptor(ENDNOTES_CONFIG);
|
|
225805
226149
|
RESTART_POLICY_TO_OOXML = {
|
|
225806
226150
|
continuous: "continuous",
|
|
225807
226151
|
eachSection: "eachSect",
|
|
@@ -236980,6 +237324,16 @@ function print() { __p += __j.call(arguments, '') }
|
|
|
236980
237324
|
event: "stylesDefaultsChanged",
|
|
236981
237325
|
handler: handleStylesDefaultsChanged
|
|
236982
237326
|
});
|
|
237327
|
+
const handleNotesPartChanged = () => {
|
|
237328
|
+
this.#pendingDocChange = true;
|
|
237329
|
+
this.#selectionSync.onLayoutStart();
|
|
237330
|
+
this.#scheduleRerender();
|
|
237331
|
+
};
|
|
237332
|
+
this.#editor.on("notes-part-changed", handleNotesPartChanged);
|
|
237333
|
+
this.#editorListeners.push({
|
|
237334
|
+
event: "notes-part-changed",
|
|
237335
|
+
handler: handleNotesPartChanged
|
|
237336
|
+
});
|
|
236983
237337
|
const handleCollaborationReady = (payload) => {
|
|
236984
237338
|
this.emit("collaborationReady", payload);
|
|
236985
237339
|
if (this.#options.collaborationProvider?.awareness && this.#layoutOptions.presence?.enabled !== false)
|
|
@@ -250454,8 +250808,8 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
|
|
|
250454
250808
|
|
|
250455
250809
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
250456
250810
|
var init_super_editor_es = __esm(() => {
|
|
250457
|
-
|
|
250458
|
-
|
|
250811
|
+
init_src_BnjrN0Yi_es();
|
|
250812
|
+
init_SuperConverter_BeR1rqZz_es();
|
|
250459
250813
|
init_jszip_ChlR43oI_es();
|
|
250460
250814
|
init_xml_js_DLE8mr0n_es();
|
|
250461
250815
|
init_constants_CMPtQbp7_es();
|
|
@@ -275878,7 +276232,7 @@ var init_awareness = __esm(() => {
|
|
|
275878
276232
|
};
|
|
275879
276233
|
});
|
|
275880
276234
|
|
|
275881
|
-
// ../../node_modules/.pnpm/y-prosemirror@1.3.7_prosemirror-model@1.25.4_prosemirror-state@1.4.4_prosemirror-view@
|
|
276235
|
+
// ../../node_modules/.pnpm/y-prosemirror@1.3.7_prosemirror-model@1.25.4_prosemirror-state@1.4.4_prosemirror-view@1_bbc4954c3f565631ca331e4536595600/node_modules/y-prosemirror/src/plugins/keys.js
|
|
275882
276236
|
var ySyncPluginKey2, yUndoPluginKey2, yCursorPluginKey2;
|
|
275883
276237
|
var init_keys = __esm(() => {
|
|
275884
276238
|
init_dist5();
|
|
@@ -275887,18 +276241,18 @@ var init_keys = __esm(() => {
|
|
|
275887
276241
|
yCursorPluginKey2 = new PluginKey2("yjs-cursor");
|
|
275888
276242
|
});
|
|
275889
276243
|
|
|
275890
|
-
// ../../node_modules/.pnpm/y-prosemirror@1.3.7_prosemirror-model@1.25.4_prosemirror-state@1.4.4_prosemirror-view@
|
|
276244
|
+
// ../../node_modules/.pnpm/y-prosemirror@1.3.7_prosemirror-model@1.25.4_prosemirror-state@1.4.4_prosemirror-view@1_bbc4954c3f565631ca331e4536595600/node_modules/y-prosemirror/src/plugins/cursor-plugin.js
|
|
275891
276245
|
var init_cursor_plugin = __esm(() => {
|
|
275892
276246
|
init_awareness();
|
|
275893
276247
|
});
|
|
275894
276248
|
|
|
275895
|
-
// ../../node_modules/.pnpm/y-prosemirror@1.3.7_prosemirror-model@1.25.4_prosemirror-state@1.4.4_prosemirror-view@
|
|
276249
|
+
// ../../node_modules/.pnpm/y-prosemirror@1.3.7_prosemirror-model@1.25.4_prosemirror-state@1.4.4_prosemirror-view@1_bbc4954c3f565631ca331e4536595600/node_modules/y-prosemirror/src/plugins/undo-plugin.js
|
|
275896
276250
|
var defaultProtectedNodes2;
|
|
275897
276251
|
var init_undo_plugin = __esm(() => {
|
|
275898
276252
|
defaultProtectedNodes2 = new Set(["paragraph"]);
|
|
275899
276253
|
});
|
|
275900
276254
|
|
|
275901
|
-
// ../../node_modules/.pnpm/y-prosemirror@1.3.7_prosemirror-model@1.25.4_prosemirror-state@1.4.4_prosemirror-view@
|
|
276255
|
+
// ../../node_modules/.pnpm/y-prosemirror@1.3.7_prosemirror-model@1.25.4_prosemirror-state@1.4.4_prosemirror-view@1_bbc4954c3f565631ca331e4536595600/node_modules/y-prosemirror/src/y-prosemirror.js
|
|
275902
276256
|
var init_y_prosemirror = __esm(() => {
|
|
275903
276257
|
init_cursor_plugin();
|
|
275904
276258
|
init_undo_plugin();
|
|
@@ -307891,20 +308245,28 @@ var init_documentCommentsImporter = __esm(() => {
|
|
|
307891
308245
|
});
|
|
307892
308246
|
|
|
307893
308247
|
// ../../packages/super-editor/src/core/super-converter/v2/importer/documentFootnotesImporter.js
|
|
307894
|
-
function
|
|
308248
|
+
function importNoteEntries2({
|
|
308249
|
+
partXml,
|
|
308250
|
+
childElementName,
|
|
308251
|
+
filename,
|
|
308252
|
+
docx,
|
|
308253
|
+
editor,
|
|
308254
|
+
converter,
|
|
308255
|
+
nodeListHandler,
|
|
308256
|
+
numbering
|
|
308257
|
+
}) {
|
|
307895
308258
|
const handler3 = nodeListHandler || defaultNodeListHandler2();
|
|
307896
|
-
|
|
307897
|
-
if (!footnotes?.elements?.length)
|
|
308259
|
+
if (!partXml?.elements?.length)
|
|
307898
308260
|
return [];
|
|
307899
|
-
const root4 =
|
|
308261
|
+
const root4 = partXml.elements[0];
|
|
307900
308262
|
const elements = Array.isArray(root4?.elements) ? root4.elements : [];
|
|
307901
|
-
const
|
|
307902
|
-
if (
|
|
308263
|
+
const noteElements = elements.filter((el) => el?.name === childElementName);
|
|
308264
|
+
if (noteElements.length === 0)
|
|
307903
308265
|
return [];
|
|
307904
308266
|
const results = [];
|
|
307905
308267
|
const lists = {};
|
|
307906
308268
|
const inlineDocumentFonts = [];
|
|
307907
|
-
|
|
308269
|
+
noteElements.forEach((el) => {
|
|
307908
308270
|
const idRaw = el?.attributes?.["w:id"];
|
|
307909
308271
|
if (idRaw === undefined || idRaw === null)
|
|
307910
308272
|
return;
|
|
@@ -307933,7 +308295,7 @@ function importFootnoteData2({ docx, editor, converter, nodeListHandler, numberi
|
|
|
307933
308295
|
numbering,
|
|
307934
308296
|
lists,
|
|
307935
308297
|
inlineDocumentFonts,
|
|
307936
|
-
filename
|
|
308298
|
+
filename,
|
|
307937
308299
|
path: [el]
|
|
307938
308300
|
});
|
|
307939
308301
|
const stripped = stripFootnoteMarkerNodes2(converted);
|
|
@@ -307946,6 +308308,30 @@ function importFootnoteData2({ docx, editor, converter, nodeListHandler, numberi
|
|
|
307946
308308
|
});
|
|
307947
308309
|
return results;
|
|
307948
308310
|
}
|
|
308311
|
+
function importFootnoteData2({ docx, editor, converter, nodeListHandler, numbering } = {}) {
|
|
308312
|
+
return importNoteEntries2({
|
|
308313
|
+
partXml: docx?.["word/footnotes.xml"],
|
|
308314
|
+
childElementName: "w:footnote",
|
|
308315
|
+
filename: "footnotes.xml",
|
|
308316
|
+
docx,
|
|
308317
|
+
editor,
|
|
308318
|
+
converter,
|
|
308319
|
+
nodeListHandler,
|
|
308320
|
+
numbering
|
|
308321
|
+
});
|
|
308322
|
+
}
|
|
308323
|
+
function importEndnoteData2({ docx, editor, converter, nodeListHandler, numbering } = {}) {
|
|
308324
|
+
return importNoteEntries2({
|
|
308325
|
+
partXml: docx?.["word/endnotes.xml"],
|
|
308326
|
+
childElementName: "w:endnote",
|
|
308327
|
+
filename: "endnotes.xml",
|
|
308328
|
+
docx,
|
|
308329
|
+
editor,
|
|
308330
|
+
converter,
|
|
308331
|
+
nodeListHandler,
|
|
308332
|
+
numbering
|
|
308333
|
+
});
|
|
308334
|
+
}
|
|
307949
308335
|
var stripFootnoteMarkerNodes2 = (nodes) => {
|
|
307950
308336
|
if (!Array.isArray(nodes) || nodes.length === 0)
|
|
307951
308337
|
return nodes;
|
|
@@ -309069,6 +309455,7 @@ var detectDocumentOrigin2 = (docx) => {
|
|
|
309069
309455
|
const numbering = getNumberingDefinitions2(docx);
|
|
309070
309456
|
const comments = importCommentData2({ docx, nodeListHandler, converter, editor });
|
|
309071
309457
|
const footnotes = importFootnoteData2({ docx, nodeListHandler, converter, editor, numbering });
|
|
309458
|
+
const endnotes = importEndnoteData2({ docx, nodeListHandler, converter, editor, numbering });
|
|
309072
309459
|
const translatedLinkedStyles = translateStyleDefinitions2(docx);
|
|
309073
309460
|
const translatedNumbering = translateNumberingDefinitions2(docx);
|
|
309074
309461
|
const importDiagnosticsCollectionId = startCollection2();
|
|
@@ -309105,6 +309492,7 @@ var detectDocumentOrigin2 = (docx) => {
|
|
|
309105
309492
|
pageStyles: getDocumentStyles2(node4, docx, converter, editor, numbering, translatedNumbering, translatedLinkedStyles),
|
|
309106
309493
|
comments,
|
|
309107
309494
|
footnotes,
|
|
309495
|
+
endnotes,
|
|
309108
309496
|
inlineDocumentFonts,
|
|
309109
309497
|
linkedStyles: getStyleDefinitions2(docx, converter, editor),
|
|
309110
309498
|
translatedLinkedStyles,
|
|
@@ -312173,6 +312561,7 @@ var init_SuperConverter = __esm(() => {
|
|
|
312173
312561
|
init_exporter_docx_defs();
|
|
312174
312562
|
init_commentsExporter();
|
|
312175
312563
|
init_footnotesExporter();
|
|
312564
|
+
init_documentFootnotesImporter();
|
|
312176
312565
|
init_docx_helpers2();
|
|
312177
312566
|
init_relationship_helpers();
|
|
312178
312567
|
init_constants2();
|
|
@@ -312800,6 +313189,7 @@ var init_SuperConverter = __esm(() => {
|
|
|
312800
313189
|
this.numbering = result.numbering;
|
|
312801
313190
|
this.comments = result.comments;
|
|
312802
313191
|
this.footnotes = result.footnotes;
|
|
313192
|
+
this.endnotes = result.endnotes ?? [];
|
|
312803
313193
|
this.linkedStyles = result.linkedStyles;
|
|
312804
313194
|
this.translatedLinkedStyles = result.translatedLinkedStyles;
|
|
312805
313195
|
this.translatedNumbering = result.translatedNumbering;
|
|
@@ -313136,6 +313526,17 @@ var init_SuperConverter = __esm(() => {
|
|
|
313136
313526
|
schema = normalizeDuplicateBlockIdentitiesInContent2(schema);
|
|
313137
313527
|
return { type: "doc", content: [...schema] };
|
|
313138
313528
|
}
|
|
313529
|
+
reimportNotePart(partId) {
|
|
313530
|
+
if (!this.convertedXml?.[partId])
|
|
313531
|
+
return [];
|
|
313532
|
+
const importFn = partId === "word/endnotes.xml" ? importEndnoteData2 : importFootnoteData2;
|
|
313533
|
+
return importFn({
|
|
313534
|
+
docx: this.convertedXml,
|
|
313535
|
+
editor: {},
|
|
313536
|
+
converter: this,
|
|
313537
|
+
numbering: this.numbering
|
|
313538
|
+
});
|
|
313539
|
+
}
|
|
313139
313540
|
createDefaultHeader(variant = "default") {
|
|
313140
313541
|
if (typeof variant !== "string") {
|
|
313141
313542
|
throw new TypeError(`variant must be a string, received ${typeof variant}`);
|
|
@@ -320411,6 +320812,9 @@ function takeSnapshot2(editor, partIds) {
|
|
|
320411
320812
|
partEntries,
|
|
320412
320813
|
numbering: converter?.numbering ? clonePart2(converter.numbering) : undefined,
|
|
320413
320814
|
translatedNumbering: converter?.translatedNumbering ? clonePart2(converter.translatedNumbering) : undefined,
|
|
320815
|
+
footnotes: converter?.footnotes ? clonePart2(converter.footnotes) : undefined,
|
|
320816
|
+
endnotes: converter?.endnotes ? clonePart2(converter.endnotes) : undefined,
|
|
320817
|
+
footnoteProperties: converter?.footnoteProperties ? clonePart2(converter.footnoteProperties) : undefined,
|
|
320414
320818
|
revision: getRevision2(editor),
|
|
320415
320819
|
documentModified: converter?.documentModified ?? false,
|
|
320416
320820
|
documentGuid: converter?.documentGuid ?? null
|
|
@@ -320434,6 +320838,12 @@ function restoreFromSnapshot2(editor, snapshot2) {
|
|
|
320434
320838
|
converter.numbering = snapshot2.numbering;
|
|
320435
320839
|
if (snapshot2.translatedNumbering !== undefined)
|
|
320436
320840
|
converter.translatedNumbering = snapshot2.translatedNumbering;
|
|
320841
|
+
if (snapshot2.footnotes !== undefined)
|
|
320842
|
+
converter.footnotes = snapshot2.footnotes;
|
|
320843
|
+
if (snapshot2.endnotes !== undefined)
|
|
320844
|
+
converter.endnotes = snapshot2.endnotes;
|
|
320845
|
+
if (snapshot2.footnoteProperties !== undefined)
|
|
320846
|
+
converter.footnoteProperties = snapshot2.footnoteProperties;
|
|
320437
320847
|
converter.documentModified = snapshot2.documentModified;
|
|
320438
320848
|
converter.documentGuid = snapshot2.documentGuid;
|
|
320439
320849
|
restoreRevision2(editor, snapshot2.revision);
|
|
@@ -336678,6 +337088,28 @@ var init_bookmark_wrappers = __esm(() => {
|
|
|
336678
337088
|
init_errors3();
|
|
336679
337089
|
});
|
|
336680
337090
|
|
|
337091
|
+
// ../../packages/super-editor/src/document-api-adapters/helpers/note-entry-lookup.ts
|
|
337092
|
+
function isSpecialEntry2(entry) {
|
|
337093
|
+
return SPECIAL_NOTE_TYPES2.has(entry.type ?? "");
|
|
337094
|
+
}
|
|
337095
|
+
function findNoteEntryById2(entries, noteId) {
|
|
337096
|
+
if (!Array.isArray(entries))
|
|
337097
|
+
return;
|
|
337098
|
+
let fallback;
|
|
337099
|
+
for (const entry of entries) {
|
|
337100
|
+
if (String(entry.id ?? "") !== noteId)
|
|
337101
|
+
continue;
|
|
337102
|
+
if (!isSpecialEntry2(entry))
|
|
337103
|
+
return entry;
|
|
337104
|
+
fallback ??= entry;
|
|
337105
|
+
}
|
|
337106
|
+
return fallback;
|
|
337107
|
+
}
|
|
337108
|
+
var SPECIAL_NOTE_TYPES2;
|
|
337109
|
+
var init_note_entry_lookup = __esm(() => {
|
|
337110
|
+
SPECIAL_NOTE_TYPES2 = new Set(["separator", "continuationSeparator"]);
|
|
337111
|
+
});
|
|
337112
|
+
|
|
336681
337113
|
// ../../packages/super-editor/src/document-api-adapters/helpers/footnote-resolver.ts
|
|
336682
337114
|
function getConverterStore2(editor) {
|
|
336683
337115
|
return editor.converter ?? {};
|
|
@@ -336711,7 +337143,7 @@ function resolveCollectionContent2(collection, noteId) {
|
|
|
336711
337143
|
if (!collection)
|
|
336712
337144
|
return "";
|
|
336713
337145
|
if (Array.isArray(collection)) {
|
|
336714
|
-
const match2 = collection
|
|
337146
|
+
const match2 = findNoteEntryById2(collection, noteId);
|
|
336715
337147
|
return extractTextFromContent2(match2?.content);
|
|
336716
337148
|
}
|
|
336717
337149
|
if (isLegacyFootnoteMap2(collection)) {
|
|
@@ -336783,39 +337215,257 @@ function buildFootnoteDiscoveryItem2(editor, resolved, evaluatedRevision) {
|
|
|
336783
337215
|
var init_footnote_resolver = __esm(() => {
|
|
336784
337216
|
init_src();
|
|
336785
337217
|
init_errors3();
|
|
337218
|
+
init_note_entry_lookup();
|
|
336786
337219
|
});
|
|
336787
337220
|
|
|
336788
|
-
// ../../packages/super-editor/src/
|
|
336789
|
-
function
|
|
336790
|
-
|
|
336791
|
-
|
|
336792
|
-
|
|
336793
|
-
|
|
336794
|
-
|
|
336795
|
-
|
|
336796
|
-
|
|
336797
|
-
|
|
336798
|
-
|
|
337221
|
+
// ../../packages/super-editor/src/core/parts/adapters/notes-part-descriptor.ts
|
|
337222
|
+
function getConverter14(editor) {
|
|
337223
|
+
return editor.converter;
|
|
337224
|
+
}
|
|
337225
|
+
function getRootElement2(part) {
|
|
337226
|
+
return part?.elements?.[0];
|
|
337227
|
+
}
|
|
337228
|
+
function getNoteElements2(part, childElementName) {
|
|
337229
|
+
const root4 = getRootElement2(part);
|
|
337230
|
+
if (!root4?.elements)
|
|
337231
|
+
return [];
|
|
337232
|
+
return root4.elements.filter((el) => el.name === childElementName);
|
|
337233
|
+
}
|
|
337234
|
+
function textToNoteOoxmlParagraphs2(text9) {
|
|
337235
|
+
return text9.split(/\r?\n/).map((line) => ({
|
|
337236
|
+
type: "element",
|
|
337237
|
+
name: "w:p",
|
|
337238
|
+
elements: line.length > 0 ? [
|
|
337239
|
+
{
|
|
337240
|
+
type: "element",
|
|
337241
|
+
name: "w:r",
|
|
337242
|
+
elements: [
|
|
337243
|
+
{
|
|
337244
|
+
type: "element",
|
|
337245
|
+
name: "w:t",
|
|
337246
|
+
attributes: { "xml:space": "preserve" },
|
|
337247
|
+
elements: [{ type: "text", text: line }]
|
|
337248
|
+
}
|
|
337249
|
+
]
|
|
337250
|
+
}
|
|
337251
|
+
] : []
|
|
337252
|
+
}));
|
|
337253
|
+
}
|
|
337254
|
+
function ensureFootnoteRefRun2(paragraphs, childElementName) {
|
|
337255
|
+
if (paragraphs.length === 0)
|
|
337256
|
+
return;
|
|
337257
|
+
const refName = childElementName === "w:footnote" ? "w:footnoteRef" : "w:endnoteRef";
|
|
337258
|
+
const styleName = childElementName === "w:footnote" ? "FootnoteReference" : "EndnoteReference";
|
|
337259
|
+
const firstParagraph = paragraphs[0];
|
|
337260
|
+
if (!firstParagraph.elements)
|
|
337261
|
+
firstParagraph.elements = [];
|
|
337262
|
+
const refRun = {
|
|
337263
|
+
type: "element",
|
|
337264
|
+
name: "w:r",
|
|
337265
|
+
elements: [
|
|
337266
|
+
{
|
|
337267
|
+
type: "element",
|
|
337268
|
+
name: "w:rPr",
|
|
337269
|
+
elements: [
|
|
337270
|
+
{ type: "element", name: "w:rStyle", attributes: { "w:val": styleName } },
|
|
337271
|
+
{ type: "element", name: "w:vertAlign", attributes: { "w:val": "superscript" } }
|
|
337272
|
+
]
|
|
337273
|
+
},
|
|
337274
|
+
{ type: "element", name: refName, elements: [] }
|
|
337275
|
+
]
|
|
337276
|
+
};
|
|
337277
|
+
const pPrIndex = firstParagraph.elements.findIndex((el) => el?.name === "w:pPr");
|
|
337278
|
+
firstParagraph.elements.splice(pPrIndex >= 0 ? pPrIndex + 1 : 0, 0, refRun);
|
|
337279
|
+
}
|
|
337280
|
+
function addNoteElement2(part, config41, noteId, text9) {
|
|
337281
|
+
const root4 = getRootElement2(part);
|
|
337282
|
+
if (!root4)
|
|
337283
|
+
throw new Error(`addNoteElement: missing root element in ${config41.partId}`);
|
|
337284
|
+
if (!root4.elements)
|
|
337285
|
+
root4.elements = [];
|
|
337286
|
+
const duplicate = root4.elements.find((el) => el.name === config41.childElementName && el.attributes?.["w:id"] === noteId);
|
|
337287
|
+
if (duplicate) {
|
|
337288
|
+
throw new Error(`addNoteElement: note id "${noteId}" already exists in ${config41.partId}`);
|
|
337289
|
+
}
|
|
337290
|
+
const paragraphs = textToNoteOoxmlParagraphs2(text9);
|
|
337291
|
+
ensureFootnoteRefRun2(paragraphs, config41.childElementName);
|
|
337292
|
+
const noteElement = {
|
|
337293
|
+
type: "element",
|
|
337294
|
+
name: config41.childElementName,
|
|
337295
|
+
attributes: { "w:id": noteId },
|
|
337296
|
+
elements: paragraphs
|
|
337297
|
+
};
|
|
337298
|
+
root4.elements.push(noteElement);
|
|
337299
|
+
return noteElement;
|
|
337300
|
+
}
|
|
337301
|
+
function updateNoteElement2(part, config41, noteId, text9) {
|
|
337302
|
+
const notes = getNoteElements2(part, config41.childElementName);
|
|
337303
|
+
const target = notes.find((el) => el.attributes?.["w:id"] === noteId);
|
|
337304
|
+
if (!target)
|
|
337305
|
+
return false;
|
|
337306
|
+
const paragraphs = textToNoteOoxmlParagraphs2(text9);
|
|
337307
|
+
ensureFootnoteRefRun2(paragraphs, config41.childElementName);
|
|
337308
|
+
target.elements = paragraphs;
|
|
337309
|
+
return true;
|
|
337310
|
+
}
|
|
337311
|
+
function removeNoteElement2(part, config41, noteId) {
|
|
337312
|
+
const root4 = getRootElement2(part);
|
|
337313
|
+
if (!root4?.elements)
|
|
337314
|
+
return false;
|
|
337315
|
+
const index3 = root4.elements.findIndex((el) => el.name === config41.childElementName && el.attributes?.["w:id"] === noteId);
|
|
337316
|
+
if (index3 < 0)
|
|
337317
|
+
return false;
|
|
337318
|
+
root4.elements.splice(index3, 1);
|
|
337319
|
+
return true;
|
|
337320
|
+
}
|
|
337321
|
+
function rebuildDerivedCache2(editor, config41, part) {
|
|
337322
|
+
const converter = getConverter14(editor);
|
|
337323
|
+
if (!converter)
|
|
337324
|
+
return;
|
|
337325
|
+
if (typeof converter.reimportNotePart === "function") {
|
|
337326
|
+
try {
|
|
337327
|
+
converter[config41.converterKey] = converter.reimportNotePart(config41.partId);
|
|
337328
|
+
return;
|
|
337329
|
+
} catch (err) {
|
|
337330
|
+
console.warn(`[parts] reimportNotePart failed for ${config41.partId}, using fallback:`, err);
|
|
336799
337331
|
}
|
|
336800
337332
|
}
|
|
336801
|
-
|
|
336802
|
-
const
|
|
336803
|
-
|
|
336804
|
-
|
|
336805
|
-
|
|
336806
|
-
|
|
336807
|
-
|
|
336808
|
-
|
|
337333
|
+
const notes = getNoteElements2(part, config41.childElementName);
|
|
337334
|
+
const entries = notes.map((el) => ({
|
|
337335
|
+
id: String(el.attributes?.["w:id"] ?? ""),
|
|
337336
|
+
type: el.attributes?.["w:type"] ?? null,
|
|
337337
|
+
content: [],
|
|
337338
|
+
originalXml: structuredClone(el)
|
|
337339
|
+
}));
|
|
337340
|
+
converter[config41.converterKey] = entries;
|
|
337341
|
+
}
|
|
337342
|
+
function createInitialNotesPart2(config41) {
|
|
337343
|
+
return {
|
|
337344
|
+
declaration: {
|
|
337345
|
+
attributes: { version: "1.0", encoding: "UTF-8", standalone: "yes" }
|
|
337346
|
+
},
|
|
337347
|
+
elements: [
|
|
337348
|
+
{
|
|
337349
|
+
type: "element",
|
|
337350
|
+
name: config41.rootElementName,
|
|
337351
|
+
attributes: { ...NOTES_XMLNS2 },
|
|
337352
|
+
elements: [
|
|
337353
|
+
{
|
|
337354
|
+
type: "element",
|
|
337355
|
+
name: config41.childElementName,
|
|
337356
|
+
attributes: { "w:type": "separator", "w:id": "-1" },
|
|
337357
|
+
elements: [
|
|
337358
|
+
{
|
|
337359
|
+
type: "element",
|
|
337360
|
+
name: "w:p",
|
|
337361
|
+
elements: [
|
|
337362
|
+
{
|
|
337363
|
+
type: "element",
|
|
337364
|
+
name: "w:r",
|
|
337365
|
+
elements: [{ type: "element", name: "w:separator", elements: [] }]
|
|
337366
|
+
}
|
|
337367
|
+
]
|
|
337368
|
+
}
|
|
337369
|
+
]
|
|
337370
|
+
},
|
|
337371
|
+
{
|
|
337372
|
+
type: "element",
|
|
337373
|
+
name: config41.childElementName,
|
|
337374
|
+
attributes: { "w:type": "continuationSeparator", "w:id": "0" },
|
|
337375
|
+
elements: [
|
|
337376
|
+
{
|
|
337377
|
+
type: "element",
|
|
337378
|
+
name: "w:p",
|
|
337379
|
+
elements: [
|
|
337380
|
+
{
|
|
337381
|
+
type: "element",
|
|
337382
|
+
name: "w:r",
|
|
337383
|
+
elements: [{ type: "element", name: "w:continuationSeparator", elements: [] }]
|
|
337384
|
+
}
|
|
337385
|
+
]
|
|
337386
|
+
}
|
|
337387
|
+
]
|
|
337388
|
+
}
|
|
337389
|
+
]
|
|
336809
337390
|
}
|
|
337391
|
+
]
|
|
337392
|
+
};
|
|
337393
|
+
}
|
|
337394
|
+
function createNotePartDescriptor2(config41) {
|
|
337395
|
+
return {
|
|
337396
|
+
id: config41.partId,
|
|
337397
|
+
ensurePart() {
|
|
337398
|
+
return createInitialNotesPart2(config41);
|
|
337399
|
+
},
|
|
337400
|
+
normalizePart(part) {
|
|
337401
|
+
const root4 = getRootElement2(part);
|
|
337402
|
+
if (!root4?.elements)
|
|
337403
|
+
return;
|
|
337404
|
+
root4.elements.sort((a2, b2) => {
|
|
337405
|
+
const aType = a2.attributes?.["w:type"];
|
|
337406
|
+
const bType = b2.attributes?.["w:type"];
|
|
337407
|
+
const aIsSpecial = aType === "separator" || aType === "continuationSeparator";
|
|
337408
|
+
const bIsSpecial = bType === "separator" || bType === "continuationSeparator";
|
|
337409
|
+
if (aIsSpecial !== bIsSpecial)
|
|
337410
|
+
return aIsSpecial ? -1 : 1;
|
|
337411
|
+
const aId = Number(a2.attributes?.["w:id"] ?? 0);
|
|
337412
|
+
const bId = Number(b2.attributes?.["w:id"] ?? 0);
|
|
337413
|
+
return aId - bId;
|
|
337414
|
+
});
|
|
337415
|
+
},
|
|
337416
|
+
afterCommit({ editor, part, source }) {
|
|
337417
|
+
rebuildDerivedCache2(editor, config41, part);
|
|
337418
|
+
clearPartCacheStale2(editor, config41.partId);
|
|
337419
|
+
editor.emit("notes-part-changed", { partId: config41.partId, source });
|
|
336810
337420
|
}
|
|
336811
|
-
|
|
336812
|
-
}
|
|
336813
|
-
return result.payload;
|
|
337421
|
+
};
|
|
336814
337422
|
}
|
|
336815
|
-
|
|
336816
|
-
|
|
336817
|
-
|
|
336818
|
-
|
|
337423
|
+
function getNotesConfig2(type) {
|
|
337424
|
+
return type === "endnote" ? ENDNOTES_CONFIG2 : FOOTNOTES_CONFIG2;
|
|
337425
|
+
}
|
|
337426
|
+
function bootstrapNotesPart2(editor, type) {
|
|
337427
|
+
const converter = editor.converter;
|
|
337428
|
+
if (!converter?.convertedXml)
|
|
337429
|
+
return;
|
|
337430
|
+
const config41 = getNotesConfig2(type);
|
|
337431
|
+
if (converter.convertedXml[config41.partId] !== undefined)
|
|
337432
|
+
return;
|
|
337433
|
+
converter.convertedXml[config41.partId] = createInitialNotesPart2(config41);
|
|
337434
|
+
}
|
|
337435
|
+
var FOOTNOTES_PART_ID2 = "word/footnotes.xml", ENDNOTES_PART_ID2 = "word/endnotes.xml", FOOTNOTES_CONFIG2, ENDNOTES_CONFIG2, NOTES_XMLNS2, footnotesPartDescriptor2, endnotesPartDescriptor2;
|
|
337436
|
+
var init_notes_part_descriptor = __esm(() => {
|
|
337437
|
+
init_cache_staleness();
|
|
337438
|
+
FOOTNOTES_CONFIG2 = {
|
|
337439
|
+
partId: FOOTNOTES_PART_ID2,
|
|
337440
|
+
rootElementName: "w:footnotes",
|
|
337441
|
+
childElementName: "w:footnote",
|
|
337442
|
+
converterKey: "footnotes"
|
|
337443
|
+
};
|
|
337444
|
+
ENDNOTES_CONFIG2 = {
|
|
337445
|
+
partId: ENDNOTES_PART_ID2,
|
|
337446
|
+
rootElementName: "w:endnotes",
|
|
337447
|
+
childElementName: "w:endnote",
|
|
337448
|
+
converterKey: "endnotes"
|
|
337449
|
+
};
|
|
337450
|
+
NOTES_XMLNS2 = {
|
|
337451
|
+
"xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
|
|
337452
|
+
"xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
|
337453
|
+
"xmlns:o": "urn:schemas-microsoft-com:office:office",
|
|
337454
|
+
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
337455
|
+
"xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
337456
|
+
"xmlns:v": "urn:schemas-microsoft-com:vml",
|
|
337457
|
+
"xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
|
|
337458
|
+
"xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
337459
|
+
"xmlns:w10": "urn:schemas-microsoft-com:office:word",
|
|
337460
|
+
"xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
337461
|
+
"xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
|
|
337462
|
+
"xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",
|
|
337463
|
+
"xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
|
|
337464
|
+
"xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml",
|
|
337465
|
+
"xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape"
|
|
337466
|
+
};
|
|
337467
|
+
footnotesPartDescriptor2 = createNotePartDescriptor2(FOOTNOTES_CONFIG2);
|
|
337468
|
+
endnotesPartDescriptor2 = createNotePartDescriptor2(ENDNOTES_CONFIG2);
|
|
336819
337469
|
});
|
|
336820
337470
|
|
|
336821
337471
|
// ../../packages/super-editor/src/document-api-adapters/plan-engine/footnote-wrappers.ts
|
|
@@ -336828,37 +337478,12 @@ function footnoteFailure2(code10, message) {
|
|
|
336828
337478
|
function configSuccess2() {
|
|
336829
337479
|
return { success: true };
|
|
336830
337480
|
}
|
|
336831
|
-
function
|
|
336832
|
-
|
|
336833
|
-
|
|
336834
|
-
|
|
336835
|
-
return value != null && typeof value === "object" && !Array.isArray(value);
|
|
336836
|
-
}
|
|
336837
|
-
function textToFootnoteContentNodes2(text9) {
|
|
336838
|
-
const lines = text9.split(/\r?\n/);
|
|
336839
|
-
return lines.map((line) => ({
|
|
336840
|
-
type: "paragraph",
|
|
336841
|
-
content: line.length > 0 ? [{ type: "text", text: line }] : []
|
|
336842
|
-
}));
|
|
336843
|
-
}
|
|
336844
|
-
function normalizeLegacyNoteMap2(map10) {
|
|
336845
|
-
return Object.entries(map10).map(([id2, value]) => ({
|
|
336846
|
-
id: String(id2),
|
|
336847
|
-
content: textToFootnoteContentNodes2(value?.content ?? "")
|
|
336848
|
-
}));
|
|
336849
|
-
}
|
|
336850
|
-
function ensureNoteEntries2(converter, kind) {
|
|
336851
|
-
const current = converter[kind];
|
|
336852
|
-
if (Array.isArray(current))
|
|
336853
|
-
return current;
|
|
336854
|
-
if (isLegacyNoteMap2(current)) {
|
|
336855
|
-
const normalized = normalizeLegacyNoteMap2(current);
|
|
336856
|
-
converter[kind] = normalized;
|
|
336857
|
-
return normalized;
|
|
337481
|
+
function getConverter15(editor) {
|
|
337482
|
+
const converter = editor.converter;
|
|
337483
|
+
if (!converter) {
|
|
337484
|
+
throw new DocumentApiAdapterError3("CAPABILITY_UNAVAILABLE", "converter not available.");
|
|
336858
337485
|
}
|
|
336859
|
-
|
|
336860
|
-
converter[kind] = initialized;
|
|
336861
|
-
return initialized;
|
|
337486
|
+
return converter;
|
|
336862
337487
|
}
|
|
336863
337488
|
function toNonNegativeInteger2(value) {
|
|
336864
337489
|
const num = Number(value);
|
|
@@ -336866,35 +337491,38 @@ function toNonNegativeInteger2(value) {
|
|
|
336866
337491
|
return null;
|
|
336867
337492
|
return num;
|
|
336868
337493
|
}
|
|
336869
|
-
function
|
|
336870
|
-
|
|
337494
|
+
function collectUsedNoteIds2(editor, converter, type) {
|
|
337495
|
+
const used = new Set;
|
|
337496
|
+
const config41 = getNotesConfig2(type);
|
|
336871
337497
|
for (const ref4 of findAllFootnotes2(editor.state.doc, type)) {
|
|
336872
337498
|
const parsed = toNonNegativeInteger2(ref4.noteId);
|
|
336873
337499
|
if (parsed != null)
|
|
336874
|
-
|
|
337500
|
+
used.add(parsed);
|
|
336875
337501
|
}
|
|
336876
|
-
|
|
336877
|
-
|
|
336878
|
-
|
|
336879
|
-
|
|
337502
|
+
const ooxmlPart = converter.convertedXml?.[config41.partId];
|
|
337503
|
+
if (ooxmlPart) {
|
|
337504
|
+
for (const el of getNoteElements2(ooxmlPart, config41.childElementName)) {
|
|
337505
|
+
const parsed = toNonNegativeInteger2(el.attributes?.["w:id"]);
|
|
337506
|
+
if (parsed != null)
|
|
337507
|
+
used.add(parsed);
|
|
337508
|
+
}
|
|
336880
337509
|
}
|
|
336881
|
-
|
|
336882
|
-
|
|
336883
|
-
|
|
336884
|
-
|
|
336885
|
-
|
|
336886
|
-
|
|
336887
|
-
|
|
337510
|
+
const cache2 = converter[config41.converterKey];
|
|
337511
|
+
if (Array.isArray(cache2)) {
|
|
337512
|
+
for (const entry of cache2) {
|
|
337513
|
+
const parsed = toNonNegativeInteger2(entry.id);
|
|
337514
|
+
if (parsed != null)
|
|
337515
|
+
used.add(parsed);
|
|
337516
|
+
}
|
|
336888
337517
|
}
|
|
336889
|
-
|
|
336890
|
-
id: noteId,
|
|
336891
|
-
content: textToFootnoteContentNodes2(content5)
|
|
336892
|
-
});
|
|
337518
|
+
return used;
|
|
336893
337519
|
}
|
|
336894
|
-
function
|
|
336895
|
-
const
|
|
336896
|
-
|
|
336897
|
-
|
|
337520
|
+
function allocateNextNoteId2(editor, converter, type) {
|
|
337521
|
+
const used = collectUsedNoteIds2(editor, converter, type);
|
|
337522
|
+
let candidate = 1;
|
|
337523
|
+
while (used.has(candidate))
|
|
337524
|
+
candidate += 1;
|
|
337525
|
+
return String(candidate);
|
|
336898
337526
|
}
|
|
336899
337527
|
function footnotesListWrapper2(editor, query2) {
|
|
336900
337528
|
const doc4 = editor.state.doc;
|
|
@@ -336916,13 +337544,10 @@ function footnotesGetWrapper2(editor, input2) {
|
|
|
336916
337544
|
}
|
|
336917
337545
|
function footnotesInsertWrapper2(editor, input2, options) {
|
|
336918
337546
|
rejectTrackedMode2("footnotes.insert", options);
|
|
336919
|
-
|
|
336920
|
-
|
|
336921
|
-
|
|
336922
|
-
|
|
336923
|
-
const noteStoreKey = input2.type === "endnote" ? "endnotes" : "footnotes";
|
|
336924
|
-
const noteEntries = ensureNoteEntries2(converter, noteStoreKey);
|
|
336925
|
-
const noteId = allocateNextNoteId2(editor, input2.type, noteEntries);
|
|
337547
|
+
checkRevision2(editor, options?.expectedRevision);
|
|
337548
|
+
const converter = getConverter15(editor);
|
|
337549
|
+
const notesConfig = getNotesConfig2(input2.type);
|
|
337550
|
+
const noteId = allocateNextNoteId2(editor, converter, input2.type);
|
|
336926
337551
|
const address2 = { kind: "entity", entityType: "footnote", noteId };
|
|
336927
337552
|
if (options?.dryRun) {
|
|
336928
337553
|
return footnoteSuccess2(address2);
|
|
@@ -336933,16 +337558,30 @@ function footnotesInsertWrapper2(editor, input2, options) {
|
|
|
336933
337558
|
throw new DocumentApiAdapterError3("CAPABILITY_UNAVAILABLE", `footnotes.insert: node type "${nodeTypeName}" is not registered in the schema.`);
|
|
336934
337559
|
}
|
|
336935
337560
|
const resolved = resolveInlineInsertPosition2(editor, input2.at, "footnotes.insert");
|
|
336936
|
-
const
|
|
336937
|
-
|
|
336938
|
-
|
|
336939
|
-
|
|
336940
|
-
|
|
336941
|
-
|
|
336942
|
-
|
|
336943
|
-
|
|
336944
|
-
|
|
336945
|
-
|
|
337561
|
+
const { success } = compoundMutation2({
|
|
337562
|
+
editor,
|
|
337563
|
+
source: `footnotes.insert:${input2.type}`,
|
|
337564
|
+
affectedParts: [notesConfig.partId],
|
|
337565
|
+
execute: () => {
|
|
337566
|
+
bootstrapNotesPart2(editor, input2.type);
|
|
337567
|
+
mutatePart2({
|
|
337568
|
+
editor,
|
|
337569
|
+
partId: notesConfig.partId,
|
|
337570
|
+
operation: "mutate",
|
|
337571
|
+
source: `footnotes.insert:${input2.type}`,
|
|
337572
|
+
mutate({ part }) {
|
|
337573
|
+
addNoteElement2(part, notesConfig, noteId, input2.content);
|
|
337574
|
+
}
|
|
337575
|
+
});
|
|
337576
|
+
const node4 = nodeType.create({ id: noteId });
|
|
337577
|
+
const { tr } = editor.state;
|
|
337578
|
+
tr.insert(resolved.from, node4);
|
|
337579
|
+
editor.dispatch(tr);
|
|
337580
|
+
clearIndexCache2(editor);
|
|
337581
|
+
return true;
|
|
337582
|
+
}
|
|
337583
|
+
});
|
|
337584
|
+
if (!success) {
|
|
336946
337585
|
return footnoteFailure2("NO_OP", "Insert operation produced no change.");
|
|
336947
337586
|
}
|
|
336948
337587
|
return footnoteSuccess2(address2);
|
|
@@ -336951,100 +337590,140 @@ function footnotesUpdateWrapper2(editor, input2, options) {
|
|
|
336951
337590
|
rejectTrackedMode2("footnotes.update", options);
|
|
336952
337591
|
const resolved = resolveFootnoteTarget2(editor.state.doc, input2.target);
|
|
336953
337592
|
const address2 = { kind: "entity", entityType: "footnote", noteId: resolved.noteId };
|
|
336954
|
-
if (options?.dryRun) {
|
|
337593
|
+
if (options?.dryRun || input2.patch.content === undefined) {
|
|
336955
337594
|
return footnoteSuccess2(address2);
|
|
336956
337595
|
}
|
|
336957
|
-
const
|
|
336958
|
-
|
|
336959
|
-
|
|
336960
|
-
|
|
336961
|
-
|
|
336962
|
-
|
|
336963
|
-
|
|
336964
|
-
|
|
336965
|
-
|
|
336966
|
-
}
|
|
336967
|
-
if (!dryRun) {
|
|
336968
|
-
upsertNoteEntry2(noteEntries, resolved.noteId, input2.patch.content);
|
|
337596
|
+
const notesConfig = getNotesConfig2(resolved.type);
|
|
337597
|
+
mutatePart2({
|
|
337598
|
+
editor,
|
|
337599
|
+
partId: notesConfig.partId,
|
|
337600
|
+
operation: "mutate",
|
|
337601
|
+
source: `footnotes.update:${resolved.type}`,
|
|
337602
|
+
expectedRevision: options?.expectedRevision,
|
|
337603
|
+
mutate({ part }) {
|
|
337604
|
+
updateNoteElement2(part, notesConfig, resolved.noteId, input2.patch.content);
|
|
336969
337605
|
}
|
|
336970
|
-
|
|
336971
|
-
}, { dryRun: options?.dryRun ?? false, expectedRevision: options?.expectedRevision });
|
|
337606
|
+
});
|
|
336972
337607
|
return footnoteSuccess2(address2);
|
|
336973
337608
|
}
|
|
336974
337609
|
function footnotesRemoveWrapper2(editor, input2, options) {
|
|
336975
337610
|
rejectTrackedMode2("footnotes.remove", options);
|
|
337611
|
+
checkRevision2(editor, options?.expectedRevision);
|
|
336976
337612
|
const resolved = resolveFootnoteTarget2(editor.state.doc, input2.target);
|
|
336977
337613
|
const address2 = { kind: "entity", entityType: "footnote", noteId: resolved.noteId };
|
|
336978
337614
|
if (options?.dryRun) {
|
|
336979
337615
|
return footnoteSuccess2(address2);
|
|
336980
337616
|
}
|
|
336981
|
-
const
|
|
336982
|
-
|
|
336983
|
-
|
|
336984
|
-
|
|
337617
|
+
const notesConfig = getNotesConfig2(resolved.type);
|
|
337618
|
+
const { success } = compoundMutation2({
|
|
337619
|
+
editor,
|
|
337620
|
+
source: `footnotes.remove:${resolved.type}`,
|
|
337621
|
+
affectedParts: [notesConfig.partId],
|
|
337622
|
+
execute: () => {
|
|
337623
|
+
const { tr } = editor.state;
|
|
337624
|
+
const node4 = tr.doc.nodeAt(resolved.pos);
|
|
337625
|
+
if (!node4)
|
|
337626
|
+
return false;
|
|
336985
337627
|
tr.delete(resolved.pos, resolved.pos + node4.nodeSize);
|
|
336986
337628
|
editor.dispatch(tr);
|
|
336987
|
-
const
|
|
336988
|
-
if (
|
|
336989
|
-
|
|
336990
|
-
|
|
336991
|
-
|
|
336992
|
-
|
|
336993
|
-
|
|
336994
|
-
|
|
337629
|
+
const stillReferenced = findAllFootnotes2(editor.state.doc, resolved.type).some((f2) => f2.noteId === resolved.noteId);
|
|
337630
|
+
if (!stillReferenced) {
|
|
337631
|
+
mutatePart2({
|
|
337632
|
+
editor,
|
|
337633
|
+
partId: notesConfig.partId,
|
|
337634
|
+
operation: "mutate",
|
|
337635
|
+
source: `footnotes.remove:${resolved.type}`,
|
|
337636
|
+
mutate({ part }) {
|
|
337637
|
+
removeNoteElement2(part, notesConfig, resolved.noteId);
|
|
337638
|
+
}
|
|
337639
|
+
});
|
|
336995
337640
|
}
|
|
336996
337641
|
clearIndexCache2(editor);
|
|
336997
337642
|
return true;
|
|
336998
337643
|
}
|
|
336999
|
-
|
|
337000
|
-
|
|
337001
|
-
if (!receiptApplied6(receipt2)) {
|
|
337644
|
+
});
|
|
337645
|
+
if (!success) {
|
|
337002
337646
|
return footnoteFailure2("NO_OP", "Remove operation produced no change.");
|
|
337003
337647
|
}
|
|
337004
337648
|
return footnoteSuccess2(address2);
|
|
337005
337649
|
}
|
|
337006
337650
|
function footnotesConfigureWrapper2(editor, input2, options) {
|
|
337007
337651
|
rejectTrackedMode2("footnotes.configure", options);
|
|
337008
|
-
const
|
|
337009
|
-
|
|
337010
|
-
|
|
337011
|
-
|
|
337012
|
-
|
|
337013
|
-
|
|
337014
|
-
|
|
337015
|
-
|
|
337016
|
-
|
|
337017
|
-
|
|
337018
|
-
|
|
337019
|
-
|
|
337020
|
-
if (
|
|
337021
|
-
|
|
337022
|
-
|
|
337023
|
-
|
|
337652
|
+
const prElementName = input2.type === "endnote" ? "w:endnotePr" : "w:footnotePr";
|
|
337653
|
+
mutatePart2({
|
|
337654
|
+
editor,
|
|
337655
|
+
partId: "word/settings.xml",
|
|
337656
|
+
operation: "mutate",
|
|
337657
|
+
source: `footnotes.configure:${input2.type}`,
|
|
337658
|
+
dryRun: options?.dryRun,
|
|
337659
|
+
expectedRevision: options?.expectedRevision,
|
|
337660
|
+
mutate({ part }) {
|
|
337661
|
+
const root4 = part?.elements?.[0];
|
|
337662
|
+
if (!root4)
|
|
337663
|
+
return;
|
|
337664
|
+
if (!root4.elements)
|
|
337665
|
+
root4.elements = [];
|
|
337666
|
+
const elements = root4.elements;
|
|
337667
|
+
let prElement = elements.find((el) => el.name === prElementName);
|
|
337668
|
+
if (!prElement) {
|
|
337669
|
+
prElement = { type: "element", name: prElementName, elements: [] };
|
|
337670
|
+
elements.push(prElement);
|
|
337671
|
+
}
|
|
337672
|
+
if (!prElement.elements)
|
|
337673
|
+
prElement.elements = [];
|
|
337674
|
+
if (!input2.numbering)
|
|
337675
|
+
return;
|
|
337676
|
+
const setOrRemoveChild = (name, value) => {
|
|
337677
|
+
if (value === undefined)
|
|
337678
|
+
return;
|
|
337679
|
+
const children = prElement.elements;
|
|
337680
|
+
const existing = children.findIndex((el) => el.name === name);
|
|
337681
|
+
const newEl = { type: "element", name, attributes: { "w:val": value } };
|
|
337682
|
+
if (existing >= 0) {
|
|
337683
|
+
children[existing] = newEl;
|
|
337684
|
+
} else {
|
|
337685
|
+
children.push(newEl);
|
|
337686
|
+
}
|
|
337687
|
+
};
|
|
337688
|
+
setOrRemoveChild("w:numFmt", input2.numbering.format);
|
|
337689
|
+
setOrRemoveChild("w:numStart", input2.numbering.start !== undefined ? String(input2.numbering.start) : undefined);
|
|
337024
337690
|
if (input2.numbering.restartPolicy !== undefined) {
|
|
337025
|
-
|
|
337691
|
+
setOrRemoveChild("w:numRestart", RESTART_POLICY_TO_OOXML2[input2.numbering.restartPolicy] ?? input2.numbering.restartPolicy);
|
|
337026
337692
|
}
|
|
337027
|
-
|
|
337028
|
-
props.pos = input2.numbering.position;
|
|
337693
|
+
setOrRemoveChild("w:pos", input2.numbering.position);
|
|
337029
337694
|
}
|
|
337030
|
-
|
|
337031
|
-
|
|
337032
|
-
|
|
337033
|
-
|
|
337034
|
-
}, { dryRun: options?.dryRun ?? false, expectedRevision: options?.expectedRevision });
|
|
337695
|
+
});
|
|
337696
|
+
if (!options?.dryRun && prElementName === "w:footnotePr") {
|
|
337697
|
+
syncFootnotePropertiesCache2(editor);
|
|
337698
|
+
}
|
|
337035
337699
|
return configSuccess2();
|
|
337036
337700
|
}
|
|
337701
|
+
function syncFootnotePropertiesCache2(editor) {
|
|
337702
|
+
const converter = getConverter15(editor);
|
|
337703
|
+
if (!converter?.footnoteProperties || converter.footnoteProperties.source !== "settings")
|
|
337704
|
+
return;
|
|
337705
|
+
const settingsPart = converter.convertedXml?.["word/settings.xml"];
|
|
337706
|
+
const settingsRoot = settingsPart?.elements?.[0];
|
|
337707
|
+
const elements = settingsRoot?.elements ?? [];
|
|
337708
|
+
const prElement = elements.find((el) => el.name === "w:footnotePr");
|
|
337709
|
+
if (prElement) {
|
|
337710
|
+
converter.footnoteProperties.originalXml = structuredClone(prElement);
|
|
337711
|
+
} else {
|
|
337712
|
+
converter.footnoteProperties = null;
|
|
337713
|
+
}
|
|
337714
|
+
}
|
|
337037
337715
|
var RESTART_POLICY_TO_OOXML2;
|
|
337038
337716
|
var init_footnote_wrappers = __esm(() => {
|
|
337039
337717
|
init_src();
|
|
337040
337718
|
init_footnote_resolver();
|
|
337041
337719
|
init_adapter_utils();
|
|
337042
337720
|
init_revision_tracker();
|
|
337043
|
-
init_plan_wrappers();
|
|
337044
337721
|
init_mutation_helpers();
|
|
337045
337722
|
init_index_cache();
|
|
337046
|
-
init_out_of_band_mutation();
|
|
337047
337723
|
init_errors3();
|
|
337724
|
+
init_mutate_part();
|
|
337725
|
+
init_compound_mutation();
|
|
337726
|
+
init_notes_part_descriptor();
|
|
337048
337727
|
RESTART_POLICY_TO_OOXML2 = {
|
|
337049
337728
|
continuous: "continuous",
|
|
337050
337729
|
eachSection: "eachSect",
|
|
@@ -337173,7 +337852,7 @@ function crossRefSuccess2(address2) {
|
|
|
337173
337852
|
function crossRefFailure2(code10, message) {
|
|
337174
337853
|
return { success: false, failure: { code: code10, message } };
|
|
337175
337854
|
}
|
|
337176
|
-
function
|
|
337855
|
+
function receiptApplied6(receipt2) {
|
|
337177
337856
|
return receipt2.steps[0]?.effect === "changed";
|
|
337178
337857
|
}
|
|
337179
337858
|
function crossRefsListWrapper2(editor, query2) {
|
|
@@ -337224,7 +337903,7 @@ function crossRefsInsertWrapper2(editor, input2, options) {
|
|
|
337224
337903
|
clearIndexCache2(editor);
|
|
337225
337904
|
return true;
|
|
337226
337905
|
}, { expectedRevision: options?.expectedRevision });
|
|
337227
|
-
if (!
|
|
337906
|
+
if (!receiptApplied6(receipt2))
|
|
337228
337907
|
return crossRefFailure2("NO_OP", "Insert produced no change.");
|
|
337229
337908
|
return crossRefSuccess2(computeInlineAddress2(editor.state.doc, resolved.from));
|
|
337230
337909
|
}
|
|
@@ -337249,7 +337928,7 @@ function crossRefsRemoveWrapper2(editor, input2, options) {
|
|
|
337249
337928
|
clearIndexCache2(editor);
|
|
337250
337929
|
return true;
|
|
337251
337930
|
}, { expectedRevision: options?.expectedRevision });
|
|
337252
|
-
if (!
|
|
337931
|
+
if (!receiptApplied6(receipt2))
|
|
337253
337932
|
return crossRefFailure2("NO_OP", "Remove produced no change.");
|
|
337254
337933
|
return crossRefSuccess2(address2);
|
|
337255
337934
|
}
|
|
@@ -337538,7 +338217,7 @@ function entrySuccess3(address2) {
|
|
|
337538
338217
|
function entryFailure3(code10, message) {
|
|
337539
338218
|
return { success: false, failure: { code: code10, message } };
|
|
337540
338219
|
}
|
|
337541
|
-
function
|
|
338220
|
+
function receiptApplied7(receipt2) {
|
|
337542
338221
|
return receipt2.steps[0]?.effect === "changed";
|
|
337543
338222
|
}
|
|
337544
338223
|
function indexListWrapper2(editor, query2) {
|
|
@@ -337579,7 +338258,7 @@ function indexInsertWrapper2(editor, input2, options) {
|
|
|
337579
338258
|
clearIndexCache2(editor);
|
|
337580
338259
|
return true;
|
|
337581
338260
|
}, { expectedRevision: options?.expectedRevision });
|
|
337582
|
-
if (!
|
|
338261
|
+
if (!receiptApplied7(receipt2))
|
|
337583
338262
|
return indexFailure2("NO_OP", "Insert produced no change.");
|
|
337584
338263
|
const insertedNode = editor.state.doc.nodeAt(pos);
|
|
337585
338264
|
const resolvedNodeId = insertedNode?.attrs?.sdBlockId ?? `index-${pos}`;
|
|
@@ -337611,7 +338290,7 @@ function indexConfigureWrapper2(editor, input2, options) {
|
|
|
337611
338290
|
clearIndexCache2(editor);
|
|
337612
338291
|
return true;
|
|
337613
338292
|
}, { expectedRevision: options?.expectedRevision });
|
|
337614
|
-
if (!
|
|
338293
|
+
if (!receiptApplied7(receipt2))
|
|
337615
338294
|
return indexFailure2("NO_OP", "Configure produced no change.");
|
|
337616
338295
|
return indexSuccess2(address2);
|
|
337617
338296
|
}
|
|
@@ -337636,7 +338315,7 @@ function indexRemoveWrapper2(editor, input2, options) {
|
|
|
337636
338315
|
clearIndexCache2(editor);
|
|
337637
338316
|
return true;
|
|
337638
338317
|
}, { expectedRevision: options?.expectedRevision });
|
|
337639
|
-
if (!
|
|
338318
|
+
if (!receiptApplied7(receipt2))
|
|
337640
338319
|
return indexFailure2("NO_OP", "Remove produced no change.");
|
|
337641
338320
|
return indexSuccess2(address2);
|
|
337642
338321
|
}
|
|
@@ -337691,7 +338370,7 @@ function indexEntriesInsertWrapper2(editor, input2, options) {
|
|
|
337691
338370
|
clearIndexCache2(editor);
|
|
337692
338371
|
return true;
|
|
337693
338372
|
}, { expectedRevision: options?.expectedRevision });
|
|
337694
|
-
if (!
|
|
338373
|
+
if (!receiptApplied7(receipt2))
|
|
337695
338374
|
return entryFailure3("NO_OP", "Insert produced no change.");
|
|
337696
338375
|
const insertedAddress = resolveInsertedIndexEntryAddress2(editor.state.doc, resolved.from, instruction);
|
|
337697
338376
|
return entrySuccess3(insertedAddress);
|
|
@@ -337728,7 +338407,7 @@ function indexEntriesUpdateWrapper2(editor, input2, options) {
|
|
|
337728
338407
|
clearIndexCache2(editor);
|
|
337729
338408
|
return true;
|
|
337730
338409
|
}, { expectedRevision: options?.expectedRevision });
|
|
337731
|
-
if (!
|
|
338410
|
+
if (!receiptApplied7(receipt2))
|
|
337732
338411
|
return entryFailure3("NO_OP", "Update produced no change.");
|
|
337733
338412
|
return entrySuccess3(address2);
|
|
337734
338413
|
}
|
|
@@ -337745,7 +338424,7 @@ function indexEntriesRemoveWrapper2(editor, input2, options) {
|
|
|
337745
338424
|
clearIndexCache2(editor);
|
|
337746
338425
|
return true;
|
|
337747
338426
|
}, { expectedRevision: options?.expectedRevision });
|
|
337748
|
-
if (!
|
|
338427
|
+
if (!receiptApplied7(receipt2))
|
|
337749
338428
|
return entryFailure3("NO_OP", "Remove produced no change.");
|
|
337750
338429
|
return entrySuccess3(address2);
|
|
337751
338430
|
}
|
|
@@ -338021,7 +338700,7 @@ function configSuccess3() {
|
|
|
338021
338700
|
function configFailure2(code10, message) {
|
|
338022
338701
|
return { success: false, failure: { code: code10, message } };
|
|
338023
338702
|
}
|
|
338024
|
-
function
|
|
338703
|
+
function receiptApplied8(receipt2) {
|
|
338025
338704
|
return receipt2.steps[0]?.effect === "changed";
|
|
338026
338705
|
}
|
|
338027
338706
|
function buildCaptionParagraphAttrs2(nodeId) {
|
|
@@ -338080,7 +338759,7 @@ function captionsInsertWrapper2(editor, input2, options) {
|
|
|
338080
338759
|
clearIndexCache2(editor);
|
|
338081
338760
|
return true;
|
|
338082
338761
|
}, { expectedRevision: options?.expectedRevision });
|
|
338083
|
-
if (!
|
|
338762
|
+
if (!receiptApplied8(receipt2))
|
|
338084
338763
|
return captionFailure2("NO_OP", "Insert produced no change.");
|
|
338085
338764
|
return captionSuccess2(address2);
|
|
338086
338765
|
}
|
|
@@ -338115,7 +338794,7 @@ function captionsUpdateWrapper2(editor, input2, options) {
|
|
|
338115
338794
|
clearIndexCache2(editor);
|
|
338116
338795
|
return true;
|
|
338117
338796
|
}, { expectedRevision: options?.expectedRevision });
|
|
338118
|
-
if (!
|
|
338797
|
+
if (!receiptApplied8(receipt2))
|
|
338119
338798
|
return captionFailure2("NO_OP", "Update produced no change.");
|
|
338120
338799
|
return captionSuccess2(address2);
|
|
338121
338800
|
}
|
|
@@ -338132,7 +338811,7 @@ function captionsRemoveWrapper2(editor, input2, options) {
|
|
|
338132
338811
|
clearIndexCache2(editor);
|
|
338133
338812
|
return true;
|
|
338134
338813
|
}, { expectedRevision: options?.expectedRevision });
|
|
338135
|
-
if (!
|
|
338814
|
+
if (!receiptApplied8(receipt2))
|
|
338136
338815
|
return captionFailure2("NO_OP", "Remove produced no change.");
|
|
338137
338816
|
return captionSuccess2(address2);
|
|
338138
338817
|
}
|
|
@@ -338164,7 +338843,7 @@ function captionsConfigureWrapper2(editor, input2, options) {
|
|
|
338164
338843
|
clearIndexCache2(editor);
|
|
338165
338844
|
return true;
|
|
338166
338845
|
}, { expectedRevision: options?.expectedRevision });
|
|
338167
|
-
if (!
|
|
338846
|
+
if (!receiptApplied8(receipt2))
|
|
338168
338847
|
return configFailure2("NO_OP", "Configure produced no change.");
|
|
338169
338848
|
return configSuccess3();
|
|
338170
338849
|
}
|
|
@@ -338296,7 +338975,7 @@ function fieldSuccess2(address2) {
|
|
|
338296
338975
|
function fieldFailure2(code10, message) {
|
|
338297
338976
|
return { success: false, failure: { code: code10, message } };
|
|
338298
338977
|
}
|
|
338299
|
-
function
|
|
338978
|
+
function receiptApplied9(receipt2) {
|
|
338300
338979
|
return receipt2.steps[0]?.effect === "changed";
|
|
338301
338980
|
}
|
|
338302
338981
|
function fieldsListWrapper2(editor, query2) {
|
|
@@ -338350,7 +339029,7 @@ function fieldsInsertWrapper2(editor, input2, options) {
|
|
|
338350
339029
|
clearIndexCache2(editor);
|
|
338351
339030
|
return true;
|
|
338352
339031
|
}, { expectedRevision: options?.expectedRevision });
|
|
338353
|
-
if (!
|
|
339032
|
+
if (!receiptApplied9(receipt2))
|
|
338354
339033
|
return fieldFailure2("NO_OP", "Insert produced no change.");
|
|
338355
339034
|
return fieldSuccess2(computeFieldAddress2(editor.state.doc, resolved.from));
|
|
338356
339035
|
}
|
|
@@ -338378,7 +339057,7 @@ function fieldsRebuildWrapper2(editor, input2, options) {
|
|
|
338378
339057
|
clearIndexCache2(editor);
|
|
338379
339058
|
return true;
|
|
338380
339059
|
}, { expectedRevision: options?.expectedRevision });
|
|
338381
|
-
if (!
|
|
339060
|
+
if (!receiptApplied9(receipt2))
|
|
338382
339061
|
return fieldFailure2("NO_OP", "Rebuild produced no change.");
|
|
338383
339062
|
return fieldSuccess2(address2);
|
|
338384
339063
|
}
|
|
@@ -338406,7 +339085,7 @@ function fieldsRemoveWrapper2(editor, input2, options) {
|
|
|
338406
339085
|
clearIndexCache2(editor);
|
|
338407
339086
|
return true;
|
|
338408
339087
|
}, { expectedRevision: options?.expectedRevision });
|
|
338409
|
-
if (!
|
|
339088
|
+
if (!receiptApplied9(receipt2))
|
|
338410
339089
|
return fieldFailure2("NO_OP", "Remove produced no change.");
|
|
338411
339090
|
return fieldSuccess2(address2);
|
|
338412
339091
|
}
|
|
@@ -338581,6 +339260,39 @@ var init_citation_resolver = __esm(() => {
|
|
|
338581
339260
|
init_errors3();
|
|
338582
339261
|
});
|
|
338583
339262
|
|
|
339263
|
+
// ../../packages/super-editor/src/document-api-adapters/out-of-band-mutation.ts
|
|
339264
|
+
function executeOutOfBandMutation2(editor, mutateFn, options) {
|
|
339265
|
+
if (!options.dryRun) {
|
|
339266
|
+
if (editor.options?.collaborationProvider && editor.options?.ydoc) {
|
|
339267
|
+
try {
|
|
339268
|
+
yUndoPluginKey2.getState(editor.state)?.undoManager?.stopCapturing();
|
|
339269
|
+
} catch {}
|
|
339270
|
+
} else {
|
|
339271
|
+
try {
|
|
339272
|
+
editor.view?.dispatch?.(closeHistory2(editor.state.tr));
|
|
339273
|
+
} catch {}
|
|
339274
|
+
}
|
|
339275
|
+
}
|
|
339276
|
+
checkRevision2(editor, options.expectedRevision);
|
|
339277
|
+
const result = mutateFn(options.dryRun);
|
|
339278
|
+
if (result.changed && !options.dryRun) {
|
|
339279
|
+
const converter = editor.converter;
|
|
339280
|
+
if (converter) {
|
|
339281
|
+
converter.documentModified = true;
|
|
339282
|
+
if (!converter.documentGuid && typeof converter.promoteToGuid === "function") {
|
|
339283
|
+
converter.promoteToGuid();
|
|
339284
|
+
}
|
|
339285
|
+
}
|
|
339286
|
+
incrementRevision2(editor);
|
|
339287
|
+
}
|
|
339288
|
+
return result.payload;
|
|
339289
|
+
}
|
|
339290
|
+
var init_out_of_band_mutation = __esm(() => {
|
|
339291
|
+
init_dist7();
|
|
339292
|
+
init_y_prosemirror();
|
|
339293
|
+
init_revision_tracker();
|
|
339294
|
+
});
|
|
339295
|
+
|
|
338584
339296
|
// ../../packages/super-editor/src/document-api-adapters/plan-engine/citation-wrappers.ts
|
|
338585
339297
|
function citationSuccess2(address2) {
|
|
338586
339298
|
return { success: true, citation: address2 };
|
|
@@ -338600,7 +339312,7 @@ function bibSuccess2(address2) {
|
|
|
338600
339312
|
function bibFailure2(code10, message) {
|
|
338601
339313
|
return { success: false, failure: { code: code10, message } };
|
|
338602
339314
|
}
|
|
338603
|
-
function
|
|
339315
|
+
function receiptApplied10(receipt2) {
|
|
338604
339316
|
return receipt2.steps[0]?.effect === "changed";
|
|
338605
339317
|
}
|
|
338606
339318
|
function citationsListWrapper2(editor, query2) {
|
|
@@ -338648,7 +339360,7 @@ function citationsInsertWrapper2(editor, input2, options) {
|
|
|
338648
339360
|
clearIndexCache2(editor);
|
|
338649
339361
|
return true;
|
|
338650
339362
|
}, { expectedRevision: options?.expectedRevision });
|
|
338651
|
-
if (!
|
|
339363
|
+
if (!receiptApplied10(receipt2))
|
|
338652
339364
|
return citationFailure2("NO_OP", "Insert produced no change.");
|
|
338653
339365
|
const insertedAddress = resolveInsertedCitationAddress2(editor.state.doc, resolved.from, input2.sourceIds);
|
|
338654
339366
|
return citationSuccess2(insertedAddress);
|
|
@@ -338672,7 +339384,7 @@ function citationsUpdateWrapper2(editor, input2, options) {
|
|
|
338672
339384
|
clearIndexCache2(editor);
|
|
338673
339385
|
return true;
|
|
338674
339386
|
}, { expectedRevision: options?.expectedRevision });
|
|
338675
|
-
if (!
|
|
339387
|
+
if (!receiptApplied10(receipt2))
|
|
338676
339388
|
return citationFailure2("NO_OP", "Update produced no change.");
|
|
338677
339389
|
return citationSuccess2(address2);
|
|
338678
339390
|
}
|
|
@@ -338689,7 +339401,7 @@ function citationsRemoveWrapper2(editor, input2, options) {
|
|
|
338689
339401
|
clearIndexCache2(editor);
|
|
338690
339402
|
return true;
|
|
338691
339403
|
}, { expectedRevision: options?.expectedRevision });
|
|
338692
|
-
if (!
|
|
339404
|
+
if (!receiptApplied10(receipt2))
|
|
338693
339405
|
return citationFailure2("NO_OP", "Remove produced no change.");
|
|
338694
339406
|
return citationSuccess2(address2);
|
|
338695
339407
|
}
|
|
@@ -338798,7 +339510,7 @@ function bibliographyInsertWrapper2(editor, input2, options) {
|
|
|
338798
339510
|
clearIndexCache2(editor);
|
|
338799
339511
|
return true;
|
|
338800
339512
|
}, { expectedRevision: options?.expectedRevision });
|
|
338801
|
-
if (!
|
|
339513
|
+
if (!receiptApplied10(receipt2))
|
|
338802
339514
|
return bibFailure2("NO_OP", "Insert produced no change.");
|
|
338803
339515
|
return bibSuccess2(address2);
|
|
338804
339516
|
}
|
|
@@ -338830,7 +339542,7 @@ function bibliographyConfigureWrapper2(editor, input2, options) {
|
|
|
338830
339542
|
clearIndexCache2(editor);
|
|
338831
339543
|
return true;
|
|
338832
339544
|
}, { expectedRevision: options?.expectedRevision });
|
|
338833
|
-
if (!
|
|
339545
|
+
if (!receiptApplied10(receipt2))
|
|
338834
339546
|
return bibFailure2("NO_OP", "Configure produced no change.");
|
|
338835
339547
|
return bibSuccess2(address2);
|
|
338836
339548
|
}
|
|
@@ -338855,7 +339567,7 @@ function bibliographyRemoveWrapper2(editor, input2, options) {
|
|
|
338855
339567
|
clearIndexCache2(editor);
|
|
338856
339568
|
return true;
|
|
338857
339569
|
}, { expectedRevision: options?.expectedRevision });
|
|
338858
|
-
if (!
|
|
339570
|
+
if (!receiptApplied10(receipt2))
|
|
338859
339571
|
return bibFailure2("NO_OP", "Remove produced no change.");
|
|
338860
339572
|
return bibSuccess2(address2);
|
|
338861
339573
|
}
|
|
@@ -339118,7 +339830,7 @@ function entrySuccess4(address2) {
|
|
|
339118
339830
|
function entryFailure4(code10, message) {
|
|
339119
339831
|
return { success: false, failure: { code: code10, message } };
|
|
339120
339832
|
}
|
|
339121
|
-
function
|
|
339833
|
+
function receiptApplied11(receipt2) {
|
|
339122
339834
|
return receipt2.steps[0]?.effect === "changed";
|
|
339123
339835
|
}
|
|
339124
339836
|
function authoritiesListWrapper2(editor, query2) {
|
|
@@ -339166,7 +339878,7 @@ function authoritiesInsertWrapper2(editor, input2, options) {
|
|
|
339166
339878
|
clearIndexCache2(editor);
|
|
339167
339879
|
return true;
|
|
339168
339880
|
}, { expectedRevision: options?.expectedRevision });
|
|
339169
|
-
if (!
|
|
339881
|
+
if (!receiptApplied11(receipt2))
|
|
339170
339882
|
return toaFailure2("NO_OP", "Insert produced no change.");
|
|
339171
339883
|
const insertedNode = editor.state.doc.nodeAt(pos);
|
|
339172
339884
|
const resolvedNodeId = insertedNode?.attrs?.sdBlockId ?? `toa-${pos}`;
|
|
@@ -339202,7 +339914,7 @@ function authoritiesConfigureWrapper2(editor, input2, options) {
|
|
|
339202
339914
|
clearIndexCache2(editor);
|
|
339203
339915
|
return true;
|
|
339204
339916
|
}, { expectedRevision: options?.expectedRevision });
|
|
339205
|
-
if (!
|
|
339917
|
+
if (!receiptApplied11(receipt2))
|
|
339206
339918
|
return toaFailure2("NO_OP", "Configure produced no change.");
|
|
339207
339919
|
return toaSuccess2(address2);
|
|
339208
339920
|
}
|
|
@@ -339227,7 +339939,7 @@ function authoritiesRemoveWrapper2(editor, input2, options) {
|
|
|
339227
339939
|
clearIndexCache2(editor);
|
|
339228
339940
|
return true;
|
|
339229
339941
|
}, { expectedRevision: options?.expectedRevision });
|
|
339230
|
-
if (!
|
|
339942
|
+
if (!receiptApplied11(receipt2))
|
|
339231
339943
|
return toaFailure2("NO_OP", "Remove produced no change.");
|
|
339232
339944
|
return toaSuccess2(address2);
|
|
339233
339945
|
}
|
|
@@ -339279,7 +339991,7 @@ function authorityEntriesInsertWrapper2(editor, input2, options) {
|
|
|
339279
339991
|
clearIndexCache2(editor);
|
|
339280
339992
|
return true;
|
|
339281
339993
|
}, { expectedRevision: options?.expectedRevision });
|
|
339282
|
-
if (!
|
|
339994
|
+
if (!receiptApplied11(receipt2))
|
|
339283
339995
|
return entryFailure4("NO_OP", "Insert produced no change.");
|
|
339284
339996
|
return entrySuccess4(computeInlineEntryAddress3(editor.state.doc, resolved.from));
|
|
339285
339997
|
}
|
|
@@ -339308,7 +340020,7 @@ function authorityEntriesUpdateWrapper2(editor, input2, options) {
|
|
|
339308
340020
|
clearIndexCache2(editor);
|
|
339309
340021
|
return true;
|
|
339310
340022
|
}, { expectedRevision: options?.expectedRevision });
|
|
339311
|
-
if (!
|
|
340023
|
+
if (!receiptApplied11(receipt2))
|
|
339312
340024
|
return entryFailure4("NO_OP", "Update produced no change.");
|
|
339313
340025
|
return entrySuccess4(address2);
|
|
339314
340026
|
}
|
|
@@ -339325,7 +340037,7 @@ function authorityEntriesRemoveWrapper2(editor, input2, options) {
|
|
|
339325
340037
|
clearIndexCache2(editor);
|
|
339326
340038
|
return true;
|
|
339327
340039
|
}, { expectedRevision: options?.expectedRevision });
|
|
339328
|
-
if (!
|
|
340040
|
+
if (!receiptApplied11(receipt2))
|
|
339329
340041
|
return entryFailure4("NO_OP", "Remove produced no change.");
|
|
339330
340042
|
return entrySuccess4(address2);
|
|
339331
340043
|
}
|