@harbour-enterprises/superdoc 0.12.14 → 0.12.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{super-editor.es-BOH6x5Dh.es.js → super-editor.es-BB3W_xzz.es.js} +144 -54
- package/dist/chunks/{super-editor.es-DF_gWgh-.cjs → super-editor.es-C1sOUR_S.cjs} +144 -54
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-D3CdG5M7.js → converter-CaX3dOo9.js} +78 -12
- package/dist/super-editor/chunks/{docx-zipper-DBFk7dLq.js → docx-zipper-C21KiTVk.js} +10 -1
- package/dist/super-editor/chunks/{editor-CdSN8S-8.js → editor-Ctzz2gCC.js} +59 -44
- package/dist/super-editor/chunks/{toolbar-C2Qr2ADq.js → toolbar-C0EZHJoI.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/core/DocxZipper.d.ts.map +1 -1
- package/dist/super-editor/core/super-converter/SuperConverter.d.ts.map +1 -1
- package/dist/super-editor/core/super-converter/constants.d.ts +2 -0
- package/dist/super-editor/core/super-converter/constants.d.ts.map +1 -1
- package/dist/super-editor/core/super-converter/exporter.d.ts.map +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/extensions/pagination/pagination-helpers.d.ts.map +1 -1
- package/dist/super-editor/extensions/pagination/pagination.d.ts.map +1 -1
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +3 -3
- package/dist/superdoc.umd.js +145 -55
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -18872,8 +18872,20 @@ function exportSchemaToJson(params2) {
|
|
|
18872
18872
|
return router[type2](params2);
|
|
18873
18873
|
}
|
|
18874
18874
|
function translateBodyNode(params2) {
|
|
18875
|
-
|
|
18875
|
+
let sectPr = params2.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
|
|
18876
18876
|
if (params2.converter) {
|
|
18877
|
+
const hasHeader = sectPr.elements.some((n) => n.name === "w:headerReference");
|
|
18878
|
+
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
18879
|
+
if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
|
|
18880
|
+
const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
|
|
18881
|
+
sectPr.elements.push(defaultHeader);
|
|
18882
|
+
}
|
|
18883
|
+
const hasFooter = sectPr.elements.some((n) => n.name === "w:footerReference");
|
|
18884
|
+
const hasDefaultFooter = params2.converter.footerIds?.default;
|
|
18885
|
+
if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
|
|
18886
|
+
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
18887
|
+
sectPr.elements.push(defaultFooter);
|
|
18888
|
+
}
|
|
18877
18889
|
const newMargins = params2.converter.pageStyles.pageMargins;
|
|
18878
18890
|
const sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
|
|
18879
18891
|
const { attributes } = sectPrMargins;
|
|
@@ -18895,6 +18907,16 @@ function translateBodyNode(params2) {
|
|
|
18895
18907
|
elements: [...elements, sectPr]
|
|
18896
18908
|
};
|
|
18897
18909
|
}
|
|
18910
|
+
const generateDefaultHeaderFooter = (type2, id) => {
|
|
18911
|
+
return {
|
|
18912
|
+
"type": "element",
|
|
18913
|
+
"name": `w:${type2}Reference`,
|
|
18914
|
+
"attributes": {
|
|
18915
|
+
"w:type": "default",
|
|
18916
|
+
"r:id": id
|
|
18917
|
+
}
|
|
18918
|
+
};
|
|
18919
|
+
};
|
|
18898
18920
|
function translateParagraphNode(params2) {
|
|
18899
18921
|
const elements = translateChildNodes(params2);
|
|
18900
18922
|
const htmlAnnotationChild = elements.find((element) => element.name === "htmlAnnotation");
|
|
@@ -23193,6 +23215,7 @@ const isAlternatingHeadersOddEven = (docx) => {
|
|
|
23193
23215
|
return !!evenOdd;
|
|
23194
23216
|
};
|
|
23195
23217
|
const HYPERLINK_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
|
|
23218
|
+
const HEADER_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
|
|
23196
23219
|
const _SuperConverter = class _SuperConverter2 {
|
|
23197
23220
|
constructor(params2 = null) {
|
|
23198
23221
|
__privateAdd$2(this, _SuperConverter_instances);
|
|
@@ -23263,7 +23286,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
23263
23286
|
return;
|
|
23264
23287
|
}
|
|
23265
23288
|
}
|
|
23266
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.
|
|
23289
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.12.16") {
|
|
23267
23290
|
const customLocation = "docProps/custom.xml";
|
|
23268
23291
|
if (!docx[customLocation]) {
|
|
23269
23292
|
docx[customLocation] = generateCustomXml();
|
|
@@ -23451,8 +23474,8 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
23451
23474
|
commentsRels = relationships;
|
|
23452
23475
|
}
|
|
23453
23476
|
this.convertedXml = { ...this.convertedXml, ...updatedXml };
|
|
23454
|
-
__privateMethod$2(this, _SuperConverter_instances,
|
|
23455
|
-
__privateMethod$2(this, _SuperConverter_instances,
|
|
23477
|
+
const headFootRels = __privateMethod$2(this, _SuperConverter_instances, exportProcessHeadersFooters_fn).call(this, { isFinalDoc });
|
|
23478
|
+
__privateMethod$2(this, _SuperConverter_instances, exportProcessNewRelationships_fn).call(this, [...params2.relationships, ...commentsRels, ...headFootRels]);
|
|
23456
23479
|
storeSuperdocVersion(this.convertedXml);
|
|
23457
23480
|
__privateMethod$2(this, _SuperConverter_instances, exportNumberingFile_fn).call(this, params2);
|
|
23458
23481
|
return xml;
|
|
@@ -23512,8 +23535,9 @@ prepareCommentsXmlFilesForExport_fn = function({ defs, exportType, commentsWithP
|
|
|
23512
23535
|
exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
|
|
23513
23536
|
const relsData = this.convertedXml["word/_rels/document.xml.rels"];
|
|
23514
23537
|
const relationships = relsData.elements.find((x) => x.name === "Relationships");
|
|
23515
|
-
|
|
23516
|
-
|
|
23538
|
+
const newDocRels = [];
|
|
23539
|
+
Object.entries(this.headers).forEach(([id, header], index2) => {
|
|
23540
|
+
const fileName = relationships.elements.find((el) => el.attributes.Id === id)?.attributes.Target || `header${index2 + 1}.xml`;
|
|
23517
23541
|
const headerEditor = this.headerEditors.find((item) => item.id === id);
|
|
23518
23542
|
if (!headerEditor) return;
|
|
23519
23543
|
const { result, params: params2 } = this.exportToXmlJson({
|
|
@@ -23527,7 +23551,27 @@ exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
|
|
|
23527
23551
|
});
|
|
23528
23552
|
const bodyContent = result.elements[0].elements;
|
|
23529
23553
|
const file = this.convertedXml[`word/${fileName}`];
|
|
23530
|
-
file
|
|
23554
|
+
if (!file) {
|
|
23555
|
+
this.convertedXml[`word/${fileName}`] = {
|
|
23556
|
+
declaration: this.initialJSON?.declaration,
|
|
23557
|
+
elements: [{
|
|
23558
|
+
attributes: DEFAULT_DOCX_DEFS,
|
|
23559
|
+
name: "w:hdr",
|
|
23560
|
+
type: "element",
|
|
23561
|
+
elements: []
|
|
23562
|
+
}]
|
|
23563
|
+
};
|
|
23564
|
+
newDocRels.push({
|
|
23565
|
+
type: "element",
|
|
23566
|
+
name: "Relationship",
|
|
23567
|
+
attributes: {
|
|
23568
|
+
Id: id,
|
|
23569
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",
|
|
23570
|
+
Target: fileName
|
|
23571
|
+
}
|
|
23572
|
+
});
|
|
23573
|
+
}
|
|
23574
|
+
this.convertedXml[`word/${fileName}`].elements[0].elements = bodyContent;
|
|
23531
23575
|
if (params2.relationships.length) {
|
|
23532
23576
|
const relationships2 = this.convertedXml[`word/_rels/${fileName}.rels`]?.elements?.find((x) => x.name === "Relationships")?.elements || [];
|
|
23533
23577
|
this.convertedXml[`word/_rels/${fileName}.rels`] = {
|
|
@@ -23545,8 +23589,8 @@ exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
|
|
|
23545
23589
|
};
|
|
23546
23590
|
}
|
|
23547
23591
|
});
|
|
23548
|
-
Object.entries(this.footers).forEach(([id, footer]) => {
|
|
23549
|
-
const fileName = relationships.elements.find((el) => el.attributes.Id === id)?.attributes.Target
|
|
23592
|
+
Object.entries(this.footers).forEach(([id, footer], index2) => {
|
|
23593
|
+
const fileName = relationships.elements.find((el) => el.attributes.Id === id)?.attributes.Target || `footer${index2 + 1}.xml`;
|
|
23550
23594
|
const footerEditor = this.footerEditors.find((item) => item.id === id);
|
|
23551
23595
|
if (!footerEditor) return;
|
|
23552
23596
|
const { result, params: params2 } = this.exportToXmlJson({
|
|
@@ -23560,7 +23604,27 @@ exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
|
|
|
23560
23604
|
});
|
|
23561
23605
|
const bodyContent = result.elements[0].elements;
|
|
23562
23606
|
const file = this.convertedXml[`word/${fileName}`];
|
|
23563
|
-
file
|
|
23607
|
+
if (!file) {
|
|
23608
|
+
this.convertedXml[`word/${fileName}`] = {
|
|
23609
|
+
declaration: this.initialJSON?.declaration,
|
|
23610
|
+
elements: [{
|
|
23611
|
+
attributes: DEFAULT_DOCX_DEFS,
|
|
23612
|
+
name: "w:ftr",
|
|
23613
|
+
type: "element",
|
|
23614
|
+
elements: []
|
|
23615
|
+
}]
|
|
23616
|
+
};
|
|
23617
|
+
newDocRels.push({
|
|
23618
|
+
type: "element",
|
|
23619
|
+
name: "Relationship",
|
|
23620
|
+
attributes: {
|
|
23621
|
+
Id: id,
|
|
23622
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",
|
|
23623
|
+
Target: fileName
|
|
23624
|
+
}
|
|
23625
|
+
});
|
|
23626
|
+
}
|
|
23627
|
+
this.convertedXml[`word/${fileName}`].elements[0].elements = bodyContent;
|
|
23564
23628
|
if (params2.relationships.length) {
|
|
23565
23629
|
const relationships2 = this.convertedXml[`word/_rels/${fileName}.rels`]?.elements?.find((x) => x.name === "Relationships")?.elements || [];
|
|
23566
23630
|
this.convertedXml[`word/_rels/${fileName}.rels`] = {
|
|
@@ -23578,6 +23642,7 @@ exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
|
|
|
23578
23642
|
};
|
|
23579
23643
|
}
|
|
23580
23644
|
});
|
|
23645
|
+
return newDocRels;
|
|
23581
23646
|
};
|
|
23582
23647
|
exportProcessNewRelationships_fn = function(rels = []) {
|
|
23583
23648
|
const relsData = this.convertedXml["word/_rels/document.xml.rels"];
|
|
@@ -23590,7 +23655,8 @@ exportProcessNewRelationships_fn = function(rels = []) {
|
|
|
23590
23655
|
const existingTarget = relationships.elements.find((el) => el.attributes.Target === rel.attributes.Target);
|
|
23591
23656
|
const isNewMedia = rel.attributes.Target?.startsWith("media/") && existingId.length > 6;
|
|
23592
23657
|
const isNewHyperlink = rel.attributes.Type === HYPERLINK_RELATIONSHIP_TYPE && existingId.length > 6;
|
|
23593
|
-
|
|
23658
|
+
const isNewHeadFoot = rel.attributes.Type === HEADER_RELATIONSHIP_TYPE && existingId.length > 6;
|
|
23659
|
+
if (existingTarget && !isNewMedia && !isNewHyperlink && !isNewHeadFoot) {
|
|
23594
23660
|
return;
|
|
23595
23661
|
}
|
|
23596
23662
|
rel.attributes.Target = rel.attributes?.Target?.replace(/&/g, "&");
|
|
@@ -23686,7 +23752,7 @@ function storeSuperdocVersion(docx) {
|
|
|
23686
23752
|
function generateCustomXml() {
|
|
23687
23753
|
return DEFAULT_CUSTOM_XML;
|
|
23688
23754
|
}
|
|
23689
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.12.
|
|
23755
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.12.16") {
|
|
23690
23756
|
return {
|
|
23691
23757
|
type: "element",
|
|
23692
23758
|
name: "property",
|
|
@@ -26124,6 +26190,15 @@ class DocxZipper {
|
|
|
26124
26190
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
|
|
26125
26191
|
if (!hasCommentsExtensible) typesString += commentsExtendedDef;
|
|
26126
26192
|
}
|
|
26193
|
+
Object.keys(docx.files).forEach((name) => {
|
|
26194
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
26195
|
+
const hasExtensible = types2.elements?.some((el) => el.name === "Override" && el.attributes.PartName === `/${name}`);
|
|
26196
|
+
const type2 = name.includes("header") ? "header" : "footer";
|
|
26197
|
+
const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type2}+xml"/>`;
|
|
26198
|
+
if (!hasExtensible) {
|
|
26199
|
+
typesString += extendedDef;
|
|
26200
|
+
}
|
|
26201
|
+
});
|
|
26127
26202
|
const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
|
26128
26203
|
const updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
|
|
26129
26204
|
docx.file(contentTypesPath, updatedContentTypesXml);
|
|
@@ -38983,7 +39058,6 @@ const createHeaderFooterEditor = ({
|
|
|
38983
39058
|
const pm = editorContainer.querySelector(".ProseMirror");
|
|
38984
39059
|
pm.style.maxHeight = "100%";
|
|
38985
39060
|
pm.style.minHeight = "100%";
|
|
38986
|
-
pm.style.overflow = "auto";
|
|
38987
39061
|
pm.style.outline = "none";
|
|
38988
39062
|
pm.style.border = "none";
|
|
38989
39063
|
return headerFooterEditor;
|
|
@@ -39048,8 +39122,9 @@ const updateYdocDocxData = async (editor) => {
|
|
|
39048
39122
|
Object.keys(newXml).forEach((key) => {
|
|
39049
39123
|
if (key.includes("header") || key.includes("footer")) {
|
|
39050
39124
|
const fileIndex = docx.findIndex((item) => item.name === key);
|
|
39051
|
-
if (fileIndex
|
|
39052
|
-
|
|
39125
|
+
if (fileIndex > -1) {
|
|
39126
|
+
docx.splice(fileIndex, 1);
|
|
39127
|
+
}
|
|
39053
39128
|
docx.push({
|
|
39054
39129
|
name: key,
|
|
39055
39130
|
content: newXml[key]
|
|
@@ -40831,7 +40906,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
40831
40906
|
* @returns {Object | void} Migration results
|
|
40832
40907
|
*/
|
|
40833
40908
|
processCollaborationMigrations() {
|
|
40834
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.12.
|
|
40909
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.12.16");
|
|
40835
40910
|
if (!this.options.ydoc) return;
|
|
40836
40911
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
40837
40912
|
let docVersion = metaMap.get("version");
|
|
@@ -52546,7 +52621,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
52546
52621
|
currentPageNumber++;
|
|
52547
52622
|
const headerId2 = getHeaderFooterId(currentPageNumber, "headerIds", editor);
|
|
52548
52623
|
header = createHeader(pageMargins, pageSize, sectionData, headerId2, editor);
|
|
52549
|
-
footer = createFooter(pageMargins, pageSize, sectionData, footerId2, editor);
|
|
52624
|
+
footer = createFooter(pageMargins, pageSize, sectionData, footerId2, editor, currentPageNumber - 1);
|
|
52550
52625
|
const bufferHeight2 = pageHeightThreshold - actualBreakBottom;
|
|
52551
52626
|
const { node: spacingNode2 } = createFinalPagePadding(bufferHeight2);
|
|
52552
52627
|
const pageSpacer2 = Decoration.widget(breakPos, spacingNode2, { key: "stable-key" });
|
|
@@ -52561,7 +52636,7 @@ function generateInternalPageBreaks(doc2, view, editor, sectionData) {
|
|
|
52561
52636
|
const headerId = getHeaderFooterId(currentPageNumber, "headerIds", editor);
|
|
52562
52637
|
const footerId = getHeaderFooterId(currentPageNumber, "footerIds", editor);
|
|
52563
52638
|
header = createHeader(pageMargins, pageSize, sectionData, headerId, editor);
|
|
52564
|
-
footer = createFooter(pageMargins, pageSize, sectionData, footerId, editor);
|
|
52639
|
+
footer = createFooter(pageMargins, pageSize, sectionData, footerId, editor, currentPageNumber);
|
|
52565
52640
|
const bufferHeight = pageHeightThreshold - lastNodeCoords.bottom;
|
|
52566
52641
|
const { node: spacingNode } = createFinalPagePadding(bufferHeight);
|
|
52567
52642
|
const pageSpacer = Decoration.widget(doc2.content.size, spacingNode, { key: "stable-key" });
|
|
@@ -52596,6 +52671,10 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
|
|
|
52596
52671
|
const headerHeight = Math.max(headerDef?.height || 0, minHeaderHeight) + headerOffset;
|
|
52597
52672
|
const availableHeight = headerHeight - headerMargin;
|
|
52598
52673
|
const editorContainer = document.createElement("div");
|
|
52674
|
+
if (!headerId && !editor.converter.headerIds["default"]) {
|
|
52675
|
+
headerId = "rId" + generateDocxRandomId();
|
|
52676
|
+
editor.converter.headerIds["default"] = headerId;
|
|
52677
|
+
}
|
|
52599
52678
|
if (!editor.converter.headers[headerId]) {
|
|
52600
52679
|
editor.converter.headers[headerId] = {
|
|
52601
52680
|
type: "doc",
|
|
@@ -52603,24 +52682,21 @@ function createHeader(pageMargins, pageSize, sectionData, headerId, editor) {
|
|
|
52603
52682
|
};
|
|
52604
52683
|
}
|
|
52605
52684
|
const data = editor.converter.headers[headerId];
|
|
52606
|
-
|
|
52607
|
-
|
|
52608
|
-
|
|
52609
|
-
|
|
52610
|
-
|
|
52611
|
-
|
|
52612
|
-
|
|
52613
|
-
|
|
52614
|
-
|
|
52615
|
-
|
|
52616
|
-
|
|
52617
|
-
editorSection
|
|
52618
|
-
|
|
52619
|
-
|
|
52620
|
-
|
|
52621
|
-
});
|
|
52622
|
-
broadcastEditorEvents(editor, editorSection);
|
|
52623
|
-
}
|
|
52685
|
+
const editorSection = createHeaderFooterEditor({
|
|
52686
|
+
editor,
|
|
52687
|
+
data,
|
|
52688
|
+
editorContainer,
|
|
52689
|
+
appendToBody: false,
|
|
52690
|
+
sectionId: headerId,
|
|
52691
|
+
type: "header",
|
|
52692
|
+
availableHeight
|
|
52693
|
+
});
|
|
52694
|
+
editor.converter.headerEditors.push({
|
|
52695
|
+
id: headerId,
|
|
52696
|
+
editor: editorSection
|
|
52697
|
+
});
|
|
52698
|
+
editorSection.setEditable(false, false);
|
|
52699
|
+
broadcastEditorEvents(editor, editorSection);
|
|
52624
52700
|
editorContainer.className = "pagination-section-header";
|
|
52625
52701
|
editorContainer.style.paddingTop = headerMargin + "px";
|
|
52626
52702
|
editorContainer.style.paddingLeft = pageMargins.left * 96 + "px";
|
|
@@ -52639,26 +52715,40 @@ function createFooter(pageMargins, pageSize, sectionData, footerId, editor, curr
|
|
|
52639
52715
|
const minFooterHeight = pageMargins.bottom * 96;
|
|
52640
52716
|
const footerPaddingFromEdge = pageMargins.footer * 96;
|
|
52641
52717
|
const footerHeight = Math.max(footerDef?.height || 0, minFooterHeight - footerPaddingFromEdge);
|
|
52718
|
+
const sectionContainer = footerDef?.sectionContainer?.cloneNode(true);
|
|
52719
|
+
const autoPageNumber = sectionContainer?.querySelector('span[data-id="auto-page-number"]');
|
|
52720
|
+
if (autoPageNumber) {
|
|
52721
|
+
const fontSize2 = autoPageNumber.previousElementSibling?.style?.fontSize || autoPageNumber.nextElementSibling?.style?.fontSize;
|
|
52722
|
+
if (fontSize2) autoPageNumber.style.fontSize = fontSize2;
|
|
52723
|
+
autoPageNumber.innerText = currentPageNumber;
|
|
52724
|
+
}
|
|
52642
52725
|
const editorContainer = document.createElement("div");
|
|
52643
|
-
|
|
52644
|
-
|
|
52645
|
-
|
|
52646
|
-
editorSection = createHeaderFooterEditor({
|
|
52647
|
-
editor,
|
|
52648
|
-
data,
|
|
52649
|
-
editorContainer,
|
|
52650
|
-
appendToBody: false,
|
|
52651
|
-
sectionId: footerId,
|
|
52652
|
-
type: "footer",
|
|
52653
|
-
availableHeight: footerHeight
|
|
52654
|
-
});
|
|
52655
|
-
editor.converter.footerEditors.push({
|
|
52656
|
-
id: footerId,
|
|
52657
|
-
editor: editorSection
|
|
52658
|
-
});
|
|
52659
|
-
editorSection.setEditable(false, false);
|
|
52660
|
-
broadcastEditorEvents(editor, editorSection);
|
|
52726
|
+
if (!footerId && !editor.converter.footerIds["default"]) {
|
|
52727
|
+
footerId = "rId" + generateDocxRandomId();
|
|
52728
|
+
editor.converter.footerIds["default"] = footerId;
|
|
52661
52729
|
}
|
|
52730
|
+
if (!editor.converter.footers[footerId]) {
|
|
52731
|
+
editor.converter.footers[footerId] = {
|
|
52732
|
+
type: "doc",
|
|
52733
|
+
content: [{ type: "paragraph", content: [] }]
|
|
52734
|
+
};
|
|
52735
|
+
}
|
|
52736
|
+
const data = editor.converter.footers[footerId];
|
|
52737
|
+
const editorSection = createHeaderFooterEditor({
|
|
52738
|
+
editor,
|
|
52739
|
+
data,
|
|
52740
|
+
editorContainer,
|
|
52741
|
+
appendToBody: false,
|
|
52742
|
+
sectionId: footerId,
|
|
52743
|
+
type: "footer",
|
|
52744
|
+
availableHeight: footerHeight
|
|
52745
|
+
});
|
|
52746
|
+
editor.converter.footerEditors.push({
|
|
52747
|
+
id: footerId,
|
|
52748
|
+
editor: editorSection
|
|
52749
|
+
});
|
|
52750
|
+
editorSection.setEditable(false, false);
|
|
52751
|
+
broadcastEditorEvents(editor, editorSection);
|
|
52662
52752
|
editorContainer.className = "pagination-section-footer";
|
|
52663
52753
|
editorContainer.style.height = footerHeight + "px";
|
|
52664
52754
|
editorContainer.style.marginBottom = footerPaddingFromEdge + "px";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref, onMounted, onUnmounted, computed, createElementBlock, openBlock, withModifiers, createElementVNode, withDirectives, unref, vModelText, createCommentVNode, nextTick } from "vue";
|
|
2
|
-
import { T as TextSelection } from "./chunks/converter-
|
|
3
|
-
import { _ as _export_sfc } from "./chunks/editor-
|
|
2
|
+
import { T as TextSelection } from "./chunks/converter-CaX3dOo9.js";
|
|
3
|
+
import { _ as _export_sfc } from "./chunks/editor-Ctzz2gCC.js";
|
|
4
4
|
const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
|
|
5
5
|
const SYSTEM_PROMPT = "You are an expert copywriter and you are immersed in a document editor. You are to provide document related text responses based on the user prompts. Only write what is asked for. Do not provide explanations. Try to keep placeholders as short as possible. Do not output your prompt. Your instructions are: ";
|
|
6
6
|
async function baseInsightsFetch(payload, options = {}) {
|
|
@@ -18874,8 +18874,20 @@ function exportSchemaToJson(params) {
|
|
|
18874
18874
|
return router[type2](params);
|
|
18875
18875
|
}
|
|
18876
18876
|
function translateBodyNode(params) {
|
|
18877
|
-
|
|
18877
|
+
let sectPr = params.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
|
|
18878
18878
|
if (params.converter) {
|
|
18879
|
+
const hasHeader = sectPr.elements.some((n) => n.name === "w:headerReference");
|
|
18880
|
+
const hasDefaultHeader = params.converter.headerIds?.default;
|
|
18881
|
+
if (!hasHeader && hasDefaultHeader && !params.editor.options.isHeaderOrFooter) {
|
|
18882
|
+
const defaultHeader = generateDefaultHeaderFooter("header", params.converter.headerIds?.default);
|
|
18883
|
+
sectPr.elements.push(defaultHeader);
|
|
18884
|
+
}
|
|
18885
|
+
const hasFooter = sectPr.elements.some((n) => n.name === "w:footerReference");
|
|
18886
|
+
const hasDefaultFooter = params.converter.footerIds?.default;
|
|
18887
|
+
if (!hasFooter && hasDefaultFooter && !params.editor.options.isHeaderOrFooter) {
|
|
18888
|
+
const defaultFooter = generateDefaultHeaderFooter("footer", params.converter.footerIds?.default);
|
|
18889
|
+
sectPr.elements.push(defaultFooter);
|
|
18890
|
+
}
|
|
18879
18891
|
const newMargins = params.converter.pageStyles.pageMargins;
|
|
18880
18892
|
const sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
|
|
18881
18893
|
const { attributes } = sectPrMargins;
|
|
@@ -18897,6 +18909,16 @@ function translateBodyNode(params) {
|
|
|
18897
18909
|
elements: [...elements, sectPr]
|
|
18898
18910
|
};
|
|
18899
18911
|
}
|
|
18912
|
+
const generateDefaultHeaderFooter = (type2, id) => {
|
|
18913
|
+
return {
|
|
18914
|
+
"type": "element",
|
|
18915
|
+
"name": `w:${type2}Reference`,
|
|
18916
|
+
"attributes": {
|
|
18917
|
+
"w:type": "default",
|
|
18918
|
+
"r:id": id
|
|
18919
|
+
}
|
|
18920
|
+
};
|
|
18921
|
+
};
|
|
18900
18922
|
function translateParagraphNode(params) {
|
|
18901
18923
|
const elements = translateChildNodes(params);
|
|
18902
18924
|
const htmlAnnotationChild = elements.find((element) => element.name === "htmlAnnotation");
|
|
@@ -23195,6 +23217,7 @@ const isAlternatingHeadersOddEven = (docx) => {
|
|
|
23195
23217
|
return !!evenOdd;
|
|
23196
23218
|
};
|
|
23197
23219
|
const HYPERLINK_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
|
|
23220
|
+
const HEADER_RELATIONSHIP_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
|
|
23198
23221
|
const _SuperConverter = class _SuperConverter {
|
|
23199
23222
|
constructor(params = null) {
|
|
23200
23223
|
__privateAdd(this, _SuperConverter_instances);
|
|
@@ -23265,7 +23288,7 @@ const _SuperConverter = class _SuperConverter {
|
|
|
23265
23288
|
return;
|
|
23266
23289
|
}
|
|
23267
23290
|
}
|
|
23268
|
-
static updateDocumentVersion(docx = this.convertedXml, version = "0.12.
|
|
23291
|
+
static updateDocumentVersion(docx = this.convertedXml, version = "0.12.16") {
|
|
23269
23292
|
const customLocation = "docProps/custom.xml";
|
|
23270
23293
|
if (!docx[customLocation]) {
|
|
23271
23294
|
docx[customLocation] = generateCustomXml();
|
|
@@ -23453,8 +23476,8 @@ const _SuperConverter = class _SuperConverter {
|
|
|
23453
23476
|
commentsRels = relationships;
|
|
23454
23477
|
}
|
|
23455
23478
|
this.convertedXml = { ...this.convertedXml, ...updatedXml };
|
|
23456
|
-
__privateMethod(this, _SuperConverter_instances,
|
|
23457
|
-
__privateMethod(this, _SuperConverter_instances,
|
|
23479
|
+
const headFootRels = __privateMethod(this, _SuperConverter_instances, exportProcessHeadersFooters_fn).call(this, { isFinalDoc });
|
|
23480
|
+
__privateMethod(this, _SuperConverter_instances, exportProcessNewRelationships_fn).call(this, [...params.relationships, ...commentsRels, ...headFootRels]);
|
|
23458
23481
|
storeSuperdocVersion(this.convertedXml);
|
|
23459
23482
|
__privateMethod(this, _SuperConverter_instances, exportNumberingFile_fn).call(this, params);
|
|
23460
23483
|
return xml;
|
|
@@ -23517,8 +23540,9 @@ prepareCommentsXmlFilesForExport_fn = function({ defs, exportType, commentsWithP
|
|
|
23517
23540
|
exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
|
|
23518
23541
|
const relsData = this.convertedXml["word/_rels/document.xml.rels"];
|
|
23519
23542
|
const relationships = relsData.elements.find((x) => x.name === "Relationships");
|
|
23520
|
-
|
|
23521
|
-
|
|
23543
|
+
const newDocRels = [];
|
|
23544
|
+
Object.entries(this.headers).forEach(([id, header], index) => {
|
|
23545
|
+
const fileName = relationships.elements.find((el) => el.attributes.Id === id)?.attributes.Target || `header${index + 1}.xml`;
|
|
23522
23546
|
const headerEditor = this.headerEditors.find((item) => item.id === id);
|
|
23523
23547
|
if (!headerEditor) return;
|
|
23524
23548
|
const { result, params } = this.exportToXmlJson({
|
|
@@ -23532,7 +23556,27 @@ exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
|
|
|
23532
23556
|
});
|
|
23533
23557
|
const bodyContent = result.elements[0].elements;
|
|
23534
23558
|
const file = this.convertedXml[`word/${fileName}`];
|
|
23535
|
-
file
|
|
23559
|
+
if (!file) {
|
|
23560
|
+
this.convertedXml[`word/${fileName}`] = {
|
|
23561
|
+
declaration: this.initialJSON?.declaration,
|
|
23562
|
+
elements: [{
|
|
23563
|
+
attributes: DEFAULT_DOCX_DEFS,
|
|
23564
|
+
name: "w:hdr",
|
|
23565
|
+
type: "element",
|
|
23566
|
+
elements: []
|
|
23567
|
+
}]
|
|
23568
|
+
};
|
|
23569
|
+
newDocRels.push({
|
|
23570
|
+
type: "element",
|
|
23571
|
+
name: "Relationship",
|
|
23572
|
+
attributes: {
|
|
23573
|
+
Id: id,
|
|
23574
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",
|
|
23575
|
+
Target: fileName
|
|
23576
|
+
}
|
|
23577
|
+
});
|
|
23578
|
+
}
|
|
23579
|
+
this.convertedXml[`word/${fileName}`].elements[0].elements = bodyContent;
|
|
23536
23580
|
if (params.relationships.length) {
|
|
23537
23581
|
const relationships2 = this.convertedXml[`word/_rels/${fileName}.rels`]?.elements?.find((x) => x.name === "Relationships")?.elements || [];
|
|
23538
23582
|
this.convertedXml[`word/_rels/${fileName}.rels`] = {
|
|
@@ -23550,8 +23594,8 @@ exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
|
|
|
23550
23594
|
};
|
|
23551
23595
|
}
|
|
23552
23596
|
});
|
|
23553
|
-
Object.entries(this.footers).forEach(([id, footer]) => {
|
|
23554
|
-
const fileName = relationships.elements.find((el) => el.attributes.Id === id)?.attributes.Target
|
|
23597
|
+
Object.entries(this.footers).forEach(([id, footer], index) => {
|
|
23598
|
+
const fileName = relationships.elements.find((el) => el.attributes.Id === id)?.attributes.Target || `footer${index + 1}.xml`;
|
|
23555
23599
|
const footerEditor = this.footerEditors.find((item) => item.id === id);
|
|
23556
23600
|
if (!footerEditor) return;
|
|
23557
23601
|
const { result, params } = this.exportToXmlJson({
|
|
@@ -23565,7 +23609,27 @@ exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
|
|
|
23565
23609
|
});
|
|
23566
23610
|
const bodyContent = result.elements[0].elements;
|
|
23567
23611
|
const file = this.convertedXml[`word/${fileName}`];
|
|
23568
|
-
file
|
|
23612
|
+
if (!file) {
|
|
23613
|
+
this.convertedXml[`word/${fileName}`] = {
|
|
23614
|
+
declaration: this.initialJSON?.declaration,
|
|
23615
|
+
elements: [{
|
|
23616
|
+
attributes: DEFAULT_DOCX_DEFS,
|
|
23617
|
+
name: "w:ftr",
|
|
23618
|
+
type: "element",
|
|
23619
|
+
elements: []
|
|
23620
|
+
}]
|
|
23621
|
+
};
|
|
23622
|
+
newDocRels.push({
|
|
23623
|
+
type: "element",
|
|
23624
|
+
name: "Relationship",
|
|
23625
|
+
attributes: {
|
|
23626
|
+
Id: id,
|
|
23627
|
+
Type: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",
|
|
23628
|
+
Target: fileName
|
|
23629
|
+
}
|
|
23630
|
+
});
|
|
23631
|
+
}
|
|
23632
|
+
this.convertedXml[`word/${fileName}`].elements[0].elements = bodyContent;
|
|
23569
23633
|
if (params.relationships.length) {
|
|
23570
23634
|
const relationships2 = this.convertedXml[`word/_rels/${fileName}.rels`]?.elements?.find((x) => x.name === "Relationships")?.elements || [];
|
|
23571
23635
|
this.convertedXml[`word/_rels/${fileName}.rels`] = {
|
|
@@ -23583,6 +23647,7 @@ exportProcessHeadersFooters_fn = function({ isFinalDoc = false }) {
|
|
|
23583
23647
|
};
|
|
23584
23648
|
}
|
|
23585
23649
|
});
|
|
23650
|
+
return newDocRels;
|
|
23586
23651
|
};
|
|
23587
23652
|
exportProcessNewRelationships_fn = function(rels = []) {
|
|
23588
23653
|
const relsData = this.convertedXml["word/_rels/document.xml.rels"];
|
|
@@ -23595,7 +23660,8 @@ exportProcessNewRelationships_fn = function(rels = []) {
|
|
|
23595
23660
|
const existingTarget = relationships.elements.find((el) => el.attributes.Target === rel.attributes.Target);
|
|
23596
23661
|
const isNewMedia = rel.attributes.Target?.startsWith("media/") && existingId.length > 6;
|
|
23597
23662
|
const isNewHyperlink = rel.attributes.Type === HYPERLINK_RELATIONSHIP_TYPE && existingId.length > 6;
|
|
23598
|
-
|
|
23663
|
+
const isNewHeadFoot = rel.attributes.Type === HEADER_RELATIONSHIP_TYPE && existingId.length > 6;
|
|
23664
|
+
if (existingTarget && !isNewMedia && !isNewHyperlink && !isNewHeadFoot) {
|
|
23599
23665
|
return;
|
|
23600
23666
|
}
|
|
23601
23667
|
rel.attributes.Target = rel.attributes?.Target?.replace(/&/g, "&");
|
|
@@ -23691,7 +23757,7 @@ function storeSuperdocVersion(docx) {
|
|
|
23691
23757
|
function generateCustomXml() {
|
|
23692
23758
|
return DEFAULT_CUSTOM_XML;
|
|
23693
23759
|
}
|
|
23694
|
-
function generateSuperdocVersion(pid = 2, version = "0.12.
|
|
23760
|
+
function generateSuperdocVersion(pid = 2, version = "0.12.16") {
|
|
23695
23761
|
return {
|
|
23696
23762
|
type: "element",
|
|
23697
23763
|
name: "property",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { x as process$1, a1 as commonjsGlobal, B as Buffer, a2 as getDefaultExportFromCjs, a3 as getContentTypesFromXml, a4 as xmljs } from "./converter-
|
|
1
|
+
import { x as process$1, a1 as commonjsGlobal, B as Buffer, a2 as getDefaultExportFromCjs, a3 as getContentTypesFromXml, a4 as xmljs } from "./converter-CaX3dOo9.js";
|
|
2
2
|
function commonjsRequire(path) {
|
|
3
3
|
throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
4
4
|
}
|
|
@@ -2414,6 +2414,15 @@ class DocxZipper {
|
|
|
2414
2414
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
|
|
2415
2415
|
if (!hasCommentsExtensible) typesString += commentsExtendedDef;
|
|
2416
2416
|
}
|
|
2417
|
+
Object.keys(docx.files).forEach((name) => {
|
|
2418
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
2419
|
+
const hasExtensible = types.elements?.some((el) => el.name === "Override" && el.attributes.PartName === `/${name}`);
|
|
2420
|
+
const type = name.includes("header") ? "header" : "footer";
|
|
2421
|
+
const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type}+xml"/>`;
|
|
2422
|
+
if (!hasExtensible) {
|
|
2423
|
+
typesString += extendedDef;
|
|
2424
|
+
}
|
|
2425
|
+
});
|
|
2417
2426
|
const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
|
2418
2427
|
const updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
|
|
2419
2428
|
docx.file(contentTypesPath, updatedContentTypesXml);
|