oasis-editor 0.0.56 → 0.0.57

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.
@@ -0,0 +1,48 @@
1
+ import { Element as XmlElement } from '@xmldom/xmldom';
2
+ import { EditorNamedStyle, EditorParagraphNode, EditorParagraphStyle, EditorTableConditionalFormat, EditorTextStyle } from '../../core/model.js';
3
+
4
+ export interface TableLook {
5
+ firstRow: boolean;
6
+ lastRow: boolean;
7
+ firstCol: boolean;
8
+ lastCol: boolean;
9
+ noHBand: boolean;
10
+ noVBand: boolean;
11
+ }
12
+ /**
13
+ * Parses `w:tblLook`, which gates which table-style conditional formats apply.
14
+ * Supports both the modern individual attributes (`firstRow`, `firstColumn`,
15
+ * `noVBand`, ...) and the legacy hex bitmask in `@w:val`. When the element is
16
+ * absent we default to Word's common case: first row + first column on, banding
17
+ * on.
18
+ */
19
+ export declare function parseTableLook(tblPr: XmlElement | null): TableLook;
20
+ /**
21
+ * Returns the table-style conditional-format keys that apply to a cell at the
22
+ * given position, ordered low→high precedence (later entries override earlier
23
+ * ones). Mirrors Word's resolution order: whole table < bands < first/last col
24
+ * < first/last row < corner cells. Banding and first/last row/col are gated by
25
+ * `tblLook`; banding parity is computed over the "body" rows/cols that remain
26
+ * after excluding the special first/last row/col.
27
+ */
28
+ export declare function resolveCellConditionalKeys(rowIndex: number, colIndex: number, rowCount: number, colCount: number, look: TableLook, rowBandSize: number, colBandSize: number): string[];
29
+ /** Merges resolved conditional formats (low→high precedence) into one. */
30
+ export declare function mergeConditionalFormats(keys: string[], conditionals: Record<string, EditorTableConditionalFormat> | undefined): EditorTableConditionalFormat;
31
+ /**
32
+ * Applies a conditional run text style (bold/color from the table style)
33
+ * beneath each run's own style, so explicit run formatting still wins.
34
+ */
35
+ export declare function applyConditionalTextStyle(paragraphs: EditorParagraphNode[], textStyle: EditorTextStyle | undefined): void;
36
+ /**
37
+ * Filter a table style's paragraph properties (its `<w:pPr>`) so they sit at the
38
+ * correct OOXML precedence for a given cell paragraph.
39
+ *
40
+ * Per ECMA-376 §17.7.2 the order (low → high) is:
41
+ * docDefaults < table style < paragraph style < direct formatting.
42
+ * So any property the paragraph's own (named) style explicitly defines must win
43
+ * over the table style. We strip those keys from the inherited table-style pPr;
44
+ * what remains only fills gaps the paragraph style leaves open. Without this, a
45
+ * table style like `TableGrid` (which sets `spacing after="0"`) would wrongly
46
+ * override Normal's `after="120"` and collapse cell row height vs Word.
47
+ */
48
+ export declare function tableStyleParagraphInheritance(tableStylePPr: EditorParagraphStyle | undefined, paragraphStyleId: string | undefined, styles: Record<string, EditorNamedStyle> | undefined): EditorParagraphStyle | undefined;
@@ -2483,7 +2483,7 @@ function OasisEditorAppLazy(props = {}) {
2483
2483
  onCleanup(() => {
2484
2484
  cancelled = true;
2485
2485
  });
2486
- import("./OasisEditorApp-jjFz0I9R.js").then((m) => {
2486
+ import("./OasisEditorApp-BQ5KeU1o.js").then((m) => {
2487
2487
  cancelled = true;
2488
2488
  setProgress(1);
2489
2489
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -33818,6 +33818,105 @@ async function parseParagraphNode(paragraphNode, numberingMaps, zip, relsMap, as
33818
33818
  );
33819
33819
  return parsed.paragraphs[0] ?? createEditorParagraphFromRuns([{ text: "" }]);
33820
33820
  }
33821
+ function parseTableLook(tblPr) {
33822
+ const element = getFirstChildByTagNameNS(tblPr, WORD_NS, "tblLook");
33823
+ const attr = (name) => {
33824
+ const value = getAttributeValue(element, name);
33825
+ return value === null || value === "" ? void 0 : isWordTrue(value);
33826
+ };
33827
+ const rawVal = getAttributeValue(element, "val");
33828
+ const mask = rawVal ? Number.parseInt(rawVal, 16) : Number.NaN;
33829
+ const bit = (flag) => Number.isFinite(mask) ? (mask & flag) !== 0 : void 0;
33830
+ return {
33831
+ firstRow: attr("firstRow") ?? bit(32) ?? true,
33832
+ lastRow: attr("lastRow") ?? bit(64) ?? false,
33833
+ firstCol: attr("firstColumn") ?? bit(128) ?? true,
33834
+ lastCol: attr("lastColumn") ?? bit(256) ?? false,
33835
+ noHBand: attr("noHBand") ?? bit(512) ?? false,
33836
+ noVBand: attr("noVBand") ?? bit(1024) ?? false
33837
+ };
33838
+ }
33839
+ function resolveCellConditionalKeys(rowIndex, colIndex, rowCount, colCount, look, rowBandSize, colBandSize) {
33840
+ const isFirstRow = look.firstRow && rowIndex === 0;
33841
+ const isLastRow = look.lastRow && rowIndex === rowCount - 1 && rowIndex !== 0;
33842
+ const isFirstCol = look.firstCol && colIndex === 0;
33843
+ const isLastCol = look.lastCol && colIndex === colCount - 1 && colIndex !== 0;
33844
+ const keys = [];
33845
+ if (!look.noHBand && !isFirstRow && !isLastRow) {
33846
+ const bodyRow = rowIndex - (look.firstRow ? 1 : 0);
33847
+ const band = Math.floor(bodyRow / Math.max(1, rowBandSize)) % 2;
33848
+ keys.push(band === 0 ? "band1Horz" : "band2Horz");
33849
+ }
33850
+ if (!look.noVBand && !isFirstCol && !isLastCol) {
33851
+ const bodyCol = colIndex - (look.firstCol ? 1 : 0);
33852
+ const band = Math.floor(bodyCol / Math.max(1, colBandSize)) % 2;
33853
+ keys.push(band === 0 ? "band1Vert" : "band2Vert");
33854
+ }
33855
+ if (isLastCol) keys.push("lastCol");
33856
+ if (isFirstCol) keys.push("firstCol");
33857
+ if (isLastRow) keys.push("lastRow");
33858
+ if (isFirstRow) keys.push("firstRow");
33859
+ if (isFirstRow && isFirstCol) keys.push("nwCell");
33860
+ if (isFirstRow && isLastCol) keys.push("neCell");
33861
+ if (isLastRow && isFirstCol) keys.push("swCell");
33862
+ if (isLastRow && isLastCol) keys.push("seCell");
33863
+ return keys;
33864
+ }
33865
+ function mergeConditionalFormats(keys, conditionals) {
33866
+ const merged = {};
33867
+ if (!conditionals) {
33868
+ return merged;
33869
+ }
33870
+ for (const key of keys) {
33871
+ const cond = conditionals[key];
33872
+ if (!cond) continue;
33873
+ if (cond.shading) merged.shading = cond.shading;
33874
+ if (cond.textStyle) {
33875
+ merged.textStyle = { ...merged.textStyle, ...cond.textStyle };
33876
+ }
33877
+ if (cond.borders) {
33878
+ merged.borders = { ...merged.borders, ...cond.borders };
33879
+ }
33880
+ if (cond.paragraphStyle) {
33881
+ merged.paragraphStyle = {
33882
+ ...merged.paragraphStyle,
33883
+ ...cond.paragraphStyle
33884
+ };
33885
+ }
33886
+ if (cond.rowStyle) {
33887
+ merged.rowStyle = { ...merged.rowStyle, ...cond.rowStyle };
33888
+ }
33889
+ }
33890
+ return merged;
33891
+ }
33892
+ function applyConditionalTextStyle(paragraphs, textStyle) {
33893
+ if (!textStyle || Object.keys(textStyle).length === 0) {
33894
+ return;
33895
+ }
33896
+ for (const paragraph of paragraphs) {
33897
+ for (const run of paragraph.runs) {
33898
+ run.styles = { ...textStyle, ...run.styles };
33899
+ }
33900
+ }
33901
+ }
33902
+ function tableStyleParagraphInheritance(tableStylePPr, paragraphStyleId, styles) {
33903
+ if (!tableStylePPr) {
33904
+ return void 0;
33905
+ }
33906
+ const effectiveStyleId = paragraphStyleId ?? resolveDefaultParagraphStyleId(styles);
33907
+ const paragraphStyleDelta = resolveNamedParagraphStyle(
33908
+ effectiveStyleId,
33909
+ styles
33910
+ );
33911
+ const definedByParagraphStyle = new Set(Object.keys(paragraphStyleDelta));
33912
+ const filtered = {};
33913
+ for (const [key, value] of Object.entries(tableStylePPr)) {
33914
+ if (!definedByParagraphStyle.has(key)) {
33915
+ filtered[key] = value;
33916
+ }
33917
+ }
33918
+ return emptyOrUndefined(filtered);
33919
+ }
33821
33920
  function parseDocxWidthValue(element) {
33822
33921
  if (!element) {
33823
33922
  return void 0;
@@ -34250,102 +34349,6 @@ function applyTableBordersToRows(rows, tblBorders) {
34250
34349
  }
34251
34350
  }
34252
34351
  }
34253
- function parseTableLook(tblPr) {
34254
- const element = getFirstChildByTagNameNS(tblPr, WORD_NS, "tblLook");
34255
- const attr = (name) => {
34256
- const value = getAttributeValue(element, name);
34257
- return value === null || value === "" ? void 0 : isWordTrue(value);
34258
- };
34259
- const rawVal = getAttributeValue(element, "val");
34260
- const mask = rawVal ? Number.parseInt(rawVal, 16) : Number.NaN;
34261
- const bit = (flag) => Number.isFinite(mask) ? (mask & flag) !== 0 : void 0;
34262
- return {
34263
- firstRow: attr("firstRow") ?? bit(32) ?? true,
34264
- lastRow: attr("lastRow") ?? bit(64) ?? false,
34265
- firstCol: attr("firstColumn") ?? bit(128) ?? true,
34266
- lastCol: attr("lastColumn") ?? bit(256) ?? false,
34267
- noHBand: attr("noHBand") ?? bit(512) ?? false,
34268
- noVBand: attr("noVBand") ?? bit(1024) ?? false
34269
- };
34270
- }
34271
- function resolveCellConditionalKeys(rowIndex, colIndex, rowCount, colCount, look, rowBandSize, colBandSize) {
34272
- const isFirstRow = look.firstRow && rowIndex === 0;
34273
- const isLastRow = look.lastRow && rowIndex === rowCount - 1 && rowIndex !== 0;
34274
- const isFirstCol = look.firstCol && colIndex === 0;
34275
- const isLastCol = look.lastCol && colIndex === colCount - 1 && colIndex !== 0;
34276
- const keys = [];
34277
- if (!look.noHBand && !isFirstRow && !isLastRow) {
34278
- const bodyRow = rowIndex - (look.firstRow ? 1 : 0);
34279
- const band = Math.floor(bodyRow / Math.max(1, rowBandSize)) % 2;
34280
- keys.push(band === 0 ? "band1Horz" : "band2Horz");
34281
- }
34282
- if (!look.noVBand && !isFirstCol && !isLastCol) {
34283
- const bodyCol = colIndex - (look.firstCol ? 1 : 0);
34284
- const band = Math.floor(bodyCol / Math.max(1, colBandSize)) % 2;
34285
- keys.push(band === 0 ? "band1Vert" : "band2Vert");
34286
- }
34287
- if (isLastCol) keys.push("lastCol");
34288
- if (isFirstCol) keys.push("firstCol");
34289
- if (isLastRow) keys.push("lastRow");
34290
- if (isFirstRow) keys.push("firstRow");
34291
- if (isFirstRow && isFirstCol) keys.push("nwCell");
34292
- if (isFirstRow && isLastCol) keys.push("neCell");
34293
- if (isLastRow && isFirstCol) keys.push("swCell");
34294
- if (isLastRow && isLastCol) keys.push("seCell");
34295
- return keys;
34296
- }
34297
- function mergeConditionalFormats(keys, conditionals) {
34298
- const merged = {};
34299
- if (!conditionals) {
34300
- return merged;
34301
- }
34302
- for (const key of keys) {
34303
- const cond = conditionals[key];
34304
- if (!cond) continue;
34305
- if (cond.shading) merged.shading = cond.shading;
34306
- if (cond.textStyle) {
34307
- merged.textStyle = { ...merged.textStyle, ...cond.textStyle };
34308
- }
34309
- if (cond.borders) {
34310
- merged.borders = { ...merged.borders, ...cond.borders };
34311
- }
34312
- if (cond.paragraphStyle) {
34313
- merged.paragraphStyle = { ...merged.paragraphStyle, ...cond.paragraphStyle };
34314
- }
34315
- if (cond.rowStyle) {
34316
- merged.rowStyle = { ...merged.rowStyle, ...cond.rowStyle };
34317
- }
34318
- }
34319
- return merged;
34320
- }
34321
- function applyConditionalTextStyle(paragraphs, textStyle) {
34322
- if (!textStyle || Object.keys(textStyle).length === 0) {
34323
- return;
34324
- }
34325
- for (const paragraph of paragraphs) {
34326
- for (const run of paragraph.runs) {
34327
- run.styles = { ...textStyle, ...run.styles };
34328
- }
34329
- }
34330
- }
34331
- function tableStyleParagraphInheritance(tableStylePPr, paragraphStyleId, styles) {
34332
- if (!tableStylePPr) {
34333
- return void 0;
34334
- }
34335
- const effectiveStyleId = paragraphStyleId ?? resolveDefaultParagraphStyleId(styles);
34336
- const paragraphStyleDelta = resolveNamedParagraphStyle(
34337
- effectiveStyleId,
34338
- styles
34339
- );
34340
- const definedByParagraphStyle = new Set(Object.keys(paragraphStyleDelta));
34341
- const filtered = {};
34342
- for (const [key, value] of Object.entries(tableStylePPr)) {
34343
- if (!definedByParagraphStyle.has(key)) {
34344
- filtered[key] = value;
34345
- }
34346
- }
34347
- return emptyOrUndefined(filtered);
34348
- }
34349
34352
  async function parseTableNode(tableNode, numberingMaps, zip, relsMap, assets, theme, parseNestedBlocks, styles) {
34350
34353
  var _a, _b;
34351
34354
  const gridCols = [];
@@ -35536,7 +35539,7 @@ function importDocxInWorker(buffer, options = {}) {
35536
35539
  const worker = new Worker(
35537
35540
  new URL(
35538
35541
  /* @vite-ignore */
35539
- "" + new URL("assets/importDocxWorker-DbI0FKvR.js", import.meta.url).href,
35542
+ "" + new URL("assets/importDocxWorker-BWyqey19.js", import.meta.url).href,
35540
35543
  import.meta.url
35541
35544
  ),
35542
35545
  {
@@ -1,4 +1,4 @@
1
- import { b2, bV, bW, bX, bY, bZ, bk, b_, b3, a_, b$, c0, c1, b1, c2, aY, c3, c4, c5, c6, c7, bQ, c8, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, bp, cj, bP, ck, bX as bX2, c0 as c02, c2 as c22, cb as cb2, cd as cd2, ci as ci2, cl, b0, aX, cm, cn, co, aZ, cp, cq, a$ } from "./index-TE81CHER.js";
1
+ import { b2, bV, bW, bX, bY, bZ, bk, b_, b3, a_, b$, c0, c1, b1, c2, aY, c3, c4, c5, c6, c7, bQ, c8, c9, ca, cb, cc, cd, ce, cf, cg, ch, ci, bp, cj, bP, ck, bX as bX2, c0 as c02, c2 as c22, cb as cb2, cd as cd2, ci as ci2, cl, b0, aX, cm, cn, co, aZ, cp, cq, a$ } from "./index-DiZU2BUt.js";
2
2
  export {
3
3
  b2 as BalloonShell,
4
4
  bV as Button,