@harbour-enterprises/superdoc 0.22.0-next.2 → 0.22.0-next.4

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.
Files changed (29) hide show
  1. package/dist/chunks/{PdfViewer-OEs-MC5j.es.js → PdfViewer-BBpGCmdE.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-Ck3Syakz.cjs → PdfViewer-CxIz7yf-.cjs} +1 -1
  3. package/dist/chunks/{index-BM732Zfw.cjs → index-BE07bQaY.cjs} +39 -19
  4. package/dist/chunks/{index-B4aklZ4_.es.js → index-CYCctXm3.es.js} +39 -19
  5. package/dist/chunks/{super-editor.es-Bokezk1E.es.js → super-editor.es-Ccu1wOj1.es.js} +201 -72
  6. package/dist/chunks/{super-editor.es-DwGNbrZq.cjs → super-editor.es-cZsHkhM6.cjs} +201 -72
  7. package/dist/core/SuperDoc.d.ts +5 -0
  8. package/dist/core/SuperDoc.d.ts.map +1 -1
  9. package/dist/core/types/index.d.ts +4 -4
  10. package/dist/core/types/index.d.ts.map +1 -1
  11. package/dist/super-editor/ai-writer.es.js +2 -2
  12. package/dist/super-editor/chunks/{converter-BcqEfCTg.js → converter-DBwwYo1I.js} +187 -63
  13. package/dist/super-editor/chunks/{docx-zipper-DZ9ph0iQ.js → docx-zipper-BCI-3XE9.js} +1 -1
  14. package/dist/super-editor/chunks/{editor-CTHD3ziL.js → editor-B2S-zXBF.js} +15 -10
  15. package/dist/super-editor/chunks/{toolbar-DLQeMuoQ.js → toolbar-BX9nPPG0.js} +2 -2
  16. package/dist/super-editor/converter.es.js +1 -1
  17. package/dist/super-editor/docx-zipper.es.js +2 -2
  18. package/dist/super-editor/editor.es.js +3 -3
  19. package/dist/super-editor/file-zipper.es.js +1 -1
  20. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +1 -13
  21. package/dist/super-editor/super-editor.es.js +7 -7
  22. package/dist/super-editor/toolbar.es.js +2 -2
  23. package/dist/super-editor.cjs +1 -1
  24. package/dist/super-editor.es.js +1 -1
  25. package/dist/superdoc.cjs +2 -2
  26. package/dist/superdoc.es.js +2 -2
  27. package/dist/superdoc.umd.js +238 -89
  28. package/dist/superdoc.umd.js.map +1 -1
  29. package/package.json +1 -1
@@ -24846,17 +24846,16 @@ const getParagraphSpacing = (node, docx, styleId = "", marks = [], options = {})
24846
24846
  };
