@harbour-enterprises/superdoc 0.22.0-next.3 → 0.22.0-next.5
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-CvFw8S_D.cjs → PdfViewer-Badqoc1e.cjs} +1 -1
- package/dist/chunks/{PdfViewer-D95oFKMa.es.js → PdfViewer-dsL5uHg1.es.js} +1 -1
- package/dist/chunks/{index-DgH1cx2c.es.js → index-DBNzXf1D.es.js} +2 -2
- package/dist/chunks/{index-Ct4VrAay.cjs → index-DVrbZM76.cjs} +2 -2
- package/dist/chunks/{super-editor.es-WUoM0FI7.es.js → super-editor.es-DruRanWK.es.js} +170 -67
- package/dist/chunks/{super-editor.es-CIDcWgLs.cjs → super-editor.es-p3eqHXlj.cjs} +170 -67
- 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-DujfV3Zn.js} +46 -34
- package/dist/super-editor/chunks/{docx-zipper-BCI-3XE9.js → docx-zipper-DccEqL60.js} +73 -12
- package/dist/super-editor/chunks/{editor-W3rw5KHF.js → editor-Dq3xPdti.js} +54 -24
- package/dist/super-editor/chunks/{toolbar-CFfRuTi3.js → toolbar-u5oyT_9K.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/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 +170 -67
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -30620,6 +30620,51 @@ const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
|
|
|
30620
30620
|
gutter: "0"
|
|
30621
30621
|
})
|
|
30622
30622
|
});
|
|
30623
|
+
const ensureSectionLayoutDefaults = (sectPr, converter) => {
|
|
30624
|
+
if (!sectPr) {
|
|
30625
|
+
return {
|
|
30626
|
+
type: "element",
|
|
30627
|
+
name: "w:sectPr",
|
|
30628
|
+
elements: []
|
|
30629
|
+
};
|
|
30630
|
+
}
|
|
30631
|
+
if (!sectPr.elements) sectPr.elements = [];
|
|
30632
|
+
const ensureChild = (name) => {
|
|
30633
|
+
let child = sectPr.elements.find((n) => n.name === name);
|
|
30634
|
+
if (!child) {
|
|
30635
|
+
child = {
|
|
30636
|
+
type: "element",
|
|
30637
|
+
name,
|
|
30638
|
+
elements: [],
|
|
30639
|
+
attributes: {}
|
|
30640
|
+
};
|
|
30641
|
+
sectPr.elements.push(child);
|
|
30642
|
+
} else {
|
|
30643
|
+
if (!child.elements) child.elements = [];
|
|
30644
|
+
if (!child.attributes) child.attributes = {};
|
|
30645
|
+
}
|
|
30646
|
+
return child;
|
|
30647
|
+
};
|
|
30648
|
+
const pageSize = converter?.pageStyles?.pageSize;
|
|
30649
|
+
const pgSz = ensureChild("w:pgSz");
|
|
30650
|
+
if (pageSize?.width != null) pgSz.attributes["w:w"] = String(inchesToTwips(pageSize.width));
|
|
30651
|
+
if (pageSize?.height != null) pgSz.attributes["w:h"] = String(inchesToTwips(pageSize.height));
|
|
30652
|
+
if (pgSz.attributes["w:w"] == null) pgSz.attributes["w:w"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
30653
|
+
if (pgSz.attributes["w:h"] == null) pgSz.attributes["w:h"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
30654
|
+
const pageMargins = converter?.pageStyles?.pageMargins;
|
|
30655
|
+
const pgMar = ensureChild("w:pgMar");
|
|
30656
|
+
if (pageMargins) {
|
|
30657
|
+
Object.entries(pageMargins).forEach(([key2, value]) => {
|
|
30658
|
+
const converted = inchesToTwips(value);
|
|
30659
|
+
if (converted != null) pgMar.attributes[`w:${key2}`] = String(converted);
|
|
30660
|
+
});
|
|
30661
|
+
}
|
|
30662
|
+
Object.entries(DEFAULT_SECTION_PROPS_TWIPS.pageMargins).forEach(([key2, value]) => {
|
|
30663
|
+
const attrKey = `w:${key2}`;
|
|
30664
|
+
if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
|
|
30665
|
+
});
|
|
30666
|
+
return sectPr;
|
|
30667
|
+
};
|
|
30623
30668
|
const isLineBreakOnlyRun = (node) => {
|
|
30624
30669
|
if (!node) return false;
|
|
30625
30670
|
if (node.type === "lineBreak" || node.type === "hardBreak") return true;
|
|
@@ -30682,6 +30727,7 @@ function translateBodyNode(params2) {
|
|
|
30682
30727
|
} else if (!sectPr.elements) {
|
|
30683
30728
|
sectPr = { ...sectPr, elements: [] };
|
|
30684
30729
|
}
|
|
30730
|
+
sectPr = ensureSectionLayoutDefaults(sectPr, params2.converter);
|
|
30685
30731
|
if (params2.converter) {
|
|
30686
30732
|
const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
|
|
30687
30733
|
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
@@ -30695,40 +30741,6 @@ function translateBodyNode(params2) {
|
|
|
30695
30741
|
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
30696
30742
|
sectPr.elements.push(defaultFooter);
|
|
30697
30743
|
}
|
|
30698
|
-
const newMargins = params2.converter.pageStyles?.pageMargins;
|
|
30699
|
-
if (newMargins) {
|
|
30700
|
-
let sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
|
|
30701
|
-
if (!sectPrMargins) {
|
|
30702
|
-
sectPrMargins = {
|
|
30703
|
-
type: "element",
|
|
30704
|
-
name: "w:pgMar",
|
|
30705
|
-
attributes: {}
|
|
30706
|
-
};
|
|
30707
|
-
sectPr.elements.push(sectPrMargins);
|
|
30708
|
-
} else if (!sectPrMargins.attributes) {
|
|
30709
|
-
sectPrMargins.attributes = {};
|
|
30710
|
-
}
|
|
30711
|
-
Object.entries(newMargins).forEach(([key2, value]) => {
|
|
30712
|
-
const convertedValue = inchesToTwips(value);
|
|
30713
|
-
sectPrMargins.attributes[`w:${key2}`] = convertedValue;
|
|
30714
|
-
});
|
|
30715
|
-
}
|
|
30716
|
-
let sectPrPgSz = sectPr.elements.find((n) => n.name === "w:pgSz");
|
|
30717
|
-
if (!sectPrPgSz) {
|
|
30718
|
-
sectPrPgSz = {
|
|
30719
|
-
type: "element",
|
|
30720
|
-
name: "w:pgSz",
|
|
30721
|
-
attributes: {}
|
|
30722
|
-
};
|
|
30723
|
-
sectPr.elements.push(sectPrPgSz);
|
|
30724
|
-
} else if (!sectPrPgSz.attributes) {
|
|
30725
|
-
sectPrPgSz.attributes = {};
|
|
30726
|
-
}
|
|
30727
|
-
const pageSize = params2.converter.pageStyles?.pageSize;
|
|
30728
|
-
const widthInches = pageSize?.width;
|
|
30729
|
-
const heightInches = pageSize?.height;
|
|
30730
|
-
sectPrPgSz.attributes["w:w"] = widthInches ? String(inchesToTwips(widthInches)) : sectPrPgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
30731
|
-
sectPrPgSz.attributes["w:h"] = heightInches ? String(inchesToTwips(heightInches)) : sectPrPgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
30732
30744
|
}
|
|
30733
30745
|
const elements = translateChildNodes(params2);
|
|
30734
30746
|
if (params2.isHeaderFooter) {
|
|
@@ -36284,14 +36296,19 @@ class DocxZipper {
|
|
|
36284
36296
|
/**
|
|
36285
36297
|
* Update [Content_Types].xml with extensions of new Image annotations
|
|
36286
36298
|
*/
|
|
36287
|
-
async updateContentTypes(docx, media, fromJson) {
|
|
36299
|
+
async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
|
|
36300
|
+
const additionalPartNames = Object.keys(updatedDocs || {});
|
|
36288
36301
|
const newMediaTypes = Object.keys(media).map((name) => {
|
|
36289
36302
|
return this.getFileExtension(name);
|
|
36290
36303
|
}).filter(Boolean);
|
|
36291
36304
|
const contentTypesPath = "[Content_Types].xml";
|
|
36292
36305
|
let contentTypesXml;
|
|
36293
36306
|
if (fromJson) {
|
|
36294
|
-
|
|
36307
|
+
if (Array.isArray(docx.files)) {
|
|
36308
|
+
contentTypesXml = docx.files.find((file) => file.name === contentTypesPath)?.content || "";
|
|
36309
|
+
} else {
|
|
36310
|
+
contentTypesXml = docx.files?.[contentTypesPath] || "";
|
|
36311
|
+
}
|
|
36295
36312
|
} else contentTypesXml = await docx.file(contentTypesPath).async("string");
|
|
36296
36313
|
let typesString = "";
|
|
36297
36314
|
const defaultMediaTypes = getContentTypesFromXml(contentTypesXml);
|
|
@@ -36317,24 +36334,39 @@ class DocxZipper {
|
|
|
36317
36334
|
const hasCommentsExtensible = types2.elements?.some(
|
|
36318
36335
|
(el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtensible.xml"
|
|
36319
36336
|
);
|
|
36320
|
-
|
|
36337
|
+
const hasFile = (filename) => {
|
|
36338
|
+
if (!docx?.files) return false;
|
|
36339
|
+
if (!fromJson) return Boolean(docx.files[filename]);
|
|
36340
|
+
if (Array.isArray(docx.files)) return docx.files.some((file) => file.name === filename);
|
|
36341
|
+
return Boolean(docx.files[filename]);
|
|
36342
|
+
};
|
|
36343
|
+
if (hasFile("word/comments.xml")) {
|
|
36321
36344
|
const commentsDef = `<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml" />`;
|
|
36322
36345
|
if (!hasComments) typesString += commentsDef;
|
|
36323
36346
|
}
|
|
36324
|
-
if (
|
|
36347
|
+
if (hasFile("word/commentsExtended.xml")) {
|
|
36325
36348
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtended.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml" />`;
|
|
36326
36349
|
if (!hasCommentsExtended) typesString += commentsExtendedDef;
|
|
36327
36350
|
}
|
|
36328
|
-
if (
|
|
36351
|
+
if (hasFile("word/commentsIds.xml")) {
|
|
36329
36352
|
const commentsIdsDef = `<Override PartName="/word/commentsIds.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml" />`;
|
|
36330
36353
|
if (!hasCommentsIds) typesString += commentsIdsDef;
|
|
36331
36354
|
}
|
|
36332
|
-
if (
|
|
36355
|
+
if (hasFile("word/commentsExtensible.xml")) {
|
|
36333
36356
|
const commentsExtendedDef = `<Override PartName="/word/commentsExtensible.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtensible+xml" />`;
|
|
36334
36357
|
if (!hasCommentsExtensible) typesString += commentsExtendedDef;
|
|
36335
36358
|
}
|
|
36336
|
-
|
|
36337
|
-
|
|
36359
|
+
const partNames = new Set(additionalPartNames);
|
|
36360
|
+
if (docx?.files) {
|
|
36361
|
+
if (fromJson && Array.isArray(docx.files)) {
|
|
36362
|
+
docx.files.forEach((file) => partNames.add(file.name));
|
|
36363
|
+
} else {
|
|
36364
|
+
Object.keys(docx.files).forEach((key2) => partNames.add(key2));
|
|
36365
|
+
}
|
|
36366
|
+
}
|
|
36367
|
+
partNames.forEach((name) => {
|
|
36368
|
+
if (name.includes(".rels")) return;
|
|
36369
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
36338
36370
|
const hasExtensible = types2.elements?.some(
|
|
36339
36371
|
(el) => el.name === "Override" && el.attributes.PartName === `/${name}`
|
|
36340
36372
|
);
|
|
@@ -36345,7 +36377,48 @@ class DocxZipper {
|
|
|
36345
36377
|
}
|
|
36346
36378
|
});
|
|
36347
36379
|
const beginningString = '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">';
|
|
36348
|
-
|
|
36380
|
+
let updatedContentTypesXml = contentTypesXml.replace(beginningString, `${beginningString}${typesString}`);
|
|
36381
|
+
let relationshipsXml = updatedDocs["word/_rels/document.xml.rels"];
|
|
36382
|
+
if (!relationshipsXml) {
|
|
36383
|
+
if (fromJson) {
|
|
36384
|
+
if (Array.isArray(docx.files)) {
|
|
36385
|
+
relationshipsXml = docx.files.find((file) => file.name === "word/_rels/document.xml.rels")?.content;
|
|
36386
|
+
} else {
|
|
36387
|
+
relationshipsXml = docx.files?.["word/_rels/document.xml.rels"];
|
|
36388
|
+
}
|
|
36389
|
+
} else {
|
|
36390
|
+
relationshipsXml = await docx.file("word/_rels/document.xml.rels")?.async("string");
|
|
36391
|
+
}
|
|
36392
|
+
}
|
|
36393
|
+
if (relationshipsXml) {
|
|
36394
|
+
try {
|
|
36395
|
+
const relJson = xmljs.xml2js(relationshipsXml, { compact: false });
|
|
36396
|
+
const relationships = relJson.elements?.find((el) => el.name === "Relationships");
|
|
36397
|
+
relationships?.elements?.forEach((rel) => {
|
|
36398
|
+
const type2 = rel.attributes?.Type;
|
|
36399
|
+
const target = rel.attributes?.Target;
|
|
36400
|
+
if (!type2 || !target) return;
|
|
36401
|
+
const isHeader = type2.includes("/header");
|
|
36402
|
+
const isFooter = type2.includes("/footer");
|
|
36403
|
+
if (!isHeader && !isFooter) return;
|
|
36404
|
+
let sanitizedTarget = target.replace(/^\.\//, "");
|
|
36405
|
+
if (sanitizedTarget.startsWith("../")) sanitizedTarget = sanitizedTarget.slice(3);
|
|
36406
|
+
if (sanitizedTarget.startsWith("/")) sanitizedTarget = sanitizedTarget.slice(1);
|
|
36407
|
+
const partName = sanitizedTarget.startsWith("word/") ? sanitizedTarget : `word/${sanitizedTarget}`;
|
|
36408
|
+
partNames.add(partName);
|
|
36409
|
+
});
|
|
36410
|
+
} catch (error) {
|
|
36411
|
+
console.warn("Failed to parse document relationships while updating content types", error);
|
|
36412
|
+
}
|
|
36413
|
+
}
|
|
36414
|
+
partNames.forEach((name) => {
|
|
36415
|
+
if (name.includes(".rels")) return;
|
|
36416
|
+
if (!name.includes("header") && !name.includes("footer")) return;
|
|
36417
|
+
if (updatedContentTypesXml.includes(`PartName="/${name}"`)) return;
|
|
36418
|
+
const type2 = name.includes("header") ? "header" : "footer";
|
|
36419
|
+
const extendedDef = `<Override PartName="/${name}" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.${type2}+xml"/>`;
|
|
36420
|
+
updatedContentTypesXml = updatedContentTypesXml.replace("</Types>", `${extendedDef}</Types>`);
|
|
36421
|
+
});
|
|
36349
36422
|
if (fromJson) return updatedContentTypesXml;
|
|
36350
36423
|
docx.file(contentTypesPath, updatedContentTypesXml);
|
|
36351
36424
|
}
|
|
@@ -36386,7 +36459,7 @@ class DocxZipper {
|
|
|
36386
36459
|
for (const [fontName, fontUintArray] of Object.entries(fonts)) {
|
|
36387
36460
|
zip.file(fontName, fontUintArray);
|
|
36388
36461
|
}
|
|
36389
|
-
await this.updateContentTypes(zip, media);
|
|
36462
|
+
await this.updateContentTypes(zip, media, false, updatedDocs);
|
|
36390
36463
|
return zip;
|
|
36391
36464
|
}
|
|
36392
36465
|
/**
|
|
@@ -36412,7 +36485,7 @@ class DocxZipper {
|
|
|
36412
36485
|
Object.keys(media).forEach((path) => {
|
|
36413
36486
|
unzippedOriginalDocx.file(path, media[path]);
|
|
36414
36487
|
});
|
|
36415
|
-
await this.updateContentTypes(unzippedOriginalDocx, media);
|
|
36488
|
+
await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
|
|
36416
36489
|
return unzippedOriginalDocx;
|
|
36417
36490
|
}
|
|
36418
36491
|
}
|
|
@@ -48070,9 +48143,11 @@ const toggleHeaderFooterEditMode = ({ editor, focusedSectionEditor, isEditMode,
|
|
|
48070
48143
|
item.editor.view.dom.setAttribute("documentmode", documentMode);
|
|
48071
48144
|
});
|
|
48072
48145
|
if (isEditMode) {
|
|
48073
|
-
const pm =
|
|
48074
|
-
pm
|
|
48075
|
-
|
|
48146
|
+
const pm = editor.view?.dom || editor.options.element?.querySelector?.(".ProseMirror");
|
|
48147
|
+
if (pm) {
|
|
48148
|
+
pm.classList.add("header-footer-edit");
|
|
48149
|
+
pm.setAttribute("aria-readonly", true);
|
|
48150
|
+
}
|
|
48076
48151
|
}
|
|
48077
48152
|
if (focusedSectionEditor) {
|
|
48078
48153
|
focusedSectionEditor.view.focus();
|
|
@@ -50684,7 +50759,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
50684
50759
|
setDocumentMode(documentMode) {
|
|
50685
50760
|
let cleanedMode = documentMode?.toLowerCase() || "editing";
|
|
50686
50761
|
if (!this.extensionService || !this.state) return;
|
|
50687
|
-
const pm =
|
|
50762
|
+
const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
|
|
50688
50763
|
if (this.options.role === "viewer") cleanedMode = "viewing";
|
|
50689
50764
|
if (this.options.role === "suggester" && cleanedMode === "editing") cleanedMode = "suggesting";
|
|
50690
50765
|
if (cleanedMode === "viewing") {
|
|
@@ -51172,7 +51247,8 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
51172
51247
|
files: this.options.content
|
|
51173
51248
|
},
|
|
51174
51249
|
media,
|
|
51175
|
-
true
|
|
51250
|
+
true,
|
|
51251
|
+
updatedDocs
|
|
51176
51252
|
);
|
|
51177
51253
|
return updatedDocs;
|
|
51178
51254
|
}
|
|
@@ -51658,9 +51734,11 @@ createView_fn = function(element) {
|
|
|
51658
51734
|
isEditMode: false,
|
|
51659
51735
|
documentMode: this.options.documentMode
|
|
51660
51736
|
});
|
|
51661
|
-
const pm =
|
|
51662
|
-
pm
|
|
51663
|
-
|
|
51737
|
+
const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
|
|
51738
|
+
if (pm) {
|
|
51739
|
+
pm.classList.remove("header-footer-edit");
|
|
51740
|
+
pm.setAttribute("aria-readonly", false);
|
|
51741
|
+
}
|
|
51664
51742
|
}
|
|
51665
51743
|
setWordSelection(view, pos);
|
|
51666
51744
|
}
|
|
@@ -53729,6 +53807,16 @@ const shouldAllowNativeContextMenu = (event) => {
|
|
|
53729
53807
|
return prefersNativeMenu(event);
|
|
53730
53808
|
};
|
|
53731
53809
|
const shouldBypassContextMenu = shouldAllowNativeContextMenu;
|
|
53810
|
+
const DEFAULT_SELECTION_STATE = Object.freeze({
|
|
53811
|
+
focused: false,
|
|
53812
|
+
preservedSelection: null,
|
|
53813
|
+
showVisualSelection: false,
|
|
53814
|
+
skipFocusReset: false
|
|
53815
|
+
});
|
|
53816
|
+
const normalizeSelectionState = (state2 = {}) => ({
|
|
53817
|
+
...DEFAULT_SELECTION_STATE,
|
|
53818
|
+
...state2
|
|
53819
|
+
});
|
|
53732
53820
|
const CustomSelectionPluginKey = new PluginKey("CustomSelection");
|
|
53733
53821
|
const handleClickOutside = (event, editor) => {
|
|
53734
53822
|
const editorElem = editor?.options?.element;
|
|
@@ -53766,11 +53854,7 @@ const CustomSelection = Extension.create({
|
|
|
53766
53854
|
const customSelectionPlugin = new Plugin({
|
|
53767
53855
|
key: CustomSelectionPluginKey,
|
|
53768
53856
|
state: {
|
|
53769
|
-
init: () => ({
|
|
53770
|
-
focused: false,
|
|
53771
|
-
preservedSelection: null,
|
|
53772
|
-
showVisualSelection: false
|
|
53773
|
-
}),
|
|
53857
|
+
init: () => ({ ...DEFAULT_SELECTION_STATE }),
|
|
53774
53858
|
apply: (tr, value) => {
|
|
53775
53859
|
const meta = getFocusMeta(tr);
|
|
53776
53860
|
if (meta !== void 0) {
|
|
@@ -53801,7 +53885,8 @@ const CustomSelection = Extension.create({
|
|
|
53801
53885
|
setFocusMeta(view.state.tr, {
|
|
53802
53886
|
focused: true,
|
|
53803
53887
|
preservedSelection: selection,
|
|
53804
|
-
showVisualSelection: true
|
|
53888
|
+
showVisualSelection: true,
|
|
53889
|
+
skipFocusReset: true
|
|
53805
53890
|
})
|
|
53806
53891
|
);
|
|
53807
53892
|
}
|
|
@@ -53822,7 +53907,8 @@ const CustomSelection = Extension.create({
|
|
|
53822
53907
|
setFocusMeta(view.state.tr, {
|
|
53823
53908
|
focused: true,
|
|
53824
53909
|
preservedSelection: selection2,
|
|
53825
|
-
showVisualSelection: true
|
|
53910
|
+
showVisualSelection: true,
|
|
53911
|
+
skipFocusReset: true
|
|
53826
53912
|
})
|
|
53827
53913
|
);
|
|
53828
53914
|
this.editor.setOptions({
|
|
@@ -53845,7 +53931,8 @@ const CustomSelection = Extension.create({
|
|
|
53845
53931
|
setFocusMeta(view.state.tr, {
|
|
53846
53932
|
focused: true,
|
|
53847
53933
|
preservedSelection: selection,
|
|
53848
|
-
showVisualSelection: true
|
|
53934
|
+
showVisualSelection: true,
|
|
53935
|
+
skipFocusReset: false
|
|
53849
53936
|
})
|
|
53850
53937
|
);
|
|
53851
53938
|
this.editor.setOptions({
|
|
@@ -53863,7 +53950,8 @@ const CustomSelection = Extension.create({
|
|
|
53863
53950
|
setFocusMeta(view.state.tr, {
|
|
53864
53951
|
focused: true,
|
|
53865
53952
|
preservedSelection: selection,
|
|
53866
|
-
showVisualSelection: true
|
|
53953
|
+
showVisualSelection: true,
|
|
53954
|
+
skipFocusReset: false
|
|
53867
53955
|
})
|
|
53868
53956
|
);
|
|
53869
53957
|
}
|
|
@@ -53874,7 +53962,8 @@ const CustomSelection = Extension.create({
|
|
|
53874
53962
|
setFocusMeta(view.state.tr, {
|
|
53875
53963
|
focused: false,
|
|
53876
53964
|
preservedSelection: null,
|
|
53877
|
-
showVisualSelection: false
|
|
53965
|
+
showVisualSelection: false,
|
|
53966
|
+
skipFocusReset: false
|
|
53878
53967
|
})
|
|
53879
53968
|
);
|
|
53880
53969
|
if (!selection.empty && !this.editor.options.element?.contains(target)) {
|
|
@@ -53891,12 +53980,20 @@ const CustomSelection = Extension.create({
|
|
|
53891
53980
|
const isElement2 = target instanceof Element;
|
|
53892
53981
|
const isToolbarBtn = isElement2 && isToolbarButton(target);
|
|
53893
53982
|
const isToolbarInp = isElement2 && isToolbarInput(target);
|
|
53983
|
+
const focusState = getFocusState(view.state);
|
|
53984
|
+
if (focusState?.skipFocusReset) {
|
|
53985
|
+
view.dispatch(
|
|
53986
|
+
setFocusMeta(view.state.tr, normalizeSelectionState({ ...focusState, skipFocusReset: false }))
|
|
53987
|
+
);
|
|
53988
|
+
return false;
|
|
53989
|
+
}
|
|
53894
53990
|
if (!isToolbarBtn && !isToolbarInp) {
|
|
53895
53991
|
view.dispatch(
|
|
53896
53992
|
setFocusMeta(view.state.tr, {
|
|
53897
53993
|
focused: false,
|
|
53898
53994
|
preservedSelection: null,
|
|
53899
|
-
showVisualSelection: false
|
|
53995
|
+
showVisualSelection: false,
|
|
53996
|
+
skipFocusReset: false
|
|
53900
53997
|
})
|
|
53901
53998
|
);
|
|
53902
53999
|
}
|
|
@@ -53907,12 +54004,16 @@ const CustomSelection = Extension.create({
|
|
|
53907
54004
|
const isToolbarBtn = isElement2 && isToolbarButton(target);
|
|
53908
54005
|
const isToolbarInp = isElement2 && isToolbarInput(target);
|
|
53909
54006
|
const state2 = getFocusState(view.state);
|
|
54007
|
+
if (state2?.skipFocusReset) {
|
|
54008
|
+
return false;
|
|
54009
|
+
}
|
|
53910
54010
|
if (isToolbarBtn || isToolbarInp) {
|
|
53911
54011
|
view.dispatch(
|
|
53912
54012
|
setFocusMeta(view.state.tr, {
|
|
53913
54013
|
focused: true,
|
|
53914
54014
|
preservedSelection: state2.preservedSelection || view.state.selection,
|
|
53915
|
-
showVisualSelection: true
|
|
54015
|
+
showVisualSelection: true,
|
|
54016
|
+
skipFocusReset: false
|
|
53916
54017
|
})
|
|
53917
54018
|
);
|
|
53918
54019
|
} else {
|
|
@@ -53920,7 +54021,8 @@ const CustomSelection = Extension.create({
|
|
|
53920
54021
|
setFocusMeta(view.state.tr, {
|
|
53921
54022
|
focused: false,
|
|
53922
54023
|
preservedSelection: null,
|
|
53923
|
-
showVisualSelection: false
|
|
54024
|
+
showVisualSelection: false,
|
|
54025
|
+
skipFocusReset: false
|
|
53924
54026
|
})
|
|
53925
54027
|
);
|
|
53926
54028
|
}
|
|
@@ -69695,7 +69797,8 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
|
|
|
69695
69797
|
const prevSelection = prevState.selection;
|
|
69696
69798
|
if (selection.from !== prevSelection.from || selection.to !== prevSelection.to) {
|
|
69697
69799
|
setTimeout(() => {
|
|
69698
|
-
const
|
|
69800
|
+
const searchRoot = editorView?.dom;
|
|
69801
|
+
const selectedResizableWrapper = searchRoot?.querySelector(".sd-editor-resizable-wrapper");
|
|
69699
69802
|
if (selectedResizableWrapper) {
|
|
69700
69803
|
showResizeHandles(view2, selectedResizableWrapper);
|
|
69701
69804
|
} else {
|
|
@@ -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,MAAM;;;;UACN,MAAM;;;;WACN,IAAI,GAAG,IAAI,GAAG,IAAI;;;;WAClB,MAAM;;;;UACN,MAAM;;;;gBACN,OAAO;;;;WACP,OAAO,KAAK,EAAE,GAAG;;;;eACjB,OAAO,sBAAsB,EAAE,kBAAkB;;;;;;;;;;SAO5D;QAAuB,MAAM,GAAlB,MAAM;QACM,QAAQ,GAApB,MAAM;KACjB;;;;;;;;;;;;gBAGA;QAA6B,WAAW;QACR,YAAY;QACb,mBAAmB,GAAvC,OAAO;KACpB;;;;;;;;;;;;;;
|
|
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,MAAM;;;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AM;;;;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-DujfV3Zn.js";
|
|
3
|
+
import { _ as _export_sfc } from "./chunks/editor-Dq3xPdti.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 = {}) {
|
|
@@ -30610,6 +30610,51 @@ const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
|
|
|
30610
30610
|
gutter: "0"
|
|
30611
30611
|
})
|
|
30612
30612
|
});
|
|
30613
|
+
const ensureSectionLayoutDefaults = (sectPr, converter) => {
|
|
30614
|
+
if (!sectPr) {
|
|
30615
|
+
return {
|
|
30616
|
+
type: "element",
|
|
30617
|
+
name: "w:sectPr",
|
|
30618
|
+
elements: []
|
|
30619
|
+
};
|
|
30620
|
+
}
|
|
30621
|
+
if (!sectPr.elements) sectPr.elements = [];
|
|
30622
|
+
const ensureChild = (name) => {
|
|
30623
|
+
let child = sectPr.elements.find((n) => n.name === name);
|
|
30624
|
+
if (!child) {
|
|
30625
|
+
child = {
|
|
30626
|
+
type: "element",
|
|
30627
|
+
name,
|
|
30628
|
+
elements: [],
|
|
30629
|
+
attributes: {}
|
|
30630
|
+
};
|
|
30631
|
+
sectPr.elements.push(child);
|
|
30632
|
+
} else {
|
|
30633
|
+
if (!child.elements) child.elements = [];
|
|
30634
|
+
if (!child.attributes) child.attributes = {};
|
|
30635
|
+
}
|
|
30636
|
+
return child;
|
|
30637
|
+
};
|
|
30638
|
+
const pageSize = converter?.pageStyles?.pageSize;
|
|
30639
|
+
const pgSz = ensureChild("w:pgSz");
|
|
30640
|
+
if (pageSize?.width != null) pgSz.attributes["w:w"] = String(inchesToTwips(pageSize.width));
|
|
30641
|
+
if (pageSize?.height != null) pgSz.attributes["w:h"] = String(inchesToTwips(pageSize.height));
|
|
30642
|
+
if (pgSz.attributes["w:w"] == null) pgSz.attributes["w:w"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
30643
|
+
if (pgSz.attributes["w:h"] == null) pgSz.attributes["w:h"] = DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
30644
|
+
const pageMargins = converter?.pageStyles?.pageMargins;
|
|
30645
|
+
const pgMar = ensureChild("w:pgMar");
|
|
30646
|
+
if (pageMargins) {
|
|
30647
|
+
Object.entries(pageMargins).forEach(([key, value]) => {
|
|
30648
|
+
const converted = inchesToTwips(value);
|
|
30649
|
+
if (converted != null) pgMar.attributes[`w:${key}`] = String(converted);
|
|
30650
|
+
});
|
|
30651
|
+
}
|
|
30652
|
+
Object.entries(DEFAULT_SECTION_PROPS_TWIPS.pageMargins).forEach(([key, value]) => {
|
|
30653
|
+
const attrKey = `w:${key}`;
|
|
30654
|
+
if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
|
|
30655
|
+
});
|
|
30656
|
+
return sectPr;
|
|
30657
|
+
};
|
|
30613
30658
|
const isLineBreakOnlyRun = (node) => {
|
|
30614
30659
|
if (!node) return false;
|
|
30615
30660
|
if (node.type === "lineBreak" || node.type === "hardBreak") return true;
|
|
@@ -30672,6 +30717,7 @@ function translateBodyNode(params) {
|
|
|
30672
30717
|
} else if (!sectPr.elements) {
|
|
30673
30718
|
sectPr = { ...sectPr, elements: [] };
|
|
30674
30719
|
}
|
|
30720
|
+
sectPr = ensureSectionLayoutDefaults(sectPr, params.converter);
|
|
30675
30721
|
if (params.converter) {
|
|
30676
30722
|
const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
|
|
30677
30723
|
const hasDefaultHeader = params.converter.headerIds?.default;
|
|
@@ -30685,40 +30731,6 @@ function translateBodyNode(params) {
|
|
|
30685
30731
|
const defaultFooter = generateDefaultHeaderFooter("footer", params.converter.footerIds?.default);
|
|
30686
30732
|
sectPr.elements.push(defaultFooter);
|
|
30687
30733
|
}
|
|
30688
|
-
const newMargins = params.converter.pageStyles?.pageMargins;
|
|
30689
|
-
if (newMargins) {
|
|
30690
|
-
let sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
|
|
30691
|
-
if (!sectPrMargins) {
|
|
30692
|
-
sectPrMargins = {
|
|
30693
|
-
type: "element",
|
|
30694
|
-
name: "w:pgMar",
|
|
30695
|
-
attributes: {}
|
|
30696
|
-
};
|
|
30697
|
-
sectPr.elements.push(sectPrMargins);
|
|
30698
|
-
} else if (!sectPrMargins.attributes) {
|
|
30699
|
-
sectPrMargins.attributes = {};
|
|
30700
|
-
}
|
|
30701
|
-
Object.entries(newMargins).forEach(([key, value]) => {
|
|
30702
|
-
const convertedValue = inchesToTwips(value);
|
|
30703
|
-
sectPrMargins.attributes[`w:${key}`] = convertedValue;
|
|
30704
|
-
});
|
|
30705
|
-
}
|
|
30706
|
-
let sectPrPgSz = sectPr.elements.find((n) => n.name === "w:pgSz");
|
|
30707
|
-
if (!sectPrPgSz) {
|
|
30708
|
-
sectPrPgSz = {
|
|
30709
|
-
type: "element",
|
|
30710
|
-
name: "w:pgSz",
|
|
30711
|
-
attributes: {}
|
|
30712
|
-
};
|
|
30713
|
-
sectPr.elements.push(sectPrPgSz);
|
|
30714
|
-
} else if (!sectPrPgSz.attributes) {
|
|
30715
|
-
sectPrPgSz.attributes = {};
|
|
30716
|
-
}
|
|
30717
|
-
const pageSize = params.converter.pageStyles?.pageSize;
|
|
30718
|
-
const widthInches = pageSize?.width;
|
|
30719
|
-
const heightInches = pageSize?.height;
|
|
30720
|
-
sectPrPgSz.attributes["w:w"] = widthInches ? String(inchesToTwips(widthInches)) : sectPrPgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
30721
|
-
sectPrPgSz.attributes["w:h"] = heightInches ? String(inchesToTwips(heightInches)) : sectPrPgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
30722
30734
|
}
|
|
30723
30735
|
const elements = translateChildNodes(params);
|
|
30724
30736
|
if (params.isHeaderFooter) {
|