quoin-editor 1.6.0 → 1.8.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 +16 -0
- package/README.md +27 -11
- package/dist/ai-labels-BXX32H9a.d.cts +53 -0
- package/dist/ai-labels-BXX32H9a.d.ts +53 -0
- package/dist/ai.cjs +84 -86
- package/dist/ai.d.cts +4 -53
- package/dist/ai.d.ts +4 -53
- package/dist/ai.js +8 -10
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +27 -24
- package/dist/catalogue.d.cts +12 -1
- package/dist/catalogue.d.ts +12 -1
- package/dist/catalogue.js +19 -16
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-QR2NIDUK.cjs → chunk-4MCYQHFL.cjs} +2 -2
- package/dist/{chunk-XFR7QGSN.cjs → chunk-53CNYRVQ.cjs} +92 -94
- package/dist/{chunk-T7O3BROK.cjs → chunk-53FJFYBR.cjs} +115 -117
- package/dist/{chunk-KFYJW7W5.js → chunk-5OZX2LV4.js} +10 -12
- package/dist/chunk-5OZX2LV4.js.map +1 -0
- package/dist/{chunk-OS2O6IKX.js → chunk-5RBMZGKV.js} +4 -4
- package/dist/{chunk-OS2O6IKX.js.map → chunk-5RBMZGKV.js.map} +1 -1
- package/dist/{chunk-4T4TJ2QS.cjs → chunk-7E43TURF.cjs} +7 -7
- package/dist/{chunk-L6RB43YM.cjs → chunk-7X3T7VXV.cjs} +32 -34
- package/dist/{chunk-BJTOLCRR.js → chunk-7Y4B7NHO.js} +2 -2
- package/dist/chunk-7Y4B7NHO.js.map +1 -0
- package/dist/{chunk-LOP66FVU.cjs → chunk-B3OBM6I4.cjs} +25 -27
- package/dist/{chunk-UUSZGUXJ.cjs → chunk-BA5WXBGE.cjs} +291 -293
- package/dist/{chunk-CSKKSXCE.js → chunk-CSPCDVCT.js} +3 -3
- package/dist/{chunk-CSKKSXCE.js.map → chunk-CSPCDVCT.js.map} +1 -1
- package/dist/{chunk-R7MYG522.js → chunk-D4L5FINK.js} +3 -3
- package/dist/{chunk-R7MYG522.js.map → chunk-D4L5FINK.js.map} +1 -1
- package/dist/{chunk-GHNQKJMD.js → chunk-DBOZFNWU.js} +3 -3
- package/dist/{chunk-GHNQKJMD.js.map → chunk-DBOZFNWU.js.map} +1 -1
- package/dist/{chunk-BM2GRZNM.cjs → chunk-DJU25PFC.cjs} +11 -11
- package/dist/chunk-DLQCTGC3.js +10 -0
- package/dist/chunk-DLQCTGC3.js.map +1 -0
- package/dist/{chunk-B5OMWOVI.js → chunk-DXUDBPG5.js} +9 -11
- package/dist/chunk-DXUDBPG5.js.map +1 -0
- package/dist/{chunk-TKCPXUPP.cjs → chunk-EZWJRBQT.cjs} +51 -53
- package/dist/{chunk-N2SCDXTI.js → chunk-EZX37R5D.js} +8 -10
- package/dist/chunk-EZX37R5D.js.map +1 -0
- package/dist/{chunk-VZZPCYA3.cjs → chunk-FK7EBZPX.cjs} +226 -226
- package/dist/{chunk-BXSWZEA5.js → chunk-GPTJYWGS.js} +3 -3
- package/dist/{chunk-BXSWZEA5.js.map → chunk-GPTJYWGS.js.map} +1 -1
- package/dist/{chunk-H3C3MJW5.cjs → chunk-LM3DHROX.cjs} +2 -2
- package/dist/{chunk-AD3NY7NA.js → chunk-LSI4RMTY.js} +3 -3
- package/dist/{chunk-AD3NY7NA.js.map → chunk-LSI4RMTY.js.map} +1 -1
- package/dist/chunk-MMS4D4MK.cjs +87 -0
- package/dist/{chunk-HT7OF52E.js → chunk-MRHDPXQ7.js} +8 -10
- package/dist/chunk-MRHDPXQ7.js.map +1 -0
- package/dist/{chunk-XFEDJEJF.js → chunk-MSWA5ZZM.js} +4 -4
- package/dist/{chunk-XFEDJEJF.js.map → chunk-MSWA5ZZM.js.map} +1 -1
- package/dist/chunk-NCDMQCZR.js +85 -0
- package/dist/chunk-NCDMQCZR.js.map +1 -0
- package/dist/{chunk-QJ34MOFV.cjs → chunk-P6HC7RUN.cjs} +120 -120
- package/dist/{chunk-O7XZFXPE.js → chunk-PHQMHXNG.js} +9 -11
- package/dist/chunk-PHQMHXNG.js.map +1 -0
- package/dist/{chunk-WN7BZDNH.cjs → chunk-PURYVDC3.cjs} +13 -13
- package/dist/{chunk-46JH34SR.cjs → chunk-PVFSJXYQ.cjs} +28 -30
- package/dist/{chunk-QOIVLYMW.js → chunk-SP4F5F6V.js} +5 -5
- package/dist/{chunk-QOIVLYMW.js.map → chunk-SP4F5F6V.js.map} +1 -1
- package/dist/{chunk-JVSYEENH.cjs → chunk-TQHFGSTT.cjs} +57 -59
- package/dist/{chunk-G25FMFEZ.js → chunk-UDBLZILE.js} +4 -4
- package/dist/{chunk-G25FMFEZ.js.map → chunk-UDBLZILE.js.map} +1 -1
- package/dist/{chunk-2AVGGPLT.js → chunk-VM567D6O.js} +8 -10
- package/dist/chunk-VM567D6O.js.map +1 -0
- package/dist/{chunk-KF3KKN4N.js → chunk-VWYPO6SX.js} +8 -10
- package/dist/chunk-VWYPO6SX.js.map +1 -0
- package/dist/{chunk-IJKGF6SC.js → chunk-WOGCD7JN.js} +8 -10
- package/dist/chunk-WOGCD7JN.js.map +1 -0
- package/dist/{chunk-AZF7B2AE.cjs → chunk-XKYNINUX.cjs} +11 -11
- package/dist/{chunk-32OZ2WM2.js → chunk-Y4EJ6UBV.js} +8 -11
- package/dist/chunk-Y4EJ6UBV.js.map +1 -0
- package/dist/{chunk-XZ4NC3Q7.cjs → chunk-YEDPBYO5.cjs} +4 -4
- package/dist/{chunk-STKGRXSA.cjs → chunk-YVPZDTVZ.cjs} +15 -17
- package/dist/chunk-ZWTIRGY5.cjs +10 -0
- package/dist/comments-labels-DWqsSz8G.d.cts +30 -0
- package/dist/comments-labels-DWqsSz8G.d.ts +30 -0
- package/dist/comments.cjs +63 -65
- package/dist/comments.d.cts +4 -30
- package/dist/comments.d.ts +4 -30
- package/dist/comments.js +9 -11
- package/dist/comments.js.map +1 -1
- package/dist/diagram-extension-22x_njXB.d.ts +30 -0
- package/dist/diagram-extension-C_FSkoj9.d.cts +30 -0
- package/dist/diagram-labels-Bi_jEZ8_.d.cts +11 -0
- package/dist/diagram-labels-Bi_jEZ8_.d.ts +11 -0
- package/dist/diagram.cjs +26 -0
- package/dist/diagram.d.cts +9 -0
- package/dist/diagram.d.ts +9 -0
- package/dist/diagram.js +11 -0
- package/dist/diagram.js.map +1 -0
- package/dist/diff-labels-DWwg7N0n.d.cts +27 -0
- package/dist/diff-labels-DWwg7N0n.d.ts +27 -0
- package/dist/diff.cjs +27 -29
- package/dist/diff.d.cts +4 -27
- package/dist/diff.d.ts +4 -27
- package/dist/diff.js +5 -7
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +30 -30
- package/dist/docx.js +3 -3
- package/dist/embed-labels-BiVa9HYl.d.cts +23 -0
- package/dist/embed-labels-BiVa9HYl.d.ts +23 -0
- package/dist/embed.cjs +10 -9
- package/dist/embed.d.cts +4 -23
- package/dist/embed.d.ts +4 -23
- package/dist/embed.js +8 -7
- package/dist/emoji-extension-C832oGeT.d.ts +16 -0
- package/dist/emoji-extension-Dk5IQLZf.d.cts +16 -0
- package/dist/{emoji-extension-gRKnbW8G.d.ts → emoji-labels-YwOms7ZJ.d.cts} +2 -15
- package/dist/{emoji-extension-C3o_Y5uC.d.cts → emoji-labels-YwOms7ZJ.d.ts} +2 -15
- package/dist/emoji.cjs +10 -9
- package/dist/emoji.d.cts +4 -3
- package/dist/emoji.d.ts +4 -3
- package/dist/emoji.js +7 -6
- package/dist/engine.cjs +58 -58
- package/dist/engine.d.cts +8 -7
- package/dist/engine.d.ts +8 -7
- package/dist/engine.js +3 -3
- package/dist/find-extension-BfruAPLi.d.cts +15 -0
- package/dist/find-extension-DmK9_N81.d.ts +15 -0
- package/dist/{find-extension-B_Ctrs6T.d.ts → find-labels-C4vs8Qe9.d.cts} +2 -14
- package/dist/{find-extension-BGGsJMu4.d.cts → find-labels-C4vs8Qe9.d.ts} +2 -14
- package/dist/find.cjs +11 -10
- package/dist/find.d.cts +2 -1
- package/dist/find.d.ts +2 -1
- package/dist/find.js +7 -6
- package/dist/headless.cjs +74 -74
- package/dist/headless.d.cts +38 -8
- package/dist/headless.d.ts +38 -8
- package/dist/headless.js +4 -4
- package/dist/highlight.cjs +7 -6
- package/dist/highlight.js +6 -5
- package/dist/highlight.js.map +1 -1
- package/dist/{index-CsG7OQoq.d.cts → index-3fYvwqUZ.d.cts} +1 -1
- package/dist/{index-h1llgZM-.d.ts → index-CgxnzCO5.d.ts} +1 -1
- package/dist/index.cjs +87 -86
- package/dist/index.d.cts +18 -185
- package/dist/index.d.ts +18 -185
- package/dist/index.js +6 -5
- package/dist/labels-BhRJYo46.d.ts +176 -0
- package/dist/labels-CiCxj2jP.d.cts +176 -0
- package/dist/locale-ar.cjs +565 -0
- package/dist/locale-ar.d.cts +63 -0
- package/dist/locale-ar.d.ts +63 -0
- package/dist/locale-ar.js +551 -0
- package/dist/locale-ar.js.map +1 -0
- package/dist/locale-de.cjs +510 -0
- package/dist/locale-de.d.cts +63 -0
- package/dist/locale-de.d.ts +63 -0
- package/dist/locale-de.js +496 -0
- package/dist/locale-de.js.map +1 -0
- package/dist/locale-es.cjs +510 -0
- package/dist/locale-es.d.cts +63 -0
- package/dist/locale-es.d.ts +63 -0
- package/dist/locale-es.js +496 -0
- package/dist/locale-es.js.map +1 -0
- package/dist/locale-fr.cjs +510 -0
- package/dist/locale-fr.d.cts +63 -0
- package/dist/locale-fr.d.ts +63 -0
- package/dist/locale-fr.js +496 -0
- package/dist/locale-fr.js.map +1 -0
- package/dist/locale-ja.cjs +505 -0
- package/dist/locale-ja.d.cts +63 -0
- package/dist/locale-ja.d.ts +63 -0
- package/dist/locale-ja.js +491 -0
- package/dist/locale-ja.js.map +1 -0
- package/dist/locale-pt.cjs +511 -0
- package/dist/locale-pt.d.cts +63 -0
- package/dist/locale-pt.d.ts +63 -0
- package/dist/locale-pt.js +497 -0
- package/dist/locale-pt.js.map +1 -0
- package/dist/locale-zh.cjs +505 -0
- package/dist/locale-zh.d.cts +63 -0
- package/dist/locale-zh.d.ts +63 -0
- package/dist/locale-zh.js +491 -0
- package/dist/locale-zh.js.map +1 -0
- package/dist/math-labels-DOf5KFxp.d.cts +24 -0
- package/dist/math-labels-DOf5KFxp.d.ts +24 -0
- package/dist/math.cjs +11 -10
- package/dist/math.d.cts +4 -24
- package/dist/math.d.ts +4 -24
- package/dist/math.js +9 -8
- package/dist/mention-labels-DIQy8LRT.d.cts +15 -0
- package/dist/mention-labels-DIQy8LRT.d.ts +15 -0
- package/dist/mention.cjs +11 -10
- package/dist/mention.d.cts +4 -15
- package/dist/mention.d.ts +4 -15
- package/dist/mention.js +9 -8
- package/dist/{view-controller-p-2x3J7Y.d.ts → node-reveal-BnFcnHhz.d.ts} +14 -14
- package/dist/{view-controller-BfVSNZYZ.d.cts → node-reveal-DY6bimv3.d.cts} +14 -14
- package/dist/palette-BrX-hEd-.d.cts +4 -0
- package/dist/palette-BrX-hEd-.d.ts +4 -0
- package/dist/presence-labels-DXVJLifl.d.cts +15 -0
- package/dist/presence-labels-DXVJLifl.d.ts +15 -0
- package/dist/presence.cjs +40 -42
- package/dist/presence.d.cts +4 -15
- package/dist/presence.d.ts +4 -15
- package/dist/presence.js +9 -11
- package/dist/presence.js.map +1 -1
- package/dist/source-labels-CeQDXsYZ.d.cts +9 -0
- package/dist/source-labels-CeQDXsYZ.d.ts +9 -0
- package/dist/source.cjs +11 -14
- package/dist/source.d.cts +5 -10
- package/dist/source.d.ts +5 -10
- package/dist/source.js +7 -10
- package/dist/source.js.map +1 -1
- package/dist/{stats-extension-oD6D1cYy.d.ts → stats-extension-D5HySF0a.d.cts} +4 -16
- package/dist/{stats-extension-XqOTvRaq.d.cts → stats-extension-Dmw0Ujxe.d.ts} +4 -16
- package/dist/stats-labels-W8gep51s.d.cts +15 -0
- package/dist/stats-labels-W8gep51s.d.ts +15 -0
- package/dist/stats.cjs +11 -10
- package/dist/stats.d.cts +3 -2
- package/dist/stats.d.ts +3 -2
- package/dist/stats.js +8 -7
- package/dist/styles.css +1 -1
- package/dist/table-extension-7LkLNK6Q.d.cts +15 -0
- package/dist/table-extension-DEpV0DnP.d.ts +15 -0
- package/dist/{table-extension-v6VB59bF.d.ts → table-labels-Dc-MzU3j.d.cts} +2 -14
- package/dist/{table-extension-BP47hHoz.d.cts → table-labels-Dc-MzU3j.d.ts} +2 -14
- package/dist/table.cjs +26 -25
- package/dist/table.d.cts +2 -1
- package/dist/table.d.ts +2 -1
- package/dist/table.js +7 -6
- package/dist/{to-html-1oD-CDle.d.cts → to-html-C19PbIzh.d.cts} +1 -0
- package/dist/{to-html-CLRBCX0I.d.ts → to-html-CogwrQer.d.ts} +1 -0
- package/dist/{to-markdown-CFPMbbiX.d.cts → to-markdown-C2w7Dzg8.d.cts} +1 -0
- package/dist/{to-markdown-BVOzhgVM.d.ts → to-markdown-DC1EUye5.d.ts} +1 -0
- package/dist/toc-extension-Dvh37bWQ.d.cts +15 -0
- package/dist/toc-extension-SVckrFmb.d.ts +15 -0
- package/dist/toc-labels-B2apPfXG.d.cts +14 -0
- package/dist/toc-labels-B2apPfXG.d.ts +14 -0
- package/dist/toc.cjs +10 -9
- package/dist/toc.d.cts +3 -2
- package/dist/toc.d.ts +3 -2
- package/dist/toc.js +7 -6
- package/dist/{types-DXF9p4qV.d.cts → types-Bzhq5AXj.d.cts} +1 -0
- package/dist/{types-BjLcmV00.d.ts → types-DMuuDBVh.d.ts} +1 -0
- package/dist/view.cjs +4 -4
- package/dist/view.js +2 -2
- package/dist/yjs.cjs +121 -121
- package/dist/yjs.d.cts +2 -2
- package/dist/yjs.d.ts +2 -2
- package/dist/yjs.js +5 -5
- package/package.json +81 -1
- package/dist/chunk-2AVGGPLT.js.map +0 -1
- package/dist/chunk-32OZ2WM2.js.map +0 -1
- package/dist/chunk-B5OMWOVI.js.map +0 -1
- package/dist/chunk-BJTOLCRR.js.map +0 -1
- package/dist/chunk-HT7OF52E.js.map +0 -1
- package/dist/chunk-IJKGF6SC.js.map +0 -1
- package/dist/chunk-KF3KKN4N.js.map +0 -1
- package/dist/chunk-KFYJW7W5.js.map +0 -1
- package/dist/chunk-N2SCDXTI.js.map +0 -1
- package/dist/chunk-O7XZFXPE.js.map +0 -1
- package/dist/toc-extension-CI6jNOYl.d.cts +0 -26
- package/dist/toc-extension-CTHWjNJC.d.ts +0 -26
- /package/dist/{chunk-WZA5S5EJ.cjs → chunk-I7X7B3WD.cjs} +0 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkBA5WXBGE_cjs = require('./chunk-BA5WXBGE.cjs');
|
|
4
|
+
var chunkP6HC7RUN_cjs = require('./chunk-P6HC7RUN.cjs');
|
|
5
|
+
var chunkZWTIRGY5_cjs = require('./chunk-ZWTIRGY5.cjs');
|
|
6
|
+
var chunkFK7EBZPX_cjs = require('./chunk-FK7EBZPX.cjs');
|
|
7
|
+
var chunkI7X7B3WD_cjs = require('./chunk-I7X7B3WD.cjs');
|
|
7
8
|
var react = require('react');
|
|
8
9
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
10
|
var reactDom = require('react-dom');
|
|
@@ -11,8 +12,8 @@ var reactDom = require('react-dom');
|
|
|
11
12
|
// src/engine/commands/table-shape.ts
|
|
12
13
|
var CELL = /^cell:(\d+):(\d+)$/;
|
|
13
14
|
var tableShape = (block) => ({
|
|
14
|
-
rows:
|
|
15
|
-
cols:
|
|
15
|
+
rows: chunkI7X7B3WD_cjs.countOf(block.attrs.rows),
|
|
16
|
+
cols: chunkI7X7B3WD_cjs.countOf(block.attrs.cols)
|
|
16
17
|
});
|
|
17
18
|
var ALIGNS = ["left", "center", "right"];
|
|
18
19
|
var columnAligns = (block, cols) => Array.from({ length: cols }, (_, col) => {
|
|
@@ -26,7 +27,7 @@ function cellOf(region) {
|
|
|
26
27
|
return match === null ? null : [Number(match[1]), Number(match[2])];
|
|
27
28
|
}
|
|
28
29
|
function tableBlock(doc, id) {
|
|
29
|
-
const block =
|
|
30
|
+
const block = chunkI7X7B3WD_cjs.blockById(doc, id);
|
|
30
31
|
return block?.type === "TABLE" ? block : null;
|
|
31
32
|
}
|
|
32
33
|
var isIndex = (index, length) => Number.isInteger(index) && index >= 0 && index < length;
|
|
@@ -40,7 +41,7 @@ function rebuiltTable(block, plan) {
|
|
|
40
41
|
for (let row = 0; row < plan.rows; row++) {
|
|
41
42
|
for (let col = 0; col < plan.cols; col++) {
|
|
42
43
|
const from = plan.source(row, col);
|
|
43
|
-
regions[
|
|
44
|
+
regions[chunkI7X7B3WD_cjs.cellKey(row, col)] = from === null ? [] : block.regions[chunkI7X7B3WD_cjs.cellKey(...from)] ?? [];
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
return { ...block, attrs: { ...block.attrs, ...plan.attrs, rows: plan.rows, cols: plan.cols }, regions };
|
|
@@ -49,17 +50,17 @@ function followedPos(pos, blockId, plan) {
|
|
|
49
50
|
const cell = pos.block === blockId ? cellOf(pos.region) : null;
|
|
50
51
|
if (cell === null) return pos;
|
|
51
52
|
const moved = plan.target(cell);
|
|
52
|
-
return moved === null ? { block: blockId, region:
|
|
53
|
+
return moved === null ? { block: blockId, region: chunkI7X7B3WD_cjs.cellKey(...plan.landing(cell)), offset: 0 } : { ...pos, region: chunkI7X7B3WD_cjs.cellKey(...moved) };
|
|
53
54
|
}
|
|
54
55
|
function followedSelection(selection, blockId, plan) {
|
|
55
56
|
if (selection?.kind !== "text") return selection;
|
|
56
57
|
const anchor = followedPos(selection.anchor, blockId, plan);
|
|
57
58
|
const head = followedPos(selection.head, blockId, plan);
|
|
58
|
-
return anchor === selection.anchor && head === selection.head ? selection :
|
|
59
|
+
return anchor === selection.anchor && head === selection.head ? selection : chunkFK7EBZPX_cjs.textSelection(anchor, head);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
// src/engine/state/cell-selection.ts
|
|
62
|
-
var cellSelectionKey =
|
|
63
|
+
var cellSelectionKey = chunkFK7EBZPX_cjs.createPluginKey("cellSelection");
|
|
63
64
|
function rangeOfSelection({ doc, selection }) {
|
|
64
65
|
if (selection?.kind !== "text") return null;
|
|
65
66
|
const { anchor, head } = selection;
|
|
@@ -97,39 +98,39 @@ function selectCells(blockId, anchor, head) {
|
|
|
97
98
|
const { rows, cols } = block === null ? { rows: 0, cols: 0 } : tableShape(block);
|
|
98
99
|
const inside = ([row, col]) => isIndex(row, rows) && isIndex(col, cols);
|
|
99
100
|
if (block === null || !inside(anchor) || !inside(head)) return false;
|
|
100
|
-
const end2 =
|
|
101
|
-
const selection =
|
|
102
|
-
{ block: blockId, region:
|
|
103
|
-
{ block: blockId, region: end2, offset:
|
|
101
|
+
const end2 = chunkI7X7B3WD_cjs.cellKey(...head);
|
|
102
|
+
const selection = chunkFK7EBZPX_cjs.textSelection(
|
|
103
|
+
{ block: blockId, region: chunkI7X7B3WD_cjs.cellKey(...anchor), offset: 0 },
|
|
104
|
+
{ block: blockId, region: end2, offset: chunkI7X7B3WD_cjs.inlineLength(block.regions[end2] ?? []) }
|
|
104
105
|
);
|
|
105
|
-
dispatch?.(new
|
|
106
|
+
dispatch?.(new chunkFK7EBZPX_cjs.Transaction(state).setSelection(selection));
|
|
106
107
|
return true;
|
|
107
108
|
};
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
// src/engine/commands/cell-commands.ts
|
|
111
112
|
function filledCells(doc, range) {
|
|
112
|
-
const regions =
|
|
113
|
+
const regions = chunkI7X7B3WD_cjs.blockById(doc, range.block)?.regions ?? {};
|
|
113
114
|
return cellsInRange(range).flatMap((cell) => {
|
|
114
|
-
const region =
|
|
115
|
-
const length =
|
|
115
|
+
const region = chunkI7X7B3WD_cjs.cellKey(...cell);
|
|
116
|
+
const length = chunkI7X7B3WD_cjs.inlineLength(regions[region] ?? []);
|
|
116
117
|
return length > 0 ? [{ region, length }] : [];
|
|
117
118
|
});
|
|
118
119
|
}
|
|
119
120
|
function firstCell({ block, anchor, head }) {
|
|
120
|
-
return { block, region:
|
|
121
|
+
return { block, region: chunkI7X7B3WD_cjs.cellKey(Math.min(anchor[0], head[0]), Math.min(anchor[1], head[1])), offset: 0 };
|
|
121
122
|
}
|
|
122
123
|
function emptied(state, range) {
|
|
123
|
-
const tr = new
|
|
124
|
+
const tr = new chunkFK7EBZPX_cjs.Transaction(state);
|
|
124
125
|
for (const { region, length } of filledCells(state.doc, range)) {
|
|
125
|
-
tr.step(
|
|
126
|
+
tr.step(chunkFK7EBZPX_cjs.replaceInlineStep(range.block, region, 0, length, []));
|
|
126
127
|
}
|
|
127
128
|
return tr;
|
|
128
129
|
}
|
|
129
130
|
var deleteCellContents = (state, dispatch) => {
|
|
130
131
|
const range = cellSelection(state);
|
|
131
132
|
if (range === null) return false;
|
|
132
|
-
dispatch?.(emptied(state, range).setSelection(
|
|
133
|
+
dispatch?.(emptied(state, range).setSelection(chunkFK7EBZPX_cjs.textSelection(firstCell(range))));
|
|
133
134
|
return true;
|
|
134
135
|
};
|
|
135
136
|
function typeOverCells(text) {
|
|
@@ -137,7 +138,7 @@ function typeOverCells(text) {
|
|
|
137
138
|
const range = cellSelection(state);
|
|
138
139
|
if (range === null || text === "") return false;
|
|
139
140
|
const tr = emptied(state, range);
|
|
140
|
-
dispatch?.(tr.setSelection(
|
|
141
|
+
dispatch?.(tr.setSelection(chunkFK7EBZPX_cjs.textSelection(chunkFK7EBZPX_cjs.insertTextAt(tr, state.schema, firstCell(range), text))));
|
|
141
142
|
return true;
|
|
142
143
|
};
|
|
143
144
|
}
|
|
@@ -145,14 +146,14 @@ function setCellsMark(type, attrs) {
|
|
|
145
146
|
return (state, dispatch) => {
|
|
146
147
|
const range = cellSelection(state);
|
|
147
148
|
const cells = range === null ? [] : filledCells(state.doc, range);
|
|
148
|
-
const regions = range === null ? void 0 :
|
|
149
|
+
const regions = range === null ? void 0 : chunkI7X7B3WD_cjs.blockById(state.doc, range.block)?.regions;
|
|
149
150
|
if (range === null || regions === void 0 || cells.length === 0) return false;
|
|
150
|
-
const carried = cells.every(({ region }) =>
|
|
151
|
-
const mark = carried ?
|
|
152
|
-
const tr = new
|
|
151
|
+
const carried = cells.every(({ region }) => chunkFK7EBZPX_cjs.markCoverage(regions[region], type, attrs).every);
|
|
152
|
+
const mark = carried ? chunkFK7EBZPX_cjs.toggleMark(type, attrs) : chunkFK7EBZPX_cjs.setMark(type, attrs);
|
|
153
|
+
const tr = new chunkFK7EBZPX_cjs.Transaction(state);
|
|
153
154
|
for (const { region, length } of cells) {
|
|
154
155
|
const start = { block: range.block, region, offset: 0 };
|
|
155
|
-
const whole =
|
|
156
|
+
const whole = chunkFK7EBZPX_cjs.textSelection(start, { ...start, offset: length });
|
|
156
157
|
mark({ ...state, doc: tr.doc, selection: whole, storedMarks: null }, (cell) => {
|
|
157
158
|
for (const step of cell.steps) tr.step(step);
|
|
158
159
|
});
|
|
@@ -167,7 +168,7 @@ function setCellsMark(type, attrs) {
|
|
|
167
168
|
var CONTROLS_SLOT = "data-quoin-table-controls";
|
|
168
169
|
var controlsSlot = (controller, blockId) => controller.blockElement(blockId)?.querySelector(`[${CONTROLS_SLOT}]`) ?? null;
|
|
169
170
|
var TableCell = react.memo(function TableCell2({ controller, blockId, row, col, header, align, label }) {
|
|
170
|
-
const inRange =
|
|
171
|
+
const inRange = chunkP6HC7RUN_cjs.useEditorState(
|
|
171
172
|
controller,
|
|
172
173
|
react.useCallback(
|
|
173
174
|
(state) => {
|
|
@@ -186,7 +187,7 @@ var TableCell = react.memo(function TableCell2({ controller, blockId, row, col,
|
|
|
186
187
|
"data-col": col,
|
|
187
188
|
"data-in-range": inRange ? "" : void 0,
|
|
188
189
|
style: align === null ? void 0 : { textAlign: align },
|
|
189
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
190
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(chunkP6HC7RUN_cjs.EditableRegion, { block: blockId, region: chunkI7X7B3WD_cjs.cellKey(row, col), label, className: "quoin-table-text" })
|
|
190
191
|
}
|
|
191
192
|
);
|
|
192
193
|
});
|
|
@@ -229,7 +230,7 @@ function changeTable(blockId, change, plan) {
|
|
|
229
230
|
const block = tableBlock(state.doc, blockId);
|
|
230
231
|
const next = block && change(block);
|
|
231
232
|
if (!next) return false;
|
|
232
|
-
const tr = new
|
|
233
|
+
const tr = new chunkFK7EBZPX_cjs.Transaction(state).step(chunkFK7EBZPX_cjs.replaceBlockStep(next));
|
|
233
234
|
dispatch?.(plan ? tr.setSelection(followedSelection(state.selection, blockId, plan)) : tr);
|
|
234
235
|
return true;
|
|
235
236
|
};
|
|
@@ -340,28 +341,28 @@ var setColumnWidth = (blockId, col, px, drawn) => changeTable(blockId, (block) =
|
|
|
340
341
|
var isCount = (value) => Number.isInteger(value) && value > 0;
|
|
341
342
|
function emptyCells({ rows, cols }) {
|
|
342
343
|
const regions = {};
|
|
343
|
-
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[chunkI7X7B3WD_cjs.cellKey(row, col)] = [];
|
|
344
345
|
return regions;
|
|
345
346
|
}
|
|
346
347
|
function insertTable(rows, cols, options = {}) {
|
|
347
348
|
return (state, dispatch) => {
|
|
348
349
|
const { doc, schema } = state;
|
|
349
|
-
const id =
|
|
350
|
+
const id = chunkFK7EBZPX_cjs.headBlockId(state.selection);
|
|
350
351
|
if (id === null || !isCount(rows) || !isCount(cols)) return false;
|
|
351
|
-
const index =
|
|
352
|
+
const index = chunkI7X7B3WD_cjs.requireBlockIndex(doc, id);
|
|
352
353
|
const current = doc.blocks[index];
|
|
353
|
-
const fills =
|
|
354
|
+
const fills = chunkFK7EBZPX_cjs.isParagraph(current) && chunkFK7EBZPX_cjs.regionLength(current, chunkFK7EBZPX_cjs.primaryRegion(schema, current) ?? "") === 0;
|
|
354
355
|
const table = {
|
|
355
|
-
id: fills ? current.id : (options.newId ??
|
|
356
|
+
id: fills ? current.id : (options.newId ?? chunkI7X7B3WD_cjs.newId)(),
|
|
356
357
|
type: "TABLE",
|
|
357
358
|
indent: current.indent,
|
|
358
359
|
attrs: { header: true, align: Array.from({ length: cols }, () => null), rows, cols },
|
|
359
360
|
regions: emptyCells({ rows, cols })
|
|
360
361
|
};
|
|
361
|
-
const tr = new
|
|
362
|
-
fills ?
|
|
362
|
+
const tr = new chunkFK7EBZPX_cjs.Transaction(state).step(
|
|
363
|
+
fills ? chunkFK7EBZPX_cjs.replaceBlockStep(table) : chunkFK7EBZPX_cjs.insertBlocksStep(chunkFK7EBZPX_cjs.descendantsEnd(doc, index), [table])
|
|
363
364
|
);
|
|
364
|
-
dispatch?.(tr.setSelection(
|
|
365
|
+
dispatch?.(tr.setSelection(chunkFK7EBZPX_cjs.textSelection({ block: table.id, region: chunkI7X7B3WD_cjs.cellKey(0, 0), offset: 0 })));
|
|
365
366
|
return true;
|
|
366
367
|
};
|
|
367
368
|
}
|
|
@@ -374,15 +375,15 @@ function headCell({ doc, selection }) {
|
|
|
374
375
|
const cell = block && cellOf(head.region);
|
|
375
376
|
return block && cell ? { block, cell, head, shape: tableShape(block) } : null;
|
|
376
377
|
}
|
|
377
|
-
var cellLength = (block, [row, col]) =>
|
|
378
|
+
var cellLength = (block, [row, col]) => chunkI7X7B3WD_cjs.inlineLength(block.regions[chunkI7X7B3WD_cjs.cellKey(row, col)] ?? []);
|
|
378
379
|
var cellPos = (block, cell, atEnd = false) => ({
|
|
379
380
|
block: block.id,
|
|
380
|
-
region:
|
|
381
|
+
region: chunkI7X7B3WD_cjs.cellKey(...cell),
|
|
381
382
|
offset: atEnd ? cellLength(block, cell) : 0
|
|
382
383
|
});
|
|
383
|
-
var moveTo = (state, pos) => new
|
|
384
|
+
var moveTo = (state, pos) => new chunkFK7EBZPX_cjs.Transaction(state).setSelection(chunkFK7EBZPX_cjs.textSelection(pos));
|
|
384
385
|
var thenCaretIn = (command, blockId, at) => (state, dispatch) => {
|
|
385
|
-
const caret =
|
|
386
|
+
const caret = chunkFK7EBZPX_cjs.textSelection({ block: blockId, region: chunkI7X7B3WD_cjs.cellKey(...at), offset: 0 });
|
|
386
387
|
return command(state, dispatch && ((tr) => dispatch(tr.setSelection(caret))));
|
|
387
388
|
};
|
|
388
389
|
var cellAtIndex = (index, { cols }) => [Math.floor(index / cols), index % cols];
|
|
@@ -415,11 +416,11 @@ var enterInCell = (state, dispatch) => {
|
|
|
415
416
|
if (row === shape.rows - 1 && cellLength(block, cell) === 0) {
|
|
416
417
|
return thenCaretIn(addRow(block.id, shape.rows), block.id, [shape.rows, col])(state, dispatch);
|
|
417
418
|
}
|
|
418
|
-
return
|
|
419
|
+
return chunkFK7EBZPX_cjs.insertHardBreak(state, dispatch);
|
|
419
420
|
};
|
|
420
421
|
var stopAtCellEdge = (atEnd) => (state) => {
|
|
421
422
|
const caret = headCell(state);
|
|
422
|
-
if (caret === null || !
|
|
423
|
+
if (caret === null || !chunkFK7EBZPX_cjs.isCollapsed(state.selection)) return false;
|
|
423
424
|
return caret.head.offset === (atEnd ? cellLength(caret.block, caret.cell) : 0);
|
|
424
425
|
};
|
|
425
426
|
var firstThatApplies = (...commands) => (state, dispatch) => commands.some((command) => command(state, dispatch));
|
|
@@ -452,7 +453,7 @@ function useCellPress(controller, blockId, table, editable) {
|
|
|
452
453
|
if (!editable || element === null) return;
|
|
453
454
|
const onPointerDown = (event) => {
|
|
454
455
|
const cell = event.button === 0 && event.pointerType !== "touch" ? cellOf2(event.target) : null;
|
|
455
|
-
const block = cell &&
|
|
456
|
+
const block = cell && chunkI7X7B3WD_cjs.blockById(controller.editor.state.doc, blockId);
|
|
456
457
|
if (!cell || !block) return;
|
|
457
458
|
event.preventDefault();
|
|
458
459
|
event.stopPropagation();
|
|
@@ -463,7 +464,7 @@ function useCellPress(controller, blockId, table, editable) {
|
|
|
463
464
|
}, [controller, blockId, table, editable]);
|
|
464
465
|
}
|
|
465
466
|
function useRevealCell(controller, blockId) {
|
|
466
|
-
const region =
|
|
467
|
+
const region = chunkP6HC7RUN_cjs.useEditorState(
|
|
467
468
|
controller,
|
|
468
469
|
react.useCallback(
|
|
469
470
|
(state) => {
|
|
@@ -484,23 +485,23 @@ function useRevealCell(controller, blockId) {
|
|
|
484
485
|
// src/extensions/table/vertical-cell-move.ts
|
|
485
486
|
var VERTICAL = { ArrowUp: -1, ArrowDown: 1 };
|
|
486
487
|
function caretAtGoal(controller, blockId, cell, direction) {
|
|
487
|
-
const region =
|
|
488
|
+
const region = chunkI7X7B3WD_cjs.cellKey(...cell);
|
|
488
489
|
const host = controller.registry.get(blockId, region);
|
|
489
490
|
const { goalX } = controller;
|
|
490
|
-
const line = host &&
|
|
491
|
+
const line = host && chunkP6HC7RUN_cjs.lineEdgeRect(host, direction < 0);
|
|
491
492
|
if (!host || !line || goalX === null) return null;
|
|
492
493
|
const box = host.getBoundingClientRect();
|
|
493
494
|
const x = Math.min(Math.max(goalX, box.left), box.right - 1);
|
|
494
|
-
const point =
|
|
495
|
-
const pos = point &&
|
|
495
|
+
const point = chunkP6HC7RUN_cjs.caretFromPoint(host.ownerDocument, x, line.top + line.height / 2);
|
|
496
|
+
const pos = point && chunkP6HC7RUN_cjs.domToPos(controller.registry, point.node, point.offset);
|
|
496
497
|
return pos && pos.block === blockId && pos.region === region ? pos : null;
|
|
497
498
|
}
|
|
498
499
|
var plainArrow = (event) => event.altKey || event.ctrlKey || event.metaKey ? void 0 : VERTICAL[event.key];
|
|
499
500
|
function caretOnEdgeLine(controller, head, direction) {
|
|
500
501
|
const host = controller.registry.get(head.block, head.region);
|
|
501
|
-
const point =
|
|
502
|
-
if (!host || !point || !(direction < 0 ?
|
|
503
|
-
return { left:
|
|
502
|
+
const point = chunkP6HC7RUN_cjs.posToDom(controller.registry, head);
|
|
503
|
+
if (!host || !point || !(direction < 0 ? chunkP6HC7RUN_cjs.isOnFirstLine(host, point) : chunkP6HC7RUN_cjs.isOnLastLine(host, point))) return null;
|
|
504
|
+
return { left: chunkP6HC7RUN_cjs.caretClientRect(point)?.left ?? null };
|
|
504
505
|
}
|
|
505
506
|
function columnAt(controller, blockId, row, x) {
|
|
506
507
|
const cells = Array.from(controller.blockElement(blockId)?.querySelector("table")?.rows[row]?.cells ?? []);
|
|
@@ -513,7 +514,7 @@ function enterTable(controller, blockId, event) {
|
|
|
513
514
|
const { selection } = state;
|
|
514
515
|
const block = tableBlock(state.doc, blockId);
|
|
515
516
|
if (direction === void 0 || event.shiftKey || block === null || selection?.kind !== "text") return false;
|
|
516
|
-
if (!
|
|
517
|
+
if (!chunkFK7EBZPX_cjs.isCollapsed(selection) || chunkP6HC7RUN_cjs.neighbourBlock(state.doc, selection.head.block, direction)?.id !== blockId) return false;
|
|
517
518
|
const caret = caretOnEdgeLine(controller, selection.head, direction);
|
|
518
519
|
if (caret === null) return false;
|
|
519
520
|
controller.goalX ??= caret.left;
|
|
@@ -522,7 +523,7 @@ function enterTable(controller, blockId, event) {
|
|
|
522
523
|
const { goalX } = controller;
|
|
523
524
|
const cell = [row, goalX === null ? direction > 0 ? 0 : cols - 1 : columnAt(controller, blockId, row, goalX)];
|
|
524
525
|
const pos = caretAtGoal(controller, blockId, cell, direction) ?? cellPos(block, cell, direction < 0);
|
|
525
|
-
controller.dispatch(controller.editor.createTransaction().setSelection(
|
|
526
|
+
controller.dispatch(controller.editor.createTransaction().setSelection(chunkFK7EBZPX_cjs.textSelection(pos)));
|
|
526
527
|
return true;
|
|
527
528
|
}
|
|
528
529
|
function moveBetweenRows(controller, blockId, event) {
|
|
@@ -538,7 +539,7 @@ function moveBetweenRows(controller, blockId, event) {
|
|
|
538
539
|
if (edge === null) return false;
|
|
539
540
|
controller.goalX ??= edge.left;
|
|
540
541
|
const pos = caretAtGoal(controller, blockId, target, direction) ?? cellPos(caret.block, target, direction < 0);
|
|
541
|
-
const selection = event.shiftKey ?
|
|
542
|
+
const selection = event.shiftKey ? chunkFK7EBZPX_cjs.textSelection(state.selection.anchor, pos) : chunkFK7EBZPX_cjs.textSelection(pos);
|
|
542
543
|
controller.dispatch(controller.editor.createTransaction().setSelection(selection));
|
|
543
544
|
return true;
|
|
544
545
|
}
|
|
@@ -553,17 +554,17 @@ function useTableKeys(controller, blockId, editable) {
|
|
|
553
554
|
react.useEffect(() => {
|
|
554
555
|
if (!editable) return;
|
|
555
556
|
const intercept = (event) => {
|
|
556
|
-
if (
|
|
557
|
+
if (chunkP6HC7RUN_cjs.isComposingKey(controller, event)) return false;
|
|
557
558
|
const handled = typeOver(controller, blockId, event) || moveBetweenRows(controller, blockId, event) || enterTable(controller, blockId, event);
|
|
558
559
|
if (handled) event.preventDefault();
|
|
559
560
|
return handled;
|
|
560
561
|
};
|
|
561
|
-
return
|
|
562
|
+
return chunkBA5WXBGE_cjs.interceptKeys(controller, intercept);
|
|
562
563
|
}, [controller, blockId, editable]);
|
|
563
564
|
}
|
|
564
565
|
var indexes = (from, to) => Array.from({ length: Math.max(to - from, 0) }, (_, i) => from + i);
|
|
565
566
|
function TableBlock({ block, controller, labels }) {
|
|
566
|
-
const readOnly =
|
|
567
|
+
const readOnly = chunkP6HC7RUN_cjs.useReadOnly(controller);
|
|
567
568
|
const table = react.useRef(null);
|
|
568
569
|
const { rows, cols } = tableShape(block);
|
|
569
570
|
const header = block.attrs.header !== false && rows > 0;
|
|
@@ -587,7 +588,7 @@ function TableBlock({ block, controller, labels }) {
|
|
|
587
588
|
col
|
|
588
589
|
)) }, index);
|
|
589
590
|
const scroller = readOnly ? { role: "region", "aria-label": labels.table, tabIndex: 0 } : void 0;
|
|
590
|
-
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 ?
|
|
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 ? chunkBA5WXBGE_cjs.FOCUS_RING : ""}`, ...scroller, children: [
|
|
591
592
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
592
593
|
"table",
|
|
593
594
|
{
|
|
@@ -611,10 +612,10 @@ function lineCells(block, index, axis) {
|
|
|
611
612
|
const { rows, cols } = tableShape(block);
|
|
612
613
|
return Array.from(
|
|
613
614
|
{ length: axis === "row" ? cols : rows },
|
|
614
|
-
(_, other) => axis === "row" ? block.regions[
|
|
615
|
+
(_, other) => axis === "row" ? block.regions[chunkI7X7B3WD_cjs.cellKey(index, other)] ?? EMPTY : block.regions[chunkI7X7B3WD_cjs.cellKey(other, index)] ?? EMPTY
|
|
615
616
|
);
|
|
616
617
|
}
|
|
617
|
-
var sameLine = (before, after, index, axis) =>
|
|
618
|
+
var sameLine = (before, after, index, axis) => chunkI7X7B3WD_cjs.sameItems(lineCells(before, index, axis), lineCells(after, index, axis), chunkI7X7B3WD_cjs.equalInline);
|
|
618
619
|
function sameMenuCells(opened, current, target, axis) {
|
|
619
620
|
const shape = tableShape(opened);
|
|
620
621
|
const lines = axis === "row" ? shape.rows : shape.cols;
|
|
@@ -639,7 +640,7 @@ function ColumnResizer(props) {
|
|
|
639
640
|
if (!controller.readOnly) controller.run(setColumnWidth(blockId, col, px, widths));
|
|
640
641
|
};
|
|
641
642
|
const onKeyDown = (event) => {
|
|
642
|
-
if (
|
|
643
|
+
if (chunkP6HC7RUN_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
643
644
|
const step = event.shiftKey ? LARGE_STEP : STEP;
|
|
644
645
|
const tab = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
645
646
|
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
@@ -694,7 +695,7 @@ function ColumnResizer(props) {
|
|
|
694
695
|
"aria-valuetext": labels.columnWidth(width),
|
|
695
696
|
className: "quoin-table-resizer",
|
|
696
697
|
style,
|
|
697
|
-
...{ [
|
|
698
|
+
...{ [chunkP6HC7RUN_cjs.NATIVE_INTERACTION]: "" },
|
|
698
699
|
onKeyDown,
|
|
699
700
|
onPointerDown,
|
|
700
701
|
onPointerMove,
|
|
@@ -709,20 +710,20 @@ function HandleMenu({ controller, axis, label, style, items, open, onOpenChange,
|
|
|
709
710
|
if (controller.run(item3.command)) controller.announce(item3.done);
|
|
710
711
|
};
|
|
711
712
|
const item2 = (entry) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
712
|
-
|
|
713
|
+
chunkBA5WXBGE_cjs.DropdownMenuItem,
|
|
713
714
|
{
|
|
714
715
|
disabled: entry.disabled,
|
|
715
716
|
className: entry.destructive ? DESTRUCTIVE : void 0,
|
|
716
717
|
onSelect: () => run(entry),
|
|
717
718
|
children: [
|
|
718
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
719
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.MenuIcon, { icon: entry.icon }),
|
|
719
720
|
entry.label
|
|
720
721
|
]
|
|
721
722
|
},
|
|
722
723
|
entry.id
|
|
723
724
|
);
|
|
724
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
725
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
725
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkBA5WXBGE_cjs.DropdownMenu, { open, onOpenChange, children: [
|
|
726
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
726
727
|
"button",
|
|
727
728
|
{
|
|
728
729
|
ref: buttonRef,
|
|
@@ -732,22 +733,22 @@ function HandleMenu({ controller, axis, label, style, items, open, onOpenChange,
|
|
|
732
733
|
"data-axis": axis,
|
|
733
734
|
className: "quoin-table-handle",
|
|
734
735
|
style,
|
|
735
|
-
children: axis === "row" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
736
|
+
children: axis === "row" ? /* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.GripVertical, { "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.GripHorizontal, { "aria-hidden": "true" })
|
|
736
737
|
}
|
|
737
738
|
) }),
|
|
738
739
|
open && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
739
|
-
|
|
740
|
+
chunkBA5WXBGE_cjs.DropdownMenuContent,
|
|
740
741
|
{
|
|
741
742
|
align: "start",
|
|
742
743
|
"aria-label": label,
|
|
743
744
|
"aria-labelledby": void 0,
|
|
744
|
-
onCloseAutoFocus:
|
|
745
|
-
...
|
|
745
|
+
onCloseAutoFocus: chunkBA5WXBGE_cjs.returnFocusToText(controller),
|
|
746
|
+
...chunkBA5WXBGE_cjs.bubblePart(controller),
|
|
746
747
|
children: [
|
|
747
748
|
items.filter((entry) => !entry.destructive).map(item2),
|
|
748
749
|
children,
|
|
749
750
|
items.filter((entry) => entry.destructive).map((entry) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
750
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
751
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.DropdownMenuSeparator, {}),
|
|
751
752
|
item2(entry)
|
|
752
753
|
] }, entry.id))
|
|
753
754
|
]
|
|
@@ -761,31 +762,31 @@ var item = (id, label, icon, command, done, options = {}) => ({ id, label, icon,
|
|
|
761
762
|
function rowMenuItems(labels, blockId, row, { rows }) {
|
|
762
763
|
const { rowInserted, rowMoved, rowDeleted } = labels;
|
|
763
764
|
return [
|
|
764
|
-
item("above", labels.insertRowAbove,
|
|
765
|
-
item("below", labels.insertRowBelow,
|
|
766
|
-
item("up", labels.moveRowUp,
|
|
767
|
-
item("down", labels.moveRowDown,
|
|
768
|
-
item("delete", labels.deleteRow,
|
|
765
|
+
item("above", labels.insertRowAbove, chunkBA5WXBGE_cjs.ArrowUpToLine, addRow(blockId, row), rowInserted),
|
|
766
|
+
item("below", labels.insertRowBelow, chunkBA5WXBGE_cjs.ArrowDownToLine, addRow(blockId, row + 1), rowInserted),
|
|
767
|
+
item("up", labels.moveRowUp, chunkBA5WXBGE_cjs.ArrowUp, moveRow(blockId, row, row - 1), rowMoved, { disabled: row === 0 }),
|
|
768
|
+
item("down", labels.moveRowDown, chunkBA5WXBGE_cjs.ArrowDown, moveRow(blockId, row, row + 1), rowMoved, { disabled: row === rows - 1 }),
|
|
769
|
+
item("delete", labels.deleteRow, chunkBA5WXBGE_cjs.Trash, removeRow(blockId, row), rowDeleted, { disabled: rows === 1, destructive: true })
|
|
769
770
|
];
|
|
770
771
|
}
|
|
771
772
|
function columnMenuItems(labels, blockId, col, { cols }) {
|
|
772
773
|
const { columnInserted, columnMoved, columnDeleted } = labels;
|
|
773
774
|
const last = col === cols - 1;
|
|
774
775
|
return [
|
|
775
|
-
item("left", labels.insertColumnLeft,
|
|
776
|
-
item("right", labels.insertColumnRight,
|
|
777
|
-
item("move-left", labels.moveColumnLeft,
|
|
778
|
-
item("move-right", labels.moveColumnRight,
|
|
779
|
-
item("delete", labels.deleteColumn,
|
|
776
|
+
item("left", labels.insertColumnLeft, chunkBA5WXBGE_cjs.ArrowLeftToLine, addColumn(blockId, col), columnInserted),
|
|
777
|
+
item("right", labels.insertColumnRight, chunkBA5WXBGE_cjs.ArrowRightToLine, addColumn(blockId, col + 1), columnInserted),
|
|
778
|
+
item("move-left", labels.moveColumnLeft, chunkBA5WXBGE_cjs.ArrowLeft, moveColumn(blockId, col, col - 1), columnMoved, { disabled: col === 0 }),
|
|
779
|
+
item("move-right", labels.moveColumnRight, chunkBA5WXBGE_cjs.ArrowRight, moveColumn(blockId, col, col + 1), columnMoved, { disabled: last }),
|
|
780
|
+
item("delete", labels.deleteColumn, chunkBA5WXBGE_cjs.Trash, removeColumn(blockId, col), columnDeleted, {
|
|
780
781
|
disabled: cols === 1,
|
|
781
782
|
destructive: true
|
|
782
783
|
})
|
|
783
784
|
];
|
|
784
785
|
}
|
|
785
786
|
var alignItems = (labels) => [
|
|
786
|
-
{ value: "left", label: labels.alignLeft, icon:
|
|
787
|
-
{ value: "center", label: labels.alignCenter, icon:
|
|
788
|
-
{ value: "right", label: labels.alignRight, icon:
|
|
787
|
+
{ value: "left", label: labels.alignLeft, icon: chunkBA5WXBGE_cjs.AlignLeft, done: labels.alignedLeft },
|
|
788
|
+
{ value: "center", label: labels.alignCenter, icon: chunkBA5WXBGE_cjs.AlignCenter, done: labels.alignedCenter },
|
|
789
|
+
{ value: "right", label: labels.alignRight, icon: chunkBA5WXBGE_cjs.AlignRight, done: labels.alignedRight }
|
|
789
790
|
];
|
|
790
791
|
var BESIDE = 4;
|
|
791
792
|
var end = (span) => span.start + span.size;
|
|
@@ -808,7 +809,7 @@ function TableHandles(props) {
|
|
|
808
809
|
const { rowEdge, colEdge } = target;
|
|
809
810
|
const rowInsertAt = edgeOf(geometry.rows, rowEdge);
|
|
810
811
|
const columnInsertAt = edgeOf(geometry.cols, colEdge);
|
|
811
|
-
|
|
812
|
+
chunkP6HC7RUN_cjs.useIsomorphicLayoutEffect(() => {
|
|
812
813
|
if (!focusRequested) return;
|
|
813
814
|
(columnHandle.current ?? rowHandle.current)?.focus();
|
|
814
815
|
onFocused();
|
|
@@ -819,7 +820,7 @@ function TableHandles(props) {
|
|
|
819
820
|
const onKeyDown = (event) => {
|
|
820
821
|
const handles = [rowHandle.current, columnHandle.current].filter((handle) => handle !== null);
|
|
821
822
|
const index = handles.indexOf(event.target);
|
|
822
|
-
if (index === -1 ||
|
|
823
|
+
if (index === -1 || chunkP6HC7RUN_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
823
824
|
if (event.key === "ArrowLeft" || event.key === "ArrowRight") handles[(index + 1) % handles.length].focus();
|
|
824
825
|
else if (isTab(event) && !event.shiftKey && resizer.current !== null) resizer.current.focus();
|
|
825
826
|
else if (isTab(event) || event.key === "Escape") controller.focus();
|
|
@@ -857,7 +858,7 @@ function TableHandles(props) {
|
|
|
857
858
|
onOpenChange: opener("row"),
|
|
858
859
|
buttonRef: rowHandle,
|
|
859
860
|
children: row === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
860
|
-
|
|
861
|
+
chunkBA5WXBGE_cjs.DropdownMenuCheckboxItem,
|
|
861
862
|
{
|
|
862
863
|
checked: block.attrs.header !== false,
|
|
863
864
|
onCheckedChange: (on) => run(toggleHeaderRow(block.id), on ? labels.headerRowOn : labels.headerRowOff),
|
|
@@ -878,14 +879,14 @@ function TableHandles(props) {
|
|
|
878
879
|
onOpenChange: opener("column"),
|
|
879
880
|
buttonRef: columnHandle,
|
|
880
881
|
children: [
|
|
881
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
882
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
883
|
-
|
|
882
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.DropdownMenuSeparator, {}),
|
|
883
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.DropdownMenuRadioGroup, { value: align ?? "", children: alignItems(labels).map(({ value, label, icon, done }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
884
|
+
chunkBA5WXBGE_cjs.DropdownMenuRadioItem,
|
|
884
885
|
{
|
|
885
886
|
value,
|
|
886
887
|
onSelect: () => align === value ? run(setColumnAlign(block.id, col, null), labels.alignmentCleared) : run(setColumnAlign(block.id, col, value), done),
|
|
887
888
|
children: [
|
|
888
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
889
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.MenuIcon, { icon }),
|
|
889
890
|
label
|
|
890
891
|
]
|
|
891
892
|
},
|
|
@@ -904,10 +905,10 @@ function TableHandles(props) {
|
|
|
904
905
|
"data-axis": "row",
|
|
905
906
|
className: "quoin-table-insert",
|
|
906
907
|
style: place(geometry.left - BESIDE, rowInsertAt),
|
|
907
|
-
onPointerDown:
|
|
908
|
-
onMouseDown:
|
|
908
|
+
onPointerDown: chunkBA5WXBGE_cjs.keepFocus,
|
|
909
|
+
onMouseDown: chunkBA5WXBGE_cjs.keepFocus,
|
|
909
910
|
onClick: () => run(addRow(block.id, rowEdge), labels.rowInserted),
|
|
910
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
911
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.Plus, { "aria-hidden": "true" })
|
|
911
912
|
}
|
|
912
913
|
),
|
|
913
914
|
colEdge !== null && columnInsertAt !== null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -919,10 +920,10 @@ function TableHandles(props) {
|
|
|
919
920
|
"data-axis": "column",
|
|
920
921
|
className: "quoin-table-insert",
|
|
921
922
|
style: place(columnInsertAt, geometry.top),
|
|
922
|
-
onPointerDown:
|
|
923
|
-
onMouseDown:
|
|
923
|
+
onPointerDown: chunkBA5WXBGE_cjs.keepFocus,
|
|
924
|
+
onMouseDown: chunkBA5WXBGE_cjs.keepFocus,
|
|
924
925
|
onClick: () => run(addColumn(block.id, colEdge), labels.columnInserted),
|
|
925
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
926
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(chunkBA5WXBGE_cjs.Plus, { "aria-hidden": "true" })
|
|
926
927
|
}
|
|
927
928
|
)
|
|
928
929
|
] });
|
|
@@ -963,7 +964,7 @@ function edgeNear(spans, at, reach) {
|
|
|
963
964
|
// src/extensions/table/use-table-geometry.ts
|
|
964
965
|
function useTableGeometry(controller, blockId, slot) {
|
|
965
966
|
const [geometry, setGeometry] = react.useState(null);
|
|
966
|
-
|
|
967
|
+
chunkP6HC7RUN_cjs.useIsomorphicLayoutEffect(() => {
|
|
967
968
|
const table = controller.blockElement(blockId)?.querySelector("table");
|
|
968
969
|
const view = slot.ownerDocument.defaultView;
|
|
969
970
|
if (!table || !view) return;
|
|
@@ -997,7 +998,7 @@ function useCutCells(controller) {
|
|
|
997
998
|
const onCut = (event) => {
|
|
998
999
|
if (controller.readOnly || cellSelection(controller.editor.state) === null) return;
|
|
999
1000
|
event.stopPropagation();
|
|
1000
|
-
|
|
1001
|
+
chunkP6HC7RUN_cjs.handleCopy(controller, event, false);
|
|
1001
1002
|
controller.run(deleteCellContents);
|
|
1002
1003
|
};
|
|
1003
1004
|
root.addEventListener("cut", onCut, true);
|
|
@@ -1041,9 +1042,9 @@ function focusOf(root) {
|
|
|
1041
1042
|
function useTableTarget(controller, held) {
|
|
1042
1043
|
const [hovered, setHovered] = react.useState(null);
|
|
1043
1044
|
const [focus, setFocus] = react.useState("none");
|
|
1044
|
-
const caret =
|
|
1045
|
+
const caret = chunkP6HC7RUN_cjs.useEditorState(controller, caretTarget, sameTarget);
|
|
1045
1046
|
const hoveredBlock = hovered?.target.block ?? null;
|
|
1046
|
-
const shape =
|
|
1047
|
+
const shape = chunkP6HC7RUN_cjs.useEditorState(
|
|
1047
1048
|
controller,
|
|
1048
1049
|
react.useCallback((state) => hoveredBlock === null ? null : shapeOf(state, hoveredBlock), [hoveredBlock])
|
|
1049
1050
|
);
|
|
@@ -1082,16 +1083,16 @@ function useTableTarget(controller, held) {
|
|
|
1082
1083
|
return pointed ?? (focus === "editor" ? caret : null);
|
|
1083
1084
|
}
|
|
1084
1085
|
var isFocusKey = (event) => event.key === "F10" && event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
1085
|
-
var takesFocusKey = (state) =>
|
|
1086
|
+
var takesFocusKey = (state) => chunkFK7EBZPX_cjs.isCollapsed(state.selection) || cellSelection(state) !== null;
|
|
1086
1087
|
function TableControls({ controller, labels }) {
|
|
1087
|
-
const readOnly =
|
|
1088
|
+
const readOnly = chunkP6HC7RUN_cjs.useReadOnly(controller);
|
|
1088
1089
|
const [held, setHeld] = react.useState(null);
|
|
1089
1090
|
const [focusFor, setFocusFor] = react.useState(null);
|
|
1090
1091
|
const [slot, setSlot] = react.useState(null);
|
|
1091
1092
|
const target = useTableTarget(controller, held?.target ?? null);
|
|
1092
1093
|
useCutCells(controller);
|
|
1093
1094
|
const blockId = target?.block ?? null;
|
|
1094
|
-
const block =
|
|
1095
|
+
const block = chunkP6HC7RUN_cjs.useEditorState(
|
|
1095
1096
|
controller,
|
|
1096
1097
|
react.useCallback((state) => blockId === null ? null : tableBlock(state.doc, blockId), [blockId])
|
|
1097
1098
|
);
|
|
@@ -1108,13 +1109,13 @@ function TableControls({ controller, labels }) {
|
|
|
1108
1109
|
const intercept = (event) => {
|
|
1109
1110
|
const { state } = controller.editor;
|
|
1110
1111
|
const caret = caretTarget(state);
|
|
1111
|
-
if (!isFocusKey(event) ||
|
|
1112
|
+
if (!isFocusKey(event) || chunkP6HC7RUN_cjs.isComposingKey(controller, event) || caret === null || !takesFocusKey(state)) return false;
|
|
1112
1113
|
event.preventDefault();
|
|
1113
1114
|
setHeld({ target: caret, menu: null });
|
|
1114
1115
|
setFocusFor(caret.block);
|
|
1115
1116
|
return true;
|
|
1116
1117
|
};
|
|
1117
|
-
return
|
|
1118
|
+
return chunkBA5WXBGE_cjs.interceptKeys(controller, intercept);
|
|
1118
1119
|
}, [controller, readOnly]);
|
|
1119
1120
|
const onMenu = react.useCallback(
|
|
1120
1121
|
(menu) => setHeld(menu === null || target === null || block === null ? null : { target, menu, opened: block }),
|
|
@@ -1125,7 +1126,7 @@ function TableControls({ controller, labels }) {
|
|
|
1125
1126
|
setFocusFor(null);
|
|
1126
1127
|
setHeld((current) => current?.menu === null ? null : current);
|
|
1127
1128
|
}, []);
|
|
1128
|
-
|
|
1129
|
+
chunkP6HC7RUN_cjs.useIsomorphicLayoutEffect(() => {
|
|
1129
1130
|
const drawn = block === null || readOnly ? null : controlsSlot(controller, block.id);
|
|
1130
1131
|
setSlot((current) => current === drawn ? current : drawn);
|
|
1131
1132
|
});
|
|
@@ -1194,10 +1195,7 @@ var englishTableLabels = {
|
|
|
1194
1195
|
alignedRight: "Column aligned right",
|
|
1195
1196
|
alignmentCleared: "Column alignment cleared"
|
|
1196
1197
|
};
|
|
1197
|
-
|
|
1198
|
-
const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
|
|
1199
|
-
return given.length === 0 ? englishTableLabels : { ...englishTableLabels, ...Object.fromEntries(given) };
|
|
1200
|
-
}
|
|
1198
|
+
var resolveTableLabels = (overrides) => chunkZWTIRGY5_cjs.mergeLabels(englishTableLabels, overrides);
|
|
1201
1199
|
|
|
1202
1200
|
// src/extensions/table/table-slash-item.ts
|
|
1203
1201
|
var NEW_TABLE = { rows: 3, cols: 3 };
|
|
@@ -1206,7 +1204,7 @@ var tableSlashItem = (labels) => ({
|
|
|
1206
1204
|
title: labels.table,
|
|
1207
1205
|
description: labels.tableDescription,
|
|
1208
1206
|
group: "advanced",
|
|
1209
|
-
icon:
|
|
1207
|
+
icon: chunkBA5WXBGE_cjs.Table,
|
|
1210
1208
|
keywords: ["grid", "rows", "columns", "spreadsheet", "|"],
|
|
1211
1209
|
command: () => insertTable(NEW_TABLE.rows, NEW_TABLE.cols)
|
|
1212
1210
|
});
|
|
@@ -1225,7 +1223,7 @@ function tableExtension(options = {}) {
|
|
|
1225
1223
|
blockNames: { TABLE: labels.table },
|
|
1226
1224
|
overlays: [TableOverlay]
|
|
1227
1225
|
};
|
|
1228
|
-
return
|
|
1226
|
+
return chunkFK7EBZPX_cjs.defineExtension({
|
|
1229
1227
|
name: "table",
|
|
1230
1228
|
priority: ABOVE_CORE_KEYS,
|
|
1231
1229
|
plugins: [cellSelectionPlugin],
|