@etrepum/lexical-builder-table 0.0.33 → 0.0.35

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.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { Store } from '@etrepum/lexical-builder';
2
-
1
+ import { ReadableStore } from '@etrepum/lexical-builder';
3
2
  export declare const PACKAGE_VERSION: string;
4
3
  export interface TableConfig {
5
4
  hasCellMerge: boolean;
6
5
  hasCellBackgroundColor: boolean;
7
6
  hasTabHandler: boolean;
8
7
  }
9
- export declare const TablePlan: import('@etrepum/lexical-builder').LexicalPlan<TableConfig, "@lexical/table", unknown, {
10
- hasCellMerge: Store<boolean>;
11
- hasCellBackgroundColor: Store<boolean>;
12
- hasTabHandler: Store<boolean>;
13
- }>;
8
+ export interface TableOutput {
9
+ hasCellMerge: ReadableStore<boolean>;
10
+ hasCellBackgroundColor: ReadableStore<boolean>;
11
+ hasTabHandler: ReadableStore<boolean>;
12
+ }
13
+ export declare const TablePlan: import('@etrepum/lexical-builder').LexicalPlan<TableConfig, "@lexical/table", TableOutput, TableOutput>;
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkCH,OAAO,EAIL,KAAK,EACN,MAAM,0BAA0B,CAAC;AAGlC,eAAO,MAAM,eAAe,EAAE,MAAwC,CAAC;AAEvE,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,sBAAsB,EAAE,OAAO,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,SAAS;;;;EAyLpB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAkCH,OAAO,EAGL,KAAK,aAAa,EAInB,MAAM,0BAA0B,CAAC;AAGlC,eAAO,MAAM,eAAe,EAAE,MAAwC,CAAC;AAEvE,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,OAAO,CAAC;IACtB,sBAAsB,EAAE,OAAO,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACrC,sBAAsB,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IAC/C,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACvC;AAED,eAAO,MAAM,SAAS,yGA4LpB,CAAC"}
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- import { TableNode as N, TableRowNode as k, TableCellNode as T, INSERT_TABLE_COMMAND as x, $createTableNodeWithDimensions as y, $computeTableMapSkipCellCheck as B, $createTableCellNode as M, $isTableNode as _, $getNodeTriplet as A, $computeTableMap as I, $isTableRowNode as $, $isTableCellNode as D, applyTableHandlers as H } from "@lexical/table";
2
- import { mergeRegister as E, $insertNodeToNearestRoot as K, $insertFirst as L } from "@lexical/utils";
3
- import { $isTextNode as O, COMMAND_PRIORITY_EDITOR as P, $createParagraphNode as v, $getNodeByKey as F } from "lexical";
4
- import { definePlan as j, safeCast as z, Store as h, registerStoreToggle as m } from "@etrepum/lexical-builder";
5
- function w(a, c, ...u) {
1
+ import { TableNode as N, TableRowNode as x, TableCellNode as T, INSERT_TABLE_COMMAND as y, $createTableNodeWithDimensions as B, $computeTableMapSkipCellCheck as _, $createTableCellNode as M, $isTableNode as A, $getNodeTriplet as I, $computeTableMap as D, $isTableRowNode as $, $isTableCellNode as H, applyTableHandlers as K } from "@lexical/table";
2
+ import { mergeRegister as E, $insertNodeToNearestRoot as L, $insertFirst as O } from "@lexical/utils";
3
+ import { $isTextNode as v, COMMAND_PRIORITY_EDITOR as P, $createParagraphNode as F, $getNodeByKey as j } from "lexical";
4
+ import { definePlan as z, safeCast as V, Store as h, provideOutput as G, registerStoreToggle as m } from "@etrepum/lexical-builder";
5
+ function w(a, c, ...C) {
6
6
  if (!a)
7
7
  throw new Error(
8
- u.reduce((C, b) => C.replace("%s", String(b)), c || "")
8
+ C.reduce((f, p) => f.replace("%s", String(p)), c || "")
9
9
  );
10
10
  }
11
- const q = "0.0.33", J = j({
11
+ const Q = "0.0.35", U = z({
12
12
  name: "@lexical/table",
13
- nodes: [N, k, T],
14
- config: z({
13
+ nodes: [N, x, T],
14
+ config: V({
15
15
  hasCellMerge: !0,
16
16
  hasCellBackgroundColor: !0,
17
17
  hasTabHandler: !0
@@ -23,133 +23,136 @@ const q = "0.0.33", J = j({
23
23
  hasTabHandler: new h(c.hasTabHandler)
24
24
  };
25
25
  },
26
- register(a, c, u) {
27
- const { hasCellMerge: C, hasCellBackgroundColor: b, hasTabHandler: R } = u.getInitResult();
28
- return E(
29
- a.registerCommand(
30
- x,
31
- ({ columns: t, rows: o, includeHeaders: r }) => {
32
- const e = y(
33
- Number(o),
34
- Number(t),
35
- r
36
- );
37
- K(e);
38
- const l = e.getFirstDescendant();
39
- return O(l) && l.select(), !0;
40
- },
41
- P
42
- ),
43
- a.registerNodeTransform(N, (t) => {
44
- const [o] = B(t, null, null);
45
- let r = 0;
46
- for (const e of o)
47
- r = Math.max(r, e.length);
48
- for (const e of o) {
49
- const l = e.length;
50
- if (l === r || l === 0)
51
- continue;
52
- const n = e[l - 1].cell;
53
- for (let s = l; s < r; ++s) {
54
- const d = M(0);
55
- d.append(v()), n.insertAfter(d);
56
- }
57
- }
58
- }),
59
- m(
60
- R,
61
- // Returning true mimics useEffect, we will call the register
62
- // function any time the value changes
63
- () => !0,
64
- () => {
65
- const t = R.get(), o = /* @__PURE__ */ new Map(), r = (e) => {
66
- const l = e.getKey(), i = a.getElementByKey(
67
- l
26
+ register(a, c, C) {
27
+ const f = C.getInitResult(), { hasCellMerge: p, hasCellBackgroundColor: k, hasTabHandler: R } = f;
28
+ return G(
29
+ f,
30
+ E(
31
+ a.registerCommand(
32
+ y,
33
+ ({ columns: t, rows: o, includeHeaders: r }) => {
34
+ const e = B(
35
+ Number(o),
36
+ Number(t),
37
+ r
68
38
  );
69
- if (i && !o.has(l)) {
70
- const n = H(
71
- e,
72
- i,
73
- a,
74
- t
75
- );
76
- o.set(l, n);
77
- }
78
- };
79
- return E(
80
- a.registerMutationListener(
81
- N,
82
- (e) => {
83
- for (const [l, i] of e)
84
- if (i === "created")
85
- a.getEditorState().read(() => {
86
- const n = F(l);
87
- _(n) && r(n);
88
- });
89
- else if (i === "destroyed") {
90
- const n = o.get(l);
91
- n !== void 0 && (n.removeListeners(), o.delete(l));
92
- }
93
- },
94
- { skipInitialization: !1 }
95
- ),
96
- // Hook might be called multiple times so cleaning up tables listeners as well,
97
- // as it'll be reinitialized during recurring call
98
- () => {
99
- for (const [, e] of o)
100
- e.removeListeners();
39
+ L(e);
40
+ const l = e.getFirstDescendant();
41
+ return v(l) && l.select(), !0;
42
+ },
43
+ P
44
+ ),
45
+ a.registerNodeTransform(N, (t) => {
46
+ const [o] = _(t, null, null);
47
+ let r = 0;
48
+ for (const e of o)
49
+ r = Math.max(r, e.length);
50
+ for (const e of o) {
51
+ const l = e.length;
52
+ if (l === r || l === 0)
53
+ continue;
54
+ const n = e[l - 1].cell;
55
+ for (let s = l; s < r; ++s) {
56
+ const d = M(0);
57
+ d.append(F()), n.insertAfter(d);
101
58
  }
102
- );
103
- }
104
- ),
105
- m(
106
- C,
107
- (t) => t,
108
- () => a.registerNodeTransform(T, (t) => {
109
- if (t.getColSpan() > 1 || t.getRowSpan() > 1) {
110
- const [, , o] = A(t), [r] = I(o, t, t);
111
- let e = o.getFirstChild();
112
- w(
113
- $(e),
114
- "Expected TableNode first child to be a RowNode"
59
+ }
60
+ }),
61
+ m(
62
+ R,
63
+ // Returning true mimics useEffect, we will call the register
64
+ // function any time the value changes
65
+ () => !0,
66
+ () => {
67
+ const t = R.get(), o = /* @__PURE__ */ new Map(), r = (e) => {
68
+ const l = e.getKey(), i = a.getElementByKey(
69
+ l
70
+ );
71
+ if (i && !o.has(l)) {
72
+ const n = K(
73
+ e,
74
+ i,
75
+ a,
76
+ t
77
+ );
78
+ o.set(l, n);
79
+ }
80
+ };
81
+ return E(
82
+ a.registerMutationListener(
83
+ N,
84
+ (e) => {
85
+ for (const [l, i] of e)
86
+ if (i === "created")
87
+ a.getEditorState().read(() => {
88
+ const n = j(l);
89
+ A(n) && r(n);
90
+ });
91
+ else if (i === "destroyed") {
92
+ const n = o.get(l);
93
+ n !== void 0 && (n.removeListeners(), o.delete(l));
94
+ }
95
+ },
96
+ { skipInitialization: !1 }
97
+ ),
98
+ // Hook might be called multiple times so cleaning up tables listeners as well,
99
+ // as it'll be reinitialized during recurring call
100
+ () => {
101
+ for (const [, e] of o)
102
+ e.removeListeners();
103
+ }
115
104
  );
116
- const l = r.length, i = r[0].length, n = [];
117
- for (let s = 0; s < l; s++) {
118
- s !== 0 && (e = e.getNextSibling(), w(
105
+ }
106
+ ),
107
+ m(
108
+ p,
109
+ (t) => t,
110
+ () => a.registerNodeTransform(T, (t) => {
111
+ if (t.getColSpan() > 1 || t.getRowSpan() > 1) {
112
+ const [, , o] = I(t), [r] = D(o, t, t);
113
+ let e = o.getFirstChild();
114
+ w(
119
115
  $(e),
120
116
  "Expected TableNode first child to be a RowNode"
121
- ));
122
- let d = null;
123
- for (let f = 0; f < i; f++) {
124
- const p = r[s][f], g = p.cell;
125
- if (p.startRow === s && p.startColumn === f)
126
- d = g, n.push(g);
127
- else if (g.getColSpan() > 1 || g.getRowSpan() > 1) {
128
- w(
129
- D(g),
130
- "Expected TableNode cell to be a TableCellNode"
131
- );
132
- const S = M(g.__headerState);
133
- d !== null ? d.insertAfter(S) : L(e, S);
117
+ );
118
+ const l = r.length, i = r[0].length, n = [];
119
+ for (let s = 0; s < l; s++) {
120
+ s !== 0 && (e = e.getNextSibling(), w(
121
+ $(e),
122
+ "Expected TableNode first child to be a RowNode"
123
+ ));
124
+ let d = null;
125
+ for (let u = 0; u < i; u++) {
126
+ const b = r[s][u], g = b.cell;
127
+ if (b.startRow === s && b.startColumn === u)
128
+ d = g, n.push(g);
129
+ else if (g.getColSpan() > 1 || g.getRowSpan() > 1) {
130
+ w(
131
+ H(g),
132
+ "Expected TableNode cell to be a TableCellNode"
133
+ );
134
+ const S = M(g.__headerState);
135
+ d !== null ? d.insertAfter(S) : O(e, S);
136
+ }
134
137
  }
135
138
  }
139
+ for (const s of n)
140
+ s.setColSpan(1), s.setRowSpan(1);
136
141
  }
137
- for (const s of n)
138
- s.setColSpan(1), s.setRowSpan(1);
139
- }
140
- })
141
- ),
142
- m(
143
- b,
144
- (t) => t,
145
- () => a.registerNodeTransform(T, (t) => {
146
- t.getBackgroundColor() !== null && t.setBackgroundColor(null);
147
- })
142
+ })
143
+ ),
144
+ m(
145
+ k,
146
+ (t) => t,
147
+ () => a.registerNodeTransform(T, (t) => {
148
+ t.getBackgroundColor() !== null && t.setBackgroundColor(null);
149
+ })
150
+ )
148
151
  )
149
152
  );
150
153
  }
151
154
  });
152
155
  export {
153
- q as PACKAGE_VERSION,
154
- J as TablePlan
156
+ Q as PACKAGE_VERSION,
157
+ U as TablePlan
155
158
  };
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "test:watch": "vitest",
16
16
  "lint": "eslint"
17
17
  },
18
- "version": "0.0.33",
18
+ "version": "0.0.35",
19
19
  "license": "MIT",
20
20
  "repository": {
21
21
  "type": "git",
@@ -40,17 +40,21 @@
40
40
  "@testing-library/jest-dom": "*",
41
41
  "@testing-library/user-event": "*",
42
42
  "@repo/eslint-config": "*",
43
- "eslint": "*",
43
+ "eslint": "^8.57.0",
44
44
  "jsdom": "*",
45
45
  "tslib": "*",
46
- "typescript": "*",
47
- "vite": "*",
48
- "vite-plugin-dts": "*",
49
- "vite-plugin-package-version": "*",
50
- "vitest": "*"
46
+ "typescript": "^5.5.2",
47
+ "vite": "^5.4.0",
48
+ "vite-plugin-dts": "^4.0.2",
49
+ "vite-plugin-package-version": "^1.1.0",
50
+ "vitest": "^2.0.5"
51
+ },
52
+ "exports": {
53
+ ".": {
54
+ "types": "./dist/index.d.ts",
55
+ "default": "./dist/index.js"
56
+ }
51
57
  },
52
- "module": "dist/index.js",
53
- "types": "dist/index.d.ts",
54
58
  "files": [
55
59
  "dist"
56
60
  ]