@harbour-enterprises/superdoc 0.25.0-next.3 → 0.25.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.
Files changed (28) hide show
  1. package/dist/chunks/{PdfViewer-DDL0V0l5.cjs → PdfViewer-8kRpbCwn.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-Y13XRanw.es.js → PdfViewer-DVToyLl3.es.js} +1 -1
  3. package/dist/chunks/{index-Bo5YCvD5.cjs → index-DisCF1vr.cjs} +2 -2
  4. package/dist/chunks/{index-DKNVSdr6.es.js → index-STsumey2.es.js} +2 -2
  5. package/dist/chunks/{super-editor.es-Ct2sXbNV.cjs → super-editor.es-QqtfiJGc.cjs} +255 -245
  6. package/dist/chunks/{super-editor.es-CYtLh0Ob.es.js → super-editor.es-rBPknGqQ.es.js} +255 -245
  7. package/dist/core/types/index.d.ts.map +1 -1
  8. package/dist/super-editor/ai-writer.es.js +2 -2
  9. package/dist/super-editor/chunks/{converter-gSy6s2VK.js → converter-DOkexB95.js} +89 -72
  10. package/dist/super-editor/chunks/{docx-zipper-CceGxV02.js → docx-zipper-Ci5JbfjE.js} +1 -1
  11. package/dist/super-editor/chunks/{editor-CoX24lXQ.js → editor-BOoGDORN.js} +171 -187
  12. package/dist/super-editor/chunks/{toolbar-BTw9-jfX.js → toolbar-DPI_cCm_.js} +2 -2
  13. package/dist/super-editor/converter.es.js +1 -1
  14. package/dist/super-editor/docx-zipper.es.js +2 -2
  15. package/dist/super-editor/editor.es.js +3 -3
  16. package/dist/super-editor/file-zipper.es.js +1 -1
  17. package/dist/super-editor/super-editor/src/core/Editor.d.ts +1 -0
  18. package/dist/super-editor/super-editor/src/core/super-converter/v3/handlers/mc/altermateContent/alternate-content-translator.d.ts +11 -0
  19. package/dist/super-editor/super-editor/src/index.d.ts +8 -2
  20. package/dist/super-editor/super-editor.es.js +16 -12
  21. package/dist/super-editor/toolbar.es.js +2 -2
  22. package/dist/super-editor.cjs +1 -1
  23. package/dist/super-editor.es.js +1 -1
  24. package/dist/superdoc.cjs +2 -2
  25. package/dist/superdoc.es.js +2 -2
  26. package/dist/superdoc.umd.js +255 -245
  27. package/dist/superdoc.umd.js.map +1 -1
  28. package/package.json +1 -1
@@ -9,12 +9,12 @@ 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 __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
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, checkFonts_fn, determineUnsupportedFontsWithLocalFonts_fn, determineUnsupportedFontsWithCanvas_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, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
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, checkFonts_fn, determineUnsupportedFonts_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, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ListItemNodeView_instances, init_fn3, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_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 updateDOMAttributes, ah as findChildren$5, ai as htmlHandler, aj as generateRandomSigned32BitIntStrId, ak as InputRule, al as kebabCase, am as findParentNodeClosestToPos, an as getListItemStyleDefinitions, ao as docxNumberigHelpers, ap as parseIndentElement, aq as combineIndents, ar as twipsToPixels, as as PIXELS_PER_INCH, at as SelectionRange, au as Transform, av as isInTable$1, aw as generateDocxRandomId, ax as insertNewRelationship, ay as inchesToPixels } from "./converter-gSy6s2VK.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 updateDOMAttributes, ah as findChildren$5, ai as htmlHandler, aj as generateRandomSigned32BitIntStrId, ak as InputRule, al as kebabCase, am as findParentNodeClosestToPos, an as getListItemStyleDefinitions, ao as docxNumberigHelpers, ap as parseIndentElement, aq as combineIndents, ar as twipsToPixels, as as PIXELS_PER_INCH, at as SelectionRange, au as Transform, av as isInTable$1, aw as generateDocxRandomId, ax as insertNewRelationship, ay as inchesToPixels } from "./converter-DOkexB95.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-CceGxV02.js";
17
+ import { D as DocxZipper } from "./docx-zipper-Ci5JbfjE.js";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
20
20
  };
