@harbour-enterprises/superdoc 0.21.0-next.8 → 0.21.1
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-BR9iwva-.cjs → PdfViewer-B507M2sz.cjs} +1 -1
- package/dist/chunks/{PdfViewer-CwVW7MVJ.es.js → PdfViewer-DCKxnML6.es.js} +1 -1
- package/dist/chunks/{index-CjQDYBP2.es.js → index-DWR8syta.es.js} +40 -20
- package/dist/chunks/{index-BNA5J__D.cjs → index-djqw1MEc.cjs} +40 -20
- package/dist/chunks/{super-editor.es-C5dhT0uU.es.js → super-editor.es-D__G4K0i.es.js} +429 -115
- package/dist/chunks/{super-editor.es-Ct59l8tt.cjs → super-editor.es-HekVJogH.cjs} +429 -115
- 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/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DYAHhSrg.js → converter-B_pO-5Ls.js} +291 -67
- package/dist/super-editor/chunks/{docx-zipper-BDbCmfbE.js → docx-zipper-WaO3WaIz.js} +73 -12
- package/dist/super-editor/chunks/{editor-B1W7AdgQ.js → editor-DInvq7gF.js} +68 -30
- package/dist/super-editor/chunks/{toolbar-CCvglB_X.js → toolbar-C15EomPB.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/SuperConverter.d.ts +1 -13
- 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 -1
- package/dist/super-editor/src/utils/contextmenu-helpers.d.ts +24 -0
- package/dist/super-editor/super-editor.es.js +7 -15
- 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 +467 -133
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +2 -5
- package/dist/super-editor/src/components/slash-menu/contextmenu-helpers.d.ts +0 -1
|
@@ -24856,17 +24856,16 @@ const getParagraphSpacing = (node, docx, styleId = "", marks = [], options = {})
|
|
|
24856
24856
|
};
|
|
24857
24857
|
const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
24858
24858
|
const styles = docx["word/styles.xml"];
|
|
24859
|
-
|
|
24859
|
+
const rootElements = styles?.elements?.[0]?.elements;
|
|
24860
|
+
if (!rootElements?.length) {
|
|
24860
24861
|
return {};
|
|
24861
24862
|
}
|
|
24862
|
-
const defaults =
|
|
24863
|
-
const pDefault = defaults
|
|
24863
|
+
const defaults = rootElements.find((el) => el.name === "w:docDefaults");
|
|
24864
|
+
const pDefault = defaults?.elements?.find((el) => el.name === "w:pPrDefault") || {};
|
|
24864
24865
|
const pPrDefault = pDefault?.elements?.find((el) => el.name === "w:pPr");
|
|
24865
24866
|
const pPrDefaultSpacingTag = pPrDefault?.elements?.find((el) => el.name === "w:spacing") || {};
|
|
24866
24867
|
const pPrDefaultIndentTag = pPrDefault?.elements?.find((el) => el.name === "w:ind") || {};
|
|
24867
|
-
const stylesNormal =
|
|
24868
|
-
(el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal"
|
|
24869
|
-
);
|
|
24868
|
+
const stylesNormal = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal");
|
|
24870
24869
|
const pPrNormal = stylesNormal?.elements?.find((el) => el.name === "w:pPr");
|
|
24871
24870
|
const pPrNormalSpacingTag = pPrNormal?.elements?.find((el) => el.name === "w:spacing") || {};
|
|
24872
24871
|
const pPrNormalIndentTag = pPrNormal?.elements?.find((el) => el.name === "w:ind") || {};
|
|
@@ -24875,9 +24874,7 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
|
24875
24874
|
let pPrStyleIdIndentTag = {};
|
|
24876
24875
|
let pPrStyleJc = {};
|
|
24877
24876
|
if (styleId) {
|
|
24878
|
-
const stylesById =
|
|
24879
|
-
(el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId
|
|
24880
|
-
);
|
|
24877
|
+
const stylesById = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId);
|
|
24881
24878
|
const pPrById = stylesById?.elements?.find((el) => el.name === "w:pPr");
|
|
24882
24879
|
pPrStyleIdSpacingTag = pPrById?.elements?.find((el) => el.name === "w:spacing") || {};
|
|
24883
24880
|
pPrStyleIdIndentTag = pPrById?.elements?.find((el) => el.name === "w:ind") || {};
|
|
@@ -27180,6 +27177,68 @@ const config$a = {
|
|
|
27180
27177
|
decode: decode$h
|
|
27181
27178
|
};
|
|
27182
27179
|
const translator$a = NodeTranslator.from(config$a);
|
|
27180
|
+
const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
|
|
27181
|
+
const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
|
|
27182
|
+
const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
|
|
27183
|
+
const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
|
|
27184
|
+
const pctToPercent = (value) => {
|
|
27185
|
+
if (value == null) return null;
|
|
27186
|
+
return value / 50;
|
|
27187
|
+
};
|
|
27188
|
+
const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
|
|
27189
|
+
const resolveMeasurementWidthPx = (measurement) => {
|
|
27190
|
+
if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
|
|
27191
|
+
const { value, type: type2 } = measurement;
|
|
27192
|
+
if (!type2 || type2 === "auto") return null;
|
|
27193
|
+
if (type2 === "dxa") return twipsToPixels(value);
|
|
27194
|
+
if (type2 === "pct") {
|
|
27195
|
+
const percent2 = pctToPercent(value);
|
|
27196
|
+
if (percent2 == null || percent2 <= 0) return null;
|
|
27197
|
+
const widthTwips = resolveContentWidthTwips() * percent2 / 100;
|
|
27198
|
+
return twipsToPixels(widthTwips);
|
|
27199
|
+
}
|
|
27200
|
+
return null;
|
|
27201
|
+
};
|
|
27202
|
+
const countColumnsInRow = (row) => {
|
|
27203
|
+
if (!row?.elements?.length) return 0;
|
|
27204
|
+
return row.elements.reduce((count, element) => {
|
|
27205
|
+
if (element.name !== "w:tc") return count;
|
|
27206
|
+
const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
|
|
27207
|
+
const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
27208
|
+
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
27209
|
+
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
27210
|
+
}, 0);
|
|
27211
|
+
};
|
|
27212
|
+
const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
|
|
27213
|
+
const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
|
|
27214
|
+
const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWidthMeasurement }) => {
|
|
27215
|
+
const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
|
|
27216
|
+
const columnCount = countColumnsInRow(firstRow);
|
|
27217
|
+
if (!columnCount) return null;
|
|
27218
|
+
const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
|
|
27219
|
+
/** @type {any} */
|
|
27220
|
+
params2
|
|
27221
|
+
);
|
|
27222
|
+
const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
27223
|
+
let totalWidthPx;
|
|
27224
|
+
if (tableWidthMeasurement) {
|
|
27225
|
+
const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
|
|
27226
|
+
if (resolved != null) totalWidthPx = resolved;
|
|
27227
|
+
}
|
|
27228
|
+
if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
|
|
27229
|
+
totalWidthPx = tableWidth.width;
|
|
27230
|
+
}
|
|
27231
|
+
if (totalWidthPx == null) {
|
|
27232
|
+
totalWidthPx = minimumColumnWidthPx * columnCount;
|
|
27233
|
+
}
|
|
27234
|
+
const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
|
|
27235
|
+
const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
|
|
27236
|
+
const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
|
|
27237
|
+
return {
|
|
27238
|
+
grid: createFallbackGrid(columnCount, columnWidthTwips),
|
|
27239
|
+
columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
|
|
27240
|
+
};
|
|
27241
|
+
};
|
|
27183
27242
|
const XML_NODE_NAME$9 = "w:tbl";
|
|
27184
27243
|
const SD_NODE_NAME$9 = "table";
|
|
27185
27244
|
const encode$g = (params2, encodedAttrs) => {
|
|
@@ -27199,7 +27258,6 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
27199
27258
|
"justification",
|
|
27200
27259
|
"tableLayout",
|
|
27201
27260
|
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
27202
|
-
["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
27203
27261
|
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
27204
27262
|
].forEach((prop) => {
|
|
27205
27263
|
let key2;
|
|
@@ -27217,6 +27275,21 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
27217
27275
|
if (encodedAttrs.tableCellSpacing) {
|
|
27218
27276
|
encodedAttrs["borderCollapse"] = "separate";
|
|
27219
27277
|
}
|
|
27278
|
+
if (encodedAttrs.tableProperties?.tableWidth) {
|
|
27279
|
+
const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
|
|
27280
|
+
const widthPx = twipsToPixels(tableWidthMeasurement.value);
|
|
27281
|
+
if (widthPx != null) {
|
|
27282
|
+
encodedAttrs.tableWidth = {
|
|
27283
|
+
width: widthPx,
|
|
27284
|
+
type: tableWidthMeasurement.type
|
|
27285
|
+
};
|
|
27286
|
+
} else if (tableWidthMeasurement.type === "auto") {
|
|
27287
|
+
encodedAttrs.tableWidth = {
|
|
27288
|
+
width: 0,
|
|
27289
|
+
type: tableWidthMeasurement.type
|
|
27290
|
+
};
|
|
27291
|
+
}
|
|
27292
|
+
}
|
|
27220
27293
|
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
27221
27294
|
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
|
|
27222
27295
|
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
@@ -27230,7 +27303,19 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
27230
27303
|
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
27231
27304
|
encodedAttrs["borders"] = borderData;
|
|
27232
27305
|
const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
|
|
27233
|
-
|
|
27306
|
+
let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
|
|
27307
|
+
if (!columnWidths.length) {
|
|
27308
|
+
const fallback = buildFallbackGridForTable({
|
|
27309
|
+
params: params2,
|
|
27310
|
+
rows,
|
|
27311
|
+
tableWidth: encodedAttrs.tableWidth,
|
|
27312
|
+
tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
|
|
27313
|
+
});
|
|
27314
|
+
if (fallback) {
|
|
27315
|
+
encodedAttrs.grid = fallback.grid;
|
|
27316
|
+
columnWidths = fallback.columnWidths;
|
|
27317
|
+
}
|
|
27318
|
+
}
|
|
27234
27319
|
const content = [];
|
|
27235
27320
|
rows.forEach((row) => {
|
|
27236
27321
|
const result = translator$G.encode({
|
|
@@ -30611,6 +30696,63 @@ const config = {
|
|
|
30611
30696
|
attributes: validXmlAttributes
|
|
30612
30697
|
};
|
|
30613
30698
|
const translator = NodeTranslator.from(config);
|
|
30699
|
+
const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
|
|
30700
|
+
pageSize: Object.freeze({ width: "12240", height: "15840" }),
|
|
30701
|
+
pageMargins: Object.freeze({
|
|
30702
|
+
top: "1440",
|
|
30703
|
+
right: "1440",
|
|
30704
|
+
bottom: "1440",
|
|
30705
|
+
left: "1440",
|
|
30706
|
+
header: "720",
|
|
30707
|
+
footer: "720",
|
|
30708
|
+
gutter: "0"
|
|
30709
|
+
})
|
|
30710
|
+
});
|
|
30711
|
+
const ensureSectionLayoutDefaults = (sectPr, converter) => {
|
|
30712
|
+
if (!sectPr) {
|
|
30713
|
+
return {
|
|
30714
|
+
type: "element",
|
|
30715
|
+
name: "w:sectPr",
|
|
30716
|
+
elements: []
|
|
30717
|
+
};
|
|
30718
|
+
}
|
|
30719
|
+
if (!sectPr.elements) sectPr.elements = [];
|
|
30720
|
+
const ensureChild = (name) => {
|
|
30721
|
+
let child = sectPr.elements.find((n) => n.name === name);
|
|
30722
|
+
if (!child) {
|
|
30723
|
+
child = {
|
|
30724
|
+
type: "element",
|
|
30725
|
+
name,
|
|
30726
|
+
elements: [],
|
|
30727
|
+
attributes: {}
|
|
30728
|
+
};
|
|
30729
|
+
sectPr.elements.push(child);
|
|
30730
|
+
} else {
|
|
30731
|
+
if (!child.elements) child.elements = [];
|
|
30732
|
+
if (!child.attributes) child.attributes = {};
|
|
30733
|
+
}
|
|
30734
|
+
return child;
|
|
30735
|
+
};
|
|
30736
|
+
const pageSize = converter?.pageStyles?.pageSize;
|
|
30737
|
+
const pgSz = ensureChild("w:pgSz");
|
|
30738
|
+
if (pageSize?.width != null) pgSz.attributes["w:w"] = String(inchesToTwips(pageSize.width));
|
|
30739
|
+
if (pageSize?.height != null) pgSz.attributes["w:h"] = String(inchesToTwips(pageSize.height));
|
|
30740
|
+
if (pgSz.attributes["w:w"] == null) pgSz.attributes["w:w"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
30741
|
+
if (pgSz.attributes["w:h"] == null) pgSz.attributes["w:h"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
30742
|
+
const pageMargins = converter?.pageStyles?.pageMargins;
|
|
30743
|
+
const pgMar = ensureChild("w:pgMar");
|
|
30744
|
+
if (pageMargins) {
|
|
30745
|
+
Object.entries(pageMargins).forEach(([key2, value]) => {
|
|
30746
|
+
const converted = inchesToTwips(value);
|
|
30747
|
+
if (converted != null) pgMar.attributes[`w:${key2}`] = String(converted);
|
|
30748
|
+
});
|
|
30749
|
+
}
|
|
30750
|
+
Object.entries(DEFAULT_SECTION_PROPS_TWIPS.pageMargins).forEach(([key2, value]) => {
|
|
30751
|
+
const attrKey = `w:${key2}`;
|
|
30752
|
+
if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
|
|
30753
|
+
});
|
|
30754
|
+
return sectPr;
|
|
30755
|
+
};
|
|
30614
30756
|
const isLineBreakOnlyRun = (node) => {
|
|
30615
30757
|
if (!node) return false;
|
|
30616
30758
|
if (node.type === "lineBreak" || node.type === "hardBreak") return true;
|
|
@@ -30663,28 +30805,30 @@ function exportSchemaToJson(params2) {
|
|
|
30663
30805
|
return handler2(params2);
|
|
30664
30806
|
}
|
|
30665
30807
|
function translateBodyNode(params2) {
|
|
30666
|
-
let sectPr = params2.bodyNode?.elements
|
|
30808
|
+
let sectPr = params2.bodyNode?.elements?.find((n) => n.name === "w:sectPr");
|
|
30809
|
+
if (!sectPr) {
|
|
30810
|
+
sectPr = {
|
|
30811
|
+
type: "element",
|
|
30812
|
+
name: "w:sectPr",
|
|
30813
|
+
elements: []
|
|
30814
|
+
};
|
|
30815
|
+
} else if (!sectPr.elements) {
|
|
30816
|
+
sectPr = { ...sectPr, elements: [] };
|
|
30817
|
+
}
|
|
30818
|
+
sectPr = ensureSectionLayoutDefaults(sectPr, params2.converter);
|
|
30667
30819
|
if (params2.converter) {
|
|
30668
|
-
const hasHeader = sectPr
|
|
30820
|
+
const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
|
|
30669
30821
|
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
30670
30822
|
if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
|
|
30671
30823
|
const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
|
|
30672
30824
|
sectPr.elements.push(defaultHeader);
|
|
30673
30825
|
}
|
|
30674
|
-
const hasFooter = sectPr
|
|
30826
|
+
const hasFooter = sectPr.elements?.some((n) => n.name === "w:footerReference");
|
|
30675
30827
|
const hasDefaultFooter = params2.converter.footerIds?.default;
|
|
30676
30828
|
if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
|
|
30677
30829
|
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
30678
30830
|
sectPr.elements.push(defaultFooter);
|
|
30679
30831
|
}
|
|
30680
|
-
const newMargins = params2.converter.pageStyles.pageMargins;
|
|
30681
|
-
const sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
|
|
30682
|
-
const { attributes } = sectPrMargins;
|
|
30683
|
-
Object.entries(newMargins).forEach(([key2, value]) => {
|
|
30684
|
-
const convertedValue = inchesToTwips(value);
|
|
30685
|
-
attributes[`w:${key2}`] = convertedValue;
|
|
30686
|
-
});
|
|
30687
|
-
sectPrMargins.attributes = attributes;
|
|
30688
30832
|
}
|
|
30689
30833
|
const elements = translateChildNodes(params2);
|
|
30690
30834
|
if (params2.isHeaderFooter) {
|
|
@@ -32699,6 +32843,7 @@ const createDocumentJson = (docx, converter, editor) => {
|
|
|
32699
32843
|
const nodeListHandler = defaultNodeListHandler();
|
|
32700
32844
|
const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
|
|
32701
32845
|
if (bodyNode) {
|
|
32846
|
+
ensureSectionProperties(bodyNode);
|
|
32702
32847
|
const node = bodyNode;
|
|
32703
32848
|
const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
|
|
32704
32849
|
const content = pruneIgnoredNodes(contentElements);
|
|
@@ -32932,6 +33077,59 @@ function getDocumentStyles(node, docx, converter, editor) {
|
|
|
32932
33077
|
styles.alternateHeaders = isAlternatingHeadersOddEven(docx);
|
|
32933
33078
|
return styles;
|
|
32934
33079
|
}
|
|
33080
|
+
const DEFAULT_SECTION_PROPS = Object.freeze({
|
|
33081
|
+
pageSize: Object.freeze({ width: "12240", height: "15840" }),
|
|
33082
|
+
pageMargins: Object.freeze({
|
|
33083
|
+
top: "1440",
|
|
33084
|
+
right: "1440",
|
|
33085
|
+
bottom: "1440",
|
|
33086
|
+
left: "1440",
|
|
33087
|
+
header: "720",
|
|
33088
|
+
footer: "720",
|
|
33089
|
+
gutter: "0"
|
|
33090
|
+
})
|
|
33091
|
+
});
|
|
33092
|
+
function ensureSectionProperties(bodyNode, converter) {
|
|
33093
|
+
if (!bodyNode.elements) bodyNode.elements = [];
|
|
33094
|
+
let sectPr = bodyNode.elements.find((el) => el.name === "w:sectPr");
|
|
33095
|
+
if (!sectPr) {
|
|
33096
|
+
sectPr = {
|
|
33097
|
+
type: "element",
|
|
33098
|
+
name: "w:sectPr",
|
|
33099
|
+
elements: []
|
|
33100
|
+
};
|
|
33101
|
+
bodyNode.elements.push(sectPr);
|
|
33102
|
+
} else if (!sectPr.elements) {
|
|
33103
|
+
sectPr.elements = [];
|
|
33104
|
+
}
|
|
33105
|
+
const ensureChild = (name, factory) => {
|
|
33106
|
+
let child = sectPr.elements.find((el) => el.name === name);
|
|
33107
|
+
if (!child) {
|
|
33108
|
+
child = factory();
|
|
33109
|
+
sectPr.elements.push(child);
|
|
33110
|
+
} else if (!child.attributes) {
|
|
33111
|
+
child.attributes = {};
|
|
33112
|
+
}
|
|
33113
|
+
return child;
|
|
33114
|
+
};
|
|
33115
|
+
const pgSz = ensureChild("w:pgSz", () => ({
|
|
33116
|
+
type: "element",
|
|
33117
|
+
name: "w:pgSz",
|
|
33118
|
+
attributes: {}
|
|
33119
|
+
}));
|
|
33120
|
+
pgSz.attributes["w:w"] = pgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS.pageSize.width;
|
|
33121
|
+
pgSz.attributes["w:h"] = pgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS.pageSize.height;
|
|
33122
|
+
const pgMar = ensureChild("w:pgMar", () => ({
|
|
33123
|
+
type: "element",
|
|
33124
|
+
name: "w:pgMar",
|
|
33125
|
+
attributes: {}
|
|
33126
|
+
}));
|
|
33127
|
+
Object.entries(DEFAULT_SECTION_PROPS.pageMargins).forEach(([key2, value]) => {
|
|
33128
|
+
const attrKey = `w:${key2}`;
|
|
33129
|
+
if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
|
|
33130
|
+
});
|
|
33131
|
+
return sectPr;
|
|
33132
|
+
}
|
|
32935
33133
|
function getStyleDefinitions(docx) {
|
|
32936
33134
|
const styles = docx["word/styles.xml"];
|
|
32937
33135
|
if (!styles) return [];
|
|
@@ -33124,6 +33322,36 @@ const FONT_FAMILY_FALLBACKS = Object.freeze({
|
|
|
33124
33322
|
auto: "sans-serif"
|
|
33125
33323
|
});
|
|
33126
33324
|
const DEFAULT_GENERIC_FALLBACK = "sans-serif";
|
|
33325
|
+
const DEFAULT_FONT_SIZE_PT = 10;
|
|
33326
|
+
const collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state: state2 }) => {
|
|
33327
|
+
if (!runProps?.elements?.length || !state2) return;
|
|
33328
|
+
const fontsNode = runProps.elements.find((el) => el.name === "w:rFonts");
|
|
33329
|
+
if (fontsNode?.attributes) {
|
|
33330
|
+
const themeName = fontsNode.attributes["w:asciiTheme"];
|
|
33331
|
+
if (themeName) {
|
|
33332
|
+
const themeInfo = themeResolver?.(themeName) || {};
|
|
33333
|
+
if ((allowOverrideTypeface || !state2.typeface) && themeInfo.typeface) state2.typeface = themeInfo.typeface;
|
|
33334
|
+
if ((allowOverrideTypeface || !state2.panose) && themeInfo.panose) state2.panose = themeInfo.panose;
|
|
33335
|
+
}
|
|
33336
|
+
const ascii = fontsNode.attributes["w:ascii"];
|
|
33337
|
+
if ((allowOverrideTypeface || !state2.typeface) && ascii) {
|
|
33338
|
+
state2.typeface = ascii;
|
|
33339
|
+
}
|
|
33340
|
+
}
|
|
33341
|
+
const sizeNode = runProps.elements.find((el) => el.name === "w:sz");
|
|
33342
|
+
if (sizeNode?.attributes?.["w:val"]) {
|
|
33343
|
+
const sizeTwips = Number(sizeNode.attributes["w:val"]);
|
|
33344
|
+
if (Number.isFinite(sizeTwips)) {
|
|
33345
|
+
if (state2.fallbackSzTwips === void 0) state2.fallbackSzTwips = sizeTwips;
|
|
33346
|
+
const sizePt = sizeTwips / 2;
|
|
33347
|
+
if (allowOverrideSize || state2.fontSizePt === void 0) state2.fontSizePt = sizePt;
|
|
33348
|
+
}
|
|
33349
|
+
}
|
|
33350
|
+
const kernNode = runProps.elements.find((el) => el.name === "w:kern");
|
|
33351
|
+
if (kernNode?.attributes?.["w:val"]) {
|
|
33352
|
+
if (allowOverrideSize || state2.kern === void 0) state2.kern = kernNode.attributes["w:val"];
|
|
33353
|
+
}
|
|
33354
|
+
};
|
|
33127
33355
|
const _SuperConverter = class _SuperConverter2 {
|
|
33128
33356
|
constructor(params2 = null) {
|
|
33129
33357
|
__privateAdd$2(this, _SuperConverter_instances);
|
|
@@ -33229,7 +33457,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
33229
33457
|
return;
|
|
33230
33458
|
}
|
|
33231
33459
|
}
|
|
33232
|
-
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.
|
|
33460
|
+
static updateDocumentVersion(docx = this.convertedXml, version2 = "0.21.1") {
|
|
33233
33461
|
const customLocation = "docProps/custom.xml";
|
|
33234
33462
|
if (!docx[customLocation]) {
|
|
33235
33463
|
docx[customLocation] = generateCustomXml();
|
|
@@ -33251,49 +33479,45 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
33251
33479
|
}
|
|
33252
33480
|
getDocumentDefaultStyles() {
|
|
33253
33481
|
const styles = this.convertedXml["word/styles.xml"];
|
|
33254
|
-
|
|
33255
|
-
const
|
|
33256
|
-
|
|
33257
|
-
|
|
33258
|
-
const
|
|
33259
|
-
const
|
|
33260
|
-
|
|
33261
|
-
|
|
33262
|
-
|
|
33263
|
-
|
|
33264
|
-
|
|
33265
|
-
|
|
33266
|
-
|
|
33267
|
-
|
|
33268
|
-
|
|
33269
|
-
|
|
33270
|
-
|
|
33271
|
-
|
|
33272
|
-
|
|
33273
|
-
|
|
33274
|
-
|
|
33275
|
-
|
|
33276
|
-
|
|
33277
|
-
|
|
33278
|
-
|
|
33279
|
-
|
|
33280
|
-
|
|
33281
|
-
|
|
33282
|
-
|
|
33283
|
-
|
|
33284
|
-
|
|
33285
|
-
|
|
33286
|
-
|
|
33287
|
-
|
|
33288
|
-
|
|
33289
|
-
|
|
33290
|
-
|
|
33291
|
-
|
|
33292
|
-
|
|
33293
|
-
const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
|
|
33294
|
-
const fontFamilyCss = _SuperConverter2.toCssFontFamily(typeface, this.convertedXml);
|
|
33295
|
-
return { fontSizePt, kern, typeface, panose, fontFamilyCss };
|
|
33296
|
-
}
|
|
33482
|
+
const styleRoot = styles?.elements?.[0];
|
|
33483
|
+
const styleElements = styleRoot?.elements || [];
|
|
33484
|
+
if (!styleElements.length) return {};
|
|
33485
|
+
const defaults = styleElements.find((el) => el.name === "w:docDefaults");
|
|
33486
|
+
const normalStyle = styleElements.find((el) => el.name === "w:style" && el.attributes?.["w:styleId"] === "Normal");
|
|
33487
|
+
const defaultsState = {
|
|
33488
|
+
typeface: void 0,
|
|
33489
|
+
panose: void 0,
|
|
33490
|
+
fontSizePt: void 0,
|
|
33491
|
+
kern: void 0,
|
|
33492
|
+
fallbackSzTwips: void 0
|
|
33493
|
+
};
|
|
33494
|
+
const docDefaultRun = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
|
|
33495
|
+
const docDefaultProps = docDefaultRun?.elements?.find((el) => el.name === "w:rPr") ?? docDefaultRun;
|
|
33496
|
+
collectRunDefaultProperties(docDefaultProps, {
|
|
33497
|
+
allowOverrideTypeface: true,
|
|
33498
|
+
allowOverrideSize: true,
|
|
33499
|
+
themeResolver: (theme) => this.getThemeInfo(theme),
|
|
33500
|
+
state: defaultsState
|
|
33501
|
+
});
|
|
33502
|
+
const normalRunProps = normalStyle?.elements?.find((el) => el.name === "w:rPr") ?? null;
|
|
33503
|
+
collectRunDefaultProperties(normalRunProps, {
|
|
33504
|
+
allowOverrideTypeface: true,
|
|
33505
|
+
allowOverrideSize: true,
|
|
33506
|
+
themeResolver: (theme) => this.getThemeInfo(theme),
|
|
33507
|
+
state: defaultsState
|
|
33508
|
+
});
|
|
33509
|
+
if (defaultsState.fontSizePt === void 0) {
|
|
33510
|
+
if (Number.isFinite(defaultsState.fallbackSzTwips)) defaultsState.fontSizePt = defaultsState.fallbackSzTwips / 2;
|
|
33511
|
+
else defaultsState.fontSizePt = DEFAULT_FONT_SIZE_PT;
|
|
33512
|
+
}
|
|
33513
|
+
const fontFamilyCss = defaultsState.typeface ? _SuperConverter2.toCssFontFamily(defaultsState.typeface, this.convertedXml) : void 0;
|
|
33514
|
+
const result = {};
|
|
33515
|
+
if (defaultsState.fontSizePt !== void 0) result.fontSizePt = defaultsState.fontSizePt;
|
|
33516
|
+
if (defaultsState.kern !== void 0) result.kern = defaultsState.kern;
|
|
33517
|
+
if (defaultsState.typeface) result.typeface = defaultsState.typeface;
|
|
33518
|
+
if (defaultsState.panose) result.panose = defaultsState.panose;
|
|
33519
|
+
if (fontFamilyCss) result.fontFamilyCss = fontFamilyCss;
|
|
33520
|
+
return result;
|
|
33297
33521
|
}
|
|
33298
33522
|
getDocumentFonts() {
|
|
33299
33523
|
const fontTable = this.convertedXml["word/fontTable.xml"];
|
|
@@ -33722,7 +33946,7 @@ function storeSuperdocVersion(docx) {
|
|
|
33722
33946
|
function generateCustomXml() {
|
|
33723
33947
|
return DEFAULT_CUSTOM_XML;
|
|
33724
33948
|
}
|
|
33725
|
-
function generateSuperdocVersion(pid = 2, version2 = "0.
|
|
33949
|
+
function generateSuperdocVersion(pid = 2, version2 = "0.21.1") {
|
|
33726
33950
|
return {
|
|
33727
33951
|
type: "element",
|
|
33728
33952
|
name: "property",
|
|
@@ -36160,14 +36384,19 @@ class DocxZipper {
|
|
|
36160
36384
|
/**
|
|
36161
36385
|
* Update [Content_Types].xml with extensions of new Image annotations
|
|
36162
36386
|
*/
|
|
36163
|
-
async updateContentTypes(docx, media, fromJson) {
|
|
36387
|
+
async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
|
|
36388
|
+
const additionalPartNames = Object.keys(updatedDocs || {});
|
|
36164
36389
|
const newMediaTypes = Object.keys(media).map((name) => {
|
|
36165
36390
|
return this.getFileExtension(name);
|
|
36166
36391
|
}).filter(Boolean);
|
|
36167
36392
|
const contentTypesPath = "[Content_Types].xml";
|
|
36168
36393
|
let contentTypesXml;
|
|
36169
36394
|
if (fromJson) {
|
|
36170
|
-
|
|
36395
|
+
if (Array.isArray(docx.files)) {
|
|
36396
|
+
contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
|
|
36397
|
+
} else {
|
|
36398
|
+
contentTypesXml = docx.files?.[contentTypesPath] || "";
|
|
36399
|
+
}
|
|
36171
36400
|
} else contentTypesXml = await docx.file(contentTypesPath).async("string");
|
|
36172
36401
|
let typesString = "";
|
|
36173
36402
|
const defaultMediaTypes = getContentTypesFromXml(contentTypesXml);
|
|
@@ -36193,24 +36422,39 @@ class DocxZipper {
|
|
|
36193
36422
|
const hasCommentsExtensible = types2.elements?.some(
|
|
36194
36423
|
(el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtensible.xml"
|
|
36195
36424
|
);
|
|
36196
|
-
|
|
36425
|
+
const hasFile = (filename) => {
|
|
36426
|
+
if (!docx?.files) return false;
|
|
36427
|
+
if (!fromJson) return Boolean(docx.files[filename]);
|
|
36428
|
+
if (Array.isArray(docx.files)) return docx.files.some((file) => file.name === filename);
|
|
36429
|
+
return Boolean(docx.files[filename]);
|
|
36430
|
+
};
|
|
36431
|
+
if (hasFile("word/comments.xml")) {
|
|
36197
36432
|
const commentsDef = `<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />`;
|
|
36198
36433
|
if (!hasComments) typesString += commentsDef;
|
|
36199
36434
|
}
|
|
36200
|
-
if (
|
|
36435
|
+
if (hasFile("word/commentsExtended.xml")) {
|
|
36201
36436
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />`;
|
|
36202
36437
|
if (!hasCommentsExtended) typesString += commentsExtendedDef;
|
|
36203
36438
|
}
|
|
36204
|
-
if (
|
|
36439
|
+
if (hasFile("word/commentsIds.xml")) {
|
|
36205
36440
|
const commentsIdsDef = `<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />`;
|
|
36206
36441
|
if (!hasCommentsIds) typesString += commentsIdsDef;
|
|
36207
36442
|
}
|
|
36208
|
-
if (
|
|
36443
|
+
if (hasFile("word/commentsExtensible.xml")) {
|
|
36209
36444
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
|
|
36210
36445
|
if (!hasCommentsExtensible) typesString += commentsExtendedDef;
|
|
36211
36446
|
}
|
|
36212
|
-
|
|
36213
|
-
|
|
36447
|
+
const partNames = new Set(additionalPartNames);
|
|
36448
|
+
if (docx?.files) {
|
|
36449
|
+
if (fromJson && Array.isArray(docx.files)) {
|
|
36450
|
+
docx.files.forEach((file) => partNames.add(file.name));
|
|
36451
|
+
} else {
|
|
36452
|
+
Object.keys(docx.files).forEach((key2) => partNames.add(key2));
|
|
36453
|
+
}
|
|
36454
|
+
}
|
|
36455
|
+
partNames.forEach((name) => {
|
|
36456
|
+
if (name.includes(".rels")) return;
|
|
36457
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
36214
36458
|
const hasExtensible = types2.elements?.some(
|
|
36215
36459
|
(el) => el.name === "Override" && el.attributes.PartName === `/${name}`
|
|
36216
36460
|
);
|
|
@@ -36221,7 +36465,48 @@ class DocxZipper {
|
|
|
36221
36465
|
}
|
|
36222
36466
|
});
|
|
36223
36467
|
const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
|
36224
|
-
|
|
36468
|
+
let updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
|
|
36469
|
+
let relationshipsXml = updatedDocs["word/_rels/document.xml.rels"];
|
|
36470
|
+
if (!relationshipsXml) {
|
|
36471
|
+
if (fromJson) {
|
|
36472
|
+
if (Array.isArray(docx.files)) {
|
|
36473
|
+
relationshipsXml = docx.files.find((file) => file.name === "word/_rels/document.xml.rels")?.content;
|
|
36474
|
+
} else {
|
|
36475
|
+
relationshipsXml = docx.files?.["word/_rels/document.xml.rels"];
|
|
36476
|
+
}
|
|
36477
|
+
} else {
|
|
36478
|
+
relationshipsXml = await docx.file("word/_rels/document.xml.rels")?.async("string");
|
|
36479
|
+
}
|
|
36480
|
+
}
|
|
36481
|
+
if (relationshipsXml) {
|
|
36482
|
+
try {
|
|
36483
|
+
const relJson = xmljs.xml2js(relationshipsXml, { compact: false });
|
|
36484
|
+
const relationships = relJson.elements?.find((el) => el.name === "Relationships");
|
|
36485
|
+
relationships?.elements?.forEach((rel) => {
|
|
36486
|
+
const type2 = rel.attributes?.Type;
|
|
36487
|
+
const target = rel.attributes?.Target;
|
|
36488
|
+
if (!type2 || !target) return;
|
|
36489
|
+
const isHeader = type2.includes("/header");
|
|
36490
|
+
const isFooter = type2.includes("/footer");
|
|
36491
|
+
if (!isHeader && !isFooter) return;
|
|
36492
|
+
let sanitizedTarget = target.replace(/^\.\//, "");
|
|
36493
|
+
if (sanitizedTarget.startsWith("../")) sanitizedTarget = sanitizedTarget.slice(3);
|
|
36494
|
+
if (sanitizedTarget.startsWith("/")) sanitizedTarget = sanitizedTarget.slice(1);
|
|
36495
|
+
const partName = sanitizedTarget.startsWith("word/") ? sanitizedTarget : `word/${sanitizedTarget}`;
|
|
36496
|
+
partNames.add(partName);
|
|
36497
|
+
});
|
|
36498
|
+
} catch (error) {
|
|
36499
|
+
console.warn("Failed to parse document relationships while updating content types", error);
|
|
36500
|
+
}
|
|
36501
|
+
}
|
|
36502
|
+
partNames.forEach((name) => {
|
|
36503
|
+
if (name.includes(".rels")) return;
|
|
36504
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
36505
|
+
if (updatedContentTypesXml.includes(`PartName="/${name}"`)) return;
|
|
36506
|
+
const type2 = name.includes("header") ? "header" : "footer";
|
|
36507
|
+
const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type2}+xml"/>`;
|
|
36508
|
+
updatedContentTypesXml = updatedContentTypesXml.replace("</Types>", `${extendedDef}</Types>`);
|
|
36509
|
+
});
|
|
36225
36510
|
if (fromJson) return updatedContentTypesXml;
|
|
36226
36511
|
docx.file(contentTypesPath, updatedContentTypesXml);
|
|
36227
36512
|
}
|
|
@@ -36262,7 +36547,7 @@ class DocxZipper {
|
|
|
36262
36547
|
for (const [fontName, fontUintArray] of Object.entries(fonts)) {
|
|
36263
36548
|
zip.file(fontName, fontUintArray);
|
|
36264
36549
|
}
|
|
36265
|
-
await this.updateContentTypes(zip, media);
|
|
36550
|
+
await this.updateContentTypes(zip, media, false, updatedDocs);
|
|
36266
36551
|
return zip;
|
|
36267
36552
|
}
|
|
36268
36553
|
/**
|
|
@@ -36288,7 +36573,7 @@ class DocxZipper {
|
|
|
36288
36573
|
Object.keys(media).forEach((path) => {
|
|
36289
36574
|
unzippedOriginalDocx.file(path, media[path]);
|
|
36290
36575
|
});
|
|
36291
|
-
await this.updateContentTypes(unzippedOriginalDocx, media);
|
|
36576
|
+
await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
|
|
36292
36577
|
return unzippedOriginalDocx;
|
|
36293
36578
|
}
|
|
36294
36579
|
}
|
|
@@ -47946,9 +48231,11 @@ const toggleHeaderFooterEditMode = ({ editor, focusedSectionEditor, isEditMode,
|
|
|
47946
48231
|
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
47947
48232
|
});
|
|
47948
48233
|
if (isEditMode) {
|
|
47949
|
-
const pm =
|
|
47950
|
-
pm
|
|
47951
|
-
|
|
48234
|
+
const pm = editor.view?.dom || editor.options.element?.querySelector?.(".ProseMirror");
|
|
48235
|
+
if (pm) {
|
|
48236
|
+
pm.classList.add("header-footer-edit");
|
|
48237
|
+
pm.setAttribute("aria-readonly", true);
|
|
48238
|
+
}
|
|
47952
48239
|
}
|
|
47953
48240
|
if (focusedSectionEditor) {
|
|
47954
48241
|
focusedSectionEditor.view.focus();
|
|
@@ -48978,6 +49265,7 @@ const generateTableIfNecessary = ({ tableNode, annotationValues, tr, state: stat
|
|
|
48978
49265
|
const mappedRowStart = tr.mapping.map(absoluteRowStart);
|
|
48979
49266
|
const rowEnd = mappedRowStart + rowNode.nodeSize;
|
|
48980
49267
|
tr.replaceWith(mappedRowStart, rowEnd, Fragment.from(newRows));
|
|
49268
|
+
tr.setMeta("tableGeneration", true);
|
|
48981
49269
|
} catch (error) {
|
|
48982
49270
|
console.error("Error during row generation:", error);
|
|
48983
49271
|
throw error;
|
|
@@ -49382,7 +49670,7 @@ function findFieldAnnotationsBetween(from2, to, doc2) {
|
|
|
49382
49670
|
}
|
|
49383
49671
|
function findRemovedFieldAnnotations(tr) {
|
|
49384
49672
|
let removedNodes = [];
|
|
49385
|
-
if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => ["inputType", "uiEvent", "paste"].includes(meta)) || ["historyUndo", "historyRedo"].includes(tr.getMeta("inputType")) || ["drop"].includes(tr.getMeta("uiEvent")) || tr.getMeta("fieldAnnotationUpdate") === true) {
|
|
49673
|
+
if (!tr.steps.length || tr.meta && !Object.keys(tr.meta).every((meta) => ["inputType", "uiEvent", "paste"].includes(meta)) || ["historyUndo", "historyRedo"].includes(tr.getMeta("inputType")) || ["drop"].includes(tr.getMeta("uiEvent")) || tr.getMeta("fieldAnnotationUpdate") === true || tr.getMeta("tableGeneration") === true) {
|
|
49386
49674
|
return removedNodes;
|
|
49387
49675
|
}
|
|
49388
49676
|
const hasDeletion = transactionDeletedAnything(tr);
|
|
@@ -50560,7 +50848,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
50560
50848
|
setDocumentMode(documentMode) {
|
|
50561
50849
|
let cleanedMode = documentMode?.toLowerCase() || "editing";
|
|
50562
50850
|
if (!this.extensionService || !this.state) return;
|
|
50563
|
-
const pm =
|
|
50851
|
+
const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
|
|
50564
50852
|
if (this.options.role === "viewer") cleanedMode = "viewing";
|
|
50565
50853
|
if (this.options.role === "suggester" && cleanedMode === "editing") cleanedMode = "suggesting";
|
|
50566
50854
|
if (cleanedMode === "viewing") {
|
|
@@ -51048,7 +51336,8 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
51048
51336
|
files: this.options.content
|
|
51049
51337
|
},
|
|
51050
51338
|
media,
|
|
51051
|
-
true
|
|
51339
|
+
true,
|
|
51340
|
+
updatedDocs
|
|
51052
51341
|
);
|
|
51053
51342
|
return updatedDocs;
|
|
51054
51343
|
}
|
|
@@ -51114,7 +51403,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
51114
51403
|
* @returns {Object | void} Migration results
|
|
51115
51404
|
*/
|
|
51116
51405
|
processCollaborationMigrations() {
|
|
51117
|
-
console.debug("[checkVersionMigrations] Current editor version", "0.
|
|
51406
|
+
console.debug("[checkVersionMigrations] Current editor version", "0.21.1");
|
|
51118
51407
|
if (!this.options.ydoc) return;
|
|
51119
51408
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
51120
51409
|
let docVersion = metaMap.get("version");
|
|
@@ -51534,9 +51823,11 @@ createView_fn = function(element) {
|
|
|
51534
51823
|
isEditMode: false,
|
|
51535
51824
|
documentMode: this.options.documentMode
|
|
51536
51825
|
});
|
|
51537
|
-
const pm =
|
|
51538
|
-
pm
|
|
51539
|
-
|
|
51826
|
+
const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
|
|
51827
|
+
if (pm) {
|
|
51828
|
+
pm.classList.remove("header-footer-edit");
|
|
51829
|
+
pm.setAttribute("aria-readonly", false);
|
|
51830
|
+
}
|
|
51540
51831
|
}
|
|
51541
51832
|
setWordSelection(view, pos);
|
|
51542
51833
|
}
|
|
@@ -53591,15 +53882,31 @@ const intToJapaneseCounting = (num) => {
|
|
|
53591
53882
|
}
|
|
53592
53883
|
return result;
|
|
53593
53884
|
};
|
|
53594
|
-
const
|
|
53595
|
-
|
|
53885
|
+
const isKeyboardInvocation = (event) => {
|
|
53886
|
+
return event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === void 0) && event.clientX === 0 && event.clientY === 0;
|
|
53887
|
+
};
|
|
53888
|
+
const prefersNativeMenu = (event) => {
|
|
53596
53889
|
if (!event) return false;
|
|
53597
53890
|
if (event.ctrlKey || event.metaKey) {
|
|
53598
53891
|
return true;
|
|
53599
53892
|
}
|
|
53600
|
-
|
|
53601
|
-
return Boolean(isKeyboardInvocation);
|
|
53893
|
+
return isKeyboardInvocation(event);
|
|
53602
53894
|
};
|
|
53895
|
+
const shouldAllowNativeContextMenu = (event) => {
|
|
53896
|
+
return prefersNativeMenu(event);
|
|
53897
|
+
};
|
|
53898
|
+
const shouldBypassContextMenu = shouldAllowNativeContextMenu;
|
|
53899
|
+
const DEFAULT_SELECTION_STATE = Object.freeze({
|
|
53900
|
+
focused: false,
|
|
53901
|
+
preservedSelection: null,
|
|
53902
|
+
showVisualSelection: false,
|
|
53903
|
+
skipFocusReset: false
|
|
53904
|
+
});
|
|
53905
|
+
const normalizeSelectionState = (state2 = {}) => ({
|
|
53906
|
+
...DEFAULT_SELECTION_STATE,
|
|
53907
|
+
...state2
|
|
53908
|
+
});
|
|
53909
|
+
const CustomSelectionPluginKey = new PluginKey("CustomSelection");
|
|
53603
53910
|
const handleClickOutside = (event, editor) => {
|
|
53604
53911
|
const editorElem = editor?.options?.element;
|
|
53605
53912
|
if (!editorElem) return;
|
|
@@ -53636,11 +53943,7 @@ const CustomSelection = Extension.create({
|
|
|
53636
53943
|
const customSelectionPlugin = new Plugin({
|
|
53637
53944
|
key: CustomSelectionPluginKey,
|
|
53638
53945
|
state: {
|
|
53639
|
-
init: () => ({
|
|
53640
|
-
focused: false,
|
|
53641
|
-
preservedSelection: null,
|
|
53642
|
-
showVisualSelection: false
|
|
53643
|
-
}),
|
|
53946
|
+
init: () => ({ ...DEFAULT_SELECTION_STATE }),
|
|
53644
53947
|
apply: (tr, value) => {
|
|
53645
53948
|
const meta = getFocusMeta(tr);
|
|
53646
53949
|
if (meta !== void 0) {
|
|
@@ -53671,7 +53974,8 @@ const CustomSelection = Extension.create({
|
|
|
53671
53974
|
setFocusMeta(view.state.tr, {
|
|
53672
53975
|
focused: true,
|
|
53673
53976
|
preservedSelection: selection,
|
|
53674
|
-
showVisualSelection: true
|
|
53977
|
+
showVisualSelection: true,
|
|
53978
|
+
skipFocusReset: true
|
|
53675
53979
|
})
|
|
53676
53980
|
);
|
|
53677
53981
|
}
|
|
@@ -53692,7 +53996,8 @@ const CustomSelection = Extension.create({
|
|
|
53692
53996
|
setFocusMeta(view.state.tr, {
|
|
53693
53997
|
focused: true,
|
|
53694
53998
|
preservedSelection: selection2,
|
|
53695
|
-
showVisualSelection: true
|
|
53999
|
+
showVisualSelection: true,
|
|
54000
|
+
skipFocusReset: true
|
|
53696
54001
|
})
|
|
53697
54002
|
);
|
|
53698
54003
|
this.editor.setOptions({
|
|
@@ -53715,7 +54020,8 @@ const CustomSelection = Extension.create({
|
|
|
53715
54020
|
setFocusMeta(view.state.tr, {
|
|
53716
54021
|
focused: true,
|
|
53717
54022
|
preservedSelection: selection,
|
|
53718
|
-
showVisualSelection: true
|
|
54023
|
+
showVisualSelection: true,
|
|
54024
|
+
skipFocusReset: false
|
|
53719
54025
|
})
|
|
53720
54026
|
);
|
|
53721
54027
|
this.editor.setOptions({
|
|
@@ -53733,7 +54039,8 @@ const CustomSelection = Extension.create({
|
|
|
53733
54039
|
setFocusMeta(view.state.tr, {
|
|
53734
54040
|
focused: true,
|
|
53735
54041
|
preservedSelection: selection,
|
|
53736
|
-
showVisualSelection: true
|
|
54042
|
+
showVisualSelection: true,
|
|
54043
|
+
skipFocusReset: false
|
|
53737
54044
|
})
|
|
53738
54045
|
);
|
|
53739
54046
|
}
|
|
@@ -53744,7 +54051,8 @@ const CustomSelection = Extension.create({
|
|
|
53744
54051
|
setFocusMeta(view.state.tr, {
|
|
53745
54052
|
focused: false,
|
|
53746
54053
|
preservedSelection: null,
|
|
53747
|
-
showVisualSelection: false
|
|
54054
|
+
showVisualSelection: false,
|
|
54055
|
+
skipFocusReset: false
|
|
53748
54056
|
})
|
|
53749
54057
|
);
|
|
53750
54058
|
if (!selection.empty && !this.editor.options.element?.contains(target)) {
|
|
@@ -53761,12 +54069,20 @@ const CustomSelection = Extension.create({
|
|
|
53761
54069
|
const isElement2 = target instanceof Element;
|
|
53762
54070
|
const isToolbarBtn = isElement2 && isToolbarButton(target);
|
|
53763
54071
|
const isToolbarInp = isElement2 && isToolbarInput(target);
|
|
54072
|
+
const focusState = getFocusState(view.state);
|
|
54073
|
+
if (focusState?.skipFocusReset) {
|
|
54074
|
+
view.dispatch(
|
|
54075
|
+
setFocusMeta(view.state.tr, normalizeSelectionState({ ...focusState, skipFocusReset: false }))
|
|
54076
|
+
);
|
|
54077
|
+
return false;
|
|
54078
|
+
}
|
|
53764
54079
|
if (!isToolbarBtn && !isToolbarInp) {
|
|
53765
54080
|
view.dispatch(
|
|
53766
54081
|
setFocusMeta(view.state.tr, {
|
|
53767
54082
|
focused: false,
|
|
53768
54083
|
preservedSelection: null,
|
|
53769
|
-
showVisualSelection: false
|
|
54084
|
+
showVisualSelection: false,
|
|
54085
|
+
skipFocusReset: false
|
|
53770
54086
|
})
|
|
53771
54087
|
);
|
|
53772
54088
|
}
|
|
@@ -53777,12 +54093,16 @@ const CustomSelection = Extension.create({
|
|
|
53777
54093
|
const isToolbarBtn = isElement2 && isToolbarButton(target);
|
|
53778
54094
|
const isToolbarInp = isElement2 && isToolbarInput(target);
|
|
53779
54095
|
const state2 = getFocusState(view.state);
|
|
54096
|
+
if (state2?.skipFocusReset) {
|
|
54097
|
+
return false;
|
|
54098
|
+
}
|
|
53780
54099
|
if (isToolbarBtn || isToolbarInp) {
|
|
53781
54100
|
view.dispatch(
|
|
53782
54101
|
setFocusMeta(view.state.tr, {
|
|
53783
54102
|
focused: true,
|
|
53784
54103
|
preservedSelection: state2.preservedSelection || view.state.selection,
|
|
53785
|
-
showVisualSelection: true
|
|
54104
|
+
showVisualSelection: true,
|
|
54105
|
+
skipFocusReset: false
|
|
53786
54106
|
})
|
|
53787
54107
|
);
|
|
53788
54108
|
} else {
|
|
@@ -53790,7 +54110,8 @@ const CustomSelection = Extension.create({
|
|
|
53790
54110
|
setFocusMeta(view.state.tr, {
|
|
53791
54111
|
focused: false,
|
|
53792
54112
|
preservedSelection: null,
|
|
53793
|
-
showVisualSelection: false
|
|
54113
|
+
showVisualSelection: false,
|
|
54114
|
+
skipFocusReset: false
|
|
53794
54115
|
})
|
|
53795
54116
|
);
|
|
53796
54117
|
}
|
|
@@ -69565,7 +69886,8 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
69565
69886
|
const prevSelection = prevState.selection;
|
|
69566
69887
|
if (selection.from !== prevSelection.from || selection.to !== prevSelection.to) {
|
|
69567
69888
|
setTimeout(() => {
|
|
69568
|
-
const
|
|
69889
|
+
const searchRoot = editorView?.dom;
|
|
69890
|
+
const selectedResizableWrapper = searchRoot?.querySelector(".sd-editor-resizable-wrapper");
|
|
69569
69891
|
if (selectedResizableWrapper) {
|
|
69570
69892
|
showResizeHandles(view2, selectedResizableWrapper);
|
|
69571
69893
|
} else {
|
|
@@ -83101,7 +83423,7 @@ class SuperToolbar extends EventEmitter2 {
|
|
|
83101
83423
|
if (!argument) return;
|
|
83102
83424
|
item.onActivate({ zoom: argument });
|
|
83103
83425
|
this.emit("superdoc-command", { item, argument });
|
|
83104
|
-
const layers =
|
|
83426
|
+
const layers = this.superdoc.element?.querySelector(".layers");
|
|
83105
83427
|
if (!layers) return;
|
|
83106
83428
|
const isMobileDevice = typeof screen.orientation !== "undefined";
|
|
83107
83429
|
const isSmallScreen = window.matchMedia("(max-width: 834px)").matches;
|
|
@@ -84163,14 +84485,6 @@ function getStructureFromResolvedPos(state2, pos) {
|
|
|
84163
84485
|
return null;
|
|
84164
84486
|
}
|
|
84165
84487
|
}
|
|
84166
|
-
const shouldBypassContextMenu = (event) => {
|
|
84167
|
-
if (!event) return false;
|
|
84168
|
-
if (event.ctrlKey || event.metaKey) {
|
|
84169
|
-
return true;
|
|
84170
|
-
}
|
|
84171
|
-
const isKeyboardInvocation = event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === void 0) && event.clientX === 0 && event.clientY === 0;
|
|
84172
|
-
return Boolean(isKeyboardInvocation);
|
|
84173
|
-
};
|
|
84174
84488
|
const isModuleEnabled = (editorOptions, moduleName) => {
|
|
84175
84489
|
switch (moduleName) {
|
|
84176
84490
|
case "ai":
|