quoin-editor 1.0.2 → 1.1.0
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/CHANGELOG.md +18 -0
- package/dist/ai.cjs +168 -249
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.js +37 -121
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +28 -43
- package/dist/catalogue.cjs.map +1 -1
- package/dist/catalogue.js +20 -37
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-DUE3HCZD.js → chunk-2EQ6FKSK.js} +19 -28
- package/dist/chunk-2EQ6FKSK.js.map +1 -0
- package/dist/{chunk-RJRX34BZ.js → chunk-3BXUGX5F.js} +4 -18
- package/dist/chunk-3BXUGX5F.js.map +1 -0
- package/dist/chunk-3QRVAI53.cjs +27 -0
- package/dist/chunk-3QRVAI53.cjs.map +1 -0
- package/dist/{chunk-U3LOLYAU.js → chunk-7FAVFJAS.js} +4 -10
- package/dist/chunk-7FAVFJAS.js.map +1 -0
- package/dist/{chunk-6V6GGBDK.cjs → chunk-7SVKLWDT.cjs} +24 -31
- package/dist/chunk-7SVKLWDT.cjs.map +1 -0
- package/dist/{chunk-EH5KXQXY.cjs → chunk-A6PGQVTR.cjs} +36 -20
- package/dist/chunk-A6PGQVTR.cjs.map +1 -0
- package/dist/{chunk-P6KYXFZC.cjs → chunk-ACSEYJJF.cjs} +426 -534
- package/dist/chunk-ACSEYJJF.cjs.map +1 -0
- package/dist/{chunk-4SLJNZSM.cjs → chunk-AIS37SL2.cjs} +201 -198
- package/dist/chunk-AIS37SL2.cjs.map +1 -0
- package/dist/{chunk-X4HDKFW5.cjs → chunk-DTQFYHDJ.cjs} +56 -105
- package/dist/chunk-DTQFYHDJ.cjs.map +1 -0
- package/dist/{chunk-O4Z2WMFF.js → chunk-HDJ653LM.js} +25 -18
- package/dist/chunk-HDJ653LM.js.map +1 -0
- package/dist/chunk-HQ43EIYO.cjs +94 -0
- package/dist/chunk-HQ43EIYO.cjs.map +1 -0
- package/dist/{chunk-6NULZPVC.js → chunk-HTLWPSMU.js} +8 -61
- package/dist/chunk-HTLWPSMU.js.map +1 -0
- package/dist/{chunk-ADSJ42DO.js → chunk-HWEK7EX5.js} +17 -69
- package/dist/chunk-HWEK7EX5.js.map +1 -0
- package/dist/{chunk-623AOJM2.js → chunk-ITXCE6KL.js} +7 -25
- package/dist/chunk-ITXCE6KL.js.map +1 -0
- package/dist/{chunk-AUOEM3SF.cjs → chunk-IXVGHH7F.cjs} +102 -155
- package/dist/chunk-IXVGHH7F.cjs.map +1 -0
- package/dist/{chunk-NEZJ7ZP5.js → chunk-JZJIWRF3.js} +4 -8
- package/dist/chunk-JZJIWRF3.js.map +1 -0
- package/dist/{chunk-C23RQVRK.js → chunk-KSF2HILJ.js} +66 -216
- package/dist/chunk-KSF2HILJ.js.map +1 -0
- package/dist/{chunk-OBMBSU2S.js → chunk-L4D23LM2.js} +5 -184
- package/dist/chunk-L4D23LM2.js.map +1 -0
- package/dist/{chunk-4XFXB37X.js → chunk-L6OW2FL3.js} +7 -90
- package/dist/chunk-L6OW2FL3.js.map +1 -0
- package/dist/chunk-LE5XMIFJ.cjs +4 -3
- package/dist/chunk-LE5XMIFJ.cjs.map +1 -1
- package/dist/{chunk-5MAYUGTE.cjs → chunk-LY2D45F2.cjs} +233 -363
- package/dist/chunk-LY2D45F2.cjs.map +1 -0
- package/dist/{chunk-VCLL5C7J.js → chunk-MGMA5PEL.js} +14 -57
- package/dist/chunk-MGMA5PEL.js.map +1 -0
- package/dist/chunk-MQUCCSWG.js +2 -3
- package/dist/chunk-MQUCCSWG.js.map +1 -1
- package/dist/chunk-NO3KTZDY.cjs +33 -0
- package/dist/chunk-NO3KTZDY.cjs.map +1 -0
- package/dist/{chunk-TLGX43P6.cjs → chunk-OM7E43ZN.cjs} +89 -86
- package/dist/chunk-OM7E43ZN.cjs.map +1 -0
- package/dist/{chunk-JHQUHFLX.js → chunk-PJCHSHM3.js} +38 -120
- package/dist/chunk-PJCHSHM3.js.map +1 -0
- package/dist/{chunk-EPARJI4V.js → chunk-QC35D2AU.js} +107 -262
- package/dist/chunk-QC35D2AU.js.map +1 -0
- package/dist/{chunk-CW3AFJBR.cjs → chunk-QEMGOL5L.cjs} +1302 -1773
- package/dist/chunk-QEMGOL5L.cjs.map +1 -0
- package/dist/chunk-QWS7KH3K.cjs +483 -0
- package/dist/chunk-QWS7KH3K.cjs.map +1 -0
- package/dist/{chunk-IQBMAE3F.js → chunk-RHQPAW4W.js} +34 -92
- package/dist/chunk-RHQPAW4W.js.map +1 -0
- package/dist/chunk-RIIXJWBR.cjs +24 -0
- package/dist/chunk-RIIXJWBR.cjs.map +1 -0
- package/dist/{chunk-VRS6WCEK.js → chunk-SAEQMDAU.js} +60 -167
- package/dist/chunk-SAEQMDAU.js.map +1 -0
- package/dist/chunk-SKZC4K5S.cjs +612 -0
- package/dist/chunk-SKZC4K5S.cjs.map +1 -0
- package/dist/{chunk-N4FGA3H4.js → chunk-TBCHYHNU.js} +38 -105
- package/dist/chunk-TBCHYHNU.js.map +1 -0
- package/dist/{chunk-OSHZQR3W.js → chunk-TNN6Z52D.js} +13 -45
- package/dist/chunk-TNN6Z52D.js.map +1 -0
- package/dist/{chunk-YBMUEEM5.js → chunk-TYZSB7JT.js} +4 -8
- package/dist/chunk-TYZSB7JT.js.map +1 -0
- package/dist/{chunk-ZKVOS57Q.cjs → chunk-VFSVN5IQ.cjs} +495 -551
- package/dist/chunk-VFSVN5IQ.cjs.map +1 -0
- package/dist/{chunk-FDRUAL3Z.cjs → chunk-WDO6DBYU.cjs} +90 -153
- package/dist/chunk-WDO6DBYU.cjs.map +1 -0
- package/dist/{chunk-WEYDDIBQ.cjs → chunk-WHV5ZSIO.cjs} +36 -64
- package/dist/chunk-WHV5ZSIO.cjs.map +1 -0
- package/dist/{chunk-T43RZTUT.js → chunk-XJDPQFPU.js} +693 -1247
- package/dist/chunk-XJDPQFPU.js.map +1 -0
- package/dist/{chunk-BQANU5BH.cjs → chunk-ZTLYHRZT.cjs} +34 -44
- package/dist/chunk-ZTLYHRZT.cjs.map +1 -0
- package/dist/chunk-ZWB7SZVI.cjs +200 -0
- package/dist/chunk-ZWB7SZVI.cjs.map +1 -0
- package/dist/comments.cjs +209 -290
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +81 -186
- package/dist/comments.js.map +1 -1
- package/dist/diff.cjs +48 -65
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.d.cts +2 -2
- package/dist/diff.d.ts +2 -2
- package/dist/diff.js +8 -32
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +50 -63
- package/dist/docx.cjs.map +1 -1
- package/dist/docx.js +7 -22
- package/dist/docx.js.map +1 -1
- package/dist/embed.cjs +18 -12
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.js +9 -16
- package/dist/embed.js.map +1 -1
- package/dist/emoji-data.cjs +7 -5
- package/dist/emoji-data.cjs.map +1 -1
- package/dist/emoji-data.js +3 -5
- package/dist/emoji-data.js.map +1 -1
- package/dist/emoji.cjs +25 -17
- package/dist/emoji.cjs.map +1 -1
- package/dist/emoji.js +8 -17
- package/dist/emoji.js.map +1 -1
- package/dist/engine.cjs +229 -118
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.js +4 -118
- package/dist/engine.js.map +1 -1
- package/dist/find.cjs +29 -19
- package/dist/find.cjs.map +1 -1
- package/dist/find.js +8 -19
- package/dist/find.js.map +1 -1
- package/dist/headless.cjs +290 -151
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +5 -1
- package/dist/headless.d.ts +5 -1
- package/dist/headless.js +5 -151
- package/dist/headless.js.map +1 -1
- package/dist/index.cjs +348 -183
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -4
- package/dist/index.d.ts +14 -4
- package/dist/index.js +7 -183
- package/dist/index.js.map +1 -1
- package/dist/math.cjs +19 -13
- package/dist/math.cjs.map +1 -1
- package/dist/math.js +10 -17
- package/dist/math.js.map +1 -1
- package/dist/mention.cjs +19 -13
- package/dist/mention.cjs.map +1 -1
- package/dist/mention.js +10 -17
- package/dist/mention.js.map +1 -1
- package/dist/presence.cjs +98 -132
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.js +21 -78
- package/dist/presence.js.map +1 -1
- package/dist/{registry-CWBOSAHm.d.ts → registry-CXegaw5k.d.cts} +25 -2
- package/dist/{registry-CWBOSAHm.d.cts → registry-CXegaw5k.d.ts} +25 -2
- package/dist/stats.cjs +26 -18
- package/dist/stats.cjs.map +1 -1
- package/dist/stats.js +9 -18
- package/dist/stats.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/table.cjs +89 -49
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +8 -49
- package/dist/table.js.map +1 -1
- package/dist/toc.cjs +25 -17
- package/dist/toc.cjs.map +1 -1
- package/dist/toc.js +8 -17
- package/dist/toc.js.map +1 -1
- package/dist/view.cjs +13 -16
- package/dist/view.cjs.map +1 -1
- package/dist/view.d.cts +2 -2
- package/dist/view.d.ts +2 -2
- package/dist/view.js +7 -16
- package/dist/view.js.map +1 -1
- package/dist/yjs.cjs +186 -228
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +12 -80
- package/dist/yjs.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4SLJNZSM.cjs.map +0 -1
- package/dist/chunk-4XFXB37X.js.map +0 -1
- package/dist/chunk-5MAYUGTE.cjs.map +0 -1
- package/dist/chunk-623AOJM2.js.map +0 -1
- package/dist/chunk-6NULZPVC.js.map +0 -1
- package/dist/chunk-6V6GGBDK.cjs.map +0 -1
- package/dist/chunk-73653CJ4.cjs +0 -34
- package/dist/chunk-73653CJ4.cjs.map +0 -1
- package/dist/chunk-ADSJ42DO.js.map +0 -1
- package/dist/chunk-AUOEM3SF.cjs.map +0 -1
- package/dist/chunk-BQANU5BH.cjs.map +0 -1
- package/dist/chunk-C23RQVRK.js.map +0 -1
- package/dist/chunk-CW3AFJBR.cjs.map +0 -1
- package/dist/chunk-DUE3HCZD.js.map +0 -1
- package/dist/chunk-EH5KXQXY.cjs.map +0 -1
- package/dist/chunk-EPARJI4V.js.map +0 -1
- package/dist/chunk-FDRUAL3Z.cjs.map +0 -1
- package/dist/chunk-IQBMAE3F.js.map +0 -1
- package/dist/chunk-JHQUHFLX.js.map +0 -1
- package/dist/chunk-KUYZMSMF.cjs +0 -100
- package/dist/chunk-KUYZMSMF.cjs.map +0 -1
- package/dist/chunk-LLTEGXWZ.cjs +0 -562
- package/dist/chunk-LLTEGXWZ.cjs.map +0 -1
- package/dist/chunk-N4FGA3H4.js.map +0 -1
- package/dist/chunk-NEZJ7ZP5.js.map +0 -1
- package/dist/chunk-O4Z2WMFF.js.map +0 -1
- package/dist/chunk-OBMBSU2S.js.map +0 -1
- package/dist/chunk-OSHZQR3W.js.map +0 -1
- package/dist/chunk-P6KYXFZC.cjs.map +0 -1
- package/dist/chunk-R2BLBV43.cjs +0 -239
- package/dist/chunk-R2BLBV43.cjs.map +0 -1
- package/dist/chunk-RJRX34BZ.js.map +0 -1
- package/dist/chunk-T43RZTUT.js.map +0 -1
- package/dist/chunk-TLGX43P6.cjs.map +0 -1
- package/dist/chunk-U3LOLYAU.js.map +0 -1
- package/dist/chunk-UEKXVCKC.cjs +0 -716
- package/dist/chunk-UEKXVCKC.cjs.map +0 -1
- package/dist/chunk-VCLL5C7J.js.map +0 -1
- package/dist/chunk-VRS6WCEK.js.map +0 -1
- package/dist/chunk-WEYDDIBQ.cjs.map +0 -1
- package/dist/chunk-X4HDKFW5.cjs.map +0 -1
- package/dist/chunk-X4P4TQXH.cjs +0 -30
- package/dist/chunk-X4P4TQXH.cjs.map +0 -1
- package/dist/chunk-XA3UEJIW.cjs +0 -25
- package/dist/chunk-XA3UEJIW.cjs.map +0 -1
- package/dist/chunk-YBMUEEM5.js.map +0 -1
- package/dist/chunk-ZKVOS57Q.cjs.map +0 -1
|
@@ -1,72 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _chunkCW3AFJBRcjs = require('./chunk-CW3AFJBR.cjs');
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var _chunkP6KYXFZCcjs = require('./chunk-P6KYXFZC.cjs');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var _chunkZKVOS57Qcjs = require('./chunk-ZKVOS57Q.cjs');
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
var _chunk4SLJNZSMcjs = require('./chunk-4SLJNZSM.cjs');
|
|
3
|
+
var chunkQEMGOL5L_cjs = require('./chunk-QEMGOL5L.cjs');
|
|
4
|
+
var chunkACSEYJJF_cjs = require('./chunk-ACSEYJJF.cjs');
|
|
5
|
+
var chunkVFSVN5IQ_cjs = require('./chunk-VFSVN5IQ.cjs');
|
|
6
|
+
var chunkAIS37SL2_cjs = require('./chunk-AIS37SL2.cjs');
|
|
7
|
+
var react = require('react');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
var reactDom = require('react-dom');
|
|
10
|
+
var lucideReact = require('lucide-react');
|
|
64
11
|
|
|
65
12
|
// src/engine/commands/table-shape.ts
|
|
66
13
|
var CELL = /^cell:(\d+):(\d+)$/;
|
|
67
14
|
var tableShape = (block) => ({
|
|
68
|
-
rows:
|
|
69
|
-
cols:
|
|
15
|
+
rows: chunkAIS37SL2_cjs.countOf(block.attrs.rows),
|
|
16
|
+
cols: chunkAIS37SL2_cjs.countOf(block.attrs.cols)
|
|
70
17
|
});
|
|
71
18
|
var ALIGNS = ["left", "center", "right"];
|
|
72
19
|
var columnAligns = (block, cols) => Array.from({ length: cols }, (_, col) => {
|
|
@@ -80,8 +27,8 @@ function cellOf(region) {
|
|
|
80
27
|
return match === null ? null : [Number(match[1]), Number(match[2])];
|
|
81
28
|
}
|
|
82
29
|
function tableBlock(doc, id) {
|
|
83
|
-
const block =
|
|
84
|
-
return
|
|
30
|
+
const block = chunkAIS37SL2_cjs.blockById(doc, id);
|
|
31
|
+
return block?.type === "TABLE" ? block : null;
|
|
85
32
|
}
|
|
86
33
|
var isIndex = (index, length) => Number.isInteger(index) && index >= 0 && index < length;
|
|
87
34
|
function movedOrder(length, from, to) {
|
|
@@ -94,7 +41,7 @@ function rebuiltTable(block, plan) {
|
|
|
94
41
|
for (let row = 0; row < plan.rows; row++) {
|
|
95
42
|
for (let col = 0; col < plan.cols; col++) {
|
|
96
43
|
const from = plan.source(row, col);
|
|
97
|
-
regions[
|
|
44
|
+
regions[chunkAIS37SL2_cjs.cellKey(row, col)] = from === null ? [] : block.regions[chunkAIS37SL2_cjs.cellKey(...from)] ?? [];
|
|
98
45
|
}
|
|
99
46
|
}
|
|
100
47
|
return { ...block, attrs: { ...block.attrs, ...plan.attrs, rows: plan.rows, cols: plan.cols }, regions };
|
|
@@ -103,19 +50,19 @@ function followedPos(pos, blockId, plan) {
|
|
|
103
50
|
const cell = pos.block === blockId ? cellOf(pos.region) : null;
|
|
104
51
|
if (cell === null) return pos;
|
|
105
52
|
const moved = plan.target(cell);
|
|
106
|
-
return moved === null ? { block: blockId, region:
|
|
53
|
+
return moved === null ? { block: blockId, region: chunkAIS37SL2_cjs.cellKey(...plan.landing(cell)), offset: 0 } : { ...pos, region: chunkAIS37SL2_cjs.cellKey(...moved) };
|
|
107
54
|
}
|
|
108
55
|
function followedSelection(selection, blockId, plan) {
|
|
109
|
-
if (
|
|
56
|
+
if (selection?.kind !== "text") return selection;
|
|
110
57
|
const anchor = followedPos(selection.anchor, blockId, plan);
|
|
111
58
|
const head = followedPos(selection.head, blockId, plan);
|
|
112
|
-
return anchor === selection.anchor && head === selection.head ? selection :
|
|
59
|
+
return anchor === selection.anchor && head === selection.head ? selection : chunkVFSVN5IQ_cjs.textSelection(anchor, head);
|
|
113
60
|
}
|
|
114
61
|
|
|
115
62
|
// src/engine/state/cell-selection.ts
|
|
116
|
-
var cellSelectionKey =
|
|
63
|
+
var cellSelectionKey = chunkVFSVN5IQ_cjs.createPluginKey("cellSelection");
|
|
117
64
|
function rangeOfSelection({ doc, selection }) {
|
|
118
|
-
if (
|
|
65
|
+
if (selection?.kind !== "text") return null;
|
|
119
66
|
const { anchor, head } = selection;
|
|
120
67
|
if (anchor.block !== head.block || anchor.region === head.region || tableBlock(doc, anchor.block) === null) return null;
|
|
121
68
|
const from = cellOf(anchor.region);
|
|
@@ -151,39 +98,39 @@ function selectCells(blockId, anchor, head) {
|
|
|
151
98
|
const { rows, cols } = block === null ? { rows: 0, cols: 0 } : tableShape(block);
|
|
152
99
|
const inside = ([row, col]) => isIndex(row, rows) && isIndex(col, cols);
|
|
153
100
|
if (block === null || !inside(anchor) || !inside(head)) return false;
|
|
154
|
-
const end2 =
|
|
155
|
-
const selection =
|
|
156
|
-
{ block: blockId, region:
|
|
157
|
-
{ block: blockId, region: end2, offset:
|
|
101
|
+
const end2 = chunkAIS37SL2_cjs.cellKey(...head);
|
|
102
|
+
const selection = chunkVFSVN5IQ_cjs.textSelection(
|
|
103
|
+
{ block: blockId, region: chunkAIS37SL2_cjs.cellKey(...anchor), offset: 0 },
|
|
104
|
+
{ block: blockId, region: end2, offset: chunkAIS37SL2_cjs.inlineLength(block.regions[end2] ?? []) }
|
|
158
105
|
);
|
|
159
|
-
|
|
106
|
+
dispatch?.(new chunkVFSVN5IQ_cjs.Transaction(state).setSelection(selection));
|
|
160
107
|
return true;
|
|
161
108
|
};
|
|
162
109
|
}
|
|
163
110
|
|
|
164
111
|
// src/engine/commands/cell-commands.ts
|
|
165
112
|
function filledCells(doc, range) {
|
|
166
|
-
const regions =
|
|
113
|
+
const regions = chunkAIS37SL2_cjs.blockById(doc, range.block)?.regions ?? {};
|
|
167
114
|
return cellsInRange(range).flatMap((cell) => {
|
|
168
|
-
const region =
|
|
169
|
-
const length =
|
|
115
|
+
const region = chunkAIS37SL2_cjs.cellKey(...cell);
|
|
116
|
+
const length = chunkAIS37SL2_cjs.inlineLength(regions[region] ?? []);
|
|
170
117
|
return length > 0 ? [{ region, length }] : [];
|
|
171
118
|
});
|
|
172
119
|
}
|
|
173
120
|
function firstCell({ block, anchor, head }) {
|
|
174
|
-
return { block, region:
|
|
121
|
+
return { block, region: chunkAIS37SL2_cjs.cellKey(Math.min(anchor[0], head[0]), Math.min(anchor[1], head[1])), offset: 0 };
|
|
175
122
|
}
|
|
176
123
|
function emptied(state, range) {
|
|
177
|
-
const tr = new
|
|
124
|
+
const tr = new chunkVFSVN5IQ_cjs.Transaction(state);
|
|
178
125
|
for (const { region, length } of filledCells(state.doc, range)) {
|
|
179
|
-
tr.step(
|
|
126
|
+
tr.step(chunkVFSVN5IQ_cjs.replaceInlineStep(range.block, region, 0, length, []));
|
|
180
127
|
}
|
|
181
128
|
return tr;
|
|
182
129
|
}
|
|
183
130
|
var deleteCellContents = (state, dispatch) => {
|
|
184
131
|
const range = cellSelection(state);
|
|
185
132
|
if (range === null) return false;
|
|
186
|
-
|
|
133
|
+
dispatch?.(emptied(state, range).setSelection(chunkVFSVN5IQ_cjs.textSelection(firstCell(range))));
|
|
187
134
|
return true;
|
|
188
135
|
};
|
|
189
136
|
function typeOverCells(text) {
|
|
@@ -191,7 +138,7 @@ function typeOverCells(text) {
|
|
|
191
138
|
const range = cellSelection(state);
|
|
192
139
|
if (range === null || text === "") return false;
|
|
193
140
|
const tr = emptied(state, range);
|
|
194
|
-
|
|
141
|
+
dispatch?.(tr.setSelection(chunkVFSVN5IQ_cjs.textSelection(chunkVFSVN5IQ_cjs.insertTextAt(tr, state.schema, firstCell(range), text))));
|
|
195
142
|
return true;
|
|
196
143
|
};
|
|
197
144
|
}
|
|
@@ -199,47 +146,40 @@ function setCellsMark(type, attrs) {
|
|
|
199
146
|
return (state, dispatch) => {
|
|
200
147
|
const range = cellSelection(state);
|
|
201
148
|
const cells = range === null ? [] : filledCells(state.doc, range);
|
|
202
|
-
const regions = range === null ? void 0 :
|
|
149
|
+
const regions = range === null ? void 0 : chunkAIS37SL2_cjs.blockById(state.doc, range.block)?.regions;
|
|
203
150
|
if (range === null || regions === void 0 || cells.length === 0) return false;
|
|
204
|
-
const carried = cells.every(({ region }) =>
|
|
205
|
-
const mark = carried ?
|
|
206
|
-
const tr = new
|
|
151
|
+
const carried = cells.every(({ region }) => chunkVFSVN5IQ_cjs.markCoverage(regions[region], type, attrs).every);
|
|
152
|
+
const mark = carried ? chunkVFSVN5IQ_cjs.toggleMark(type, attrs) : chunkVFSVN5IQ_cjs.setMark(type, attrs);
|
|
153
|
+
const tr = new chunkVFSVN5IQ_cjs.Transaction(state);
|
|
207
154
|
for (const { region, length } of cells) {
|
|
208
155
|
const start = { block: range.block, region, offset: 0 };
|
|
209
|
-
const whole =
|
|
156
|
+
const whole = chunkVFSVN5IQ_cjs.textSelection(start, { ...start, offset: length });
|
|
210
157
|
mark({ ...state, doc: tr.doc, selection: whole, storedMarks: null }, (cell) => {
|
|
211
158
|
for (const step of cell.steps) tr.step(step);
|
|
212
159
|
});
|
|
213
160
|
}
|
|
214
161
|
if (!tr.docChanged) return false;
|
|
215
|
-
|
|
162
|
+
dispatch?.(tr);
|
|
216
163
|
return true;
|
|
217
164
|
};
|
|
218
165
|
}
|
|
219
166
|
|
|
220
|
-
// src/extensions/table/TableBlock.tsx
|
|
221
|
-
var _react = require('react');
|
|
222
|
-
|
|
223
167
|
// src/extensions/table/controls-slot.ts
|
|
224
168
|
var CONTROLS_SLOT = "data-quoin-table-controls";
|
|
225
|
-
var controlsSlot = (controller, blockId) =>
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
230
|
-
var TableCell = _react.memo.call(void 0, function TableCell2({ controller, blockId, row, col, header, align, label }) {
|
|
231
|
-
const inRange = _chunkP6KYXFZCcjs.useEditorState.call(void 0,
|
|
169
|
+
var controlsSlot = (controller, blockId) => controller.blockElement(blockId)?.querySelector(`[${CONTROLS_SLOT}]`) ?? null;
|
|
170
|
+
var TableCell = react.memo(function TableCell2({ controller, blockId, row, col, header, align, label }) {
|
|
171
|
+
const inRange = chunkACSEYJJF_cjs.useEditorState(
|
|
232
172
|
controller,
|
|
233
|
-
|
|
173
|
+
react.useCallback(
|
|
234
174
|
(state) => {
|
|
235
175
|
const range = cellSelection(state);
|
|
236
|
-
return
|
|
176
|
+
return range?.block === blockId && rangeHasCell(range, [row, col]);
|
|
237
177
|
},
|
|
238
178
|
[blockId, row, col]
|
|
239
179
|
)
|
|
240
180
|
);
|
|
241
181
|
const Cell = header ? "th" : "td";
|
|
242
|
-
return /* @__PURE__ */
|
|
182
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
243
183
|
Cell,
|
|
244
184
|
{
|
|
245
185
|
scope: header ? "col" : void 0,
|
|
@@ -247,13 +187,10 @@ var TableCell = _react.memo.call(void 0, function TableCell2({ controller, block
|
|
|
247
187
|
"data-col": col,
|
|
248
188
|
"data-in-range": inRange ? "" : void 0,
|
|
249
189
|
style: align === null ? void 0 : { textAlign: align },
|
|
250
|
-
children: /* @__PURE__ */
|
|
190
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(chunkACSEYJJF_cjs.EditableRegion, { block: blockId, region: chunkAIS37SL2_cjs.cellKey(row, col), label, className: "quoin-table-text" })
|
|
251
191
|
}
|
|
252
192
|
);
|
|
253
193
|
});
|
|
254
|
-
|
|
255
|
-
// src/extensions/table/table-ui-store.ts
|
|
256
|
-
|
|
257
194
|
function createTableUiStore() {
|
|
258
195
|
let state = { preview: null };
|
|
259
196
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -280,24 +217,21 @@ function tableUiStore(controller) {
|
|
|
280
217
|
}
|
|
281
218
|
function useWidthPreview(controller, blockId) {
|
|
282
219
|
const store = tableUiStore(controller);
|
|
283
|
-
const read =
|
|
220
|
+
const read = react.useCallback(() => {
|
|
284
221
|
const { preview } = store.get();
|
|
285
|
-
return
|
|
222
|
+
return preview?.block === blockId ? preview.widths : null;
|
|
286
223
|
}, [store, blockId]);
|
|
287
|
-
return
|
|
224
|
+
return react.useSyncExternalStore(store.subscribe, read, read);
|
|
288
225
|
}
|
|
289
226
|
|
|
290
|
-
// src/extensions/table/use-cell-press.ts
|
|
291
|
-
|
|
292
|
-
|
|
293
227
|
// src/engine/commands/table-commands.ts
|
|
294
228
|
function changeTable(blockId, change, plan) {
|
|
295
229
|
return (state, dispatch) => {
|
|
296
230
|
const block = tableBlock(state.doc, blockId);
|
|
297
231
|
const next = block && change(block);
|
|
298
232
|
if (!next) return false;
|
|
299
|
-
const tr = new
|
|
300
|
-
|
|
233
|
+
const tr = new chunkVFSVN5IQ_cjs.Transaction(state).step(chunkVFSVN5IQ_cjs.replaceBlockStep(next));
|
|
234
|
+
dispatch?.(plan ? tr.setSelection(followedSelection(state.selection, blockId, plan)) : tr);
|
|
301
235
|
return true;
|
|
302
236
|
};
|
|
303
237
|
}
|
|
@@ -399,57 +333,57 @@ var setColumnWidth = (blockId, col, px, drawn) => changeTable(blockId, (block) =
|
|
|
399
333
|
const width = Math.round(px);
|
|
400
334
|
if (!isIndex(col, cols) || !(width > 0)) return null;
|
|
401
335
|
const stored = storedWidths(block, cols);
|
|
402
|
-
if (
|
|
336
|
+
if (stored?.[col] === width) return null;
|
|
403
337
|
const measured = drawn && validWidths(drawn.map(Math.round), cols);
|
|
404
|
-
const widths =
|
|
338
|
+
const widths = stored ?? measured ?? Array(cols).fill(DEFAULT_COLUMN_WIDTH);
|
|
405
339
|
return withAttrs(block, { widths: spliced(widths, col, 1, width) });
|
|
406
340
|
});
|
|
407
341
|
var isCount = (value) => Number.isInteger(value) && value > 0;
|
|
408
342
|
function emptyCells({ rows, cols }) {
|
|
409
343
|
const regions = {};
|
|
410
|
-
for (let row = 0; row < rows; row++) for (let col = 0; col < cols; col++) regions[
|
|
344
|
+
for (let row = 0; row < rows; row++) for (let col = 0; col < cols; col++) regions[chunkAIS37SL2_cjs.cellKey(row, col)] = [];
|
|
411
345
|
return regions;
|
|
412
346
|
}
|
|
413
347
|
function insertTable(rows, cols, options = {}) {
|
|
414
348
|
return (state, dispatch) => {
|
|
415
349
|
const { doc, schema } = state;
|
|
416
|
-
const id =
|
|
350
|
+
const id = chunkVFSVN5IQ_cjs.headBlockId(state.selection);
|
|
417
351
|
if (id === null || !isCount(rows) || !isCount(cols)) return false;
|
|
418
|
-
const index =
|
|
352
|
+
const index = chunkAIS37SL2_cjs.requireBlockIndex(doc, id);
|
|
419
353
|
const current = doc.blocks[index];
|
|
420
|
-
const fills =
|
|
354
|
+
const fills = chunkVFSVN5IQ_cjs.isParagraph(current) && chunkVFSVN5IQ_cjs.regionLength(current, chunkVFSVN5IQ_cjs.primaryRegion(schema, current) ?? "") === 0;
|
|
421
355
|
const table = {
|
|
422
|
-
id: fills ? current.id : (
|
|
356
|
+
id: fills ? current.id : (options.newId ?? chunkAIS37SL2_cjs.newId)(),
|
|
423
357
|
type: "TABLE",
|
|
424
358
|
indent: current.indent,
|
|
425
359
|
attrs: { header: true, align: Array.from({ length: cols }, () => null), rows, cols },
|
|
426
360
|
regions: emptyCells({ rows, cols })
|
|
427
361
|
};
|
|
428
|
-
const tr = new
|
|
429
|
-
fills ?
|
|
362
|
+
const tr = new chunkVFSVN5IQ_cjs.Transaction(state).step(
|
|
363
|
+
fills ? chunkVFSVN5IQ_cjs.replaceBlockStep(table) : chunkVFSVN5IQ_cjs.insertBlocksStep(chunkVFSVN5IQ_cjs.descendantsEnd(doc, index), [table])
|
|
430
364
|
);
|
|
431
|
-
|
|
365
|
+
dispatch?.(tr.setSelection(chunkVFSVN5IQ_cjs.textSelection({ block: table.id, region: chunkAIS37SL2_cjs.cellKey(0, 0), offset: 0 })));
|
|
432
366
|
return true;
|
|
433
367
|
};
|
|
434
368
|
}
|
|
435
369
|
|
|
436
370
|
// src/extensions/table/table-keys.ts
|
|
437
371
|
function headCell({ doc, selection }) {
|
|
438
|
-
if (
|
|
372
|
+
if (selection?.kind !== "text") return null;
|
|
439
373
|
const { head } = selection;
|
|
440
374
|
const block = tableBlock(doc, head.block);
|
|
441
375
|
const cell = block && cellOf(head.region);
|
|
442
376
|
return block && cell ? { block, cell, head, shape: tableShape(block) } : null;
|
|
443
377
|
}
|
|
444
|
-
var cellLength = (block, [row, col]) =>
|
|
378
|
+
var cellLength = (block, [row, col]) => chunkAIS37SL2_cjs.inlineLength(block.regions[chunkAIS37SL2_cjs.cellKey(row, col)] ?? []);
|
|
445
379
|
var cellPos = (block, cell, atEnd = false) => ({
|
|
446
380
|
block: block.id,
|
|
447
|
-
region:
|
|
381
|
+
region: chunkAIS37SL2_cjs.cellKey(...cell),
|
|
448
382
|
offset: atEnd ? cellLength(block, cell) : 0
|
|
449
383
|
});
|
|
450
|
-
var moveTo = (state, pos) => new
|
|
384
|
+
var moveTo = (state, pos) => new chunkVFSVN5IQ_cjs.Transaction(state).setSelection(chunkVFSVN5IQ_cjs.textSelection(pos));
|
|
451
385
|
var thenCaretIn = (command, blockId, at) => (state, dispatch) => {
|
|
452
|
-
const caret =
|
|
386
|
+
const caret = chunkVFSVN5IQ_cjs.textSelection({ block: blockId, region: chunkAIS37SL2_cjs.cellKey(...at), offset: 0 });
|
|
453
387
|
return command(state, dispatch && ((tr) => dispatch(tr.setSelection(caret))));
|
|
454
388
|
};
|
|
455
389
|
var cellAtIndex = (index, { cols }) => [Math.floor(index / cols), index % cols];
|
|
@@ -462,7 +396,7 @@ var nextCell = (state, dispatch) => {
|
|
|
462
396
|
if (next === shape.rows * shape.cols) {
|
|
463
397
|
return thenCaretIn(addRow(block.id, shape.rows), block.id, [shape.rows, 0])(state, dispatch);
|
|
464
398
|
}
|
|
465
|
-
|
|
399
|
+
dispatch?.(moveTo(state, cellPos(block, cellAtIndex(next, shape), true)));
|
|
466
400
|
return true;
|
|
467
401
|
};
|
|
468
402
|
var previousCell = (state, dispatch) => {
|
|
@@ -470,7 +404,7 @@ var previousCell = (state, dispatch) => {
|
|
|
470
404
|
if (caret === null) return false;
|
|
471
405
|
const { block, cell, shape } = caret;
|
|
472
406
|
const previous = indexOfCell(cell, shape) - 1;
|
|
473
|
-
if (previous >= 0)
|
|
407
|
+
if (previous >= 0) dispatch?.(moveTo(state, cellPos(block, cellAtIndex(previous, shape), true)));
|
|
474
408
|
return true;
|
|
475
409
|
};
|
|
476
410
|
var enterInCell = (state, dispatch) => {
|
|
@@ -482,11 +416,11 @@ var enterInCell = (state, dispatch) => {
|
|
|
482
416
|
if (row === shape.rows - 1 && cellLength(block, cell) === 0) {
|
|
483
417
|
return thenCaretIn(addRow(block.id, shape.rows), block.id, [shape.rows, col])(state, dispatch);
|
|
484
418
|
}
|
|
485
|
-
return
|
|
419
|
+
return chunkVFSVN5IQ_cjs.insertHardBreak(state, dispatch);
|
|
486
420
|
};
|
|
487
421
|
var stopAtCellEdge = (atEnd) => (state) => {
|
|
488
422
|
const caret = headCell(state);
|
|
489
|
-
if (caret === null || !
|
|
423
|
+
if (caret === null || !chunkVFSVN5IQ_cjs.isCollapsed(state.selection)) return false;
|
|
490
424
|
return caret.head.offset === (atEnd ? cellLength(caret.block, caret.cell) : 0);
|
|
491
425
|
};
|
|
492
426
|
var firstThatApplies = (...commands) => (state, dispatch) => commands.some((command) => command(state, dispatch));
|
|
@@ -514,12 +448,12 @@ function cellOf2(element) {
|
|
|
514
448
|
return element.matches("td, th") && row !== null && col !== null ? [Number(row), Number(col)] : null;
|
|
515
449
|
}
|
|
516
450
|
function useCellPress(controller, blockId, table, editable) {
|
|
517
|
-
|
|
451
|
+
react.useEffect(() => {
|
|
518
452
|
const element = table.current;
|
|
519
453
|
if (!editable || element === null) return;
|
|
520
454
|
const onPointerDown = (event) => {
|
|
521
455
|
const cell = event.button === 0 && event.pointerType !== "touch" ? cellOf2(event.target) : null;
|
|
522
|
-
const block = cell &&
|
|
456
|
+
const block = cell && chunkAIS37SL2_cjs.blockById(controller.editor.state.doc, blockId);
|
|
523
457
|
if (!cell || !block) return;
|
|
524
458
|
event.preventDefault();
|
|
525
459
|
event.stopPropagation();
|
|
@@ -529,54 +463,48 @@ function useCellPress(controller, blockId, table, editable) {
|
|
|
529
463
|
return () => element.removeEventListener("pointerdown", onPointerDown);
|
|
530
464
|
}, [controller, blockId, table, editable]);
|
|
531
465
|
}
|
|
532
|
-
|
|
533
|
-
// src/extensions/table/use-reveal-cell.ts
|
|
534
|
-
|
|
535
466
|
function useRevealCell(controller, blockId) {
|
|
536
|
-
const region =
|
|
467
|
+
const region = chunkACSEYJJF_cjs.useEditorState(
|
|
537
468
|
controller,
|
|
538
|
-
|
|
469
|
+
react.useCallback(
|
|
539
470
|
(state) => {
|
|
540
471
|
const caret = headCell(state);
|
|
541
|
-
return
|
|
472
|
+
return caret?.block.id === blockId ? caret.head.region : null;
|
|
542
473
|
},
|
|
543
474
|
[blockId]
|
|
544
475
|
)
|
|
545
476
|
);
|
|
546
|
-
|
|
477
|
+
react.useEffect(() => {
|
|
547
478
|
const host = region === null ? void 0 : controller.registry.get(blockId, region);
|
|
548
479
|
const root = controller.root;
|
|
549
|
-
if (!host || !
|
|
550
|
-
|
|
480
|
+
if (!host || !root?.contains(root.ownerDocument.activeElement)) return;
|
|
481
|
+
host.closest("td, th")?.scrollIntoView({ block: "nearest", inline: "nearest" });
|
|
551
482
|
}, [controller, blockId, region]);
|
|
552
483
|
}
|
|
553
484
|
|
|
554
|
-
// src/extensions/table/use-table-keys.ts
|
|
555
|
-
|
|
556
|
-
|
|
557
485
|
// src/extensions/table/vertical-cell-move.ts
|
|
558
486
|
var VERTICAL = { ArrowUp: -1, ArrowDown: 1 };
|
|
559
487
|
function caretAtGoal(controller, blockId, cell, direction) {
|
|
560
|
-
const region =
|
|
488
|
+
const region = chunkAIS37SL2_cjs.cellKey(...cell);
|
|
561
489
|
const host = controller.registry.get(blockId, region);
|
|
562
490
|
const { goalX } = controller;
|
|
563
|
-
const line = host &&
|
|
491
|
+
const line = host && chunkACSEYJJF_cjs.lineEdgeRect(host, direction < 0);
|
|
564
492
|
if (!host || !line || goalX === null) return null;
|
|
565
493
|
const box = host.getBoundingClientRect();
|
|
566
494
|
const x = Math.min(Math.max(goalX, box.left), box.right - 1);
|
|
567
|
-
const point =
|
|
568
|
-
const pos = point &&
|
|
495
|
+
const point = chunkACSEYJJF_cjs.caretFromPoint(host.ownerDocument, x, line.top + line.height / 2);
|
|
496
|
+
const pos = point && chunkACSEYJJF_cjs.domToPos(controller.registry, point.node, point.offset);
|
|
569
497
|
return pos && pos.block === blockId && pos.region === region ? pos : null;
|
|
570
498
|
}
|
|
571
499
|
var plainArrow = (event) => event.altKey || event.ctrlKey || event.metaKey ? void 0 : VERTICAL[event.key];
|
|
572
500
|
function caretOnEdgeLine(controller, head, direction) {
|
|
573
501
|
const host = controller.registry.get(head.block, head.region);
|
|
574
|
-
const point =
|
|
575
|
-
if (!host || !point || !(direction < 0 ?
|
|
576
|
-
return { left:
|
|
502
|
+
const point = chunkACSEYJJF_cjs.posToDom(controller.registry, head);
|
|
503
|
+
if (!host || !point || !(direction < 0 ? chunkACSEYJJF_cjs.isOnFirstLine(host, point) : chunkACSEYJJF_cjs.isOnLastLine(host, point))) return null;
|
|
504
|
+
return { left: chunkACSEYJJF_cjs.caretClientRect(point)?.left ?? null };
|
|
577
505
|
}
|
|
578
506
|
function columnAt(controller, blockId, row, x) {
|
|
579
|
-
const cells = Array.from(
|
|
507
|
+
const cells = Array.from(controller.blockElement(blockId)?.querySelector("table")?.rows[row]?.cells ?? []);
|
|
580
508
|
const index = cells.findIndex((cell) => x < cell.getBoundingClientRect().right);
|
|
581
509
|
return index === -1 ? Math.max(cells.length - 1, 0) : index;
|
|
582
510
|
}
|
|
@@ -585,8 +513,8 @@ function enterTable(controller, blockId, event) {
|
|
|
585
513
|
const { state } = controller.editor;
|
|
586
514
|
const { selection } = state;
|
|
587
515
|
const block = tableBlock(state.doc, blockId);
|
|
588
|
-
if (direction === void 0 || event.shiftKey || block === null ||
|
|
589
|
-
if (!
|
|
516
|
+
if (direction === void 0 || event.shiftKey || block === null || selection?.kind !== "text") return false;
|
|
517
|
+
if (!chunkVFSVN5IQ_cjs.isCollapsed(selection) || chunkACSEYJJF_cjs.neighbourBlock(state.doc, selection.head.block, direction)?.id !== blockId) return false;
|
|
590
518
|
const caret = caretOnEdgeLine(controller, selection.head, direction);
|
|
591
519
|
if (caret === null) return false;
|
|
592
520
|
controller.goalX ??= caret.left;
|
|
@@ -594,15 +522,15 @@ function enterTable(controller, blockId, event) {
|
|
|
594
522
|
const row = direction > 0 ? 0 : rows - 1;
|
|
595
523
|
const { goalX } = controller;
|
|
596
524
|
const cell = [row, goalX === null ? direction > 0 ? 0 : cols - 1 : columnAt(controller, blockId, row, goalX)];
|
|
597
|
-
const pos =
|
|
598
|
-
controller.dispatch(controller.editor.createTransaction().setSelection(
|
|
525
|
+
const pos = caretAtGoal(controller, blockId, cell, direction) ?? cellPos(block, cell, direction < 0);
|
|
526
|
+
controller.dispatch(controller.editor.createTransaction().setSelection(chunkVFSVN5IQ_cjs.textSelection(pos)));
|
|
599
527
|
return true;
|
|
600
528
|
}
|
|
601
529
|
function moveBetweenRows(controller, blockId, event) {
|
|
602
530
|
const direction = plainArrow(event);
|
|
603
531
|
const { state } = controller.editor;
|
|
604
532
|
const caret = headCell(state);
|
|
605
|
-
if (direction === void 0 || caret === null || caret.block.id !== blockId ||
|
|
533
|
+
if (direction === void 0 || caret === null || caret.block.id !== blockId || state.selection?.kind !== "text") {
|
|
606
534
|
return false;
|
|
607
535
|
}
|
|
608
536
|
const target = [caret.cell[0] + direction, caret.cell[1]];
|
|
@@ -610,8 +538,8 @@ function moveBetweenRows(controller, blockId, event) {
|
|
|
610
538
|
const edge = caretOnEdgeLine(controller, caret.head, direction);
|
|
611
539
|
if (edge === null) return false;
|
|
612
540
|
controller.goalX ??= edge.left;
|
|
613
|
-
const pos =
|
|
614
|
-
const selection = event.shiftKey ?
|
|
541
|
+
const pos = caretAtGoal(controller, blockId, target, direction) ?? cellPos(caret.block, target, direction < 0);
|
|
542
|
+
const selection = event.shiftKey ? chunkVFSVN5IQ_cjs.textSelection(state.selection.anchor, pos) : chunkVFSVN5IQ_cjs.textSelection(pos);
|
|
615
543
|
controller.dispatch(controller.editor.createTransaction().setSelection(selection));
|
|
616
544
|
return true;
|
|
617
545
|
}
|
|
@@ -619,37 +547,34 @@ function moveBetweenRows(controller, blockId, event) {
|
|
|
619
547
|
// src/extensions/table/use-table-keys.ts
|
|
620
548
|
var printable = (event) => [...event.key].length === 1 && !event.ctrlKey && !event.metaKey;
|
|
621
549
|
function typeOver(controller, blockId, event) {
|
|
622
|
-
if (
|
|
550
|
+
if (cellSelection(controller.editor.state)?.block !== blockId || !printable(event)) return false;
|
|
623
551
|
return controller.run(typeOverCells(event.key));
|
|
624
552
|
}
|
|
625
553
|
function useTableKeys(controller, blockId, editable) {
|
|
626
|
-
|
|
554
|
+
react.useEffect(() => {
|
|
627
555
|
if (!editable) return;
|
|
628
556
|
const intercept = (event) => {
|
|
629
|
-
if (
|
|
557
|
+
if (chunkACSEYJJF_cjs.isComposingKey(controller, event)) return false;
|
|
630
558
|
const handled = typeOver(controller, blockId, event) || moveBetweenRows(controller, blockId, event) || enterTable(controller, blockId, event);
|
|
631
559
|
if (handled) event.preventDefault();
|
|
632
560
|
return handled;
|
|
633
561
|
};
|
|
634
|
-
return
|
|
562
|
+
return chunkQEMGOL5L_cjs.interceptKeys(controller, intercept);
|
|
635
563
|
}, [controller, blockId, editable]);
|
|
636
564
|
}
|
|
637
|
-
|
|
638
|
-
// src/extensions/table/TableBlock.tsx
|
|
639
|
-
|
|
640
565
|
var indexes = (from, to) => Array.from({ length: Math.max(to - from, 0) }, (_, i) => from + i);
|
|
641
566
|
function TableBlock({ block, controller, labels }) {
|
|
642
|
-
const readOnly =
|
|
643
|
-
const table =
|
|
567
|
+
const readOnly = chunkACSEYJJF_cjs.useReadOnly(controller);
|
|
568
|
+
const table = react.useRef(null);
|
|
644
569
|
const { rows, cols } = tableShape(block);
|
|
645
570
|
const header = block.attrs.header !== false && rows > 0;
|
|
646
571
|
const aligns = columnAligns(block, cols);
|
|
647
572
|
const preview = useWidthPreview(controller, block.id);
|
|
648
|
-
const widths =
|
|
573
|
+
const widths = preview?.length === cols ? preview : storedWidths(block, cols);
|
|
649
574
|
useTableKeys(controller, block.id, !readOnly);
|
|
650
575
|
useCellPress(controller, block.id, table, !readOnly);
|
|
651
576
|
useRevealCell(controller, block.id);
|
|
652
|
-
const row = (index) => /* @__PURE__ */
|
|
577
|
+
const row = (index) => /* @__PURE__ */ jsxRuntime.jsx("tr", { children: indexes(0, cols).map((col) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
653
578
|
TableCell,
|
|
654
579
|
{
|
|
655
580
|
controller,
|
|
@@ -663,38 +588,34 @@ function TableBlock({ block, controller, labels }) {
|
|
|
663
588
|
col
|
|
664
589
|
)) }, index);
|
|
665
590
|
const scroller = readOnly ? { role: "region", "aria-label": labels.table, tabIndex: 0 } : void 0;
|
|
666
|
-
return /* @__PURE__ */
|
|
667
|
-
/* @__PURE__ */
|
|
591
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { contentEditable: false, className: "quoin-table", "data-readonly": readOnly ? "" : void 0, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `quoin-table-scroll ${readOnly ? chunkQEMGOL5L_cjs.FOCUS_RING : ""}`, ...scroller, children: [
|
|
592
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
668
593
|
"table",
|
|
669
594
|
{
|
|
670
595
|
ref: table,
|
|
671
596
|
"aria-label": readOnly ? void 0 : labels.table,
|
|
672
597
|
style: widths === null ? void 0 : { width: widths.reduce((sum, width) => sum + width, 0), tableLayout: "fixed" },
|
|
673
598
|
children: [
|
|
674
|
-
widths !== null && /* @__PURE__ */
|
|
675
|
-
header && /* @__PURE__ */
|
|
676
|
-
rows > (header ? 1 : 0) && /* @__PURE__ */
|
|
599
|
+
widths !== null && /* @__PURE__ */ jsxRuntime.jsx("colgroup", { children: widths.map((width, col) => /* @__PURE__ */ jsxRuntime.jsx("col", { style: { width } }, col)) }),
|
|
600
|
+
header && /* @__PURE__ */ jsxRuntime.jsx("thead", { children: row(0) }),
|
|
601
|
+
rows > (header ? 1 : 0) && /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: indexes(header ? 1 : 0, rows).map(row) })
|
|
677
602
|
]
|
|
678
603
|
}
|
|
679
604
|
),
|
|
680
|
-
!readOnly && /* @__PURE__ */
|
|
605
|
+
!readOnly && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-table-controls", ...{ [CONTROLS_SLOT]: "" } })
|
|
681
606
|
] }) });
|
|
682
607
|
}
|
|
683
608
|
|
|
684
|
-
// src/extensions/table/TableControls.tsx
|
|
685
|
-
|
|
686
|
-
var _reactdom = require('react-dom');
|
|
687
|
-
|
|
688
609
|
// src/extensions/table/menu-cells.ts
|
|
689
610
|
var EMPTY = [];
|
|
690
611
|
function lineCells(block, index, axis) {
|
|
691
612
|
const { rows, cols } = tableShape(block);
|
|
692
613
|
return Array.from(
|
|
693
614
|
{ length: axis === "row" ? cols : rows },
|
|
694
|
-
(_, other) => axis === "row" ?
|
|
615
|
+
(_, other) => axis === "row" ? block.regions[chunkAIS37SL2_cjs.cellKey(index, other)] ?? EMPTY : block.regions[chunkAIS37SL2_cjs.cellKey(other, index)] ?? EMPTY
|
|
695
616
|
);
|
|
696
617
|
}
|
|
697
|
-
var sameLine = (before, after, index, axis) =>
|
|
618
|
+
var sameLine = (before, after, index, axis) => chunkAIS37SL2_cjs.sameItems(lineCells(before, index, axis), lineCells(after, index, axis), chunkAIS37SL2_cjs.equalInline);
|
|
698
619
|
function sameMenuCells(opened, current, target, axis) {
|
|
699
620
|
const shape = tableShape(opened);
|
|
700
621
|
const lines = axis === "row" ? shape.rows : shape.cols;
|
|
@@ -705,14 +626,6 @@ function sameMenuCells(opened, current, target, axis) {
|
|
|
705
626
|
const others = Array.from({ length: lines }, (_, other) => other);
|
|
706
627
|
return others.every((other) => other === index || sameLine(opened, current, other, axis));
|
|
707
628
|
}
|
|
708
|
-
|
|
709
|
-
// src/extensions/table/TableHandles.tsx
|
|
710
|
-
|
|
711
|
-
var _lucidereact = require('lucide-react');
|
|
712
|
-
|
|
713
|
-
// src/extensions/table/ColumnResizer.tsx
|
|
714
|
-
|
|
715
|
-
|
|
716
629
|
var MIN_COLUMN_WIDTH = 48;
|
|
717
630
|
var MAX_COLUMN_WIDTH = 1200;
|
|
718
631
|
var STEP = 10;
|
|
@@ -720,14 +633,14 @@ var LARGE_STEP = 50;
|
|
|
720
633
|
var clampWidth = (px) => Math.min(MAX_COLUMN_WIDTH, Math.max(MIN_COLUMN_WIDTH, Math.round(px)));
|
|
721
634
|
function ColumnResizer(props) {
|
|
722
635
|
const { controller, labels, blockId, col, drawn, style, resizerRef, onHold, onBack } = props;
|
|
723
|
-
const drag =
|
|
724
|
-
const width = Math.round(
|
|
636
|
+
const drag = react.useRef(null);
|
|
637
|
+
const width = Math.round(drawn[col] ?? 0);
|
|
725
638
|
const store = tableUiStore(controller);
|
|
726
639
|
const write = (px, widths) => {
|
|
727
640
|
if (!controller.readOnly) controller.run(setColumnWidth(blockId, col, px, widths));
|
|
728
641
|
};
|
|
729
642
|
const onKeyDown = (event) => {
|
|
730
|
-
if (
|
|
643
|
+
if (chunkACSEYJJF_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
731
644
|
const step = event.shiftKey ? LARGE_STEP : STEP;
|
|
732
645
|
const tab = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
733
646
|
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
@@ -740,7 +653,7 @@ function ColumnResizer(props) {
|
|
|
740
653
|
};
|
|
741
654
|
const onPointerDown = (event) => {
|
|
742
655
|
if (event.button !== 0) return;
|
|
743
|
-
|
|
656
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
744
657
|
drag.current = { x: event.clientX, widths: [...drawn], to: null };
|
|
745
658
|
onHold(true);
|
|
746
659
|
};
|
|
@@ -748,7 +661,7 @@ function ColumnResizer(props) {
|
|
|
748
661
|
const current = drag.current;
|
|
749
662
|
if (current === null) return;
|
|
750
663
|
current.to = clampWidth(current.widths[col] + event.clientX - current.x);
|
|
751
|
-
const widths = current.widths.map((px, i) => i === col ?
|
|
664
|
+
const widths = current.widths.map((px, i) => i === col ? current.to ?? px : px);
|
|
752
665
|
store.set({ preview: { block: blockId, widths } });
|
|
753
666
|
};
|
|
754
667
|
const stop = () => {
|
|
@@ -758,7 +671,7 @@ function ColumnResizer(props) {
|
|
|
758
671
|
onHold(false);
|
|
759
672
|
return current;
|
|
760
673
|
};
|
|
761
|
-
|
|
674
|
+
react.useEffect(
|
|
762
675
|
() => () => {
|
|
763
676
|
if (drag.current !== null) store.set({ preview: null });
|
|
764
677
|
},
|
|
@@ -766,9 +679,9 @@ function ColumnResizer(props) {
|
|
|
766
679
|
);
|
|
767
680
|
const end2 = () => {
|
|
768
681
|
const ended = stop();
|
|
769
|
-
if (
|
|
682
|
+
if (ended?.to != null && ended.to !== Math.round(ended.widths[col])) write(ended.to, ended.widths);
|
|
770
683
|
};
|
|
771
|
-
return /* @__PURE__ */
|
|
684
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
772
685
|
"div",
|
|
773
686
|
{
|
|
774
687
|
ref: resizerRef,
|
|
@@ -782,7 +695,7 @@ function ColumnResizer(props) {
|
|
|
782
695
|
"aria-valuetext": labels.columnWidth(width),
|
|
783
696
|
className: "quoin-table-resizer",
|
|
784
697
|
style,
|
|
785
|
-
...{ [
|
|
698
|
+
...{ [chunkACSEYJJF_cjs.NATIVE_INTERACTION]: "" },
|
|
786
699
|
onKeyDown,
|
|
787
700
|
onPointerDown,
|
|
788
701
|
onPointerMove,
|
|
@@ -791,31 +704,26 @@ function ColumnResizer(props) {
|
|
|
791
704
|
}
|
|
792
705
|
);
|
|
793
706
|
}
|
|
794
|
-
|
|
795
|
-
// src/extensions/table/HandleMenu.tsx
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
707
|
var DESTRUCTIVE = "text-destructive focus:text-destructive";
|
|
800
708
|
function HandleMenu({ controller, axis, label, style, items, open, onOpenChange, buttonRef, children }) {
|
|
801
709
|
const run = (item3) => {
|
|
802
710
|
if (controller.run(item3.command)) controller.announce(item3.done);
|
|
803
711
|
};
|
|
804
|
-
const item2 = (entry) => /* @__PURE__ */
|
|
805
|
-
|
|
712
|
+
const item2 = (entry) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
713
|
+
chunkQEMGOL5L_cjs.DropdownMenuItem,
|
|
806
714
|
{
|
|
807
715
|
disabled: entry.disabled,
|
|
808
716
|
className: entry.destructive ? DESTRUCTIVE : void 0,
|
|
809
717
|
onSelect: () => run(entry),
|
|
810
718
|
children: [
|
|
811
|
-
/* @__PURE__ */
|
|
719
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.MenuIcon, { icon: entry.icon }),
|
|
812
720
|
entry.label
|
|
813
721
|
]
|
|
814
722
|
},
|
|
815
723
|
entry.id
|
|
816
724
|
);
|
|
817
|
-
return /* @__PURE__ */
|
|
818
|
-
/* @__PURE__ */
|
|
725
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkQEMGOL5L_cjs.DropdownMenu, { open, onOpenChange, children: [
|
|
726
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
819
727
|
"button",
|
|
820
728
|
{
|
|
821
729
|
ref: buttonRef,
|
|
@@ -825,22 +733,22 @@ function HandleMenu({ controller, axis, label, style, items, open, onOpenChange,
|
|
|
825
733
|
"data-axis": axis,
|
|
826
734
|
className: "quoin-table-handle",
|
|
827
735
|
style,
|
|
828
|
-
children: axis === "row" ? /* @__PURE__ */
|
|
736
|
+
children: axis === "row" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GripVertical, { "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.GripHorizontal, { "aria-hidden": "true" })
|
|
829
737
|
}
|
|
830
738
|
) }),
|
|
831
|
-
open && /* @__PURE__ */
|
|
832
|
-
|
|
739
|
+
open && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
740
|
+
chunkQEMGOL5L_cjs.DropdownMenuContent,
|
|
833
741
|
{
|
|
834
742
|
align: "start",
|
|
835
743
|
"aria-label": label,
|
|
836
744
|
"aria-labelledby": void 0,
|
|
837
|
-
onCloseAutoFocus:
|
|
838
|
-
...
|
|
745
|
+
onCloseAutoFocus: chunkQEMGOL5L_cjs.returnFocusToText(controller),
|
|
746
|
+
...chunkQEMGOL5L_cjs.bubblePart(controller),
|
|
839
747
|
children: [
|
|
840
748
|
items.filter((entry) => !entry.destructive).map(item2),
|
|
841
749
|
children,
|
|
842
|
-
items.filter((entry) => entry.destructive).map((entry) => /* @__PURE__ */
|
|
843
|
-
/* @__PURE__ */
|
|
750
|
+
items.filter((entry) => entry.destructive).map((entry) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
751
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.DropdownMenuSeparator, {}),
|
|
844
752
|
item2(entry)
|
|
845
753
|
] }, entry.id))
|
|
846
754
|
]
|
|
@@ -848,55 +756,36 @@ function HandleMenu({ controller, axis, label, style, items, open, onOpenChange,
|
|
|
848
756
|
)
|
|
849
757
|
] });
|
|
850
758
|
}
|
|
851
|
-
|
|
852
|
-
// src/extensions/table/table-menu-items.ts
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
759
|
var item = (id, label, icon, command, done, options = {}) => ({ id, label, icon, command, done, ...options });
|
|
868
760
|
function rowMenuItems(labels, blockId, row, { rows }) {
|
|
869
761
|
const { rowInserted, rowMoved, rowDeleted } = labels;
|
|
870
762
|
return [
|
|
871
|
-
item("above", labels.insertRowAbove,
|
|
872
|
-
item("below", labels.insertRowBelow,
|
|
873
|
-
item("up", labels.moveRowUp,
|
|
874
|
-
item("down", labels.moveRowDown,
|
|
875
|
-
item("delete", labels.deleteRow,
|
|
763
|
+
item("above", labels.insertRowAbove, lucideReact.ArrowUpToLine, addRow(blockId, row), rowInserted),
|
|
764
|
+
item("below", labels.insertRowBelow, lucideReact.ArrowDownToLine, addRow(blockId, row + 1), rowInserted),
|
|
765
|
+
item("up", labels.moveRowUp, lucideReact.ArrowUp, moveRow(blockId, row, row - 1), rowMoved, { disabled: row === 0 }),
|
|
766
|
+
item("down", labels.moveRowDown, lucideReact.ArrowDown, moveRow(blockId, row, row + 1), rowMoved, { disabled: row === rows - 1 }),
|
|
767
|
+
item("delete", labels.deleteRow, lucideReact.Trash, removeRow(blockId, row), rowDeleted, { disabled: rows === 1, destructive: true })
|
|
876
768
|
];
|
|
877
769
|
}
|
|
878
770
|
function columnMenuItems(labels, blockId, col, { cols }) {
|
|
879
771
|
const { columnInserted, columnMoved, columnDeleted } = labels;
|
|
880
772
|
const last = col === cols - 1;
|
|
881
773
|
return [
|
|
882
|
-
item("left", labels.insertColumnLeft,
|
|
883
|
-
item("right", labels.insertColumnRight,
|
|
884
|
-
item("move-left", labels.moveColumnLeft,
|
|
885
|
-
item("move-right", labels.moveColumnRight,
|
|
886
|
-
item("delete", labels.deleteColumn,
|
|
774
|
+
item("left", labels.insertColumnLeft, lucideReact.ArrowLeftToLine, addColumn(blockId, col), columnInserted),
|
|
775
|
+
item("right", labels.insertColumnRight, lucideReact.ArrowRightToLine, addColumn(blockId, col + 1), columnInserted),
|
|
776
|
+
item("move-left", labels.moveColumnLeft, lucideReact.ArrowLeft, moveColumn(blockId, col, col - 1), columnMoved, { disabled: col === 0 }),
|
|
777
|
+
item("move-right", labels.moveColumnRight, lucideReact.ArrowRight, moveColumn(blockId, col, col + 1), columnMoved, { disabled: last }),
|
|
778
|
+
item("delete", labels.deleteColumn, lucideReact.Trash, removeColumn(blockId, col), columnDeleted, {
|
|
887
779
|
disabled: cols === 1,
|
|
888
780
|
destructive: true
|
|
889
781
|
})
|
|
890
782
|
];
|
|
891
783
|
}
|
|
892
784
|
var alignItems = (labels) => [
|
|
893
|
-
{ value: "left", label: labels.alignLeft, icon:
|
|
894
|
-
{ value: "center", label: labels.alignCenter, icon:
|
|
895
|
-
{ value: "right", label: labels.alignRight, icon:
|
|
785
|
+
{ value: "left", label: labels.alignLeft, icon: lucideReact.AlignLeft, done: labels.alignedLeft },
|
|
786
|
+
{ value: "center", label: labels.alignCenter, icon: lucideReact.AlignCenter, done: labels.alignedCenter },
|
|
787
|
+
{ value: "right", label: labels.alignRight, icon: lucideReact.AlignRight, done: labels.alignedRight }
|
|
896
788
|
];
|
|
897
|
-
|
|
898
|
-
// src/extensions/table/TableHandles.tsx
|
|
899
|
-
|
|
900
789
|
var BESIDE = 4;
|
|
901
790
|
var end = (span) => span.start + span.size;
|
|
902
791
|
function edgeOf(spans, edge) {
|
|
@@ -907,9 +796,9 @@ var middle = (span) => span.start + span.size / 2;
|
|
|
907
796
|
var isTab = (event) => event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
908
797
|
function TableHandles(props) {
|
|
909
798
|
const { controller, labels, block, target, geometry, menu, onMenu, onHold, focusRequested, onFocused } = props;
|
|
910
|
-
const rowHandle =
|
|
911
|
-
const columnHandle =
|
|
912
|
-
const resizer =
|
|
799
|
+
const rowHandle = react.useRef(null);
|
|
800
|
+
const columnHandle = react.useRef(null);
|
|
801
|
+
const resizer = react.useRef(null);
|
|
913
802
|
const shape = tableShape(block);
|
|
914
803
|
const row = Math.min(target.row, shape.rows - 1);
|
|
915
804
|
const col = Math.min(target.col, shape.cols - 1);
|
|
@@ -918,9 +807,9 @@ function TableHandles(props) {
|
|
|
918
807
|
const { rowEdge, colEdge } = target;
|
|
919
808
|
const rowInsertAt = edgeOf(geometry.rows, rowEdge);
|
|
920
809
|
const columnInsertAt = edgeOf(geometry.cols, colEdge);
|
|
921
|
-
|
|
810
|
+
chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
|
|
922
811
|
if (!focusRequested) return;
|
|
923
|
-
|
|
812
|
+
(columnHandle.current ?? rowHandle.current)?.focus();
|
|
924
813
|
onFocused();
|
|
925
814
|
}, [focusRequested, onFocused]);
|
|
926
815
|
const run = (command, done) => {
|
|
@@ -929,7 +818,7 @@ function TableHandles(props) {
|
|
|
929
818
|
const onKeyDown = (event) => {
|
|
930
819
|
const handles = [rowHandle.current, columnHandle.current].filter((handle) => handle !== null);
|
|
931
820
|
const index = handles.indexOf(event.target);
|
|
932
|
-
if (index === -1 ||
|
|
821
|
+
if (index === -1 || chunkACSEYJJF_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
933
822
|
if (event.key === "ArrowLeft" || event.key === "ArrowRight") handles[(index + 1) % handles.length].focus();
|
|
934
823
|
else if (isTab(event) && !event.shiftKey && resizer.current !== null) resizer.current.focus();
|
|
935
824
|
else if (isTab(event) || event.key === "Escape") controller.focus();
|
|
@@ -938,8 +827,8 @@ function TableHandles(props) {
|
|
|
938
827
|
};
|
|
939
828
|
const place = (left, top) => ({ left, top });
|
|
940
829
|
const opener = (kind) => (open) => onMenu(open ? kind : null);
|
|
941
|
-
return /* @__PURE__ */
|
|
942
|
-
geometry.cols.map((span, index) => /* @__PURE__ */
|
|
830
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
831
|
+
geometry.cols.map((span, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
943
832
|
ColumnResizer,
|
|
944
833
|
{
|
|
945
834
|
controller,
|
|
@@ -950,12 +839,12 @@ function TableHandles(props) {
|
|
|
950
839
|
style: { left: end(span), top: geometry.top, height: geometry.height },
|
|
951
840
|
resizerRef: index === col ? resizer : void 0,
|
|
952
841
|
onHold,
|
|
953
|
-
onBack: () =>
|
|
842
|
+
onBack: () => (columnHandle.current ?? rowHandle.current)?.focus()
|
|
954
843
|
},
|
|
955
844
|
index
|
|
956
845
|
)),
|
|
957
|
-
/* @__PURE__ */
|
|
958
|
-
rowInsertAt === null && geometry.rows[row] && /* @__PURE__ */
|
|
846
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { role: "toolbar", "aria-label": labels.tableControls, className: "quoin-table-toolbar", onKeyDown, children: [
|
|
847
|
+
rowInsertAt === null && geometry.rows[row] && /* @__PURE__ */ jsxRuntime.jsx(
|
|
959
848
|
HandleMenu,
|
|
960
849
|
{
|
|
961
850
|
controller,
|
|
@@ -966,8 +855,8 @@ function TableHandles(props) {
|
|
|
966
855
|
open: menu === "row",
|
|
967
856
|
onOpenChange: opener("row"),
|
|
968
857
|
buttonRef: rowHandle,
|
|
969
|
-
children: row === 0 && /* @__PURE__ */
|
|
970
|
-
|
|
858
|
+
children: row === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
859
|
+
chunkQEMGOL5L_cjs.DropdownMenuCheckboxItem,
|
|
971
860
|
{
|
|
972
861
|
checked: block.attrs.header !== false,
|
|
973
862
|
onCheckedChange: (on) => run(toggleHeaderRow(block.id), on ? labels.headerRowOn : labels.headerRowOff),
|
|
@@ -976,7 +865,7 @@ function TableHandles(props) {
|
|
|
976
865
|
)
|
|
977
866
|
}
|
|
978
867
|
),
|
|
979
|
-
columnInsertAt === null && geometry.cols[col] && /* @__PURE__ */
|
|
868
|
+
columnInsertAt === null && geometry.cols[col] && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
980
869
|
HandleMenu,
|
|
981
870
|
{
|
|
982
871
|
controller,
|
|
@@ -988,14 +877,14 @@ function TableHandles(props) {
|
|
|
988
877
|
onOpenChange: opener("column"),
|
|
989
878
|
buttonRef: columnHandle,
|
|
990
879
|
children: [
|
|
991
|
-
/* @__PURE__ */
|
|
992
|
-
/* @__PURE__ */
|
|
993
|
-
|
|
880
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.DropdownMenuSeparator, {}),
|
|
881
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.DropdownMenuRadioGroup, { value: align ?? "", children: alignItems(labels).map(({ value, label, icon, done }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
882
|
+
chunkQEMGOL5L_cjs.DropdownMenuRadioItem,
|
|
994
883
|
{
|
|
995
884
|
value,
|
|
996
885
|
onSelect: () => align === value ? run(setColumnAlign(block.id, col, null), labels.alignmentCleared) : run(setColumnAlign(block.id, col, value), done),
|
|
997
886
|
children: [
|
|
998
|
-
/* @__PURE__ */
|
|
887
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkQEMGOL5L_cjs.MenuIcon, { icon }),
|
|
999
888
|
label
|
|
1000
889
|
]
|
|
1001
890
|
},
|
|
@@ -1005,7 +894,7 @@ function TableHandles(props) {
|
|
|
1005
894
|
}
|
|
1006
895
|
)
|
|
1007
896
|
] }),
|
|
1008
|
-
rowEdge !== null && rowInsertAt !== null && /* @__PURE__ */
|
|
897
|
+
rowEdge !== null && rowInsertAt !== null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1009
898
|
"button",
|
|
1010
899
|
{
|
|
1011
900
|
type: "button",
|
|
@@ -1014,13 +903,13 @@ function TableHandles(props) {
|
|
|
1014
903
|
"data-axis": "row",
|
|
1015
904
|
className: "quoin-table-insert",
|
|
1016
905
|
style: place(geometry.left - BESIDE, rowInsertAt),
|
|
1017
|
-
onPointerDown:
|
|
1018
|
-
onMouseDown:
|
|
906
|
+
onPointerDown: chunkQEMGOL5L_cjs.keepFocus,
|
|
907
|
+
onMouseDown: chunkQEMGOL5L_cjs.keepFocus,
|
|
1019
908
|
onClick: () => run(addRow(block.id, rowEdge), labels.rowInserted),
|
|
1020
|
-
children: /* @__PURE__ */
|
|
909
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { "aria-hidden": "true" })
|
|
1021
910
|
}
|
|
1022
911
|
),
|
|
1023
|
-
colEdge !== null && columnInsertAt !== null && /* @__PURE__ */
|
|
912
|
+
colEdge !== null && columnInsertAt !== null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1024
913
|
"button",
|
|
1025
914
|
{
|
|
1026
915
|
type: "button",
|
|
@@ -1029,18 +918,15 @@ function TableHandles(props) {
|
|
|
1029
918
|
"data-axis": "column",
|
|
1030
919
|
className: "quoin-table-insert",
|
|
1031
920
|
style: place(columnInsertAt, geometry.top),
|
|
1032
|
-
onPointerDown:
|
|
1033
|
-
onMouseDown:
|
|
921
|
+
onPointerDown: chunkQEMGOL5L_cjs.keepFocus,
|
|
922
|
+
onMouseDown: chunkQEMGOL5L_cjs.keepFocus,
|
|
1034
923
|
onClick: () => run(addColumn(block.id, colEdge), labels.columnInserted),
|
|
1035
|
-
children: /* @__PURE__ */
|
|
924
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { "aria-hidden": "true" })
|
|
1036
925
|
}
|
|
1037
926
|
)
|
|
1038
927
|
] });
|
|
1039
928
|
}
|
|
1040
929
|
|
|
1041
|
-
// src/extensions/table/use-table-geometry.ts
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
930
|
// src/extensions/table/table-geometry.ts
|
|
1045
931
|
function measureTable(table, origin) {
|
|
1046
932
|
const box = table.getBoundingClientRect();
|
|
@@ -1054,7 +940,7 @@ function measureTable(table, origin) {
|
|
|
1054
940
|
const rect = row.getBoundingClientRect();
|
|
1055
941
|
return { start: rect.top - origin.top, size: rect.height };
|
|
1056
942
|
}),
|
|
1057
|
-
cols: Array.from(
|
|
943
|
+
cols: Array.from(first?.cells ?? [], (cell) => {
|
|
1058
944
|
const rect = cell.getBoundingClientRect();
|
|
1059
945
|
return { start: rect.left - origin.left, size: rect.width };
|
|
1060
946
|
})
|
|
@@ -1075,9 +961,9 @@ function edgeNear(spans, at, reach) {
|
|
|
1075
961
|
|
|
1076
962
|
// src/extensions/table/use-table-geometry.ts
|
|
1077
963
|
function useTableGeometry(controller, blockId, slot) {
|
|
1078
|
-
const [geometry, setGeometry] =
|
|
1079
|
-
|
|
1080
|
-
const table =
|
|
964
|
+
const [geometry, setGeometry] = react.useState(null);
|
|
965
|
+
chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
|
|
966
|
+
const table = controller.blockElement(blockId)?.querySelector("table");
|
|
1081
967
|
const view = slot.ownerDocument.defaultView;
|
|
1082
968
|
if (!table || !view) return;
|
|
1083
969
|
const measure = () => {
|
|
@@ -1103,26 +989,20 @@ function useTableGeometry(controller, blockId, slot) {
|
|
|
1103
989
|
}, [controller, blockId, slot]);
|
|
1104
990
|
return geometry;
|
|
1105
991
|
}
|
|
1106
|
-
|
|
1107
|
-
// src/extensions/table/use-cut-cells.ts
|
|
1108
|
-
|
|
1109
992
|
function useCutCells(controller) {
|
|
1110
|
-
|
|
993
|
+
react.useEffect(() => {
|
|
1111
994
|
const root = controller.root;
|
|
1112
995
|
if (root === null) return;
|
|
1113
996
|
const onCut = (event) => {
|
|
1114
997
|
if (controller.readOnly || cellSelection(controller.editor.state) === null) return;
|
|
1115
998
|
event.stopPropagation();
|
|
1116
|
-
|
|
999
|
+
chunkACSEYJJF_cjs.handleCopy(controller, event, false);
|
|
1117
1000
|
controller.run(deleteCellContents);
|
|
1118
1001
|
};
|
|
1119
1002
|
root.addEventListener("cut", onCut, true);
|
|
1120
1003
|
return () => root.removeEventListener("cut", onCut, true);
|
|
1121
1004
|
}, [controller]);
|
|
1122
1005
|
}
|
|
1123
|
-
|
|
1124
|
-
// src/extensions/table/use-table-target.ts
|
|
1125
|
-
|
|
1126
1006
|
var EDGE_ZONE = 24;
|
|
1127
1007
|
var EDGE_REACH = 8;
|
|
1128
1008
|
var VIEWPORT = { left: 0, top: 0 };
|
|
@@ -1135,7 +1015,7 @@ function caretTarget(state) {
|
|
|
1135
1015
|
function pointerTarget(controller, event) {
|
|
1136
1016
|
const blockId = controller.blockAt(event.target);
|
|
1137
1017
|
const block = blockId === void 0 ? null : tableBlock(controller.editor.state.doc, blockId);
|
|
1138
|
-
const table = block &&
|
|
1018
|
+
const table = block && controller.blockElement(block.id)?.querySelector("table");
|
|
1139
1019
|
if (!block || !table) return null;
|
|
1140
1020
|
const geometry = measureTable(table, VIEWPORT);
|
|
1141
1021
|
const { clientX: x, clientY: y } = event;
|
|
@@ -1158,16 +1038,16 @@ function focusOf(root) {
|
|
|
1158
1038
|
return active.closest(CONTROLS) === null ? "editor" : "controls";
|
|
1159
1039
|
}
|
|
1160
1040
|
function useTableTarget(controller, held) {
|
|
1161
|
-
const [hovered, setHovered] =
|
|
1162
|
-
const [focus, setFocus] =
|
|
1163
|
-
const caret =
|
|
1164
|
-
const hoveredBlock =
|
|
1165
|
-
const shape =
|
|
1041
|
+
const [hovered, setHovered] = react.useState(null);
|
|
1042
|
+
const [focus, setFocus] = react.useState("none");
|
|
1043
|
+
const caret = chunkACSEYJJF_cjs.useEditorState(controller, caretTarget, sameTarget);
|
|
1044
|
+
const hoveredBlock = hovered?.target.block ?? null;
|
|
1045
|
+
const shape = chunkACSEYJJF_cjs.useEditorState(
|
|
1166
1046
|
controller,
|
|
1167
|
-
|
|
1047
|
+
react.useCallback((state) => hoveredBlock === null ? null : shapeOf(state, hoveredBlock), [hoveredBlock])
|
|
1168
1048
|
);
|
|
1169
1049
|
const pointed = hovered !== null && hovered.shape === shape ? hovered.target : null;
|
|
1170
|
-
|
|
1050
|
+
react.useEffect(() => {
|
|
1171
1051
|
const root = controller.root;
|
|
1172
1052
|
if (root === null) return;
|
|
1173
1053
|
const onPointerMove = (event) => {
|
|
@@ -1197,63 +1077,60 @@ function useTableTarget(controller, held) {
|
|
|
1197
1077
|
};
|
|
1198
1078
|
}, [controller]);
|
|
1199
1079
|
if (held !== null) return held;
|
|
1200
|
-
if (focus === "controls") return
|
|
1201
|
-
return
|
|
1080
|
+
if (focus === "controls") return caret ?? pointed;
|
|
1081
|
+
return pointed ?? (focus === "editor" ? caret : null);
|
|
1202
1082
|
}
|
|
1203
|
-
|
|
1204
|
-
// src/extensions/table/TableControls.tsx
|
|
1205
|
-
|
|
1206
1083
|
var isFocusKey = (event) => event.key === "F10" && event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
1207
|
-
var takesFocusKey = (state) =>
|
|
1084
|
+
var takesFocusKey = (state) => chunkVFSVN5IQ_cjs.isCollapsed(state.selection) || cellSelection(state) !== null;
|
|
1208
1085
|
function TableControls({ controller, labels }) {
|
|
1209
|
-
const readOnly =
|
|
1210
|
-
const [held, setHeld] =
|
|
1211
|
-
const [focusFor, setFocusFor] =
|
|
1212
|
-
const [slot, setSlot] =
|
|
1213
|
-
const target = useTableTarget(controller,
|
|
1086
|
+
const readOnly = chunkACSEYJJF_cjs.useReadOnly(controller);
|
|
1087
|
+
const [held, setHeld] = react.useState(null);
|
|
1088
|
+
const [focusFor, setFocusFor] = react.useState(null);
|
|
1089
|
+
const [slot, setSlot] = react.useState(null);
|
|
1090
|
+
const target = useTableTarget(controller, held?.target ?? null);
|
|
1214
1091
|
useCutCells(controller);
|
|
1215
|
-
const blockId =
|
|
1216
|
-
const block =
|
|
1092
|
+
const blockId = target?.block ?? null;
|
|
1093
|
+
const block = chunkACSEYJJF_cjs.useEditorState(
|
|
1217
1094
|
controller,
|
|
1218
|
-
|
|
1095
|
+
react.useCallback((state) => blockId === null ? null : tableBlock(state.doc, blockId), [blockId])
|
|
1219
1096
|
);
|
|
1220
|
-
if (
|
|
1097
|
+
if (held?.menu && held.opened && block && held.opened !== block) {
|
|
1221
1098
|
setHeld(sameMenuCells(held.opened, block, held.target, held.menu) ? { ...held, opened: block } : null);
|
|
1222
1099
|
}
|
|
1223
|
-
|
|
1100
|
+
react.useEffect(() => {
|
|
1224
1101
|
if (!readOnly && block !== null) return;
|
|
1225
1102
|
setHeld(null);
|
|
1226
1103
|
setFocusFor(null);
|
|
1227
1104
|
}, [readOnly, block]);
|
|
1228
|
-
|
|
1105
|
+
react.useEffect(() => {
|
|
1229
1106
|
if (readOnly) return;
|
|
1230
1107
|
const intercept = (event) => {
|
|
1231
1108
|
const { state } = controller.editor;
|
|
1232
1109
|
const caret = caretTarget(state);
|
|
1233
|
-
if (!isFocusKey(event) ||
|
|
1110
|
+
if (!isFocusKey(event) || chunkACSEYJJF_cjs.isComposingKey(controller, event) || caret === null || !takesFocusKey(state)) return false;
|
|
1234
1111
|
event.preventDefault();
|
|
1235
1112
|
setHeld({ target: caret, menu: null });
|
|
1236
1113
|
setFocusFor(caret.block);
|
|
1237
1114
|
return true;
|
|
1238
1115
|
};
|
|
1239
|
-
return
|
|
1116
|
+
return chunkQEMGOL5L_cjs.interceptKeys(controller, intercept);
|
|
1240
1117
|
}, [controller, readOnly]);
|
|
1241
|
-
const onMenu =
|
|
1118
|
+
const onMenu = react.useCallback(
|
|
1242
1119
|
(menu) => setHeld(menu === null || target === null || block === null ? null : { target, menu, opened: block }),
|
|
1243
1120
|
[target, block]
|
|
1244
1121
|
);
|
|
1245
|
-
const onHold =
|
|
1246
|
-
const onFocused =
|
|
1122
|
+
const onHold = react.useCallback((hold) => setHeld(hold && target !== null ? { target, menu: null } : null), [target]);
|
|
1123
|
+
const onFocused = react.useCallback(() => {
|
|
1247
1124
|
setFocusFor(null);
|
|
1248
|
-
setHeld((current) =>
|
|
1125
|
+
setHeld((current) => current?.menu === null ? null : current);
|
|
1249
1126
|
}, []);
|
|
1250
|
-
|
|
1127
|
+
chunkACSEYJJF_cjs.useIsomorphicLayoutEffect(() => {
|
|
1251
1128
|
const drawn = block === null || readOnly ? null : controlsSlot(controller, block.id);
|
|
1252
1129
|
setSlot((current) => current === drawn ? current : drawn);
|
|
1253
1130
|
});
|
|
1254
1131
|
if (target === null || block === null || readOnly || slot === null || !slot.isConnected) return null;
|
|
1255
|
-
return
|
|
1256
|
-
/* @__PURE__ */
|
|
1132
|
+
return reactDom.createPortal(
|
|
1133
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1257
1134
|
PlacedHandles,
|
|
1258
1135
|
{
|
|
1259
1136
|
controller,
|
|
@@ -1261,7 +1138,7 @@ function TableControls({ controller, labels }) {
|
|
|
1261
1138
|
block,
|
|
1262
1139
|
target,
|
|
1263
1140
|
slot,
|
|
1264
|
-
menu:
|
|
1141
|
+
menu: held?.menu ?? null,
|
|
1265
1142
|
onMenu,
|
|
1266
1143
|
onHold,
|
|
1267
1144
|
focusRequested: focusFor === block.id,
|
|
@@ -1274,7 +1151,7 @@ function TableControls({ controller, labels }) {
|
|
|
1274
1151
|
}
|
|
1275
1152
|
function PlacedHandles({ slot, ...props }) {
|
|
1276
1153
|
const geometry = useTableGeometry(props.controller, props.block.id, slot);
|
|
1277
|
-
return geometry === null ? null : /* @__PURE__ */
|
|
1154
|
+
return geometry === null ? null : /* @__PURE__ */ jsxRuntime.jsx(TableHandles, { ...props, geometry });
|
|
1278
1155
|
}
|
|
1279
1156
|
|
|
1280
1157
|
// src/extensions/table/table-labels.ts
|
|
@@ -1317,25 +1194,19 @@ var englishTableLabels = {
|
|
|
1317
1194
|
alignmentCleared: "Column alignment cleared"
|
|
1318
1195
|
};
|
|
1319
1196
|
function resolveTableLabels(overrides) {
|
|
1320
|
-
const given = Object.entries(
|
|
1197
|
+
const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
|
|
1321
1198
|
return given.length === 0 ? englishTableLabels : { ...englishTableLabels, ...Object.fromEntries(given) };
|
|
1322
1199
|
}
|
|
1323
|
-
|
|
1324
|
-
// src/extensions/table/table-slash-item.ts
|
|
1325
|
-
|
|
1326
1200
|
var NEW_TABLE = { rows: 3, cols: 3 };
|
|
1327
1201
|
var tableSlashItem = (labels) => ({
|
|
1328
1202
|
id: "table",
|
|
1329
1203
|
title: labels.table,
|
|
1330
1204
|
description: labels.tableDescription,
|
|
1331
1205
|
group: "advanced",
|
|
1332
|
-
icon:
|
|
1206
|
+
icon: lucideReact.Table,
|
|
1333
1207
|
keywords: ["grid", "rows", "columns", "spreadsheet", "|"],
|
|
1334
1208
|
command: () => insertTable(NEW_TABLE.rows, NEW_TABLE.cols)
|
|
1335
1209
|
});
|
|
1336
|
-
|
|
1337
|
-
// src/extensions/table/table-extension.tsx
|
|
1338
|
-
|
|
1339
1210
|
var ABOVE_CORE_KEYS = 200;
|
|
1340
1211
|
var pasteOverCells = {
|
|
1341
1212
|
name: "table-cells",
|
|
@@ -1343,15 +1214,15 @@ var pasteOverCells = {
|
|
|
1343
1214
|
};
|
|
1344
1215
|
function tableExtension(options = {}) {
|
|
1345
1216
|
const labels = resolveTableLabels(options.labels);
|
|
1346
|
-
const TableRenderer = (props) => /* @__PURE__ */
|
|
1347
|
-
const TableOverlay = ({ controller }) => /* @__PURE__ */
|
|
1217
|
+
const TableRenderer = (props) => /* @__PURE__ */ jsxRuntime.jsx(TableBlock, { ...props, labels });
|
|
1218
|
+
const TableOverlay = ({ controller }) => /* @__PURE__ */ jsxRuntime.jsx(TableControls, { controller, labels });
|
|
1348
1219
|
const ui = {
|
|
1349
1220
|
slashItems: [tableSlashItem(labels)],
|
|
1350
1221
|
renderers: { TABLE: TableRenderer },
|
|
1351
1222
|
blockNames: { TABLE: labels.table },
|
|
1352
1223
|
overlays: [TableOverlay]
|
|
1353
1224
|
};
|
|
1354
|
-
return
|
|
1225
|
+
return chunkVFSVN5IQ_cjs.defineExtension({
|
|
1355
1226
|
name: "table",
|
|
1356
1227
|
priority: ABOVE_CORE_KEYS,
|
|
1357
1228
|
plugins: [cellSelectionPlugin],
|
|
@@ -1361,25 +1232,24 @@ function tableExtension(options = {}) {
|
|
|
1361
1232
|
});
|
|
1362
1233
|
}
|
|
1363
1234
|
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
//# sourceMappingURL=chunk-5MAYUGTE.cjs.map
|
|
1235
|
+
exports.addColumn = addColumn;
|
|
1236
|
+
exports.addRow = addRow;
|
|
1237
|
+
exports.cellSelection = cellSelection;
|
|
1238
|
+
exports.cellSelectionKey = cellSelectionKey;
|
|
1239
|
+
exports.cellSelectionPlugin = cellSelectionPlugin;
|
|
1240
|
+
exports.cellsInRange = cellsInRange;
|
|
1241
|
+
exports.deleteCellContents = deleteCellContents;
|
|
1242
|
+
exports.englishTableLabels = englishTableLabels;
|
|
1243
|
+
exports.insertTable = insertTable;
|
|
1244
|
+
exports.moveColumn = moveColumn;
|
|
1245
|
+
exports.moveRow = moveRow;
|
|
1246
|
+
exports.removeColumn = removeColumn;
|
|
1247
|
+
exports.removeRow = removeRow;
|
|
1248
|
+
exports.selectCells = selectCells;
|
|
1249
|
+
exports.setCellsMark = setCellsMark;
|
|
1250
|
+
exports.setColumnAlign = setColumnAlign;
|
|
1251
|
+
exports.setColumnWidth = setColumnWidth;
|
|
1252
|
+
exports.tableExtension = tableExtension;
|
|
1253
|
+
exports.toggleHeaderRow = toggleHeaderRow;
|
|
1254
|
+
//# sourceMappingURL=chunk-LY2D45F2.cjs.map
|
|
1255
|
+
//# sourceMappingURL=chunk-LY2D45F2.cjs.map
|