oasis-editor 0.0.29 → 0.0.31

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.
@@ -2442,7 +2442,7 @@ function OasisEditorAppLazy(props = {}) {
2442
2442
  onCleanup(() => {
2443
2443
  cancelled = true;
2444
2444
  });
2445
- import("./OasisEditorApp-D0fgzHt5.js").then((m) => {
2445
+ import("./OasisEditorApp-CeDQ_a8-.js").then((m) => {
2446
2446
  cancelled = true;
2447
2447
  setProgress(1);
2448
2448
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -3486,6 +3486,148 @@ function findParagraphTableLocation(document2, paragraphId, activeSectionIndex =
3486
3486
  }
3487
3487
  return { ...entry.tableLocation, zone: entry.location.zone };
3488
3488
  }
3489
+ const BULLET_GLYPHS = ["•", "○", "▪", "•", "○", "▪"];
3490
+ const ORDERED_DEFAULT_FORMATS = [
3491
+ "decimal",
3492
+ "lowerLetter",
3493
+ "lowerRoman",
3494
+ "decimal",
3495
+ "lowerLetter",
3496
+ "lowerRoman"
3497
+ ];
3498
+ const PUA_BULLET_MAP = {
3499
+ 61623: "•",
3500
+ 61548: "·",
3501
+ 61607: "▪",
3502
+ 61656: "➢",
3503
+ 61559: "✓",
3504
+ 61692: "✓",
3505
+ 61671: "⚡",
3506
+ 61472: " "
3507
+ };
3508
+ function toAlpha(value) {
3509
+ if (value <= 0) return String(value);
3510
+ let remaining = value;
3511
+ let output = "";
3512
+ while (remaining > 0) {
3513
+ output = String.fromCharCode(65 + (remaining - 1) % 26) + output;
3514
+ remaining = Math.floor((remaining - 1) / 26);
3515
+ }
3516
+ return output;
3517
+ }
3518
+ function toRoman$1(value) {
3519
+ if (value <= 0 || value >= 4e3) return String(value);
3520
+ const numerals = [
3521
+ [1e3, "M"],
3522
+ [900, "CM"],
3523
+ [500, "D"],
3524
+ [400, "CD"],
3525
+ [100, "C"],
3526
+ [90, "XC"],
3527
+ [50, "L"],
3528
+ [40, "XL"],
3529
+ [10, "X"],
3530
+ [9, "IX"],
3531
+ [5, "V"],
3532
+ [4, "IV"],
3533
+ [1, "I"]
3534
+ ];
3535
+ let remaining = value;
3536
+ let output = "";
3537
+ for (const [amount, text] of numerals) {
3538
+ while (remaining >= amount) {
3539
+ output += text;
3540
+ remaining -= amount;
3541
+ }
3542
+ }
3543
+ return output;
3544
+ }
3545
+ function formatOrdinal(value, format) {
3546
+ switch (format) {
3547
+ case "lowerLetter":
3548
+ return toAlpha(value).toLowerCase();
3549
+ case "upperLetter":
3550
+ return toAlpha(value).toUpperCase();
3551
+ case "lowerRoman":
3552
+ return toRoman$1(value).toLowerCase();
3553
+ case "upperRoman":
3554
+ return toRoman$1(value).toUpperCase();
3555
+ default:
3556
+ return String(value);
3557
+ }
3558
+ }
3559
+ function normalizeBulletGlyph(glyph) {
3560
+ const code2 = glyph.codePointAt(0);
3561
+ return code2 !== void 0 && code2 >= 57344 && code2 <= 63743 ? PUA_BULLET_MAP[code2] ?? "•" : glyph;
3562
+ }
3563
+ function collectNumberingParagraphs(document2) {
3564
+ const result = [];
3565
+ const collectTextBoxes = (paragraph) => {
3566
+ for (const run of paragraph.runs) {
3567
+ if (run.textBox) collectBlocks2(run.textBox.blocks);
3568
+ }
3569
+ };
3570
+ const collectBlocks2 = (blocks) => {
3571
+ for (const block of blocks) {
3572
+ if (block.type === "paragraph") {
3573
+ result.push(block);
3574
+ collectTextBoxes(block);
3575
+ } else {
3576
+ for (const row of block.rows) {
3577
+ for (const cell of row.cells) collectBlocks2(cell.blocks);
3578
+ }
3579
+ }
3580
+ }
3581
+ };
3582
+ for (const paragraph of getDocumentParagraphs(document2)) {
3583
+ result.push(paragraph);
3584
+ collectTextBoxes(paragraph);
3585
+ }
3586
+ return result;
3587
+ }
3588
+ function buildListLabels(document2) {
3589
+ const labels = /* @__PURE__ */ new Map();
3590
+ const states = /* @__PURE__ */ new Map();
3591
+ for (const paragraph of collectNumberingParagraphs(document2)) {
3592
+ const list = paragraph.list;
3593
+ if (!list) continue;
3594
+ const level = Math.max(0, list.level ?? 0);
3595
+ if (list.kind === "bullet") {
3596
+ labels.set(
3597
+ paragraph.id,
3598
+ list.bulletGlyph ? normalizeBulletGlyph(list.bulletGlyph) : BULLET_GLYPHS[level % BULLET_GLYPHS.length]
3599
+ );
3600
+ continue;
3601
+ }
3602
+ const key = list.instanceId ? `instance:${list.instanceId}` : "legacy";
3603
+ const state = states.get(key) ?? { counters: [], formats: [] };
3604
+ states.set(key, state);
3605
+ while (state.counters.length <= level) state.counters.push(0);
3606
+ state.counters.length = level + 1;
3607
+ if (list.levelFormats) {
3608
+ list.levelFormats.forEach((format, index) => {
3609
+ state.formats[index] = format;
3610
+ });
3611
+ }
3612
+ state.formats[level] = list.format ?? ORDERED_DEFAULT_FORMATS[level % ORDERED_DEFAULT_FORMATS.length];
3613
+ state.counters[level] = typeof list.startAt === "number" ? list.startAt : state.counters[level] === 0 ? 1 : state.counters[level] + 1;
3614
+ const pattern = list.levelText ?? `%${level + 1}.`;
3615
+ labels.set(
3616
+ paragraph.id,
3617
+ pattern.replace(/%([1-9])/g, (token, rawLevel) => {
3618
+ const referencedLevel = Number(rawLevel) - 1;
3619
+ const value = state.counters[referencedLevel];
3620
+ if (value === void 0) return token;
3621
+ const format = list.legal ? "decimal" : state.formats[referencedLevel] ?? "decimal";
3622
+ return formatOrdinal(value, format);
3623
+ })
3624
+ );
3625
+ }
3626
+ return labels;
3627
+ }
3628
+ function resolveListLabel(paragraph, labels) {
3629
+ return labels.get(paragraph.id) ?? "";
3630
+ }
3489
3631
  function getActiveSectionIndex(state) {
3490
3632
  return state.activeSectionIndex ?? 0;
3491
3633
  }
@@ -11078,6 +11220,19 @@ function getListLabelInset(paragraph, styles) {
11078
11220
  const baseInset = (paragraphStyle.indentLeft ?? 0) + resolveListGutterPx(paragraph, paragraphStyle);
11079
11221
  return baseInset - Math.abs(paragraphStyle.indentHanging ?? 0);
11080
11222
  }
11223
+ function getAlignedListLabelInset(paragraph, styles, textStart, labelWidth) {
11224
+ var _a;
11225
+ const start = Math.max(0, getListLabelInset(paragraph, styles));
11226
+ const width = Math.max(0, textStart - start);
11227
+ switch ((_a = paragraph.list) == null ? void 0 : _a.alignment) {
11228
+ case "center":
11229
+ return start + Math.max(0, (width - labelWidth) / 2);
11230
+ case "right":
11231
+ return start + Math.max(0, width - labelWidth);
11232
+ default:
11233
+ return start;
11234
+ }
11235
+ }
11081
11236
  function getAvailableWidth(paragraph, styles, contentWidth, isFirstLine) {
11082
11237
  const paragraphStyle = resolveEffectiveParagraphStyle(
11083
11238
  paragraph.style,
@@ -14106,7 +14261,7 @@ const ROMAN_NUMERALS = [
14106
14261
  [4, "iv"],
14107
14262
  [1, "i"]
14108
14263
  ];
14109
- function toRoman$1(value) {
14264
+ function toRoman(value) {
14110
14265
  if (value <= 0) return String(value);
14111
14266
  let remaining = value;
14112
14267
  let result = "";
@@ -14133,9 +14288,9 @@ const SYMBOL_MARKS = ["*", "†", "‡", "§", "¶", "#"];
14133
14288
  function getFootnoteDisplayMarker(oneBasedIndex, format = "decimal") {
14134
14289
  switch (format) {
14135
14290
  case "lowerRoman":
14136
- return toRoman$1(oneBasedIndex);
14291
+ return toRoman(oneBasedIndex);
14137
14292
  case "upperRoman":
14138
- return toRoman$1(oneBasedIndex).toUpperCase();
14293
+ return toRoman(oneBasedIndex).toUpperCase();
14139
14294
  case "lowerLetter":
14140
14295
  return toLetters(oneBasedIndex);
14141
14296
  case "upperLetter":
@@ -14581,125 +14736,14 @@ function getCachedCanvasImage(src, onUpdate) {
14581
14736
  imageCache.set(src, img);
14582
14737
  return img;
14583
14738
  }
14584
- const listOrdinalsCache = /* @__PURE__ */ new WeakMap();
14585
- function getListOrdinals(document2) {
14586
- const cached = listOrdinalsCache.get(document2);
14587
- if (cached) return cached;
14588
- const result = /* @__PURE__ */ new Map();
14589
- const paragraphs = getDocumentParagraphs(document2);
14590
- const counters = /* @__PURE__ */ new Map();
14591
- for (const paragraph of paragraphs) {
14592
- const list = paragraph.list;
14593
- if (!list || list.kind !== "ordered") {
14594
- continue;
14595
- }
14596
- const level = list.level ?? 0;
14597
- const prev = counters.get(level);
14598
- const next = prev !== void 0 ? prev + 1 : list.startAt ?? 1;
14599
- counters.set(level, next);
14600
- result.set(paragraph.id, next);
14601
- }
14602
- listOrdinalsCache.set(document2, result);
14603
- return result;
14604
- }
14605
- function formatOrdinal(value, format) {
14606
- switch (format) {
14607
- case "lowerLetter":
14608
- return toAlpha(value).toLowerCase();
14609
- case "upperLetter":
14610
- return toAlpha(value).toUpperCase();
14611
- case "lowerRoman":
14612
- return toRoman(value).toLowerCase();
14613
- case "upperRoman":
14614
- return toRoman(value).toUpperCase();
14615
- case "decimal":
14616
- default:
14617
- return String(value);
14618
- }
14619
- }
14620
- function toAlpha(value) {
14621
- if (value <= 0) return String(value);
14622
- let n = value;
14623
- let out = "";
14624
- while (n > 0) {
14625
- const rem = (n - 1) % 26;
14626
- out = String.fromCharCode(65 + rem) + out;
14627
- n = Math.floor((n - 1) / 26);
14628
- }
14629
- return out;
14630
- }
14631
- function toRoman(value) {
14632
- if (value <= 0 || value >= 4e3) return String(value);
14633
- const map = [
14634
- [1e3, "M"],
14635
- [900, "CM"],
14636
- [500, "D"],
14637
- [400, "CD"],
14638
- [100, "C"],
14639
- [90, "XC"],
14640
- [50, "L"],
14641
- [40, "XL"],
14642
- [10, "X"],
14643
- [9, "IX"],
14644
- [5, "V"],
14645
- [4, "IV"],
14646
- [1, "I"]
14647
- ];
14648
- let n = value;
14649
- let out = "";
14650
- for (const [v, s] of map) {
14651
- while (n >= v) {
14652
- out += s;
14653
- n -= v;
14654
- }
14655
- }
14656
- return out;
14657
- }
14658
- const PUA_BULLET_MAP = {
14659
- 61623: "•",
14660
- // Symbol: filled circle bullet
14661
- 61548: "·",
14662
- // Wingdings: medium bullet
14663
- 61607: "▪",
14664
- // Wingdings 2: black small square
14665
- 61656: "➢",
14666
- // Wingdings: arrowhead
14667
- 61559: "✓",
14668
- // Wingdings: check mark
14669
- 61692: "✓",
14670
- // Wingdings: check mark (alt)
14671
- 61671: "⚡",
14672
- // Wingdings: lightning
14673
- 61472: " "
14674
- // Symbol/Wingdings: space
14675
- };
14676
- function normalizeBulletGlyph(glyph) {
14677
- const code2 = glyph.codePointAt(0);
14678
- if (code2 !== void 0 && code2 >= 57344 && code2 <= 63743) {
14679
- return PUA_BULLET_MAP[code2] ?? "•";
14680
- }
14681
- return glyph;
14682
- }
14683
- const BULLET_GLYPHS = ["•", "○", "▪", "•", "○", "▪"];
14684
- const ORDERED_DEFAULT_FORMATS = [
14685
- "decimal",
14686
- "lowerLetter",
14687
- "lowerRoman",
14688
- "decimal",
14689
- "lowerLetter",
14690
- "lowerRoman"
14691
- ];
14739
+ const listLabelsCache = /* @__PURE__ */ new WeakMap();
14692
14740
  function resolveListPrefix(paragraph, document2) {
14693
- if (!paragraph.list) return "";
14694
- const level = paragraph.list.level ?? 0;
14695
- if (paragraph.list.kind === "bullet") {
14696
- const raw = paragraph.list.bulletGlyph;
14697
- if (raw) return normalizeBulletGlyph(raw);
14698
- return BULLET_GLYPHS[level % BULLET_GLYPHS.length] ?? "•";
14741
+ let labels = listLabelsCache.get(document2);
14742
+ if (!labels) {
14743
+ labels = buildListLabels(document2);
14744
+ listLabelsCache.set(document2, labels);
14699
14745
  }
14700
- const ordinal = getListOrdinals(document2).get(paragraph.id) ?? paragraph.list.startAt ?? 1;
14701
- const format = paragraph.list.format && paragraph.list.format !== "bullet" ? paragraph.list.format : ORDERED_DEFAULT_FORMATS[level % ORDERED_DEFAULT_FORMATS.length] ?? "decimal";
14702
- return `${formatOrdinal(ordinal, format)}.`;
14746
+ return resolveListLabel(paragraph, labels);
14703
14747
  }
14704
14748
  function drawEdge(ctx, border, x1, y1, x2, y2) {
14705
14749
  if (!border || border.type === "none" || border.width <= 0) {
@@ -16909,7 +16953,13 @@ function drawParagraph(ctx, paragraph, lines, state, originX, originY, onUpdate,
16909
16953
  const gap = ctx.measureText(`${listPrefix} `).width;
16910
16954
  const labelInset = getListLabelInset(paragraph, state.document.styles);
16911
16955
  const labelWidth = ctx.measureText(listPrefix).width;
16912
- const left = first !== void 0 && labelInset + labelWidth > first.left ? Math.max(0, first.left - gap) : Math.max(0, labelInset);
16956
+ const alignedLeft = getAlignedListLabelInset(
16957
+ paragraph,
16958
+ state.document.styles,
16959
+ (first == null ? void 0 : first.left) ?? labelInset + labelWidth,
16960
+ labelWidth
16961
+ );
16962
+ const left = first !== void 0 && labelInset + labelWidth > first.left ? Math.max(0, first.left - gap) : alignedLeft;
16913
16963
  ctx.fillText(listPrefix, originX + left, baselineY);
16914
16964
  ctx.restore();
16915
16965
  }
@@ -31715,191 +31765,173 @@ const FORMAT_MAP = {
31715
31765
  upperRoman: "upperRoman",
31716
31766
  bullet: "bullet"
31717
31767
  };
31768
+ function isXmlTrue$1(value) {
31769
+ return value == null || value === "1" || value === "true" || value === "on";
31770
+ }
31771
+ function parseLevel(level) {
31772
+ const result = {};
31773
+ const formatRaw = getAttributeValue(
31774
+ getFirstChildByTagNameNS(level, WORD_NS, "numFmt"),
31775
+ "val"
31776
+ );
31777
+ if (formatRaw) {
31778
+ result.kind = formatRaw === "bullet" ? "bullet" : "ordered";
31779
+ result.format = FORMAT_MAP[formatRaw];
31780
+ }
31781
+ const suffix = getAttributeValue(
31782
+ getFirstChildByTagNameNS(level, WORD_NS, "suff"),
31783
+ "val"
31784
+ );
31785
+ if (suffix === "tab" || suffix === "space" || suffix === "nothing") {
31786
+ result.suffix = suffix;
31787
+ }
31788
+ const startRaw = getAttributeValue(
31789
+ getFirstChildByTagNameNS(level, WORD_NS, "start"),
31790
+ "val"
31791
+ );
31792
+ if (startRaw != null) {
31793
+ const startAt = Number.parseInt(startRaw, 10);
31794
+ if (Number.isFinite(startAt)) result.startAt = startAt;
31795
+ }
31796
+ result.levelText = getAttributeValue(
31797
+ getFirstChildByTagNameNS(level, WORD_NS, "lvlText"),
31798
+ "val"
31799
+ ) ?? void 0;
31800
+ const alignment = getAttributeValue(
31801
+ getFirstChildByTagNameNS(level, WORD_NS, "lvlJc"),
31802
+ "val"
31803
+ );
31804
+ if (alignment === "left" || alignment === "center" || alignment === "right") {
31805
+ result.alignment = alignment;
31806
+ }
31807
+ const legal = getFirstChildByTagNameNS(level, WORD_NS, "isLgl");
31808
+ if (legal) result.legal = isXmlTrue$1(getAttributeValue(legal, "val"));
31809
+ if (result.kind === "bullet" && result.levelText) {
31810
+ result.bulletGlyph = result.levelText;
31811
+ }
31812
+ const rPr = getFirstChildByTagNameNS(level, WORD_NS, "rPr");
31813
+ const rFonts = getFirstChildByTagNameNS(rPr, WORD_NS, "rFonts");
31814
+ result.bulletFont = getAttributeValue(rFonts, "ascii") ?? getAttributeValue(rFonts, "hAnsi") ?? void 0;
31815
+ const pPr = getFirstChildByTagNameNS(level, WORD_NS, "pPr");
31816
+ const ind = getFirstChildByTagNameNS(pPr, WORD_NS, "ind");
31817
+ if (ind) {
31818
+ const leftRaw = getAttributeValue(ind, "left") ?? getAttributeValue(ind, "start");
31819
+ const hangingRaw = getAttributeValue(ind, "hanging");
31820
+ const left = leftRaw != null ? twipsToPx(leftRaw, 0) : void 0;
31821
+ const hanging = hangingRaw != null ? twipsToPx(hangingRaw, 0) : void 0;
31822
+ if (left !== void 0 || hanging !== void 0)
31823
+ result.indent = { left, hanging };
31824
+ }
31825
+ return result;
31826
+ }
31718
31827
  function parseNumbering(numberingXml) {
31719
- const abstractKinds = /* @__PURE__ */ new Map();
31720
- const numKinds = /* @__PURE__ */ new Map();
31721
- const abstractIndents = /* @__PURE__ */ new Map();
31722
- const abstractSuffixes = /* @__PURE__ */ new Map();
31723
- const abstractFormats = /* @__PURE__ */ new Map();
31724
- const abstractStarts = /* @__PURE__ */ new Map();
31725
- const abstractBulletGlyphs = /* @__PURE__ */ new Map();
31726
- const abstractBulletFonts = /* @__PURE__ */ new Map();
31727
- const numStartOverrides = /* @__PURE__ */ new Map();
31728
- const numToAbstractId = /* @__PURE__ */ new Map();
31729
- const seenInstances = /* @__PURE__ */ new Set();
31730
- const emptyResult = () => ({
31731
- abstractKinds,
31732
- numKinds,
31733
- abstractIndents,
31734
- abstractSuffixes,
31735
- abstractFormats,
31736
- abstractStarts,
31737
- abstractBulletGlyphs,
31738
- abstractBulletFonts,
31739
- numStartOverrides,
31740
- numToAbstractId,
31741
- seenInstances
31742
- });
31743
- if (!numberingXml) return emptyResult();
31828
+ const maps = {
31829
+ abstractLevels: /* @__PURE__ */ new Map(),
31830
+ numOverrideLevels: /* @__PURE__ */ new Map(),
31831
+ numStartOverrides: /* @__PURE__ */ new Map(),
31832
+ numToAbstractId: /* @__PURE__ */ new Map(),
31833
+ seenInstances: /* @__PURE__ */ new Set()
31834
+ };
31835
+ if (!numberingXml) return maps;
31744
31836
  const document2 = new DOMParser$1().parseFromString(
31745
31837
  numberingXml,
31746
31838
  "application/xml"
31747
31839
  );
31748
31840
  const numbering = document2.documentElement;
31749
- if (!numbering) return emptyResult();
31750
- const abstractNums = numbering.getElementsByTagNameNS(WORD_NS, "abstractNum");
31751
- for (let index = 0; index < abstractNums.length; index += 1) {
31752
- const abstractNum = abstractNums[index];
31841
+ if (!numbering) return maps;
31842
+ for (const abstractNum of Array.from(
31843
+ numbering.getElementsByTagNameNS(WORD_NS, "abstractNum")
31844
+ )) {
31753
31845
  const abstractId = getAttributeValue(abstractNum, "abstractNumId");
31754
31846
  if (!abstractId) continue;
31755
31847
  for (const level of getChildrenByTagNameNS(abstractNum, WORD_NS, "lvl")) {
31756
31848
  const ilvl = getAttributeValue(level, "ilvl") ?? "0";
31757
- const levelKey = `${abstractId}:${ilvl}`;
31758
- const numFmt = getFirstChildByTagNameNS(level, WORD_NS, "numFmt");
31759
- const format = getAttributeValue(numFmt, "val");
31760
- if (format) {
31761
- abstractKinds.set(
31762
- levelKey,
31763
- format === "bullet" ? "bullet" : "ordered"
31849
+ maps.abstractLevels.set(`${abstractId}:${ilvl}`, parseLevel(level));
31850
+ }
31851
+ }
31852
+ for (const num of Array.from(
31853
+ numbering.getElementsByTagNameNS(WORD_NS, "num")
31854
+ )) {
31855
+ const numId = getAttributeValue(num, "numId");
31856
+ const abstractId = getAttributeValue(
31857
+ getFirstChildByTagNameNS(num, WORD_NS, "abstractNumId"),
31858
+ "val"
31859
+ );
31860
+ if (!numId || !abstractId) continue;
31861
+ maps.numToAbstractId.set(numId, abstractId);
31862
+ for (const override of getChildrenByTagNameNS(
31863
+ num,
31864
+ WORD_NS,
31865
+ "lvlOverride"
31866
+ )) {
31867
+ const ilvl = getAttributeValue(override, "ilvl") ?? "0";
31868
+ const overrideLevel = getFirstChildByTagNameNS(override, WORD_NS, "lvl");
31869
+ if (overrideLevel) {
31870
+ maps.numOverrideLevels.set(
31871
+ `${numId}:${ilvl}`,
31872
+ parseLevel(overrideLevel)
31764
31873
  );
31765
- if (ilvl === "0") {
31766
- abstractKinds.set(
31767
- abstractId,
31768
- format === "bullet" ? "bullet" : "ordered"
31769
- );
31770
- }
31771
- const editorFormat = FORMAT_MAP[format];
31772
- if (editorFormat) abstractFormats.set(levelKey, editorFormat);
31773
- }
31774
- const suffRaw = getAttributeValue(
31775
- getFirstChildByTagNameNS(level, WORD_NS, "suff"),
31776
- "val"
31777
- );
31778
- if (suffRaw === "space" || suffRaw === "nothing" || suffRaw === "tab") {
31779
- abstractSuffixes.set(levelKey, suffRaw);
31780
31874
  }
31781
31875
  const startRaw = getAttributeValue(
31782
- getFirstChildByTagNameNS(level, WORD_NS, "start"),
31876
+ getFirstChildByTagNameNS(override, WORD_NS, "startOverride"),
31783
31877
  "val"
31784
31878
  );
31785
31879
  if (startRaw != null) {
31786
- const n = parseInt(startRaw, 10);
31787
- if (!isNaN(n)) abstractStarts.set(levelKey, n);
31788
- }
31789
- if (format === "bullet") {
31790
- const lvlTextEl = getFirstChildByTagNameNS(level, WORD_NS, "lvlText");
31791
- const glyph = getAttributeValue(lvlTextEl, "val");
31792
- if (glyph) abstractBulletGlyphs.set(levelKey, glyph);
31793
- }
31794
- const rPr = getFirstChildByTagNameNS(level, WORD_NS, "rPr");
31795
- const rFonts = getFirstChildByTagNameNS(rPr, WORD_NS, "rFonts");
31796
- const fontName = getAttributeValue(rFonts, "ascii") ?? getAttributeValue(rFonts, "hAnsi");
31797
- if (fontName) abstractBulletFonts.set(levelKey, fontName);
31798
- const pPr = getFirstChildByTagNameNS(level, WORD_NS, "pPr");
31799
- const ind = getFirstChildByTagNameNS(pPr, WORD_NS, "ind");
31800
- if (ind) {
31801
- const leftRaw = getAttributeValue(ind, "left") ?? getAttributeValue(ind, "start");
31802
- const hangingRaw = getAttributeValue(ind, "hanging");
31803
- const left = leftRaw != null ? twipsToPx(leftRaw, 0) : void 0;
31804
- const hanging = hangingRaw != null ? twipsToPx(hangingRaw, 0) : void 0;
31805
- if (left !== void 0 || hanging !== void 0) {
31806
- abstractIndents.set(levelKey, { left, hanging });
31880
+ const startAt = Number.parseInt(startRaw, 10);
31881
+ if (Number.isFinite(startAt)) {
31882
+ maps.numStartOverrides.set(`${numId}:${ilvl}`, startAt);
31807
31883
  }
31808
31884
  }
31809
31885
  }
31810
31886
  }
31811
- const nums = numbering.getElementsByTagNameNS(WORD_NS, "num");
31812
- for (let index = 0; index < nums.length; index += 1) {
31813
- const num = nums[index];
31814
- const numId = getAttributeValue(num, "numId");
31815
- const abstractNumIdElement = getFirstChildByTagNameNS(
31816
- num,
31817
- WORD_NS,
31818
- "abstractNumId"
31819
- );
31820
- const abstractNumId = getAttributeValue(abstractNumIdElement, "val");
31821
- if (!numId || !abstractNumId) {
31822
- continue;
31823
- }
31824
- numToAbstractId.set(numId, abstractNumId);
31825
- numKinds.set(numId, abstractKinds.get(abstractNumId) ?? "ordered");
31826
- for (const override of getChildrenByTagNameNS(num, WORD_NS, "lvlOverride")) {
31827
- const overrideIlvl = getAttributeValue(override, "ilvl");
31828
- if (!overrideIlvl) continue;
31829
- const startOverrideEl = getFirstChildByTagNameNS(
31830
- override,
31831
- WORD_NS,
31832
- "startOverride"
31833
- );
31834
- const startOverrideRaw = getAttributeValue(startOverrideEl, "val");
31835
- if (startOverrideRaw != null) {
31836
- const n = parseInt(startOverrideRaw, 10);
31837
- if (!isNaN(n)) numStartOverrides.set(`${numId}:${overrideIlvl}`, n);
31838
- }
31839
- }
31840
- }
31841
- return {
31842
- abstractKinds,
31843
- numKinds,
31844
- abstractIndents,
31845
- abstractSuffixes,
31846
- abstractFormats,
31847
- abstractStarts,
31848
- abstractBulletGlyphs,
31849
- abstractBulletFonts,
31850
- numStartOverrides,
31851
- numToAbstractId,
31852
- seenInstances
31853
- };
31887
+ return maps;
31888
+ }
31889
+ function effectiveLevel(numberingMaps, numId, ilvl) {
31890
+ const abstractId = numberingMaps.numToAbstractId.get(numId);
31891
+ const base = abstractId ? numberingMaps.abstractLevels.get(`${abstractId}:${ilvl}`) : void 0;
31892
+ const override = numberingMaps.numOverrideLevels.get(`${numId}:${ilvl}`);
31893
+ return override ?? base ?? {};
31854
31894
  }
31855
31895
  function parseParagraphList(paragraphProperties, numberingMaps) {
31856
- if (!paragraphProperties) {
31857
- return void 0;
31858
- }
31896
+ if (!paragraphProperties) return void 0;
31859
31897
  const numPr = getFirstChildByTagNameNS(paragraphProperties, WORD_NS, "numPr");
31860
- if (!numPr) {
31861
- return void 0;
31862
- }
31898
+ if (!numPr) return void 0;
31863
31899
  const numId = getAttributeValue(
31864
31900
  getFirstChildByTagNameNS(numPr, WORD_NS, "numId"),
31865
31901
  "val"
31866
31902
  );
31867
- if (!numId) {
31868
- return void 0;
31869
- }
31870
- const ilvlValue = getAttributeValue(
31903
+ if (!numId) return void 0;
31904
+ const ilvlRaw = getAttributeValue(
31871
31905
  getFirstChildByTagNameNS(numPr, WORD_NS, "ilvl"),
31872
31906
  "val"
31873
31907
  ) ?? "0";
31874
- const level = Number(ilvlValue);
31875
- const abstractId = numberingMaps.numToAbstractId.get(numId);
31876
- const levelKey = abstractId ? `${abstractId}:${ilvlValue}` : void 0;
31877
- const indent = levelKey ? numberingMaps.abstractIndents.get(levelKey) : void 0;
31878
- const suffix = (levelKey ? numberingMaps.abstractSuffixes.get(levelKey) : void 0) ?? "tab";
31879
- const format = levelKey ? numberingMaps.abstractFormats.get(levelKey) : void 0;
31880
- const bulletGlyph = levelKey ? numberingMaps.abstractBulletGlyphs.get(levelKey) : void 0;
31881
- const bulletFont = levelKey ? numberingMaps.abstractBulletFonts.get(levelKey) : void 0;
31882
- const instanceKey = `${numId}:${ilvlValue}`;
31908
+ const level = Number.parseInt(ilvlRaw, 10);
31909
+ const safeLevel = Number.isFinite(level) ? level : 0;
31910
+ const effective = effectiveLevel(numberingMaps, numId, safeLevel);
31911
+ const levelFormats = [];
31912
+ for (let index = 0; index <= safeLevel; index += 1) {
31913
+ levelFormats[index] = effectiveLevel(numberingMaps, numId, index).format ?? "decimal";
31914
+ }
31915
+ const instanceKey = `${numId}:${safeLevel}`;
31883
31916
  const isFirstInInstance = !numberingMaps.seenInstances.has(instanceKey);
31884
31917
  numberingMaps.seenInstances.add(instanceKey);
31885
- let startAt;
31886
- if (isFirstInInstance) {
31887
- const override = numberingMaps.numStartOverrides.get(instanceKey);
31888
- const abstractStart = levelKey ? numberingMaps.abstractStarts.get(levelKey) : void 0;
31889
- const effectiveStart = override ?? abstractStart ?? 1;
31890
- if (effectiveStart !== 1) startAt = effectiveStart;
31891
- }
31918
+ const startAt = isFirstInInstance ? numberingMaps.numStartOverrides.get(instanceKey) ?? effective.startAt : void 0;
31892
31919
  return {
31893
31920
  list: {
31894
- kind: numberingMaps.numKinds.get(numId) ?? "ordered",
31895
- level: Number.isFinite(level) ? level : 0,
31896
- suffix,
31897
- ...format !== void 0 && { format },
31898
- ...startAt !== void 0 && { startAt },
31899
- ...bulletGlyph !== void 0 && { bulletGlyph },
31900
- ...bulletFont !== void 0 && { bulletFont }
31921
+ kind: effective.kind ?? "ordered",
31922
+ level: safeLevel,
31923
+ instanceId: numId,
31924
+ suffix: effective.suffix ?? "tab",
31925
+ ...effective.format ? { format: effective.format } : {},
31926
+ ...levelFormats.length ? { levelFormats } : {},
31927
+ ...effective.levelText ? { levelText: effective.levelText } : {},
31928
+ ...effective.alignment ? { alignment: effective.alignment } : {},
31929
+ ...effective.legal !== void 0 ? { legal: effective.legal } : {},
31930
+ ...startAt !== void 0 && startAt !== 1 ? { startAt } : {},
31931
+ ...effective.bulletGlyph ? { bulletGlyph: effective.bulletGlyph } : {},
31932
+ ...effective.bulletFont ? { bulletFont: effective.bulletFont } : {}
31901
31933
  },
31902
- indent
31934
+ indent: effective.indent
31903
31935
  };
31904
31936
  }
31905
31937
  function stripUndefined(value) {
@@ -34424,6 +34456,24 @@ function applyConditionalTextStyle(paragraphs, textStyle) {
34424
34456
  }
34425
34457
  }
34426
34458
  }
34459
+ function tableStyleParagraphInheritance(tableStylePPr, paragraphStyleId, styles) {
34460
+ if (!tableStylePPr) {
34461
+ return void 0;
34462
+ }
34463
+ const effectiveStyleId = paragraphStyleId ?? resolveDefaultParagraphStyleId(styles);
34464
+ const paragraphStyleDelta = resolveNamedParagraphStyle(
34465
+ effectiveStyleId,
34466
+ styles
34467
+ );
34468
+ const definedByParagraphStyle = new Set(Object.keys(paragraphStyleDelta));
34469
+ const filtered = {};
34470
+ for (const [key, value] of Object.entries(tableStylePPr)) {
34471
+ if (!definedByParagraphStyle.has(key)) {
34472
+ filtered[key] = value;
34473
+ }
34474
+ }
34475
+ return emptyOrUndefined(filtered);
34476
+ }
34427
34477
  async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, theme, styles) {
34428
34478
  var _a, _b;
34429
34479
  const gridCols = [];
@@ -34496,6 +34546,19 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
34496
34546
  WORD_NS,
34497
34547
  "p"
34498
34548
  )) {
34549
+ const paragraphStyleId = getAttributeValue(
34550
+ getFirstChildByTagNameNS(
34551
+ getFirstChildByTagNameNS(paragraphNode, WORD_NS, "pPr"),
34552
+ WORD_NS,
34553
+ "pStyle"
34554
+ ),
34555
+ "val"
34556
+ ) ?? void 0;
34557
+ const cellInheritedStyle = tableStyleParagraphInheritance(
34558
+ inheritedParagraphStyle,
34559
+ paragraphStyleId,
34560
+ styles
34561
+ );
34499
34562
  paragraphs.push(
34500
34563
  await parseParagraphNode(
34501
34564
  paragraphNode,
@@ -34504,7 +34567,7 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
34504
34567
  relsMap,
34505
34568
  assets,
34506
34569
  theme,
34507
- inheritedParagraphStyle
34570
+ cellInheritedStyle
34508
34571
  )
34509
34572
  );
34510
34573
  autospacingFlags.push(
@@ -35819,7 +35882,7 @@ function importDocxInWorker(buffer, options = {}) {
35819
35882
  const worker = new Worker(
35820
35883
  new URL(
35821
35884
  /* @vite-ignore */
35822
- "" + new URL("assets/importDocxWorker-DcrboJNQ.js", import.meta.url).href,
35885
+ "" + new URL("assets/importDocxWorker-C8ErVbAl.js", import.meta.url).href,
35823
35886
  import.meta.url
35824
35887
  ),
35825
35888
  {
@@ -40154,154 +40217,157 @@ export {
40154
40217
  imageExtensionFromMime as Z,
40155
40218
  pxToPt as _,
40156
40219
  getParagraphLength as a,
40157
- createComponent as a$,
40220
+ createMemo as a$,
40158
40221
  buildCanvasTableLayout as a0,
40159
40222
  resolveFloatingObjectRect as a1,
40160
40223
  getTextBoxFloatingGeometry as a2,
40161
40224
  getPresetPathSegments as a3,
40162
40225
  projectBlocksLayout as a4,
40163
- textStyleToFontSizePt as a5,
40164
- PX_PER_POINT$2 as a6,
40165
- DEFAULT_FONT_SIZE_PX as a7,
40166
- isDoubleUnderlineStyle as a8,
40167
- isWavyUnderlineStyle as a9,
40168
- parseFontSizePtToPx as aA,
40169
- formatFontSizePt as aB,
40170
- listKindForTag as aC,
40171
- isParagraphTag as aD,
40172
- collectInlineRuns as aE,
40173
- parseParagraphStyle as aF,
40174
- t as aG,
40175
- getHeadingLevel as aH,
40176
- preciseFontModeVersion as aI,
40177
- isPreciseFontModeEnabled as aJ,
40178
- togglePreciseFontMode as aK,
40179
- nextFontSizePt as aL,
40180
- previousFontSizePt as aM,
40181
- fontSizePtToPx as aN,
40182
- createDefaultToolbarPreset as aO,
40183
- defaultMenuItems as aP,
40184
- MenuRegistry as aQ,
40185
- createToolbarRegistry as aR,
40186
- Editor as aS,
40187
- resolveCommandRef as aT,
40188
- commandRefName as aU,
40189
- InlineShell as aV,
40190
- BalloonShell as aW,
40191
- DocumentShell as aX,
40192
- createMemo as aY,
40193
- getCaretRectFromSnapshot as aZ,
40194
- getParagraphRectFromSnapshot as a_,
40195
- underlineStyleLineWidthPx as aa,
40196
- underlineStyleDashArray as ab,
40197
- getListLabelInset as ac,
40198
- getParagraphBorderInsets as ad,
40199
- normalizeFamily as ae,
40200
- ROBOTO_FONT_FILES as af,
40201
- loadFontAsset as ag,
40202
- OFFICE_COMPAT_FONT_FAMILIES as ah,
40203
- buildSfnt as ai,
40204
- defaultFontDecoderRegistry as aj,
40205
- SfntFontProgram as ak,
40206
- collectPdfFontFamilies as al,
40207
- projectDocumentLayout as am,
40208
- getPageHeaderZoneTop as an,
40209
- getPageBodyTop as ao,
40210
- getPageColumnRects as ap,
40211
- findFootnoteReference as aq,
40212
- FOOTNOTE_MARKER_GUTTER_PX as ar,
40213
- resolveImporterForFile as as,
40214
- createEditorStateFromDocument as at,
40215
- getDocumentParagraphsCanonical as au,
40216
- getToolbarStyleState as av,
40217
- STANDARD_FONT_SIZES_PT as aw,
40218
- fontSizePxToPt as ax,
40219
- probeLocalFontFamilies as ay,
40220
- createInitialEditorState as az,
40226
+ buildListLabels as a5,
40227
+ textStyleToFontSizePt as a6,
40228
+ PX_PER_POINT$2 as a7,
40229
+ DEFAULT_FONT_SIZE_PX as a8,
40230
+ isDoubleUnderlineStyle as a9,
40231
+ fontSizePxToPt as aA,
40232
+ probeLocalFontFamilies as aB,
40233
+ createInitialEditorState as aC,
40234
+ parseFontSizePtToPx as aD,
40235
+ formatFontSizePt as aE,
40236
+ listKindForTag as aF,
40237
+ isParagraphTag as aG,
40238
+ collectInlineRuns as aH,
40239
+ parseParagraphStyle as aI,
40240
+ t as aJ,
40241
+ getHeadingLevel as aK,
40242
+ preciseFontModeVersion as aL,
40243
+ isPreciseFontModeEnabled as aM,
40244
+ togglePreciseFontMode as aN,
40245
+ nextFontSizePt as aO,
40246
+ previousFontSizePt as aP,
40247
+ fontSizePtToPx as aQ,
40248
+ createDefaultToolbarPreset as aR,
40249
+ defaultMenuItems as aS,
40250
+ MenuRegistry as aT,
40251
+ createToolbarRegistry as aU,
40252
+ Editor as aV,
40253
+ resolveCommandRef as aW,
40254
+ commandRefName as aX,
40255
+ InlineShell as aY,
40256
+ BalloonShell as aZ,
40257
+ DocumentShell as a_,
40258
+ isWavyUnderlineStyle as aa,
40259
+ underlineStyleLineWidthPx as ab,
40260
+ underlineStyleDashArray as ac,
40261
+ resolveListLabel as ad,
40262
+ getListLabelInset as ae,
40263
+ getAlignedListLabelInset as af,
40264
+ getParagraphBorderInsets as ag,
40265
+ normalizeFamily as ah,
40266
+ ROBOTO_FONT_FILES as ai,
40267
+ loadFontAsset as aj,
40268
+ OFFICE_COMPAT_FONT_FAMILIES as ak,
40269
+ buildSfnt as al,
40270
+ defaultFontDecoderRegistry as am,
40271
+ SfntFontProgram as an,
40272
+ collectPdfFontFamilies as ao,
40273
+ projectDocumentLayout as ap,
40274
+ getPageHeaderZoneTop as aq,
40275
+ getPageBodyTop as ar,
40276
+ getPageColumnRects as as,
40277
+ findFootnoteReference as at,
40278
+ FOOTNOTE_MARKER_GUTTER_PX as au,
40279
+ resolveImporterForFile as av,
40280
+ createEditorStateFromDocument as aw,
40281
+ getDocumentParagraphsCanonical as ax,
40282
+ getToolbarStyleState as ay,
40283
+ STANDARD_FONT_SIZES_PT as az,
40221
40284
  createEditorRun as b,
40222
- PluginCollection as b$,
40223
- CaretOverlay as b0,
40224
- Show as b1,
40225
- createRenderEffect as b2,
40226
- style as b3,
40227
- setAttribute as b4,
40228
- setStyleProperty as b5,
40229
- memo as b6,
40230
- template as b7,
40231
- insert as b8,
40232
- use as b9,
40233
- createEditorZoom as bA,
40234
- startLongTaskObserver as bB,
40235
- installGlobalReport as bC,
40236
- applyStoredPreciseFontPreference as bD,
40237
- getWelcomeSeen as bE,
40238
- isLocalFontAccessSupported as bF,
40239
- EDITOR_SCROLL_PADDING_PX as bG,
40240
- Toolbar as bH,
40241
- OasisEditorLoading as bI,
40242
- createEditorLogger as bJ,
40243
- getCachedCanvasImage as bK,
40244
- registerDomStatsSurface as bL,
40245
- Button as bM,
40246
- Checkbox as bN,
40247
- ColorPicker as bO,
40248
- CommandRegistry as bP,
40249
- DEFAULT_PALETTE as bQ,
40250
- DialogFooter as bR,
40251
- FloatingActionButton as bS,
40252
- GridPicker as bT,
40253
- IconButton as bU,
40254
- Menu as bV,
40255
- OASIS_BUILTIN_COMMANDS as bW,
40256
- OASIS_MENU_ITEMS as bX,
40257
- OASIS_TOOLBAR_ITEMS as bY,
40258
- OasisEditorAppLazy as bZ,
40259
- OasisEditorContainer as b_,
40260
- addEventListener as ba,
40261
- Dialog as bb,
40262
- delegateEvents as bc,
40263
- className as bd,
40264
- For as be,
40265
- UNDERLINE_STYLE_OPTIONS as bf,
40266
- Tabs as bg,
40267
- measureParagraphMinContentWidthPx as bh,
40268
- getEditableBlocksForZone as bi,
40269
- findParagraphLocation as bj,
40270
- createSectionBoundaryParagraph as bk,
40271
- normalizePageSettings as bl,
40272
- DEFAULT_EDITOR_PAGE_SETTINGS as bm,
40273
- markStart as bn,
40274
- markEnd as bo,
40275
- getParagraphEntries as bp,
40276
- getParagraphById as bq,
40277
- PluginUiHost as br,
40278
- OasisEditorEditor as bs,
40279
- perfTimer as bt,
40280
- OasisBrandMark as bu,
40281
- setPreciseFontPreference as bv,
40282
- setWelcomeSeen as bw,
40283
- enablePreciseFontMode as bx,
40284
- createOasisEditorClient as by,
40285
- setLocale as bz,
40285
+ OASIS_TOOLBAR_ITEMS as b$,
40286
+ getCaretRectFromSnapshot as b0,
40287
+ getParagraphRectFromSnapshot as b1,
40288
+ createComponent as b2,
40289
+ CaretOverlay as b3,
40290
+ Show as b4,
40291
+ createRenderEffect as b5,
40292
+ style as b6,
40293
+ setAttribute as b7,
40294
+ setStyleProperty as b8,
40295
+ memo as b9,
40296
+ enablePreciseFontMode as bA,
40297
+ createOasisEditorClient as bB,
40298
+ setLocale as bC,
40299
+ createEditorZoom as bD,
40300
+ startLongTaskObserver as bE,
40301
+ installGlobalReport as bF,
40302
+ applyStoredPreciseFontPreference as bG,
40303
+ getWelcomeSeen as bH,
40304
+ isLocalFontAccessSupported as bI,
40305
+ EDITOR_SCROLL_PADDING_PX as bJ,
40306
+ Toolbar as bK,
40307
+ OasisEditorLoading as bL,
40308
+ createEditorLogger as bM,
40309
+ getCachedCanvasImage as bN,
40310
+ registerDomStatsSurface as bO,
40311
+ Button as bP,
40312
+ Checkbox as bQ,
40313
+ ColorPicker as bR,
40314
+ CommandRegistry as bS,
40315
+ DEFAULT_PALETTE as bT,
40316
+ DialogFooter as bU,
40317
+ FloatingActionButton as bV,
40318
+ GridPicker as bW,
40319
+ IconButton as bX,
40320
+ Menu as bY,
40321
+ OASIS_BUILTIN_COMMANDS as bZ,
40322
+ OASIS_MENU_ITEMS as b_,
40323
+ template as ba,
40324
+ insert as bb,
40325
+ use as bc,
40326
+ addEventListener as bd,
40327
+ Dialog as be,
40328
+ delegateEvents as bf,
40329
+ className as bg,
40330
+ For as bh,
40331
+ UNDERLINE_STYLE_OPTIONS as bi,
40332
+ Tabs as bj,
40333
+ measureParagraphMinContentWidthPx as bk,
40334
+ getEditableBlocksForZone as bl,
40335
+ findParagraphLocation as bm,
40336
+ createSectionBoundaryParagraph as bn,
40337
+ normalizePageSettings as bo,
40338
+ DEFAULT_EDITOR_PAGE_SETTINGS as bp,
40339
+ markStart as bq,
40340
+ markEnd as br,
40341
+ getParagraphEntries as bs,
40342
+ getParagraphById as bt,
40343
+ PluginUiHost as bu,
40344
+ OasisEditorEditor as bv,
40345
+ perfTimer as bw,
40346
+ OasisBrandMark as bx,
40347
+ setPreciseFontPreference as by,
40348
+ setWelcomeSeen as bz,
40286
40349
  createEditorParagraphFromRuns as c,
40287
- Popover as c0,
40288
- RIBBON_TABS as c1,
40289
- RIBBON_TAB_DEFINITIONS as c2,
40290
- Select as c3,
40291
- SelectField as c4,
40292
- Separator as c5,
40293
- SidePanel as c6,
40294
- SidePanelBody as c7,
40295
- SidePanelFooter as c8,
40296
- SidePanelHeader as c9,
40297
- SplitButton as ca,
40298
- TextField as cb,
40299
- Button$1 as cc,
40300
- createEditorCommandBus as cd,
40301
- createOasisEditor as ce,
40302
- createOasisEditorContainer as cf,
40303
- mount as cg,
40304
- registerToolbarRenderer as ch,
40350
+ OasisEditorAppLazy as c0,
40351
+ OasisEditorContainer as c1,
40352
+ PluginCollection as c2,
40353
+ Popover as c3,
40354
+ RIBBON_TABS as c4,
40355
+ RIBBON_TAB_DEFINITIONS as c5,
40356
+ Select as c6,
40357
+ SelectField as c7,
40358
+ Separator as c8,
40359
+ SidePanel as c9,
40360
+ SidePanelBody as ca,
40361
+ SidePanelFooter as cb,
40362
+ SidePanelHeader as cc,
40363
+ SplitButton as cd,
40364
+ TextField as ce,
40365
+ Button$1 as cf,
40366
+ createEditorCommandBus as cg,
40367
+ createOasisEditor as ch,
40368
+ createOasisEditorContainer as ci,
40369
+ mount as cj,
40370
+ registerToolbarRenderer as ck,
40305
40371
  getDocumentSections as d,
40306
40372
  createEditorStyledRun as e,
40307
40373
  getParagraphText as f,