24847
24847
  const getDefaultParagraphStyle = (docx, styleId = "") => {
24848
24848
  const styles = docx["word/styles.xml"];
24849
- if (!styles) {
24849
+ const rootElements = styles?.elements?.[0]?.elements;
24850
+ if (!rootElements?.length) {
24850
24851
  return {};
24851
24852
  }
24852
- const defaults = styles.elements[0].elements?.find((el) => el.name === "w:docDefaults");
24853
- const pDefault = defaults.elements.find((el) => el.name === "w:pPrDefault");
24853
+ const defaults = rootElements.find((el) => el.name === "w:docDefaults");
24854
+ const pDefault = defaults?.elements?.find((el) => el.name === "w:pPrDefault") || {};
24854
24855
  const pPrDefault = pDefault?.elements?.find((el) => el.name === "w:pPr");
24855
24856
  const pPrDefaultSpacingTag = pPrDefault?.elements?.find((el) => el.name === "w:spacing") || {};
24856
24857
  const pPrDefaultIndentTag = pPrDefault?.elements?.find((el) => el.name === "w:ind") || {};
24857
- const stylesNormal = styles.elements[0].elements?.find(
24858
- (el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal"
24859
- );
24858
+ const stylesNormal = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === "Normal");
24860
24859
  const pPrNormal = stylesNormal?.elements?.find((el) => el.name === "w:pPr");
24861
24860
  const pPrNormalSpacingTag = pPrNormal?.elements?.find((el) => el.name === "w:spacing") || {};
24862
24861
  const pPrNormalIndentTag = pPrNormal?.elements?.find((el) => el.name === "w:ind") || {};
@@ -24865,9 +24864,7 @@ const getDefaultParagraphStyle = (docx, styleId = "") => {
24865
24864
  let pPrStyleIdIndentTag = {};
24866
24865
  let pPrStyleJc = {};
24867
24866
  if (styleId) {
24868
- const stylesById = styles.elements[0].elements?.find(
24869
- (el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId
24870
- );
24867
+ const stylesById = rootElements.find((el) => el.name === "w:style" && el.attributes["w:styleId"] === styleId);
24871
24868
  const pPrById = stylesById?.elements?.find((el) => el.name === "w:pPr");
24872
24869
  pPrStyleIdSpacingTag = pPrById?.elements?.find((el) => el.name === "w:spacing") || {};
24873
24870
  pPrStyleIdIndentTag = pPrById?.elements?.find((el) => el.name === "w:ind") || {};
@@ -30601,6 +30598,18 @@ const config = {
30601
30598
  attributes: validXmlAttributes
30602
30599
  };
30603
30600
  const translator = NodeTranslator.from(config);
30601
+ const DEFAULT_SECTION_PROPS_TWIPS = Object.freeze({
30602
+ pageSize: Object.freeze({ width: "12240", height: "15840" }),
30603
+ pageMargins: Object.freeze({
30604
+ top: "1440",
30605
+ right: "1440",
30606
+ bottom: "1440",
30607
+ left: "1440",
30608
+ header: "720",
30609
+ footer: "720",
30610
+ gutter: "0"
30611
+ })
30612
+ });
30604
30613
  const isLineBreakOnlyRun = (node) => {
30605
30614
  if (!node) return false;
30606
30615
  if (node.type === "lineBreak" || node.type === "hardBreak") return true;
@@ -30653,28 +30662,63 @@ function exportSchemaToJson(params) {
30653
30662
  return handler2(params);
30654
30663
  }
30655
30664
  function translateBodyNode(params) {
30656
- let sectPr = params.bodyNode?.elements.find((n) => n.name === "w:sectPr") || {};
30665
+ let sectPr = params.bodyNode?.elements?.find((n) => n.name === "w:sectPr");
30666
+ if (!sectPr) {
30667
+ sectPr = {
30668
+ type: "element",
30669
+ name: "w:sectPr",
30670
+ elements: []
30671
+ };
30672
+ } else if (!sectPr.elements) {
30673
+ sectPr = { ...sectPr, elements: [] };
30674
+ }
30657
30675
  if (params.converter) {
30658
- const hasHeader = sectPr?.elements?.some((n) => n.name === "w:headerReference");
30676
+ const hasHeader = sectPr.elements?.some((n) => n.name === "w:headerReference");
30659
30677
  const hasDefaultHeader = params.converter.headerIds?.default;
30660
30678
  if (!hasHeader && hasDefaultHeader && !params.editor.options.isHeaderOrFooter) {
30661
30679
  const defaultHeader = generateDefaultHeaderFooter("header", params.converter.headerIds?.default);
30662
30680
  sectPr.elements.push(defaultHeader);
30663
30681
  }
30664
- const hasFooter = sectPr?.elements?.some((n) => n.name === "w:footerReference");
30682
+ const hasFooter = sectPr.elements?.some((n) => n.name === "w:footerReference");
30665
30683
  const hasDefaultFooter = params.converter.footerIds?.default;
30666
30684
  if (!hasFooter && hasDefaultFooter && !params.editor.options.isHeaderOrFooter) {
30667
30685
  const defaultFooter = generateDefaultHeaderFooter("footer", params.converter.footerIds?.default);
30668
30686
  sectPr.elements.push(defaultFooter);
30669
30687
  }
30670
- const newMargins = params.converter.pageStyles.pageMargins;
30671
- const sectPrMargins = sectPr.elements.find((n) => n.name === "w:pgMar");
30672
- const { attributes } = sectPrMargins;
30673
- Object.entries(newMargins).forEach(([key, value]) => {
30674
- const convertedValue = inchesToTwips(value);
30675
- attributes[`w:${key}`] = convertedValue;
30676
- });
30677
- sectPrMargins.attributes = attributes;
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;
30678
30722
  }
30679
30723
  const elements = translateChildNodes(params);
30680
30724
  if (params.isHeaderFooter) {
@@ -32689,6 +32733,7 @@ const createDocumentJson = (docx, converter, editor) => {
32689
32733
  const nodeListHandler = defaultNodeListHandler();
32690
32734
  const bodyNode = json.elements[0].elements.find((el) => el.name === "w:body");
32691
32735
  if (bodyNode) {
32736
+ ensureSectionProperties(bodyNode);
32692
32737
  const node = bodyNode;
32693
32738
  const contentElements = node.elements?.filter((n) => n.name !== "w:sectPr") ?? [];
32694
32739
  const content = pruneIgnoredNodes(contentElements);
@@ -32922,6 +32967,59 @@ function getDocumentStyles(node, docx, converter, editor) {
32922
32967
  styles.alternateHeaders = isAlternatingHeadersOddEven(docx);
32923
32968
  return styles;
32924
32969
  }
32970
+ const DEFAULT_SECTION_PROPS = Object.freeze({
32971
+ pageSize: Object.freeze({ width: "12240", height: "15840" }),
32972
+ pageMargins: Object.freeze({
32973
+ top: "1440",
32974
+ right: "1440",
32975
+ bottom: "1440",
32976
+ left: "1440",
32977
+ header: "720",
32978
+ footer: "720",
32979
+ gutter: "0"
32980
+ })
32981
+ });
32982
+ function ensureSectionProperties(bodyNode, converter) {
32983
+ if (!bodyNode.elements) bodyNode.elements = [];
32984
+ let sectPr = bodyNode.elements.find((el) => el.name === "w:sectPr");
32985
+ if (!sectPr) {
32986
+ sectPr = {
32987
+ type: "element",
32988
+ name: "w:sectPr",
32989
+ elements: []
32990
+ };
32991
+ bodyNode.elements.push(sectPr);
32992
+ } else if (!sectPr.elements) {
32993
+ sectPr.elements = [];
32994
+ }
32995
+ const ensureChild = (name, factory) => {
32996
+ let child = sectPr.elements.find((el) => el.name === name);
32997
+ if (!child) {
32998
+ child = factory();
32999
+ sectPr.elements.push(child);
33000
+ } else if (!child.attributes) {
33001
+ child.attributes = {};
33002
+ }
33003
+ return child;
33004
+ };
33005
+ const pgSz = ensureChild("w:pgSz", () => ({
33006
+ type: "element",
33007
+ name: "w:pgSz",
33008
+ attributes: {}
33009
+ }));
33010
+ pgSz.attributes["w:w"] = pgSz.attributes["w:w"] ?? DEFAULT_SECTION_PROPS.pageSize.width;
33011
+ pgSz.attributes["w:h"] = pgSz.attributes["w:h"] ?? DEFAULT_SECTION_PROPS.pageSize.height;
33012
+ const pgMar = ensureChild("w:pgMar", () => ({
33013
+ type: "element",
33014
+ name: "w:pgMar",
33015
+ attributes: {}
33016
+ }));
33017
+ Object.entries(DEFAULT_SECTION_PROPS.pageMargins).forEach(([key, value]) => {
33018
+ const attrKey = `w:${key}`;
33019
+ if (pgMar.attributes[attrKey] == null) pgMar.attributes[attrKey] = value;
33020
+ });
33021
+ return sectPr;
33022
+ }
32925
33023
  function getStyleDefinitions(docx) {
32926
33024
  const styles = docx["word/styles.xml"];
32927
33025
  if (!styles) return [];
@@ -33114,6 +33212,36 @@ const FONT_FAMILY_FALLBACKS = Object.freeze({
33114
33212
  auto: "sans-serif"
33115
33213
  });
33116
33214
  const DEFAULT_GENERIC_FALLBACK = "sans-serif";
33215
+ const DEFAULT_FONT_SIZE_PT = 10;
33216
+ const collectRunDefaultProperties = (runProps, { allowOverrideTypeface = true, allowOverrideSize = true, themeResolver, state: state2 }) => {
33217
+ if (!runProps?.elements?.length || !state2) return;
33218
+ const fontsNode = runProps.elements.find((el) => el.name === "w:rFonts");
33219
+ if (fontsNode?.attributes) {
33220
+ const themeName = fontsNode.attributes["w:asciiTheme"];
33221
+ if (themeName) {
33222
+ const themeInfo = themeResolver?.(themeName) || {};
33223
+ if ((allowOverrideTypeface || !state2.typeface) && themeInfo.typeface) state2.typeface = themeInfo.typeface;
33224
+ if ((allowOverrideTypeface || !state2.panose) && themeInfo.panose) state2.panose = themeInfo.panose;
33225
+ }
33226
+ const ascii = fontsNode.attributes["w:ascii"];
33227
+ if ((allowOverrideTypeface || !state2.typeface) && ascii) {
33228
+ state2.typeface = ascii;
33229
+ }
33230
+ }
33231
+ const sizeNode = runProps.elements.find((el) => el.name === "w:sz");
33232
+ if (sizeNode?.attributes?.["w:val"]) {
33233
+ const sizeTwips = Number(sizeNode.attributes["w:val"]);
33234
+ if (Number.isFinite(sizeTwips)) {
33235
+ if (state2.fallbackSzTwips === void 0) state2.fallbackSzTwips = sizeTwips;
33236
+ const sizePt = sizeTwips / 2;
33237
+ if (allowOverrideSize || state2.fontSizePt === void 0) state2.fontSizePt = sizePt;
33238
+ }
33239
+ }
33240
+ const kernNode = runProps.elements.find((el) => el.name === "w:kern");
33241
+ if (kernNode?.attributes?.["w:val"]) {
33242
+ if (allowOverrideSize || state2.kern === void 0) state2.kern = kernNode.attributes["w:val"];
33243
+ }
33244
+ };
33117
33245
  const _SuperConverter = class _SuperConverter {
33118
33246
  constructor(params = null) {
33119
33247
  __privateAdd(this, _SuperConverter_instances);
@@ -33241,49 +33369,45 @@ const _SuperConverter = class _SuperConverter {
33241
33369
  }
33242
33370
  getDocumentDefaultStyles() {
33243
33371
  const styles = this.convertedXml["word/styles.xml"];
33244
- if (!styles) return {};
33245
- const defaults = styles.elements[0].elements.find((el) => el.name === "w:docDefaults");
33246
- const rDefault = defaults.elements.find((el) => el.name === "w:rPrDefault");
33247
- if (!rDefault.elements) return {};
33248
- const rElements = rDefault.elements[0].elements;
33249
- const rFonts = rElements?.find((el) => el.name === "w:rFonts");
33250
- if ("elements" in rDefault) {
33251
- const fontThemeName = rElements.find((el) => el.name === "w:rFonts")?.attributes["w:asciiTheme"];
33252
- let typeface, panose, fontSizeNormal;
33253
- if (fontThemeName) {
33254
- const fontInfo = this.getThemeInfo(fontThemeName);
33255
- typeface = fontInfo.typeface;
33256
- panose = fontInfo.panose;
33257
- } else if (rFonts) {
33258
- typeface = rFonts?.attributes["w:ascii"];
33259
- }
33260
- const paragraphDefaults = styles.elements[0].elements.filter((el) => {
33261
- return el.name === "w:style" && el.attributes["w:styleId"] === "Normal";
33262
- }) || [];
33263
- paragraphDefaults.forEach((el) => {
33264
- const rPr = el.elements.find((el2) => el2.name === "w:rPr");
33265
- const fonts = rPr?.elements?.find((el2) => el2.name === "w:rFonts");
33266
- typeface = fonts?.attributes["w:ascii"];
33267
- fontSizeNormal = Number(rPr?.elements?.find((el2) => el2.name === "w:sz")?.attributes["w:val"]) / 2;
33268
- });
33269
- const rPrDefaults = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
33270
- if (rPrDefaults) {
33271
- const rPr = rPrDefaults.elements?.find((el) => el.name === "w:rPr");
33272
- const fonts = rPr?.elements?.find((el) => el.name === "w:rFonts");
33273
- if (fonts?.attributes?.["w:ascii"]) {
33274
- typeface = fonts.attributes["w:ascii"];
33275
- }
33276
- const fontSizeRaw = rPr?.elements?.find((el) => el.name === "w:sz")?.attributes?.["w:val"];
33277
- if (!fontSizeNormal && fontSizeRaw) {
33278
- fontSizeNormal = Number(fontSizeRaw) / 2;
33279
- }
33280
- }
33281
- const fallbackSz = Number(rElements.find((el) => el.name === "w:sz")?.attributes?.["w:val"]);
33282
- const fontSizePt = fontSizeNormal ?? (Number.isFinite(fallbackSz) ? fallbackSz / 2 : void 0) ?? 10;
33283
- const kern = rElements.find((el) => el.name === "w:kern")?.attributes["w:val"];
33284
- const fontFamilyCss = _SuperConverter.toCssFontFamily(typeface, this.convertedXml);
33285
- return { fontSizePt, kern, typeface, panose, fontFamilyCss };
33286
- }
33372
+ const styleRoot = styles?.elements?.[0];
33373
+ const styleElements = styleRoot?.elements || [];
33374
+ if (!styleElements.length) return {};
33375
+ const defaults = styleElements.find((el) => el.name === "w:docDefaults");
33376
+ const normalStyle = styleElements.find((el) => el.name === "w:style" && el.attributes?.["w:styleId"] === "Normal");
33377
+ const defaultsState = {
33378
+ typeface: void 0,
33379
+ panose: void 0,
33380
+ fontSizePt: void 0,
33381
+ kern: void 0,
33382
+ fallbackSzTwips: void 0
33383
+ };
33384
+ const docDefaultRun = defaults?.elements?.find((el) => el.name === "w:rPrDefault");
33385
+ const docDefaultProps = docDefaultRun?.elements?.find((el) => el.name === "w:rPr") ?? docDefaultRun;
33386
+ collectRunDefaultProperties(docDefaultProps, {
33387
+ allowOverrideTypeface: true,
33388
+ allowOverrideSize: true,
33389
+ themeResolver: (theme) => this.getThemeInfo(theme),
33390
+ state: defaultsState
33391
+ });
33392
+ const normalRunProps = normalStyle?.elements?.find((el) => el.name === "w:rPr") ?? null;
33393
+ collectRunDefaultProperties(normalRunProps, {
33394
+ allowOverrideTypeface: true,
33395
+ allowOverrideSize: true,
33396
+ themeResolver: (theme) => this.getThemeInfo(theme),
33397
+ state: defaultsState
33398
+ });
33399
+ if (defaultsState.fontSizePt === void 0) {
33400
+ if (Number.isFinite(defaultsState.fallbackSzTwips)) defaultsState.fontSizePt = defaultsState.fallbackSzTwips / 2;
33401
+ else defaultsState.fontSizePt = DEFAULT_FONT_SIZE_PT;
33402
+ }
33403
+ const fontFamilyCss = defaultsState.typeface ? _SuperConverter.toCssFontFamily(defaultsState.typeface, this.convertedXml) : void 0;
33404
+ const result = {};
33405
+ if (defaultsState.fontSizePt !== void 0) result.fontSizePt = defaultsState.fontSizePt;
33406
+ if (defaultsState.kern !== void 0) result.kern = defaultsState.kern;
33407
+ if (defaultsState.typeface) result.typeface = defaultsState.typeface;
33408
+ if (defaultsState.panose) result.panose = defaultsState.panose;
33409
+ if (fontFamilyCss) result.fontFamilyCss = fontFamilyCss;
33410
+ return result;
33287
33411
  }
33288
33412
  getDocumentFonts() {
33289
33413
  const fontTable = this.convertedXml["word/fontTable.xml"];
@@ -1,4 +1,4 @@
1
- import { p as process$1, au as commonjsGlobal, B as Buffer, av as getDefaultExportFromCjs, aw as getContentTypesFromXml, ax as xmljs } from "./converter-BcqEfCTg.js";
1
+ import { p as process$1, au as commonjsGlobal, B as Buffer, av as getDefaultExportFromCjs, aw as getContentTypesFromXml, ax as xmljs } from "./converter-DBwwYo1I.js";
2
2
  function commonjsRequire(path) {
3
3
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
4
4
  }
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_fn;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as SelectionRange, ao as Transform, ap as isInTable$1, aq as generateDocxRandomId, ar as insertNewRelationship, as as updateDOMAttributes, at as htmlHandler } from "./converter-BcqEfCTg.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as SelectionRange, ao as Transform, ap as isInTable$1, aq as generateDocxRandomId, ar as insertNewRelationship, as as updateDOMAttributes, at as htmlHandler } from "./converter-DBwwYo1I.js";
16
16
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
17
- import { D as DocxZipper } from "./docx-zipper-DZ9ph0iQ.js";
17
+ import { D as DocxZipper } from "./docx-zipper-BCI-3XE9.js";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
20
20
  };
@@ -11675,9 +11675,11 @@ const toggleHeaderFooterEditMode = ({ editor, focusedSectionEditor, isEditMode,
11675
11675
  item.editor.view.dom.setAttribute("documentmode", documentMode);
11676
11676
  });
11677
11677
  if (isEditMode) {
11678
- const pm = document.querySelector(".ProseMirror");
11679
- pm.classList.add("header-footer-edit");
11680
- pm.setAttribute("aria-readonly", true);
11678
+ const pm = editor.view?.dom || editor.options.element?.querySelector?.(".ProseMirror");
11679
+ if (pm) {
11680
+ pm.classList.add("header-footer-edit");
11681
+ pm.setAttribute("aria-readonly", true);
11682
+ }
11681
11683
  }
11682
11684
  if (focusedSectionEditor) {
11683
11685
  focusedSectionEditor.view.focus();
@@ -14332,7 +14334,7 @@ const _Editor = class _Editor extends EventEmitter {
14332
14334
  setDocumentMode(documentMode) {
14333
14335
  let cleanedMode = documentMode?.toLowerCase() || "editing";
14334
14336
  if (!this.extensionService || !this.state) return;
14335
- const pm = document.querySelector(".ProseMirror");
14337
+ const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
14336
14338
  if (this.options.role === "viewer") cleanedMode = "viewing";
14337
14339
  if (this.options.role === "suggester" && cleanedMode === "editing") cleanedMode = "suggesting";
14338
14340
  if (cleanedMode === "viewing") {
@@ -15380,9 +15382,11 @@ createView_fn = function(element) {
15380
15382
  isEditMode: false,
15381
15383
  documentMode: this.options.documentMode
15382
15384
  });
15383
- const pm = document.querySelector(".ProseMirror");
15384
- pm.classList.remove("header-footer-edit");
15385
- pm.setAttribute("aria-readonly", false);
15385
+ const pm = this.view?.dom || this.options.element?.querySelector?.(".ProseMirror");
15386
+ if (pm) {
15387
+ pm.classList.remove("header-footer-edit");
15388
+ pm.setAttribute("aria-readonly", false);
15389
+ }
15386
15390
  }
15387
15391
  setWordSelection(view, pos);
15388
15392
  }
@@ -33460,7 +33464,8 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
33460
33464
  const prevSelection = prevState.selection;
33461
33465
  if (selection.from !== prevSelection.from || selection.to !== prevSelection.to) {
33462
33466
  setTimeout(() => {
33463
- const selectedResizableWrapper = document.querySelector(".sd-editor-resizable-wrapper");
33467
+ const searchRoot = editorView?.dom;
33468
+ const selectedResizableWrapper = searchRoot?.querySelector(".sd-editor-resizable-wrapper");
33464
33469
  if (selectedResizableWrapper) {
33465
33470
  showResizeHandles(view2, selectedResizableWrapper);
33466
33471
  } else {
@@ -1,6 +1,6 @@
1
1
  import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, normalizeStyle, ref, withKeys, unref, withModifiers, createBlock, toDisplayString, withDirectives, vModelText, nextTick, getCurrentInstance, createVNode, readonly, watch, onMounted, onBeforeUnmount, reactive, onBeforeMount, inject, onActivated, onDeactivated, createTextVNode, Fragment, Comment, defineComponent, provide, h, Teleport, toRef, renderSlot, isVNode, shallowRef, watchEffect, mergeProps, Transition, vShow, cloneVNode, Text, renderList, withCtx } from "vue";
2
- import { p as process$1 } from "./converter-BcqEfCTg.js";
3
- import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-CTHD3ziL.js";
2
+ import { p as process$1 } from "./converter-DBwwYo1I.js";
3
+ import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-B2S-zXBF.js";
4
4
  const sanitizeNumber = (value, defaultNumber) => {
5
5
  let sanitized = value.replace(/[^0-9.]/g, "");
6
6
  sanitized = parseFloat(sanitized);
@@ -1,4 +1,4 @@
1
- import { a5 } from "./chunks/converter-BcqEfCTg.js";
1
+ import { a5 } from "./chunks/converter-DBwwYo1I.js";
2
2
  import "vue";
3
3
  export {
4
4
  a5 as SuperConverter
@@ -1,5 +1,5 @@
1
- import "./chunks/converter-BcqEfCTg.js";
2
- import { D } from "./chunks/docx-zipper-DZ9ph0iQ.js";
1
+ import "./chunks/converter-DBwwYo1I.js";
2
+ import { D } from "./chunks/docx-zipper-BCI-3XE9.js";
3
3
  export {
4
4
  D as default
5
5
  };
@@ -1,6 +1,6 @@
1
- import { E } from "./chunks/editor-CTHD3ziL.js";
2
- import "./chunks/converter-BcqEfCTg.js";
3
- import "./chunks/docx-zipper-DZ9ph0iQ.js";
1
+ import { E } from "./chunks/editor-B2S-zXBF.js";
2
+ import "./chunks/converter-DBwwYo1I.js";
3
+ import "./chunks/docx-zipper-BCI-3XE9.js";
4
4
  export {
5
5
  E as Editor
6
6
  };
@@ -1,4 +1,4 @@
1
- import { J as JSZip } from "./chunks/docx-zipper-DZ9ph0iQ.js";
1
+ import { J as JSZip } from "./chunks/docx-zipper-BCI-3XE9.js";
2
2
  async function createZip(blobs, fileNames) {
3
3
  const zip = new JSZip();
4
4
  blobs.forEach((blob, index) => {
@@ -98,19 +98,7 @@ export class SuperConverter {
98
98
  get docxHelpers(): any;
99
99
  parseFromXml(): void;
100
100
  parseXmlToJson(xml: any): any;
101
- getDocumentDefaultStyles(): {
102
- fontSizePt?: undefined;
103
- kern?: undefined;
104
- typeface?: undefined;
105
- panose?: undefined;
106
- fontFamilyCss?: undefined;
107
- } | {
108
- fontSizePt: number;
109
- kern: any;
110
- typeface: any;
111
- panose: any;
112
- fontFamilyCss: any;
113
- };
101
+ getDocumentDefaultStyles(): {};
114
102
  getDocumentFonts(): string;
115
103
  getDocumentInternalId(): void;
116
104
  createDocumentIdElement(): {
@@ -9,14 +9,14 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
11
11
  var _SuperToolbar_instances, initToolbarGroups_fn, _interceptedCommands, makeToolbarItems_fn, initDefaultFonts_fn, updateHighlightColors_fn, deactivateAll_fn, updateToolbarHistory_fn, runCommandWithArgumentOnly_fn;
12
- import { av as getDefaultExportFromCjs, V as v4, T as TextSelection$1, v as getMarkRange, ay as vClickOutside, H as findParentNode, az as getActiveFormatting, ap as isInTable, aA as readFromClipboard, aB as handleClipboardPaste, aC as getFileObject, aD as runPropertyTranslators, aE as translator, aF as translator$1, aG as translator$2, aH as translator$3, aI as translator$4, aJ as translator$5, aK as translator$6, aL as translator$7, aM as translator$8, aN as translator$9, aO as translator$a, aP as translator$b, aQ as translator$c, aR as translator$d, aS as translator$e, aT as translator$f, aU as translator$g, aV as translator$h, aW as translator$i, aX as translator$j, aY as translator$k, aZ as translator$l, a_ as translator$m, a$ as translator$n, b0 as translator$o, b1 as translator$p, b2 as translator$q, b3 as translator$r, b4 as translator$s, b5 as translator$t, b6 as translator$u, b7 as translator$v, b8 as translator$w, b9 as translator$x, ba as translator$y, bb as translator$z, bc as translator$A, bd as translator$B, be as translator$C, bf as translator$D, bg as translator$E, bh as translator$F, bi as translator$G, bj as translator$H, bk as translator$I, bl as translator$J, bm as translator$K, bn as translator$L, bo as translator$M, bp as translator$N, bq as translator$O, br as translator$P, bs as translator$Q, bt as translator$R, bu as translator$S, bv as translator$T, bw as translator$U, bx as translator$V, by as translator$W, bz as translator$X, bA as translator$Y, bB as translator$Z, bC as translator$_, bD as translator$$, bE as translator$10, a as Plugin } from "./chunks/converter-BcqEfCTg.js";
13
- import { bF, a5, i, a2 } from "./chunks/converter-BcqEfCTg.js";
14
- import { _ as _export_sfc, u as useHighContrastMode, a as getQuickFormatList, b as generateLinkedStyleString, c as getFileOpener, d as checkAndProcessImage, r as replaceSelectionWithImagePlaceholder, e as uploadAndInsertImage, y as yUndoPluginKey, f as undoDepth, h as redoDepth, s as shouldBypassContextMenu, S as SlashMenuPluginKey, E as Editor, i as getStarterExtensions, P as Placeholder, j as getRichTextExtensions, M as Mark, k as Extension, A as Attribute, N as Node } from "./chunks/editor-CTHD3ziL.js";
15
- import { n, C, o, T, l, p, m } from "./chunks/editor-CTHD3ziL.js";
12
+ import { av as getDefaultExportFromCjs, V as v4, T as TextSelection$1, v as getMarkRange, ay as vClickOutside, H as findParentNode, az as getActiveFormatting, ap as isInTable, aA as readFromClipboard, aB as handleClipboardPaste, aC as getFileObject, aD as runPropertyTranslators, aE as translator, aF as translator$1, aG as translator$2, aH as translator$3, aI as translator$4, aJ as translator$5, aK as translator$6, aL as translator$7, aM as translator$8, aN as translator$9, aO as translator$a, aP as translator$b, aQ as translator$c, aR as translator$d, aS as translator$e, aT as translator$f, aU as translator$g, aV as translator$h, aW as translator$i, aX as translator$j, aY as translator$k, aZ as translator$l, a_ as translator$m, a$ as translator$n, b0 as translator$o, b1 as translator$p, b2 as translator$q, b3 as translator$r, b4 as translator$s, b5 as translator$t, b6 as translator$u, b7 as translator$v, b8 as translator$w, b9 as translator$x, ba as translator$y, bb as translator$z, bc as translator$A, bd as translator$B, be as translator$C, bf as translator$D, bg as translator$E, bh as translator$F, bi as translator$G, bj as translator$H, bk as translator$I, bl as translator$J, bm as translator$K, bn as translator$L, bo as translator$M, bp as translator$N, bq as translator$O, br as translator$P, bs as translator$Q, bt as translator$R, bu as translator$S, bv as translator$T, bw as translator$U, bx as translator$V, by as translator$W, bz as translator$X, bA as translator$Y, bB as translator$Z, bC as translator$_, bD as translator$$, bE as translator$10, a as Plugin } from "./chunks/converter-DBwwYo1I.js";
13
+ import { bF, a5, i, a2 } from "./chunks/converter-DBwwYo1I.js";
14
+ import { _ as _export_sfc, u as useHighContrastMode, a as getQuickFormatList, b as generateLinkedStyleString, c as getFileOpener, d as checkAndProcessImage, r as replaceSelectionWithImagePlaceholder, e as uploadAndInsertImage, y as yUndoPluginKey, f as undoDepth, h as redoDepth, s as shouldBypassContextMenu, S as SlashMenuPluginKey, E as Editor, i as getStarterExtensions, P as Placeholder, j as getRichTextExtensions, M as Mark, k as Extension, A as Attribute, N as Node } from "./chunks/editor-B2S-zXBF.js";
15
+ import { n, C, o, T, l, p, m } from "./chunks/editor-B2S-zXBF.js";
16
16
  import { ref, onMounted, createElementBlock, openBlock, normalizeClass, unref, Fragment, renderList, createElementVNode, withModifiers, toDisplayString, createCommentVNode, normalizeStyle, computed, watch, withDirectives, withKeys, vModelText, createTextVNode, createVNode, h, createApp, markRaw, nextTick, onBeforeUnmount, reactive, onUnmounted, renderSlot, shallowRef, createBlock, withCtx, resolveDynamicComponent, normalizeProps, guardReactiveProps } from "vue";
17
- import { t as toolbarIcons, s as sanitizeNumber, T as Toolbar, m as magicWandIcon, p as plusIconSvg, a as trashIconSvg, l as linkIconSvg, b as tableIconSvg, c as scissorsIconSvg, d as copyIconSvg, e as pasteIconSvg, f as borderNoneIconSvg, g as arrowsToDotIconSvg, h as arrowsLeftRightIconSvg, w as wrenchIconSvg, u as useMessage, N as NSkeleton } from "./chunks/toolbar-DLQeMuoQ.js";
17
+ import { t as toolbarIcons, s as sanitizeNumber, T as Toolbar, m as magicWandIcon, p as plusIconSvg, a as trashIconSvg, l as linkIconSvg, b as tableIconSvg, c as scissorsIconSvg, d as copyIconSvg, e as pasteIconSvg, f as borderNoneIconSvg, g as arrowsToDotIconSvg, h as arrowsLeftRightIconSvg, w as wrenchIconSvg, u as useMessage, N as NSkeleton } from "./chunks/toolbar-BX9nPPG0.js";
18
18
  import AIWriter from "./ai-writer.es.js";
19
- import { D } from "./chunks/docx-zipper-DZ9ph0iQ.js";
19
+ import { D } from "./chunks/docx-zipper-BCI-3XE9.js";
20
20
  import { createZip } from "./file-zipper.es.js";
21
21
  var eventemitter3 = { exports: {} };
22
22
  var hasRequiredEventemitter3;
@@ -2584,7 +2584,7 @@ class SuperToolbar extends EventEmitter {
2584
2584
  if (!argument) return;
2585
2585
  item.onActivate({ zoom: argument });
2586
2586
  this.emit("superdoc-command", { item, argument });
2587
- const layers = document.querySelector(this.superdoc.config.selector)?.querySelector(".layers");
2587
+ const layers = this.superdoc.element?.querySelector(".layers");
2588
2588
  if (!layers) return;
2589
2589
  const isMobileDevice = typeof screen.orientation !== "undefined";
2590
2590
  const isSmallScreen = window.matchMedia("(max-width: 834px)").matches;
@@ -1,6 +1,6 @@
1
1
  import "vue";
2
- import { T } from "./chunks/toolbar-DLQeMuoQ.js";
3
- import "./chunks/editor-CTHD3ziL.js";
2
+ import { T } from "./chunks/toolbar-BX9nPPG0.js";
3
+ import "./chunks/editor-B2S-zXBF.js";
4
4
  export {
5
5
  T as default
6
6
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const superEditor_es = require("./chunks/super-editor.es-DwGNbrZq.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-cZsHkhM6.cjs");
4
4
  require("./chunks/vue-DWle4Cai.cjs");
5
5
  exports.AIWriter = superEditor_es.AIWriter;
6
6
  exports.AnnotatorHelpers = superEditor_es.AnnotatorHelpers;
@@ -1,4 +1,4 @@
1
- import { A, a, _, C, D, E, b, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-Bokezk1E.es.js";
1
+ import { A, a, _, C, D, E, b, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-Ccu1wOj1.es.js";
2
2
  import "./chunks/vue-CXxsqYcP.es.js";
3
3
  export {
4
4
  A as AIWriter,
package/dist/superdoc.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const superEditor_es = require("./chunks/super-editor.es-DwGNbrZq.cjs");
4
- const superdoc = require("./chunks/index-BM732Zfw.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-cZsHkhM6.cjs");
4
+ const superdoc = require("./chunks/index-BE07bQaY.cjs");
5
5
  require("./chunks/vue-DWle4Cai.cjs");
6
6
  require("./chunks/jszip-b7l8QkfH.cjs");
7
7
  const blankDocx = require("./chunks/blank-docx-CPqX9RF5.cjs");
@@ -1,5 +1,5 @@
1
- import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-Bokezk1E.es.js";
2
- import { D, H, P, S as S2, m, l } from "./chunks/index-B4aklZ4_.es.js";
1
+ import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-Ccu1wOj1.es.js";
2
+ import { D, H, P, S as S2, m, l } from "./chunks/index-CYCctXm3.es.js";
3
3
  import "./chunks/vue-CXxsqYcP.es.js";
4
4
  import "./chunks/jszip-B8KIZSNe.es.js";
5
5
  import { B } from "./chunks/blank-docx-iwdyG9RH.es.js";