@harbour-enterprises/superdoc 1.3.0-next.11 → 1.3.0-next.13

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.
@@ -1,6 +1,6 @@
1
1
  import { d as defineComponent, h, T as Transition, p as process$1, w as watchEffect, c as computed, r as ref, f as onMounted, X as onUnmounted, E as createElementBlock, G as openBlock, K as createBaseVNode, M as createCommentVNode, I as createVNode, v as unref } from "./vue-BnBKJwCW.es.js";
2
- import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-D2CRfjhH.es.js";
3
- import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-CE0fU2k7.es.js";
2
+ import { N as NBaseLoading, u as useSuperdocStore, s as storeToRefs, a as useSelection } from "./index-DOsTLvRQ.es.js";
3
+ import { C as derived, r as c, q as cB, aF as fadeInTransition, y as cM, I as warnOnce, J as useConfig, N as useTheme, aG as pxfy, P as createKey, Q as useThemeClass, aH as useCompitable, ai as _export_sfc } from "./index-OlLDoLS-.es.js";
4
4
  function self(vars) {
5
5
  const {
6
6
  opacityDisabled,
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-De9wkgLl.cjs");
4
- const superdoc = require("./index-CTQjsYpZ.cjs");
5
- const index = require("./index-BClM7AjD.cjs");
4
+ const superdoc = require("./index-C7p34V06.cjs");
5
+ const index = require("./index-DNdp0AxW.cjs");
6
6
  function self(vars) {
7
7
  const {
8
8
  opacityDisabled,
@@ -31007,7 +31007,7 @@ class SuperConverter {
31007
31007
  static getStoredSuperdocVersion(docx) {
31008
31008
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
31009
31009
  }
31010
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.11") {
31010
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.13") {
31011
31011
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
31012
31012
  }
31013
31013
  /**
@@ -31685,17 +31685,18 @@ export {
31685
31685
  translator$14 as a0,
31686
31686
  translator$1O as a1,
31687
31687
  resolveDocxFontFamily as a2,
31688
- _getReferencedTableStyles as a3,
31689
- decodeRPrFromMarks as a4,
31690
- calculateResolvedParagraphProperties as a5,
31691
- encodeCSSFromPPr as a6,
31692
- encodeCSSFromRPr as a7,
31693
- generateOrderedListIndex as a8,
31694
- docxNumberingHelpers as a9,
31695
- InputRule as aa,
31696
- insertNewRelationship as ab,
31697
- kebabCase as ac,
31698
- getUnderlineCssString as ad,
31688
+ combineIndentProperties as a3,
31689
+ _getReferencedTableStyles as a4,
31690
+ decodeRPrFromMarks as a5,
31691
+ calculateResolvedParagraphProperties as a6,
31692
+ encodeCSSFromPPr as a7,
31693
+ encodeCSSFromRPr as a8,
31694
+ generateOrderedListIndex as a9,
31695
+ docxNumberingHelpers as aa,
31696
+ InputRule as ab,
31697
+ insertNewRelationship as ac,
31698
+ kebabCase as ad,
31699
+ getUnderlineCssString as ae,
31699
31700
  chainableEditorState as b,
31700
31701
  createDocFromMarkdown as c,
31701
31702
  convertMarkdownToHTML as d,
@@ -31008,7 +31008,7 @@ class SuperConverter {
31008
31008
  static getStoredSuperdocVersion(docx) {
31009
31009
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
31010
31010
  }
31011
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.11") {
31011
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.3.0-next.13") {
31012
31012
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
31013
31013
  }
31014
31014
  /**
@@ -31686,6 +31686,7 @@ exports.canJoin = canJoin;
31686
31686
  exports.canSplit = canSplit;
31687
31687
  exports.chainableEditorState = chainableEditorState;
31688
31688
  exports.changeListLevel = changeListLevel;
31689
+ exports.combineIndentProperties = combineIndentProperties;
31689
31690
  exports.convertMarkdownToHTML = convertMarkdownToHTML;
31690
31691
  exports.createDocFromHTML = createDocFromHTML;
31691
31692
  exports.createDocFromMarkdown = createDocFromMarkdown;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const index = require("./index-BClM7AjD.cjs");
3
- require("./SuperConverter-DgyRPhnD.cjs");
2
+ const index = require("./index-DNdp0AxW.cjs");
3
+ require("./SuperConverter-Dxl1uYvz.cjs");
4
4
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
5
5
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
6
6
  const provider = require("@hocuspocus/provider");
@@ -7465,7 +7465,7 @@ const _sfc_main = {
7465
7465
  __name: "SuperDoc",
7466
7466
  emits: ["selection-update"],
7467
7467
  setup(__props, { emit: __emit }) {
7468
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DxthqP0q.cjs")));
7468
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-z2obaZHa.cjs")));
7469
7469
  const superdocStore = useSuperdocStore();
7470
7470
  const commentsStore = useCommentsStore();
7471
7471
  const {
@@ -7506,6 +7506,7 @@ const _sfc_main = {
7506
7506
  commentsStore.proxy = proxy;
7507
7507
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
7508
7508
  const { uiFontFamily } = useUiFontFamily();
7509
+ const isViewingMode = () => proxy?.$superdoc?.config?.documentMode === "viewing";
7509
7510
  const commentsModuleConfig = vue.computed(() => {
7510
7511
  const config = modules.comments;
7511
7512
  if (config === false || config == null) return null;
@@ -7600,6 +7601,10 @@ const _sfc_main = {
7600
7601
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7601
7602
  if (!commentsConfig || commentsConfig === false) return;
7602
7603
  if (!positions || Object.keys(positions).length === 0) return;
7604
+ if (isViewingMode()) {
7605
+ commentsStore.clearEditorCommentPositions?.();
7606
+ return;
7607
+ }
7603
7608
  const mappedPositions = presentationEditor.getCommentBounds(positions, layers.value);
7604
7609
  handleEditorLocationsUpdate(mappedPositions);
7605
7610
  });
@@ -7619,6 +7624,13 @@ const _sfc_main = {
7619
7624
  const onEditorSelectionChange = ({ editor, transaction }) => {
7620
7625
  if (skipSelectionUpdate.value) {
7621
7626
  skipSelectionUpdate.value = false;
7627
+ if (isViewingMode()) {
7628
+ resetSelection();
7629
+ }
7630
+ return;
7631
+ }
7632
+ if (isViewingMode()) {
7633
+ resetSelection();
7622
7634
  return;
7623
7635
  }
7624
7636
  const { documentId } = editor.options;
@@ -7797,6 +7809,10 @@ const _sfc_main = {
7797
7809
  const onEditorCommentLocationsUpdate = (doc, { allCommentIds: activeThreadId, allCommentPositions } = {}) => {
7798
7810
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7799
7811
  if (!commentsConfig || commentsConfig === false) return;
7812
+ if (isViewingMode()) {
7813
+ commentsStore.clearEditorCommentPositions?.();
7814
+ return;
7815
+ }
7800
7816
  const presentation = index.PresentationEditor.getInstance(doc.id);
7801
7817
  if (!presentation) {
7802
7818
  handleEditorLocationsUpdate(allCommentPositions, activeThreadId);
@@ -7852,11 +7868,12 @@ const _sfc_main = {
7852
7868
  };
7853
7869
  const isCommentsEnabled = vue.computed(() => Boolean(commentsModuleConfig.value));
7854
7870
  const showCommentsSidebar = vue.computed(() => {
7871
+ if (isViewingMode()) return false;
7855
7872
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
7856
7873
  });
7857
7874
  const showToolsFloatingMenu = vue.computed(() => {
7858
7875
  if (!isCommentsEnabled.value) return false;
7859
- return toolsMenuPosition.top && !getConfig.value?.readOnly;
7876
+ return selectionPosition.value && toolsMenuPosition.top && !getConfig.value?.readOnly;
7860
7877
  });
7861
7878
  vue.computed(() => {
7862
7879
  if (!isCommentsEnabled.value) return false;
@@ -7904,6 +7921,10 @@ const _sfc_main = {
7904
7921
  return style2;
7905
7922
  });
7906
7923
  const handleSelectionChange = (selection) => {
7924
+ if (isViewingMode()) {
7925
+ resetSelection();
7926
+ return;
7927
+ }
7907
7928
  if (!selection.selectionBounds || !isCommentsEnabled.value) return;
7908
7929
  resetSelection();
7909
7930
  const isMobileView = window.matchMedia("(max-width: 768px)").matches;
@@ -7929,12 +7950,14 @@ const _sfc_main = {
7929
7950
  };
7930
7951
  const resetSelection = () => {
7931
7952
  selectionPosition.value = null;
7953
+ toolsMenuPosition.top = null;
7932
7954
  };
7933
7955
  const updateSelection = ({ startX, startY, x, y, source }) => {
7934
7956
  const hasStartCoords = typeof startX === "number" || typeof startY === "number";
7935
7957
  const hasEndCoords = typeof x === "number" || typeof y === "number";
7936
7958
  if (!hasStartCoords && !hasEndCoords) {
7937
- return selectionPosition.value = null;
7959
+ resetSelection();
7960
+ return;
7938
7961
  }
7939
7962
  if (!selectionPosition.value) {
7940
7963
  if (startY == null || startX == null) return;
@@ -8187,7 +8210,7 @@ const _sfc_main = {
8187
8210
  };
8188
8211
  }
8189
8212
  };
8190
- const App = /* @__PURE__ */ index._export_sfc(_sfc_main, [["__scopeId", "data-v-1e96f708"]]);
8213
+ const App = /* @__PURE__ */ index._export_sfc(_sfc_main, [["__scopeId", "data-v-5196811d"]]);
8191
8214
  const createSuperdocVueApp = () => {
8192
8215
  const app = vue.createApp(App);
8193
8216
  const pinia = createPinia();
@@ -8371,7 +8394,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
8371
8394
  this.config.colors = shuffleArray(this.config.colors);
8372
8395
  this.userColorMap = /* @__PURE__ */ new Map();
8373
8396
  this.colorIndex = 0;
8374
- this.version = "1.3.0-next.11";
8397
+ this.version = "1.3.0-next.13";
8375
8398
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8376
8399
  this.superdocId = config.superdocId || uuid.v4();
8377
8400
  this.colors = this.config.colors;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  const jszip = require("./jszip-C8_CqJxM.cjs");
3
3
  const helpers$1 = require("./helpers-nOdwpmwb.cjs");
4
- const superEditor_converter = require("./SuperConverter-DgyRPhnD.cjs");
4
+ const superEditor_converter = require("./SuperConverter-Dxl1uYvz.cjs");
5
5
  const vue = require("./vue-De9wkgLl.cjs");
6
6
  require("./jszip.min-BPh2MMAa.cjs");
7
7
  const eventemitter3 = require("./eventemitter3-BQuRcMPI.cjs");
@@ -10953,6 +10953,105 @@ const setSectionHeaderFooterAtSelection = ({ headerInches, footerInches } = {})
10953
10953
  tr.setNodeMarkup(pos, void 0, nextAttrs, node.marks);
10954
10954
  return true;
10955
10955
  };
10956
+ function findGoverningSectPrParagraph(doc2, selectionPos) {
10957
+ const candidates = [];
10958
+ doc2.descendants((node, nodePos) => {
10959
+ if (node.type?.name === "paragraph" && node.attrs?.paragraphProperties?.sectPr) {
10960
+ candidates.push({ node, pos: nodePos });
10961
+ }
10962
+ });
10963
+ if (!candidates.length) return null;
10964
+ const inside = candidates.find((c2) => selectionPos >= c2.pos && selectionPos < c2.pos + c2.node.nodeSize);
10965
+ if (inside) return inside;
10966
+ const atOrAfter = candidates.find((c2) => c2.pos >= selectionPos);
10967
+ return atOrAfter ?? candidates[candidates.length - 1];
10968
+ }
10969
+ const setSectionPageMarginsAtSelection = ({ topInches, rightInches, bottomInches, leftInches } = {}) => ({ tr, state, editor }) => {
10970
+ if (!state || !editor) {
10971
+ console.warn("[setSectionPageMarginsAtSelection] Missing state or editor");
10972
+ return false;
10973
+ }
10974
+ const hasTop = typeof topInches === "number";
10975
+ const hasRight = typeof rightInches === "number";
10976
+ const hasBottom = typeof bottomInches === "number";
10977
+ const hasLeft = typeof leftInches === "number";
10978
+ if (!hasTop && !hasRight && !hasBottom && !hasLeft) {
10979
+ console.warn("[setSectionPageMarginsAtSelection] No margin values provided");
10980
+ return false;
10981
+ }
10982
+ if (hasTop && topInches < 0 || hasRight && rightInches < 0 || hasBottom && bottomInches < 0 || hasLeft && leftInches < 0) {
10983
+ console.warn("[setSectionPageMarginsAtSelection] Margin values must be >= 0");
10984
+ return false;
10985
+ }
10986
+ const updates = {};
10987
+ if (hasTop) updates.topInches = topInches;
10988
+ if (hasRight) updates.rightInches = rightInches;
10989
+ if (hasBottom) updates.bottomInches = bottomInches;
10990
+ if (hasLeft) updates.leftInches = leftInches;
10991
+ const { from: from3 } = state.selection;
10992
+ const governing = findGoverningSectPrParagraph(state.doc, from3);
10993
+ if (governing) {
10994
+ const { node, pos } = governing;
10995
+ const paraProps = node.attrs?.paragraphProperties || null;
10996
+ const existingSectPr = paraProps?.sectPr || null;
10997
+ if (!existingSectPr) {
10998
+ console.warn("[setSectionPageMarginsAtSelection] Paragraph found but has no sectPr");
10999
+ return false;
11000
+ }
11001
+ const sectPr2 = JSON.parse(JSON.stringify(existingSectPr));
11002
+ try {
11003
+ updateSectionMargins({ type: "sectPr", sectPr: sectPr2 }, updates);
11004
+ } catch (err) {
11005
+ console.error("[setSectionPageMarginsAtSelection] Failed to update sectPr:", err);
11006
+ return false;
11007
+ }
11008
+ const resolved = getSectPrMargins(sectPr2);
11009
+ const normalizedSectionMargins = {
11010
+ top: resolved.top ?? null,
11011
+ right: resolved.right ?? null,
11012
+ bottom: resolved.bottom ?? null,
11013
+ left: resolved.left ?? null,
11014
+ header: resolved.header ?? null,
11015
+ footer: resolved.footer ?? null
11016
+ };
11017
+ const newParagraphProperties = { ...paraProps || {}, sectPr: sectPr2 };
11018
+ const nextAttrs = {
11019
+ ...node.attrs,
11020
+ paragraphProperties: newParagraphProperties,
11021
+ sectionMargins: normalizedSectionMargins
11022
+ };
11023
+ tr.setNodeMarkup(pos, void 0, nextAttrs, node.marks);
11024
+ tr.setMeta("forceUpdatePagination", true);
11025
+ return true;
11026
+ }
11027
+ const docAttrs = state.doc.attrs ?? {};
11028
+ const converter = editor.converter ?? null;
11029
+ const baseBodySectPr = docAttrs.bodySectPr || converter?.bodySectPr || null;
11030
+ const sectPr = baseBodySectPr != null ? JSON.parse(JSON.stringify(baseBodySectPr)) : { type: "element", name: "w:sectPr", elements: [] };
11031
+ try {
11032
+ updateSectionMargins({ type: "sectPr", sectPr }, updates);
11033
+ } catch (err) {
11034
+ console.error("[setSectionPageMarginsAtSelection] Failed to update sectPr:", err);
11035
+ return false;
11036
+ }
11037
+ if (converter) {
11038
+ converter.bodySectPr = sectPr;
11039
+ if (!converter.pageStyles) converter.pageStyles = {};
11040
+ if (!converter.pageStyles.pageMargins) converter.pageStyles.pageMargins = {};
11041
+ const pageMargins = converter.pageStyles.pageMargins;
11042
+ const resolved = getSectPrMargins(sectPr);
11043
+ if (resolved.top != null) pageMargins.top = resolved.top;
11044
+ if (resolved.right != null) pageMargins.right = resolved.right;
11045
+ if (resolved.bottom != null) pageMargins.bottom = resolved.bottom;
11046
+ if (resolved.left != null) pageMargins.left = resolved.left;
11047
+ if (resolved.header != null) pageMargins.header = resolved.header;
11048
+ if (resolved.footer != null) pageMargins.footer = resolved.footer;
11049
+ }
11050
+ const nextDocAttrs = { ...docAttrs, bodySectPr: sectPr };
11051
+ tr.setNodeMarkup(0, void 0, nextDocAttrs);
11052
+ tr.setMeta("forceUpdatePagination", true);
11053
+ return true;
11054
+ };
10956
11055
  const insertSectionBreakAtSelection = ({ headerInches, footerInches } = {}) => ({ tr, state, editor }) => {
10957
11056
  if (!state || !editor) {
10958
11057
  console.warn("[insertSectionBreakAtSelection] Missing state or editor");
@@ -11484,6 +11583,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
11484
11583
  setMeta,
11485
11584
  setNode,
11486
11585
  setSectionHeaderFooterAtSelection,
11586
+ setSectionPageMarginsAtSelection,
11487
11587
  setTextIndentation,
11488
11588
  setTextSelection,
11489
11589
  skipTab,
@@ -15351,7 +15451,7 @@ const canUseDOM = () => {
15351
15451
  return false;
15352
15452
  }
15353
15453
  };
15354
- const summaryVersion = "1.3.0-next.11";
15454
+ const summaryVersion = "1.3.0-next.13";
15355
15455
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
15356
15456
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
15357
15457
  function mapAttributes(attrs) {
@@ -17353,9 +17453,8 @@ class Editor extends EventEmitter {
17353
17453
  try {
17354
17454
  const jsonObj = json;
17355
17455
  const attrs = jsonObj.attrs;
17356
- const hasBody = attrs && "bodySectPr" in attrs;
17357
17456
  const converter = this.converter;
17358
- if (!hasBody && converter && converter.bodySectPr) {
17457
+ if (converter && converter.bodySectPr) {
17359
17458
  jsonObj.attrs = attrs || {};
17360
17459
  jsonObj.attrs.bodySectPr = converter.bodySectPr;
17361
17460
  }
@@ -17984,7 +18083,7 @@ class Editor extends EventEmitter {
17984
18083
  * Process collaboration migrations
17985
18084
  */
17986
18085
  processCollaborationMigrations() {
17987
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.11");
18086
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.13");
17988
18087
  if (!this.options.ydoc) return;
17989
18088
  const metaMap = this.options.ydoc.getMap("meta");
17990
18089
  let docVersion = metaMap.get("version");
@@ -43355,7 +43454,16 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
43355
43454
  if (!value || typeof value !== "object") return;
43356
43455
  return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
43357
43456
  };
43358
- const normalizedIndent = normalizeIndentObject(attrs.indent) ?? convertIndentTwipsToPx(paragraphProps.indent) ?? convertIndentTwipsToPx(hydrated?.indent) ?? normalizeParagraphIndent(attrs.textIndent);
43457
+ const hydratedIndentPx = convertIndentTwipsToPx(hydrated?.indent);
43458
+ const paragraphIndentPx = convertIndentTwipsToPx(paragraphProps.indent);
43459
+ const textIndentPx = normalizeParagraphIndent(attrs.textIndent);
43460
+ const attrsIndentPx = normalizeIndentObject(attrs.indent);
43461
+ const indentChain = [];
43462
+ if (hydratedIndentPx) indentChain.push({ indent: hydratedIndentPx });
43463
+ if (paragraphIndentPx) indentChain.push({ indent: paragraphIndentPx });
43464
+ if (textIndentPx) indentChain.push({ indent: textIndentPx });
43465
+ if (attrsIndentPx) indentChain.push({ indent: attrsIndentPx });
43466
+ const normalizedIndent = indentChain.length ? superEditor_converter.combineIndentProperties(indentChain).indent : void 0;
43359
43467
  const unwrapTabStops = (tabStops) => {
43360
43468
  if (!Array.isArray(tabStops)) {
43361
43469
  return void 0;
@@ -49611,7 +49719,11 @@ async function measureTableBlock(block, constraints) {
49611
49719
  }
49612
49720
  async function measureImageBlock(block, constraints) {
49613
49721
  const intrinsic = getIntrinsicImageSize(block, constraints.maxWidth);
49614
- const maxWidth = constraints.maxWidth > 0 ? constraints.maxWidth : intrinsic.width;
49722
+ const isBlockBehindDoc = block.anchor?.behindDoc;
49723
+ const isBlockWrapBehindDoc = block.wrap?.type === "None" && block.wrap?.behindDoc;
49724
+ const bypassWidthConstraint = isBlockBehindDoc || isBlockWrapBehindDoc;
49725
+ const isWidthConstraintBypassed = bypassWidthConstraint || constraints.maxWidth <= 0;
49726
+ const maxWidth = isWidthConstraintBypassed ? intrinsic.width : constraints.maxWidth;
49615
49727
  const hasNegativeVerticalPosition = block.anchor?.isAnchored && (typeof block.anchor?.offsetV === "number" && block.anchor.offsetV < 0 || typeof block.margin?.top === "number" && block.margin.top < 0);
49616
49728
  const maxHeight = hasNegativeVerticalPosition || !constraints.maxHeight || constraints.maxHeight <= 0 ? Infinity : constraints.maxHeight;
49617
49729
  const widthScale = maxWidth / intrinsic.width;
@@ -54732,7 +54844,7 @@ class PresentationEditor extends EventEmitter {
54732
54844
  const zoom = this.#layoutOptions.zoom ?? 1;
54733
54845
  const layoutMode = this.#layoutOptions.layoutMode ?? "vertical";
54734
54846
  const pages = this.#layoutState.layout?.pages;
54735
- const pageGap = this.#layoutState.layout?.pageGap ?? this.#getEffectivePageGap();
54847
+ const pageGap = this.#getEffectivePageGap();
54736
54848
  const defaultWidth = this.#layoutOptions.pageSize?.w ?? DEFAULT_PAGE_SIZE.w;
54737
54849
  const defaultHeight = this.#layoutOptions.pageSize?.h ?? DEFAULT_PAGE_SIZE.h;
54738
54850
  let maxWidth = defaultWidth;
@@ -57843,7 +57955,11 @@ const Document = Node$1.create({
57843
57955
  */
57844
57956
  clearDocument: () => ({ commands: commands2 }) => {
57845
57957
  return commands2.setContent("<p></p>");
57846
- }
57958
+ },
57959
+ /**
57960
+ * Set section page margins (top/right/bottom/left) for the section at the current selection.
57961
+ */
57962
+ setSectionPageMarginsAtSelection
57847
57963
  };
57848
57964
  }
57849
57965
  });
@@ -64352,6 +64468,10 @@ const Image = Node$1.create({
64352
64468
  }
64353
64469
  const hasAnchorData = Boolean(anchorData);
64354
64470
  const hasMarginOffsets = marginOffset?.horizontal != null || marginOffset?.top != null;
64471
+ const isWrapBehindDoc = wrap?.attrs?.behindDoc;
64472
+ const isAnchorBehindDoc = anchorData?.behindDoc;
64473
+ const isBehindDocAnchor = wrap?.type === "None" && (isWrapBehindDoc || isAnchorBehindDoc);
64474
+ const isAbsolutelyPositioned = style2.includes("position: absolute;");
64355
64475
  if (hasAnchorData) {
64356
64476
  switch (anchorData.hRelativeFrom) {
64357
64477
  case "page":
@@ -64379,7 +64499,6 @@ const Image = Node$1.create({
64379
64499
  style2 += "float: left;";
64380
64500
  }
64381
64501
  } else if (!anchorData.alignH && marginOffset?.horizontal != null) {
64382
- const isAbsolutelyPositioned = style2.includes("position: absolute;");
64383
64502
  if (isAbsolutelyPositioned) {
64384
64503
  style2 += `left: ${baseHorizontal}px;`;
64385
64504
  style2 += "max-width: none;";
@@ -64393,7 +64512,8 @@ const Image = Node$1.create({
64393
64512
  const relativeFromPageV = anchorData?.vRelativeFrom === "page";
64394
64513
  const relativeFromMarginV = anchorData?.vRelativeFrom === "margin";
64395
64514
  const maxMarginV = 500;
64396
- const baseTop = Math.max(0, marginOffset?.top ?? 0);
64515
+ const allowNegativeTopOffset = isBehindDocAnchor;
64516
+ const baseTop = allowNegativeTopOffset ? marginOffset?.top ?? 0 : Math.max(0, marginOffset?.top ?? 0);
64397
64517
  let rotationHorizontal = 0;
64398
64518
  let rotationTop = 0;
64399
64519
  const { rotation: rotation2 } = transformData ?? {};
@@ -64412,7 +64532,10 @@ const Image = Node$1.create({
64412
64532
  margin.left += horizontal;
64413
64533
  }
64414
64534
  }
64415
- if (top2 && !relativeFromMarginV) {
64535
+ const appliedTopViaStyle = isAbsolutelyPositioned && allowNegativeTopOffset && !relativeFromMarginV;
64536
+ if (appliedTopViaStyle) {
64537
+ style2 += `top: ${top2}px;`;
64538
+ } else if (top2 && !relativeFromMarginV) {
64416
64539
  if (relativeFromPageV && top2 >= maxMarginV) margin.top += maxMarginV;
64417
64540
  else margin.top += top2;
64418
64541
  }
@@ -64425,6 +64548,9 @@ const Image = Node$1.create({
64425
64548
  }
64426
64549
  if (margin.top) style2 += `margin-top: ${margin.top}px;`;
64427
64550
  if (margin.bottom) style2 += `margin-bottom: ${margin.bottom}px;`;
64551
+ if (isBehindDocAnchor) {
64552
+ style2 += "max-width: none;";
64553
+ }
64428
64554
  const finalAttributes = { ...htmlAttributes };
64429
64555
  if (style2) {
64430
64556
  const existingStyle = finalAttributes.style || "";
@@ -90234,10 +90360,14 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
90234
90360
  const handleMarginChange = ({ side, value }) => {
90235
90361
  const base2 = activeEditor.value;
90236
90362
  if (!base2) return;
90237
- const pageStyles2 = base2.getPageStyles();
90238
- const { pageMargins } = pageStyles2;
90239
- const update = { ...pageMargins, [side]: value };
90240
- base2?.updatePageStyle({ pageMargins: update });
90363
+ const payload = side === "left" ? { leftInches: value } : side === "right" ? { rightInches: value } : side === "top" ? { topInches: value } : side === "bottom" ? { bottomInches: value } : {};
90364
+ const didUpdateSection = typeof base2.commands?.setSectionPageMarginsAtSelection === "function" ? base2.commands.setSectionPageMarginsAtSelection(payload) : false;
90365
+ if (!didUpdateSection) {
90366
+ const pageStyles2 = base2.getPageStyles();
90367
+ const { pageMargins } = pageStyles2;
90368
+ const update = { ...pageMargins, [side]: value };
90369
+ base2?.updatePageStyle({ pageMargins: update });
90370
+ }
90241
90371
  };
90242
90372
  vue.onBeforeUnmount(() => {
90243
90373
  stopPolling();
@@ -90373,7 +90503,7 @@ const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
90373
90503
  };
90374
90504
  }
90375
90505
  });
90376
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8dd4cf59"]]);
90506
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-3e9da07c"]]);
90377
90507
  const _hoisted_1 = ["innerHTML"];
90378
90508
  const _sfc_main = {
90379
90509
  __name: "SuperInput",
@@ -1,5 +1,5 @@
1
- import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-CE0fU2k7.es.js";
2
- import "./SuperConverter-Caxoktb7.es.js";
1
+ import { B as BIT8, M as MAX_SAFE_INTEGER, c as create, a as BITS7, u as utf8TextDecoder, b as create$1, s as setIfUndefined, d as create$2, f as from, e as floor$1, g as equalityDeep, w as writeVarUint, h as writeVarString, t as toUint8Array, i as createEncoder, j as createInjectionKey, k as toString, l as throwError, m as useSsrAdapter, n as configProviderInjectionKey, o as cssrAnchorMetaName, p as globalStyle, q as cB, r as c, v as isMounted, x as commonVariables$2, y as cM, z as cNotM, A as cE, C as derived, D as changeColor, E as insideModal, F as insidePopover, G as resolveWrappedSlot, H as on, I as warnOnce, J as useConfig, K as useMergedState, L as useMemo, N as useTheme, O as useRtl, P as createKey, Q as useThemeClass, R as createId, S as call, T as render, U as messageProviderInjectionKey, V as messageApiInjectionKey, W as fromBase64, X as onChange, Y as varStorage, Z as toBase64, _ as createUint8ArrayFromArrayBuffer, $ as offChange, a0 as writeVarUint8Array, a1 as map, a2 as length, a3 as isNode, a4 as min, a5 as pow, a6 as comments_module_events, a7 as getFileObject, a8 as getTrackChanges, a9 as CommentsPluginKey, aa as TrackChangesBasePluginKey, ab as Editor, ac as getRichTextExtensions, ad as ellipsisVerticalSvg, ae as xmarkIconSvg, af as checkIconSvg, ag as caretDownIconSvg, ah as commentIconSvg, ai as _export_sfc, aj as NDropdown, ak as SuperInput, al as vClickOutside, am as PresentationEditor, an as SuperEditor, ao as AIWriter, ap as NConfigProvider, aq as SuperToolbar } from "./index-OlLDoLS-.es.js";
2
+ import "./SuperConverter-Dh27SFeK.es.js";
3
3
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
4
4
  import { E as EventEmitter } from "./eventemitter3-CwrdEv8r.es.js";
5
5
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -7448,7 +7448,7 @@ const _sfc_main = {
7448
7448
  __name: "SuperDoc",
7449
7449
  emits: ["selection-update"],
7450
7450
  setup(__props, { emit: __emit }) {
7451
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-Dsxwbxdh.es.js"));
7451
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-DebfKi_n.es.js"));
7452
7452
  const superdocStore = useSuperdocStore();
7453
7453
  const commentsStore = useCommentsStore();
7454
7454
  const {
@@ -7489,6 +7489,7 @@ const _sfc_main = {
7489
7489
  commentsStore.proxy = proxy;
7490
7490
  const { isHighContrastMode: isHighContrastMode2 } = useHighContrastMode();
7491
7491
  const { uiFontFamily } = useUiFontFamily();
7492
+ const isViewingMode = () => proxy?.$superdoc?.config?.documentMode === "viewing";
7492
7493
  const commentsModuleConfig = computed(() => {
7493
7494
  const config = modules.comments;
7494
7495
  if (config === false || config == null) return null;
@@ -7583,6 +7584,10 @@ const _sfc_main = {
7583
7584
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7584
7585
  if (!commentsConfig || commentsConfig === false) return;
7585
7586
  if (!positions || Object.keys(positions).length === 0) return;
7587
+ if (isViewingMode()) {
7588
+ commentsStore.clearEditorCommentPositions?.();
7589
+ return;
7590
+ }
7586
7591
  const mappedPositions = presentationEditor.getCommentBounds(positions, layers.value);
7587
7592
  handleEditorLocationsUpdate(mappedPositions);
7588
7593
  });
@@ -7602,6 +7607,13 @@ const _sfc_main = {
7602
7607
  const onEditorSelectionChange = ({ editor, transaction }) => {
7603
7608
  if (skipSelectionUpdate.value) {
7604
7609
  skipSelectionUpdate.value = false;
7610
+ if (isViewingMode()) {
7611
+ resetSelection();
7612
+ }
7613
+ return;
7614
+ }
7615
+ if (isViewingMode()) {
7616
+ resetSelection();
7605
7617
  return;
7606
7618
  }
7607
7619
  const { documentId } = editor.options;
@@ -7780,6 +7792,10 @@ const _sfc_main = {
7780
7792
  const onEditorCommentLocationsUpdate = (doc, { allCommentIds: activeThreadId, allCommentPositions } = {}) => {
7781
7793
  const commentsConfig = proxy.$superdoc.config.modules?.comments;
7782
7794
  if (!commentsConfig || commentsConfig === false) return;
7795
+ if (isViewingMode()) {
7796
+ commentsStore.clearEditorCommentPositions?.();
7797
+ return;
7798
+ }
7783
7799
  const presentation = PresentationEditor.getInstance(doc.id);
7784
7800
  if (!presentation) {
7785
7801
  handleEditorLocationsUpdate(allCommentPositions, activeThreadId);
@@ -7835,11 +7851,12 @@ const _sfc_main = {
7835
7851
  };
7836
7852
  const isCommentsEnabled = computed(() => Boolean(commentsModuleConfig.value));
7837
7853
  const showCommentsSidebar = computed(() => {
7854
+ if (isViewingMode()) return false;
7838
7855
  return pendingComment.value || getFloatingComments.value?.length > 0 && isReady.value && layers.value && isCommentsEnabled.value && !isCommentsListVisible.value;
7839
7856
  });
7840
7857
  const showToolsFloatingMenu = computed(() => {
7841
7858
  if (!isCommentsEnabled.value) return false;
7842
- return toolsMenuPosition.top && !getConfig.value?.readOnly;
7859
+ return selectionPosition.value && toolsMenuPosition.top && !getConfig.value?.readOnly;
7843
7860
  });
7844
7861
  computed(() => {
7845
7862
  if (!isCommentsEnabled.value) return false;
@@ -7887,6 +7904,10 @@ const _sfc_main = {
7887
7904
  return style2;
7888
7905
  });
7889
7906
  const handleSelectionChange = (selection) => {
7907
+ if (isViewingMode()) {
7908
+ resetSelection();
7909
+ return;
7910
+ }
7890
7911
  if (!selection.selectionBounds || !isCommentsEnabled.value) return;
7891
7912
  resetSelection();
7892
7913
  const isMobileView = window.matchMedia("(max-width: 768px)").matches;
@@ -7912,12 +7933,14 @@ const _sfc_main = {
7912
7933
  };
7913
7934
  const resetSelection = () => {
7914
7935
  selectionPosition.value = null;
7936
+ toolsMenuPosition.top = null;
7915
7937
  };
7916
7938
  const updateSelection = ({ startX, startY, x, y, source }) => {
7917
7939
  const hasStartCoords = typeof startX === "number" || typeof startY === "number";
7918
7940
  const hasEndCoords = typeof x === "number" || typeof y === "number";
7919
7941
  if (!hasStartCoords && !hasEndCoords) {
7920
- return selectionPosition.value = null;
7942
+ resetSelection();
7943
+ return;
7921
7944
  }
7922
7945
  if (!selectionPosition.value) {
7923
7946
  if (startY == null || startX == null) return;
@@ -8170,7 +8193,7 @@ const _sfc_main = {
8170
8193
  };
8171
8194
  }
8172
8195
  };
8173
- const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1e96f708"]]);
8196
+ const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-5196811d"]]);
8174
8197
  const createSuperdocVueApp = () => {
8175
8198
  const app = createApp(App);
8176
8199
  const pinia = createPinia();
@@ -8354,7 +8377,7 @@ class SuperDoc extends EventEmitter {
8354
8377
  this.config.colors = shuffleArray(this.config.colors);
8355
8378
  this.userColorMap = /* @__PURE__ */ new Map();
8356
8379
  this.colorIndex = 0;
8357
- this.version = "1.3.0-next.11";
8380
+ this.version = "1.3.0-next.13";
8358
8381
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
8359
8382
  this.superdocId = config.superdocId || v4();
8360
8383
  this.colors = this.config.colors;