oasis-editor 0.0.88 → 0.0.89

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 (32) hide show
  1. package/dist/{OasisEditorApp-Bx4I4GCm.js → OasisEditorApp-cKm4OFIF.js} +1325 -171
  2. package/dist/assets/{importDocxWorker-BcELKms0.js → importDocxWorker-DVDyiqYf.js} +1 -1
  3. package/dist/core/commands/table/tableCommandUtils.d.ts +2 -1
  4. package/dist/core/commands/table/tableFloatingCommands.d.ts +5 -0
  5. package/dist/core/commands/table.d.ts +1 -0
  6. package/dist/core/model/index.d.ts +2 -2
  7. package/dist/core/model/types/layout.d.ts +4 -0
  8. package/dist/core/model/types/nodes.d.ts +23 -7
  9. package/dist/core/model/types/primitives.d.ts +17 -0
  10. package/dist/core/model/types/styles.d.ts +43 -6
  11. package/dist/core/model.d.ts +1 -0
  12. package/dist/core/tableStyleResolver.d.ts +20 -0
  13. package/dist/export/docx/tableXml.d.ts +1 -0
  14. package/dist/export/pdf/draw/drawFragment.d.ts +13 -1
  15. package/dist/export/pdf/draw/drawTextBoxShape.d.ts +1 -0
  16. package/dist/i18n/locales/en.d.ts +18 -0
  17. package/dist/i18n/locales/pt-BR.d.ts +18 -0
  18. package/dist/import/docx/tableProperties.d.ts +2 -1
  19. package/dist/import/docx/tables.d.ts +1 -1
  20. package/dist/{index-Ds5uOUe8.js → index-BICQTKCZ.js} +1401 -850
  21. package/dist/layoutProjection/floatingObjects.d.ts +15 -1
  22. package/dist/layoutProjection/paginationTrack.d.ts +2 -0
  23. package/dist/layoutProjection/paragraphPagination.d.ts +2 -2
  24. package/dist/oasis-editor.js +50 -50
  25. package/dist/oasis-editor.umd.cjs +4 -4
  26. package/dist/ui/canvas/CanvasLayoutSnapshot.d.ts +1 -1
  27. package/dist/ui/canvas/CanvasTableLayout.d.ts +7 -1
  28. package/dist/ui/canvas/canvasBorders.d.ts +2 -0
  29. package/dist/ui/canvas/canvasSnapshotTypes.d.ts +12 -0
  30. package/dist/ui/components/Dialogs/TablePropertiesDialog.d.ts +22 -1
  31. package/dist/ui/editorUiTypes.d.ts +1 -1
  32. package/package.json +1 -1