@@ -14294,7 +14294,9 @@ const _Editor = class _Editor extends EventEmitter {
14294
14294
  isHeaderFooterChanged: false,
14295
14295
  isCustomXmlChanged: false,
14296
14296
  focusTarget: null,
14297
- permissionResolver: null
14297
+ permissionResolver: null,
14298
+ // header/footer editors may have parent(main) editor set
14299
+ parentEditor: null
14298
14300
  });
14299
14301
  __privateMethod(this, _Editor_instances, initContainerElement_fn).call(this, options);
14300
14302
  __privateMethod(this, _Editor_instances, checkHeadless_fn).call(this, options);
@@ -15271,9 +15273,6 @@ init_fn = function() {
15271
15273
  this.emit("beforeCreate", { editor: this });
15272
15274
  this.on("contentError", this.options.onContentError);
15273
15275
  this.mount(this.options.element);
15274
- if (!this.options.isHeadless) {
15275
- __privateMethod(this, _Editor_instances, checkFonts_fn).call(this);
15276
- }
15277
15276
  this.on("create", this.options.onCreate);
15278
15277
  this.on("update", this.options.onUpdate);
15279
15278
  this.on("selectionUpdate", this.options.onSelectionUpdate);
@@ -15295,8 +15294,12 @@ init_fn = function() {
15295
15294
  if (!this.options.isHeadless) {
15296
15295
  this.initializeCollaborationData();
15297
15296
  this.initDefaultStyles();
15297
+ __privateMethod(this, _Editor_instances, checkFonts_fn).call(this);
15298
15298
  }
15299
- if (!this.options.ydoc || this.options.markdown || this.options.html) {
15299
+ const shouldMigrateListsOnInit = Boolean(
15300
+ this.options.markdown || this.options.html || this.options.loadFromSchema || this.options.jsonOverride || this.options.mode === "html" || this.options.mode === "text"
15301
+ );
15302
+ if (shouldMigrateListsOnInit) {
15300
15303
  this.migrateListsToV2();
15301
15304
  }
15302
15305
  this.setDocumentMode(this.options.documentMode);
@@ -15490,58 +15493,17 @@ checkFonts_fn = async function() {
15490
15493
  if (this.options.isHeadless) {
15491
15494
  return;
15492
15495
  }
15493
- const fontsUsedInDocument = this.converter.getDocumentFonts();
15494
- if (!("queryLocalFonts" in window)) {
15495
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
15496
- const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
15497
- this.emit("fonts-resolved", {
15498
- documentFonts: fontsUsedInDocument,
15499
- unsupportedFonts
15500
- });
15501
- return;
15502
- }
15503
- const localFontAccess = await navigator.permissions.query({ name: "local-fonts" });
15504
- if (localFontAccess.state === "denied") {
15505
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
15506
- const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
15507
- this.emit("fonts-resolved", {
15508
- documentFonts: fontsUsedInDocument,
15509
- unsupportedFonts
15510
- });
15511
- return;
15512
- }
15513
15496
  try {
15514
- const localFonts = await window.queryLocalFonts();
15515
- const uniqueLocalFonts = [...new Set(localFonts.map((font) => font.family))];
15516
- const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithLocalFonts_fn).call(this, fontsUsedInDocument, uniqueLocalFonts);
15497
+ const fontsUsedInDocument = this.converter.getDocumentFonts();
15498
+ const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFonts_fn).call(this, fontsUsedInDocument);
15517
15499
  this.emit("fonts-resolved", {
15518
15500
  documentFonts: fontsUsedInDocument,
15519
15501
  unsupportedFonts
15520
15502
  });
15521
15503
  } catch {
15522
- console.warn("[SuperDoc] Could not get access to local fonts. Using fallback solution.");
15523
- const unsupportedFonts = __privateMethod(this, _Editor_instances, determineUnsupportedFontsWithCanvas_fn).call(this, fontsUsedInDocument);
15524
- this.emit("fonts-resolved", {
15525
- documentFonts: fontsUsedInDocument,
15526
- unsupportedFonts
15527
- });
15504
+ console.warn("[SuperDoc] Could not determine document fonts and unsupported fonts");
15528
15505
  }
15529
15506
  };
15530
- /**
15531
- * Determines which fonts used in the document are not available locally nor imported.
15532
- *
15533
- * @param {string[]} fonts - Array of font family names used in the document.
15534
- * @param {string[]} localFonts - Array of local font family names available on the system.
15535
- * @returns {string[]} Array of font names that are unsupported.
15536
- */
15537
- determineUnsupportedFontsWithLocalFonts_fn = function(fonts, localFonts) {
15538
- const unsupportedFonts = fonts.filter((font) => {
15539
- const isLocalFont = localFonts.includes(font);
15540
- const isFontImported = this.fontsImported.includes(font);
15541
- return !isLocalFont && !isFontImported;
15542
- });
15543
- return unsupportedFonts;
15544
- };
15545
15507
  /**
15546
15508
  * Determines which fonts used in the document are not supported
15547
15509
  * by attempting to render them on a canvas.
@@ -15551,7 +15513,7 @@ determineUnsupportedFontsWithLocalFonts_fn = function(fonts, localFonts) {
15551
15513
  * @param {string[]} fonts - Array of font family names used in the document.
15552
15514
  * @returns {string[]} Array of unsupported font family names.
15553
15515
  */
15554
- determineUnsupportedFontsWithCanvas_fn = function(fonts) {
15516
+ determineUnsupportedFonts_fn = function(fonts) {
15555
15517
  const unsupportedFonts = fonts.filter((font) => {
15556
15518
  const canRender = canRenderFont(font);
15557
15519
  const isFontImported = this.fontsImported.includes(font);
@@ -15660,6 +15622,9 @@ onCollaborationReady_fn = function({ editor, ydoc }) {
15660
15622
  if (this.options.collaborationIsReady) return;
15661
15623
  console.debug("🔗 [super-editor] Collaboration ready");
15662
15624
  __privateMethod(this, _Editor_instances, validateDocumentInit_fn).call(this);
15625
+ if (this.options.ydoc) {
15626
+ this.migrateListsToV2();
15627
+ }
15663
15628
  this.options.onCollaborationReady({ editor, ydoc });
15664
15629
  this.options.collaborationIsReady = true;
15665
15630
  this.options.initialState = this.state;
@@ -26665,58 +26630,6 @@ const registerImages = async (foundImages, editor, view) => {
26665
26630
  }
26666
26631
  });
26667
26632
  };
26668
- const normalizeWrap = (attrs = {}) => {
26669
- const wrap = attrs.wrap;
26670
- if (wrap?.type && wrap.type !== "Inline") {
26671
- return {
26672
- type: wrap.type,
26673
- attrs: wrap.attrs ?? {}
26674
- };
26675
- }
26676
- if (wrap?.type === "Inline" && Object.keys(wrap.attrs ?? {}).length) {
26677
- return {
26678
- type: "Inline",
26679
- attrs: wrap.attrs
26680
- };
26681
- }
26682
- if (!wrap && attrs.wrapText) {
26683
- return {
26684
- type: "Square",
26685
- attrs: {
26686
- wrapText: attrs.wrapText
26687
- }
26688
- };
26689
- }
26690
- if (!wrap && attrs.wrapTopAndBottom) {
26691
- return {
26692
- type: "TopAndBottom",
26693
- attrs: {}
26694
- };
26695
- }
26696
- if (wrap?.type === "Inline") {
26697
- return {
26698
- type: "Inline",
26699
- attrs: wrap.attrs ?? {}
26700
- };
26701
- }
26702
- return {
26703
- type: "Inline",
26704
- attrs: {}
26705
- };
26706
- };
26707
- const normalizeMarginOffset = (marginOffset = {}) => {
26708
- const { left: left2, horizontal, ...rest } = marginOffset;
26709
- return {
26710
- ...rest,
26711
- horizontal: horizontal ?? left2
26712
- };
26713
- };
26714
- const getNormalizedImageAttrs = (attrs = {}) => {
26715
- return {
26716
- wrap: normalizeWrap(attrs),
26717
- marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
26718
- };
26719
- };
26720
26633
  const ImagePositionPluginKey = new PluginKey("ImagePosition");
26721
26634
  const ImagePositionPlugin = ({ editor }) => {
26722
26635
  const { view } = editor;
@@ -26729,8 +26642,9 @@ const ImagePositionPlugin = ({ editor }) => {
26729
26642
  return DecorationSet.empty;
26730
26643
  },
26731
26644
  apply(tr, oldDecorationSet, oldState, newState) {
26732
- if (!tr.docChanged) return oldDecorationSet;
26645
+ if (!tr.docChanged && !shouldUpdate) return oldDecorationSet;
26733
26646
  const decorations = getImagePositionDecorations(newState, view);
26647
+ shouldUpdate = false;
26734
26648
  return DecorationSet.create(newState.doc, decorations);
26735
26649
  }
26736
26650
  },
@@ -26739,7 +26653,6 @@ const ImagePositionPlugin = ({ editor }) => {
26739
26653
  update: (view2, lastState) => {
26740
26654
  const pagination = PaginationPluginKey.getState(lastState);
26741
26655
  if (shouldUpdate) {
26742
- shouldUpdate = false;
26743
26656
  const decorations = getImagePositionDecorations(lastState, view2);
26744
26657
  const updateTransaction = view2.state.tr.setMeta(ImagePositionPluginKey, { decorations });
26745
26658
  view2.dispatch(updateTransaction);
@@ -26765,41 +26678,35 @@ const getImagePositionDecorations = (state, view) => {
26765
26678
  let className = "";
26766
26679
  const { vRelativeFrom, alignH } = node.attrs.anchorData;
26767
26680
  const { size, padding } = node.attrs;
26768
- const { marginOffset } = getNormalizedImageAttrs(node.attrs);
26769
26681
  const pageBreak = findPreviousDomNodeWithClass(view, pos, "pagination-break-wrapper");
26770
- if (pageBreak) {
26771
- switch (alignH) {
26772
- case "left":
26773
- style += "float: left; left: 0; margin-left: 0; ";
26774
- break;
26775
- case "right":
26776
- style += "float: right; right: 0; margin-right: 0; ";
26777
- break;
26778
- case "center":
26779
- style += "display: block; margin-left: auto; margin-right: auto; ";
26780
- break;
26682
+ if (pageBreak && vRelativeFrom === "margin" && alignH) {
26683
+ const topPos = pageBreak?.offsetTop + pageBreak?.offsetHeight;
26684
+ let horizontalAlignment = `${alignH}: 0;`;
26685
+ if (alignH === "center") horizontalAlignment = "left: 50%; transform: translateX(-50%);";
26686
+ style += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ${horizontalAlignment}` : "";
26687
+ const nextPos = view.posAtDOM(pageBreak, 1);
26688
+ if (nextPos < 0) {
26689
+ const $pos = view.state.doc.resolve(pos);
26690
+ decorations.push(
26691
+ Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
26692
+ style: `height: ${size.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
26693
+ })
26694
+ );
26781
26695
  }
26782
- const topPos = marginOffset.top !== void 0 ? marginOffset.top : pageBreak?.offsetTop + pageBreak?.offsetHeight;
26783
- style += vRelativeFrom === "margin" ? `position: absolute; top: ${topPos}px; ` : "";
26784
- if (vRelativeFrom === "margin") {
26785
- const nextPos = view.posAtDOM(pageBreak, 1);
26786
- if (nextPos < 0) {
26787
- const $pos = view.state.doc.resolve(pos);
26788
- decorations.push(
26789
- Decoration.node(pos - 1, pos + $pos.parent.nodeSize - 1, {
26790
- style: `height: ${size.height + parseInt(padding.top) + parseInt(padding.bottom)}px`
26791
- })
26792
- );
26793
- }
26794
- const imageBlock = document.createElement("div");
26795
- imageBlock.className = "anchor-image-placeholder";
26796
- imageBlock.style.float = alignH;
26797
- imageBlock.style.width = size.width + parseInt(padding[alignH]) + "px";
26798
- imageBlock.style.height = size.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
26799
- decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
26696
+ const imageBlock = document.createElement("div");
26697
+ imageBlock.className = "anchor-image-placeholder";
26698
+ imageBlock.style.float = alignH === "left" || alignH === "right" ? alignH : "none";
26699
+ let paddingHorizontal;
26700
+ if (alignH === "center") {
26701
+ paddingHorizontal = (parseInt(padding.left) || 0) + (parseInt(padding.right) || 0);
26702
+ } else {
26703
+ paddingHorizontal = parseInt(padding[alignH]) || 0;
26800
26704
  }
26705
+ imageBlock.style.width = size.width + paddingHorizontal + "px";
26706
+ imageBlock.style.height = size.height + parseInt(padding.top) + parseInt(padding.bottom) + "px";
26707
+ decorations.push(Decoration.widget(nextPos, imageBlock, { key: "stable-key" }));
26708
+ decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style, class: className }));
26801
26709
  }
26802
- decorations.push(Decoration.inline(pos, pos + node.nodeSize, { style, class: className }));
26803
26710
  }
26804
26711
  });
26805
26712
  return decorations;
@@ -26824,6 +26731,58 @@ const findPreviousDomNodeWithClass = (view, pos, className) => {
26824
26731
  }
26825
26732
  return null;
26826
26733
  };
