@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
|
@@ -27160,6 +27160,68 @@ const config$a = {
|
|
|
27160
27160
|
decode: decode$h
|
|
27161
27161
|
};
|
|
27162
27162
|
const translator$a = NodeTranslator.from(config$a);
|
|
27163
|
+
const DEFAULT_PAGE_WIDTH_TWIPS = 12240;
|
|
27164
|
+
const DEFAULT_PAGE_MARGIN_TWIPS = 1440;
|
|
27165
|
+
const DEFAULT_CONTENT_WIDTH_TWIPS = DEFAULT_PAGE_WIDTH_TWIPS - 2 * DEFAULT_PAGE_MARGIN_TWIPS;
|
|
27166
|
+
const MIN_COLUMN_WIDTH_TWIPS = pixelsToTwips(10);
|
|
27167
|
+
const pctToPercent = (value) => {
|
|
27168
|
+
if (value == null) return null;
|
|
27169
|
+
return value / 50;
|
|
27170
|
+
};
|
|
27171
|
+
const resolveContentWidthTwips = () => DEFAULT_CONTENT_WIDTH_TWIPS;
|
|
27172
|
+
const resolveMeasurementWidthPx = (measurement) => {
|
|
27173
|
+
if (!measurement || typeof measurement.value !== "number" || measurement.value <= 0) return null;
|
|
27174
|
+
const { value, type: type2 } = measurement;
|
|
27175
|
+
if (!type2 || type2 === "auto") return null;
|
|
27176
|
+
if (type2 === "dxa") return twipsToPixels(value);
|
|
27177
|
+
if (type2 === "pct") {
|
|
27178
|
+
const percent2 = pctToPercent(value);
|
|
27179
|
+
if (percent2 == null || percent2 <= 0) return null;
|
|
27180
|
+
const widthTwips = resolveContentWidthTwips() * percent2 / 100;
|
|
27181
|
+
return twipsToPixels(widthTwips);
|
|
27182
|
+
}
|
|
27183
|
+
return null;
|
|
27184
|
+
};
|
|
27185
|
+
const countColumnsInRow = (row) => {
|
|
27186
|
+
if (!row?.elements?.length) return 0;
|
|
27187
|
+
return row.elements.reduce((count, element) => {
|
|
27188
|
+
if (element.name !== "w:tc") return count;
|
|
27189
|
+
const tcPr = element.elements?.find((el) => el.name === "w:tcPr");
|
|
27190
|
+
const gridSpan = tcPr?.elements?.find((el) => el.name === "w:gridSpan");
|
|
27191
|
+
const spanValue = parseInt(gridSpan?.attributes?.["w:val"] || "1", 10);
|
|
27192
|
+
return count + (Number.isFinite(spanValue) && spanValue > 0 ? spanValue : 1);
|
|
27193
|
+
}, 0);
|
|
27194
|
+
};
|
|
27195
|
+
const clampColumnWidthTwips = (value) => Math.max(Math.round(value), MIN_COLUMN_WIDTH_TWIPS);
|
|
27196
|
+
const createFallbackGrid = (columnCount, columnWidthTwips) => Array.from({ length: columnCount }, () => ({ col: clampColumnWidthTwips(columnWidthTwips) }));
|
|
27197
|
+
const buildFallbackGridForTable = ({ params: params2, rows, tableWidth, tableWidthMeasurement }) => {
|
|
27198
|
+
const firstRow = rows.find((row) => row.elements?.some((el) => el.name === "w:tc"));
|
|
27199
|
+
const columnCount = countColumnsInRow(firstRow);
|
|
27200
|
+
if (!columnCount) return null;
|
|
27201
|
+
const schemaDefaultPx = getSchemaDefaultColumnWidthPx(
|
|
27202
|
+
/** @type {any} */
|
|
27203
|
+
params2
|
|
27204
|
+
);
|
|
27205
|
+
const minimumColumnWidthPx = Number.isFinite(schemaDefaultPx) && schemaDefaultPx > 0 ? schemaDefaultPx : DEFAULT_COLUMN_WIDTH_PX;
|
|
27206
|
+
let totalWidthPx;
|
|
27207
|
+
if (tableWidthMeasurement) {
|
|
27208
|
+
const resolved = resolveMeasurementWidthPx(tableWidthMeasurement);
|
|
27209
|
+
if (resolved != null) totalWidthPx = resolved;
|
|
27210
|
+
}
|
|
27211
|
+
if (totalWidthPx == null && tableWidth?.width && tableWidth.width > 0) {
|
|
27212
|
+
totalWidthPx = tableWidth.width;
|
|
27213
|
+
}
|
|
27214
|
+
if (totalWidthPx == null) {
|
|
27215
|
+
totalWidthPx = minimumColumnWidthPx * columnCount;
|
|
27216
|
+
}
|
|
27217
|
+
const rawColumnWidthPx = Math.max(totalWidthPx / columnCount, minimumColumnWidthPx);
|
|
27218
|
+
const columnWidthTwips = clampColumnWidthTwips(pixelsToTwips(rawColumnWidthPx));
|
|
27219
|
+
const fallbackColumnWidthPx = twipsToPixels(columnWidthTwips);
|
|
27220
|
+
return {
|
|
27221
|
+
grid: createFallbackGrid(columnCount, columnWidthTwips),
|
|
27222
|
+
columnWidths: Array(columnCount).fill(fallbackColumnWidthPx)
|
|
27223
|
+
};
|
|
27224
|
+
};
|
|
27163
27225
|
const XML_NODE_NAME$9 = "w:tbl";
|
|
27164
27226
|
const SD_NODE_NAME$9 = "table";
|
|
27165
27227
|
const encode$g = (params2, encodedAttrs) => {
|
|
@@ -27179,7 +27241,6 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
27179
27241
|
"justification",
|
|
27180
27242
|
"tableLayout",
|
|
27181
27243
|
["tableIndent", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
27182
|
-
["tableWidth", ({ value, type: type2 }) => ({ width: twipsToPixels(value), type: type2 })],
|
|
27183
27244
|
["tableCellSpacing", ({ value, type: type2 }) => ({ w: String(value), type: type2 })]
|
|
27184
27245
|
].forEach((prop) => {
|
|
27185
27246
|
let key2;
|
|
@@ -27197,6 +27258,21 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
27197
27258
|
if (encodedAttrs.tableCellSpacing) {
|
|
27198
27259
|
encodedAttrs["borderCollapse"] = "separate";
|
|
27199
27260
|
}
|
|
27261
|
+
if (encodedAttrs.tableProperties?.tableWidth) {
|
|
27262
|
+
const tableWidthMeasurement = encodedAttrs.tableProperties.tableWidth;
|
|
27263
|
+
const widthPx = twipsToPixels(tableWidthMeasurement.value);
|
|
27264
|
+
if (widthPx != null) {
|
|
27265
|
+
encodedAttrs.tableWidth = {
|
|
27266
|
+
width: widthPx,
|
|
27267
|
+
type: tableWidthMeasurement.type
|
|
27268
|
+
};
|
|
27269
|
+
} else if (tableWidthMeasurement.type === "auto") {
|
|
27270
|
+
encodedAttrs.tableWidth = {
|
|
27271
|
+
width: 0,
|
|
27272
|
+
type: tableWidthMeasurement.type
|
|
27273
|
+
};
|
|
27274
|
+
}
|
|
27275
|
+
}
|
|
27200
27276
|
const { borders, rowBorders } = _processTableBorders(encodedAttrs.tableProperties?.borders || {});
|
|
27201
27277
|
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2);
|
|
27202
27278
|
if (referencedStyles?.cellMargins && !encodedAttrs.tableProperties?.cellMargins) {
|
|
@@ -27210,7 +27286,19 @@ const encode$g = (params2, encodedAttrs) => {
|
|
|
27210
27286
|
const borderRowData = Object.assign({}, referencedStyles?.rowBorders || {}, rowBorders || {});
|
|
27211
27287
|
encodedAttrs["borders"] = borderData;
|
|
27212
27288
|
const tblStyleTag = tblPr?.elements?.find((el) => el.name === "w:tblStyle");
|
|
27213
|
-
|
|
27289
|
+
let columnWidths = Array.isArray(encodedAttrs["grid"]) ? encodedAttrs["grid"].map((item) => twipsToPixels(item.col)) : [];
|
|
27290
|
+
if (!columnWidths.length) {
|
|
27291
|
+
const fallback = buildFallbackGridForTable({
|
|
27292
|
+
params: params2,
|
|
27293
|
+
rows,
|
|
27294
|
+
tableWidth: encodedAttrs.tableWidth,
|
|
27295
|
+
tableWidthMeasurement: encodedAttrs.tableProperties?.tableWidth
|
|
27296
|
+
});
|
|
27297
|
+
if (fallback) {
|
|
27298
|
+
encodedAttrs.grid = fallback.grid;
|
|
27299
|
+
columnWidths = fallback.columnWidths;
|
|
27300
|
+
}
|
|
27301
|
+
}
|
|
27214
27302
|
const content = [];
|
|
27215
27303
|
rows.forEach((row) => {
|
|
27216
27304
|
const result = translator$G.encode({
|
|
@@ -30603,6 +30691,51 @@ const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
|
|
|
30603
30691
|
gutter: "0"
|
|
30604
30692
|
})
|
|
30605
30693
|
});
|
|
30694
|
+
const ensureSectionLayoutDefaults = (sectPr, converter) => {
|
|
30695
|
+
if (!sectPr) {
|
|
30696
|
+
return {
|
|
30697
|
+
type: "element",
|
|
30698
|
+
name: "w:sectPr",
|
|
30699
|
+
elements: []
|
|
30700
|
+
};
|
|
30701
|
+
}
|
|
30702
|
+
if (!sectPr.elements) sectPr.elements = [];
|
|
30703
|
+
const ensureChild = (name) => {
|
|
30704
|
+
let child = sectPr.elements.find((n) => n.name === name);
|
|
30705
|
+
if (!child) {
|
|
30706
|
+
child = {
|
|
30707
|
+
type: "element",
|
|
30708
|
+
name,
|
|
30709
|
+
elements: [],
|
|
30710
|
+
attributes: {}
|
|
30711
|
+
};
|
|
30712
|
+
sectPr.elements.push(child);
|
|
30713
|
+
} else {
|
|
30714
|
+
if (!child.elements) child.elements = [];
|
|
30715
|
+
if (!child.attributes) child.attributes = {};
|
|
30716
|
+
}
|
|
30717
|
+
return child;
|
|
30718
|
+
};
|
|
30719
|
+
const pageSize = converter?.pageStyles?.pageSize;
|
|
30720
|
+
const pgSz = ensureChild("w:pgSz");
|
|
30721
|
+
if (pageSize?.width != null) pgSz.attributes["w:w"] = String(inchesToTwips(pageSize.width));
|
|
30722
|
+
if (pageSize?.height != null) pgSz.attributes["w:h"] = String(inchesToTwips(pageSize.height));
|
|
30723
|
+
if (pgSz.attributes["w:w"] == null) pgSz.attributes["w:w"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
30724
|
+
if (pgSz.attributes["w:h"] == null) pgSz.attributes["w:h"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
30725
|
+
const pageMargins = converter?.pageStyles?.pageMargins;
|
|
30726
|
+
const pgMar = ensureChild("w:pgMar");
|
|
30727
|
+
if (pageMargins) {
|
|
30728
|
+
Object.entries(pageMargins).forEach(([key2, value]) => {
|
|
30729
|
+
const converted = inchesToTwips(value);
|
|
30730
|
+
if (converted != null) pgMar.attributes[`w:${key2}`] = String(converted);
|
|
30731
|
+
});
|
|
30732
|
+
}
|
|
30733
|
+
Object.entries(DEFAULT_SECTION_PROPS_TWIPS.pageMargins).forEach(([key2, value]) => {
|
|
30734
|
+
const attrKey = `w:${key2}`;
|
|
30735
|
+
if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
|
|
30736
|
+
});
|
|
30737
|
+
return sectPr;
|
|
30738
|
+
};
|
|
30606
30739
|
const isLineBreakOnlyRun = (node) => {
|
|
30607
30740
|
if (!node) return false;
|
|
30608
30741
|
if (node.type === "lineBreak" || node.type === "hardBreak") return true;
|
|
@@ -30665,6 +30798,7 @@ function translateBodyNode(params2) {
|
|
|
30665
30798
|
} else if (!sectPr.elements) {
|
|
30666
30799
|
sectPr = { ...sectPr, elements: [] };
|
|
30667
30800
|
}
|
|
30801
|
+
sectPr = ensureSectionLayoutDefaults(sectPr, params2.converter);
|
|
30668
30802
|
if (params2.converter) {
|
|
30669
30803
|
const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
|
|
30670
30804
|
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
@@ -30678,40 +30812,6 @@ function translateBodyNode(params2) {
|
|
|
30678
30812
|
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
30679
30813
|
sectPr.elements.push(defaultFooter);
|
|
30680
30814
|
}
|
|
30681
|
-
const newMargins = params2.converter.pageStyles?.pageMargins;
|
|
30682
|
-
if (newMargins) {
|
|
30683
|
-
let sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
|
|
30684
|
-
if (!sectPrMargins) {
|
|
30685
|
-
sectPrMargins = {
|
|
30686
|
-
type: "element",
|
|
30687
|
-
name: "w:pgMar",
|
|
30688
|
-
attributes: {}
|
|
30689
|
-
};
|
|
30690
|
-
sectPr.elements.push(sectPrMargins);
|
|
30691
|
-
} else if (!sectPrMargins.attributes) {
|
|
30692
|
-
sectPrMargins.attributes = {};
|
|
30693
|
-
}
|
|
30694
|
-
Object.entries(newMargins).forEach(([key2, value]) => {
|
|
30695
|
-
const convertedValue = inchesToTwips(value);
|
|
30696
|
-
sectPrMargins.attributes[`w:${key2}`] = convertedValue;
|
|
30697
|
-
});
|
|
30698
|
-
}
|
|
30699
|
-
let sectPrPgSz = sectPr.elements.find((n) => n.name === "w:pgSz");
|
|
30700
|
-
if (!sectPrPgSz) {
|
|
30701
|
-
sectPrPgSz = {
|
|
30702
|
-
type: "element",
|
|
30703
|
-
name: "w:pgSz",
|
|
30704
|
-
attributes: {}
|
|
30705
|
-
};
|
|
30706
|
-
sectPr.elements.push(sectPrPgSz);
|
|
30707
|
-
} else if (!sectPrPgSz.attributes) {
|
|
30708
|
-
sectPrPgSz.attributes = {};
|
|
30709
|
-
}
|
|
30710
|
-
const pageSize = params2.converter.pageStyles?.pageSize;
|
|
30711
|
-
const widthInches = pageSize?.width;
|
|
30712
|
-
const heightInches = pageSize?.height;
|
|
30713
|
-
sectPrPgSz.attributes["w:w"] = widthInches ? String(inchesToTwips(widthInches)) : sectPrPgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
30714
|
-
sectPrPgSz.attributes["w:h"] = heightInches ? String(inchesToTwips(heightInches)) : sectPrPgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
30715
30815
|
}
|
|
30716
30816
|
const elements = translateChildNodes(params2);
|
|
30717
30817
|
if (params2.isHeaderFooter) {
|
|
@@ -36267,14 +36367,19 @@ class DocxZipper {
|
|
|
36267
36367
|
/**
|
|
36268
36368
|
* Update [Content_Types].xml with extensions of new Image annotations
|
|
36269
36369
|
*/
|
|
36270
|
-
async updateContentTypes(docx, media, fromJson) {
|
|
36370
|
+
async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
|
|
36371
|
+
const additionalPartNames = Object.keys(updatedDocs || {});
|
|
36271
36372
|
const newMediaTypes = Object.keys(media).map((name) => {
|
|
36272
36373
|
return this.getFileExtension(name);
|
|
36273
36374
|
}).filter(Boolean);
|
|
36274
36375
|
const contentTypesPath = "[Content_Types].xml";
|
|
36275
36376
|
let contentTypesXml;
|
|
36276
36377
|
if (fromJson) {
|
|
36277
|
-
|
|
36378
|
+
if (Array.isArray(docx.files)) {
|
|
36379
|
+
contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
|
|
36380
|
+
} else {
|
|
36381
|
+
contentTypesXml = docx.files?.[contentTypesPath] || "";
|
|
36382
|
+
}
|
|
36278
36383
|
} else contentTypesXml = await docx.file(contentTypesPath).async("string");
|
|
36279
36384
|
let typesString = "";
|
|
36280
36385
|
const defaultMediaTypes = getContentTypesFromXml(contentTypesXml);
|
|
@@ -36300,24 +36405,39 @@ class DocxZipper {
|
|
|
36300
36405
|
const hasCommentsExtensible = types2.elements?.some(
|
|
36301
36406
|
(el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtensible.xml"
|
|
36302
36407
|
);
|
|
36303
|
-
|
|
36408
|
+
const hasFile = (filename) => {
|
|
36409
|
+
if (!docx?.files) return false;
|
|
36410
|
+
if (!fromJson) return Boolean(docx.files[filename]);
|
|
36411
|
+
if (Array.isArray(docx.files)) return docx.files.some((file) => file.name === filename);
|
|
36412
|
+
return Boolean(docx.files[filename]);
|
|
36413
|
+
};
|
|
36414
|
+
if (hasFile("word/comments.xml")) {
|
|
36304
36415
|
const commentsDef = `<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />`;
|
|
36305
36416
|
if (!hasComments) typesString += commentsDef;
|
|
36306
36417
|
}
|
|
36307
|
-
if (
|
|
36418
|
+
if (hasFile("word/commentsExtended.xml")) {
|
|
36308
36419
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />`;
|
|
36309
36420
|
if (!hasCommentsExtended) typesString += commentsExtendedDef;
|
|
36310
36421
|
}
|
|
36311
|
-
if (
|
|
36422
|
+
if (hasFile("word/commentsIds.xml")) {
|
|
36312
36423
|
const commentsIdsDef = `<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />`;
|
|
36313
36424
|
if (!hasCommentsIds) typesString += commentsIdsDef;
|
|
36314
36425
|
}
|
|
36315
|
-
if (
|
|
36426
|
+
if (hasFile("word/commentsExtensible.xml")) {
|
|
36316
36427
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
|
|
36317
36428
|
if (!hasCommentsExtensible) typesString += commentsExtendedDef;
|
|
36318
36429
|
}
|
|
36319
|
-
|
|
36320
|
-
|
|
36430
|
+
const partNames = new Set(additionalPartNames);
|
|
36431
|
+
if (docx?.files) {
|
|
36432
|
+
if (fromJson && Array.isArray(docx.files)) {
|
|
36433
|
+
docx.files.forEach((file) => partNames.add(file.name));
|
|
36434
|
+
} else {
|
|
36435
|
+
Object.keys(docx.files).forEach((key2) => partNames.add(key2));
|
|
36436
|
+
}
|
|
36437
|
+
}
|
|
36438
|
+
partNames.forEach((name) => {
|
|
36439
|
+
if (name.includes(".rels")) return;
|
|
36440
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
36321
36441
|
const hasExtensible = types2.elements?.some(
|
|
36322
36442
|
(el) => el.name === "Override" && el.attributes.PartName === `/${name}`
|
|
36323
36443
|
);
|
|
@@ -36328,7 +36448,48 @@ class DocxZipper {
|
|
|
36328
36448
|
}
|
|
36329
36449
|
});
|
|
36330
36450
|
const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
|
36331
|
-
|
|
36451
|
+
let updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
|
|
36452
|
+
let relationshipsXml = updatedDocs["word/_rels/document.xml.rels"];
|
|
36453
|
+
if (!relationshipsXml) {
|
|
36454
|
+
if (fromJson) {
|
|
36455
|
+
if (Array.isArray(docx.files)) {
|
|
36456
|
+
relationshipsXml = docx.files.find((file) => file.name === "word/_rels/document.xml.rels")?.content;
|
|
36457
|
+
} else {
|
|
36458
|
+
relationshipsXml = docx.files?.["word/_rels/document.xml.rels"];
|
|
36459
|
+
}
|
|
36460
|
+
} else {
|
|
36461
|
+
relationshipsXml = await docx.file("word/_rels/document.xml.rels")?.async("string");
|
|
36462
|
+
}
|
|
36463
|
+
}
|
|
36464
|
+
if (relationshipsXml) {
|
|
36465
|
+
try {
|
|
36466
|
+
const relJson = xmljs.xml2js(relationshipsXml, { compact: false });
|
|
36467
|
+
const relationships = relJson.elements?.find((el) => el.name === "Relationships");
|
|
36468
|
+
relationships?.elements?.forEach((rel) => {
|
|
36469
|
+
const type2 = rel.attributes?.Type;
|
|
36470
|
+
const target = rel.attributes?.Target;
|
|
36471
|
+
if (!type2 || !target) return;
|
|
36472
|
+
const isHeader = type2.includes("/header");
|
|
36473
|
+
const isFooter = type2.includes("/footer");
|
|
36474
|
+
if (!isHeader && !isFooter) return;
|
|
36475
|
+
let sanitizedTarget = target.replace(/^\.\//, "");
|
|
36476
|
+
if (sanitizedTarget.startsWith("../")) sanitizedTarget = sanitizedTarget.slice(3);
|
|
36477
|
+
if (sanitizedTarget.startsWith("/")) sanitizedTarget = sanitizedTarget.slice(1);
|
|
36478
|
+
const partName = sanitizedTarget.startsWith("word/") ? sanitizedTarget : `word/${sanitizedTarget}`;
|
|
36479
|
+
partNames.add(partName);
|
|
36480
|
+
});
|
|
36481
|
+
} catch (error) {
|
|
36482
|
+
console.warn("Failed to parse document relationships while updating content types", error);
|
|
36483
|
+
}
|
|
36484
|
+
}
|
|
36485
|
+
partNames.forEach((name) => {
|
|
36486
|
+
if (name.includes(".rels")) return;
|
|
36487
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
36488
|
+
if (updatedContentTypesXml.includes(`PartName="/${name}"`)) return;
|
|
36489
|
+
const type2 = name.includes("header") ? "header" : "footer";
|
|
36490
|
+
const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type2}+xml"/>`;
|
|
36491
|
+
updatedContentTypesXml = updatedContentTypesXml.replace("</Types>", `${extendedDef}</Types>`);
|
|
36492
|
+
});
|
|
36332
36493
|
if (fromJson) return updatedContentTypesXml;
|
|
36333
36494
|
docx.file(contentTypesPath, updatedContentTypesXml);
|
|
36334
36495
|
}
|
|
@@ -36369,7 +36530,7 @@ class DocxZipper {
|
|
|
36369
36530
|
for (const [fontName, fontUintArray] of Object.entries(fonts)) {
|
|
36370
36531
|
zip.file(fontName, fontUintArray);
|
|
36371
36532
|
}
|
|
36372
|
-
await this.updateContentTypes(zip, media);
|
|
36533
|
+
await this.updateContentTypes(zip, media, false, updatedDocs);
|
|
36373
36534
|
return zip;
|
|
36374
36535
|
}
|
|
36375
36536
|
/**
|
|
@@ -36395,7 +36556,7 @@ class DocxZipper {
|
|
|
36395
36556
|
Object.keys(media).forEach((path) => {
|
|
36396
36557
|
unzippedOriginalDocx.file(path, media[path]);
|
|
36397
36558
|
});
|
|
36398
|
-
await this.updateContentTypes(unzippedOriginalDocx, media);
|
|
36559
|
+
await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
|
|
36399
36560
|
return unzippedOriginalDocx;
|
|
36400
36561
|
}
|
|
36401
36562
|
}
|
|
@@ -51157,7 +51318,8 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
51157
51318
|
files: this.options.content
|
|
51158
51319
|
},
|
|
51159
51320
|
media,
|
|
51160
|
-
true
|
|
51321
|
+
true,
|
|
51322
|
+
updatedDocs
|
|
51161
51323
|
);
|
|
51162
51324
|
return updatedDocs;
|
|
51163
51325
|
}
|
|
@@ -53716,6 +53878,16 @@ const shouldAllowNativeContextMenu = (event) => {
|
|
|
53716
53878
|
return prefersNativeMenu(event);
|
|
53717
53879
|
};
|
|
53718
53880
|
const shouldBypassContextMenu = shouldAllowNativeContextMenu;
|
|
53881
|
+
const DEFAULT_SELECTION_STATE = Object.freeze({
|
|
53882
|
+
focused: false,
|
|
53883
|
+
preservedSelection: null,
|
|
53884
|
+
showVisualSelection: false,
|
|
53885
|
+
skipFocusReset: false
|
|
53886
|
+
});
|
|
53887
|
+
const normalizeSelectionState = (state2 = {}) => ({
|
|
53888
|
+
...DEFAULT_SELECTION_STATE,
|
|
53889
|
+
...state2
|
|
53890
|
+
});
|
|
53719
53891
|
const CustomSelectionPluginKey = new PluginKey("CustomSelection");
|
|
53720
53892
|
const handleClickOutside = (event, editor) => {
|
|
53721
53893
|
const editorElem = editor?.options?.element;
|
|
@@ -53753,11 +53925,7 @@ const CustomSelection = Extension.create({
|
|
|
53753
53925
|
const customSelectionPlugin = new Plugin({
|
|
53754
53926
|
key: CustomSelectionPluginKey,
|
|
53755
53927
|
state: {
|
|
53756
|
-
init: () => ({
|
|
53757
|
-
focused: false,
|
|
53758
|
-
preservedSelection: null,
|
|
53759
|
-
showVisualSelection: false
|
|
53760
|
-
}),
|
|
53928
|
+
init: () => ({ ...DEFAULT_SELECTION_STATE }),
|
|
53761
53929
|
apply: (tr, value) => {
|
|
53762
53930
|
const meta = getFocusMeta(tr);
|
|
53763
53931
|
if (meta !== void 0) {
|
|
@@ -53788,7 +53956,8 @@ const CustomSelection = Extension.create({
|
|
|
53788
53956
|
setFocusMeta(view.state.tr, {
|
|
53789
53957
|
focused: true,
|
|
53790
53958
|
preservedSelection: selection,
|
|
53791
|
-
showVisualSelection: true
|
|
53959
|
+
showVisualSelection: true,
|
|
53960
|
+
skipFocusReset: true
|
|
53792
53961
|
})
|
|
53793
53962
|
);
|
|
53794
53963
|
}
|
|
@@ -53809,7 +53978,8 @@ const CustomSelection = Extension.create({
|
|
|
53809
53978
|
setFocusMeta(view.state.tr, {
|
|
53810
53979
|
focused: true,
|
|
53811
53980
|
preservedSelection: selection2,
|
|
53812
|
-
showVisualSelection: true
|
|
53981
|
+
showVisualSelection: true,
|
|
53982
|
+
skipFocusReset: true
|
|
53813
53983
|
})
|
|
53814
53984
|
);
|
|
53815
53985
|
this.editor.setOptions({
|
|
@@ -53832,7 +54002,8 @@ const CustomSelection = Extension.create({
|
|
|
53832
54002
|
setFocusMeta(view.state.tr, {
|
|
53833
54003
|
focused: true,
|
|
53834
54004
|
preservedSelection: selection,
|
|
53835
|
-
showVisualSelection: true
|
|
54005
|
+
showVisualSelection: true,
|
|
54006
|
+
skipFocusReset: false
|
|
53836
54007
|
})
|
|
53837
54008
|
);
|
|
53838
54009
|
this.editor.setOptions({
|
|
@@ -53850,7 +54021,8 @@ const CustomSelection = Extension.create({
|
|
|
53850
54021
|
setFocusMeta(view.state.tr, {
|
|
53851
54022
|
focused: true,
|
|
53852
54023
|
preservedSelection: selection,
|
|
53853
|
-
showVisualSelection: true
|
|
54024
|
+
showVisualSelection: true,
|
|
54025
|
+
skipFocusReset: false
|
|
53854
54026
|
})
|
|
53855
54027
|
);
|
|
53856
54028
|
}
|
|
@@ -53861,7 +54033,8 @@ const CustomSelection = Extension.create({
|
|
|
53861
54033
|
setFocusMeta(view.state.tr, {
|
|
53862
54034
|
focused: false,
|
|
53863
54035
|
preservedSelection: null,
|
|
53864
|
-
showVisualSelection: false
|
|
54036
|
+
showVisualSelection: false,
|
|
54037
|
+
skipFocusReset: false
|
|
53865
54038
|
})
|
|
53866
54039
|
);
|
|
53867
54040
|
if (!selection.empty && !this.editor.options.element?.contains(target)) {
|
|
@@ -53878,12 +54051,20 @@ const CustomSelection = Extension.create({
|
|
|
53878
54051
|
const isElement2 = target instanceof Element;
|
|
53879
54052
|
const isToolbarBtn = isElement2 && isToolbarButton(target);
|
|
53880
54053
|
const isToolbarInp = isElement2 && isToolbarInput(target);
|
|
54054
|
+
const focusState = getFocusState(view.state);
|
|
54055
|
+
if (focusState?.skipFocusReset) {
|
|
54056
|
+
view.dispatch(
|
|
54057
|
+
setFocusMeta(view.state.tr, normalizeSelectionState({ ...focusState, skipFocusReset: false }))
|
|
54058
|
+
);
|
|
54059
|
+
return false;
|
|
54060
|
+
}
|
|
53881
54061
|
if (!isToolbarBtn && !isToolbarInp) {
|
|
53882
54062
|
view.dispatch(
|
|
53883
54063
|
setFocusMeta(view.state.tr, {
|
|
53884
54064
|
focused: false,
|
|
53885
54065
|
preservedSelection: null,
|
|
53886
|
-
showVisualSelection: false
|
|
54066
|
+
showVisualSelection: false,
|
|
54067
|
+
skipFocusReset: false
|
|
53887
54068
|
})
|
|
53888
54069
|
);
|
|
53889
54070
|
}
|
|
@@ -53894,12 +54075,16 @@ const CustomSelection = Extension.create({
|
|
|
53894
54075
|
const isToolbarBtn = isElement2 && isToolbarButton(target);
|
|
53895
54076
|
const isToolbarInp = isElement2 && isToolbarInput(target);
|
|
53896
54077
|
const state2 = getFocusState(view.state);
|
|
54078
|
+
if (state2?.skipFocusReset) {
|
|
54079
|
+
return false;
|
|
54080
|
+
}
|
|
53897
54081
|
if (isToolbarBtn || isToolbarInp) {
|
|
53898
54082
|
view.dispatch(
|
|
53899
54083
|
setFocusMeta(view.state.tr, {
|
|
53900
54084
|
focused: true,
|
|
53901
54085
|
preservedSelection: state2.preservedSelection || view.state.selection,
|
|
53902
|
-
showVisualSelection: true
|
|
54086
|
+
showVisualSelection: true,
|
|
54087
|
+
skipFocusReset: false
|
|
53903
54088
|
})
|
|
53904
54089
|
);
|
|
53905
54090
|
} else {
|
|
@@ -53907,7 +54092,8 @@ const CustomSelection = Extension.create({
|
|
|
53907
54092
|
setFocusMeta(view.state.tr, {
|
|
53908
54093
|
focused: false,
|
|
53909
54094
|
preservedSelection: null,
|
|
53910
|
-
showVisualSelection: false
|
|
54095
|
+
showVisualSelection: false,
|
|
54096
|
+
skipFocusReset: false
|
|
53911
54097
|
})
|
|
53912
54098
|
);
|
|
53913
54099
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/types/index.js"],"names":[],"mappings":";;;;;;;UAEc,MAAM;;;;WACN,MAAM;;;;YACN,MAAM,GAAG,IAAI;;;;;;;;;cAKb,OAAO;;;;iBACP,MAAM;;;;eACN,MAAM;;;;sBACN,MAAM;;;;;;SAKN,MA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E,KAAK,IAAI;;;;yBACvD,MAAM,IAAI;;;;sBACV,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI;;;;2BAC3B,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI;;;;qBACpC,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI;;;;kBACpC,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,KAAK,CAAA;KAAE,KAAK,IAAI;;;;2BAClC,CAAC,MAAM,EAAE;QAAE,UAAU,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI;;;;8BACzC,CAAC,MAAM,EAAE,EAAE,KAAC,GAAA;;;;aACZ,MAAM;;;;uBACN,KAAQ;;;;iBACR,OAAO;;;;YACP,MAAM;;;;oBACN,KAAQ;;;;eACR,OAAO;;;;wBACP,CAAS,IAAI,EAAJ,IAAI,KAAG,OAAO,CAAC,MAAM,CAAC;;;;eAC/B,IAAI;;;;aACJ,OAAO;;;;gCACP,OAAO;;;;;;;;yBAEP,OAAO;;;;WACP,MAAM;;;;eACN,MAAM;;;;cACN,OAAO"}
|
|
@@ -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-D9kK7Smo.js";
|
|
3
|
+
import { _ as _export_sfc } from "./chunks/editor-Ddkz97dH.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 = {}) {
|