@harbour-enterprises/superdoc 0.22.0-next.1 → 0.22.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{PdfViewer-BpwMPbUj.es.js → PdfViewer-CS3pY_UR.es.js} +1 -1
- package/dist/chunks/{PdfViewer-B3KmcDup.cjs → PdfViewer-Cz3fT1qt.cjs} +1 -1
- package/dist/chunks/{index-Cw4YywoD.es.js → index-Bbqhu9ev.es.js} +53 -26
- package/dist/chunks/{index-BOf6E2I4.cjs → index-p73XAt11.cjs} +53 -26
- package/dist/chunks/{super-editor.es-DHDx2fsy.cjs → super-editor.es-CFD0lcOY.cjs} +3201 -2009
- package/dist/chunks/{super-editor.es-vfoWxyZL.es.js → super-editor.es-DK3l03fz.es.js} +3201 -2009
- package/dist/core/SuperDoc.d.ts +5 -0
- package/dist/core/SuperDoc.d.ts.map +1 -1
- package/dist/core/types/index.d.ts +4 -4
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/stores/comments-store.d.ts +4 -1
- package/dist/stores/comments-store.d.ts.map +1 -1
- package/dist/style.css +51 -44
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BcqEfCTg.js → converter-DFDRdFEB.js} +1880 -1169
- package/dist/super-editor/chunks/{docx-zipper-DZ9ph0iQ.js → docx-zipper-CplUdgI9.js} +73 -12
- package/dist/super-editor/chunks/{editor-BC2sSIVa.js → editor-BnpIdTLI.js} +1492 -1061
- package/dist/super-editor/chunks/{toolbar-DNTo5DDf.js → toolbar-5h-ljJ_h.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/src/core/DocxZipper.d.ts +1 -1
- package/dist/super-editor/src/core/helpers/generateDocxRandomId.d.ts +5 -0
- package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +1 -13
- package/dist/super-editor/src/core/super-converter/exporter.d.ts +5 -4
- package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/hyperlink-preprocessor.d.ts +9 -0
- package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/index.d.ts +2 -0
- package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/num-pages-preprocessor.d.ts +9 -0
- package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-preprocessor.d.ts +9 -0
- package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/page-ref-preprocessor.d.ts +9 -0
- package/dist/super-editor/src/core/super-converter/field-references/fld-preprocessors/toc-preprocessor.d.ts +8 -0
- package/dist/super-editor/src/core/super-converter/field-references/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/field-references/preProcessNodesForFldChar.d.ts +21 -0
- package/dist/super-editor/src/core/super-converter/helpers/tableFallbackHelpers.d.ts +24 -0
- package/dist/super-editor/src/core/super-converter/v2/exporter/helpers/translateChildNodes.d.ts +3 -3
- package/dist/super-editor/src/core/super-converter/v2/importer/pageReferenceImporter.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v2/importer/tableOfContentsImporter.d.ts +4 -0
- package/dist/super-editor/src/core/super-converter/v2/types/index.d.ts +7 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/sd/pageReference/pageReference-translator.d.ts +7 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/index.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/sd/tableOfContents/tableOfContents-translator.d.ts +10 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/caps/caps-translator.d.ts +7 -0
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/p/helpers/w-p-helpers.d.ts +0 -2
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/handle-doc-part-obj.d.ts +9 -1
- package/dist/super-editor/src/core/super-converter/v3/handlers/w/sdt/helpers/translate-document-part-obj.d.ts +6 -0
- package/dist/super-editor/src/core/super-converter/v3/node-translator/node-translator.d.ts +2 -2
- package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +5 -1
- package/dist/super-editor/src/extensions/index.d.ts +2 -1
- package/dist/super-editor/src/extensions/page-reference/index.d.ts +1 -0
- package/dist/super-editor/src/extensions/page-reference/page-reference.d.ts +2 -0
- package/dist/super-editor/src/extensions/structured-content/document-part-object.d.ts +2 -0
- package/dist/super-editor/src/extensions/structured-content/index.d.ts +2 -0
- package/dist/super-editor/src/extensions/structured-content/structured-content-commands.d.ts +67 -0
- package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentBlockTags.d.ts +6 -0
- package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentInlineTags.d.ts +6 -0
- package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTags.d.ts +6 -0
- package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/getStructuredContentTagsById.d.ts +7 -0
- package/dist/super-editor/src/extensions/structured-content/structuredContentHelpers/index.d.ts +4 -0
- package/dist/super-editor/src/extensions/tab/helpers/tabDecorations.d.ts +2 -2
- package/dist/super-editor/src/extensions/table-of-contents/index.d.ts +1 -0
- package/dist/super-editor/src/extensions/table-of-contents/table-of-contents.d.ts +2 -0
- package/dist/super-editor/src/utils/contextmenu-helpers.d.ts +24 -0
- package/dist/super-editor/style.css +7 -0
- package/dist/super-editor/super-editor.es.js +11 -17
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +3245 -2026
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/src/components/slash-menu/contextmenu-helpers.d.ts +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as process$1,
|
|
1
|
+
import { p as process$1, aw as commonjsGlobal, B as Buffer, ax as getDefaultExportFromCjs, ay as getContentTypesFromXml, az as xmljs } from "./converter-DFDRdFEB.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,14 +2414,19 @@ class DocxZipper {
|
|
|
2414
2414
|
/**
|
|
2415
2415
|
* Update [Content_Types].xml with extensions of new Image annotations
|
|
2416
2416
|
*/
|
|
2417
|
-
async updateContentTypes(docx, media, fromJson) {
|
|
2417
|
+
async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
|
|
2418
|
+
const additionalPartNames = Object.keys(updatedDocs || {});
|
|
2418
2419
|
const newMediaTypes = Object.keys(media).map((name) => {
|
|
2419
2420
|
return this.getFileExtension(name);
|
|
2420
2421
|
}).filter(Boolean);
|
|
2421
2422
|
const contentTypesPath = "[Content_Types].xml";
|
|
2422
2423
|
let contentTypesXml;
|
|
2423
2424
|
if (fromJson) {
|
|
2424
|
-
|
|
2425
|
+
if (Array.isArray(docx.files)) {
|
|
2426
|
+
contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
|
|
2427
|
+
} else {
|
|
2428
|
+
contentTypesXml = docx.files?.[contentTypesPath] || "";
|
|
2429
|
+
}
|
|
2425
2430
|
} else contentTypesXml = await docx.file(contentTypesPath).async("string");
|
|
2426
2431
|
let typesString = "";
|
|
2427
2432
|
const defaultMediaTypes = getContentTypesFromXml(contentTypesXml);
|
|
@@ -2447,24 +2452,39 @@ class DocxZipper {
|
|
|
2447
2452
|
const hasCommentsExtensible = types.elements?.some(
|
|
2448
2453
|
(el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtensible.xml"
|
|
2449
2454
|
);
|
|
2450
|
-
|
|
2455
|
+
const hasFile = (filename) => {
|
|
2456
|
+
if (!docx?.files) return false;
|
|
2457
|
+
if (!fromJson) return Boolean(docx.files[filename]);
|
|
2458
|
+
if (Array.isArray(docx.files)) return docx.files.some((file) => file.name === filename);
|
|
2459
|
+
return Boolean(docx.files[filename]);
|
|
2460
|
+
};
|
|
2461
|
+
if (hasFile("word/comments.xml")) {
|
|
2451
2462
|
const commentsDef = `<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />`;
|
|
2452
2463
|
if (!hasComments) typesString += commentsDef;
|
|
2453
2464
|
}
|
|
2454
|
-
if (
|
|
2465
|
+
if (hasFile("word/commentsExtended.xml")) {
|
|
2455
2466
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />`;
|
|
2456
2467
|
if (!hasCommentsExtended) typesString += commentsExtendedDef;
|
|
2457
2468
|
}
|
|
2458
|
-
if (
|
|
2469
|
+
if (hasFile("word/commentsIds.xml")) {
|
|
2459
2470
|
const commentsIdsDef = `<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />`;
|
|
2460
2471
|
if (!hasCommentsIds) typesString += commentsIdsDef;
|
|
2461
2472
|
}
|
|
2462
|
-
if (
|
|
2473
|
+
if (hasFile("word/commentsExtensible.xml")) {
|
|
2463
2474
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
|
|
2464
2475
|
if (!hasCommentsExtensible) typesString += commentsExtendedDef;
|
|
2465
2476
|
}
|
|
2466
|
-
|
|
2467
|
-
|
|
2477
|
+
const partNames = new Set(additionalPartNames);
|
|
2478
|
+
if (docx?.files) {
|
|
2479
|
+
if (fromJson && Array.isArray(docx.files)) {
|
|
2480
|
+
docx.files.forEach((file) => partNames.add(file.name));
|
|
2481
|
+
} else {
|
|
2482
|
+
Object.keys(docx.files).forEach((key) => partNames.add(key));
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
partNames.forEach((name) => {
|
|
2486
|
+
if (name.includes(".rels")) return;
|
|
2487
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
2468
2488
|
const hasExtensible = types.elements?.some(
|
|
2469
2489
|
(el) => el.name === "Override" && el.attributes.PartName === `/${name}`
|
|
2470
2490
|
);
|
|
@@ -2475,7 +2495,48 @@ class DocxZipper {
|
|
|
2475
2495
|
}
|
|
2476
2496
|
});
|
|
2477
2497
|
const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
|
2478
|
-
|
|
2498
|
+
let updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
|
|
2499
|
+
let relationshipsXml = updatedDocs["word/_rels/document.xml.rels"];
|
|
2500
|
+
if (!relationshipsXml) {
|
|
2501
|
+
if (fromJson) {
|
|
2502
|
+
if (Array.isArray(docx.files)) {
|
|
2503
|
+
relationshipsXml = docx.files.find((file) => file.name === "word/_rels/document.xml.rels")?.content;
|
|
2504
|
+
} else {
|
|
2505
|
+
relationshipsXml = docx.files?.["word/_rels/document.xml.rels"];
|
|
2506
|
+
}
|
|
2507
|
+
} else {
|
|
2508
|
+
relationshipsXml = await docx.file("word/_rels/document.xml.rels")?.async("string");
|
|
2509
|
+
}
|
|
2510
|
+
}
|
|
2511
|
+
if (relationshipsXml) {
|
|
2512
|
+
try {
|
|
2513
|
+
const relJson = xmljs.xml2js(relationshipsXml, { compact: false });
|
|
2514
|
+
const relationships = relJson.elements?.find((el) => el.name === "Relationships");
|
|
2515
|
+
relationships?.elements?.forEach((rel) => {
|
|
2516
|
+
const type = rel.attributes?.Type;
|
|
2517
|
+
const target = rel.attributes?.Target;
|
|
2518
|
+
if (!type || !target) return;
|
|
2519
|
+
const isHeader = type.includes("/header");
|
|
2520
|
+
const isFooter = type.includes("/footer");
|
|
2521
|
+
if (!isHeader && !isFooter) return;
|
|
2522
|
+
let sanitizedTarget = target.replace(/^\.\//, "");
|
|
2523
|
+
if (sanitizedTarget.startsWith("../")) sanitizedTarget = sanitizedTarget.slice(3);
|
|
2524
|
+
if (sanitizedTarget.startsWith("/")) sanitizedTarget = sanitizedTarget.slice(1);
|
|
2525
|
+
const partName = sanitizedTarget.startsWith("word/") ? sanitizedTarget : `word/${sanitizedTarget}`;
|
|
2526
|
+
partNames.add(partName);
|
|
2527
|
+
});
|
|
2528
|
+
} catch (error) {
|
|
2529
|
+
console.warn("Failed to parse document relationships while updating content types", error);
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
partNames.forEach((name) => {
|
|
2533
|
+
if (name.includes(".rels")) return;
|
|
2534
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
2535
|
+
if (updatedContentTypesXml.includes(`PartName="/${name}"`)) return;
|
|
2536
|
+
const type = name.includes("header") ? "header" : "footer";
|
|
2537
|
+
const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type}+xml"/>`;
|
|
2538
|
+
updatedContentTypesXml = updatedContentTypesXml.replace("</Types>", `${extendedDef}</Types>`);
|
|
2539
|
+
});
|
|
2479
2540
|
if (fromJson) return updatedContentTypesXml;
|
|
2480
2541
|
docx.file(contentTypesPath, updatedContentTypesXml);
|
|
2481
2542
|
}
|
|
@@ -2516,7 +2577,7 @@ class DocxZipper {
|
|
|
2516
2577
|
for (const [fontName, fontUintArray] of Object.entries(fonts)) {
|
|
2517
2578
|
zip.file(fontName, fontUintArray);
|
|
2518
2579
|
}
|
|
2519
|
-
await this.updateContentTypes(zip, media);
|
|
2580
|
+
await this.updateContentTypes(zip, media, false, updatedDocs);
|
|
2520
2581
|
return zip;
|
|
2521
2582
|
}
|
|
2522
2583
|
/**
|
|
@@ -2542,7 +2603,7 @@ class DocxZipper {
|
|
|
2542
2603
|
Object.keys(media).forEach((path) => {
|
|
2543
2604
|
unzippedOriginalDocx.file(path, media[path]);
|
|
2544
2605
|
});
|
|
2545
|
-
await this.updateContentTypes(unzippedOriginalDocx, media);
|
|
2606
|
+
await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
|
|
2546
2607
|
return unzippedOriginalDocx;
|
|
2547
2608
|
}
|
|
2548
2609
|
}
|