26734
+ const normalizeWrap = (attrs = {}) => {
26735
+ const wrap = attrs.wrap;
26736
+ if (wrap?.type && wrap.type !== "Inline") {
26737
+ return {
26738
+ type: wrap.type,
26739
+ attrs: wrap.attrs ?? {}
26740
+ };
26741
+ }
26742
+ if (wrap?.type === "Inline" && Object.keys(wrap.attrs ?? {}).length) {
26743
+ return {
26744
+ type: "Inline",
26745
+ attrs: wrap.attrs
26746
+ };
26747
+ }
26748
+ if (!wrap && attrs.wrapText) {
26749
+ return {
26750
+ type: "Square",
26751
+ attrs: {
26752
+ wrapText: attrs.wrapText
26753
+ }
26754
+ };
26755
+ }
26756
+ if (!wrap && attrs.wrapTopAndBottom) {
26757
+ return {
26758
+ type: "TopAndBottom",
26759
+ attrs: {}
26760
+ };
26761
+ }
26762
+ if (wrap?.type === "Inline") {
26763
+ return {
26764
+ type: "Inline",
26765
+ attrs: wrap.attrs ?? {}
26766
+ };
26767
+ }
26768
+ return {
26769
+ type: "Inline",
26770
+ attrs: {}
26771
+ };
26772
+ };
26773
+ const normalizeMarginOffset = (marginOffset = {}) => {
26774
+ const { left: left2, horizontal, ...rest } = marginOffset;
26775
+ return {
26776
+ ...rest,
26777
+ horizontal: horizontal ?? left2
26778
+ };
26779
+ };
26780
+ const getNormalizedImageAttrs = (attrs = {}) => {
26781
+ return {
26782
+ wrap: normalizeWrap(attrs),
26783
+ marginOffset: normalizeMarginOffset(attrs.marginOffset ?? {})
26784
+ };
26785
+ };
26827
26786
  const getRotationMargins = (w, h, angleDegrees) => {
26828
26787
  const rad = angleDegrees * (Math.PI / 180);
26829
26788
  const cos = Math.abs(Math.cos(rad));
@@ -27032,27 +26991,15 @@ const Image = Node$1.create({
27032
26991
  style += "float: right;";
27033
26992
  floatRight = true;
27034
26993
  } else if (["largest", "bothSides"].includes(attrs.wrapText)) {
27035
- const pageStyles2 = this.editor?.converter?.pageStyles;
27036
- if (pageStyles2?.pageSize && pageStyles2?.pageMargins && size.width) {
27037
- const pageWidth = inchesToPixels(pageStyles2.pageSize.width);
27038
- const leftMargin = inchesToPixels(pageStyles2.pageMargins.left);
27039
- const rightMargin = inchesToPixels(pageStyles2.pageMargins.right);
27040
- const contentWidth = pageWidth - leftMargin - rightMargin;
27041
- const imageWidth = size.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
27042
- const leftSpace = marginOffset.horizontal;
27043
- const rightSpace = contentWidth - leftSpace - imageWidth;
27044
- if (rightSpace < 0) {
27045
- style += "float: left;";
27046
- } else if (rightSpace > leftSpace) {
27047
- style += "float: left;";
27048
- } else {
27049
- style += "float: right;";
27050
- floatRight = true;
27051
- baseHorizontal = rightSpace;
27052
- }
27053
- } else {
27054
- style += "float: left;";
27055
- }
26994
+ const pageStylesData2 = getDataFromPageStyles({
26995
+ editor: this.editor,
26996
+ marginOffset,
26997
+ size,
26998
+ attrs
26999
+ });
27000
+ style += pageStylesData2.style;
27001
+ floatRight = pageStylesData2.floatRight;
27002
+ baseHorizontal = pageStylesData2.baseHorizontal;
27056
27003
  }
27057
27004
  if (attrs.distTop) margin.top += attrs.distTop;
27058
27005
  if (attrs.distBottom) margin.bottom += attrs.distBottom;
@@ -27062,27 +27009,15 @@ const Image = Node$1.create({
27062
27009
  case "Through":
27063
27010
  case "Tight":
27064
27011
  style += "clear: both;";
27065
- const pageStyles = this.editor?.converter?.pageStyles;
27066
- if (pageStyles?.pageSize && pageStyles?.pageMargins && size.width) {
27067
- const pageWidth = inchesToPixels(pageStyles.pageSize.width);
27068
- const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
27069
- const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
27070
- const contentWidth = pageWidth - leftMargin - rightMargin;
27071
- const imageWidth = size.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
27072
- const leftSpace = marginOffset.horizontal;
27073
- const rightSpace = contentWidth - leftSpace - imageWidth;
27074
- if (rightSpace < 0) {
27075
- style += "float: left;";
27076
- } else if (rightSpace > leftSpace) {
27077
- style += "float: left;";
27078
- } else {
27079
- style += "float: right;";
27080
- floatRight = true;
27081
- baseHorizontal = rightSpace;
27082
- }
27083
- } else {
27084
- style += "float: left;";
27085
- }
27012
+ const pageStylesData = getDataFromPageStyles({
27013
+ editor: this.editor,
27014
+ marginOffset,
27015
+ size,
27016
+ attrs
27017
+ });
27018
+ style += pageStylesData.style;
27019
+ floatRight = pageStylesData.floatRight;
27020
+ baseHorizontal = pageStylesData.baseHorizontal;
27086
27021
  if (attrs.distTop) margin.top += attrs.distTop;
27087
27022
  if (attrs.distBottom) margin.bottom += attrs.distBottom;
27088
27023
  if (attrs.distLeft) margin.left += attrs.distLeft;
@@ -27119,6 +27054,22 @@ const Image = Node$1.create({
27119
27054
  }
27120
27055
  const hasAnchorData = Boolean(anchorData);
27121
27056
  const hasMarginOffsets = marginOffset?.horizontal != null || marginOffset?.top != null;
27057
+ if (hasAnchorData) {
27058
+ switch (anchorData.hRelativeFrom) {
27059
+ case "page":
27060
+ const pageStyles = this.editor?.converter?.pageStyles || this.editor?.options.parentEditor?.converter?.pageStyles;
27061
+ margin.left -= inchesToPixels(pageStyles?.pageMargins?.left) || 0;
27062
+ break;
27063
+ case "margin":
27064
+ if (anchorData.alignH === "center") {
27065
+ style += "position: absolute; left: 50%; transform: translateX(-50%);";
27066
+ }
27067
+ if (anchorData.alignH === "left" || anchorData.alignH === "right") {
27068
+ style += `position: absolute; ${anchorData.alignH}: 0;`;
27069
+ }
27070
+ break;
27071
+ }
27072
+ }
27122
27073
  if (hasAnchorData || hasMarginOffsets) {
27123
27074
  const relativeFromPageV = anchorData?.vRelativeFrom === "page";
27124
27075
  const maxMarginV = 500;
@@ -27267,6 +27218,37 @@ const Image = Node$1.create({
27267
27218
  return [ImageRegistrationPlugin({ editor: this.editor }), ImagePositionPlugin({ editor: this.editor })];
27268
27219
  }
27269
27220
  });
27221
+ const getDataFromPageStyles = ({ editor, marginOffset, size, attrs }) => {
27222
+ let style = "";
27223
+ let floatRight = false;
27224
+ let baseHorizontal = marginOffset?.horizontal || 0;
27225
+ const pageStyles = editor?.converter?.pageStyles || editor?.options.parentEditor?.converter?.pageStyles;
27226
+ if (pageStyles?.pageSize && pageStyles?.pageMargins && size.width) {
27227
+ const pageWidth = inchesToPixels(pageStyles.pageSize.width);
27228
+ const leftMargin = inchesToPixels(pageStyles.pageMargins.left);
27229
+ const rightMargin = inchesToPixels(pageStyles.pageMargins.right);
27230
+ const contentWidth = pageWidth - leftMargin - rightMargin;
27231
+ const imageWidth = size.width + (attrs.distLeft || 0) + (attrs.distRight || 0);
27232
+ const leftSpace = marginOffset.horizontal;
27233
+ const rightSpace = contentWidth - leftSpace - imageWidth;
27234
+ if (rightSpace < 0) {
27235
+ style += "float: left;";
27236
+ } else if (rightSpace > leftSpace) {
27237
+ style += "float: left;";
27238
+ } else {
27239
+ style += "float: right;";
27240
+ floatRight = true;
27241
+ baseHorizontal = rightSpace;
27242
+ }
27243
+ } else {
27244
+ style += "float: left;";
27245
+ }
27246
+ return {
27247
+ style,
27248
+ floatRight,
27249
+ baseHorizontal
27250
+ };
27251
+ };
27270
27252
  const ACCEPT_IMAGE_TYPES = [".jpg", ".jpeg", ".png", "image/jpeg", "image/png"];
27271
27253
  const getFileOpener = () => {
27272
27254
  let fileInput = document.createElement("input");
@@ -34709,7 +34691,7 @@ const nodeResizer = (nodeNames = ["image"], editor) => {
34709
34691
  return oldState;
34710
34692
  }
34711
34693
  if (typeof document === "undefined" || editor.options.isHeadless) return oldState;
34712
- if (editor.options.documentMode === "viewing" || !editor.isEditable) {
34694
+ if (!editor.options.isHeaderOrFooter && (editor.options.documentMode === "viewing" || !editor.isEditable)) {
34713
34695
  return DecorationSet.empty;
34714
34696
  }
34715
34697
  const { selection } = newState;
@@ -35059,6 +35041,7 @@ const getStarterExtensions = () => {
35059
35041
  export {
35060
35042
  Attribute as A,
35061
35043
  CommentsPluginKey as C,
35044
+ DecorationSet as D,
35062
35045
  Editor as E,
35063
35046
  Mark as M,
35064
35047
  Node$1 as N,
@@ -35079,14 +35062,15 @@ export {
35079
35062
  collectTrackedChangesForContext as k,
35080
35063
  getStarterExtensions as l,
35081
35064
  getRichTextExtensions as m,
35082
- Extension as n,
35083
- index$1 as o,
35084
- index as p,
35085
- AnnotatorHelpers as q,
35065
+ Decoration as n,
35066
+ Extension as o,
35067
+ index$1 as p,
35068
+ index as q,
35086
35069
  replaceSelectionWithImagePlaceholder as r,
35087
35070
  shouldBypassContextMenu as s,
35088
- SectionHelpers as t,
35071
+ AnnotatorHelpers as t,
35089
35072
  useHighContrastMode as u,
35090
- getAllowedImageDimensions as v,
35073
+ SectionHelpers as v,
35074
+ getAllowedImageDimensions as w,
35091
35075
  yUndoPluginKey as y
35092
35076
  };
@@ -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-gSy6s2VK.js";
3
- import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-CoX24lXQ.js";
2
+ import { p as process$1 } from "./converter-DOkexB95.js";
3
+ import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-BOoGDORN.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-gSy6s2VK.js";
1
+ import { a5 } from "./chunks/converter-DOkexB95.js";
2
2
  import "vue";
3
3
  export {
4
4
  a5 as SuperConverter
@@ -1,5 +1,5 @@
1
- import "./chunks/converter-gSy6s2VK.js";
2
- import { D } from "./chunks/docx-zipper-CceGxV02.js";
1
+ import "./chunks/converter-DOkexB95.js";
2
+ import { D } from "./chunks/docx-zipper-Ci5JbfjE.js";
3
3
  export {
4
4
  D as default
5
5
  };
@@ -1,6 +1,6 @@
1
- import { E } from "./chunks/editor-CoX24lXQ.js";
2
- import "./chunks/converter-gSy6s2VK.js";
3
- import "./chunks/docx-zipper-CceGxV02.js";
1
+ import { E } from "./chunks/editor-BOoGDORN.js";
2
+ import "./chunks/converter-DOkexB95.js";
3
+ import "./chunks/docx-zipper-Ci5JbfjE.js";
4
4
  export {
5
5
  E as Editor
6
6
  };
@@ -1,4 +1,4 @@
1
- import { J as JSZip } from "./chunks/docx-zipper-CceGxV02.js";
1
+ import { J as JSZip } from "./chunks/docx-zipper-Ci5JbfjE.js";
2
2
  async function createZip(blobs, fileNames) {
3
3
  const zip = new JSZip();
4
4
  blobs.forEach((blob, index) => {
@@ -253,6 +253,7 @@ export class Editor extends EventEmitter {
253
253
  isCustomXmlChanged: boolean;
254
254
  focusTarget: any;
255
255
  permissionResolver: any;
256
+ parentEditor: any;
256
257
  };
257
258
  setHighContrastMode: (value: any) => void;
258
259
  /**
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Selects the best-fit mc:AlternateContent branch, mirroring the legacy importer logic.
3
+ * @param {import('@translator').SCExtraParams['node']} node
4
+ * @returns {{ branch: import('@translator').XmlNode|null, elements: import('@translator').XmlNode[]|null }}
5
+ */
6
+ export function selectAlternateContentElements(node: import("@translator").SCExtraParams["node"]): {
7
+ branch: import("@translator").XmlNode | null;
8
+ elements: import("@translator").XmlNode[] | null;
9
+ };
10
+ /** @type {Set<string>} */
11
+ export const SUPPORTED_ALTERNATE_CONTENT_REQUIRES: Set<string>;
1
12
  /** @type {import('@translator').NodeTranslatorConfig} */
2
13
  export const config: import("@translator").NodeTranslatorConfig;
3
14
  /**
@@ -19,14 +19,20 @@ export namespace Extensions {
19
19
  export { Node };
20
20
  export { Attribute };
21
21
  export { Extension };
22
- export { Plugin };
23
22
  export { Mark };
23
+ export { Plugin };
24
+ export { PluginKey };
25
+ export { Decoration };
26
+ export { DecorationSet };
24
27
  }
25
28
  import { TrackChangesBasePluginKey } from './extensions/track-changes/plugins/index.js';
26
29
  import { CommentsPluginKey } from './extensions/comment/comments-plugin.js';
27
30
  import { Node } from '@core/index.js';
28
31
  import { Attribute } from '@core/index.js';
29
32
  import { Extension } from '@core/Extension.js';
30
- import { Plugin } from 'prosemirror-state';
31
33
  import { Mark } from '@core/Mark.js';
34
+ import { Plugin } from 'prosemirror-state';
35
+ import { PluginKey } from 'prosemirror-state';
36
+ import { Decoration } from 'prosemirror-view';
37
+ import { DecorationSet } from 'prosemirror-view';
32
38
  export { SuperConverter, DocxZipper, SuperToolbar, Editor, SuperEditor, SuperInput, BasicUpload, Toolbar, AIWriter, SlashMenu, helpers, fieldAnnotationHelpers, trackChangesHelpers, AnnotatorHelpers, SectionHelpers, getMarksFromSelection, getActiveFormatting, getStarterExtensions, getRichTextExtensions, createZip, getAllowedImageDimensions, registeredHandlers, TrackChangesBasePluginKey, CommentsPluginKey };