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

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,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-BauKfBRr.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.12";
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.12");
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;
@@ -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",
package/dist/style.css CHANGED
@@ -1978,10 +1978,10 @@ to {
1978
1978
  box-shadow: 0 0 4px rgba(74, 144, 226, 0.5);
1979
1979
  }
1980
1980
 
1981
- .editor-element[data-v-8dd4cf59] {
1981
+ .editor-element[data-v-3e9da07c] {
1982
1982
  position: relative;
1983
1983
  }
1984
- .super-editor-container[data-v-8dd4cf59] {
1984
+ .super-editor-container[data-v-3e9da07c] {
1985
1985
  width: auto;
1986
1986
  height: auto;
1987
1987
  /* min-width is controlled via inline style (containerStyle) to scale with zoom */
@@ -1990,14 +1990,14 @@ to {
1990
1990
  display: flex;
1991
1991
  flex-direction: column;
1992
1992
  }
1993
- .ruler[data-v-8dd4cf59] {
1993
+ .ruler[data-v-3e9da07c] {
1994
1994
  margin-bottom: 2px;
1995
1995
  }
1996
- .super-editor[data-v-8dd4cf59] {
1996
+ .super-editor[data-v-3e9da07c] {
1997
1997
  color: initial;
1998
1998
  overflow: hidden;
1999
1999
  }
2000
- .placeholder-editor[data-v-8dd4cf59] {
2000
+ .placeholder-editor[data-v-3e9da07c] {
2001
2001
  position: absolute;
2002
2002
  top: 0;
2003
2003
  left: 0;
@@ -2009,7 +2009,7 @@ to {
2009
2009
  background-color: white;
2010
2010
  box-sizing: border-box;
2011
2011
  }
2012
- .placeholder-title[data-v-8dd4cf59] {
2012
+ .placeholder-title[data-v-3e9da07c] {
2013
2013
  display: flex;
2014
2014
  justify-content: center;
2015
2015
  margin-bottom: 40px;
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("../chunks/jszip-C8_CqJxM.cjs");
4
4
  require("../chunks/helpers-nOdwpmwb.cjs");
5
- const superEditor_converter = require("../chunks/SuperConverter-DgyRPhnD.cjs");
5
+ const superEditor_converter = require("../chunks/SuperConverter-BauKfBRr.cjs");
6
6
  require("../chunks/uuid-R7L08bOx.cjs");
7
7
  exports.SuperConverter = superEditor_converter.SuperConverter;
@@ -1,6 +1,6 @@
1
1
  import "../chunks/jszip-B1fkPkPJ.es.js";
2
2
  import "../chunks/helpers-C8e9wR5l.es.js";
3
- import { S } from "../chunks/SuperConverter-Caxoktb7.es.js";
3
+ import { S } from "../chunks/SuperConverter-BQHQ2WON.es.js";
4
4
  import "../chunks/uuid-CjlX8hrF.es.js";
5
5
  export {
6
6
  S as SuperConverter
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-BClM7AjD.cjs");
3
+ const index = require("./chunks/index-CCWqRqAf.cjs");
4
4
  const superEditor_docxZipper = require("./super-editor/docx-zipper.cjs");
5
5
  const superEditor_fileZipper = require("./super-editor/file-zipper.cjs");
6
6
  const vue = require("./chunks/vue-De9wkgLl.cjs");
7
- const superEditor_converter = require("./chunks/SuperConverter-DgyRPhnD.cjs");
7
+ const superEditor_converter = require("./chunks/SuperConverter-BauKfBRr.cjs");
8
8
  function isNodeType(node, name) {
9
9
  return node.type.name === name;
10
10
  }
@@ -1,9 +1,9 @@
1
- import { ax as Node, ay as Mark } from "./chunks/index-CE0fU2k7.es.js";
2
- import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-CE0fU2k7.es.js";
1
+ import { ax as Node, ay as Mark } from "./chunks/index-BRomAwaA.es.js";
2
+ import { ao, au, a9, ab, aw, am, av, aA, an, ak, aq, az, aa, as, aC, aE, aB, ac, aD, ar, at } from "./chunks/index-BRomAwaA.es.js";
3
3
  import { default as default2 } from "./super-editor/docx-zipper.es.js";
4
4
  import { createZip } from "./super-editor/file-zipper.es.js";
5
5
  import { d as defineComponent, E as createElementBlock, G as openBlock, K as createBaseVNode } from "./chunks/vue-BnBKJwCW.es.js";
6
- import { S, r } from "./chunks/SuperConverter-Caxoktb7.es.js";
6
+ import { S, r } from "./chunks/SuperConverter-BQHQ2WON.es.js";
7
7
  function isNodeType(node, name) {
8
8
  return node.type.name === name;
9
9
  }
package/dist/superdoc.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index = require("./chunks/index-BClM7AjD.cjs");
4
- const superdoc = require("./chunks/index-CTQjsYpZ.cjs");
5
- const superEditor_converter = require("./chunks/SuperConverter-DgyRPhnD.cjs");
3
+ const index = require("./chunks/index-CCWqRqAf.cjs");
4
+ const superdoc = require("./chunks/index-BC056HXc.cjs");
5
+ const superEditor_converter = require("./chunks/SuperConverter-BauKfBRr.cjs");
6
6
  const blankDocx = require("./chunks/blank-docx-DfW3Eeh2.cjs");
7
7
  require("./chunks/jszip-C8_CqJxM.cjs");
8
8
  require("./chunks/helpers-nOdwpmwb.cjs");
@@ -1,6 +1,6 @@
1
- import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-CE0fU2k7.es.js";
2
- import { D, H, P, S, c } from "./chunks/index-D2CRfjhH.es.js";
3
- import { S as S2, r } from "./chunks/SuperConverter-Caxoktb7.es.js";
1
+ import { au, ab, aw, av, as, a7, ac, ar, at } from "./chunks/index-BRomAwaA.es.js";
2
+ import { D, H, P, S, c } from "./chunks/index-BPi2Cjky.es.js";
3
+ import { S as S2, r } from "./chunks/SuperConverter-BQHQ2WON.es.js";
4
4
  import { B } from "./chunks/blank-docx-ABm6XYAA.es.js";
5
5
  import "./chunks/jszip-B1fkPkPJ.es.js";
6
6
  import "./chunks/helpers-C8e9wR5l.es.js";
@@ -36435,7 +36435,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
36435
36435
  static getStoredSuperdocVersion(docx) {
36436
36436
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
36437
36437
  }
36438
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.0-next.11") {
36438
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.3.0-next.12") {
36439
36439
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
36440
36440
  }
36441
36441
  /**
@@ -47282,6 +47282,105 @@ Please report this to https://github.com/markedjs/marked.`, e) {
47282
47282
  tr.setNodeMarkup(pos, void 0, nextAttrs, node2.marks);
47283
47283
  return true;
47284
47284
  };
47285
+ function findGoverningSectPrParagraph(doc2, selectionPos) {
47286
+ const candidates = [];
47287
+ doc2.descendants((node2, nodePos) => {
47288
+ if (node2.type?.name === "paragraph" && node2.attrs?.paragraphProperties?.sectPr) {
47289
+ candidates.push({ node: node2, pos: nodePos });
47290
+ }
47291
+ });
47292
+ if (!candidates.length) return null;
47293
+ const inside = candidates.find((c2) => selectionPos >= c2.pos && selectionPos < c2.pos + c2.node.nodeSize);
47294
+ if (inside) return inside;
47295
+ const atOrAfter = candidates.find((c2) => c2.pos >= selectionPos);
47296
+ return atOrAfter ?? candidates[candidates.length - 1];
47297
+ }
47298
+ const setSectionPageMarginsAtSelection = ({ topInches, rightInches, bottomInches, leftInches } = {}) => ({ tr, state, editor }) => {
47299
+ if (!state || !editor) {
47300
+ console.warn("[setSectionPageMarginsAtSelection] Missing state or editor");
47301
+ return false;
47302
+ }
47303
+ const hasTop = typeof topInches === "number";
47304
+ const hasRight = typeof rightInches === "number";
47305
+ const hasBottom = typeof bottomInches === "number";
47306
+ const hasLeft = typeof leftInches === "number";
47307
+ if (!hasTop && !hasRight && !hasBottom && !hasLeft) {
47308
+ console.warn("[setSectionPageMarginsAtSelection] No margin values provided");
47309
+ return false;
47310
+ }
47311
+ if (hasTop && topInches < 0 || hasRight && rightInches < 0 || hasBottom && bottomInches < 0 || hasLeft && leftInches < 0) {
47312
+ console.warn("[setSectionPageMarginsAtSelection] Margin values must be >= 0");
47313
+ return false;
47314
+ }
47315
+ const updates = {};
47316
+ if (hasTop) updates.topInches = topInches;
47317
+ if (hasRight) updates.rightInches = rightInches;
47318
+ if (hasBottom) updates.bottomInches = bottomInches;
47319
+ if (hasLeft) updates.leftInches = leftInches;
47320
+ const { from: from2 } = state.selection;
47321
+ const governing = findGoverningSectPrParagraph(state.doc, from2);
47322
+ if (governing) {
47323
+ const { node: node2, pos } = governing;
47324
+ const paraProps = node2.attrs?.paragraphProperties || null;
47325
+ const existingSectPr = paraProps?.sectPr || null;
47326
+ if (!existingSectPr) {
47327
+ console.warn("[setSectionPageMarginsAtSelection] Paragraph found but has no sectPr");
47328
+ return false;
47329
+ }
47330
+ const sectPr2 = JSON.parse(JSON.stringify(existingSectPr));
47331
+ try {
47332
+ updateSectionMargins({ type: "sectPr", sectPr: sectPr2 }, updates);
47333
+ } catch (err) {
47334
+ console.error("[setSectionPageMarginsAtSelection] Failed to update sectPr:", err);
47335
+ return false;
47336
+ }
47337
+ const resolved = getSectPrMargins(sectPr2);
47338
+ const normalizedSectionMargins = {
47339
+ top: resolved.top ?? null,
47340
+ right: resolved.right ?? null,
47341
+ bottom: resolved.bottom ?? null,
47342
+ left: resolved.left ?? null,
47343
+ header: resolved.header ?? null,
47344
+ footer: resolved.footer ?? null
47345
+ };
47346
+ const newParagraphProperties = { ...paraProps || {}, sectPr: sectPr2 };
47347
+ const nextAttrs = {
47348
+ ...node2.attrs,
47349
+ paragraphProperties: newParagraphProperties,
47350
+ sectionMargins: normalizedSectionMargins
47351
+ };
47352
+ tr.setNodeMarkup(pos, void 0, nextAttrs, node2.marks);
47353
+ tr.setMeta("forceUpdatePagination", true);
47354
+ return true;
47355
+ }
47356
+ const docAttrs = state.doc.attrs ?? {};
47357
+ const converter = editor.converter ?? null;
47358
+ const baseBodySectPr = docAttrs.bodySectPr || converter?.bodySectPr || null;
47359
+ const sectPr = baseBodySectPr != null ? JSON.parse(JSON.stringify(baseBodySectPr)) : { type: "element", name: "w:sectPr", elements: [] };
47360
+ try {
47361
+ updateSectionMargins({ type: "sectPr", sectPr }, updates);
47362
+ } catch (err) {
47363
+ console.error("[setSectionPageMarginsAtSelection] Failed to update sectPr:", err);
47364
+ return false;
47365
+ }
47366
+ if (converter) {
47367
+ converter.bodySectPr = sectPr;
47368
+ if (!converter.pageStyles) converter.pageStyles = {};
47369
+ if (!converter.pageStyles.pageMargins) converter.pageStyles.pageMargins = {};
47370
+ const pageMargins = converter.pageStyles.pageMargins;
47371
+ const resolved = getSectPrMargins(sectPr);
47372
+ if (resolved.top != null) pageMargins.top = resolved.top;
47373
+ if (resolved.right != null) pageMargins.right = resolved.right;
47374
+ if (resolved.bottom != null) pageMargins.bottom = resolved.bottom;
47375
+ if (resolved.left != null) pageMargins.left = resolved.left;
47376
+ if (resolved.header != null) pageMargins.header = resolved.header;
47377
+ if (resolved.footer != null) pageMargins.footer = resolved.footer;
47378
+ }
47379
+ const nextDocAttrs = { ...docAttrs, bodySectPr: sectPr };
47380
+ tr.setNodeMarkup(0, void 0, nextDocAttrs);
47381
+ tr.setMeta("forceUpdatePagination", true);
47382
+ return true;
47383
+ };
47285
47384
  const insertSectionBreakAtSelection = ({ headerInches, footerInches } = {}) => ({ tr, state, editor }) => {
47286
47385
  if (!state || !editor) {
47287
47386
  console.warn("[insertSectionBreakAtSelection] Missing state or editor");
@@ -47813,6 +47912,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
47813
47912
  setMeta,
47814
47913
  setNode,
47815
47914
  setSectionHeaderFooterAtSelection,
47915
+ setSectionPageMarginsAtSelection,
47816
47916
  setTextIndentation,
47817
47917
  setTextSelection,
47818
47918
  skipTab,
@@ -62145,7 +62245,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
62145
62245
  return false;
62146
62246
  }
62147
62247
  };
62148
- const summaryVersion = "1.3.0-next.11";
62248
+ const summaryVersion = "1.3.0-next.12";
62149
62249
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
62150
62250
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
62151
62251
  function mapAttributes(attrs) {
@@ -64148,9 +64248,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64148
64248
  try {
64149
64249
  const jsonObj = json;
64150
64250
  const attrs = jsonObj.attrs;
64151
- const hasBody = attrs && "bodySectPr" in attrs;
64152
64251
  const converter = this.converter;
64153
- if (!hasBody && converter && converter.bodySectPr) {
64252
+ if (converter && converter.bodySectPr) {
64154
64253
  jsonObj.attrs = attrs || {};
64155
64254
  jsonObj.attrs.bodySectPr = converter.bodySectPr;
64156
64255
  }
@@ -64779,7 +64878,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64779
64878
  * Process collaboration migrations
64780
64879
  */
64781
64880
  processCollaborationMigrations() {
64782
- console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.11");
64881
+ console.debug("[checkVersionMigrations] Current editor version", "1.3.0-next.12");
64783
64882
  if (!this.options.ydoc) return;
64784
64883
  const metaMap = this.options.ydoc.getMap("meta");
64785
64884
  let docVersion = metaMap.get("version");
@@ -90098,7 +90197,16 @@ ${l}
90098
90197
  if (!value || typeof value !== "object") return;
90099
90198
  return normalizePxIndent(value) ?? convertIndentTwipsToPx(value);
90100
90199
  };
90101
- const normalizedIndent = normalizeIndentObject(attrs.indent) ?? convertIndentTwipsToPx(paragraphProps.indent) ?? convertIndentTwipsToPx(hydrated?.indent) ?? normalizeParagraphIndent(attrs.textIndent);
90200
+ const hydratedIndentPx = convertIndentTwipsToPx(hydrated?.indent);
90201
+ const paragraphIndentPx = convertIndentTwipsToPx(paragraphProps.indent);
90202
+ const textIndentPx = normalizeParagraphIndent(attrs.textIndent);
90203
+ const attrsIndentPx = normalizeIndentObject(attrs.indent);
90204
+ const indentChain = [];
90205
+ if (hydratedIndentPx) indentChain.push({ indent: hydratedIndentPx });
90206
+ if (paragraphIndentPx) indentChain.push({ indent: paragraphIndentPx });
90207
+ if (textIndentPx) indentChain.push({ indent: textIndentPx });
90208
+ if (attrsIndentPx) indentChain.push({ indent: attrsIndentPx });
90209
+ const normalizedIndent = indentChain.length ? combineIndentProperties(indentChain).indent : void 0;
90102
90210
  const unwrapTabStops = (tabStops) => {
90103
90211
  if (!Array.isArray(tabStops)) {
90104
90212
  return void 0;
@@ -96354,7 +96462,11 @@ ${l}
96354
96462
  }
96355
96463
  async function measureImageBlock(block, constraints) {
96356
96464
  const intrinsic = getIntrinsicImageSize(block, constraints.maxWidth);
96357
- const maxWidth = constraints.maxWidth > 0 ? constraints.maxWidth : intrinsic.width;
96465
+ const isBlockBehindDoc = block.anchor?.behindDoc;
96466
+ const isBlockWrapBehindDoc = block.wrap?.type === "None" && block.wrap?.behindDoc;
96467
+ const bypassWidthConstraint = isBlockBehindDoc || isBlockWrapBehindDoc;
96468
+ const isWidthConstraintBypassed = bypassWidthConstraint || constraints.maxWidth <= 0;
96469
+ const maxWidth = isWidthConstraintBypassed ? intrinsic.width : constraints.maxWidth;
96358
96470
  const hasNegativeVerticalPosition = block.anchor?.isAnchored && (typeof block.anchor?.offsetV === "number" && block.anchor.offsetV < 0 || typeof block.margin?.top === "number" && block.margin.top < 0);
96359
96471
  const maxHeight = hasNegativeVerticalPosition || !constraints.maxHeight || constraints.maxHeight <= 0 ? Infinity : constraints.maxHeight;
96360
96472
  const widthScale = maxWidth / intrinsic.width;
@@ -104539,7 +104651,11 @@ ${l}
104539
104651
  */
104540
104652
  clearDocument: () => ({ commands: commands2 }) => {
104541
104653
  return commands2.setContent("<p></p>");
104542
- }
104654
+ },
104655
+ /**
104656
+ * Set section page margins (top/right/bottom/left) for the section at the current selection.
104657
+ */
104658
+ setSectionPageMarginsAtSelection
104543
104659
  };
104544
104660
  }
104545
104661
  });
@@ -111048,6 +111164,10 @@ ${l}
111048
111164
  }
111049
111165
  const hasAnchorData = Boolean(anchorData);
111050
111166
  const hasMarginOffsets = marginOffset?.horizontal != null || marginOffset?.top != null;
111167
+ const isWrapBehindDoc = wrap2?.attrs?.behindDoc;
111168
+ const isAnchorBehindDoc = anchorData?.behindDoc;
111169
+ const isBehindDocAnchor = wrap2?.type === "None" && (isWrapBehindDoc || isAnchorBehindDoc);
111170
+ const isAbsolutelyPositioned = style2.includes("position: absolute;");
111051
111171
  if (hasAnchorData) {
111052
111172
  switch (anchorData.hRelativeFrom) {
111053
111173
  case "page":
@@ -111075,7 +111195,6 @@ ${l}
111075
111195
  style2 += "float: left;";
111076
111196
  }
111077
111197
  } else if (!anchorData.alignH && marginOffset?.horizontal != null) {
111078
- const isAbsolutelyPositioned = style2.includes("position: absolute;");
111079
111198
  if (isAbsolutelyPositioned) {
111080
111199
  style2 += `left: ${baseHorizontal}px;`;
111081
111200
  style2 += "max-width: none;";
@@ -111089,7 +111208,8 @@ ${l}
111089
111208
  const relativeFromPageV = anchorData?.vRelativeFrom === "page";
111090
111209
  const relativeFromMarginV = anchorData?.vRelativeFrom === "margin";
111091
111210
  const maxMarginV = 500;
111092
- const baseTop = Math.max(0, marginOffset?.top ?? 0);
111211
+ const allowNegativeTopOffset = isBehindDocAnchor;
111212
+ const baseTop = allowNegativeTopOffset ? marginOffset?.top ?? 0 : Math.max(0, marginOffset?.top ?? 0);
111093
111213
  let rotationHorizontal = 0;
111094
111214
  let rotationTop = 0;
111095
111215
  const { rotation: rotation2 } = transformData ?? {};
@@ -111108,7 +111228,10 @@ ${l}
111108
111228
  margin.left += horizontal;
111109
111229
  }
111110
111230
  }
111111
- if (top2 && !relativeFromMarginV) {
111231
+ const appliedTopViaStyle = isAbsolutelyPositioned && allowNegativeTopOffset && !relativeFromMarginV;
111232
+ if (appliedTopViaStyle) {
111233
+ style2 += `top: ${top2}px;`;
111234
+ } else if (top2 && !relativeFromMarginV) {
111112
111235
  if (relativeFromPageV && top2 >= maxMarginV) margin.top += maxMarginV;
111113
111236
  else margin.top += top2;
111114
111237
  }
@@ -111121,6 +111244,9 @@ ${l}
111121
111244
  }
111122
111245
  if (margin.top) style2 += `margin-top: ${margin.top}px;`;
111123
111246
  if (margin.bottom) style2 += `margin-bottom: ${margin.bottom}px;`;
111247
+ if (isBehindDocAnchor) {
111248
+ style2 += "max-width: none;";
111249
+ }
111124
111250
  const finalAttributes = { ...htmlAttributes };
111125
111251
  if (style2) {
111126
111252
  const existingStyle = finalAttributes.style || "";
@@ -139009,10 +139135,14 @@ ${style2}
139009
139135
  const handleMarginChange = ({ side, value }) => {
139010
139136
  const base2 = activeEditor.value;
139011
139137
  if (!base2) return;
139012
- const pageStyles2 = base2.getPageStyles();
139013
- const { pageMargins } = pageStyles2;
139014
- const update = { ...pageMargins, [side]: value };
139015
- base2?.updatePageStyle({ pageMargins: update });
139138
+ const payload = side === "left" ? { leftInches: value } : side === "right" ? { rightInches: value } : side === "top" ? { topInches: value } : side === "bottom" ? { bottomInches: value } : {};
139139
+ const didUpdateSection = typeof base2.commands?.setSectionPageMarginsAtSelection === "function" ? base2.commands.setSectionPageMarginsAtSelection(payload) : false;
139140
+ if (!didUpdateSection) {
139141
+ const pageStyles2 = base2.getPageStyles();
139142
+ const { pageMargins } = pageStyles2;
139143
+ const update = { ...pageMargins, [side]: value };
139144
+ base2?.updatePageStyle({ pageMargins: update });
139145
+ }
139016
139146
  };
139017
139147
  onBeforeUnmount(() => {
139018
139148
  stopPolling();
@@ -139148,7 +139278,7 @@ ${style2}
139148
139278
  };
139149
139279
  }
139150
139280
  });
139151
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-8dd4cf59"]]);
139281
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$j, [["__scopeId", "data-v-3e9da07c"]]);
139152
139282
  const _hoisted_1$h = ["innerHTML"];
139153
139283
  const _sfc_main$i = {
139154
139284
  __name: "SuperInput",
@@ -144186,7 +144316,7 @@ ${reason}`);
144186
144316
  this.config.colors = shuffleArray(this.config.colors);
144187
144317
  this.userColorMap = /* @__PURE__ */ new Map();
144188
144318
  this.colorIndex = 0;
144189
- this.version = "1.3.0-next.11";
144319
+ this.version = "1.3.0-next.12";
144190
144320
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
144191
144321
  this.superdocId = config2.superdocId || v4();
144192
144322
  this.colors = this.config.colors;