@harbour-enterprises/superdoc 0.22.0-next.4 → 0.22.0-next.6
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-BBpGCmdE.es.js → PdfViewer-BMfm6DSP.es.js} +1 -1
- package/dist/chunks/{PdfViewer-CxIz7yf-.cjs → PdfViewer-XMDxj-2m.cjs} +1 -1
- package/dist/chunks/{index-BE07bQaY.cjs → index-BlNiELtW.cjs} +2 -2
- package/dist/chunks/{index-CYCctXm3.es.js → index-Cvi1utmk.es.js} +2 -2
- package/dist/chunks/{super-editor.es-cZsHkhM6.cjs → super-editor.es-BDsfLrnI.cjs} +247 -61
- package/dist/chunks/{super-editor.es-Ccu1wOj1.es.js → super-editor.es-CmQ5GChv.es.js} +247 -61
- package/dist/core/types/index.d.ts.map +1 -1
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DBwwYo1I.js → converter-D9kK7Smo.js} +136 -36
- package/dist/super-editor/chunks/{docx-zipper-BCI-3XE9.js → docx-zipper-D8HnWWpv.js} +73 -12
- package/dist/super-editor/chunks/{editor-B2S-zXBF.js → editor-Ddkz97dH.js} +41 -16
- package/dist/super-editor/chunks/{toolbar-BX9nPPG0.js → toolbar-BxjdbiUf.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/super-converter/exporter.d.ts +1 -0
- package/dist/super-editor/src/core/super-converter/helpers/tableFallbackHelpers.d.ts +24 -0
- package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +5 -0
- 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 +2 -2
- package/dist/superdoc.umd.js +247 -61
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/super-editor.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const superEditor_es = require("./chunks/super-editor.es-
|
|
3
|
+
const superEditor_es = require("./chunks/super-editor.es-BDsfLrnI.cjs");
|
|
4
4
|
require("./chunks/vue-DWle4Cai.cjs");
|
|
5
5
|
exports.AIWriter = superEditor_es.AIWriter;
|
|
6
6
|
exports.AnnotatorHelpers = superEditor_es.AnnotatorHelpers;
|
package/dist/super-editor.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A, a, _, C, D, E, b, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-
|
|
1
|
+
import { A, a, _, C, D, E, b, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-CmQ5GChv.es.js";
|
|
2
2
|
import "./chunks/vue-CXxsqYcP.es.js";
|
|
3
3
|
export {
|
|
4
4
|
A as AIWriter,
|
package/dist/superdoc.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const superEditor_es = require("./chunks/super-editor.es-
|
|
4
|
-
const superdoc = require("./chunks/index-
|
|
3
|
+
const superEditor_es = require("./chunks/super-editor.es-BDsfLrnI.cjs");
|
|
4
|
+
const superdoc = require("./chunks/index-BlNiELtW.cjs");
|
|
5
5
|
require("./chunks/vue-DWle4Cai.cjs");
|
|
6
6
|
require("./chunks/jszip-b7l8QkfH.cjs");
|
|
7
7
|
const blankDocx = require("./chunks/blank-docx-CPqX9RF5.cjs");
|
package/dist/superdoc.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-
|
|
2
|
-
import { D, H, P, S as S2, m, l } from "./chunks/index-
|
|
1
|
+
import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-CmQ5GChv.es.js";
|
|
2
|
+
import { D, H, P, S as S2, m, l } from "./chunks/index-Cvi1utmk.es.js";
|
|
3
3
|
import "./chunks/vue-CXxsqYcP.es.js";
|
|
4
4
|
import "./chunks/jszip-B8KIZSNe.es.js";
|
|
5
5
|
import { B } from "./chunks/blank-docx-iwdyG9RH.es.js";
|
package/dist/superdoc.umd.js
CHANGED
|
@@ -34902,6 +34902,68 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34902
34902
|
decode: decode$h
|
|
34903
34903
|
};
|
|
34904
34904
|
const translator$a = NodeTranslator.from(config$a);
|
|
34905
|
+
const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
|
|
34906
|
+
const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
|
|
34907
|
+
const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
|
|
34908
|
+
const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
|
|
34909
|
+
const pctToPercent = (value) => {
|
|
34910
|
+
if (value == null) return null;
|
|
34911
|
+
return value / 50;
|
|
34912
|
+
};
|
|
34913
|
+
const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
|
|
34914
|
+
const resolveMeasurementWidthPx = (measurement) => {
|
|
34915
|
+
if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
|
|
34916
|
+
const { value, type: type2 } = measurement;
|
|
34917
|
+
if (!type2 || type2 === "auto") return null;
|
|
34918
|
+
if (type2 === "dxa") return twipsToPixels(value);
|
|
34919
|
+
if (type2 === "pct") {
|
|
34920
|
+
const percent2 = pctToPercent(value);
|
|
34921
|
+
if (percent2 == null || percent2 <= 0) return null;
|
|
34922
|
+
const widthTwips = resolveContentWidthTwips() * percent2 / 100;
|
|
34923
|
+
return twipsToPixels(widthTwips);
|
|
34924
|
+
}
|
|
34925
|
+
return null;
|
|
34926
|
+
};
|
|
34927
|
+
const countColumnsInRow = (row) => {
|
|
34928
|
+
if (!row?.elements?.length) return 0;
|
|
34929
|
+
return row.elements.reduce((count, element) => {
|
|
34930
|
+
if (element.name !== "w:tc") return count;
|
|
34931
|
+
const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
|
|
34932
|
+
const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
34933
|
+
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
34934
|
+
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
34935
|
+
}, 0);
|
|
34936
|
+
};
|
|
34937
|
+
const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
|
|
34938
|
+
const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
|
|
34939
|
+
const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWidthMeasurement }) => {
|
|
34940
|
+
const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
|
|
34941
|
+
const columnCount = countColumnsInRow(firstRow);
|
|
34942
|
+
if (!columnCount) return null;
|
|
34943
|
+
const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
|
|
34944
|
+
/** @type {any} */
|
|
34945
|
+
params2
|
|
34946
|
+
);
|
|
34947
|
+
const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
34948
|
+
let totalWidthPx;
|
|
34949
|
+
if (tableWidthMeasurement) {
|
|
34950
|
+
const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
|
|
34951
|
+
if (resolved != null) totalWidthPx = resolved;
|
|
34952
|
+
}
|
|
34953
|
+
if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
|
|
34954
|
+
totalWidthPx = tableWidth.width;
|
|
34955
|
+
}
|
|
34956
|
+
if (totalWidthPx == null) {
|
|
34957
|
+
totalWidthPx = minimumColumnWidthPx * columnCount;
|
|
34958
|
+
}
|
|
34959
|
+
const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
|
|
34960
|
+
const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
|
|
34961
|
+
const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
|
|
34962
|
+
return {
|
|
34963
|
+
grid: createFallbackGrid(columnCount, columnWidthTwips),
|
|
34964
|
+
columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
|
|
34965
|
+
};
|
|
34966
|
+
};
|
|
34905
34967
|
const XML_NODE_NAME$9 = "w:tbl";
|
|
34906
34968
|
const SD_NODE_NAME$9 = "table";
|
|
34907
34969
|
const encode$g = (params2, encodedAttrs) => {
|
|
@@ -34921,7 +34983,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34921
34983
|
"justification",
|
|
34922
34984
|
"tableLayout",
|
|
34923
34985
|
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
34924
|
-
["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
34925
34986
|
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
34926
34987
|
].forEach((prop) => {
|
|
34927
34988
|
let key2;
|
|
@@ -34939,6 +35000,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34939
35000
|
if (encodedAttrs.tableCellSpacing) {
|
|
34940
35001
|
encodedAttrs["borderCollapse"] = "separate";
|
|
34941
35002
|
}
|
|
35003
|
+
if (encodedAttrs.tableProperties?.tableWidth) {
|
|
35004
|
+
const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
|
|
35005
|
+
const widthPx = twipsToPixels(tableWidthMeasurement.value);
|
|
35006
|
+
if (widthPx != null) {
|
|
35007
|
+
encodedAttrs.tableWidth = {
|
|
35008
|
+
width: widthPx,
|
|
35009
|
+
type: tableWidthMeasurement.type
|
|
35010
|
+
};
|
|
35011
|
+
} else if (tableWidthMeasurement.type === "auto") {
|
|
35012
|
+
encodedAttrs.tableWidth = {
|
|
35013
|
+
width: 0,
|
|
35014
|
+
type: tableWidthMeasurement.type
|
|
35015
|
+
};
|
|
35016
|
+
}
|
|
35017
|
+
}
|
|
34942
35018
|
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
34943
35019
|
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
|
|
34944
35020
|
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
@@ -34952,7 +35028,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
34952
35028
|
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
34953
35029
|
encodedAttrs["borders"] = borderData;
|
|
34954
35030
|
const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
|
|
34955
|
-
|
|
35031
|
+
let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
|
|
35032
|
+
if (!columnWidths.length) {
|
|
35033
|
+
const fallback = buildFallbackGridForTable({
|
|
35034
|
+
params: params2,
|
|
35035
|
+
rows,
|
|
35036
|
+
tableWidth: encodedAttrs.tableWidth,
|
|
35037
|
+
tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
|
|
35038
|
+
});
|
|
35039
|
+
if (fallback) {
|
|
35040
|
+
encodedAttrs.grid = fallback.grid;
|
|
35041
|
+
columnWidths = fallback.columnWidths;
|
|
35042
|
+
}
|
|
35043
|
+
}
|
|
34956
35044
|
const content = [];
|
|
34957
35045
|
rows.forEach((row) => {
|
|
34958
35046
|
const result = translator$G.encode({
|
|
@@ -38345,6 +38433,51 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38345
38433
|
gutter: "0"
|
|
38346
38434
|
})
|
|
38347
38435
|
});
|
|
38436
|
+
const ensureSectionLayoutDefaults = (sectPr, converter) => {
|
|
38437
|
+
if (!sectPr) {
|
|
38438
|
+
return {
|
|
38439
|
+
type: "element",
|
|
38440
|
+
name: "w:sectPr",
|
|
38441
|
+
elements: []
|
|
38442
|
+
};
|
|
38443
|
+
}
|
|
38444
|
+
if (!sectPr.elements) sectPr.elements = [];
|
|
38445
|
+
const ensureChild = (name) => {
|
|
38446
|
+
let child = sectPr.elements.find((n) => n.name === name);
|
|
38447
|
+
if (!child) {
|
|
38448
|
+
child = {
|
|
38449
|
+
type: "element",
|
|
38450
|
+
name,
|
|
38451
|
+
elements: [],
|
|
38452
|
+
attributes: {}
|
|
38453
|
+
};
|
|
38454
|
+
sectPr.elements.push(child);
|
|
38455
|
+
} else {
|
|
38456
|
+
if (!child.elements) child.elements = [];
|
|
38457
|
+
if (!child.attributes) child.attributes = {};
|
|
38458
|
+
}
|
|
38459
|
+
return child;
|
|
38460
|
+
};
|
|
38461
|
+
const pageSize = converter?.pageStyles?.pageSize;
|
|
38462
|
+
const pgSz = ensureChild("w:pgSz");
|
|
38463
|
+
if (pageSize?.width != null) pgSz.attributes["w:w"] = String(inchesToTwips(pageSize.width));
|
|
38464
|
+
if (pageSize?.height != null) pgSz.attributes["w:h"] = String(inchesToTwips(pageSize.height));
|
|
38465
|
+
if (pgSz.attributes["w:w"] == null) pgSz.attributes["w:w"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
38466
|
+
if (pgSz.attributes["w:h"] == null) pgSz.attributes["w:h"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
38467
|
+
const pageMargins = converter?.pageStyles?.pageMargins;
|
|
38468
|
+
const pgMar = ensureChild("w:pgMar");
|
|
38469
|
+
if (pageMargins) {
|
|
38470
|
+
Object.entries(pageMargins).forEach(([key2, value]) => {
|
|
38471
|
+
const converted = inchesToTwips(value);
|
|
38472
|
+
if (converted != null) pgMar.attributes[`w:${key2}`] = String(converted);
|
|
38473
|
+
});
|
|
38474
|
+
}
|
|
38475
|
+
Object.entries(DEFAULT_SECTION_PROPS_TWIPS.pageMargins).forEach(([key2, value]) => {
|
|
38476
|
+
const attrKey = `w:${key2}`;
|
|
38477
|
+
if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
|
|
38478
|
+
});
|
|
38479
|
+
return sectPr;
|
|
38480
|
+
};
|
|
38348
38481
|
const isLineBreakOnlyRun = (node) => {
|
|
38349
38482
|
if (!node) return false;
|
|
38350
38483
|
if (node.type === "lineBreak" || node.type === "hardBreak") return true;
|
|
@@ -38407,6 +38540,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38407
38540
|
} else if (!sectPr.elements) {
|
|
38408
38541
|
sectPr = { ...sectPr, elements: [] };
|
|
38409
38542
|
}
|
|
38543
|
+
sectPr = ensureSectionLayoutDefaults(sectPr, params2.converter);
|
|
38410
38544
|
if (params2.converter) {
|
|
38411
38545
|
const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
|
|
38412
38546
|
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
@@ -38420,40 +38554,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38420
38554
|
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
38421
38555
|
sectPr.elements.push(defaultFooter);
|
|
38422
38556
|
}
|
|
38423
|
-
const newMargins = params2.converter.pageStyles?.pageMargins;
|
|
38424
|
-
if (newMargins) {
|
|
38425
|
-
let sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
|
|
38426
|
-
if (!sectPrMargins) {
|
|
38427
|
-
sectPrMargins = {
|
|
38428
|
-
type: "element",
|
|
38429
|
-
name: "w:pgMar",
|
|
38430
|
-
attributes: {}
|
|
38431
|
-
};
|
|
38432
|
-
sectPr.elements.push(sectPrMargins);
|
|
38433
|
-
} else if (!sectPrMargins.attributes) {
|
|
38434
|
-
sectPrMargins.attributes = {};
|
|
38435
|
-
}
|
|
38436
|
-
Object.entries(newMargins).forEach(([key2, value]) => {
|
|
38437
|
-
const convertedValue = inchesToTwips(value);
|
|
38438
|
-
sectPrMargins.attributes[`w:${key2}`] = convertedValue;
|
|
38439
|
-
});
|
|
38440
|
-
}
|
|
38441
|
-
let sectPrPgSz = sectPr.elements.find((n) => n.name === "w:pgSz");
|
|
38442
|
-
if (!sectPrPgSz) {
|
|
38443
|
-
sectPrPgSz = {
|
|
38444
|
-
type: "element",
|
|
38445
|
-
name: "w:pgSz",
|
|
38446
|
-
attributes: {}
|
|
38447
|
-
};
|
|
38448
|
-
sectPr.elements.push(sectPrPgSz);
|
|
38449
|
-
} else if (!sectPrPgSz.attributes) {
|
|
38450
|
-
sectPrPgSz.attributes = {};
|
|
38451
|
-
}
|
|
38452
|
-
const pageSize = params2.converter.pageStyles?.pageSize;
|
|
38453
|
-
const widthInches = pageSize?.width;
|
|
38454
|
-
const heightInches = pageSize?.height;
|
|
38455
|
-
sectPrPgSz.attributes["w:w"] = widthInches ? String(inchesToTwips(widthInches)) : sectPrPgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
38456
|
-
sectPrPgSz.attributes["w:h"] = heightInches ? String(inchesToTwips(heightInches)) : sectPrPgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
38457
38557
|
}
|
|
38458
38558
|
const elements = translateChildNodes(params2);
|
|
38459
38559
|
if (params2.isHeaderFooter) {
|
|
@@ -43982,14 +44082,19 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
43982
44082
|
/**
|
|
43983
44083
|
* Update [Content_Types].xml with extensions of new Image annotations
|
|
43984
44084
|
*/
|
|
43985
|
-
async updateContentTypes(docx, media, fromJson) {
|
|
44085
|
+
async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
|
|
44086
|
+
const additionalPartNames = Object.keys(updatedDocs || {});
|
|
43986
44087
|
const newMediaTypes = Object.keys(media).map((name) => {
|
|
43987
44088
|
return this.getFileExtension(name);
|
|
43988
44089
|
}).filter(Boolean);
|
|
43989
44090
|
const contentTypesPath = "[Content_Types].xml";
|
|
43990
44091
|
let contentTypesXml;
|
|
43991
44092
|
if (fromJson) {
|
|
43992
|
-
|
|
44093
|
+
if (Array.isArray(docx.files)) {
|
|
44094
|
+
contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
|
|
44095
|
+
} else {
|
|
44096
|
+
contentTypesXml = docx.files?.[contentTypesPath] || "";
|
|
44097
|
+
}
|
|
43993
44098
|
} else contentTypesXml = await docx.file(contentTypesPath).async("string");
|
|
43994
44099
|
let typesString = "";
|
|
43995
44100
|
const defaultMediaTypes = getContentTypesFromXml(contentTypesXml);
|
|
@@ -44015,24 +44120,39 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
44015
44120
|
const hasCommentsExtensible = types2.elements?.some(
|
|
44016
44121
|
(el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtensible.xml"
|
|
44017
44122
|
);
|
|
44018
|
-
|
|
44123
|
+
const hasFile = (filename) => {
|
|
44124
|
+
if (!docx?.files) return false;
|
|
44125
|
+
if (!fromJson) return Boolean(docx.files[filename]);
|
|
44126
|
+
if (Array.isArray(docx.files)) return docx.files.some((file) => file.name === filename);
|
|
44127
|
+
return Boolean(docx.files[filename]);
|
|
44128
|
+
};
|
|
44129
|
+
if (hasFile("word/comments.xml")) {
|
|
44019
44130
|
const commentsDef = `<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />`;
|
|
44020
44131
|
if (!hasComments) typesString += commentsDef;
|
|
44021
44132
|
}
|
|
44022
|
-
if (
|
|
44133
|
+
if (hasFile("word/commentsExtended.xml")) {
|
|
44023
44134
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />`;
|
|
44024
44135
|
if (!hasCommentsExtended) typesString += commentsExtendedDef;
|
|
44025
44136
|
}
|
|
44026
|
-
if (
|
|
44137
|
+
if (hasFile("word/commentsIds.xml")) {
|
|
44027
44138
|
const commentsIdsDef = `<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />`;
|
|
44028
44139
|
if (!hasCommentsIds) typesString += commentsIdsDef;
|
|
44029
44140
|
}
|
|
44030
|
-
if (
|
|
44141
|
+
if (hasFile("word/commentsExtensible.xml")) {
|
|
44031
44142
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
|
|
44032
44143
|
if (!hasCommentsExtensible) typesString += commentsExtendedDef;
|
|
44033
44144
|
}
|
|
44034
|
-
|
|
44035
|
-
|
|
44145
|
+
const partNames = new Set(additionalPartNames);
|
|
44146
|
+
if (docx?.files) {
|
|
44147
|
+
if (fromJson && Array.isArray(docx.files)) {
|
|
44148
|
+
docx.files.forEach((file) => partNames.add(file.name));
|
|
44149
|
+
} else {
|
|
44150
|
+
Object.keys(docx.files).forEach((key2) => partNames.add(key2));
|
|
44151
|
+
}
|
|
44152
|
+
}
|
|
44153
|
+
partNames.forEach((name) => {
|
|
44154
|
+
if (name.includes(".rels")) return;
|
|
44155
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
44036
44156
|
const hasExtensible = types2.elements?.some(
|
|
44037
44157
|
(el) => el.name === "Override" && el.attributes.PartName === `/${name}`
|
|
44038
44158
|
);
|
|
@@ -44043,7 +44163,48 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
44043
44163
|
}
|
|
44044
44164
|
});
|
|
44045
44165
|
const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
|
44046
|
-
|
|
44166
|
+
let updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
|
|
44167
|
+
let relationshipsXml = updatedDocs["word/_rels/document.xml.rels"];
|
|
44168
|
+
if (!relationshipsXml) {
|
|
44169
|
+
if (fromJson) {
|
|
44170
|
+
if (Array.isArray(docx.files)) {
|
|
44171
|
+
relationshipsXml = docx.files.find((file) => file.name === "word/_rels/document.xml.rels")?.content;
|
|
44172
|
+
} else {
|
|
44173
|
+
relationshipsXml = docx.files?.["word/_rels/document.xml.rels"];
|
|
44174
|
+
}
|
|
44175
|
+
} else {
|
|
44176
|
+
relationshipsXml = await docx.file("word/_rels/document.xml.rels")?.async("string");
|
|
44177
|
+
}
|
|
44178
|
+
}
|
|
44179
|
+
if (relationshipsXml) {
|
|
44180
|
+
try {
|
|
44181
|
+
const relJson = xmljs.xml2js(relationshipsXml, { compact: false });
|
|
44182
|
+
const relationships = relJson.elements?.find((el) => el.name === "Relationships");
|
|
44183
|
+
relationships?.elements?.forEach((rel) => {
|
|
44184
|
+
const type2 = rel.attributes?.Type;
|
|
44185
|
+
const target = rel.attributes?.Target;
|
|
44186
|
+
if (!type2 || !target) return;
|
|
44187
|
+
const isHeader = type2.includes("/header");
|
|
44188
|
+
const isFooter = type2.includes("/footer");
|
|
44189
|
+
if (!isHeader && !isFooter) return;
|
|
44190
|
+
let sanitizedTarget = target.replace(/^\.\//, "");
|
|
44191
|
+
if (sanitizedTarget.startsWith("../")) sanitizedTarget = sanitizedTarget.slice(3);
|
|
44192
|
+
if (sanitizedTarget.startsWith("/")) sanitizedTarget = sanitizedTarget.slice(1);
|
|
44193
|
+
const partName = sanitizedTarget.startsWith("word/") ? sanitizedTarget : `word/${sanitizedTarget}`;
|
|
44194
|
+
partNames.add(partName);
|
|
44195
|
+
});
|
|
44196
|
+
} catch (error) {
|
|
44197
|
+
console.warn("Failed to parse document relationships while updating content types", error);
|
|
44198
|
+
}
|
|
44199
|
+
}
|
|
44200
|
+
partNames.forEach((name) => {
|
|
44201
|
+
if (name.includes(".rels")) return;
|
|
44202
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
44203
|
+
if (updatedContentTypesXml.includes(`PartName="/${name}"`)) return;
|
|
44204
|
+
const type2 = name.includes("header") ? "header" : "footer";
|
|
44205
|
+
const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type2}+xml"/>`;
|
|
44206
|
+
updatedContentTypesXml = updatedContentTypesXml.replace("</Types>", `${extendedDef}</Types>`);
|
|
44207
|
+
});
|
|
44047
44208
|
if (fromJson) return updatedContentTypesXml;
|
|
44048
44209
|
docx.file(contentTypesPath, updatedContentTypesXml);
|
|
44049
44210
|
}
|
|
@@ -44084,7 +44245,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
44084
44245
|
for (const [fontName, fontUintArray] of Object.entries(fonts)) {
|
|
44085
44246
|
zip.file(fontName, fontUintArray);
|
|
44086
44247
|
}
|
|
44087
|
-
await this.updateContentTypes(zip, media);
|
|
44248
|
+
await this.updateContentTypes(zip, media, false, updatedDocs);
|
|
44088
44249
|
return zip;
|
|
44089
44250
|
}
|
|
44090
44251
|
/**
|
|
@@ -44110,7 +44271,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
44110
44271
|
Object.keys(media).forEach((path) => {
|
|
44111
44272
|
unzippedOriginalDocx.file(path, media[path]);
|
|
44112
44273
|
});
|
|
44113
|
-
await this.updateContentTypes(unzippedOriginalDocx, media);
|
|
44274
|
+
await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
|
|
44114
44275
|
return unzippedOriginalDocx;
|
|
44115
44276
|
}
|
|
44116
44277
|
}
|
|
@@ -58872,7 +59033,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
58872
59033
|
files: this.options.content
|
|
58873
59034
|
},
|
|
58874
59035
|
media,
|
|
58875
|
-
true
|
|
59036
|
+
true,
|
|
59037
|
+
updatedDocs
|
|
58876
59038
|
);
|
|
58877
59039
|
return updatedDocs;
|
|
58878
59040
|
}
|
|
@@ -61431,6 +61593,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61431
61593
|
return prefersNativeMenu(event);
|
|
61432
61594
|
};
|
|
61433
61595
|
const shouldBypassContextMenu = shouldAllowNativeContextMenu;
|
|
61596
|
+
const DEFAULT_SELECTION_STATE = Object.freeze({
|
|
61597
|
+
focused: false,
|
|
61598
|
+
preservedSelection: null,
|
|
61599
|
+
showVisualSelection: false,
|
|
61600
|
+
skipFocusReset: false
|
|
61601
|
+
});
|
|
61602
|
+
const normalizeSelectionState = (state2 = {}) => ({
|
|
61603
|
+
...DEFAULT_SELECTION_STATE,
|
|
61604
|
+
...state2
|
|
61605
|
+
});
|
|
61434
61606
|
const CustomSelectionPluginKey = new PluginKey("CustomSelection");
|
|
61435
61607
|
const handleClickOutside = (event, editor) => {
|
|
61436
61608
|
const editorElem = editor?.options?.element;
|
|
@@ -61468,11 +61640,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61468
61640
|
const customSelectionPlugin = new Plugin({
|
|
61469
61641
|
key: CustomSelectionPluginKey,
|
|
61470
61642
|
state: {
|
|
61471
|
-
init: () => ({
|
|
61472
|
-
focused: false,
|
|
61473
|
-
preservedSelection: null,
|
|
61474
|
-
showVisualSelection: false
|
|
61475
|
-
}),
|
|
61643
|
+
init: () => ({ ...DEFAULT_SELECTION_STATE }),
|
|
61476
61644
|
apply: (tr, value) => {
|
|
61477
61645
|
const meta = getFocusMeta(tr);
|
|
61478
61646
|
if (meta !== void 0) {
|
|
@@ -61503,7 +61671,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61503
61671
|
setFocusMeta(view.state.tr, {
|
|
61504
61672
|
focused: true,
|
|
61505
61673
|
preservedSelection: selection,
|
|
61506
|
-
showVisualSelection: true
|
|
61674
|
+
showVisualSelection: true,
|
|
61675
|
+
skipFocusReset: true
|
|
61507
61676
|
})
|
|
61508
61677
|
);
|
|
61509
61678
|
}
|
|
@@ -61524,7 +61693,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61524
61693
|
setFocusMeta(view.state.tr, {
|
|
61525
61694
|
focused: true,
|
|
61526
61695
|
preservedSelection: selection2,
|
|
61527
|
-
showVisualSelection: true
|
|
61696
|
+
showVisualSelection: true,
|
|
61697
|
+
skipFocusReset: true
|
|
61528
61698
|
})
|
|
61529
61699
|
);
|
|
61530
61700
|
this.editor.setOptions({
|
|
@@ -61547,7 +61717,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61547
61717
|
setFocusMeta(view.state.tr, {
|
|
61548
61718
|
focused: true,
|
|
61549
61719
|
preservedSelection: selection,
|
|
61550
|
-
showVisualSelection: true
|
|
61720
|
+
showVisualSelection: true,
|
|
61721
|
+
skipFocusReset: false
|
|
61551
61722
|
})
|
|
61552
61723
|
);
|
|
61553
61724
|
this.editor.setOptions({
|
|
@@ -61565,7 +61736,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61565
61736
|
setFocusMeta(view.state.tr, {
|
|
61566
61737
|
focused: true,
|
|
61567
61738
|
preservedSelection: selection,
|
|
61568
|
-
showVisualSelection: true
|
|
61739
|
+
showVisualSelection: true,
|
|
61740
|
+
skipFocusReset: false
|
|
61569
61741
|
})
|
|
61570
61742
|
);
|
|
61571
61743
|
}
|
|
@@ -61576,7 +61748,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61576
61748
|
setFocusMeta(view.state.tr, {
|
|
61577
61749
|
focused: false,
|
|
61578
61750
|
preservedSelection: null,
|
|
61579
|
-
showVisualSelection: false
|
|
61751
|
+
showVisualSelection: false,
|
|
61752
|
+
skipFocusReset: false
|
|
61580
61753
|
})
|
|
61581
61754
|
);
|
|
61582
61755
|
if (!selection.empty && !this.editor.options.element?.contains(target)) {
|
|
@@ -61593,12 +61766,20 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61593
61766
|
const isElement2 = target instanceof Element;
|
|
61594
61767
|
const isToolbarBtn = isElement2 && isToolbarButton(target);
|
|
61595
61768
|
const isToolbarInp = isElement2 && isToolbarInput(target);
|
|
61769
|
+
const focusState = getFocusState(view.state);
|
|
61770
|
+
if (focusState?.skipFocusReset) {
|
|
61771
|
+
view.dispatch(
|
|
61772
|
+
setFocusMeta(view.state.tr, normalizeSelectionState({ ...focusState, skipFocusReset: false }))
|
|
61773
|
+
);
|
|
61774
|
+
return false;
|
|
61775
|
+
}
|
|
61596
61776
|
if (!isToolbarBtn && !isToolbarInp) {
|
|
61597
61777
|
view.dispatch(
|
|
61598
61778
|
setFocusMeta(view.state.tr, {
|
|
61599
61779
|
focused: false,
|
|
61600
61780
|
preservedSelection: null,
|
|
61601
|
-
showVisualSelection: false
|
|
61781
|
+
showVisualSelection: false,
|
|
61782
|
+
skipFocusReset: false
|
|
61602
61783
|
})
|
|
61603
61784
|
);
|
|
61604
61785
|
}
|
|
@@ -61609,12 +61790,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61609
61790
|
const isToolbarBtn = isElement2 && isToolbarButton(target);
|
|
61610
61791
|
const isToolbarInp = isElement2 && isToolbarInput(target);
|
|
61611
61792
|
const state2 = getFocusState(view.state);
|
|
61793
|
+
if (state2?.skipFocusReset) {
|
|
61794
|
+
return false;
|
|
61795
|
+
}
|
|
61612
61796
|
if (isToolbarBtn || isToolbarInp) {
|
|
61613
61797
|
view.dispatch(
|
|
61614
61798
|
setFocusMeta(view.state.tr, {
|
|
61615
61799
|
focused: true,
|
|
61616
61800
|
preservedSelection: state2.preservedSelection || view.state.selection,
|
|
61617
|
-
showVisualSelection: true
|
|
61801
|
+
showVisualSelection: true,
|
|
61802
|
+
skipFocusReset: false
|
|
61618
61803
|
})
|
|
61619
61804
|
);
|
|
61620
61805
|
} else {
|
|
@@ -61622,7 +61807,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61622
61807
|
setFocusMeta(view.state.tr, {
|
|
61623
61808
|
focused: false,
|
|
61624
61809
|
preservedSelection: null,
|
|
61625
|
-
showVisualSelection: false
|
|
61810
|
+
showVisualSelection: false,
|
|
61811
|
+
skipFocusReset: false
|
|
61626
61812
|
})
|
|
61627
61813
|
);
|
|
61628
61814
|
}
|