@@ -1650,6 +1650,24 @@ const en = {
1650
1650
  "table.wrapAround": "Around",
1651
1651
  "table.positioning": "Positioning...",
1652
1652
  "table.positioningReadOnly": "Floating table positioning is preserved for DOCX round-trip and is not editable yet.",
1653
+ "table.horizontalAnchor": "Horizontal relative to",
1654
+ "table.verticalAnchor": "Vertical relative to",
1655
+ "table.anchorMargin": "Margin",
1656
+ "table.anchorPage": "Page",
1657
+ "table.anchorText": "Text",
1658
+ "table.positionX": "Horizontal position (pt)",
1659
+ "table.positionY": "Vertical position (pt)",
1660
+ "table.horizontalAlignment": "Horizontal alignment",
1661
+ "table.explicitOffset": "Explicit offset",
1662
+ "table.distanceTop": "Top distance (pt)",
1663
+ "table.distanceRight": "Right distance (pt)",
1664
+ "table.distanceBottom": "Bottom distance (pt)",
1665
+ "table.distanceLeft": "Left distance (pt)",
1666
+ "table.allowOverlap": "Allow overlap",
1667
+ "table.borderStart": "Start",
1668
+ "table.borderEnd": "End",
1669
+ "table.borderTlBr": "Diagonal down",
1670
+ "table.borderTrBl": "Diagonal up",
1653
1671
  "table.rowHeight": "Preferred height",
1654
1672
  "table.rowHeightRule": "Row height is",
1655
1673
  "table.rowAuto": "Auto",
@@ -2108,6 +2126,24 @@ const ptBR = {
2108
2126
  "table.wrapAround": "Ao redor",
2109
2127
  "table.positioning": "Posicionamento...",
2110
2128
  "table.positioningReadOnly": "O posicionamento de tabela flutuante é preservado no DOCX e ainda não é editável.",
2129
+ "table.horizontalAnchor": "Horizontal relativo a",
2130
+ "table.verticalAnchor": "Vertical relativo a",
2131
+ "table.anchorMargin": "Margem",
2132
+ "table.anchorPage": "Página",
2133
+ "table.anchorText": "Texto",
2134
+ "table.positionX": "Posição horizontal (pt)",
2135
+ "table.positionY": "Posição vertical (pt)",
2136
+ "table.horizontalAlignment": "Alinhamento horizontal",
2137
+ "table.explicitOffset": "Deslocamento explícito",
2138
+ "table.distanceTop": "Distância superior (pt)",
2139
+ "table.distanceRight": "Distância direita (pt)",
2140
+ "table.distanceBottom": "Distância inferior (pt)",
2141
+ "table.distanceLeft": "Distância esquerda (pt)",
2142
+ "table.allowOverlap": "Permitir sobreposição",
2143
+ "table.borderStart": "Início",
2144
+ "table.borderEnd": "Fim",
2145
+ "table.borderTlBr": "Diagonal descendente",
2146
+ "table.borderTrBl": "Diagonal ascendente",
2111
2147
  "table.rowHeight": "Altura preferencial",
2112
2148
  "table.rowHeightRule": "Altura da linha",
2113
2149
  "table.rowAuto": "Automática",
@@ -2483,7 +2519,7 @@ function OasisEditorAppLazy(props = {}) {
2483
2519
  onCleanup(() => {
2484
2520
  cancelled = true;
2485
2521
  });
2486
- import("./OasisEditorApp-Bx4I4GCm.js").then((m) => {
2522
+ import("./OasisEditorApp-cKm4OFIF.js").then((m) => {
2487
2523
  cancelled = true;
2488
2524
  setProgress(1);
2489
2525
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -3771,6 +3807,198 @@ function getParagraphs(state) {
3771
3807
  getBlockParagraphs
3772
3808
  );
3773
3809
  }
3810
+ function resolveEffectiveTableStyle(table, styles) {
3811
+ var _a;
3812
+ const named = resolveNamedTableStyle((_a = table.style) == null ? void 0 : _a.styleId, styles);
3813
+ return mergeTableStyles(named.tableStyle, table.style);
3814
+ }
3815
+ function resolveTableParagraphInheritance(tableStyle, paragraphStyleId, styles) {
3816
+ if (!tableStyle) return void 0;
3817
+ const effectiveStyleId = paragraphStyleId ?? resolveDefaultParagraphStyleId(styles);
3818
+ const named = resolveNamedParagraphStyle(effectiveStyleId, styles);
3819
+ const inherited = {};
3820
+ for (const [key, value] of Object.entries(tableStyle)) {
3821
+ if (!(key in named)) {
3822
+ inherited[key] = value;
3823
+ }
3824
+ }
3825
+ return Object.keys(inherited).length > 0 ? inherited : void 0;
3826
+ }
3827
+ function mergeTableStyles(base, next) {
3828
+ const conditionalFormats = {
3829
+ ...(base == null ? void 0 : base.conditionalFormats) ?? {}
3830
+ };
3831
+ for (const [key, incoming] of Object.entries(
3832
+ (next == null ? void 0 : next.conditionalFormats) ?? {}
3833
+ )) {
3834
+ const previous = conditionalFormats[key];
3835
+ conditionalFormats[key] = {
3836
+ ...previous ?? {},
3837
+ ...incoming,
3838
+ textStyle: { ...previous == null ? void 0 : previous.textStyle, ...incoming.textStyle },
3839
+ paragraphStyle: {
3840
+ ...previous == null ? void 0 : previous.paragraphStyle,
3841
+ ...incoming.paragraphStyle
3842
+ },
3843
+ rowStyle: { ...previous == null ? void 0 : previous.rowStyle, ...incoming.rowStyle },
3844
+ cellStyle: { ...previous == null ? void 0 : previous.cellStyle, ...incoming.cellStyle },
3845
+ borders: { ...previous == null ? void 0 : previous.borders, ...incoming.borders },
3846
+ tableStyle: mergeTableStyles(previous == null ? void 0 : previous.tableStyle, incoming.tableStyle)
3847
+ };
3848
+ }
3849
+ return {
3850
+ ...base ?? {},
3851
+ ...next ?? {},
3852
+ defaultCellMargins: {
3853
+ ...(base == null ? void 0 : base.defaultCellMargins) ?? {},
3854
+ ...(next == null ? void 0 : next.defaultCellMargins) ?? {}
3855
+ },
3856
+ borders: { ...(base == null ? void 0 : base.borders) ?? {}, ...(next == null ? void 0 : next.borders) ?? {} },
3857
+ ...Object.keys(conditionalFormats).length > 0 ? { conditionalFormats } : {}
3858
+ };
3859
+ }
3860
+ function resolveNamedTableStyle(styleId, styles, seen = /* @__PURE__ */ new Set()) {
3861
+ var _a;
3862
+ if (!styles) return { tableStyle: {} };
3863
+ const effectiveId = styleId ?? ((_a = Object.values(styles).find(
3864
+ (style2) => style2.type === "table" && style2.isDefault
3865
+ )) == null ? void 0 : _a.id);
3866
+ if (!effectiveId || seen.has(effectiveId)) return { tableStyle: {} };
3867
+ const named = styles[effectiveId];
3868
+ if (!named || named.type !== "table") return { tableStyle: {} };
3869
+ seen.add(effectiveId);
3870
+ const parent = resolveNamedTableStyle(named.basedOn, styles, seen);
3871
+ return {
3872
+ tableStyle: mergeTableStyles(parent.tableStyle, named.tableStyle),
3873
+ paragraphStyle: {
3874
+ ...parent.paragraphStyle ?? {},
3875
+ ...named.paragraphStyle ?? {}
3876
+ },
3877
+ textStyle: {
3878
+ ...parent.textStyle ?? {},
3879
+ ...named.textStyle ?? {}
3880
+ }
3881
+ };
3882
+ }
3883
+ function conditionalKeys(options) {
3884
+ const { rowIndex, columnIndex, rowCount, columnCount, tableStyle } = options;
3885
+ const look = tableStyle.tblLook ?? {
3886
+ firstRow: true,
3887
+ lastRow: false,
3888
+ firstCol: true,
3889
+ lastCol: false,
3890
+ noHBand: false,
3891
+ noVBand: false
3892
+ };
3893
+ const firstRow = look.firstRow && rowIndex === 0;
3894
+ const lastRow = look.lastRow && rowIndex === rowCount - 1 && rowIndex !== 0;
3895
+ const firstCol = look.firstCol && columnIndex === 0;
3896
+ const lastCol = look.lastCol && columnIndex === columnCount - 1 && columnIndex !== 0;
3897
+ const keys = ["wholeTable"];
3898
+ if (!look.noHBand && !firstRow && !lastRow) {
3899
+ const body = rowIndex - (look.firstRow ? 1 : 0);
3900
+ keys.push(
3901
+ Math.floor(body / Math.max(1, tableStyle.rowBandSize ?? 1)) % 2 === 0 ? "band1Horz" : "band2Horz"
3902
+ );
3903
+ }
3904
+ if (!look.noVBand && !firstCol && !lastCol) {
3905
+ const body = columnIndex - (look.firstCol ? 1 : 0);
3906
+ keys.push(
3907
+ Math.floor(body / Math.max(1, tableStyle.colBandSize ?? 1)) % 2 === 0 ? "band1Vert" : "band2Vert"
3908
+ );
3909
+ }
3910
+ if (lastCol) keys.push("lastCol");
3911
+ if (firstCol) keys.push("firstCol");
3912
+ if (lastRow) keys.push("lastRow");
3913
+ if (firstRow) keys.push("firstRow");
3914
+ if (firstRow && firstCol) keys.push("nwCell");
3915
+ if (firstRow && lastCol) keys.push("neCell");
3916
+ if (lastRow && firstCol) keys.push("swCell");
3917
+ if (lastRow && lastCol) keys.push("seCell");
3918
+ for (const flags of [options.rowFlags, options.cellFlags]) {
3919
+ for (const [key, enabled2] of Object.entries(flags ?? {})) {
3920
+ if (enabled2 && !keys.includes(key)) keys.push(key);
3921
+ if (enabled2 === false) {
3922
+ const index = keys.indexOf(key);
3923
+ if (index >= 0) keys.splice(index, 1);
3924
+ }
3925
+ }
3926
+ }
3927
+ return keys;
3928
+ }
3929
+ function mergeConditionals(keys, formats) {
3930
+ const merged = {};
3931
+ for (const key of keys) {
3932
+ const next = formats == null ? void 0 : formats[key];
3933
+ if (!next) continue;
3934
+ if (next.shading) merged.shading = next.shading;
3935
+ if (next.textStyle)
3936
+ merged.textStyle = { ...merged.textStyle, ...next.textStyle };
3937
+ if (next.paragraphStyle)
3938
+ merged.paragraphStyle = {
3939
+ ...merged.paragraphStyle,
3940
+ ...next.paragraphStyle
3941
+ };
3942
+ if (next.rowStyle)
3943
+ merged.rowStyle = { ...merged.rowStyle, ...next.rowStyle };
3944
+ if (next.cellStyle)
3945
+ merged.cellStyle = { ...merged.cellStyle, ...next.cellStyle };
3946
+ if (next.borders) merged.borders = { ...merged.borders, ...next.borders };
3947
+ if (next.tableStyle)
3948
+ merged.tableStyle = mergeTableStyles(merged.tableStyle, next.tableStyle);
3949
+ }
3950
+ return merged;
3951
+ }
3952
+ function resolveEffectiveTableCellFormatting(options) {
3953
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
3954
+ const { table, rowIndex, cellIndex, visualColumnIndex, columnCount, styles } = options;
3955
+ const named = resolveNamedTableStyle((_a = table.style) == null ? void 0 : _a.styleId, styles);
3956
+ const baseTableStyle = mergeTableStyles(named.tableStyle, table.style);
3957
+ const row = table.rows[rowIndex];
3958
+ const cell = row == null ? void 0 : row.cells[cellIndex];
3959
+ const keys = conditionalKeys({
3960
+ rowIndex,
3961
+ columnIndex: visualColumnIndex,
3962
+ rowCount: table.rows.length,
3963
+ columnCount,
3964
+ tableStyle: baseTableStyle,
3965
+ rowFlags: row == null ? void 0 : row.conditionalStyle,
3966
+ cellFlags: cell == null ? void 0 : cell.conditionalStyle
3967
+ });
3968
+ const conditional = mergeConditionals(
3969
+ keys,
3970
+ baseTableStyle.conditionalFormats
3971
+ );
3972
+ const conditionalCell = {
3973
+ ...((_b = baseTableStyle.defaultCellMargins) == null ? void 0 : _b.top) !== void 0 ? { paddingTop: baseTableStyle.defaultCellMargins.top } : {},
3974
+ ...((_c = baseTableStyle.defaultCellMargins) == null ? void 0 : _c.right) !== void 0 ? { paddingRight: baseTableStyle.defaultCellMargins.right } : {},
3975
+ ...((_d = baseTableStyle.defaultCellMargins) == null ? void 0 : _d.bottom) !== void 0 ? { paddingBottom: baseTableStyle.defaultCellMargins.bottom } : {},
3976
+ ...((_e = baseTableStyle.defaultCellMargins) == null ? void 0 : _e.left) !== void 0 ? { paddingLeft: baseTableStyle.defaultCellMargins.left } : {},
3977
+ ...((_f = baseTableStyle.defaultCellMargins) == null ? void 0 : _f.start) !== void 0 ? { paddingStart: baseTableStyle.defaultCellMargins.start } : {},
3978
+ ...((_g = baseTableStyle.defaultCellMargins) == null ? void 0 : _g.end) !== void 0 ? { paddingEnd: baseTableStyle.defaultCellMargins.end } : {},
3979
+ ...rowIndex === 0 && ((_h = baseTableStyle.borders) == null ? void 0 : _h.borderTop) ? { borderTop: baseTableStyle.borders.borderTop } : rowIndex > 0 && ((_i = baseTableStyle.borders) == null ? void 0 : _i.borderInsideH) ? { borderTop: baseTableStyle.borders.borderInsideH } : {},
3980
+ ...rowIndex === table.rows.length - 1 && ((_j = baseTableStyle.borders) == null ? void 0 : _j.borderBottom) ? { borderBottom: baseTableStyle.borders.borderBottom } : rowIndex < table.rows.length - 1 && ((_k = baseTableStyle.borders) == null ? void 0 : _k.borderInsideH) ? { borderBottom: baseTableStyle.borders.borderInsideH } : {},
3981
+ ...visualColumnIndex === 0 && ((_l = baseTableStyle.borders) == null ? void 0 : _l.borderLeft) ? { borderLeft: baseTableStyle.borders.borderLeft } : visualColumnIndex > 0 && ((_m = baseTableStyle.borders) == null ? void 0 : _m.borderInsideV) ? { borderLeft: baseTableStyle.borders.borderInsideV } : {},
3982
+ ...visualColumnIndex === columnCount - 1 && ((_n = baseTableStyle.borders) == null ? void 0 : _n.borderRight) ? { borderRight: baseTableStyle.borders.borderRight } : visualColumnIndex < columnCount - 1 && ((_o = baseTableStyle.borders) == null ? void 0 : _o.borderInsideV) ? { borderRight: baseTableStyle.borders.borderInsideV } : {},
3983
+ ...conditional.cellStyle ?? {},
3984
+ ...conditional.borders ?? {},
3985
+ ...conditional.shading ? { shading: conditional.shading } : {}
3986
+ };
3987
+ return {
3988
+ tableStyle: mergeTableStyles(baseTableStyle, conditional.tableStyle),
3989
+ rowStyle: { ...conditional.rowStyle ?? {}, ...(row == null ? void 0 : row.style) ?? {} },
3990
+ cellStyle: { ...conditionalCell, ...(cell == null ? void 0 : cell.style) ?? {} },
3991
+ paragraphStyle: {
3992
+ ...named.paragraphStyle ?? {},
3993
+ ...conditional.paragraphStyle ?? {}
3994
+ },
3995
+ textStyle: {
3996
+ ...named.textStyle ?? {},
3997
+ ...conditional.textStyle ?? {}
3998
+ },
3999
+ conditionalKeys: keys
4000
+ };
4001
+ }
3774
4002
  function findParagraphIndex(paragraphs, paragraphId) {
3775
4003
  const index = paragraphs.findIndex(
3776
4004
  (paragraph) => paragraph.id === paragraphId
@@ -4766,7 +4994,7 @@ function ToolIcon(props) {
4766
4994
  children: (render2) => render2()()
4767
4995
  });
4768
4996
  }
4769
- var _tmpl$$P = /* @__PURE__ */ template(`<div class=oasis-menubar role=menubar>`), _tmpl$2$y = /* @__PURE__ */ template(`<div class=oasis-menubar-dropdown role=menu>`), _tmpl$3$m = /* @__PURE__ */ template(`<div class=oasis-menubar-menu><div class=oasis-menubar-button role=menuitem aria-haspopup=true>`), _tmpl$4$g = /* @__PURE__ */ template(`<div class=oasis-menubar-separator role=separator>`), _tmpl$5$e = /* @__PURE__ */ template(`<span class=oasis-menubar-item-icon aria-hidden=true>`), _tmpl$6$7 = /* @__PURE__ */ template(`<span class=oasis-menubar-shortcut>`), _tmpl$7$3 = /* @__PURE__ */ template(`<i class=oasis-menubar-submenu-icon data-lucide=chevron-right>`), _tmpl$8$2 = /* @__PURE__ */ template(`<div class=oasis-menubar-submenu role=menu>`), _tmpl$9$1 = /* @__PURE__ */ template(`<div class=oasis-menubar-item role=menuitem><span class=oasis-menubar-item-main><span>`);
4997
+ var _tmpl$$P = /* @__PURE__ */ template(`<div class=oasis-menubar role=menubar>`), _tmpl$2$y = /* @__PURE__ */ template(`<div class=oasis-menubar-dropdown role=menu>`), _tmpl$3$m = /* @__PURE__ */ template(`<div class=oasis-menubar-menu><div class=oasis-menubar-button role=menuitem aria-haspopup=true>`), _tmpl$4$h = /* @__PURE__ */ template(`<div class=oasis-menubar-separator role=separator>`), _tmpl$5$e = /* @__PURE__ */ template(`<span class=oasis-menubar-item-icon aria-hidden=true>`), _tmpl$6$7 = /* @__PURE__ */ template(`<span class=oasis-menubar-shortcut>`), _tmpl$7$3 = /* @__PURE__ */ template(`<i class=oasis-menubar-submenu-icon data-lucide=chevron-right>`), _tmpl$8$2 = /* @__PURE__ */ template(`<div class=oasis-menubar-submenu role=menu>`), _tmpl$9$1 = /* @__PURE__ */ template(`<div class=oasis-menubar-item role=menuitem><span class=oasis-menubar-item-main><span>`);
4770
4998
  function Menubar(props) {
4771
4999
  const t = useI18n();
4772
5000
  const [activeMenu, setActiveMenu] = createSignal(null);
@@ -4900,7 +5128,7 @@ function MenuNode(props) {
4900
5128
  } = props;
4901
5129
  const isSeparator = (_a = node.item) == null ? void 0 : _a.separator;
4902
5130
  if (isSeparator) {
4903
- return _tmpl$4$g();
5131
+ return _tmpl$4$h();
4904
5132
  }
4905
5133
  const hasChildren = node.children.length > 0;
4906
5134
  const [showSub, setShowSub] = createSignal(false);
@@ -11830,7 +12058,7 @@ function emuToPx$1(value) {
11830
12058
  function clampFinite(value, fallback) {
11831
12059
  return Number.isFinite(value) ? value : fallback;
11832
12060
  }
11833
- function resolveAlignedOffset(align, containerSize, boxSize) {
12061
+ function resolveAlignedOffset(align, containerSize, boxSize, pageIndex = 0) {
11834
12062
  switch (align) {
11835
12063
  case "left":
11836
12064
  case "top":
@@ -11841,10 +12069,52 @@ function resolveAlignedOffset(align, containerSize, boxSize) {
11841
12069
  case "right":
11842
12070
  case "bottom":
11843
12071
  return containerSize - boxSize;
12072
+ case "inside":
12073
+ return pageIndex % 2 === 0 ? 0 : containerSize - boxSize;
12074
+ case "outside":
12075
+ return pageIndex % 2 === 0 ? containerSize - boxSize : 0;
11844
12076
  default:
11845
12077
  return null;
11846
12078
  }
11847
12079
  }
12080
+ function resolveFloatingTableRect(options) {
12081
+ const {
12082
+ floating,
12083
+ pageSettings,
12084
+ contentLeft,
12085
+ contentTop,
12086
+ contentWidth,
12087
+ anchorTop,
12088
+ width,
12089
+ height,
12090
+ pageIndex
12091
+ } = options;
12092
+ const horizontalPage = floating.horizontalAnchor === "page";
12093
+ const verticalPage = floating.verticalAnchor === "page";
12094
+ const verticalMargin = floating.verticalAnchor === "margin";
12095
+ const hBase = horizontalPage ? 0 : contentLeft;
12096
+ const hSize = horizontalPage ? pageSettings.width : contentWidth;
12097
+ const vBase = verticalPage ? 0 : verticalMargin ? contentTop : anchorTop;
12098
+ const vSize = verticalPage ? pageSettings.height : verticalMargin ? Math.max(1, pageSettings.height - contentTop) : Math.max(1, pageSettings.height - anchorTop);
12099
+ const alignedX = resolveAlignedOffset(
12100
+ floating.xAlign,
12101
+ hSize,
12102
+ width,
12103
+ pageIndex
12104
+ );
12105
+ const alignedY = resolveAlignedOffset(
12106
+ floating.yAlign,
12107
+ vSize,
12108
+ height,
12109
+ pageIndex
12110
+ );
12111
+ return {
12112
+ x: hBase + (alignedX ?? (floating.x ?? 0) * PX_PER_POINT),
12113
+ y: vBase + (alignedY ?? (floating.y ?? 0) * PX_PER_POINT),
12114
+ width: Math.max(1, width),
12115
+ height: Math.max(1, height)
12116
+ };
12117
+ }
11848
12118
  function getTextBoxFloatingGeometry(textBox, heightOverride) {
11849
12119
  return {
11850
12120
  width: textBox.width,
@@ -12168,7 +12438,7 @@ function projectParagraphLayout(paragraph, pageIndex, totalPages, styles, conten
12168
12438
  cacheForParagraph.set(cacheKey, result);
12169
12439
  return result;
12170
12440
  }
12171
- function projectParagraphLayoutWithExclusions(paragraph, pageSettings, contentWidth, measurer = domTextMeasurer, pageIndex, totalPages, styles, defaultTabStop, resolveTextBoxHeight) {
12441
+ function projectParagraphLayoutWithExclusions(paragraph, pageSettings, contentWidth, measurer = domTextMeasurer, pageIndex, totalPages, styles, defaultTabStop, resolveTextBoxHeight, externalExclusions = []) {
12172
12442
  const preliminary = projectParagraphLayout(
12173
12443
  paragraph,
12174
12444
  pageIndex,
@@ -12187,7 +12457,7 @@ function projectParagraphLayoutWithExclusions(paragraph, pageSettings, contentWi
12187
12457
  return (((_a = f.textBox) == null ? void 0 : _a.floating) ?? ((_b = f.image) == null ? void 0 : _b.floating)) !== void 0;
12188
12458
  }
12189
12459
  );
12190
- if (!hasFloatingObject && !paragraph.dropCap) {
12460
+ if (!hasFloatingObject && !paragraph.dropCap && externalExclusions.length === 0) {
12191
12461
  return preliminary;
12192
12462
  }
12193
12463
  const fontSize = estimateParagraphFontSize(paragraph, styles);
@@ -12199,6 +12469,7 @@ function projectParagraphLayoutWithExclusions(paragraph, pageSettings, contentWi
12199
12469
  contentWidth,
12200
12470
  resolveTextBoxHeight
12201
12471
  }) : [];
12472
+ exclusions.push(...externalExclusions);
12202
12473
  if (paragraph.dropCap) {
12203
12474
  const dropCapExclusion = resolveDropCapExclusion({
12204
12475
  dropCap: paragraph.dropCap,
@@ -12624,12 +12895,65 @@ function getCachedTableColumnGeometry(table, contentWidthPx) {
12624
12895
  }
12625
12896
  function estimateTableRowHeight(row, styles, measurer, defaultTabStop, contentWidth, table, rowIndex) {
12626
12897
  var _a, _b;
12627
- if ((_a = row.style) == null ? void 0 : _a.hidden) {
12898
+ const tableEntries = table ? buildTableCellLayout(table) : [];
12899
+ const columnCount = Math.max(
12900
+ 1,
12901
+ ...tableEntries.map(
12902
+ (entry) => entry.visualColumnIndex + Math.max(1, entry.colSpan)
12903
+ )
12904
+ );
12905
+ const rowFormatting = table && rowIndex !== void 0 ? (() => {
12906
+ const entry = tableEntries.find(
12907
+ (candidate) => candidate.rowIndex === rowIndex
12908
+ );
12909
+ return entry ? resolveEffectiveTableCellFormatting({
12910
+ table,
12911
+ rowIndex,
12912
+ cellIndex: entry.cellIndex,
12913
+ visualColumnIndex: entry.visualColumnIndex,
12914
+ columnCount,
12915
+ styles
12916
+ }) : void 0;
12917
+ })() : void 0;
12918
+ if ((_a = (rowFormatting == null ? void 0 : rowFormatting.rowStyle) ?? row.style) == null ? void 0 : _a.hidden) {
12628
12919
  return 0;
12629
12920
  }
12630
12921
  const geometry = table && typeof contentWidth === "number" ? getCachedTableColumnGeometry(table, contentWidth) : null;
12631
- const cellHeights = row.cells.map((cell, cellIndex) => {
12922
+ const cellHeights = row.cells.map((sourceCell, cellIndex) => {
12632
12923
  var _a2;
12924
+ const entry = rowIndex !== void 0 ? tableEntries.find(
12925
+ (candidate) => candidate.rowIndex === rowIndex && candidate.cellIndex === cellIndex
12926
+ ) : void 0;
12927
+ const formatting = table && rowIndex !== void 0 && entry ? resolveEffectiveTableCellFormatting({
12928
+ table,
12929
+ rowIndex,
12930
+ cellIndex,
12931
+ visualColumnIndex: entry.visualColumnIndex,
12932
+ columnCount,
12933
+ styles
12934
+ }) : void 0;
12935
+ const cell = {
12936
+ ...sourceCell,
12937
+ style: (formatting == null ? void 0 : formatting.cellStyle) ?? sourceCell.style,
12938
+ blocks: sourceCell.blocks.map((paragraph) => {
12939
+ var _a3;
12940
+ return {
12941
+ ...paragraph,
12942
+ style: {
12943
+ ...resolveTableParagraphInheritance(
12944
+ formatting == null ? void 0 : formatting.paragraphStyle,
12945
+ (_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
12946
+ styles
12947
+ ),
12948
+ ...paragraph.style
12949
+ },
12950
+ runs: paragraph.runs.map((run) => ({
12951
+ ...run,
12952
+ styles: { ...formatting == null ? void 0 : formatting.textStyle, ...run.styles }
12953
+ }))
12954
+ };
12955
+ })
12956
+ };
12633
12957
  if (cell.vMerge === "continue") return 0;
12634
12958
  let columnWidthPx;
12635
12959
  if (geometry && typeof rowIndex === "number") {
@@ -12686,13 +13010,16 @@ function estimateTableRowHeight(row, styles, measurer, defaultTabStop, contentWi
12686
13010
  ...cellHeights,
12687
13011
  DEFAULT_FONT_SIZE$1 * DEFAULT_LINE_HEIGHT
12688
13012
  );
12689
- const explicitHeight = parseTableRowHeightToPx((_b = row.style) == null ? void 0 : _b.height);
13013
+ const explicitHeight = parseTableRowHeightToPx(
13014
+ (_b = (rowFormatting == null ? void 0 : rowFormatting.rowStyle) ?? row.style) == null ? void 0 : _b.height
13015
+ );
12690
13016
  return Math.max(contentHeight, explicitHeight ?? 0) + DEFAULT_TABLE_ROW_VERTICAL_SPACING;
12691
13017
  }
12692
13018
  function getTableHeaderRowCount(table) {
13019
+ var _a;
12693
13020
  let count = 0;
12694
13021
  for (const row of table.rows) {
12695
- if (!row.isHeader) {
13022
+ if (!(((_a = row.style) == null ? void 0 : _a.isHeader) ?? row.isHeader)) {
12696
13023
  break;
12697
13024
  }
12698
13025
  count += 1;
@@ -12801,6 +13128,7 @@ function projectHeaderFooterBlocksWithDependencies(blocks, deps, context2 = {})
12801
13128
  defaultTabStop
12802
13129
  } = context2;
12803
13130
  return blocks.map((block, index) => {
13131
+ var _a, _b;
12804
13132
  if (block.type === "paragraph") {
12805
13133
  const layout = deps.projectParagraphLayout(
12806
13134
  block,
@@ -12822,18 +13150,20 @@ function projectHeaderFooterBlocksWithDependencies(blocks, deps, context2 = {})
12822
13150
  sourceBlock: block
12823
13151
  };
12824
13152
  }
13153
+ const tableHeight = (measuredHeights == null ? void 0 : measuredHeights[block.id]) ?? deps.estimateTableBlockHeight(
13154
+ block,
13155
+ styles,
13156
+ contentWidth,
13157
+ measurer,
13158
+ defaultTabStop
13159
+ );
12825
13160
  return {
12826
13161
  blockId: block.id,
12827
13162
  sourceBlockId: block.id,
12828
13163
  blockType: block.type,
12829
13164
  globalIndex: index,
12830
- estimatedHeight: (measuredHeights == null ? void 0 : measuredHeights[block.id]) ?? deps.estimateTableBlockHeight(
12831
- block,
12832
- styles,
12833
- contentWidth,
12834
- measurer,
12835
- defaultTabStop
12836
- ),
13165
+ estimatedHeight: ((_a = block.style) == null ? void 0 : _a.floating) ? 0 : tableHeight,
13166
+ floatingTableHeight: ((_b = block.style) == null ? void 0 : _b.floating) ? tableHeight : void 0,
12837
13167
  sourceBlock: block
12838
13168
  };
12839
13169
  });
@@ -12933,6 +13263,7 @@ class PaginationTrack {
12933
13263
  __publicField(this, "pages");
12934
13264
  __publicField(this, "blocks");
12935
13265
  __publicField(this, "height");
13266
+ __publicField(this, "floatingExclusions", []);
12936
13267
  this.pageOffset = pageOffset;
12937
13268
  this.maxPageHeight = maxPageHeight;
12938
13269
  this.reservedHeightByPageIndex = reservedHeightByPageIndex;
@@ -12977,6 +13308,7 @@ class PaginationTrack {
12977
13308
  });
12978
13309
  this.blocks = [];
12979
13310
  this.height = 0;
13311
+ this.floatingExclusions = [];
12980
13312
  }
12981
13313
  /** Flushes the trailing track and guarantees at least one page exists. */
12982
13314
  finalize() {
@@ -12996,6 +13328,21 @@ class PaginationTrack {
12996
13328
  }
12997
13329
  }
12998
13330
  const TEXT_BOX_AUTOFIT_SAFETY_PX$1 = 2;
13331
+ function registerParagraphFloatingExclusions(options) {
13332
+ const exclusions = collectParagraphFloatingExclusions({
13333
+ fragments: options.layout.fragments,
13334
+ preliminaryLines: options.layout.lines,
13335
+ pageSettings: options.params.pageSettings,
13336
+ contentWidth: options.params.contentWidth,
13337
+ resolveTextBoxHeight: options.resolveTextBoxHeight
13338
+ });
13339
+ options.track.floatingExclusions.push(
13340
+ ...exclusions.map((exclusion) => ({
13341
+ ...exclusion,
13342
+ y: exclusion.y + options.blockTop
13343
+ }))
13344
+ );
13345
+ }
12999
13346
  function estimateTextBoxAutoFitHeight(textBox, styles, measurer, pageIndex, totalPages, defaultTabStop) {
13000
13347
  var _a, _b, _c, _d, _e;
13001
13348
  if (!((_a = textBox.body) == null ? void 0 : _a.autoFit)) {
@@ -13052,6 +13399,14 @@ function paginateParagraphBlock(track, params, sourceBlock, nextBlock, index) {
13052
13399
  measuredParagraphLayouts
13053
13400
  } = params;
13054
13401
  const pageIndex = track.pageIndex;
13402
+ const resolveTextBoxHeight = (textBox) => estimateTextBoxAutoFitHeight(
13403
+ textBox,
13404
+ styles,
13405
+ measurer,
13406
+ pageIndex,
13407
+ totalPages,
13408
+ defaultTabStop
13409
+ );
13055
13410
  const projectedParagraphLayout = projectParagraphLayoutWithExclusions(
13056
13411
  sourceBlock,
13057
13412
  pageSettings,
@@ -13061,14 +13416,11 @@ function paginateParagraphBlock(track, params, sourceBlock, nextBlock, index) {
13061
13416
  totalPages,
13062
13417
  styles,
13063
13418
  defaultTabStop,
13064
- (textBox) => estimateTextBoxAutoFitHeight(
13065
- textBox,
13066
- styles,
13067
- measurer,
13068
- pageIndex,
13069
- totalPages,
13070
- defaultTabStop
13071
- )
13419
+ resolveTextBoxHeight,
13420
+ track.floatingExclusions.map((exclusion) => ({
13421
+ ...exclusion,
13422
+ y: exclusion.y - track.height
13423
+ }))
13072
13424
  );
13073
13425
  const measuredParagraphLayout = measuredParagraphLayouts == null ? void 0 : measuredParagraphLayouts[sourceBlock.id];
13074
13426
  const paragraphLayout = measuredParagraphLayout && isMeasuredLayoutCurrent(projectedParagraphLayout, measuredParagraphLayout) ? applyMeasuredLineGeometry(
@@ -13150,6 +13502,13 @@ function paginateParagraphBlock(track, params, sourceBlock, nextBlock, index) {
13150
13502
  sourceBlock
13151
13503
  });
13152
13504
  track.height += measuredHeight;
13505
+ registerParagraphFloatingExclusions({
13506
+ track,
13507
+ layout: paragraphLayout,
13508
+ blockTop: track.height - measuredHeight + (paragraphStyle.spacingBefore ?? 0),
13509
+ params,
13510
+ resolveTextBoxHeight
13511
+ });
13153
13512
  return;
13154
13513
  }
13155
13514
  let startLineIndex = 0;
@@ -13261,6 +13620,15 @@ function paginateParagraphBlock(track, params, sourceBlock, nextBlock, index) {
13261
13620
  sourceBlock
13262
13621
  });
13263
13622
  track.height += measuredHeight;
13623
+ if (startLineIndex === 0) {
13624
+ registerParagraphFloatingExclusions({
13625
+ track,
13626
+ layout: segmentLayout,
13627
+ blockTop: track.height - measuredHeight + (paragraphStyle.spacingBefore ?? 0),
13628
+ params,
13629
+ resolveTextBoxHeight
13630
+ });
13631
+ }
13264
13632
  startLineIndex = lineEndIndex;
13265
13633
  segmentIndex += 1;
13266
13634
  if (startLineIndex < paragraphLayout.lines.length) {
@@ -13453,7 +13821,21 @@ function positionsFinishedRow(row, ends) {
13453
13821
  }
13454
13822
  );
13455
13823
  }
13824
+ function resolveFloatingTableWidth(table, contentWidth) {
13825
+ var _a, _b;
13826
+ const width = (_a = table.style) == null ? void 0 : _a.width;
13827
+ if (typeof width === "number") return width * PX_PER_POINT;
13828
+ if (typeof width === "string" && width.endsWith("%")) {
13829
+ const percent = Number.parseFloat(width);
13830
+ if (Number.isFinite(percent)) return contentWidth * (percent / 100);
13831
+ }
13832
+ if ((_b = table.gridCols) == null ? void 0 : _b.length) {
13833
+ return table.gridCols.reduce((sum, value) => sum + value, 0) * PX_PER_POINT;
13834
+ }
13835
+ return contentWidth;
13836
+ }
13456
13837
  function paginateTableBlock(track, params, sourceBlock, index) {
13838
+ var _a;
13457
13839
  const { contentWidth, measurer, styles, defaultTabStop, measuredHeights } = params;
13458
13840
  const tableHeight = (measuredHeights == null ? void 0 : measuredHeights[sourceBlock.id]) ?? estimateTableBlockHeight(
13459
13841
  sourceBlock,
@@ -13462,6 +13844,60 @@ function paginateTableBlock(track, params, sourceBlock, index) {
13462
13844
  measurer,
13463
13845
  defaultTabStop
13464
13846
  );
13847
+ if ((_a = sourceBlock.style) == null ? void 0 : _a.floating) {
13848
+ track.blocks.push({
13849
+ blockId: sourceBlock.id,
13850
+ sourceBlockId: sourceBlock.id,
13851
+ blockType: sourceBlock.type,
13852
+ globalIndex: index,
13853
+ estimatedHeight: 0,
13854
+ floatingTableHeight: tableHeight,
13855
+ sourceBlock
13856
+ });
13857
+ const pageContentLeft = params.pageSettings.margins.left + params.pageSettings.margins.gutter;
13858
+ const pageContentTop = getPageBodyTop(params.pageSettings);
13859
+ const raw = resolveFloatingTableRect({
13860
+ floating: sourceBlock.style.floating,
13861
+ pageSettings: params.pageSettings,
13862
+ contentLeft: pageContentLeft,
13863
+ contentTop: pageContentTop,
13864
+ contentWidth,
13865
+ anchorTop: pageContentTop + track.height,
13866
+ width: resolveFloatingTableWidth(sourceBlock, contentWidth),
13867
+ height: tableHeight,
13868
+ pageIndex: track.pageIndex
13869
+ });
13870
+ const exclusion = {
13871
+ x: raw.x - pageContentLeft - (sourceBlock.style.floating.distanceLeft ?? 0) * PX_PER_POINT,
13872
+ y: raw.y - pageContentTop - (sourceBlock.style.floating.distanceTop ?? 0) * PX_PER_POINT,
13873
+ width: raw.width + ((sourceBlock.style.floating.distanceLeft ?? 0) + (sourceBlock.style.floating.distanceRight ?? 0)) * PX_PER_POINT,
13874
+ height: raw.height + ((sourceBlock.style.floating.distanceTop ?? 0) + (sourceBlock.style.floating.distanceBottom ?? 0)) * PX_PER_POINT,
13875
+ wrap: "square",
13876
+ sourceRunId: `table:${sourceBlock.id}`
13877
+ };
13878
+ let collisionOffsetY = 0;
13879
+ if (sourceBlock.style.tblOverlap === "never") {
13880
+ for (const existing of track.floatingExclusions) {
13881
+ if (!existing.sourceRunId.startsWith("table:")) continue;
13882
+ const overlaps = exclusion.x < existing.x + existing.width && exclusion.x + exclusion.width > existing.x && exclusion.y + collisionOffsetY < existing.y + existing.height && exclusion.y + collisionOffsetY + exclusion.height > existing.y;
13883
+ if (overlaps) {
13884
+ collisionOffsetY = Math.max(
13885
+ collisionOffsetY,
13886
+ existing.y + existing.height - exclusion.y
13887
+ );
13888
+ }
13889
+ }
13890
+ }
13891
+ const layoutBlock = track.blocks.at(-1);
13892
+ if (layoutBlock && collisionOffsetY > 0) {
13893
+ layoutBlock.floatingTableOffsetY = collisionOffsetY;
13894
+ }
13895
+ track.floatingExclusions.push({
13896
+ ...exclusion,
13897
+ y: exclusion.y + collisionOffsetY
13898
+ });
13899
+ return;
13900
+ }
13465
13901
  const maxHeightForCurrentPage = track.currentMaxHeight;
13466
13902
  const firstRow = sourceBlock.rows[0];
13467
13903
  const canSplitSingleRow = canSplitTableRow(firstRow);
@@ -14705,7 +15141,7 @@ function parseDimensionToPx(value) {
14705
15141
  const parsed = Number.parseFloat(trimmed);
14706
15142
  return Number.isFinite(parsed) ? parsed : null;
14707
15143
  }
14708
- function resolveTableWidth(table, contentWidth) {
15144
+ function resolveCanvasTableWidth(table, contentWidth) {
14709
15145
  var _a;
14710
15146
  const raw = (_a = table.style) == null ? void 0 : _a.width;
14711
15147
  if (typeof raw === "number") return Math.max(24, toPx(raw));
@@ -14784,9 +15220,9 @@ function resolveVerticalContentOffset(cell, contentHeightPx, contentNaturalHeigh
14784
15220
  return 0;
14785
15221
  }
14786
15222
  function buildCanvasTableLayout(options) {
14787
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
15223
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
14788
15224
  const {
14789
- table,
15225
+ table: sourceTable,
14790
15226
  state,
14791
15227
  pageIndex,
14792
15228
  originX,
@@ -14794,7 +15230,11 @@ function buildCanvasTableLayout(options) {
14794
15230
  contentWidth,
14795
15231
  estimatedHeight
14796
15232
  } = options;
14797
- const tableWidth = resolveTableWidth(table, contentWidth);
15233
+ const table = {
15234
+ ...sourceTable,
15235
+ style: resolveEffectiveTableStyle(sourceTable, state.document.styles)
15236
+ };
15237
+ const tableWidth = resolveCanvasTableWidth(table, contentWidth);
14798
15238
  const tableLeft = originX + resolveTableIndentLeft(table);
14799
15239
  const tableEntries = buildTableCellLayout(table);
14800
15240
  const unsupported = [];
@@ -14842,15 +15282,62 @@ function buildCanvasTableLayout(options) {
14842
15282
  (entry) => [`${entry.rowIndex}:${entry.cellIndex}`, entry]
14843
15283
  )
14844
15284
  );
15285
+ const effectiveRowStyles = table.rows.map((row, rowIndex) => {
15286
+ const entry = tableEntries.find(
15287
+ (candidate) => candidate.rowIndex === rowIndex
15288
+ );
15289
+ return entry ? resolveEffectiveTableCellFormatting({
15290
+ table: sourceTable,
15291
+ rowIndex,
15292
+ cellIndex: entry.cellIndex,
15293
+ visualColumnIndex: entry.visualColumnIndex,
15294
+ columnCount: visualColumnCount,
15295
+ styles: state.document.styles
15296
+ }).rowStyle : row.style;
15297
+ });
14845
15298
  const prepared = [];
14846
15299
  for (let rowIndex = 0; rowIndex < table.rows.length; rowIndex += 1) {
14847
15300
  const row = table.rows[rowIndex];
14848
- if ((_f = row.style) == null ? void 0 : _f.hidden) {
15301
+ if ((_f = effectiveRowStyles[rowIndex]) == null ? void 0 : _f.hidden) {
14849
15302
  continue;
14850
15303
  }
14851
15304
  for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
14852
- const cell = row.cells[cellIndex];
15305
+ const sourceCell = row.cells[cellIndex];
14853
15306
  const entry = cellEntriesByKey.get(`${rowIndex}:${cellIndex}`);
15307
+ if (!entry) {
15308
+ continue;
15309
+ }
15310
+ const formatting = resolveEffectiveTableCellFormatting({
15311
+ table: sourceTable,
15312
+ rowIndex,
15313
+ cellIndex,
15314
+ visualColumnIndex: entry.visualColumnIndex,
15315
+ columnCount: visualColumnCount,
15316
+ styles: state.document.styles
15317
+ });
15318
+ const cell = {
15319
+ ...sourceCell,
15320
+ style: formatting.cellStyle,
15321
+ blocks: sourceCell.blocks.map((paragraph) => {
15322
+ var _a2;
15323
+ return {
15324
+ ...paragraph,
15325
+ style: {
15326
+ ...resolveTableParagraphInheritance(
15327
+ formatting.paragraphStyle,
15328
+ (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
15329
+ state.document.styles
15330
+ ),
15331
+ ...paragraph.style
15332
+ },
15333
+ runs: paragraph.runs.map((run) => ({
15334
+ ...run,
15335
+ styles: { ...formatting.textStyle, ...run.styles }
15336
+ }))
15337
+ };
15338
+ })
15339
+ };
15340
+ const effectiveRow = formatting.rowStyle;
14854
15341
  const rowSpan = Math.max(1, cell.rowSpan ?? 1);
14855
15342
  if (rowSpan > 1) {
14856
15343
  unsupported.push("unsupported:v-span");
@@ -14858,9 +15345,6 @@ function buildCanvasTableLayout(options) {
14858
15345
  if (cell.vMerge === "continue" || cell.vMerge === "restart") {
14859
15346
  unsupported.push("unsupported:v-merge");
14860
15347
  }
14861
- if (!entry) {
14862
- continue;
14863
- }
14864
15348
  const visualCol = entry.visualColumnIndex;
14865
15349
  const colSpan = Math.max(1, entry.colSpan);
14866
15350
  const width = Math.max(
@@ -14868,11 +15352,23 @@ function buildCanvasTableLayout(options) {
14868
15352
  (columnOffsets[visualCol + colSpan] ?? tableWidth) - (columnOffsets[visualCol] ?? 0)
14869
15353
  );
14870
15354
  const padding = resolveCellPadding(cell);
15355
+ const logicalLeft = ((_g = table.style) == null ? void 0 : _g.bidiVisual) ? (_h = cell.style) == null ? void 0 : _h.borderEnd : (_i = cell.style) == null ? void 0 : _i.borderStart;
15356
+ const logicalRight = ((_j = table.style) == null ? void 0 : _j.bidiVisual) ? (_k = cell.style) == null ? void 0 : _k.borderStart : (_l = cell.style) == null ? void 0 : _l.borderEnd;
14871
15357
  const borders = {
14872
- top: resolveBorder((_g = cell.style) == null ? void 0 : _g.borderTop),
14873
- right: resolveBorder(((_h = cell.style) == null ? void 0 : _h.borderRight) ?? ((_i = cell.style) == null ? void 0 : _i.borderEnd)),
14874
- bottom: resolveBorder((_j = cell.style) == null ? void 0 : _j.borderBottom),
14875
- left: resolveBorder(((_k = cell.style) == null ? void 0 : _k.borderLeft) ?? ((_l = cell.style) == null ? void 0 : _l.borderStart))
15358
+ top: resolveBorder((_m = cell.style) == null ? void 0 : _m.borderTop),
15359
+ right: resolveBorder(((_n = cell.style) == null ? void 0 : _n.borderRight) ?? logicalRight),
15360
+ bottom: resolveBorder((_o = cell.style) == null ? void 0 : _o.borderBottom),
15361
+ left: resolveBorder(((_p = cell.style) == null ? void 0 : _p.borderLeft) ?? logicalLeft),
15362
+ ...((_q = cell.style) == null ? void 0 : _q.borderTopLeftToBottomRight) ? {
15363
+ topLeftToBottomRight: resolveBorder(
15364
+ cell.style.borderTopLeftToBottomRight
15365
+ )
15366
+ } : {},
15367
+ ...((_r = cell.style) == null ? void 0 : _r.borderTopRightToBottomLeft) ? {
15368
+ topRightToBottomLeft: resolveBorder(
15369
+ cell.style.borderTopRightToBottomLeft
15370
+ )
15371
+ } : {}
14876
15372
  };
14877
15373
  const contentWidthPx = Math.max(
14878
15374
  MIN_TABLE_CELL_CONTENT_WIDTH_PX,
@@ -14881,8 +15377,8 @@ function buildCanvasTableLayout(options) {
14881
15377
  const verticalMode = resolveCellVerticalMode(cell);
14882
15378
  const isRotated = verticalMode === "rotate-cw" || verticalMode === "rotate-ccw";
14883
15379
  const isStacked = verticalMode === "stack";
14884
- const explicitRowHeightPx = parseDimensionToPx((_m = row.style) == null ? void 0 : _m.height);
14885
- const wrapWidth = isRotated || ((_n = cell.style) == null ? void 0 : _n.noWrap) ? isRotated && explicitRowHeightPx !== null && explicitRowHeightPx > 0 ? Math.max(
15380
+ const explicitRowHeightPx = parseDimensionToPx(effectiveRow.height);
15381
+ const wrapWidth = isRotated || ((_s = cell.style) == null ? void 0 : _s.noWrap) ? isRotated && explicitRowHeightPx !== null && explicitRowHeightPx > 0 ? Math.max(
14886
15382
  MIN_TABLE_CELL_CONTENT_WIDTH_PX,
14887
15383
  explicitRowHeightPx - borders.top.width - borders.bottom.width - padding.top - padding.bottom
14888
15384
  ) : NO_WRAP_WIDTH_PX : contentWidthPx;
@@ -14906,7 +15402,7 @@ function buildCanvasTableLayout(options) {
14906
15402
  spacingAfter
14907
15403
  });
14908
15404
  const hasExplicitRowHeight = explicitRowHeightPx !== null && explicitRowHeightPx > 0;
14909
- const paragraphStyleSize = ((_p = (_o = paragraph.runs[0]) == null ? void 0 : _o.styles) == null ? void 0 : _p.fontSize) ?? 14.6667;
15405
+ const paragraphStyleSize = ((_u = (_t = paragraph.runs[0]) == null ? void 0 : _t.styles) == null ? void 0 : _u.fontSize) ?? 14.6667;
14910
15406
  contentNaturalHeightPx = Math.max(
14911
15407
  contentNaturalHeightPx,
14912
15408
  hasExplicitRowHeight ? paragraphStyleSize * 1.25 : stackLength
@@ -14920,7 +15416,7 @@ function buildCanvasTableLayout(options) {
14920
15416
  state.document.styles,
14921
15417
  wrapWidth,
14922
15418
  void 0,
14923
- (_q = state.document.settings) == null ? void 0 : _q.defaultTabStop
15419
+ (_v = state.document.settings) == null ? void 0 : _v.defaultTabStop
14924
15420
  );
14925
15421
  const linesBottom = projected.lines.length > 0 ? Math.max(...projected.lines.map((line) => line.top + line.height)) : 1;
14926
15422
  let effectiveSpacingBefore = spacingBefore;
@@ -14987,17 +15483,18 @@ function buildCanvasTableLayout(options) {
14987
15483
  }
14988
15484
  const rowCount = Math.max(1, table.rows.length);
14989
15485
  const explicitRowHeights = table.rows.map((row) => {
14990
- var _a2, _b2;
14991
- if ((_a2 = row.style) == null ? void 0 : _a2.hidden) {
15486
+ const rowIndex = table.rows.indexOf(row);
15487
+ const effective = effectiveRowStyles[rowIndex];
15488
+ if (effective == null ? void 0 : effective.hidden) {
14992
15489
  return 0;
14993
15490
  }
14994
- const explicit = parseDimensionToPx((_b2 = row.style) == null ? void 0 : _b2.height);
15491
+ const explicit = parseDimensionToPx(effective == null ? void 0 : effective.height);
14995
15492
  return explicit !== null && explicit > 0 ? explicit : null;
14996
15493
  });
14997
15494
  const fallbackPerRow = estimatedHeight > 0 ? estimatedHeight / rowCount : DEFAULT_TABLE_ROW_HEIGHT;
14998
15495
  const rowHeights = [];
14999
15496
  for (let rowIndex = 0; rowIndex < table.rows.length; rowIndex += 1) {
15000
- if ((_s = (_r = table.rows[rowIndex]) == null ? void 0 : _r.style) == null ? void 0 : _s.hidden) {
15497
+ if ((_w = effectiveRowStyles[rowIndex]) == null ? void 0 : _w.hidden) {
15001
15498
  rowHeights[rowIndex] = 0;
15002
15499
  continue;
15003
15500
  }
@@ -15081,12 +15578,13 @@ function buildCanvasTableLayout(options) {
15081
15578
  contentTop,
15082
15579
  contentWidth: contentWidthPx,
15083
15580
  contentHeight: contentHeightPx,
15084
- shading: (_t = cell.style) == null ? void 0 : _t.shading,
15581
+ shading: (_x = cell.style) == null ? void 0 : _x.shading,
15085
15582
  anchorPosition,
15086
15583
  padding,
15087
15584
  borders,
15088
15585
  paragraphs,
15089
- verticalMode: cellEntry.verticalMode
15586
+ verticalMode: cellEntry.verticalMode,
15587
+ revision: ((_y = cell.style) == null ? void 0 : _y.revision) ?? (((_z = cell.style) == null ? void 0 : _z.propertyRevision) ? { ...cell.style.propertyRevision, type: "property" } : void 0)
15090
15588
  });
15091
15589
  }
15092
15590
  return {
@@ -15443,6 +15941,7 @@ function buildCanvasLayoutSnapshot(options) {
15443
15941
  const floatingImages = [];
15444
15942
  const inlineTextBoxes = [];
15445
15943
  const floatingTextBoxes = [];
15944
+ const floatingTables = [];
15446
15945
  const unsupportedRegions = [];
15447
15946
  for (const page of documentLayout.pages) {
15448
15947
  const pageElement = canvasPages.find(
@@ -15478,7 +15977,7 @@ function buildCanvasLayoutSnapshot(options) {
15478
15977
  const contentLeft = pageRect.left + page.pageSettings.margins.left + page.pageSettings.margins.gutter;
15479
15978
  const contentWidth = getPageContentWidth(page.pageSettings);
15480
15979
  const collectParagraphBlock = (zone, blocks, startTop, options2 = {}) => {
15481
- var _a;
15980
+ var _a, _b, _c;
15482
15981
  let cursorY = startTop;
15483
15982
  let blockContentLeft = options2.contentLeft ?? contentLeft;
15484
15983
  let blockContentWidth = options2.contentWidth ?? contentWidth;
@@ -15592,15 +16091,45 @@ function buildCanvasLayoutSnapshot(options) {
15592
16091
  })
15593
16092
  );
15594
16093
  } else if (block.sourceBlock.type === "table") {
16094
+ const floating = (_b = block.sourceBlock.style) == null ? void 0 : _b.floating;
16095
+ const floatingRect = floating ? resolveFloatingTableRect({
16096
+ floating,
16097
+ pageSettings: page.pageSettings,
16098
+ contentLeft: blockContentLeft - pageRect.left,
16099
+ contentTop: startTop - pageRect.top,
16100
+ contentWidth: blockContentWidth,
16101
+ anchorTop: cursorY - pageRect.top,
16102
+ width: resolveCanvasTableWidth(
16103
+ block.sourceBlock,
16104
+ blockContentWidth
16105
+ ),
16106
+ height: block.floatingTableHeight ?? 1,
16107
+ pageIndex: page.index
16108
+ }) : void 0;
16109
+ if (floatingRect) {
16110
+ floatingRect.y += block.floatingTableOffsetY ?? 0;
16111
+ }
16112
+ if (floatingRect) {
16113
+ floatingTables.push({
16114
+ tableId: block.sourceBlock.id,
16115
+ zone,
16116
+ footnoteId: blockFootnoteId,
16117
+ pageIndex: page.index,
16118
+ left: pageRect.left + floatingRect.x,
16119
+ top: pageRect.top + floatingRect.y,
16120
+ width: floatingRect.width,
16121
+ height: floatingRect.height
16122
+ });
16123
+ }
15595
16124
  const segmentTable = block.tableSegment ? buildSegmentTable(block.sourceBlock, block.tableSegment) : block.sourceBlock;
15596
16125
  const tableLayout = buildCanvasTableLayout({
15597
16126
  table: segmentTable,
15598
16127
  state,
15599
16128
  pageIndex: page.index,
15600
- originX: blockContentLeft,
15601
- originY: cursorY,
16129
+ originX: floatingRect ? pageRect.left + floatingRect.x : blockContentLeft,
16130
+ originY: floatingRect ? pageRect.top + floatingRect.y : cursorY,
15602
16131
  contentWidth: blockContentWidth,
15603
- estimatedHeight: block.estimatedHeight
16132
+ estimatedHeight: block.floatingTableHeight ?? block.estimatedHeight
15604
16133
  });
15605
16134
  for (const reason of tableLayout.unsupported) {
15606
16135
  unsupportedRegions.push({
@@ -15678,7 +16207,8 @@ function buildCanvasLayoutSnapshot(options) {
15678
16207
  top: cell.top,
15679
16208
  width: cell.width,
15680
16209
  height: cell.height,
15681
- anchorPosition: cell.anchorPosition
16210
+ anchorPosition: cell.anchorPosition,
16211
+ revisionId: (_c = cell.revision) == null ? void 0 : _c.id
15682
16212
  }
15683
16213
  });
15684
16214
  inlineImages.push(
@@ -15801,6 +16331,7 @@ function buildCanvasLayoutSnapshot(options) {
15801
16331
  floatingImages,
15802
16332
  inlineTextBoxes,
15803
16333
  floatingTextBoxes,
16334
+ floatingTables,
15804
16335
  unsupportedRegions
15805
16336
  };
15806
16337
  }
@@ -15856,7 +16387,7 @@ function getCaretRectFromSnapshot(snapshot, position2, paragraphOffset) {
15856
16387
  );
15857
16388
  return rectFromBox(slot.left, slot.top, 1, slot.height || line.height);
15858
16389
  }
15859
- var _tmpl$$N = /* @__PURE__ */ template(`<span class=oasis-outline-title>`), _tmpl$2$x = /* @__PURE__ */ template(`<div class=oasis-outline-list>`), _tmpl$3$l = /* @__PURE__ */ template(`<div class=oasis-outline-panel><div class=oasis-outline-header><button class=oasis-outline-toggle><i>`), _tmpl$4$f = /* @__PURE__ */ template(`<div class=oasis-outline-empty>`), _tmpl$5$d = /* @__PURE__ */ template(`<div class=oasis-outline-item>`);
16390
+ var _tmpl$$N = /* @__PURE__ */ template(`<span class=oasis-outline-title>`), _tmpl$2$x = /* @__PURE__ */ template(`<div class=oasis-outline-list>`), _tmpl$3$l = /* @__PURE__ */ template(`<div class=oasis-outline-panel><div class=oasis-outline-header><button class=oasis-outline-toggle><i>`), _tmpl$4$g = /* @__PURE__ */ template(`<div class=oasis-outline-empty>`), _tmpl$5$d = /* @__PURE__ */ template(`<div class=oasis-outline-item>`);
15860
16391
  function OutlinePanel(props) {
15861
16392
  const t = useI18n();
15862
16393
  const [collapsed, setCollapsed] = createSignal(props.defaultCollapsed ?? false);
@@ -15949,7 +16480,7 @@ function OutlinePanel(props) {
15949
16480
  },
15950
16481
  get fallback() {
15951
16482
  return (() => {
15952
- var _el$7 = _tmpl$4$f();
16483
+ var _el$7 = _tmpl$4$g();
15953
16484
  insert(_el$7, () => t("outline.empty"));
15954
16485
  return _el$7;
15955
16486
  })();
@@ -16424,7 +16955,7 @@ function Popover(props) {
16424
16955
  }
16425
16956
  })];
16426
16957
  }
16427
- var _tmpl$$J = /* @__PURE__ */ template(`<div>`), _tmpl$2$u = /* @__PURE__ */ template(`<div class=oasis-editor-toolbar-dropdown>`), _tmpl$3$k = /* @__PURE__ */ template(`<i>`), _tmpl$4$e = /* @__PURE__ */ template(`<span class=oasis-editor-tool-button-label>`), _tmpl$5$c = /* @__PURE__ */ template(`<i data-lucide=chevron-down class=oasis-editor-dropdown-chevron>`), _tmpl$6$6 = /* @__PURE__ */ template(`<button type=button class="oasis-editor-tool-button oasis-editor-tool-button-dropdown"aria-haspopup=menu>`);
16958
+ var _tmpl$$J = /* @__PURE__ */ template(`<div>`), _tmpl$2$u = /* @__PURE__ */ template(`<div class=oasis-editor-toolbar-dropdown>`), _tmpl$3$k = /* @__PURE__ */ template(`<i>`), _tmpl$4$f = /* @__PURE__ */ template(`<span class=oasis-editor-tool-button-label>`), _tmpl$5$c = /* @__PURE__ */ template(`<i data-lucide=chevron-down class=oasis-editor-dropdown-chevron>`), _tmpl$6$6 = /* @__PURE__ */ template(`<button type=button class="oasis-editor-tool-button oasis-editor-tool-button-dropdown"aria-haspopup=menu>`);
16428
16959
  function Menu(props) {
16429
16960
  const [open, setOpen] = createSignal(false);
16430
16961
  const ariaLabel = () => props.tooltip || props.label || "";
@@ -16462,7 +16993,7 @@ function Menu(props) {
16462
16993
  return props.label;
16463
16994
  },
16464
16995
  get children() {
16465
- var _el$5 = _tmpl$4$e();
16996
+ var _el$5 = _tmpl$4$f();
16466
16997
  insert(_el$5, () => props.label);
16467
16998
  return _el$5;
16468
16999
  }
@@ -16620,7 +17151,7 @@ function SplitButton(props) {
16620
17151
  });
16621
17152
  }
16622
17153
  delegateEvents(["click"]);
16623
- var _tmpl$$F = /* @__PURE__ */ template(`<i data-lucide=type>`), _tmpl$2$t = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-menu-action role=menuitem><span class=oasis-editor-color-menu-action-swatch></span><span>`), _tmpl$3$j = /* @__PURE__ */ template(`<div class=oasis-editor-color-menu-section><div class=oasis-editor-color-menu-heading></div><div class=oasis-editor-color-theme-grid>`), _tmpl$4$d = /* @__PURE__ */ template(`<div class=oasis-editor-color-menu-section><div class=oasis-editor-color-menu-heading></div><div class=oasis-editor-color-standard-grid>`), _tmpl$5$b = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-menu-action role=menuitem><span class="oasis-editor-color-menu-action-swatch oasis-editor-color-menu-more-swatch"></span><span>`), _tmpl$6$5 = /* @__PURE__ */ template(`<input type=color class=oasis-editor-color-custom-input>`), _tmpl$7$2 = /* @__PURE__ */ template(`<span class=oasis-editor-color-split-icon><i></i><span class=oasis-editor-color-split-indicator>`), _tmpl$8$1 = /* @__PURE__ */ template(`<i data-lucide=slash>`), _tmpl$9 = /* @__PURE__ */ template(`<div class=oasis-editor-color-theme-column>`), _tmpl$0 = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-swatch>`);
17154
+ var _tmpl$$F = /* @__PURE__ */ template(`<i data-lucide=type>`), _tmpl$2$t = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-menu-action role=menuitem><span class=oasis-editor-color-menu-action-swatch></span><span>`), _tmpl$3$j = /* @__PURE__ */ template(`<div class=oasis-editor-color-menu-section><div class=oasis-editor-color-menu-heading></div><div class=oasis-editor-color-theme-grid>`), _tmpl$4$e = /* @__PURE__ */ template(`<div class=oasis-editor-color-menu-section><div class=oasis-editor-color-menu-heading></div><div class=oasis-editor-color-standard-grid>`), _tmpl$5$b = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-menu-action role=menuitem><span class="oasis-editor-color-menu-action-swatch oasis-editor-color-menu-more-swatch"></span><span>`), _tmpl$6$5 = /* @__PURE__ */ template(`<input type=color class=oasis-editor-color-custom-input>`), _tmpl$7$2 = /* @__PURE__ */ template(`<span class=oasis-editor-color-split-icon><i></i><span class=oasis-editor-color-split-indicator>`), _tmpl$8$1 = /* @__PURE__ */ template(`<i data-lucide=slash>`), _tmpl$9 = /* @__PURE__ */ template(`<div class=oasis-editor-color-theme-column>`), _tmpl$0 = /* @__PURE__ */ template(`<button type=button class=oasis-editor-color-swatch>`);
16624
17155
  const normalizeColor = (value) => (value == null ? void 0 : value.trim().toLowerCase()) ?? "";
16625
17156
  function ColorPicker(props) {
16626
17157
  const [isOpen, setIsOpen] = createSignal(false);
@@ -16743,7 +17274,7 @@ function ColorPicker(props) {
16743
17274
  }));
16744
17275
  return _el$5;
16745
17276
  })(), (() => {
16746
- var _el$8 = _tmpl$4$d(), _el$9 = _el$8.firstChild, _el$0 = _el$9.nextSibling;
17277
+ var _el$8 = _tmpl$4$e(), _el$9 = _el$8.firstChild, _el$0 = _el$9.nextSibling;
16747
17278
  insert(_el$9, () => props.standardColorsLabel);
16748
17279
  insert(_el$0, createComponent(For, {
16749
17280
  get each() {
@@ -16808,7 +17339,7 @@ function ColorPicker(props) {
16808
17339
  });
16809
17340
  }
16810
17341
  delegateEvents(["click", "input"]);
16811
- var _tmpl$$E = /* @__PURE__ */ template(`<div class=oasis-editor-table-grid-picker-status>`), _tmpl$2$s = /* @__PURE__ */ template(`<div class=oasis-editor-table-grid-picker-grid>`), _tmpl$3$i = /* @__PURE__ */ template(`<div class=oasis-editor-toolbar-dropdown>`), _tmpl$4$c = /* @__PURE__ */ template(`<button type=button class=oasis-editor-tool-button><i>`), _tmpl$5$a = /* @__PURE__ */ template(`<button type=button class=oasis-editor-table-grid-picker-cell>`);
17342
+ var _tmpl$$E = /* @__PURE__ */ template(`<div class=oasis-editor-table-grid-picker-status>`), _tmpl$2$s = /* @__PURE__ */ template(`<div class=oasis-editor-table-grid-picker-grid>`), _tmpl$3$i = /* @__PURE__ */ template(`<div class=oasis-editor-toolbar-dropdown>`), _tmpl$4$d = /* @__PURE__ */ template(`<button type=button class=oasis-editor-tool-button><i>`), _tmpl$5$a = /* @__PURE__ */ template(`<button type=button class=oasis-editor-table-grid-picker-cell>`);
16812
17343
  function GridPicker(props) {
16813
17344
  const t = useI18n();
16814
17345
  const [isOpen, setIsOpen] = createSignal(false);
@@ -16895,7 +17426,7 @@ function GridPicker(props) {
16895
17426
  col: 0
16896
17427
  }),
16897
17428
  trigger: (api) => (() => {
16898
- var _el$4 = _tmpl$4$c(), _el$5 = _el$4.firstChild;
17429
+ var _el$4 = _tmpl$4$d(), _el$5 = _el$4.firstChild;
16899
17430
  _el$4.$$click = () => api.toggle();
16900
17431
  use((el) => api.ref(el), _el$4);
16901
17432
  createRenderEffect((_p$) => {
@@ -17021,7 +17552,7 @@ const DEFAULT_PALETTE = {
17021
17552
  standardColors: STANDARD_COLORS,
17022
17553
  allowCustom: true
17023
17554
  };
17024
- var _tmpl$$D = /* @__PURE__ */ template(`<button type=button class=oasis-editor-style-gallery-card role=option><span>`), _tmpl$2$r = /* @__PURE__ */ template(`<div class=oasis-editor-style-gallery-grid>`), _tmpl$3$h = /* @__PURE__ */ template(`<div class=oasis-editor-style-gallery><div class=oasis-editor-style-gallery-ribbon><div class=oasis-editor-style-gallery-strip role=listbox></div><button type=button class=oasis-editor-style-gallery-expand aria-haspopup=listbox><i data-lucide=chevron-down>`), _tmpl$4$b = /* @__PURE__ */ template(`<option>`);
17555
+ var _tmpl$$D = /* @__PURE__ */ template(`<button type=button class=oasis-editor-style-gallery-card role=option><span>`), _tmpl$2$r = /* @__PURE__ */ template(`<div class=oasis-editor-style-gallery-grid>`), _tmpl$3$h = /* @__PURE__ */ template(`<div class=oasis-editor-style-gallery><div class=oasis-editor-style-gallery-ribbon><div class=oasis-editor-style-gallery-strip role=listbox></div><button type=button class=oasis-editor-style-gallery-expand aria-haspopup=listbox><i data-lucide=chevron-down>`), _tmpl$4$c = /* @__PURE__ */ template(`<option>`);
17025
17556
  function getQuickStyles(styles) {
17026
17557
  const applicable = styles.filter((style2) => style2.type !== "table" && (!style2.semiHidden || style2.unhideWhenUsed && style2.isUsed));
17027
17558
  const hasQuickStyles = applicable.some((style2) => style2.qFormat === true);
@@ -17156,7 +17687,7 @@ function StyleGallery(props) {
17156
17687
  return styles();
17157
17688
  },
17158
17689
  children: (style2) => (() => {
17159
- var _el$8 = _tmpl$4$b();
17690
+ var _el$8 = _tmpl$4$c();
17160
17691
  insert(_el$8, () => style2.name);
17161
17692
  createRenderEffect(() => _el$8.value = style2.id);
17162
17693
  return _el$8;
@@ -20601,6 +21132,8 @@ function drawBorderBox(ctx, left, top, width, height, borders) {
20601
21132
  drawEdge(ctx, borders.right, right, top, right, bottom);
20602
21133
  drawEdge(ctx, borders.bottom, left, bottom, right, bottom);
20603
21134
  drawEdge(ctx, borders.left, left, top, left, bottom);
21135
+ drawEdge(ctx, borders.topLeftToBottomRight, left, top, right, bottom);
21136
+ drawEdge(ctx, borders.topRightToBottomLeft, right, top, left, bottom);
20604
21137
  }
20605
21138
  const __vite_import_meta_env__ = { "DEV": false };
20606
21139
  function drawVerticalCell(ctx, cell, state, pageIndex, onUpdate, painters) {
@@ -20675,6 +21208,20 @@ function drawTable(ctx, table, tableSegment, state, originX, originY, contentWid
20675
21208
  cell.height,
20676
21209
  cell.borders
20677
21210
  );
21211
+ if (cell.revision) {
21212
+ const color = cell.revision.type === "insert" ? "#059669" : cell.revision.type === "delete" ? "#dc2626" : "#d97706";
21213
+ ctx.save();
21214
+ ctx.strokeStyle = color;
21215
+ ctx.lineWidth = 2;
21216
+ ctx.setLineDash([5, 3]);
21217
+ ctx.strokeRect(
21218
+ cell.left + 1,
21219
+ cell.top + 1,
21220
+ cell.width - 2,
21221
+ cell.height - 2
21222
+ );
21223
+ ctx.restore();
21224
+ }
20678
21225
  if (cell.verticalMode === "horizontal") {
20679
21226
  for (const paragraphLayout of cell.paragraphs) {
20680
21227
  drawParagraph(
@@ -20770,6 +21317,7 @@ function drawParagraphDecorations(ctx, paragraphStyle, lines, originX, contentTo
20770
21317
  }
20771
21318
  }
20772
21319
  function renderBlockList(ctx, state, blocks, originX, originY, contentWidth, pageIndex, onUpdate, pageSettings) {
21320
+ var _a;
20773
21321
  let cursorY = originY;
20774
21322
  for (const block of blocks) {
20775
21323
  if (block.sourceBlock.type === "paragraph" && block.layout) {
@@ -20865,6 +21413,37 @@ function renderBlockList(ctx, state, blocks, originX, originY, contentWidth, pag
20865
21413
  });
20866
21414
  }
20867
21415
  } else if (block.sourceBlock.type === "table") {
21416
+ const floating = (_a = block.sourceBlock.style) == null ? void 0 : _a.floating;
21417
+ if (floating && pageSettings) {
21418
+ const width = resolveCanvasTableWidth(block.sourceBlock, contentWidth);
21419
+ const rect = resolveFloatingTableRect({
21420
+ floating,
21421
+ pageSettings,
21422
+ contentLeft: originX,
21423
+ contentTop: originY,
21424
+ contentWidth,
21425
+ anchorTop: cursorY,
21426
+ width,
21427
+ height: block.floatingTableHeight ?? 1,
21428
+ pageIndex
21429
+ });
21430
+ rect.y += block.floatingTableOffsetY ?? 0;
21431
+ drawTable(
21432
+ ctx,
21433
+ block.sourceBlock,
21434
+ void 0,
21435
+ state,
21436
+ rect.x,
21437
+ rect.y,
21438
+ contentWidth,
21439
+ rect.height,
21440
+ pageIndex,
21441
+ onUpdate,
21442
+ canvasBlockPainters
21443
+ );
21444
+ cursorY += Math.max(0, block.estimatedHeight);
21445
+ continue;
21446
+ }
20868
21447
  drawTable(
20869
21448
  ctx,
20870
21449
  block.sourceBlock,
@@ -21220,7 +21799,7 @@ function createCanvasPageRenderer(options) {
21220
21799
  }
21221
21800
  };
21222
21801
  }
21223
- var _tmpl$$v = /* @__PURE__ */ template(`<div class="oasis-editor-paper-stack oasis-editor-canvas-stack"style=position:relative>`), _tmpl$2$m = /* @__PURE__ */ template(`<div class=oasis-editor-canvas-page-slot style=position:relative>`), _tmpl$3$f = /* @__PURE__ */ template(`<div class=oasis-editor-paper data-renderer=canvas data-testid=editor-page style=position:relative;z-index:1><canvas>`);
21802
+ var _tmpl$$v = /* @__PURE__ */ template(`<div class="oasis-editor-paper-stack oasis-editor-canvas-stack"style=position:relative>`), _tmpl$2$m = /* @__PURE__ */ template(`<div class=oasis-editor-canvas-page-slot style=position:relative>`), _tmpl$3$f = /* @__PURE__ */ template(`<div class=oasis-editor-paper data-renderer=canvas data-testid=editor-page style=position:relative;z-index:1><canvas>`), _tmpl$4$b = /* @__PURE__ */ template(`<div class=oasis-editor-table-revision-hit style=position:absolute;pointer-events:auto;background:transparent>`);
21224
21803
  const canvasTextMeasurer = {
21225
21804
  composeMeasuredParagraphLines: (options) => domTextMeasurer.composeMeasuredParagraphLines(options),
21226
21805
  resolveRenderedLineHeightPx: (styles, lineHeightMultiple) => domTextMeasurer.resolveRenderedLineHeightPx(styles, lineHeightMultiple)
@@ -21332,6 +21911,12 @@ function CanvasEditorSurface(props) {
21332
21911
  },
21333
21912
  get onSurfaceDblClick() {
21334
21913
  return props.onSurfaceDblClick;
21914
+ },
21915
+ get onRevisionMouseEnter() {
21916
+ return props.onRevisionMouseEnter;
21917
+ },
21918
+ get onRevisionMouseLeave() {
21919
+ return props.onRevisionMouseLeave;
21335
21920
  }
21336
21921
  }), null);
21337
21922
  return _el$2;
@@ -21348,6 +21933,57 @@ function CanvasPage(props) {
21348
21933
  getPage: () => props.page,
21349
21934
  getState: () => props.state
21350
21935
  });
21936
+ const revisionCells = createMemo(() => {
21937
+ var _a;
21938
+ const result = [];
21939
+ let cursorY = props.page.bodyTop ?? props.page.pageSettings.margins.top;
21940
+ const columns = getPageColumnRects(props.page.pageSettings);
21941
+ for (const block of props.page.blocks) {
21942
+ if (block.sourceBlock.type === "table") {
21943
+ const column = columns[block.columnIndex ?? 0] ?? columns[0];
21944
+ const sourceTable = block.tableSegment ? buildSegmentTable(block.sourceBlock, block.tableSegment) : block.sourceBlock;
21945
+ let originX = column.left;
21946
+ let originY = cursorY;
21947
+ const floating = (_a = sourceTable.style) == null ? void 0 : _a.floating;
21948
+ if (floating) {
21949
+ const rect = resolveFloatingTableRect({
21950
+ floating,
21951
+ pageSettings: props.page.pageSettings,
21952
+ contentLeft: column.left,
21953
+ contentTop: props.page.bodyTop ?? props.page.pageSettings.margins.top,
21954
+ contentWidth: column.width,
21955
+ anchorTop: cursorY,
21956
+ width: resolveCanvasTableWidth(sourceTable, column.width),
21957
+ height: block.floatingTableHeight ?? 1,
21958
+ pageIndex: props.page.index
21959
+ });
21960
+ originX = rect.x;
21961
+ originY = rect.y + (block.floatingTableOffsetY ?? 0);
21962
+ }
21963
+ const layout = buildCanvasTableLayout({
21964
+ table: sourceTable,
21965
+ state: props.state,
21966
+ pageIndex: props.page.index,
21967
+ originX,
21968
+ originY,
21969
+ contentWidth: column.width,
21970
+ estimatedHeight: block.floatingTableHeight ?? block.estimatedHeight
21971
+ });
21972
+ for (const cell of layout.cells) {
21973
+ if (!cell.revision) continue;
21974
+ result.push({
21975
+ id: cell.revision.id,
21976
+ left: cell.left,
21977
+ top: cell.top,
21978
+ width: cell.width,
21979
+ height: cell.height
21980
+ });
21981
+ }
21982
+ }
21983
+ cursorY += Math.max(0, block.estimatedHeight);
21984
+ }
21985
+ return result;
21986
+ });
21351
21987
  createEffect(() => {
21352
21988
  props.page;
21353
21989
  props.state.document;
@@ -21381,6 +22017,36 @@ function CanvasPage(props) {
21381
22017
  addEventListener(_el$3, "mousedown", props.onSurfaceMouseDown, true);
21382
22018
  var _ref$ = canvasRef;
21383
22019
  typeof _ref$ === "function" ? use(_ref$, _el$4) : canvasRef = _el$4;
22020
+ insert(_el$3, createComponent(For, {
22021
+ get each() {
22022
+ return revisionCells();
22023
+ },
22024
+ children: (revision) => (() => {
22025
+ var _el$5 = _tmpl$4$b();
22026
+ addEventListener(_el$5, "mousedown", props.onSurfaceMouseDown, true);
22027
+ _el$5.addEventListener("mouseleave", (event) => {
22028
+ var _a;
22029
+ return (_a = props.onRevisionMouseLeave) == null ? void 0 : _a.call(props, revision.id, event);
22030
+ });
22031
+ _el$5.addEventListener("mouseenter", (event) => props.onRevisionMouseEnter(revision.id, event));
22032
+ createRenderEffect((_p$) => {
22033
+ var _v$4 = revision.id, _v$5 = `${revision.left}px`, _v$6 = `${revision.top}px`, _v$7 = `${revision.width}px`, _v$8 = `${revision.height}px`;
22034
+ _v$4 !== _p$.e && setAttribute(_el$5, "data-revision-id", _p$.e = _v$4);
22035
+ _v$5 !== _p$.t && setStyleProperty(_el$5, "left", _p$.t = _v$5);
22036
+ _v$6 !== _p$.a && setStyleProperty(_el$5, "top", _p$.a = _v$6);
22037
+ _v$7 !== _p$.o && setStyleProperty(_el$5, "width", _p$.o = _v$7);
22038
+ _v$8 !== _p$.i && setStyleProperty(_el$5, "height", _p$.i = _v$8);
22039
+ return _p$;
22040
+ }, {
22041
+ e: void 0,
22042
+ t: void 0,
22043
+ a: void 0,
22044
+ o: void 0,
22045
+ i: void 0
22046
+ });
22047
+ return _el$5;
22048
+ })()
22049
+ }), null);
21384
22050
  createRenderEffect((_p$) => {
21385
22051
  var _v$ = props.index, _v$2 = `${props.page.pageSettings.width}px`, _v$3 = `${props.page.pageSettings.height}px`;
21386
22052
  _v$ !== _p$.e && setAttribute(_el$3, "data-page-index", _p$.e = _v$);
@@ -22075,7 +22741,11 @@ function RevisionOverlay(props) {
22075
22741
  return "Data desconhecida";
22076
22742
  }
22077
22743
  };
22078
- const label = () => props.box.type === "insert" ? "Inserido por" : "Excluído por";
22744
+ const label = () => {
22745
+ if (props.box.type === "insert") return "Inserido por";
22746
+ if (props.box.type === "delete") return "Excluído por";
22747
+ return "Alterado por";
22748
+ };
22079
22749
  return (() => {
22080
22750
  var _el$ = _tmpl$$r(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild;
22081
22751
  _el$4.nextSibling;
@@ -32478,23 +33148,508 @@ function parseParagraphStyle$1(paragraphProperties) {
32478
33148
  }
32479
33149
  return emptyOrUndefined(style2);
32480
33150
  }
32481
- function parseConditionalRowStyle(trPr) {
32482
- if (!trPr) return void 0;
33151
+ function parseDocxWidthValue(element) {
33152
+ if (!element) {
33153
+ return void 0;
33154
+ }
33155
+ const type = getAttributeValue(element, "type");
33156
+ const raw = getAttributeValue(element, "w");
33157
+ if (type === "auto") {
33158
+ return "auto";
33159
+ }
33160
+ if (type === "pct") {
33161
+ if (!raw) {
33162
+ return void 0;
33163
+ }
33164
+ const pct = raw.trim().endsWith("%") ? Number.parseFloat(raw) : Number(raw) / 50;
33165
+ return Number.isFinite(pct) ? `${Math.round(pct * 1e4) / 1e4}%` : void 0;
33166
+ }
33167
+ return twipsToPoints(raw);
33168
+ }
33169
+ function parsePositiveIntegerProperty(parent, localName) {
33170
+ const element = getFirstChildByTagNameNS(parent, WORD_NS, localName);
33171
+ const raw = getAttributeValue(element, "val");
33172
+ const parsed = raw ? Number(raw) : Number.NaN;
33173
+ return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : void 0;
33174
+ }
33175
+ function parseTableConditionalFlags(properties) {
33176
+ const element = getFirstChildByTagNameNS(properties, WORD_NS, "cnfStyle");
33177
+ if (!element) return void 0;
33178
+ const names = [
33179
+ ["firstRow", "firstRow"],
33180
+ ["lastRow", "lastRow"],
33181
+ ["firstColumn", "firstCol"],
33182
+ ["lastColumn", "lastCol"],
33183
+ ["oddVBand", "band1Vert"],
33184
+ ["evenVBand", "band2Vert"],
33185
+ ["oddHBand", "band1Horz"],
33186
+ ["evenHBand", "band2Horz"],
33187
+ ["firstRowFirstColumn", "nwCell"],
33188
+ ["firstRowLastColumn", "neCell"],
33189
+ ["lastRowFirstColumn", "swCell"],
33190
+ ["lastRowLastColumn", "seCell"]
33191
+ ];
33192
+ const rawBits = getAttributeValue(element, "val") ?? "";
33193
+ const flags = {};
33194
+ names.forEach(([attribute, key], index) => {
33195
+ const explicit = getAttributeValue(element, attribute);
33196
+ if (explicit === "1" || explicit === "true" || explicit === "on") {
33197
+ flags[key] = true;
33198
+ } else if (explicit === "0" || explicit === "false" || explicit === "off") {
33199
+ flags[key] = false;
33200
+ } else if (rawBits.length === 12 && rawBits[index] === "1") {
33201
+ flags[key] = true;
33202
+ }
33203
+ });
33204
+ return Object.keys(flags).length > 0 ? flags : void 0;
33205
+ }
33206
+ function parseRevisionMetadata(element) {
33207
+ const rawDate = getAttributeValue(element, "date");
33208
+ const parsedDate = rawDate ? Date.parse(rawDate) : Number.NaN;
33209
+ return {
33210
+ id: getAttributeValue(element, "id") ?? `revision:${element.localName}`,
33211
+ author: getAttributeValue(element, "author") ?? "Unknown",
33212
+ date: Number.isFinite(parsedDate) ? parsedDate : 0
33213
+ };
33214
+ }
33215
+ function parseFloatingTableProperties(tblPr) {
33216
+ const tblpPr = getFirstChildByTagNameNS(tblPr, WORD_NS, "tblpPr");
33217
+ if (!tblpPr || !tblpPr.attributes || tblpPr.attributes.length === 0) {
33218
+ return void 0;
33219
+ }
33220
+ const attrs = {};
33221
+ for (let index = 0; index < tblpPr.attributes.length; index += 1) {
33222
+ const attr = tblpPr.attributes.item(index);
33223
+ if ((attr == null ? void 0 : attr.namespaceURI) === WORD_NS || (attr == null ? void 0 : attr.prefix) === "w") {
33224
+ attrs[attr.localName || attr.name.replace(/^w:/, "")] = attr.value;
33225
+ }
33226
+ }
33227
+ const point = (name) => twipsToPoints(attrs[name] ?? null);
33228
+ const horizontalAnchor = attrs.horzAnchor === "margin" || attrs.horzAnchor === "page" || attrs.horzAnchor === "text" ? attrs.horzAnchor : void 0;
33229
+ const verticalAnchor = attrs.vertAnchor === "margin" || attrs.vertAnchor === "page" || attrs.vertAnchor === "text" ? attrs.vertAnchor : void 0;
33230
+ const xAlign = attrs.tblpXSpec === "left" || attrs.tblpXSpec === "center" || attrs.tblpXSpec === "right" || attrs.tblpXSpec === "inside" || attrs.tblpXSpec === "outside" ? attrs.tblpXSpec : void 0;
33231
+ const yAlign = attrs.tblpYSpec === "top" || attrs.tblpYSpec === "center" || attrs.tblpYSpec === "bottom" || attrs.tblpYSpec === "inside" || attrs.tblpYSpec === "outside" ? attrs.tblpYSpec : void 0;
33232
+ return {
33233
+ ...horizontalAnchor ? { horizontalAnchor } : {},
33234
+ ...verticalAnchor ? { verticalAnchor } : {},
33235
+ ...point("tblpX") !== void 0 ? { x: point("tblpX") } : {},
33236
+ ...point("tblpY") !== void 0 ? { y: point("tblpY") } : {},
33237
+ ...xAlign ? { xAlign } : {},
33238
+ ...yAlign ? { yAlign } : {},
33239
+ ...point("topFromText") !== void 0 ? { distanceTop: point("topFromText") } : {},
33240
+ ...point("rightFromText") !== void 0 ? { distanceRight: point("rightFromText") } : {},
33241
+ ...point("bottomFromText") !== void 0 ? { distanceBottom: point("bottomFromText") } : {},
33242
+ ...point("leftFromText") !== void 0 ? { distanceLeft: point("leftFromText") } : {}
33243
+ };
33244
+ }
33245
+ function parseCellMargins(container) {
33246
+ if (!container) {
33247
+ return void 0;
33248
+ }
33249
+ const edgePt = (edge) => twipsToPoints(
33250
+ getAttributeValue(
33251
+ getFirstChildByTagNameNS(container, WORD_NS, edge),
33252
+ "w"
33253
+ )
33254
+ );
33255
+ const margins = {};
33256
+ const top = edgePt("top");
33257
+ const right = edgePt("right");
33258
+ const bottom = edgePt("bottom");
33259
+ const left = edgePt("left");
33260
+ const start = edgePt("start");
33261
+ const end = edgePt("end");
33262
+ if (top !== void 0) margins.top = top;
33263
+ if (right !== void 0) margins.right = right;
33264
+ if (bottom !== void 0) margins.bottom = bottom;
33265
+ if (left !== void 0) margins.left = left;
33266
+ if (start !== void 0) margins.start = start;
33267
+ if (end !== void 0) margins.end = end;
33268
+ return Object.keys(margins).length > 0 ? margins : void 0;
33269
+ }
33270
+ function parseTableLayout(tblPr) {
33271
+ const value = getAttributeValue(
33272
+ getFirstChildByTagNameNS(tblPr, WORD_NS, "tblLayout"),
33273
+ "type"
33274
+ );
33275
+ return value === "fixed" || value === "autofit" ? value : void 0;
33276
+ }
33277
+ function parseTableStyle(tblPr, tableStyleId) {
32483
33278
  const style2 = {};
32484
- const trHeight = getFirstChildByTagNameNS(trPr, WORD_NS, "trHeight");
32485
- if (trHeight) {
32486
- const height = twipsToPoints(getAttributeValue(trHeight, "val"));
32487
- if (height !== void 0) style2.height = height;
32488
- const hRule = getAttributeValue(trHeight, "hRule");
32489
- if (hRule === "auto" || hRule === "exact" || hRule === "atLeast") {
32490
- style2.heightRule = hRule;
33279
+ if (tableStyleId) {
33280
+ style2.styleId = tableStyleId;
33281
+ }
33282
+ const altTitle = getAttributeValue(
33283
+ getFirstChildByTagNameNS(tblPr, WORD_NS, "tblCaption"),
33284
+ "val"
33285
+ );
33286
+ if (altTitle) {
33287
+ style2.altTitle = altTitle;
33288
+ }
33289
+ const altDescription = getAttributeValue(
33290
+ getFirstChildByTagNameNS(tblPr, WORD_NS, "tblDescription"),
33291
+ "val"
33292
+ );
33293
+ if (altDescription) {
33294
+ style2.altDescription = altDescription;
33295
+ }
33296
+ const width = parseDocxWidthValue(
33297
+ getFirstChildByTagNameNS(tblPr, WORD_NS, "tblW")
33298
+ );
33299
+ if (width !== void 0) {
33300
+ style2.width = width;
33301
+ }
33302
+ const indentLeft = parseDocxWidthValue(
33303
+ getFirstChildByTagNameNS(tblPr, WORD_NS, "tblInd")
33304
+ );
33305
+ if (indentLeft !== void 0) {
33306
+ style2.indentLeft = indentLeft;
33307
+ }
33308
+ const jc = getAttributeValue(
33309
+ getFirstChildByTagNameNS(tblPr, WORD_NS, "jc"),
33310
+ "val"
33311
+ );
33312
+ if (jc === "left" || jc === "center" || jc === "right") {
33313
+ style2.align = jc;
33314
+ }
33315
+ const layout = parseTableLayout(tblPr);
33316
+ if (layout) {
33317
+ style2.layout = layout;
33318
+ }
33319
+ const cellSpacing = parseDocxWidthValue(
33320
+ getFirstChildByTagNameNS(tblPr, WORD_NS, "tblCellSpacing")
33321
+ );
33322
+ if (cellSpacing !== void 0) {
33323
+ style2.cellSpacing = cellSpacing;
33324
+ }
33325
+ const borders = parseDocxTableBorders(
33326
+ getFirstChildByTagNameNS(tblPr, WORD_NS, "tblBorders")
33327
+ );
33328
+ if (Object.keys(borders).length > 0) style2.borders = borders;
33329
+ const defaultCellMargins = parseCellMargins(
33330
+ getFirstChildByTagNameNS(tblPr, WORD_NS, "tblCellMar")
33331
+ );
33332
+ if (defaultCellMargins) {
33333
+ style2.defaultCellMargins = defaultCellMargins;
33334
+ }
33335
+ const bidiVisual = tblPr ? parseOnOffProperty(tblPr, "bidiVisual") : void 0;
33336
+ if (bidiVisual !== void 0) {
33337
+ style2.bidiVisual = bidiVisual;
33338
+ }
33339
+ const tblOverlap = getAttributeValue(
33340
+ getFirstChildByTagNameNS(tblPr, WORD_NS, "tblOverlap"),
33341
+ "val"
33342
+ );
33343
+ if (tblOverlap === "overlap" || tblOverlap === "never") {
33344
+ style2.tblOverlap = tblOverlap;
33345
+ }
33346
+ const floating = parseFloatingTableProperties(tblPr);
33347
+ if (floating) {
33348
+ style2.floating = floating;
33349
+ }
33350
+ const rowBandSize = parsePositiveIntegerProperty(
33351
+ tblPr,
33352
+ "tblStyleRowBandSize"
33353
+ );
33354
+ if (rowBandSize !== void 0) style2.rowBandSize = rowBandSize;
33355
+ const colBandSize = parsePositiveIntegerProperty(
33356
+ tblPr,
33357
+ "tblStyleColBandSize"
33358
+ );
33359
+ if (colBandSize !== void 0) style2.colBandSize = colBandSize;
33360
+ const tblLook = getFirstChildByTagNameNS(tblPr, WORD_NS, "tblLook");
33361
+ if (tblLook) {
33362
+ const raw = getAttributeValue(tblLook, "val");
33363
+ const mask = raw ? Number.parseInt(raw, 16) : Number.NaN;
33364
+ const flag = (name, bit, fallback) => {
33365
+ const value = getAttributeValue(tblLook, name);
33366
+ if (value !== null && value !== "") {
33367
+ return value === "1" || value === "true" || value === "on";
33368
+ }
33369
+ return Number.isFinite(mask) ? (mask & bit) !== 0 : fallback;
33370
+ };
33371
+ style2.tblLook = {
33372
+ firstRow: flag("firstRow", 32, true),
33373
+ lastRow: flag("lastRow", 64, false),
33374
+ firstCol: flag("firstColumn", 128, true),
33375
+ lastCol: flag("lastColumn", 256, false),
33376
+ noHBand: flag("noHBand", 512, false),
33377
+ noVBand: flag("noVBand", 1024, false)
33378
+ };
33379
+ }
33380
+ const change = getFirstChildByTagNameNS(tblPr, WORD_NS, "tblPrChange");
33381
+ const previousProperties = getFirstChildByTagNameNS(change, WORD_NS, "tblPr");
33382
+ if (change && previousProperties) {
33383
+ style2.revision = {
33384
+ ...parseRevisionMetadata(change),
33385
+ type: "property",
33386
+ previous: parseTableStyle(previousProperties) ?? {}
33387
+ };
33388
+ }
33389
+ return emptyOrUndefined(style2);
33390
+ }
33391
+ function parseTableRowStyle(rowProperties) {
33392
+ if (!rowProperties) {
33393
+ return void 0;
33394
+ }
33395
+ const style2 = {};
33396
+ const isHeader = parseOnOffProperty(rowProperties, "tblHeader");
33397
+ if (isHeader !== void 0) style2.isHeader = isHeader;
33398
+ const gridBefore = parsePositiveIntegerProperty(rowProperties, "gridBefore");
33399
+ if (gridBefore !== void 0) {
33400
+ style2.gridBefore = gridBefore;
33401
+ }
33402
+ const gridAfter = parsePositiveIntegerProperty(rowProperties, "gridAfter");
33403
+ if (gridAfter !== void 0) {
33404
+ style2.gridAfter = gridAfter;
33405
+ }
33406
+ const widthBefore = parseDocxWidthValue(
33407
+ getFirstChildByTagNameNS(rowProperties, WORD_NS, "wBefore")
33408
+ );
33409
+ if (widthBefore !== void 0) {
33410
+ style2.widthBefore = widthBefore;
33411
+ }
33412
+ const widthAfter = parseDocxWidthValue(
33413
+ getFirstChildByTagNameNS(rowProperties, WORD_NS, "wAfter")
33414
+ );
33415
+ if (widthAfter !== void 0) {
33416
+ style2.widthAfter = widthAfter;
33417
+ }
33418
+ const trHeight = getFirstChildByTagNameNS(rowProperties, WORD_NS, "trHeight");
33419
+ const height = twipsToPoints(getAttributeValue(trHeight, "val"));
33420
+ if (height !== void 0) {
33421
+ style2.height = height;
33422
+ }
33423
+ const hRule = getAttributeValue(trHeight, "hRule");
33424
+ if (hRule === "auto" || hRule === "exact" || hRule === "atLeast") {
33425
+ style2.heightRule = hRule;
33426
+ }
33427
+ const cellSpacing = parseDocxWidthValue(
33428
+ getFirstChildByTagNameNS(rowProperties, WORD_NS, "tblCellSpacing")
33429
+ );
33430
+ if (cellSpacing !== void 0) {
33431
+ style2.cellSpacing = cellSpacing;
33432
+ }
33433
+ const cantSplit = parseOnOffProperty(rowProperties, "cantSplit");
33434
+ if (cantSplit !== void 0) {
33435
+ style2.cantSplit = cantSplit;
33436
+ }
33437
+ const hidden = parseOnOffProperty(rowProperties, "hidden");
33438
+ if (hidden !== void 0) {
33439
+ style2.hidden = hidden;
33440
+ }
33441
+ const change = getFirstChildByTagNameNS(rowProperties, WORD_NS, "trPrChange");
33442
+ const previousProperties = getFirstChildByTagNameNS(change, WORD_NS, "trPr");
33443
+ if (change && previousProperties) {
33444
+ style2.propertyRevision = {
33445
+ ...parseRevisionMetadata(change),
33446
+ type: "property",
33447
+ previous: parseTableRowStyle(previousProperties) ?? {}
33448
+ };
33449
+ }
33450
+ const inserted = getFirstChildByTagNameNS(rowProperties, WORD_NS, "ins");
33451
+ const deleted = getFirstChildByTagNameNS(rowProperties, WORD_NS, "del");
33452
+ const structural = inserted ?? deleted;
33453
+ if (structural) {
33454
+ style2.revision = {
33455
+ ...parseRevisionMetadata(structural),
33456
+ type: inserted ? "insert" : "delete"
33457
+ };
33458
+ }
33459
+ return emptyOrUndefined(style2);
33460
+ }
33461
+ function getTableCellColSpan(cellProperties) {
33462
+ if (!cellProperties) {
33463
+ return 1;
33464
+ }
33465
+ const gridSpan = getFirstChildByTagNameNS(
33466
+ cellProperties,
33467
+ WORD_NS,
33468
+ "gridSpan"
33469
+ );
33470
+ const value = getAttributeValue(gridSpan, "val");
33471
+ const parsed = value ? Number(value) : 1;
33472
+ return Number.isFinite(parsed) && parsed > 1 ? Math.floor(parsed) : 1;
33473
+ }
33474
+ function getTableCellVMerge(cellProperties) {
33475
+ if (!cellProperties) {
33476
+ return void 0;
33477
+ }
33478
+ const vMerge = getFirstChildByTagNameNS(cellProperties, WORD_NS, "vMerge");
33479
+ if (!vMerge) {
33480
+ return void 0;
33481
+ }
33482
+ const value = getAttributeValue(vMerge, "val");
33483
+ return value === "restart" ? "restart" : "continue";
33484
+ }
33485
+ function parseTableCellVerticalAlign(cellProperties) {
33486
+ if (!cellProperties) {
33487
+ return void 0;
33488
+ }
33489
+ const vAlign = getFirstChildByTagNameNS(cellProperties, WORD_NS, "vAlign");
33490
+ const value = getAttributeValue(vAlign, "val");
33491
+ if (value === "top" || value === "bottom") {
33492
+ return value;
33493
+ }
33494
+ if (value === "center") {
33495
+ return "middle";
33496
+ }
33497
+ return void 0;
33498
+ }
33499
+ function parseTableCellBorders(cellProperties) {
33500
+ if (!cellProperties) {
33501
+ return {};
33502
+ }
33503
+ return parseDocxBoxBorders(
33504
+ getFirstChildByTagNameNS(cellProperties, WORD_NS, "tcBorders")
33505
+ );
33506
+ }
33507
+ function parseTableCellStyle(cellProperties, tableDefaultMargins) {
33508
+ if (!cellProperties) {
33509
+ {
33510
+ return void 0;
33511
+ }
33512
+ }
33513
+ const style2 = {
33514
+ ...{},
33515
+ ...{},
33516
+ ...{},
33517
+ ...{},
33518
+ ...{},
33519
+ ...{}
33520
+ };
33521
+ const shading = getFirstChildByTagNameNS(cellProperties, WORD_NS, "shd");
33522
+ const fill = parseShdFill(shading);
33523
+ if (fill) {
33524
+ style2.shading = fill;
33525
+ }
33526
+ const cellWidth = getFirstChildByTagNameNS(cellProperties, WORD_NS, "tcW");
33527
+ const cellWidthType = getAttributeValue(cellWidth, "type");
33528
+ const cellWidthValue = getAttributeValue(cellWidth, "w");
33529
+ if (cellWidthType === "dxa") {
33530
+ const width = twipsToPoints(cellWidthValue);
33531
+ if (width !== void 0) {
33532
+ style2.width = width;
33533
+ }
33534
+ } else if (cellWidthType === "pct" && cellWidthValue) {
33535
+ const pct = Number(cellWidthValue);
33536
+ if (Number.isFinite(pct)) {
33537
+ style2.width = `${Math.round(pct / 50 * 1e4) / 1e4}%`;
33538
+ }
33539
+ }
33540
+ const tcMar = parseCellMargins(
33541
+ getFirstChildByTagNameNS(cellProperties, WORD_NS, "tcMar")
33542
+ );
33543
+ if (tcMar) {
33544
+ if (tcMar.top !== void 0) style2.paddingTop = tcMar.top;
33545
+ if (tcMar.bottom !== void 0) style2.paddingBottom = tcMar.bottom;
33546
+ if (tcMar.left !== void 0) style2.paddingLeft = tcMar.left;
33547
+ if (tcMar.right !== void 0) style2.paddingRight = tcMar.right;
33548
+ if (tcMar.start !== void 0) style2.paddingStart = tcMar.start;
33549
+ if (tcMar.end !== void 0) style2.paddingEnd = tcMar.end;
33550
+ }
33551
+ const verticalAlign = parseTableCellVerticalAlign(cellProperties);
33552
+ if (verticalAlign) {
33553
+ style2.verticalAlign = verticalAlign;
33554
+ }
33555
+ const textDirection = parseTextDirection(
33556
+ getAttributeValue(
33557
+ getFirstChildByTagNameNS(cellProperties, WORD_NS, "textDirection"),
33558
+ "val"
33559
+ )
33560
+ );
33561
+ if (textDirection) {
33562
+ style2.textDirection = textDirection;
33563
+ }
33564
+ const noWrap = parseOnOffProperty(cellProperties, "noWrap");
33565
+ if (noWrap !== void 0) {
33566
+ style2.noWrap = noWrap;
33567
+ }
33568
+ const fitText = parseOnOffProperty(cellProperties, "tcFitText");
33569
+ if (fitText !== void 0) {
33570
+ style2.fitText = fitText;
33571
+ }
33572
+ const hideMark = parseOnOffProperty(cellProperties, "hideMark");
33573
+ if (hideMark !== void 0) {
33574
+ style2.hideMark = hideMark;
33575
+ }
33576
+ const headers = getAttributeValue(
33577
+ getFirstChildByTagNameNS(cellProperties, WORD_NS, "headers"),
33578
+ "val"
33579
+ );
33580
+ if (headers) {
33581
+ style2.headers = headers;
33582
+ }
33583
+ const change = getFirstChildByTagNameNS(
33584
+ cellProperties,
33585
+ WORD_NS,
33586
+ "tcPrChange"
33587
+ );
33588
+ const previousProperties = getFirstChildByTagNameNS(change, WORD_NS, "tcPr");
33589
+ if (change && previousProperties) {
33590
+ style2.propertyRevision = {
33591
+ ...parseRevisionMetadata(change),
33592
+ type: "property",
33593
+ previous: parseTableCellStyle(previousProperties) ?? {}
33594
+ };
33595
+ }
33596
+ const inserted = getFirstChildByTagNameNS(cellProperties, WORD_NS, "cellIns");
33597
+ const deleted = getFirstChildByTagNameNS(cellProperties, WORD_NS, "cellDel");
33598
+ const merged = getFirstChildByTagNameNS(cellProperties, WORD_NS, "cellMerge");
33599
+ const structural = inserted ?? deleted ?? merged;
33600
+ if (structural) {
33601
+ const originalMerge = getAttributeValue(structural, "vMergeOrig");
33602
+ style2.revision = {
33603
+ ...parseRevisionMetadata(structural),
33604
+ type: inserted ? "insert" : deleted ? "delete" : "merge",
33605
+ ...merged && originalMerge ? {
33606
+ previous: {
33607
+ vMerge: originalMerge === "restart" ? "restart" : "continue"
33608
+ }
33609
+ } : {}
33610
+ };
33611
+ }
33612
+ for (const [key, border] of Object.entries(
33613
+ parseTableCellBorders(cellProperties)
33614
+ )) {
33615
+ if (border) {
33616
+ style2[key] = border;
33617
+ }
33618
+ }
33619
+ return emptyOrUndefined(style2);
33620
+ }
33621
+ function isTableHeaderRow(rowNode) {
33622
+ const rowProperties = getFirstChildByTagNameNS(rowNode, WORD_NS, "trPr");
33623
+ return rowProperties ? parseOnOffProperty(rowProperties, "tblHeader") === true : false;
33624
+ }
33625
+ function collapseCellAutospacing(paragraphs, flags) {
33626
+ var _a, _b;
33627
+ const styleOf = (paragraph) => paragraph.style ?? (paragraph.style = {});
33628
+ const lastIndex = paragraphs.length - 1;
33629
+ for (let index = 0; index < paragraphs.length; index += 1) {
33630
+ const flag = flags[index];
33631
+ if (!flag) {
33632
+ continue;
33633
+ }
33634
+ if (index === 0 && flag.before) {
33635
+ styleOf(paragraphs[index]).spacingBefore = 0;
33636
+ }
33637
+ if (index === lastIndex && flag.after) {
33638
+ styleOf(paragraphs[index]).spacingAfter = 0;
33639
+ }
33640
+ }
33641
+ for (let index = 0; index < lastIndex; index += 1) {
33642
+ if (!((_a = flags[index]) == null ? void 0 : _a.after) || !((_b = flags[index + 1]) == null ? void 0 : _b.before)) {
33643
+ continue;
33644
+ }
33645
+ const prev = styleOf(paragraphs[index]);
33646
+ const next = styleOf(paragraphs[index + 1]);
33647
+ if ((prev.spacingAfter ?? 0) >= (next.spacingBefore ?? 0)) {
33648
+ next.spacingBefore = 0;
33649
+ } else {
33650
+ prev.spacingAfter = 0;
32491
33651
  }
32492
33652
  }
32493
- const cantSplit = parseOnOffProperty(trPr, "cantSplit");
32494
- if (cantSplit !== void 0) style2.cantSplit = cantSplit;
32495
- const hidden = parseOnOffProperty(trPr, "hidden");
32496
- if (hidden !== void 0) style2.hidden = hidden;
32497
- return Object.keys(style2).length > 0 ? style2 : void 0;
32498
33653
  }
32499
33654
  function parseImportedStyles(stylesXml, theme) {
32500
33655
  if (!stylesXml) {
@@ -32566,8 +33721,6 @@ function parseImportedStyles(stylesXml, theme) {
32566
33721
  let tableStyle;
32567
33722
  if (type === "table") {
32568
33723
  const tblPr = getFirstChildByTagNameNS(styleElement, WORD_NS, "tblPr");
32569
- const tblInd = getFirstChildByTagNameNS(tblPr, WORD_NS, "tblInd");
32570
- const indentLeft = twipsToPoints(getAttributeValue(tblInd, "w"));
32571
33724
  const parseBandSize = (localName) => {
32572
33725
  const raw = getAttributeValue(
32573
33726
  getFirstChildByTagNameNS(tblPr, WORD_NS, localName),
@@ -32587,6 +33740,10 @@ function parseImportedStyles(stylesXml, theme) {
32587
33740
  const condType = getAttributeValue(tblStylePr, "type");
32588
33741
  if (!condType) continue;
32589
33742
  const tcPr = getFirstChildByTagNameNS(tblStylePr, WORD_NS, "tcPr");
33743
+ const conditionalCellStyle = parseTableCellStyle(tcPr);
33744
+ const conditionalTableStyle = parseTableStyle(
33745
+ getFirstChildByTagNameNS(tblStylePr, WORD_NS, "tblPr")
33746
+ );
32590
33747
  const shd = getFirstChildByTagNameNS(tcPr, WORD_NS, "shd");
32591
33748
  const fill = parseShdFill(shd);
32592
33749
  const condTextStyle = parseRunStyle(
@@ -32601,22 +33758,23 @@ function parseImportedStyles(stylesXml, theme) {
32601
33758
  const condParagraphStyle = parseParagraphStyle$1(
32602
33759
  getFirstChildByTagNameNS(tblStylePr, WORD_NS, "pPr")
32603
33760
  );
32604
- const condRowStyle = parseConditionalRowStyle(
33761
+ const condRowStyle = parseTableRowStyle(
32605
33762
  getFirstChildByTagNameNS(tblStylePr, WORD_NS, "trPr")
32606
33763
  );
32607
- if (fill || condTextStyle || condBorders || condParagraphStyle || condRowStyle) {
33764
+ if (fill || condTextStyle || condBorders || condParagraphStyle || condRowStyle || conditionalCellStyle || conditionalTableStyle) {
32608
33765
  conditionalFormats[condType] = {
32609
33766
  ...fill ? { shading: fill } : {},
32610
33767
  ...condTextStyle ? { textStyle: condTextStyle } : {},
32611
33768
  ...condBorders ? { borders: condBorders } : {},
32612
33769
  ...condParagraphStyle ? { paragraphStyle: condParagraphStyle } : {},
32613
- ...condRowStyle ? { rowStyle: condRowStyle } : {}
33770
+ ...condRowStyle ? { rowStyle: condRowStyle } : {},
33771
+ ...conditionalCellStyle ? { cellStyle: conditionalCellStyle } : {},
33772
+ ...conditionalTableStyle ? { tableStyle: conditionalTableStyle } : {}
32614
33773
  };
32615
33774
  }
32616
33775
  }
32617
33776
  tableStyle = {
32618
- styleId: id,
32619
- indentLeft,
33777
+ ...parseTableStyle(tblPr, id) ?? { styleId: id },
32620
33778
  ...rowBandSize !== void 0 ? { rowBandSize } : {},
32621
33779
  ...colBandSize !== void 0 ? { colBandSize } : {},
32622
33780
  ...Object.keys(conditionalFormats).length > 0 ? { conditionalFormats } : {}
@@ -32630,6 +33788,7 @@ function parseImportedStyles(stylesXml, theme) {
32630
33788
  id,
32631
33789
  name,
32632
33790
  type,
33791
+ isDefault: isWordTrue(getAttributeValue(styleElement, "default")),
32633
33792
  basedOn,
32634
33793
  nextStyle,
32635
33794
  qFormat,
@@ -34057,7 +35216,7 @@ async function parseParagraphNodes(paragraphNode, numberingMaps, zip, relsMap, a
34057
35216
  };
34058
35217
  }
34059
35218
  const paragraphStyle = normalizeImportedParagraphStyle(
34060
- inheritedStyle ? { ...inheritedStyle, ...styleWithListIndent ?? {} } : styleWithListIndent
35219
+ styleWithListIndent
34061
35220
  );
34062
35221
  const dropCapFrame = parseDropCapFrame(paragraphProperties, runs);
34063
35222
  if (dropCapFrame) {
@@ -34101,8 +35260,7 @@ async function parseParagraphNode(paragraphNode, numberingMaps, zip, relsMap, as
34101
35260
  relsMap,
34102
35261
  assets,
34103
35262
  theme,
34104
- parseNestedBlocks,
34105
- inheritedStyle
35263
+ parseNestedBlocks
34106
35264
  );
34107
35265
  return parsed.paragraphs[0] ?? createEditorParagraphFromRuns([{ text: "" }]);
34108
35266
  }
@@ -34124,521 +35282,7 @@ function parseTableLook(tblPr) {
34124
35282
  noVBand: attr("noVBand") ?? bit(1024) ?? false
34125
35283
  };
34126
35284
  }
34127
- function resolveCellConditionalKeys(rowIndex, colIndex, rowCount, colCount, look, rowBandSize, colBandSize) {
34128
- const isFirstRow = look.firstRow && rowIndex === 0;
34129
- const isLastRow = look.lastRow && rowIndex === rowCount - 1 && rowIndex !== 0;
34130
- const isFirstCol = look.firstCol && colIndex === 0;
34131
- const isLastCol = look.lastCol && colIndex === colCount - 1 && colIndex !== 0;
34132
- const keys = [];
34133
- if (!look.noHBand && !isFirstRow && !isLastRow) {
34134
- const bodyRow = rowIndex - (look.firstRow ? 1 : 0);
34135
- const band = Math.floor(bodyRow / Math.max(1, rowBandSize)) % 2;
34136
- keys.push(band === 0 ? "band1Horz" : "band2Horz");
34137
- }
34138
- if (!look.noVBand && !isFirstCol && !isLastCol) {
34139
- const bodyCol = colIndex - (look.firstCol ? 1 : 0);
34140
- const band = Math.floor(bodyCol / Math.max(1, colBandSize)) % 2;
34141
- keys.push(band === 0 ? "band1Vert" : "band2Vert");
34142
- }
34143
- if (isLastCol) keys.push("lastCol");
34144
- if (isFirstCol) keys.push("firstCol");
34145
- if (isLastRow) keys.push("lastRow");
34146
- if (isFirstRow) keys.push("firstRow");
34147
- if (isFirstRow && isFirstCol) keys.push("nwCell");
34148
- if (isFirstRow && isLastCol) keys.push("neCell");
34149
- if (isLastRow && isFirstCol) keys.push("swCell");
34150
- if (isLastRow && isLastCol) keys.push("seCell");
34151
- return keys;
34152
- }
34153
- function mergeConditionalFormats(keys, conditionals) {
34154
- const merged = {};
34155
- if (!conditionals) {
34156
- return merged;
34157
- }
34158
- for (const key of keys) {
34159
- const cond = conditionals[key];
34160
- if (!cond) continue;
34161
- if (cond.shading) merged.shading = cond.shading;
34162
- if (cond.textStyle) {
34163
- merged.textStyle = { ...merged.textStyle, ...cond.textStyle };
34164
- }
34165
- if (cond.borders) {
34166
- merged.borders = { ...merged.borders, ...cond.borders };
34167
- }
34168
- if (cond.paragraphStyle) {
34169
- merged.paragraphStyle = {
34170
- ...merged.paragraphStyle,
34171
- ...cond.paragraphStyle
34172
- };
34173
- }
34174
- if (cond.rowStyle) {
34175
- merged.rowStyle = { ...merged.rowStyle, ...cond.rowStyle };
34176
- }
34177
- }
34178
- return merged;
34179
- }
34180
- function applyConditionalTextStyle(paragraphs, textStyle) {
34181
- if (!textStyle || Object.keys(textStyle).length === 0) {
34182
- return;
34183
- }
34184
- for (const paragraph of paragraphs) {
34185
- for (const run of paragraph.runs) {
34186
- run.styles = { ...textStyle, ...run.styles };
34187
- }
34188
- }
34189
- }
34190
- function tableStyleParagraphInheritance(tableStylePPr, paragraphStyleId, styles) {
34191
- if (!tableStylePPr) {
34192
- return void 0;
34193
- }
34194
- const effectiveStyleId = paragraphStyleId ?? resolveDefaultParagraphStyleId(styles);
34195
- const paragraphStyleDelta = resolveNamedParagraphStyle(
34196
- effectiveStyleId,
34197
- styles
34198
- );
34199
- const definedByParagraphStyle = new Set(Object.keys(paragraphStyleDelta));
34200
- const filtered = {};
34201
- for (const [key, value] of Object.entries(tableStylePPr)) {
34202
- if (!definedByParagraphStyle.has(key)) {
34203
- filtered[key] = value;
34204
- }
34205
- }
34206
- return emptyOrUndefined(filtered);
34207
- }
34208
- function parseDocxWidthValue(element) {
34209
- if (!element) {
34210
- return void 0;
34211
- }
34212
- const type = getAttributeValue(element, "type");
34213
- const raw = getAttributeValue(element, "w");
34214
- if (type === "auto") {
34215
- return "auto";
34216
- }
34217
- if (type === "pct") {
34218
- if (!raw) {
34219
- return void 0;
34220
- }
34221
- const pct = raw.trim().endsWith("%") ? Number.parseFloat(raw) : Number(raw) / 50;
34222
- return Number.isFinite(pct) ? `${Math.round(pct * 1e4) / 1e4}%` : void 0;
34223
- }
34224
- return twipsToPoints(raw);
34225
- }
34226
- function parsePositiveIntegerProperty(parent, localName) {
34227
- const element = getFirstChildByTagNameNS(parent, WORD_NS, localName);
34228
- const raw = getAttributeValue(element, "val");
34229
- const parsed = raw ? Number(raw) : Number.NaN;
34230
- return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : void 0;
34231
- }
34232
- function serializeChildXml(parent, localNames) {
34233
- if (!parent) {
34234
- return void 0;
34235
- }
34236
- const names = new Set(localNames);
34237
- const serializer = new XMLSerializer();
34238
- const result = [];
34239
- const children2 = parent.childNodes;
34240
- for (let index = 0; index < children2.length; index += 1) {
34241
- const node = children2[index];
34242
- if ((node == null ? void 0 : node.nodeType) === node.ELEMENT_NODE && node.namespaceURI === WORD_NS && names.has(node.localName ?? "")) {
34243
- result.push(serializer.serializeToString(node));
34244
- }
34245
- }
34246
- return result.length > 0 ? result : void 0;
34247
- }
34248
- function parseFloatingTableProperties(tblPr) {
34249
- const tblpPr = getFirstChildByTagNameNS(tblPr, WORD_NS, "tblpPr");
34250
- if (!tblpPr || !tblpPr.attributes || tblpPr.attributes.length === 0) {
34251
- return void 0;
34252
- }
34253
- const floating = {};
34254
- for (let index = 0; index < tblpPr.attributes.length; index += 1) {
34255
- const attr = tblpPr.attributes.item(index);
34256
- if ((attr == null ? void 0 : attr.namespaceURI) === WORD_NS || (attr == null ? void 0 : attr.prefix) === "w") {
34257
- floating[attr.localName || attr.name.replace(/^w:/, "")] = attr.value;
34258
- }
34259
- }
34260
- return Object.keys(floating).length > 0 ? floating : void 0;
34261
- }
34262
- function parseCellMargins(container) {
34263
- if (!container) {
34264
- return void 0;
34265
- }
34266
- const edgePt = (edge) => twipsToPoints(
34267
- getAttributeValue(getFirstChildByTagNameNS(container, WORD_NS, edge), "w")
34268
- );
34269
- const margins = {};
34270
- const top = edgePt("top");
34271
- const right = edgePt("right");
34272
- const bottom = edgePt("bottom");
34273
- const left = edgePt("left");
34274
- const start = edgePt("start");
34275
- const end = edgePt("end");
34276
- if (top !== void 0) margins.top = top;
34277
- if (right !== void 0) margins.right = right;
34278
- if (bottom !== void 0) margins.bottom = bottom;
34279
- if (left !== void 0) margins.left = left;
34280
- if (start !== void 0) margins.start = start;
34281
- if (end !== void 0) margins.end = end;
34282
- return Object.keys(margins).length > 0 ? margins : void 0;
34283
- }
34284
- function parseTableLayout(tblPr) {
34285
- const value = getAttributeValue(
34286
- getFirstChildByTagNameNS(tblPr, WORD_NS, "tblLayout"),
34287
- "type"
34288
- );
34289
- return value === "fixed" || value === "autofit" ? value : void 0;
34290
- }
34291
- function parseTableStyle(tblPr, tableStyleId) {
34292
- const style2 = {};
34293
- if (tableStyleId) {
34294
- style2.styleId = tableStyleId;
34295
- }
34296
- const altTitle = getAttributeValue(
34297
- getFirstChildByTagNameNS(tblPr, WORD_NS, "tblCaption"),
34298
- "val"
34299
- );
34300
- if (altTitle) {
34301
- style2.altTitle = altTitle;
34302
- }
34303
- const altDescription = getAttributeValue(
34304
- getFirstChildByTagNameNS(tblPr, WORD_NS, "tblDescription"),
34305
- "val"
34306
- );
34307
- if (altDescription) {
34308
- style2.altDescription = altDescription;
34309
- }
34310
- const width = parseDocxWidthValue(
34311
- getFirstChildByTagNameNS(tblPr, WORD_NS, "tblW")
34312
- );
34313
- if (width !== void 0) {
34314
- style2.width = width;
34315
- }
34316
- const indentLeft = parseDocxWidthValue(
34317
- getFirstChildByTagNameNS(tblPr, WORD_NS, "tblInd")
34318
- );
34319
- if (indentLeft !== void 0) {
34320
- style2.indentLeft = indentLeft;
34321
- }
34322
- const jc = getAttributeValue(
34323
- getFirstChildByTagNameNS(tblPr, WORD_NS, "jc"),
34324
- "val"
34325
- );
34326
- if (jc === "left" || jc === "center" || jc === "right") {
34327
- style2.align = jc;
34328
- }
34329
- const layout = parseTableLayout(tblPr);
34330
- if (layout) {
34331
- style2.layout = layout;
34332
- }
34333
- const cellSpacing = parseDocxWidthValue(
34334
- getFirstChildByTagNameNS(tblPr, WORD_NS, "tblCellSpacing")
34335
- );
34336
- if (cellSpacing !== void 0) {
34337
- style2.cellSpacing = cellSpacing;
34338
- }
34339
- const defaultCellMargins = parseCellMargins(
34340
- getFirstChildByTagNameNS(tblPr, WORD_NS, "tblCellMar")
34341
- );
34342
- if (defaultCellMargins) {
34343
- style2.defaultCellMargins = defaultCellMargins;
34344
- }
34345
- const bidiVisual = tblPr ? parseOnOffProperty(tblPr, "bidiVisual") : void 0;
34346
- if (bidiVisual !== void 0) {
34347
- style2.bidiVisual = bidiVisual;
34348
- }
34349
- const tblOverlap = getAttributeValue(
34350
- getFirstChildByTagNameNS(tblPr, WORD_NS, "tblOverlap"),
34351
- "val"
34352
- );
34353
- if (tblOverlap) {
34354
- style2.tblOverlap = tblOverlap;
34355
- }
34356
- const floating = parseFloatingTableProperties(tblPr);
34357
- if (floating) {
34358
- style2.floating = floating;
34359
- }
34360
- const revisionXml = serializeChildXml(tblPr, ["tblPrChange"]);
34361
- if (revisionXml) {
34362
- style2.revisionXml = revisionXml;
34363
- }
34364
- return emptyOrUndefined(style2);
34365
- }
34366
- function parseTableRowStyle(rowProperties) {
34367
- if (!rowProperties) {
34368
- return void 0;
34369
- }
34370
- const style2 = {};
34371
- const gridBefore = parsePositiveIntegerProperty(rowProperties, "gridBefore");
34372
- if (gridBefore !== void 0) {
34373
- style2.gridBefore = gridBefore;
34374
- }
34375
- const gridAfter = parsePositiveIntegerProperty(rowProperties, "gridAfter");
34376
- if (gridAfter !== void 0) {
34377
- style2.gridAfter = gridAfter;
34378
- }
34379
- const widthBefore = parseDocxWidthValue(
34380
- getFirstChildByTagNameNS(rowProperties, WORD_NS, "wBefore")
34381
- );
34382
- if (widthBefore !== void 0) {
34383
- style2.widthBefore = widthBefore;
34384
- }
34385
- const widthAfter = parseDocxWidthValue(
34386
- getFirstChildByTagNameNS(rowProperties, WORD_NS, "wAfter")
34387
- );
34388
- if (widthAfter !== void 0) {
34389
- style2.widthAfter = widthAfter;
34390
- }
34391
- const trHeight = getFirstChildByTagNameNS(rowProperties, WORD_NS, "trHeight");
34392
- const height = twipsToPoints(getAttributeValue(trHeight, "val"));
34393
- if (height !== void 0) {
34394
- style2.height = height;
34395
- }
34396
- const hRule = getAttributeValue(trHeight, "hRule");
34397
- if (hRule === "auto" || hRule === "exact" || hRule === "atLeast") {
34398
- style2.heightRule = hRule;
34399
- }
34400
- const cellSpacing = parseDocxWidthValue(
34401
- getFirstChildByTagNameNS(rowProperties, WORD_NS, "tblCellSpacing")
34402
- );
34403
- if (cellSpacing !== void 0) {
34404
- style2.cellSpacing = cellSpacing;
34405
- }
34406
- const cantSplit = parseOnOffProperty(rowProperties, "cantSplit");
34407
- if (cantSplit !== void 0) {
34408
- style2.cantSplit = cantSplit;
34409
- }
34410
- const hidden = parseOnOffProperty(rowProperties, "hidden");
34411
- if (hidden !== void 0) {
34412
- style2.hidden = hidden;
34413
- }
34414
- const revisionXml = serializeChildXml(rowProperties, [
34415
- "trPrChange",
34416
- "ins",
34417
- "del"
34418
- ]);
34419
- if (revisionXml) {
34420
- style2.revisionXml = revisionXml;
34421
- }
34422
- return emptyOrUndefined(style2);
34423
- }
34424
- function getTableCellColSpan(cellProperties) {
34425
- if (!cellProperties) {
34426
- return 1;
34427
- }
34428
- const gridSpan = getFirstChildByTagNameNS(
34429
- cellProperties,
34430
- WORD_NS,
34431
- "gridSpan"
34432
- );
34433
- const value = getAttributeValue(gridSpan, "val");
34434
- const parsed = value ? Number(value) : 1;
34435
- return Number.isFinite(parsed) && parsed > 1 ? Math.floor(parsed) : 1;
34436
- }
34437
- function getTableCellVMerge(cellProperties) {
34438
- if (!cellProperties) {
34439
- return void 0;
34440
- }
34441
- const vMerge = getFirstChildByTagNameNS(cellProperties, WORD_NS, "vMerge");
34442
- if (!vMerge) {
34443
- return void 0;
34444
- }
34445
- const value = getAttributeValue(vMerge, "val");
34446
- return value === "restart" ? "restart" : "continue";
34447
- }
34448
- function parseTableCellVerticalAlign(cellProperties) {
34449
- if (!cellProperties) {
34450
- return void 0;
34451
- }
34452
- const vAlign = getFirstChildByTagNameNS(cellProperties, WORD_NS, "vAlign");
34453
- const value = getAttributeValue(vAlign, "val");
34454
- if (value === "top" || value === "bottom") {
34455
- return value;
34456
- }
34457
- if (value === "center") {
34458
- return "middle";
34459
- }
34460
- return void 0;
34461
- }
34462
- function parseTableCellBorders(cellProperties) {
34463
- if (!cellProperties) {
34464
- return {};
34465
- }
34466
- return parseDocxBoxBorders(
34467
- getFirstChildByTagNameNS(cellProperties, WORD_NS, "tcBorders")
34468
- );
34469
- }
34470
- function parseTableCellStyle(cellProperties, tableDefaultMargins) {
34471
- if (!cellProperties) {
34472
- if (!tableDefaultMargins) {
34473
- return void 0;
34474
- }
34475
- return emptyOrUndefined({
34476
- paddingTop: tableDefaultMargins.top,
34477
- paddingRight: tableDefaultMargins.right,
34478
- paddingBottom: tableDefaultMargins.bottom,
34479
- paddingLeft: tableDefaultMargins.left,
34480
- paddingStart: tableDefaultMargins.start,
34481
- paddingEnd: tableDefaultMargins.end
34482
- });
34483
- }
34484
- const style2 = {
34485
- ...(tableDefaultMargins == null ? void 0 : tableDefaultMargins.top) !== void 0 ? { paddingTop: tableDefaultMargins.top } : {},
34486
- ...(tableDefaultMargins == null ? void 0 : tableDefaultMargins.right) !== void 0 ? { paddingRight: tableDefaultMargins.right } : {},
34487
- ...(tableDefaultMargins == null ? void 0 : tableDefaultMargins.bottom) !== void 0 ? { paddingBottom: tableDefaultMargins.bottom } : {},
34488
- ...(tableDefaultMargins == null ? void 0 : tableDefaultMargins.left) !== void 0 ? { paddingLeft: tableDefaultMargins.left } : {},
34489
- ...(tableDefaultMargins == null ? void 0 : tableDefaultMargins.start) !== void 0 ? { paddingStart: tableDefaultMargins.start } : {},
34490
- ...(tableDefaultMargins == null ? void 0 : tableDefaultMargins.end) !== void 0 ? { paddingEnd: tableDefaultMargins.end } : {}
34491
- };
34492
- const shading = getFirstChildByTagNameNS(cellProperties, WORD_NS, "shd");
34493
- const fill = parseShdFill(shading);
34494
- if (fill) {
34495
- style2.shading = fill;
34496
- }
34497
- const cellWidth = getFirstChildByTagNameNS(cellProperties, WORD_NS, "tcW");
34498
- const cellWidthType = getAttributeValue(cellWidth, "type");
34499
- const cellWidthValue = getAttributeValue(cellWidth, "w");
34500
- if (cellWidthType === "dxa") {
34501
- const width = twipsToPoints(cellWidthValue);
34502
- if (width !== void 0) {
34503
- style2.width = width;
34504
- }
34505
- } else if (cellWidthType === "pct" && cellWidthValue) {
34506
- const pct = Number(cellWidthValue);
34507
- if (Number.isFinite(pct)) {
34508
- style2.width = `${Math.round(pct / 50 * 1e4) / 1e4}%`;
34509
- }
34510
- }
34511
- const tcMar = parseCellMargins(
34512
- getFirstChildByTagNameNS(cellProperties, WORD_NS, "tcMar")
34513
- );
34514
- if (tcMar) {
34515
- if (tcMar.top !== void 0) style2.paddingTop = tcMar.top;
34516
- if (tcMar.bottom !== void 0) style2.paddingBottom = tcMar.bottom;
34517
- if (tcMar.left !== void 0) style2.paddingLeft = tcMar.left;
34518
- if (tcMar.right !== void 0) style2.paddingRight = tcMar.right;
34519
- if (tcMar.start !== void 0) style2.paddingStart = tcMar.start;
34520
- if (tcMar.end !== void 0) style2.paddingEnd = tcMar.end;
34521
- }
34522
- const verticalAlign = parseTableCellVerticalAlign(cellProperties);
34523
- if (verticalAlign) {
34524
- style2.verticalAlign = verticalAlign;
34525
- }
34526
- const textDirection = parseTextDirection(
34527
- getAttributeValue(
34528
- getFirstChildByTagNameNS(cellProperties, WORD_NS, "textDirection"),
34529
- "val"
34530
- )
34531
- );
34532
- if (textDirection) {
34533
- style2.textDirection = textDirection;
34534
- }
34535
- const noWrap = parseOnOffProperty(cellProperties, "noWrap");
34536
- if (noWrap !== void 0) {
34537
- style2.noWrap = noWrap;
34538
- }
34539
- const fitText = parseOnOffProperty(cellProperties, "tcFitText");
34540
- if (fitText !== void 0) {
34541
- style2.fitText = fitText;
34542
- }
34543
- const hideMark = parseOnOffProperty(cellProperties, "hideMark");
34544
- if (hideMark !== void 0) {
34545
- style2.hideMark = hideMark;
34546
- }
34547
- const headers = getAttributeValue(
34548
- getFirstChildByTagNameNS(cellProperties, WORD_NS, "headers"),
34549
- "val"
34550
- );
34551
- if (headers) {
34552
- style2.headers = headers;
34553
- }
34554
- const revisionXml = serializeChildXml(cellProperties, [
34555
- "tcPrChange",
34556
- "cellIns",
34557
- "cellDel",
34558
- "cellMerge"
34559
- ]);
34560
- if (revisionXml) {
34561
- style2.revisionXml = revisionXml;
34562
- }
34563
- for (const [key, border] of Object.entries(
34564
- parseTableCellBorders(cellProperties)
34565
- )) {
34566
- if (border) {
34567
- style2[key] = border;
34568
- }
34569
- }
34570
- return emptyOrUndefined(style2);
34571
- }
34572
- function isTableHeaderRow(rowNode) {
34573
- const rowProperties = getFirstChildByTagNameNS(rowNode, WORD_NS, "trPr");
34574
- return rowProperties ? parseOnOffProperty(rowProperties, "tblHeader") === true : false;
34575
- }
34576
- function collapseCellAutospacing(paragraphs, flags) {
34577
- var _a, _b;
34578
- const styleOf = (paragraph) => paragraph.style ?? (paragraph.style = {});
34579
- const lastIndex = paragraphs.length - 1;
34580
- for (let index = 0; index < paragraphs.length; index += 1) {
34581
- const flag = flags[index];
34582
- if (!flag) {
34583
- continue;
34584
- }
34585
- if (index === 0 && flag.before) {
34586
- styleOf(paragraphs[index]).spacingBefore = 0;
34587
- }
34588
- if (index === lastIndex && flag.after) {
34589
- styleOf(paragraphs[index]).spacingAfter = 0;
34590
- }
34591
- }
34592
- for (let index = 0; index < lastIndex; index += 1) {
34593
- if (!((_a = flags[index]) == null ? void 0 : _a.after) || !((_b = flags[index + 1]) == null ? void 0 : _b.before)) {
34594
- continue;
34595
- }
34596
- const prev = styleOf(paragraphs[index]);
34597
- const next = styleOf(paragraphs[index + 1]);
34598
- if ((prev.spacingAfter ?? 0) >= (next.spacingBefore ?? 0)) {
34599
- next.spacingBefore = 0;
34600
- } else {
34601
- prev.spacingAfter = 0;
34602
- }
34603
- }
34604
- }
34605
- function applyTableBordersToRows(rows, tblBorders) {
34606
- if (Object.keys(tblBorders).length === 0) {
34607
- return;
34608
- }
34609
- const lastRowIndex = rows.length - 1;
34610
- for (let rowIndex = 0; rowIndex <= lastRowIndex; rowIndex += 1) {
34611
- const row = rows[rowIndex];
34612
- const lastColIndex = row.cells.length - 1;
34613
- for (let colIndex = 0; colIndex <= lastColIndex; colIndex += 1) {
34614
- const cell = row.cells[colIndex];
34615
- const style2 = cell.style ?? {};
34616
- if (rowIndex === 0 && style2.borderTop === void 0 && tblBorders.borderTop) {
34617
- style2.borderTop = tblBorders.borderTop;
34618
- }
34619
- if (rowIndex === lastRowIndex && style2.borderBottom === void 0 && tblBorders.borderBottom) {
34620
- style2.borderBottom = tblBorders.borderBottom;
34621
- }
34622
- if (colIndex === 0 && style2.borderLeft === void 0 && tblBorders.borderLeft) {
34623
- style2.borderLeft = tblBorders.borderLeft;
34624
- }
34625
- if (colIndex === lastColIndex && style2.borderRight === void 0 && tblBorders.borderRight) {
34626
- style2.borderRight = tblBorders.borderRight;
34627
- }
34628
- if (rowIndex < lastRowIndex && style2.borderBottom === void 0 && tblBorders.borderInsideH) {
34629
- style2.borderBottom = tblBorders.borderInsideH;
34630
- }
34631
- if (colIndex < lastColIndex && style2.borderRight === void 0 && tblBorders.borderInsideV) {
34632
- style2.borderRight = tblBorders.borderInsideV;
34633
- }
34634
- if (Object.keys(style2).length > 0 && cell.style !== style2) {
34635
- cell.style = style2;
34636
- }
34637
- }
34638
- }
34639
- }
34640
- async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, theme, parseNestedBlocks, styles) {
34641
- var _a, _b;
35285
+ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, theme, parseNestedBlocks, _styles) {
34642
35286
  const gridCols = [];
34643
35287
  const tblGrid = getFirstChildByTagNameNS(tableNode, WORD_NS, "tblGrid");
34644
35288
  if (tblGrid) {
@@ -34660,39 +35304,14 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
34660
35304
  getFirstChildByTagNameNS(tblPr, WORD_NS, "tblStyle"),
34661
35305
  "val"
34662
35306
  );
34663
- const inheritedParagraphStyle = tableStyleId && ((_a = styles == null ? void 0 : styles[tableStyleId]) == null ? void 0 : _a.paragraphStyle) ? styles[tableStyleId].paragraphStyle : void 0;
34664
- const tblBorders = parseDocxTableBorders(
34665
- getFirstChildByTagNameNS(tblPr, WORD_NS, "tblBorders")
34666
- );
34667
- const tableStyleDef = tableStyleId ? (_b = styles == null ? void 0 : styles[tableStyleId]) == null ? void 0 : _b.tableStyle : void 0;
34668
35307
  const directTableStyle = parseTableStyle(tblPr, tableStyleId ?? void 0);
34669
- const tableDefaultMargins = directTableStyle == null ? void 0 : directTableStyle.defaultCellMargins;
34670
- const tblConditionals = (tableStyleDef == null ? void 0 : tableStyleDef.conditionalFormats) ?? void 0;
34671
35308
  const look = parseTableLook(tblPr);
34672
- const rowBandSize = (tableStyleDef == null ? void 0 : tableStyleDef.rowBandSize) ?? 1;
34673
- const colBandSize = (tableStyleDef == null ? void 0 : tableStyleDef.colBandSize) ?? 1;
34674
35309
  const rowNodes = getChildrenByTagNameNS(tableNode, WORD_NS, "tr");
34675
- const rowCount = rowNodes.length;
34676
- const colCount = gridCols.length > 0 ? gridCols.length : rowNodes.reduce(
34677
- (max, node) => Math.max(max, getChildrenByTagNameNS(node, WORD_NS, "tc").length),
34678
- 0
34679
- );
34680
35310
  const rows = [];
34681
35311
  for (let rowIndex = 0; rowIndex < rowNodes.length; rowIndex += 1) {
34682
35312
  const rowNode = rowNodes[rowIndex];
34683
35313
  const rowProperties = getFirstChildByTagNameNS(rowNode, WORD_NS, "trPr");
34684
- const cnfStyle = getFirstChildByTagNameNS(
34685
- rowProperties,
34686
- WORD_NS,
34687
- "cnfStyle"
34688
- );
34689
- const explicitRowKeys = [];
34690
- if (getAttributeValue(cnfStyle, "firstRow") === "1") {
34691
- explicitRowKeys.push("firstRow");
34692
- }
34693
- if (getAttributeValue(cnfStyle, "lastRow") === "1") {
34694
- explicitRowKeys.push("lastRow");
34695
- }
35314
+ const rowConditionalStyle = parseTableConditionalFlags(rowProperties);
34696
35315
  const cellNodes = getChildrenByTagNameNS(rowNode, WORD_NS, "tc");
34697
35316
  const cells = [];
34698
35317
  for (let colIndex = 0; colIndex < cellNodes.length; colIndex += 1) {
@@ -34709,19 +35328,6 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
34709
35328
  WORD_NS,
34710
35329
  "p"
34711
35330
  )) {
34712
- const paragraphStyleId = getAttributeValue(
34713
- getFirstChildByTagNameNS(
34714
- getFirstChildByTagNameNS(paragraphNode, WORD_NS, "pPr"),
34715
- WORD_NS,
34716
- "pStyle"
34717
- ),
34718
- "val"
34719
- ) ?? void 0;
34720
- const cellInheritedStyle = tableStyleParagraphInheritance(
34721
- inheritedParagraphStyle,
34722
- paragraphStyleId,
34723
- styles
34724
- );
34725
35331
  paragraphs.push(
34726
35332
  await parseParagraphNode(
34727
35333
  paragraphNode,
@@ -34730,8 +35336,7 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
34730
35336
  relsMap,
34731
35337
  assets,
34732
35338
  theme,
34733
- parseNestedBlocks,
34734
- cellInheritedStyle
35339
+ parseNestedBlocks
34735
35340
  )
34736
35341
  );
34737
35342
  autospacingFlags.push(
@@ -34743,55 +35348,14 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
34743
35348
  collapseCellAutospacing(paragraphs, autospacingFlags);
34744
35349
  const colSpan = getTableCellColSpan(cellProperties);
34745
35350
  const vMerge = getTableCellVMerge(cellProperties);
34746
- const cellStyle = parseTableCellStyle(cellProperties, tableDefaultMargins);
34747
- const conditional = mergeConditionalFormats(
34748
- [
34749
- ...resolveCellConditionalKeys(
34750
- rowIndex,
34751
- colIndex,
34752
- rowCount,
34753
- colCount,
34754
- look,
34755
- rowBandSize,
34756
- colBandSize
34757
- ),
34758
- ...explicitRowKeys
34759
- ],
34760
- tblConditionals
34761
- );
34762
- applyConditionalTextStyle(paragraphs, conditional.textStyle);
34763
- if (conditional.paragraphStyle) {
34764
- const condPStyle = conditional.paragraphStyle;
34765
- for (const paragraph of paragraphs) {
34766
- paragraph.style = { ...condPStyle, ...paragraph.style };
34767
- }
34768
- }
35351
+ const cellStyle = parseTableCellStyle(cellProperties);
34769
35352
  const cell = createEditorTableCell(
34770
35353
  paragraphs.length > 0 ? paragraphs : [createEditorParagraphFromRuns([{ text: "" }])],
34771
35354
  colSpan,
34772
35355
  vMerge === "restart" ? { rowSpan: 1, vMerge } : vMerge ? { vMerge } : void 0
34773
35356
  );
34774
- const mergedStyle = { ...cellStyle ?? {} };
34775
- const resolvedShading = (cellStyle == null ? void 0 : cellStyle.shading) ?? conditional.shading;
34776
- if (resolvedShading) {
34777
- mergedStyle.shading = resolvedShading;
34778
- }
34779
- if (conditional.borders) {
34780
- for (const edge of [
34781
- "borderTop",
34782
- "borderRight",
34783
- "borderBottom",
34784
- "borderLeft"
34785
- ]) {
34786
- const border = conditional.borders[edge];
34787
- if (mergedStyle[edge] === void 0 && border) {
34788
- mergedStyle[edge] = border;
34789
- }
34790
- }
34791
- }
34792
- if (Object.keys(mergedStyle).length > 0) {
34793
- cell.style = mergedStyle;
34794
- }
35357
+ if (cellStyle) cell.style = cellStyle;
35358
+ cell.conditionalStyle = parseTableConditionalFlags(cellProperties);
34795
35359
  if (vMerge === "continue") {
34796
35360
  cell.blocks = [];
34797
35361
  }
@@ -34805,33 +35369,13 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
34805
35369
  if (rowStyle) {
34806
35370
  row.style = rowStyle;
34807
35371
  }
34808
- if (tblConditionals) {
34809
- const rowKeys = resolveCellConditionalKeys(
34810
- rowIndex,
34811
- 0,
34812
- rowCount,
34813
- Math.max(1, colCount),
34814
- look,
34815
- rowBandSize,
34816
- colBandSize
34817
- ).filter(
34818
- (k) => k === "firstRow" || k === "lastRow" || k === "band1Horz" || k === "band2Horz"
34819
- );
34820
- const mergedRowConditional = mergeConditionalFormats(
34821
- [...explicitRowKeys, ...rowKeys],
34822
- tblConditionals
34823
- );
34824
- if (mergedRowConditional.rowStyle) {
34825
- row.style = { ...mergedRowConditional.rowStyle, ...row.style };
34826
- }
34827
- }
35372
+ row.conditionalStyle = rowConditionalStyle;
34828
35373
  const tblPrEx = getFirstChildByTagNameNS(rowNode, WORD_NS, "tblPrEx");
34829
35374
  if (tblPrEx) {
34830
35375
  row.tblPrExXml = new XMLSerializer().serializeToString(tblPrEx);
34831
35376
  }
34832
35377
  rows.push(row);
34833
35378
  }
34834
- applyTableBordersToRows(rows, tblBorders);
34835
35379
  for (let rowIndex = 0; rowIndex < rows.length; rowIndex += 1) {
34836
35380
  const row = rows[rowIndex];
34837
35381
  for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
@@ -34865,9 +35409,21 @@ async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, th
34865
35409
  table.style = { tblLook: look };
34866
35410
  }
34867
35411
  if (tblGridChangeXml) {
34868
- table.tblGridChangeXml = new XMLSerializer().serializeToString(
34869
- tblGridChangeXml
35412
+ const previousGrid = getFirstChildByTagNameNS(
35413
+ tblGridChangeXml,
35414
+ WORD_NS,
35415
+ "tblGrid"
34870
35416
  );
35417
+ const previous = previousGrid ? getChildrenByTagNameNS(previousGrid, WORD_NS, "gridCol").map((gridCol) => twipsToPoints(getAttributeValue(gridCol, "w"))).filter((width) => width !== void 0) : [];
35418
+ const rawDate = getAttributeValue(tblGridChangeXml, "date");
35419
+ const parsedDate = rawDate ? Date.parse(rawDate) : Number.NaN;
35420
+ table.gridRevision = {
35421
+ id: getAttributeValue(tblGridChangeXml, "id") ?? "revision:grid",
35422
+ author: getAttributeValue(tblGridChangeXml, "author") ?? "Unknown",
35423
+ date: Number.isFinite(parsedDate) ? parsedDate : 0,
35424
+ type: "grid",
35425
+ previous
35426
+ };
34871
35427
  }
34872
35428
  return table;
34873
35429
  }
@@ -34972,8 +35528,7 @@ async function parseHeaderFooterXml(xmlContent, numberingMaps, zip, relsMap, ass
34972
35528
  relsMap,
34973
35529
  assets,
34974
35530
  theme,
34975
- parseNestedBlocks,
34976
- styles
35531
+ parseNestedBlocks
34977
35532
  )
34978
35533
  );
34979
35534
  }
@@ -35041,8 +35596,7 @@ async function parseDocxNotesXml(kind, xmlContent, numberingMaps, zip, relsMap,
35041
35596
  relsMap,
35042
35597
  assets,
35043
35598
  theme,
35044
- parseNestedBlocks,
35045
- styles
35599
+ parseNestedBlocks
35046
35600
  )
35047
35601
  );
35048
35602
  }
@@ -35083,8 +35637,7 @@ async function parseFootnotesXml(xmlContent, numberingMaps, zip, relsMap, assets
35083
35637
  zip,
35084
35638
  relsMap,
35085
35639
  assets,
35086
- theme,
35087
- styles
35640
+ theme
35088
35641
  );
35089
35642
  return {
35090
35643
  byDocxId: parsed.byDocxId,
@@ -35101,8 +35654,7 @@ async function parseEndnotesXml(xmlContent, numberingMaps, zip, relsMap, assets,
35101
35654
  zip,
35102
35655
  relsMap,
35103
35656
  assets,
35104
- theme,
35105
- styles
35657
+ theme
35106
35658
  );
35107
35659
  return {
35108
35660
  byDocxId: parsed.byDocxId,
@@ -35481,8 +36033,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
35481
36033
  relsMap,
35482
36034
  assets,
35483
36035
  theme,
35484
- parseNestedBlocks,
35485
- importedStyles
36036
+ parseNestedBlocks
35486
36037
  )
35487
36038
  );
35488
36039
  reportBodyProgress();
@@ -35550,8 +36101,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
35550
36101
  zip,
35551
36102
  partRelsMap,
35552
36103
  assets,
35553
- theme,
35554
- importedStyles
36104
+ theme
35555
36105
  );
35556
36106
  applyDocGridLinePitch(
35557
36107
  partBlocks,
@@ -35611,8 +36161,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
35611
36161
  zip,
35612
36162
  footnotesPartRels,
35613
36163
  assets,
35614
- theme,
35615
- importedStyles
36164
+ theme
35616
36165
  );
35617
36166
  if (docSettings.footnoteSettings) {
35618
36167
  parsedFootnotes.footnotes.settings = docSettings.footnoteSettings;
@@ -35627,8 +36176,7 @@ async function importDocxToEditorDocument(buffer, options = {}) {
35627
36176
  zip,
35628
36177
  endnotesPartRels,
35629
36178
  assets,
35630
- theme,
35631
- importedStyles
36179
+ theme
35632
36180
  );
35633
36181
  if (docSettings.endnoteSettings) {
35634
36182
  parsedEndnotes.endnotes.settings = docSettings.endnoteSettings;
@@ -35841,7 +36389,7 @@ function importDocxInWorker(buffer, options = {}) {
35841
36389
  const worker = new Worker(
35842
36390
  new URL(
35843
36391
  /* @vite-ignore */
35844
- "" + new URL("assets/importDocxWorker-BcELKms0.js", import.meta.url).href,
36392
+ "" + new URL("assets/importDocxWorker-DVDyiqYf.js", import.meta.url).href,
35845
36393
  import.meta.url
35846
36394
  ),
35847
36395
  {
@@ -40206,7 +40754,7 @@ export {
40206
40754
  createRenderEffect as Z,
40207
40755
  style as _,
40208
40756
  assertNever as a,
40209
- defaultFontDecoderRegistry as a$,
40757
+ loadFontAsset as a$,
40210
40758
  setStyleProperty as a0,
40211
40759
  memo as a1,
40212
40760
  template as a2,
@@ -40226,24 +40774,24 @@ export {
40226
40774
  getPresetPathSegments as aG,
40227
40775
  projectBlocksLayout as aH,
40228
40776
  buildListLabels as aI,
40229
- textStyleToFontSizePt as aJ,
40230
- PX_PER_POINT as aK,
40231
- DEFAULT_FONT_SIZE_PX as aL,
40232
- isDoubleUnderlineStyle as aM,
40233
- isWavyUnderlineStyle as aN,
40234
- underlineStyleLineWidthPx as aO,
40235
- underlineStyleDashArray as aP,
40236
- resolveListLabel as aQ,
40237
- getListLabelInset as aR,
40238
- getAlignedListLabelInset as aS,
40239
- getParagraphBorderInsets as aT,
40240
- buildSegmentTable as aU,
40241
- buildCanvasTableLayout as aV,
40242
- normalizeFamily as aW,
40243
- ROBOTO_FONT_FILES as aX,
40244
- loadFontAsset as aY,
40245
- OFFICE_COMPAT_FONT_FAMILIES as aZ,
40246
- buildSfnt as a_,
40777
+ getImageFloatingGeometry as aJ,
40778
+ textStyleToFontSizePt as aK,
40779
+ PX_PER_POINT as aL,
40780
+ DEFAULT_FONT_SIZE_PX as aM,
40781
+ isDoubleUnderlineStyle as aN,
40782
+ isWavyUnderlineStyle as aO,
40783
+ underlineStyleLineWidthPx as aP,
40784
+ underlineStyleDashArray as aQ,
40785
+ resolveListLabel as aR,
40786
+ getListLabelInset as aS,
40787
+ getAlignedListLabelInset as aT,
40788
+ getParagraphBorderInsets as aU,
40789
+ buildSegmentTable as aV,
40790
+ buildCanvasTableLayout as aW,
40791
+ resolveCanvasTableWidth as aX,
40792
+ resolveFloatingTableRect as aY,
40793
+ normalizeFamily as aZ,
40794
+ ROBOTO_FONT_FILES as a_,
40247
40795
  className as aa,
40248
40796
  For as ab,
40249
40797
  UNDERLINE_STYLE_OPTIONS as ac,
@@ -40271,109 +40819,112 @@ export {
40271
40819
  getRunFieldChar as ay,
40272
40820
  getRunFieldInstruction as az,
40273
40821
  createEditorStateFromDocument as b,
40274
- I18nProvider as b$,
40275
- SfntFontProgram as b0,
40276
- collectPdfFontFamilies as b1,
40277
- projectDocumentLayout as b2,
40278
- getPageContentWidth as b3,
40279
- getPageHeaderZoneTop as b4,
40280
- getPageBodyTop as b5,
40281
- getPageColumnRects as b6,
40282
- findFootnoteReference as b7,
40283
- FOOTNOTE_MARKER_GUTTER_PX as b8,
40284
- resolveImporterForFile as b9,
40285
- createFootnoteReferenceRun as bA,
40286
- renumberFootnotes as bB,
40287
- getFootnoteDisplayMarker as bC,
40288
- getHeadingLevel as bD,
40289
- preciseFontModeVersion as bE,
40290
- isPreciseFontModeEnabled as bF,
40291
- resolveNamedTextStyle as bG,
40292
- togglePreciseFontMode as bH,
40293
- nextFontSizePt as bI,
40294
- previousFontSizePt as bJ,
40295
- fontSizePtToPx as bK,
40296
- createDefaultToolbarPreset as bL,
40297
- MenuRegistry as bM,
40298
- createToolbarRegistry as bN,
40299
- Editor as bO,
40300
- resolveCommandRef as bP,
40301
- commandRefName as bQ,
40302
- createOasisEditorClient as bR,
40303
- createEditorZoom as bS,
40304
- startLongTaskObserver as bT,
40305
- installGlobalReport as bU,
40306
- applyStoredPreciseFontPreference as bV,
40307
- getWelcomeSeen as bW,
40308
- isLocalFontAccessSupported as bX,
40309
- EDITOR_SCROLL_PADDING_PX as bY,
40310
- Toolbar as bZ,
40311
- OasisEditorLoading as b_,
40312
- getDocumentSectionsCanonical as ba,
40313
- getDocumentParagraphsCanonical as bb,
40314
- getDocumentParagraphs as bc,
40315
- getDocumentPageSettings as bd,
40316
- getTableCellContentWidthForParagraph as be,
40317
- on as bf,
40318
- debounce as bg,
40319
- unwrap as bh,
40320
- perfTimer as bi,
40321
- getRunTextBox as bj,
40322
- createEditorDocument as bk,
40323
- resolveResizedDimensions as bl,
40324
- resolveTextBoxRenderHeight as bm,
40325
- getToolbarStyleState as bn,
40326
- getCachedCanvasImage as bo,
40327
- measureParagraphMinContentWidthPx as bp,
40328
- getEditableBlocksForZone as bq,
40329
- findParagraphLocation as br,
40330
- createSectionBoundaryParagraph as bs,
40331
- normalizePageSettings as bt,
40332
- DEFAULT_EDITOR_PAGE_SETTINGS as bu,
40333
- markStart as bv,
40334
- markEnd as bw,
40335
- getParagraphEntries as bx,
40336
- getParagraphById as by,
40337
- createEditorFootnote as bz,
40822
+ EDITOR_SCROLL_PADDING_PX as b$,
40823
+ OFFICE_COMPAT_FONT_FAMILIES as b0,
40824
+ buildSfnt as b1,
40825
+ defaultFontDecoderRegistry as b2,
40826
+ SfntFontProgram as b3,
40827
+ collectPdfFontFamilies as b4,
40828
+ projectDocumentLayout as b5,
40829
+ getPageContentWidth as b6,
40830
+ getPageHeaderZoneTop as b7,
40831
+ getPageBodyTop as b8,
40832
+ getPageColumnRects as b9,
40833
+ getParagraphEntries as bA,
40834
+ getParagraphById as bB,
40835
+ createEditorFootnote as bC,
40836
+ createFootnoteReferenceRun as bD,
40837
+ renumberFootnotes as bE,
40838
+ getFootnoteDisplayMarker as bF,
40839
+ getHeadingLevel as bG,
40840
+ preciseFontModeVersion as bH,
40841
+ isPreciseFontModeEnabled as bI,
40842
+ resolveNamedTextStyle as bJ,
40843
+ togglePreciseFontMode as bK,
40844
+ nextFontSizePt as bL,
40845
+ previousFontSizePt as bM,
40846
+ fontSizePtToPx as bN,
40847
+ createDefaultToolbarPreset as bO,
40848
+ MenuRegistry as bP,
40849
+ createToolbarRegistry as bQ,
40850
+ Editor as bR,
40851
+ resolveCommandRef as bS,
40852
+ commandRefName as bT,
40853
+ createOasisEditorClient as bU,
40854
+ createEditorZoom as bV,
40855
+ startLongTaskObserver as bW,
40856
+ installGlobalReport as bX,
40857
+ applyStoredPreciseFontPreference as bY,
40858
+ getWelcomeSeen as bZ,
40859
+ isLocalFontAccessSupported as b_,
40860
+ findFootnoteReference as ba,
40861
+ FOOTNOTE_MARKER_GUTTER_PX as bb,
40862
+ resolveImporterForFile as bc,
40863
+ getDocumentSectionsCanonical as bd,
40864
+ getDocumentParagraphsCanonical as be,
40865
+ getDocumentParagraphs as bf,
40866
+ getDocumentPageSettings as bg,
40867
+ getTableCellContentWidthForParagraph as bh,
40868
+ on as bi,
40869
+ debounce as bj,
40870
+ unwrap as bk,
40871
+ perfTimer as bl,
40872
+ getRunTextBox as bm,
40873
+ createEditorDocument as bn,
40874
+ resolveResizedDimensions as bo,
40875
+ resolveTextBoxRenderHeight as bp,
40876
+ getToolbarStyleState as bq,
40877
+ getCachedCanvasImage as br,
40878
+ measureParagraphMinContentWidthPx as bs,
40879
+ getEditableBlocksForZone as bt,
40880
+ findParagraphLocation as bu,
40881
+ createSectionBoundaryParagraph as bv,
40882
+ normalizePageSettings as bw,
40883
+ DEFAULT_EDITOR_PAGE_SETTINGS as bx,
40884
+ markStart as by,
40885
+ markEnd as bz,
40338
40886
  createSignal as c,
40339
- createTranslator as c0,
40340
- createEditorLogger as c1,
40341
- registerDomStatsSurface as c2,
40342
- Button as c3,
40343
- Checkbox as c4,
40344
- ColorPicker as c5,
40345
- CommandRegistry as c6,
40346
- DEFAULT_PALETTE as c7,
40347
- DialogFooter as c8,
40348
- FloatingActionButton as c9,
40349
- mount as cA,
40350
- registerToolbarRenderer as cB,
40351
- GridPicker as ca,
40352
- IconButton as cb,
40353
- Menu as cc,
40354
- OASIS_BUILTIN_COMMANDS as cd,
40355
- OASIS_MENU_ITEMS as ce,
40356
- OASIS_TOOLBAR_ITEMS as cf,
40357
- OasisEditorAppLazy as cg,
40358
- OasisEditorContainer as ch,
40359
- PluginCollection as ci,
40360
- Popover as cj,
40361
- RIBBON_TABS as ck,
40362
- Select as cl,
40363
- SelectField as cm,
40364
- Separator as cn,
40365
- SidePanel as co,
40366
- SidePanelBody as cp,
40367
- SidePanelFooter as cq,
40368
- SidePanelHeader as cr,
40369
- SplitButton as cs,
40370
- StyleGallery as ct,
40371
- TextField as cu,
40372
- Button$1 as cv,
40373
- buildRibbonTabDefinitions as cw,
40374
- createEditorCommandBus as cx,
40375
- createOasisEditor as cy,
40376
- createOasisEditorContainer as cz,
40887
+ Toolbar as c0,
40888
+ OasisEditorLoading as c1,
40889
+ I18nProvider as c2,
40890
+ createTranslator as c3,
40891
+ createEditorLogger as c4,
40892
+ registerDomStatsSurface as c5,
40893
+ Button as c6,
40894
+ Checkbox as c7,
40895
+ ColorPicker as c8,
40896
+ CommandRegistry as c9,
40897
+ createEditorCommandBus as cA,
40898
+ createOasisEditor as cB,
40899
+ createOasisEditorContainer as cC,
40900
+ mount as cD,
40901
+ registerToolbarRenderer as cE,
40902
+ DEFAULT_PALETTE as ca,
40903
+ DialogFooter as cb,
40904
+ FloatingActionButton as cc,
40905
+ GridPicker as cd,
40906
+ IconButton as ce,
40907
+ Menu as cf,
40908
+ OASIS_BUILTIN_COMMANDS as cg,
40909
+ OASIS_MENU_ITEMS as ch,
40910
+ OASIS_TOOLBAR_ITEMS as ci,
40911
+ OasisEditorAppLazy as cj,
40912
+ OasisEditorContainer as ck,
40913
+ PluginCollection as cl,
40914
+ Popover as cm,
40915
+ RIBBON_TABS as cn,
40916
+ Select as co,
40917
+ SelectField as cp,
40918
+ Separator as cq,
40919
+ SidePanel as cr,
40920
+ SidePanelBody as cs,
40921
+ SidePanelFooter as ct,
40922
+ SidePanelHeader as cu,
40923
+ SplitButton as cv,
40924
+ StyleGallery as cw,
40925
+ TextField as cx,
40926
+ Button$1 as cy,
40927
+ buildRibbonTabDefinitions as cz,
40377
40928
  createInitialEditorState as d,
40378
40929
  createEditorParagraphFromRuns as e,
40379
40930
  fontSizePxToPt as f,