@harbour-enterprises/superdoc 0.22.0-next.1 → 0.22.0-next.3
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-B3KmcDup.cjs → PdfViewer-CvFw8S_D.cjs} +1 -1
- package/dist/chunks/{PdfViewer-BpwMPbUj.es.js → PdfViewer-D95oFKMa.es.js} +1 -1
- package/dist/chunks/{index-BOf6E2I4.cjs → index-Ct4VrAay.cjs} +39 -19
- package/dist/chunks/{index-Cw4YywoD.es.js → index-DgH1cx2c.es.js} +39 -19
- package/dist/chunks/{super-editor.es-DHDx2fsy.cjs → super-editor.es-CIDcWgLs.cjs} +198 -76
- package/dist/chunks/{super-editor.es-vfoWxyZL.es.js → super-editor.es-WUoM0FI7.es.js} +198 -76
- 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-BcqEfCTg.js → converter-DBwwYo1I.js} +187 -63
- package/dist/super-editor/chunks/{docx-zipper-DZ9ph0iQ.js → docx-zipper-BCI-3XE9.js} +1 -1
- package/dist/super-editor/chunks/{editor-BC2sSIVa.js → editor-W3rw5KHF.js} +13 -6
- package/dist/super-editor/chunks/{toolbar-DNTo5DDf.js → toolbar-CFfRuTi3.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/super-converter/SuperConverter.d.ts +1 -13
- package/dist/super-editor/src/extensions/custom-selection/custom-selection.d.ts +0 -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 +235 -93
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/super-editor/src/components/slash-menu/contextmenu-helpers.d.ts +0 -1
package/dist/superdoc.umd.js
CHANGED
|
@@ -32581,17 +32581,16 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32581
32581
|
};
|
|
32582
32582
|
const getDefaultParagraphStyle = (docx, styleId = "") => {
|
|
32583
32583
|
const styles = docx["word/styles.xml"];
|
|
32584
|
-
|
|
32584
|
+
const rootElements = styles?.elements?.[0]?.elements;
|
|
32585
|
+
if (!rootElements?.length) {
|
|
32585
32586
|
return {};
|
|
32586
32587
|
}
|
|
32587
|
-
const defaults =
|
|
32588
|
-
const pDefault = defaults
|
|
32588
|
+
const defaults = rootElements.find((el) => el.name === "w:docDefaults");
|
|
32589
|
+
const pDefault = defaults?.elements?.find((el) => el.name === "w:pPrDefault") || {};
|
|
32589
32590
|
const pPrDefault = pDefault?.elements?.find((el) => el.name === "w:pPr");
|
|
32590
32591
|
const pPrDefaultSpacingTag = pPrDefault?.elements?.find((el) => el.name === "w:spacing") || {};
|
|
32591
32592
|
const pPrDefaultIndentTag = pPrDefault?.elements?.find((el) => el.name === "w:ind") || {};
|
|
32592
|
-
const stylesNormal =
|
|
32593
|
-
(el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal"
|
|
32594
|
-
);
|
|
32593
|
+
const stylesNormal = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal");
|
|
32595
32594
|
const pPrNormal = stylesNormal?.elements?.find((el) => el.name === "w:pPr");
|
|
32596
32595
|
const pPrNormalSpacingTag = pPrNormal?.elements?.find((el) => el.name === "w:spacing") || {};
|
|
32597
32596
|
const pPrNormalIndentTag = pPrNormal?.elements?.find((el) => el.name === "w:ind") || {};
|
|
@@ -32600,9 +32599,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
32600
32599
|
let pPrStyleIdIndentTag = {};
|
|
32601
32600
|
let pPrStyleJc = {};
|
|
32602
32601
|
if (styleId) {
|
|
32603
|
-
const stylesById =
|
|
32604
|
-
(el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId
|
|
32605
|
-
);
|
|
32602
|
+
const stylesById = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId);
|
|
32606
32603
|
const pPrById = stylesById?.elements?.find((el) => el.name === "w:pPr");
|
|
32607
32604
|
pPrStyleIdSpacingTag = pPrById?.elements?.find((el) => el.name === "w:spacing") || {};
|
|
32608
32605
|
pPrStyleIdIndentTag = pPrById?.elements?.find((el) => el.name === "w:ind") || {};
|
|
@@ -38336,6 +38333,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38336
38333
|
attributes: validXmlAttributes
|
|
38337
38334
|
};
|
|
38338
38335
|
const translator = NodeTranslator.from(config);
|
|
38336
|
+
const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
|
|
38337
|
+
pageSize: Object.freeze({ width: "12240", height: "15840" }),
|
|
38338
|
+
pageMargins: Object.freeze({
|
|
38339
|
+
top: "1440",
|
|
38340
|
+
right: "1440",
|
|
38341
|
+
bottom: "1440",
|
|
38342
|
+
left: "1440",
|
|
38343
|
+
header: "720",
|
|
38344
|
+
footer: "720",
|
|
38345
|
+
gutter: "0"
|
|
38346
|
+
})
|
|
38347
|
+
});
|
|
38339
38348
|
const isLineBreakOnlyRun = (node) => {
|
|
38340
38349
|
if (!node) return false;
|
|
38341
38350
|
if (node.type === "lineBreak" || node.type === "hardBreak") return true;
|
|
@@ -38388,28 +38397,63 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
38388
38397
|
return handler2(params2);
|
|
38389
38398
|
}
|
|
38390
38399
|
function translateBodyNode(params2) {
|
|
38391
|
-
let sectPr = params2.bodyNode?.elements
|
|
38400
|
+
let sectPr = params2.bodyNode?.elements?.find((n) => n.name === "w:sectPr");
|
|
38401
|
+
if (!sectPr) {
|
|
38402
|
+
sectPr = {
|
|
38403
|
+
type: "element",
|
|
38404
|
+
name: "w:sectPr",
|
|
38405
|
+
elements: []
|
|
38406
|
+
};
|
|
38407
|
+
} else if (!sectPr.elements) {
|
|
38408
|
+
sectPr = { ...sectPr, elements: [] };
|
|
38409
|
+
}
|
|
38392
38410
|
if (params2.converter) {
|
|
38393
|
-
const hasHeader = sectPr
|
|
38411
|
+
const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
|
|
38394
38412
|
const hasDefaultHeader = params2.converter.headerIds?.default;
|
|
38395
38413
|
if (!hasHeader && hasDefaultHeader && !params2.editor.options.isHeaderOrFooter) {
|
|
38396
38414
|
const defaultHeader = generateDefaultHeaderFooter("header", params2.converter.headerIds?.default);
|
|
38397
38415
|
sectPr.elements.push(defaultHeader);
|
|
38398
38416
|
}
|
|
38399
|
-
const hasFooter = sectPr
|
|
38417
|
+
const hasFooter = sectPr.elements?.some((n) => n.name === "w:footerReference");
|
|
38400
38418
|
const hasDefaultFooter = params2.converter.footerIds?.default;
|
|
38401
38419
|
if (!hasFooter && hasDefaultFooter && !params2.editor.options.isHeaderOrFooter) {
|
|
38402
38420
|
const defaultFooter = generateDefaultHeaderFooter("footer", params2.converter.footerIds?.default);
|
|
38403
38421
|
sectPr.elements.push(defaultFooter);
|
|
38404
38422
|
}
|
|
38405
|
-
const newMargins = params2.converter.pageStyles
|
|
38406
|
-
|
|
38407
|
-
|
|
38408
|
-
|
|
38409
|
-
|
|
38410
|
-
|
|
38411
|
-
|
|
38412
|
-
|
|
38423
|
+
const newMargins = params2.converter.pageStyles?.pageMargins;
|
|
38424
|
+
if (newMargins) {
|
|
38425
|
+
let sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
|
|
38426
|
+
if (!sectPrMargins) {
|
|
38427
|
+
sectPrMargins = {
|
|
38428
|
+
type: "element",
|
|
38429
|
+
name: "w:pgMar",
|
|
38430
|
+
attributes: {}
|
|
38431
|
+
};
|
|
38432
|
+
sectPr.elements.push(sectPrMargins);
|
|
38433
|
+
} else if (!sectPrMargins.attributes) {
|
|
38434
|
+
sectPrMargins.attributes = {};
|
|
38435
|
+
}
|
|
38436
|
+
Object.entries(newMargins).forEach(([key2, value]) => {
|
|
38437
|
+
const convertedValue = inchesToTwips(value);
|
|
38438
|
+
sectPrMargins.attributes[`w:${key2}`] = convertedValue;
|
|
38439
|
+
});
|
|
38440
|
+
}
|
|
38441
|
+
let sectPrPgSz = sectPr.elements.find((n) => n.name === "w:pgSz");
|
|
38442
|
+
if (!sectPrPgSz) {
|
|
38443
|
+
sectPrPgSz = {
|
|
38444
|
+
type: "element",
|
|
38445
|
+
name: "w:pgSz",
|
|
38446
|
+
attributes: {}
|
|
38447
|
+
};
|
|
38448
|
+
sectPr.elements.push(sectPrPgSz);
|
|
38449
|
+
} else if (!sectPrPgSz.attributes) {
|
|
38450
|
+
sectPrPgSz.attributes = {};
|
|
38451
|
+
}
|
|
38452
|
+
const pageSize = params2.converter.pageStyles?.pageSize;
|
|
38453
|
+
const widthInches = pageSize?.width;
|
|
38454
|
+
const heightInches = pageSize?.height;
|
|
38455
|
+
sectPrPgSz.attributes["w:w"] = widthInches ? String(inchesToTwips(widthInches)) : sectPrPgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.width;
|
|
38456
|
+
sectPrPgSz.attributes["w:h"] = heightInches ? String(inchesToTwips(heightInches)) : sectPrPgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS_TWIPS.pageSize.height;
|
|
38413
38457
|
}
|
|
38414
38458
|
const elements = translateChildNodes(params2);
|
|
38415
38459
|
if (params2.isHeaderFooter) {
|
|
@@ -40397,6 +40441,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
40397
40441
|
const nodeListHandler = defaultNodeListHandler();
|
|
40398
40442
|
const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
|
|
40399
40443
|
if (bodyNode) {
|
|
40444
|
+
ensureSectionProperties(bodyNode);
|
|
40400
40445
|
const node = bodyNode;
|
|
40401
40446
|
const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
|
|
40402
40447
|
const content = pruneIgnoredNodes(contentElements);
|
|
@@ -40630,6 +40675,59 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
40630
40675
|
styles.alternateHeaders = isAlternatingHeadersOddEven(docx);
|
|
40631
40676
|
return styles;
|
|
40632
40677
|
}
|
|
40678
|
+
const DEFAULT_SECTION_PROPS = Object.freeze({
|
|
40679
|
+
pageSize: Object.freeze({ width: "12240", height: "15840" }),
|
|
40680
|
+
pageMargins: Object.freeze({
|
|
40681
|
+
top: "1440",
|
|
40682
|
+
right: "1440",
|
|
40683
|
+
bottom: "1440",
|
|
40684
|
+
left: "1440",
|
|
40685
|
+
header: "720",
|
|
40686
|
+
footer: "720",
|
|
40687
|
+
gutter: "0"
|
|
40688
|
+
})
|
|
40689
|
+
});
|
|
40690
|
+
function ensureSectionProperties(bodyNode, converter) {
|
|
40691
|
+
if (!bodyNode.elements) bodyNode.elements = [];
|
|
40692
|
+
let sectPr = bodyNode.elements.find((el) => el.name === "w:sectPr");
|
|
40693
|
+
if (!sectPr) {
|
|
40694
|
+
sectPr = {
|
|
40695
|
+
type: "element",
|
|
40696
|
+
name: "w:sectPr",
|
|
40697
|
+
elements: []
|
|
40698
|
+
};
|
|
40699
|
+
bodyNode.elements.push(sectPr);
|
|
40700
|
+
} else if (!sectPr.elements) {
|
|
40701
|
+
sectPr.elements = [];
|
|
40702
|
+
}
|
|
40703
|
+
const ensureChild = (name, factory) => {
|
|
40704
|
+
let child = sectPr.elements.find((el) => el.name === name);
|
|
40705
|
+
if (!child) {
|
|
40706
|
+
child = factory();
|
|
40707
|
+
sectPr.elements.push(child);
|
|
40708
|
+
} else if (!child.attributes) {
|
|
40709
|
+
child.attributes = {};
|
|
40710
|
+
}
|
|
40711
|
+
return child;
|
|
40712
|
+
};
|
|
40713
|
+
const pgSz = ensureChild("w:pgSz", () => ({
|
|
40714
|
+
type: "element",
|
|
40715
|
+
name: "w:pgSz",
|
|
40716
|
+
attributes: {}
|
|
40717
|
+
}));
|
|
40718
|
+
pgSz.attributes["w:w"] = pgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS.pageSize.width;
|
|
40719
|
+
pgSz.attributes["w:h"] = pgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS.pageSize.height;
|
|
40720
|
+
const pgMar = ensureChild("w:pgMar", () => ({
|
|
40721
|
+
type: "element",
|
|
40722
|
+
name: "w:pgMar",
|
|
40723
|
+
attributes: {}
|
|
40724
|
+
}));
|
|
40725
|
+
Object.entries(DEFAULT_SECTION_PROPS.pageMargins).forEach(([key2, value]) => {
|
|
40726
|
+
const attrKey = `w:${key2}`;
|
|
40727
|
+
if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
|
|
40728
|
+
});
|
|
40729
|
+
return sectPr;
|
|
40730
|
+
}
|
|
40633
40731
|
function getStyleDefinitions(docx) {
|
|
40634
40732
|
const styles = docx["word/styles.xml"];
|
|
40635
40733
|
if (!styles) return [];
|
|
@@ -40822,6 +40920,36 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
40822
40920
|
auto: "sans-serif"
|
|
40823
40921
|
});
|
|
40824
40922
|
const DEFAULT_GENERIC_FALLBACK = "sans-serif";
|
|
40923
|
+
const DEFAULT_FONT_SIZE_PT = 10;
|
|
40924
|
+
const collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state: state2 }) => {
|
|
40925
|
+
if (!runProps?.elements?.length || !state2) return;
|
|
40926
|
+
const fontsNode = runProps.elements.find((el) => el.name === "w:rFonts");
|
|
40927
|
+
if (fontsNode?.attributes) {
|
|
40928
|
+
const themeName = fontsNode.attributes["w:asciiTheme"];
|
|
40929
|
+
if (themeName) {
|
|
40930
|
+
const themeInfo = themeResolver?.(themeName) || {};
|
|
40931
|
+
if ((allowOverrideTypeface || !state2.typeface) && themeInfo.typeface) state2.typeface = themeInfo.typeface;
|
|
40932
|
+
if ((allowOverrideTypeface || !state2.panose) && themeInfo.panose) state2.panose = themeInfo.panose;
|
|
40933
|
+
}
|
|
40934
|
+
const ascii = fontsNode.attributes["w:ascii"];
|
|
40935
|
+
if ((allowOverrideTypeface || !state2.typeface) && ascii) {
|
|
40936
|
+
state2.typeface = ascii;
|
|
40937
|
+
}
|
|
40938
|
+
}
|
|
40939
|
+
const sizeNode = runProps.elements.find((el) => el.name === "w:sz");
|
|
40940
|
+
if (sizeNode?.attributes?.["w:val"]) {
|
|
40941
|
+
const sizeTwips = Number(sizeNode.attributes["w:val"]);
|
|
40942
|
+
if (Number.isFinite(sizeTwips)) {
|
|
40943
|
+
if (state2.fallbackSzTwips === void 0) state2.fallbackSzTwips = sizeTwips;
|
|
40944
|
+
const sizePt = sizeTwips / 2;
|
|
40945
|
+
if (allowOverrideSize || state2.fontSizePt === void 0) state2.fontSizePt = sizePt;
|
|
40946
|
+
}
|
|
40947
|
+
}
|
|
40948
|
+
const kernNode = runProps.elements.find((el) => el.name === "w:kern");
|
|
40949
|
+
if (kernNode?.attributes?.["w:val"]) {
|
|
40950
|
+
if (allowOverrideSize || state2.kern === void 0) state2.kern = kernNode.attributes["w:val"];
|
|
40951
|
+
}
|
|
40952
|
+
};
|
|
40825
40953
|
const _SuperConverter = class _SuperConverter2 {
|
|
40826
40954
|
constructor(params2 = null) {
|
|
40827
40955
|
__privateAdd$2(this, _SuperConverter_instances);
|
|
@@ -40949,49 +41077,45 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
40949
41077
|
}
|
|
40950
41078
|
getDocumentDefaultStyles() {
|
|
40951
41079
|
const styles = this.convertedXml["word/styles.xml"];
|
|
40952
|
-
|
|
40953
|
-
const
|
|
40954
|
-
|
|
40955
|
-
|
|
40956
|
-
const
|
|
40957
|
-
const
|
|
40958
|
-
|
|
40959
|
-
|
|
40960
|
-
|
|
40961
|
-
|
|
40962
|
-
|
|
40963
|
-
|
|
40964
|
-
|
|
40965
|
-
|
|
40966
|
-
|
|
40967
|
-
|
|
40968
|
-
|
|
40969
|
-
|
|
40970
|
-
|
|
40971
|
-
|
|
40972
|
-
|
|
40973
|
-
|
|
40974
|
-
|
|
40975
|
-
|
|
40976
|
-
|
|
40977
|
-
|
|
40978
|
-
|
|
40979
|
-
|
|
40980
|
-
|
|
40981
|
-
|
|
40982
|
-
|
|
40983
|
-
|
|
40984
|
-
|
|
40985
|
-
|
|
40986
|
-
|
|
40987
|
-
|
|
40988
|
-
|
|
40989
|
-
|
|
40990
|
-
|
|
40991
|
-
const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
|
|
40992
|
-
const fontFamilyCss = _SuperConverter2.toCssFontFamily(typeface, this.convertedXml);
|
|
40993
|
-
return { fontSizePt, kern, typeface, panose, fontFamilyCss };
|
|
40994
|
-
}
|
|
41080
|
+
const styleRoot = styles?.elements?.[0];
|
|
41081
|
+
const styleElements = styleRoot?.elements || [];
|
|
41082
|
+
if (!styleElements.length) return {};
|
|
41083
|
+
const defaults = styleElements.find((el) => el.name === "w:docDefaults");
|
|
41084
|
+
const normalStyle = styleElements.find((el) => el.name === "w:style" && el.attributes?.["w:styleId"] === "Normal");
|
|
41085
|
+
const defaultsState = {
|
|
41086
|
+
typeface: void 0,
|
|
41087
|
+
panose: void 0,
|
|
41088
|
+
fontSizePt: void 0,
|
|
41089
|
+
kern: void 0,
|
|
41090
|
+
fallbackSzTwips: void 0
|
|
41091
|
+
};
|
|
41092
|
+
const docDefaultRun = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
|
|
41093
|
+
const docDefaultProps = docDefaultRun?.elements?.find((el) => el.name === "w:rPr") ?? docDefaultRun;
|
|
41094
|
+
collectRunDefaultProperties(docDefaultProps, {
|
|
41095
|
+
allowOverrideTypeface: true,
|
|
41096
|
+
allowOverrideSize: true,
|
|
41097
|
+
themeResolver: (theme) => this.getThemeInfo(theme),
|
|
41098
|
+
state: defaultsState
|
|
41099
|
+
});
|
|
41100
|
+
const normalRunProps = normalStyle?.elements?.find((el) => el.name === "w:rPr") ?? null;
|
|
41101
|
+
collectRunDefaultProperties(normalRunProps, {
|
|
41102
|
+
allowOverrideTypeface: true,
|
|
41103
|
+
allowOverrideSize: true,
|
|
41104
|
+
themeResolver: (theme) => this.getThemeInfo(theme),
|
|
41105
|
+
state: defaultsState
|
|
41106
|
+
});
|
|
41107
|
+
if (defaultsState.fontSizePt === void 0) {
|
|
41108
|
+
if (Number.isFinite(defaultsState.fallbackSzTwips)) defaultsState.fontSizePt = defaultsState.fallbackSzTwips / 2;
|
|
41109
|
+
else defaultsState.fontSizePt = DEFAULT_FONT_SIZE_PT;
|
|
41110
|
+
}
|
|
41111
|
+
const fontFamilyCss = defaultsState.typeface ? _SuperConverter2.toCssFontFamily(defaultsState.typeface, this.convertedXml) : void 0;
|
|
41112
|
+
const result = {};
|
|
41113
|
+
if (defaultsState.fontSizePt !== void 0) result.fontSizePt = defaultsState.fontSizePt;
|
|
41114
|
+
if (defaultsState.kern !== void 0) result.kern = defaultsState.kern;
|
|
41115
|
+
if (defaultsState.typeface) result.typeface = defaultsState.typeface;
|
|
41116
|
+
if (defaultsState.panose) result.panose = defaultsState.panose;
|
|
41117
|
+
if (fontFamilyCss) result.fontFamilyCss = fontFamilyCss;
|
|
41118
|
+
return result;
|
|
40995
41119
|
}
|
|
40996
41120
|
getDocumentFonts() {
|
|
40997
41121
|
const fontTable = this.convertedXml["word/fontTable.xml"];
|
|
@@ -61289,15 +61413,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
|
|
|
61289
61413
|
}
|
|
61290
61414
|
return result;
|
|
61291
61415
|
};
|
|
61292
|
-
const
|
|
61293
|
-
|
|
61416
|
+
const isKeyboardInvocation = (event) => {
|
|
61417
|
+
return event.type === "contextmenu" && typeof event.detail === "number" && event.detail === 0 && (event.button === 0 || event.button === void 0) && event.clientX === 0 && event.clientY === 0;
|
|
61418
|
+
};
|
|
61419
|
+
const prefersNativeMenu = (event) => {
|
|
61294
61420
|
if (!event) return false;
|
|
61295
61421
|
if (event.ctrlKey || event.metaKey) {
|
|
61296
61422
|
return true;
|
|
61297
61423
|
}
|
|
61298
|
-
|
|
61299
|
-
|
|
61424
|
+
return isKeyboardInvocation(event);
|
|
61425
|
+
};
|
|
61426
|
+
const shouldAllowNativeContextMenu = (event) => {
|
|
61427
|
+
return prefersNativeMenu(event);
|
|
61300
61428
|
};
|
|
61429
|
+
const shouldBypassContextMenu = shouldAllowNativeContextMenu;
|
|
61430
|
+
const CustomSelectionPluginKey = new PluginKey("CustomSelection");
|
|
61301
61431
|
const handleClickOutside = (event, editor) => {
|
|
61302
61432
|
const editorElem = editor?.options?.element;
|
|
61303
61433
|
if (!editorElem) return;
|
|
@@ -90799,7 +90929,7 @@ ${style2}
|
|
|
90799
90929
|
if (!argument) return;
|
|
90800
90930
|
item.onActivate({ zoom: argument });
|
|
90801
90931
|
this.emit("superdoc-command", { item, argument });
|
|
90802
|
-
const layers =
|
|
90932
|
+
const layers = this.superdoc.element?.querySelector(".layers");
|
|
90803
90933
|
if (!layers) return;
|
|
90804
90934
|
const isMobileDevice = typeof screen.orientation !== "undefined";
|
|
90805
90935
|
const isSmallScreen = window.matchMedia("(max-width: 834px)").matches;
|
|
@@ -91861,14 +91991,6 @@ ${style2}
|
|
|
91861
91991
|
return null;
|
|
91862
91992
|
}
|
|
91863
91993
|
}
|
|
91864
|
-
const shouldBypassContextMenu = (event) => {
|
|
91865
|
-
if (!event) return false;
|
|
91866
|
-
if (event.ctrlKey || event.metaKey) {
|
|
91867
|
-
return true;
|
|
91868
|
-
}
|
|
91869
|
-
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;
|
|
91870
|
-
return Boolean(isKeyboardInvocation);
|
|
91871
|
-
};
|
|
91872
91994
|
const isModuleEnabled = (editorOptions, moduleName) => {
|
|
91873
91995
|
switch (moduleName) {
|
|
91874
91996
|
case "ai":
|
|
@@ -110476,6 +110598,9 @@ ${style2}
|
|
|
110476
110598
|
this.isDev = this.config.isDev || false;
|
|
110477
110599
|
this.activeEditor = null;
|
|
110478
110600
|
this.comments = [];
|
|
110601
|
+
if (!this.config.selector) {
|
|
110602
|
+
throw new Error("SuperDoc: selector is required");
|
|
110603
|
+
}
|
|
110479
110604
|
this.app.mount(this.config.selector);
|
|
110480
110605
|
this.readyEditors = 0;
|
|
110481
110606
|
this.isLocked = this.config.isLocked || false;
|
|
@@ -110495,6 +110620,16 @@ ${style2}
|
|
|
110495
110620
|
users: this.users
|
|
110496
110621
|
};
|
|
110497
110622
|
}
|
|
110623
|
+
/**
|
|
110624
|
+
* Get the SuperDoc container element
|
|
110625
|
+
* @returns {HTMLElement | null}
|
|
110626
|
+
*/
|
|
110627
|
+
get element() {
|
|
110628
|
+
if (typeof this.config.selector === "string") {
|
|
110629
|
+
return document.querySelector(this.config.selector);
|
|
110630
|
+
}
|
|
110631
|
+
return this.config.selector;
|
|
110632
|
+
}
|
|
110498
110633
|
#patchNaiveUIStyles() {
|
|
110499
110634
|
const cspNonce = this.config.cspNonce;
|
|
110500
110635
|
const originalCreateElement = document.createElement;
|
|
@@ -110518,10 +110653,16 @@ ${style2}
|
|
|
110518
110653
|
}
|
|
110519
110654
|
if (hasDocumentConfig) {
|
|
110520
110655
|
const normalized = normalizeDocumentEntry(this.config.document);
|
|
110521
|
-
this.config.documents = [
|
|
110656
|
+
this.config.documents = [
|
|
110657
|
+
{
|
|
110658
|
+
id: v4(),
|
|
110659
|
+
...normalized
|
|
110660
|
+
}
|
|
110661
|
+
];
|
|
110522
110662
|
} else if (hasDocumentUrl) {
|
|
110523
110663
|
this.config.documents = [
|
|
110524
110664
|
{
|
|
110665
|
+
id: v4(),
|
|
110525
110666
|
type: DOCX,
|
|
110526
110667
|
url: this.config.document,
|
|
110527
110668
|
name: "document.docx",
|
|
@@ -110529,33 +110670,34 @@ ${style2}
|
|
|
110529
110670
|
}
|
|
110530
110671
|
];
|
|
110531
110672
|
} else if (hasDocumentFile) {
|
|
110673
|
+
const normalized = normalizeDocumentEntry(this.config.document);
|
|
110532
110674
|
this.config.documents = [
|
|
110533
110675
|
{
|
|
110534
|
-
|
|
110535
|
-
|
|
110536
|
-
name: this.config.document.name,
|
|
110537
|
-
isNewFile: true
|
|
110676
|
+
id: v4(),
|
|
110677
|
+
...normalized
|
|
110538
110678
|
}
|
|
110539
110679
|
];
|
|
110540
110680
|
} else if (hasDocumentBlob) {
|
|
110541
|
-
const
|
|
110542
|
-
let extension = ".docx";
|
|
110543
|
-
if (docType === PDF) {
|
|
110544
|
-
extension = ".pdf";
|
|
110545
|
-
} else if (docType === HTML) {
|
|
110546
|
-
extension = ".html";
|
|
110547
|
-
}
|
|
110681
|
+
const normalized = normalizeDocumentEntry(this.config.document);
|
|
110548
110682
|
this.config.documents = [
|
|
110549
110683
|
{
|
|
110550
|
-
|
|
110551
|
-
|
|
110552
|
-
name: `document${extension}`,
|
|
110553
|
-
isNewFile: true
|
|
110684
|
+
id: v4(),
|
|
110685
|
+
...normalized
|
|
110554
110686
|
}
|
|
110555
110687
|
];
|
|
110556
110688
|
}
|
|
110557
110689
|
if (Array.isArray(this.config.documents) && this.config.documents.length > 0) {
|
|
110558
|
-
this.config.documents = this.config.documents.map((d2) =>
|
|
110690
|
+
this.config.documents = this.config.documents.map((d2) => {
|
|
110691
|
+
const normalized = normalizeDocumentEntry(d2);
|
|
110692
|
+
if (!normalized || typeof normalized !== "object") {
|
|
110693
|
+
return normalized;
|
|
110694
|
+
}
|
|
110695
|
+
const existingId = typeof normalized === "object" && "id" in normalized && normalized.id || d2 && typeof d2 === "object" && "id" in d2 && d2.id;
|
|
110696
|
+
return {
|
|
110697
|
+
...normalized,
|
|
110698
|
+
id: existingId || v4()
|
|
110699
|
+
};
|
|
110700
|
+
});
|
|
110559
110701
|
}
|
|
110560
110702
|
}
|
|
110561
110703
|
#initVueApp() {
|