superdoc 1.0.0-beta.97 → 1.0.0-beta.98

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 (27) hide show
  1. package/dist/chunks/{PdfViewer-BHcBfUWj.es.js → PdfViewer-1_KffD-j.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-YvkZg201.cjs → PdfViewer-D1Ot32kX.cjs} +1 -1
  3. package/dist/chunks/{index-DeQfFbTb.es.js → index-CP2_WwLA.es.js} +3 -3
  4. package/dist/chunks/{index-DZ_AI-HW.cjs → index-CUO7gEi8.cjs} +3 -3
  5. package/dist/chunks/{index-Pvlqsxge-vW641SZt.es.js → index-Dg_sTYZK-D20z8mus.es.js} +1 -1
  6. package/dist/chunks/{index-Pvlqsxge-IH3eauKE.cjs → index-Dg_sTYZK-DYDzxoXL.cjs} +1 -1
  7. package/dist/chunks/{super-editor.es-BinyZw4F.es.js → super-editor.es-3dJOUw65.es.js} +113 -151
  8. package/dist/chunks/{super-editor.es-BP3PKkwh.cjs → super-editor.es-DN_dgBH0.cjs} +113 -151
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-BEVM5t3i.js → converter-Oj-eTB79.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-vETk3IMG.js → docx-zipper-Dl188zQ3.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-B8k1bwD_.js → editor-DBXoaaWP.js} +114 -152
  13. package/dist/super-editor/chunks/{index-Pvlqsxge.js → index-Dg_sTYZK.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-j1GSUGWU.js → toolbar-PlGGj0Ew.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +115 -153
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  import { y as defineComponent, z as h, O as Transition, a0 as process$1, J as watchEffect, a as computed, r as ref, j as onMounted, W as onUnmounted, b as createElementBlock, o as openBlock, f as createBaseVNode, e as createCommentVNode, u as createVNode, v as unref } from "./vue-Dysv_7z5.es.js";
2
- import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-DeQfFbTb.es.js";
2
+ import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-CP2_WwLA.es.js";
3
3
  function self(vars) {
4
4
  const {
5
5
  opacityDisabled,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-jWLMl8Ts.cjs");
4
- const superdoc = require("./index-DZ_AI-HW.cjs");
4
+ const superdoc = require("./index-CUO7gEi8.cjs");
5
5
  function self(vars) {
6
6
  const {
7
7
  opacityDisabled,
@@ -1,4 +1,4 @@
1
- import { q as index, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, P as PresentationEditor, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-BinyZw4F.es.js";
1
+ import { q as index, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, P as PresentationEditor, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-3dJOUw65.es.js";
2
2
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
3
3
  import { E as EventEmitter } from "./eventemitter3-CcXAdeql.es.js";
4
4
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -17251,7 +17251,7 @@ const _sfc_main = {
17251
17251
  __name: "SuperDoc",
17252
17252
  emits: ["selection-update"],
17253
17253
  setup(__props, { emit: __emit }) {
17254
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-BHcBfUWj.es.js"));
17254
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-1_KffD-j.es.js"));
17255
17255
  const superdocStore = useSuperdocStore();
17256
17256
  const commentsStore = useCommentsStore();
17257
17257
  const {
@@ -18140,7 +18140,7 @@ class SuperDoc extends EventEmitter {
18140
18140
  this.config.colors = shuffleArray(this.config.colors);
18141
18141
  this.userColorMap = /* @__PURE__ */ new Map();
18142
18142
  this.colorIndex = 0;
18143
- this.version = "1.0.0-beta.97";
18143
+ this.version = "1.0.0-beta.98";
18144
18144
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
18145
18145
  this.superdocId = config.superdocId || v4();
18146
18146
  this.colors = this.config.colors;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const superEditor_es = require("./super-editor.es-BP3PKkwh.cjs");
2
+ const superEditor_es = require("./super-editor.es-DN_dgBH0.cjs");
3
3
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
4
4
  const eventemitter3 = require("./eventemitter3-DQmQUge-.cjs");
5
5
  const provider = require("@hocuspocus/provider");
@@ -17268,7 +17268,7 @@ const _sfc_main = {
17268
17268
  __name: "SuperDoc",
17269
17269
  emits: ["selection-update"],
17270
17270
  setup(__props, { emit: __emit }) {
17271
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-YvkZg201.cjs")));
17271
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-D1Ot32kX.cjs")));
17272
17272
  const superdocStore = useSuperdocStore();
17273
17273
  const commentsStore = useCommentsStore();
17274
17274
  const {
@@ -18157,7 +18157,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
18157
18157
  this.config.colors = shuffleArray(this.config.colors);
18158
18158
  this.userColorMap = /* @__PURE__ */ new Map();
18159
18159
  this.colorIndex = 0;
18160
- this.version = "1.0.0-beta.97";
18160
+ this.version = "1.0.0-beta.98";
18161
18161
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
18162
18162
  this.superdocId = config.superdocId || uuid.v4();
18163
18163
  this.colors = this.config.colors;
@@ -1,4 +1,4 @@
1
- import { s as getDefaultExportFromCjs$2 } from "./super-editor.es-BinyZw4F.es.js";
1
+ import { s as getDefaultExportFromCjs$2 } from "./super-editor.es-3dJOUw65.es.js";
2
2
  import { V as VFile } from "./index-CvBqQJbG-CvBqQJbG.es.js";
3
3
  function bail(error) {
4
4
  if (error) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const superEditor_es = require("./super-editor.es-BP3PKkwh.cjs");
3
+ const superEditor_es = require("./super-editor.es-DN_dgBH0.cjs");
4
4
  const indexCvBqQJbG = require("./index-CvBqQJbG-Dwm0THD7.cjs");
5
5
  function bail(error) {
6
6
  if (error) {
@@ -42404,7 +42404,7 @@ const _SuperConverter = class _SuperConverter2 {
42404
42404
  static getStoredSuperdocVersion(docx) {
42405
42405
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42406
42406
  }
42407
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.97") {
42407
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.98") {
42408
42408
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42409
42409
  }
42410
42410
  /**
@@ -59622,7 +59622,7 @@ const isHeadless = (editor) => {
59622
59622
  const shouldSkipNodeView = (editor) => {
59623
59623
  return isHeadless(editor);
59624
59624
  };
59625
- const summaryVersion = "1.0.0-beta.97";
59625
+ const summaryVersion = "1.0.0-beta.98";
59626
59626
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59627
59627
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59628
59628
  function mapAttributes(attrs) {
@@ -60411,7 +60411,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60411
60411
  { default: remarkStringify },
60412
60412
  { default: remarkGfm }
60413
60413
  ] = await Promise.all([
60414
- import("./index-Pvlqsxge-vW641SZt.es.js"),
60414
+ import("./index-Dg_sTYZK-D20z8mus.es.js"),
60415
60415
  import("./index-DRCvimau-Cw339678.es.js"),
60416
60416
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
60417
60417
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -60616,7 +60616,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60616
60616
  * Process collaboration migrations
60617
60617
  */
60618
60618
  processCollaborationMigrations() {
60619
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.97");
60619
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.98");
60620
60620
  if (!this.options.ydoc) return;
60621
60621
  const metaMap = this.options.ydoc.getMap("meta");
60622
60622
  let docVersion = metaMap.get("version");
@@ -62994,14 +62994,15 @@ function extractPageSizeAndOrientation(elements) {
62994
62994
  return { pageSizePx, orientation };
62995
62995
  }
62996
62996
  function extractFallbackMargins(elements, currentHeader, currentFooter) {
62997
- if (currentHeader !== void 0 && currentFooter !== void 0) {
62998
- return { headerPx: currentHeader, footerPx: currentFooter };
62999
- }
63000
62997
  const pgMar = elements.find((el) => el?.name === "w:pgMar");
63001
62998
  const a = pgMar?.attributes || {};
63002
62999
  return {
63003
63000
  headerPx: currentHeader ?? (a["w:header"] != null ? twipsToPixels$1(a["w:header"]) : void 0),
63004
- footerPx: currentFooter ?? (a["w:footer"] != null ? twipsToPixels$1(a["w:footer"]) : void 0)
63001
+ footerPx: currentFooter ?? (a["w:footer"] != null ? twipsToPixels$1(a["w:footer"]) : void 0),
63002
+ topPx: a["w:top"] != null ? twipsToPixels$1(a["w:top"]) : void 0,
63003
+ rightPx: a["w:right"] != null ? twipsToPixels$1(a["w:right"]) : void 0,
63004
+ bottomPx: a["w:bottom"] != null ? twipsToPixels$1(a["w:bottom"]) : void 0,
63005
+ leftPx: a["w:left"] != null ? twipsToPixels$1(a["w:left"]) : void 0
63005
63006
  };
63006
63007
  }
63007
63008
  function extractHeaderFooterRefs(elements, refName) {
@@ -63062,7 +63063,10 @@ function extractSectionData(para) {
63062
63063
  const type2 = extractSectionType(sectPrElements);
63063
63064
  const { pageSizePx, orientation } = extractPageSizeAndOrientation(sectPrElements);
63064
63065
  const titlePg = sectPrElements.some((el) => el?.name === "w:titlePg");
63065
- ({ headerPx, footerPx } = extractFallbackMargins(sectPrElements, headerPx, footerPx));
63066
+ const fallbackMargins = extractFallbackMargins(sectPrElements, headerPx, footerPx);
63067
+ headerPx = fallbackMargins.headerPx;
63068
+ footerPx = fallbackMargins.footerPx;
63069
+ const { topPx, rightPx, bottomPx, leftPx } = fallbackMargins;
63066
63070
  const headerRefs = extractHeaderFooterRefs(sectPrElements, "w:headerReference");
63067
63071
  const footerRefs = extractHeaderFooterRefs(sectPrElements, "w:footerReference");
63068
63072
  const numbering = extractPageNumbering(sectPrElements);
@@ -63071,6 +63075,10 @@ function extractSectionData(para) {
63071
63075
  return {
63072
63076
  headerPx,
63073
63077
  footerPx,
63078
+ topPx,
63079
+ rightPx,
63080
+ bottomPx,
63081
+ leftPx,
63074
63082
  type: type2,
63075
63083
  pageSizePx,
63076
63084
  orientation,
@@ -63182,7 +63190,14 @@ function buildSectionRangesFromParagraphs(paragraphs, hasBodySectPr) {
63182
63190
  startParagraphIndex: currentStart,
63183
63191
  endParagraphIndex: item.index,
63184
63192
  sectPr,
63185
- margins: sectionData.headerPx != null || sectionData.footerPx != null ? { header: sectionData.headerPx ?? 0, footer: sectionData.footerPx ?? 0 } : null,
63193
+ margins: sectionData.headerPx != null || sectionData.footerPx != null ? {
63194
+ header: sectionData.headerPx ?? 0,
63195
+ footer: sectionData.footerPx ?? 0,
63196
+ top: sectionData.topPx,
63197
+ right: sectionData.rightPx,
63198
+ bottom: sectionData.bottomPx,
63199
+ left: sectionData.leftPx
63200
+ } : null,
63186
63201
  pageSize: sectionData.pageSizePx ?? null,
63187
63202
  orientation: sectionData.orientation ?? null,
63188
63203
  columns: sectionData.columnsPx ?? null,
@@ -63224,7 +63239,14 @@ function createFinalSectionFromBodySectPr(bodySectPr, currentStart, totalParagra
63224
63239
  startParagraphIndex: currentStart,
63225
63240
  endParagraphIndex: totalParagraphs - 1,
63226
63241
  sectPr: bodySectPr,
63227
- margins: bodySectionData.headerPx != null || bodySectionData.footerPx != null ? { header: bodySectionData.headerPx ?? 0, footer: bodySectionData.footerPx ?? 0 } : null,
63242
+ margins: bodySectionData.headerPx != null || bodySectionData.footerPx != null ? {
63243
+ header: bodySectionData.headerPx ?? 0,
63244
+ footer: bodySectionData.footerPx ?? 0,
63245
+ top: bodySectionData.topPx,
63246
+ right: bodySectionData.rightPx,
63247
+ bottom: bodySectionData.bottomPx,
63248
+ left: bodySectionData.leftPx
63249
+ } : null,
63228
63250
  pageSize: bodySectionData.pageSizePx ?? null,
63229
63251
  orientation: bodySectionData.orientation ?? null,
63230
63252
  columns: bodySectionData.columnsPx ?? null,
@@ -69503,41 +69525,6 @@ const parseTableCell = (args) => {
69503
69525
  }
69504
69526
  }
69505
69527
  }
69506
- try {
69507
- const blockSummaries = blocks.map((b2) => {
69508
- if (b2.kind === "paragraph") {
69509
- const runs = b2.runs ?? [];
69510
- const attrs = b2.attrs ?? {};
69511
- return {
69512
- kind: "paragraph",
69513
- runKinds: runs.map((r2) => r2.kind ?? "text"),
69514
- runCount: runs.length,
69515
- runPreview: runs.map((r2) => {
69516
- const kind = r2.kind ?? "text";
69517
- if (kind === "image") {
69518
- const img = r2;
69519
- return { kind, src: img.src, width: img.width, height: img.height };
69520
- }
69521
- return { kind };
69522
- }),
69523
- hasNumbering: Boolean(attrs.numberingProperties),
69524
- markerText: attrs.wordLayout?.marker?.markerText
69525
- };
69526
- }
69527
- return { kind: b2.kind };
69528
- });
69529
- console.log(
69530
- "[tableNodeToBlock.parseTableCell] cell contents",
69531
- JSON.stringify({
69532
- cellIndex,
69533
- rowIndex,
69534
- cellIdPreview: `cell-${rowIndex}-${cellIndex}`,
69535
- childTypes: cellNode.content.map((c2) => c2?.type),
69536
- blocks: blockSummaries
69537
- })
69538
- );
69539
- } catch {
69540
- }
69541
69528
  if (blocks.length === 0) {
69542
69529
  return null;
69543
69530
  }
@@ -73402,20 +73389,6 @@ const renderTableCell = (deps) => {
73402
73389
  }
73403
73390
  const cellBlocks = cell?.blocks ?? (cell?.paragraph ? [cell.paragraph] : []);
73404
73391
  const blockMeasures = cellMeasure?.blocks ?? (cellMeasure?.paragraph ? [cellMeasure.paragraph] : []);
73405
- try {
73406
- console.log(
73407
- "[DomPainter.renderTableCell] cell render input",
73408
- JSON.stringify({
73409
- cellId: cell?.id,
73410
- blockKinds: cellBlocks.map((b2) => b2.kind),
73411
- measureKinds: blockMeasures.map((m2) => m2.kind),
73412
- width: cellMeasure?.width,
73413
- height: cellMeasure?.height,
73414
- rowHeight
73415
- })
73416
- );
73417
- } catch {
73418
- }
73419
73392
  if (cellBlocks.length > 0 && blockMeasures.length > 0) {
73420
73393
  const content = doc2.createElement("div");
73421
73394
  content.style.position = "relative";
@@ -73448,15 +73421,6 @@ const renderTableCell = (deps) => {
73448
73421
  const blockMeasure = blockMeasures[i];
73449
73422
  const block = cellBlocks[i];
73450
73423
  if (blockMeasure.kind === "image" && block?.kind === "image") {
73451
- console.log(
73452
- "[DomPainter.renderTableCell] rendering image block in cell",
73453
- JSON.stringify({
73454
- cellId: cell?.id,
73455
- blockId: block.id,
73456
- width: blockMeasure.width,
73457
- height: blockMeasure.height
73458
- })
73459
- );
73460
73424
  const imageWrapper = doc2.createElement("div");
73461
73425
  imageWrapper.style.position = "relative";
73462
73426
  imageWrapper.style.width = `${blockMeasure.width}px`;
@@ -73479,16 +73443,6 @@ const renderTableCell = (deps) => {
73479
73443
  continue;
73480
73444
  }
73481
73445
  if (blockMeasure.kind === "drawing" && block?.kind === "drawing") {
73482
- console.log(
73483
- "[DomPainter.renderTableCell] rendering drawing block in cell",
73484
- JSON.stringify({
73485
- cellId: cell?.id,
73486
- blockId: block.id,
73487
- drawingKind: block.drawingKind,
73488
- width: blockMeasure.width,
73489
- height: blockMeasure.height
73490
- })
73491
- );
73492
73446
  const drawingWrapper = doc2.createElement("div");
73493
73447
  drawingWrapper.style.position = "relative";
73494
73448
  drawingWrapper.style.width = `${blockMeasure.width}px`;
@@ -73531,20 +73485,6 @@ const renderTableCell = (deps) => {
73531
73485
  continue;
73532
73486
  }
73533
73487
  if (blockMeasure.kind === "paragraph" && block?.kind === "paragraph") {
73534
- try {
73535
- const runKinds = (block.runs ?? []).map((r2) => r2.kind ?? "text");
73536
- const imageRuns = (block.runs ?? []).filter((r2) => r2.kind === "image").map((r2) => ({ src: r2.src }));
73537
- console.log(
73538
- "[DomPainter.renderTableCell] rendering paragraph block in cell",
73539
- JSON.stringify({
73540
- cellId: cell?.id,
73541
- blockId: block.id,
73542
- runKinds,
73543
- imageRuns
73544
- })
73545
- );
73546
- } catch {
73547
- }
73548
73488
  const paragraphMeasure = blockMeasure;
73549
73489
  const lines = paragraphMeasure.lines;
73550
73490
  const blockLineCount = lines?.length || 0;
@@ -75359,7 +75299,9 @@ const _DomPainter = class _DomPainter2 {
75359
75299
  const isTocEntry = block.attrs?.isTocEntry;
75360
75300
  const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
75361
75301
  const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
75362
- const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
75302
+ const paraIndentForOverflow = block.attrs?.indent;
75303
+ const hasNegativeIndent = (paraIndentForOverflow?.left ?? 0) < 0 || (paraIndentForOverflow?.right ?? 0) < 0;
75304
+ const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer || hasNegativeIndent ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
75363
75305
  applyStyles$2(fragmentEl, styles);
75364
75306
  this.applyFragmentFrame(fragmentEl, fragment, context.section);
75365
75307
  if (isTocEntry) {
@@ -75388,6 +75330,8 @@ const _DomPainter = class _DomPainter2 {
75388
75330
  }
75389
75331
  if (fragmentEl.style.paddingLeft) fragmentEl.style.removeProperty("padding-left");
75390
75332
  if (fragmentEl.style.paddingRight) fragmentEl.style.removeProperty("padding-right");
75333
+ if (fragmentEl.style.marginLeft) fragmentEl.style.removeProperty("margin-left");
75334
+ if (fragmentEl.style.marginRight) fragmentEl.style.removeProperty("margin-right");
75391
75335
  if (fragmentEl.style.textIndent) fragmentEl.style.removeProperty("text-indent");
75392
75336
  const paraIndent = block.attrs?.indent;
75393
75337
  const paraIndentLeft = paraIndent?.left ?? 0;
@@ -75416,16 +75360,22 @@ const _DomPainter = class _DomPainter2 {
75416
75360
  if (!isListFirstLine) {
75417
75361
  if (hasExplicitSegmentPositioning) {
75418
75362
  if (isFirstLine && firstLineOffset !== 0) {
75419
- const adjustedPadding = paraIndentLeft + firstLineOffset;
75420
- lineEl.style.paddingLeft = `${adjustedPadding}px`;
75363
+ const effectiveLeftIndent = paraIndentLeft < 0 ? 0 : paraIndentLeft;
75364
+ const adjustedPadding = effectiveLeftIndent + firstLineOffset;
75365
+ if (adjustedPadding > 0) {
75366
+ lineEl.style.paddingLeft = `${adjustedPadding}px`;
75367
+ }
75421
75368
  }
75422
- } else if (paraIndentLeft) {
75369
+ } else if (paraIndentLeft && paraIndentLeft > 0) {
75423
75370
  lineEl.style.paddingLeft = `${paraIndentLeft}px`;
75371
+ } else if (!isFirstLine && paraIndent?.hanging && paraIndent.hanging > 0) {
75372
+ lineEl.style.paddingLeft = `${paraIndent.hanging}px`;
75424
75373
  }
75425
75374
  }
75426
- if (paraIndentRight) {
75375
+ if (paraIndentRight && paraIndentRight > 0) {
75427
75376
  lineEl.style.paddingRight = `${paraIndentRight}px`;
75428
75377
  }
75378
+ const hasNegativeLeftIndent = paraIndentLeft != null && paraIndentLeft < 0;
75429
75379
  if (!fragment.continuesFromPrev && index2 === 0 && firstLineOffset && !isListFirstLine) {
75430
75380
  if (!hasExplicitSegmentPositioning) {
75431
75381
  lineEl.style.textIndent = `${firstLineOffset}px`;
@@ -77710,15 +77660,18 @@ const applyParagraphBlockStyles = (element, attrs) => {
77710
77660
  }
77711
77661
  const indent = attrs.indent;
77712
77662
  if (indent) {
77713
- if (indent.left) {
77663
+ if (indent.left && indent.left > 0) {
77714
77664
  element.style.paddingLeft = `${indent.left}px`;
77715
77665
  }
77716
- if (indent.right) {
77666
+ if (indent.right && indent.right > 0) {
77717
77667
  element.style.paddingRight = `${indent.right}px`;
77718
77668
  }
77719
- const textIndent = (indent.firstLine ?? 0) - (indent.hanging ?? 0);
77720
- if (textIndent) {
77721
- element.style.textIndent = `${textIndent}px`;
77669
+ const hasNegativeLeftIndent = indent.left != null && indent.left < 0;
77670
+ if (!hasNegativeLeftIndent) {
77671
+ const textIndent = (indent.firstLine ?? 0) - (indent.hanging ?? 0);
77672
+ if (textIndent) {
77673
+ element.style.textIndent = `${textIndent}px`;
77674
+ }
77722
77675
  }
77723
77676
  }
77724
77677
  applyParagraphBorderStyles(element, attrs.borders);
@@ -79080,20 +79033,6 @@ const asSafeNumber = (value) => {
79080
79033
  }
79081
79034
  return value;
79082
79035
  };
79083
- function calculateFirstLineIndent(block, measure) {
79084
- const wordLayout = block.attrs?.wordLayout;
79085
- if (!wordLayout?.firstLineIndentMode) {
79086
- return 0;
79087
- }
79088
- if (!wordLayout.marker || !measure.marker) {
79089
- return 0;
79090
- }
79091
- const markerWidthRaw = measure.marker.markerWidth ?? wordLayout.marker.markerBoxWidthPx ?? 0;
79092
- const markerWidth = Number.isFinite(markerWidthRaw) && markerWidthRaw >= 0 ? markerWidthRaw : 0;
79093
- const gutterWidthRaw = measure.marker.gutterWidth ?? 0;
79094
- const gutterWidth = Number.isFinite(gutterWidthRaw) && gutterWidthRaw >= 0 ? gutterWidthRaw : 0;
79095
- return markerWidth + gutterWidth;
79096
- }
79097
79036
  function layoutParagraphBlock(ctx2, anchors) {
79098
79037
  const { block, measure, columnWidth, ensurePage, advanceColumn, columnX, floatManager } = ctx2;
79099
79038
  const remeasureParagraph2 = ctx2.remeasureParagraph;
@@ -79215,10 +79154,25 @@ function layoutParagraphBlock(ctx2, anchors) {
79215
79154
  }
79216
79155
  let lines = normalizeLines(measure);
79217
79156
  const measurementWidth = lines[0]?.maxWidth;
79157
+ const paraIndent = block.attrs?.indent;
79158
+ const indentLeft = typeof paraIndent?.left === "number" && Number.isFinite(paraIndent.left) ? paraIndent.left : 0;
79159
+ const indentRight = typeof paraIndent?.right === "number" && Number.isFinite(paraIndent.right) ? paraIndent.right : 0;
79160
+ const negativeLeftIndent = indentLeft < 0 ? indentLeft : 0;
79161
+ const negativeRightIndent = indentRight < 0 ? indentRight : 0;
79162
+ const remeasureWidth = Math.max(1, columnWidth - indentLeft - indentRight);
79218
79163
  let didRemeasureForColumnWidth = false;
79219
- if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > columnWidth) {
79220
- const firstLineIndent = calculateFirstLineIndent(block, measure);
79221
- const newMeasure = remeasureParagraph2(block, columnWidth, firstLineIndent);
79164
+ if (typeof remeasureParagraph2 === "function" && typeof measurementWidth === "number" && measurementWidth > remeasureWidth) {
79165
+ let firstLineIndent = 0;
79166
+ const wordLayout = block.attrs?.wordLayout;
79167
+ if (wordLayout?.marker && measure.marker) {
79168
+ const markerJustification = wordLayout.marker.justification ?? "left";
79169
+ if (markerJustification === "left") {
79170
+ const markerWidth = measure.marker.markerWidth ?? 0;
79171
+ const gutterWidth = measure.marker.gutterWidth ?? wordLayout.marker.gutterWidthPx ?? 0;
79172
+ firstLineIndent = markerWidth + gutterWidth;
79173
+ }
79174
+ }
79175
+ const newMeasure = remeasureParagraph2(block, remeasureWidth, firstLineIndent);
79222
79176
  lines = normalizeLines(newMeasure);
79223
79177
  didRemeasureForColumnWidth = true;
79224
79178
  }
@@ -79297,9 +79251,19 @@ function layoutParagraphBlock(ctx2, anchors) {
79297
79251
  }
79298
79252
  tempY += lineHeight2;
79299
79253
  }
79300
- if (narrowestWidth < columnWidth) {
79301
- const firstLineIndent = calculateFirstLineIndent(block, measure);
79302
- const newMeasure = remeasureParagraph2(block, narrowestWidth, firstLineIndent);
79254
+ const narrowestRemeasureWidth = Math.max(1, narrowestWidth - indentLeft - indentRight);
79255
+ if (narrowestRemeasureWidth < remeasureWidth) {
79256
+ let firstLineIndent = 0;
79257
+ const wordLayout = block.attrs?.wordLayout;
79258
+ if (wordLayout?.marker && measure.marker) {
79259
+ const markerJustification = wordLayout.marker.justification ?? "left";
79260
+ if (markerJustification === "left") {
79261
+ const markerWidth = measure.marker.markerWidth ?? 0;
79262
+ const gutterWidth = measure.marker.gutterWidth ?? wordLayout.marker.gutterWidthPx ?? 0;
79263
+ firstLineIndent = markerWidth + gutterWidth;
79264
+ }
79265
+ }
79266
+ const newMeasure = remeasureParagraph2(block, narrowestRemeasureWidth, firstLineIndent);
79303
79267
  lines = normalizeLines(newMeasure);
79304
79268
  didRemeasureForFloats = true;
79305
79269
  }
@@ -79353,14 +79317,16 @@ function layoutParagraphBlock(ctx2, anchors) {
79353
79317
  }
79354
79318
  const slice2 = sliceLines(lines, fromLine, state2.contentBottom - state2.cursorY);
79355
79319
  const fragmentHeight = slice2.height;
79320
+ const adjustedX = columnX(state2.columnIndex) + offsetX + negativeLeftIndent;
79321
+ const adjustedWidth = effectiveColumnWidth - negativeLeftIndent - negativeRightIndent;
79356
79322
  const fragment = {
79357
79323
  kind: "para",
79358
79324
  blockId: block.id,
79359
79325
  fromLine,
79360
79326
  toLine: slice2.toLine,
79361
- x: columnX(state2.columnIndex) + offsetX,
79327
+ x: adjustedX,
79362
79328
  y: state2.cursorY,
79363
- width: effectiveColumnWidth,
79329
+ width: adjustedWidth,
79364
79330
  ...computeFragmentPmRange(block, lines, fromLine, slice2.toLine)
79365
79331
  };
79366
79332
  if (didRemeasureForColumnWidth) {
@@ -83068,9 +83034,15 @@ async function incrementalLayout(previousBlocks, _previousLayout, nextBlocks, op
83068
83034
  }
83069
83035
  const DEFAULT_PAGE_SIZE$1 = { w: 612, h: 792 };
83070
83036
  const DEFAULT_MARGINS$1 = { top: 72, right: 72, bottom: 72, left: 72 };
83037
+ const normalizeMargin = (value, fallback) => Number.isFinite(value) ? value : fallback;
83071
83038
  function resolveMeasurementConstraints(options) {
83072
83039
  const pageSize = options.pageSize ?? DEFAULT_PAGE_SIZE$1;
83073
- const margins = options.margins ?? DEFAULT_MARGINS$1;
83040
+ const margins = {
83041
+ top: normalizeMargin(options.margins?.top, DEFAULT_MARGINS$1.top),
83042
+ right: normalizeMargin(options.margins?.right, DEFAULT_MARGINS$1.right),
83043
+ bottom: normalizeMargin(options.margins?.bottom, DEFAULT_MARGINS$1.bottom),
83044
+ left: normalizeMargin(options.margins?.left, DEFAULT_MARGINS$1.left)
83045
+ };
83074
83046
  const contentWidth = pageSize.w - (margins.left + margins.right);
83075
83047
  const contentHeight = pageSize.h - (margins.top + margins.bottom);
83076
83048
  const columns = options.columns;
@@ -84608,8 +84580,8 @@ async function measureParagraphBlock(block, maxWidth) {
84608
84580
  const lines = [];
84609
84581
  const indent = block.attrs?.indent;
84610
84582
  const spacing = block.attrs?.spacing;
84611
- const indentLeft = sanitizePositive(indent?.left);
84612
- const indentRight = sanitizePositive(indent?.right);
84583
+ const indentLeft = sanitizeIndent(indent?.left);
84584
+ const indentRight = sanitizeIndent(indent?.right);
84613
84585
  const firstLine = indent?.firstLine ?? 0;
84614
84586
  const hanging = indent?.hanging ?? 0;
84615
84587
  const isWordLayoutList = Boolean(wordLayout?.marker);
@@ -84618,10 +84590,10 @@ async function measureParagraphBlock(block, maxWidth) {
84618
84590
  const clampedFirstLineOffset = Math.max(0, rawFirstLineOffset);
84619
84591
  const firstLineOffset = isWordLayoutList ? 0 : clampedFirstLineOffset;
84620
84592
  const contentWidth = Math.max(1, maxWidth - indentLeft - indentRight);
84593
+ const bodyContentWidth = contentWidth;
84621
84594
  let initialAvailableWidth;
84622
84595
  const textStartPx = wordLayout?.textStartPx;
84623
- const treatAsHanging = isWordLayoutList && indentLeft === 0 && hanging === 0 && typeof textStartPx === "number";
84624
- if (typeof textStartPx === "number" && textStartPx > indentLeft && !treatAsHanging) {
84596
+ if (typeof textStartPx === "number" && textStartPx > indentLeft) {
84625
84597
  initialAvailableWidth = Math.max(1, maxWidth - textStartPx - indentRight);
84626
84598
  } else {
84627
84599
  initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset);
@@ -84668,21 +84640,6 @@ async function measureParagraphBlock(block, maxWidth) {
84668
84640
  totalHeight: metrics.lineHeight
84669
84641
  };
84670
84642
  }
84671
- const isListLike = Boolean(block.attrs?.numId || wordLayout?.marker);
84672
- if (isListLike) {
84673
- console.log(
84674
- "[measureParagraph][list]",
84675
- JSON.stringify({
84676
- blockId: block.id,
84677
- maxWidth,
84678
- indentLeft,
84679
- indentRight,
84680
- textStartPx: textStartPx ?? null,
84681
- firstLineOffset: firstLineOffset ?? null,
84682
- initialAvailableWidth
84683
- })
84684
- );
84685
- }
84686
84643
  let currentLine = null;
84687
84644
  const getEffectiveWidth = (baseWidth) => {
84688
84645
  if (dropCapMeasure && lines.length < dropCapMeasure.lines && dropCapMeasure.mode === "drop") {
@@ -84828,7 +84785,7 @@ async function measureParagraphBlock(block, maxWidth) {
84828
84785
  lines.push(emptyLine);
84829
84786
  }
84830
84787
  const hadPreviousLine = lines.length > 0;
84831
- const nextLineMaxWidth = hadPreviousLine ? getEffectiveWidth(contentWidth) : getEffectiveWidth(initialAvailableWidth);
84788
+ const nextLineMaxWidth = hadPreviousLine ? getEffectiveWidth(bodyContentWidth) : getEffectiveWidth(initialAvailableWidth);
84832
84789
  currentLine = {
84833
84790
  fromRun: runIndex,
84834
84791
  fromChar: 0,
@@ -84939,7 +84896,7 @@ async function measureParagraphBlock(block, maxWidth) {
84939
84896
  toChar: 1,
84940
84897
  width: imageWidth,
84941
84898
  maxFontSize: imageHeight,
84942
- maxWidth: getEffectiveWidth(contentWidth),
84899
+ maxWidth: getEffectiveWidth(bodyContentWidth),
84943
84900
  spaceCount: 0,
84944
84901
  segments: [
84945
84902
  {
@@ -85028,7 +84985,7 @@ async function measureParagraphBlock(block, maxWidth) {
85028
84985
  toChar: 1,
85029
84986
  width: annotationWidth,
85030
84987
  maxFontSize: annotationHeight,
85031
- maxWidth: getEffectiveWidth(contentWidth),
84988
+ maxWidth: getEffectiveWidth(bodyContentWidth),
85032
84989
  spaceCount: 0,
85033
84990
  segments: [
85034
84991
  {
@@ -85110,7 +85067,7 @@ async function measureParagraphBlock(block, maxWidth) {
85110
85067
  width: spacesWidth,
85111
85068
  maxFontSize: run2.fontSize,
85112
85069
  maxFontInfo: getFontInfoFromRun(run2),
85113
- maxWidth: getEffectiveWidth(contentWidth),
85070
+ maxWidth: getEffectiveWidth(bodyContentWidth),
85114
85071
  segments: [{ runIndex, fromChar: spacesStartChar, toChar: spacesEndChar, width: spacesWidth }],
85115
85072
  spaceCount: spacesLength
85116
85073
  };
@@ -85173,7 +85130,7 @@ async function measureParagraphBlock(block, maxWidth) {
85173
85130
  width: singleSpaceWidth,
85174
85131
  maxFontSize: run2.fontSize,
85175
85132
  maxFontInfo: getFontInfoFromRun(run2),
85176
- maxWidth: getEffectiveWidth(contentWidth),
85133
+ maxWidth: getEffectiveWidth(bodyContentWidth),
85177
85134
  segments: [{ runIndex, fromChar: spaceStartChar, toChar: spaceEndChar, width: singleSpaceWidth }],
85178
85135
  spaceCount: 1
85179
85136
  };
@@ -85366,7 +85323,7 @@ async function measureParagraphBlock(block, maxWidth) {
85366
85323
  width: wordOnlyWidth,
85367
85324
  maxFontSize: run2.fontSize,
85368
85325
  maxFontInfo: getFontInfoFromRun(run2),
85369
- maxWidth: getEffectiveWidth(contentWidth),
85326
+ maxWidth: getEffectiveWidth(bodyContentWidth),
85370
85327
  segments: [{ runIndex, fromChar: wordStartChar, toChar: wordEndNoSpace, width: wordOnlyWidth }],
85371
85328
  spaceCount: 0
85372
85329
  };
@@ -85931,6 +85888,7 @@ const resolveLineHeight = (spacing, baseLineHeight) => {
85931
85888
  return Math.max(baseLineHeight, raw);
85932
85889
  };
85933
85890
  const sanitizePositive = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
85891
+ const sanitizeIndent = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
85934
85892
  const sanitizeDecimalSeparator = (value) => {
85935
85893
  if (value === ",") return ",";
85936
85894
  return DEFAULT_DECIMAL_SEPARATOR;
@@ -90479,6 +90437,10 @@ resolveLayoutOptions_fn = function(blocks, sectionMetadata) {
90479
90437
  const pageSize = firstSection?.pageSize ?? defaults.pageSize;
90480
90438
  const margins = {
90481
90439
  ...defaults.margins,
90440
+ ...firstSection?.margins?.top != null ? { top: firstSection.margins.top } : {},
90441
+ ...firstSection?.margins?.right != null ? { right: firstSection.margins.right } : {},
90442
+ ...firstSection?.margins?.bottom != null ? { bottom: firstSection.margins.bottom } : {},
90443
+ ...firstSection?.margins?.left != null ? { left: firstSection.margins.left } : {},
90482
90444
  ...firstSection?.margins?.header != null ? { header: firstSection.margins.header } : {},
90483
90445
  ...firstSection?.margins?.footer != null ? { footer: firstSection.margins.footer } : {}
90484
90446
  };