quoin-editor 1.2.3 → 1.4.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 +21 -0
- package/THIRD_PARTY_NOTICES.md +47 -0
- package/dist/ai.cjs +69 -70
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.d.cts +4 -3
- package/dist/ai.d.ts +4 -3
- package/dist/ai.js +4 -5
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +20 -20
- package/dist/catalogue.d.cts +10 -9
- package/dist/catalogue.d.ts +10 -9
- package/dist/catalogue.js +12 -12
- package/dist/{chunk-35CHEARK.cjs → chunk-3NVFHJFS.cjs} +42 -41
- package/dist/chunk-3NVFHJFS.cjs.map +1 -0
- package/dist/{chunk-BR25RE7U.js → chunk-3YA7FYEL.js} +9 -6
- package/dist/chunk-3YA7FYEL.js.map +1 -0
- package/dist/{chunk-CZ5ZXBWC.cjs → chunk-65WK575V.cjs} +762 -306
- package/dist/chunk-65WK575V.cjs.map +1 -0
- package/dist/{chunk-Y7UKOBSY.js → chunk-6LOYAC5N.js} +7 -6
- package/dist/chunk-6LOYAC5N.js.map +1 -0
- package/dist/{chunk-KMIWUFNM.cjs → chunk-7WSBPD6Z.cjs} +96 -93
- package/dist/chunk-7WSBPD6Z.cjs.map +1 -0
- package/dist/{chunk-TARBFPWC.js → chunk-AC4AFDTI.js} +6 -6
- package/dist/{chunk-TARBFPWC.js.map → chunk-AC4AFDTI.js.map} +1 -1
- package/dist/{chunk-SCFW4JFT.cjs → chunk-AZ2ZNSFN.cjs} +43 -44
- package/dist/chunk-AZ2ZNSFN.cjs.map +1 -0
- package/dist/{chunk-ZVCBTQA3.cjs → chunk-AZF7B2AE.cjs} +10 -10
- package/dist/{chunk-ZVCBTQA3.cjs.map → chunk-AZF7B2AE.cjs.map} +1 -1
- package/dist/{chunk-DQV37F7J.cjs → chunk-FQDNF7MF.cjs} +68 -69
- package/dist/chunk-FQDNF7MF.cjs.map +1 -0
- package/dist/{chunk-25HNTVEI.js → chunk-G25FMFEZ.js} +3 -3
- package/dist/{chunk-25HNTVEI.js.map → chunk-G25FMFEZ.js.map} +1 -1
- package/dist/{chunk-A5LIN7FO.cjs → chunk-H5FM6I5W.cjs} +26 -26
- package/dist/{chunk-A5LIN7FO.cjs.map → chunk-H5FM6I5W.cjs.map} +1 -1
- package/dist/{chunk-YCVNFRL3.js → chunk-IJKGF6SC.js} +4 -4
- package/dist/{chunk-YCVNFRL3.js.map → chunk-IJKGF6SC.js.map} +1 -1
- package/dist/{chunk-4HFE3YFF.js → chunk-KRLHGVJV.js} +8 -7
- package/dist/chunk-KRLHGVJV.js.map +1 -0
- package/dist/{chunk-J552D3A7.js → chunk-MQTLZTIM.js} +448 -25
- package/dist/chunk-MQTLZTIM.js.map +1 -0
- package/dist/{chunk-KXOAV7AT.js → chunk-OS2O6IKX.js} +135 -12
- package/dist/chunk-OS2O6IKX.js.map +1 -0
- package/dist/{chunk-OGBD74IR.cjs → chunk-QJ34MOFV.cjs} +187 -117
- package/dist/chunk-QJ34MOFV.cjs.map +1 -0
- package/dist/{chunk-SAPLIQF2.js → chunk-QOIVLYMW.js} +4 -4
- package/dist/{chunk-SAPLIQF2.js.map → chunk-QOIVLYMW.js.map} +1 -1
- package/dist/{chunk-IGEWAL2J.cjs → chunk-QPOUONJ7.cjs} +32 -31
- package/dist/chunk-QPOUONJ7.cjs.map +1 -0
- package/dist/{chunk-K7JEN3KT.cjs → chunk-QR2NIDUK.cjs} +4 -4
- package/dist/{chunk-K7JEN3KT.cjs.map → chunk-QR2NIDUK.cjs.map} +1 -1
- package/dist/{chunk-4D7HZRNC.js → chunk-R7MYG522.js} +3 -3
- package/dist/{chunk-4D7HZRNC.js.map → chunk-R7MYG522.js.map} +1 -1
- package/dist/{chunk-BNUQ647G.js → chunk-STCJWXP5.js} +5 -6
- package/dist/chunk-STCJWXP5.js.map +1 -0
- package/dist/{chunk-BJIWN7BQ.cjs → chunk-STKGRXSA.cjs} +10 -10
- package/dist/{chunk-BJIWN7BQ.cjs.map → chunk-STKGRXSA.cjs.map} +1 -1
- package/dist/{chunk-5ANJW76W.cjs → chunk-VUYJGFUA.cjs} +23 -22
- package/dist/chunk-VUYJGFUA.cjs.map +1 -0
- package/dist/{chunk-FOEEDJ5R.js → chunk-VVS6JJLI.js} +7 -6
- package/dist/chunk-VVS6JJLI.js.map +1 -0
- package/dist/{chunk-G37GQ5JE.cjs → chunk-VZZPCYA3.cjs} +135 -12
- package/dist/chunk-VZZPCYA3.cjs.map +1 -0
- package/dist/{chunk-JYKSWEXT.cjs → chunk-WN7BZDNH.cjs} +6 -6
- package/dist/{chunk-JYKSWEXT.cjs.map → chunk-WN7BZDNH.cjs.map} +1 -1
- package/dist/{chunk-CCOPHCXX.js → chunk-XFEDJEJF.js} +109 -39
- package/dist/chunk-XFEDJEJF.js.map +1 -0
- package/dist/{chunk-I7OOIEZZ.js → chunk-YEQEBJPM.js} +5 -6
- package/dist/chunk-YEQEBJPM.js.map +1 -0
- package/dist/comments.cjs +54 -54
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.d.cts +4 -3
- package/dist/comments.d.ts +4 -3
- package/dist/comments.js +8 -8
- package/dist/comments.js.map +1 -1
- package/dist/diff.d.cts +7 -5
- package/dist/diff.d.ts +7 -5
- package/dist/docx.cjs +1 -1
- package/dist/docx.d.cts +3 -2
- package/dist/docx.d.ts +3 -2
- package/dist/docx.js +1 -1
- package/dist/embed.cjs +6 -6
- package/dist/embed.d.cts +5 -4
- package/dist/embed.d.ts +5 -4
- package/dist/embed.js +4 -4
- package/dist/emoji-data.cjs +272 -263
- package/dist/emoji-data.cjs.map +1 -1
- package/dist/emoji-data.js +272 -263
- package/dist/emoji-data.js.map +1 -1
- package/dist/{emoji-extension-CmPlRssm.d.ts → emoji-extension-C3o_Y5uC.d.cts} +3 -2
- package/dist/{emoji-extension-zJ6F7hW8.d.cts → emoji-extension-gRKnbW8G.d.ts} +3 -2
- package/dist/emoji.cjs +7 -7
- package/dist/emoji.d.cts +6 -5
- package/dist/emoji.d.ts +6 -5
- package/dist/emoji.js +4 -4
- package/dist/engine.cjs +43 -43
- package/dist/engine.d.cts +7 -6
- package/dist/engine.d.ts +7 -6
- package/dist/engine.js +1 -1
- package/dist/{find-extension-CmFehyul.d.ts → find-extension-BGGsJMu4.d.cts} +3 -2
- package/dist/{find-extension-BcRyE9K4.d.cts → find-extension-B_Ctrs6T.d.ts} +3 -2
- package/dist/find.cjs +8 -8
- package/dist/find.d.cts +5 -4
- package/dist/find.d.ts +5 -4
- package/dist/find.js +4 -4
- package/dist/headless.cjs +59 -59
- package/dist/headless.d.cts +10 -9
- package/dist/headless.d.ts +10 -9
- package/dist/headless.js +2 -2
- package/dist/{index-DiCGV60d.d.ts → index-CsG7OQoq.d.cts} +3 -2
- package/dist/{index-CFPmCee4.d.cts → index-h1llgZM-.d.ts} +3 -2
- package/dist/index.cjs +71 -71
- package/dist/index.d.cts +11 -10
- package/dist/index.d.ts +11 -10
- package/dist/index.js +3 -3
- package/dist/math.cjs +7 -7
- package/dist/math.d.cts +5 -4
- package/dist/math.d.ts +5 -4
- package/dist/math.js +5 -5
- package/dist/mention.cjs +7 -7
- package/dist/mention.d.cts +4 -3
- package/dist/mention.d.ts +4 -3
- package/dist/mention.js +5 -5
- package/dist/presence.cjs +33 -33
- package/dist/presence.d.cts +5 -4
- package/dist/presence.d.ts +5 -4
- package/dist/presence.js +5 -5
- package/dist/{registry-CXegaw5k.d.ts → registry-DdQaddP1.d.cts} +2 -1
- package/dist/{registry-CXegaw5k.d.cts → registry-DdQaddP1.d.ts} +2 -1
- package/dist/{stats-extension-DisOEbbI.d.ts → stats-extension-XqOTvRaq.d.cts} +3 -2
- package/dist/{stats-extension-Dt1lgP3m.d.cts → stats-extension-oD6D1cYy.d.ts} +3 -2
- package/dist/stats.cjs +7 -7
- package/dist/stats.d.cts +6 -5
- package/dist/stats.d.ts +6 -5
- package/dist/stats.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/{table-extension-DxZz3jqp.d.cts → table-extension-BP47hHoz.d.cts} +3 -2
- package/dist/{table-extension-BTMJnT7J.d.ts → table-extension-v6VB59bF.d.ts} +3 -2
- package/dist/table.cjs +23 -23
- package/dist/table.d.cts +5 -4
- package/dist/table.d.ts +5 -4
- package/dist/table.js +4 -4
- package/dist/{to-html-CNCITCln.d.cts → to-html-1oD-CDle.d.cts} +3 -2
- package/dist/{to-html-C5t7xyaM.d.ts → to-html-CLRBCX0I.d.ts} +3 -2
- package/dist/{toc-extension-DGHywOBv.d.cts → toc-extension-CI6jNOYl.d.cts} +3 -2
- package/dist/{toc-extension-CR9U-l6j.d.ts → toc-extension-CTHWjNJC.d.ts} +3 -2
- package/dist/toc.cjs +7 -7
- package/dist/toc.d.cts +5 -4
- package/dist/toc.d.ts +5 -4
- package/dist/toc.js +4 -4
- package/dist/{types-C6_QkXzy.d.ts → types-BjLcmV00.d.ts} +3 -26
- package/dist/{types-DULc8wwg.d.ts → types-CQ8Vw_7N.d.cts} +27 -1
- package/dist/{types-DULc8wwg.d.cts → types-CQ8Vw_7N.d.ts} +27 -1
- package/dist/{types-CJ7Gq3GX.d.cts → types-DXF9p4qV.d.cts} +3 -26
- package/dist/{view-controller-zNqHm_Qg.d.ts → view-controller-BfVSNZYZ.d.cts} +4 -3
- package/dist/{view-controller-cxQJ5rQb.d.cts → view-controller-p-2x3J7Y.d.ts} +4 -3
- package/dist/view.d.cts +7 -5
- package/dist/view.d.ts +7 -5
- package/dist/yjs.cjs +99 -99
- package/dist/yjs.d.cts +4 -4
- package/dist/yjs.d.ts +4 -4
- package/dist/yjs.js +3 -3
- package/package.json +19 -18
- package/dist/chunk-35CHEARK.cjs.map +0 -1
- package/dist/chunk-4HFE3YFF.js.map +0 -1
- package/dist/chunk-5ANJW76W.cjs.map +0 -1
- package/dist/chunk-BNUQ647G.js.map +0 -1
- package/dist/chunk-BR25RE7U.js.map +0 -1
- package/dist/chunk-CCOPHCXX.js.map +0 -1
- package/dist/chunk-CZ5ZXBWC.cjs.map +0 -1
- package/dist/chunk-DQV37F7J.cjs.map +0 -1
- package/dist/chunk-FOEEDJ5R.js.map +0 -1
- package/dist/chunk-G37GQ5JE.cjs.map +0 -1
- package/dist/chunk-I7OOIEZZ.js.map +0 -1
- package/dist/chunk-IGEWAL2J.cjs.map +0 -1
- package/dist/chunk-J552D3A7.js.map +0 -1
- package/dist/chunk-KMIWUFNM.cjs.map +0 -1
- package/dist/chunk-KXOAV7AT.js.map +0 -1
- package/dist/chunk-OGBD74IR.cjs.map +0 -1
- package/dist/chunk-SCFW4JFT.cjs.map +0 -1
- package/dist/chunk-Y7UKOBSY.js.map +0 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk65WK575V_cjs = require('./chunk-65WK575V.cjs');
|
|
4
|
+
var chunkQJ34MOFV_cjs = require('./chunk-QJ34MOFV.cjs');
|
|
5
|
+
var chunkVZZPCYA3_cjs = require('./chunk-VZZPCYA3.cjs');
|
|
6
6
|
var chunkWZA5S5EJ_cjs = require('./chunk-WZA5S5EJ.cjs');
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
9
|
var reactDom = require('react-dom');
|
|
10
|
-
var lucideReact = require('lucide-react');
|
|
11
10
|
|
|
12
11
|
// src/engine/commands/table-shape.ts
|
|
13
12
|
var CELL = /^cell:(\d+):(\d+)$/;
|
|
@@ -56,11 +55,11 @@ function followedSelection(selection, blockId, plan) {
|
|
|
56
55
|
if (selection?.kind !== "text") return selection;
|
|
57
56
|
const anchor = followedPos(selection.anchor, blockId, plan);
|
|
58
57
|
const head = followedPos(selection.head, blockId, plan);
|
|
59
|
-
return anchor === selection.anchor && head === selection.head ? selection :
|
|
58
|
+
return anchor === selection.anchor && head === selection.head ? selection : chunkVZZPCYA3_cjs.textSelection(anchor, head);
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
// src/engine/state/cell-selection.ts
|
|
63
|
-
var cellSelectionKey =
|
|
62
|
+
var cellSelectionKey = chunkVZZPCYA3_cjs.createPluginKey("cellSelection");
|
|
64
63
|
function rangeOfSelection({ doc, selection }) {
|
|
65
64
|
if (selection?.kind !== "text") return null;
|
|
66
65
|
const { anchor, head } = selection;
|
|
@@ -99,11 +98,11 @@ function selectCells(blockId, anchor, head) {
|
|
|
99
98
|
const inside = ([row, col]) => isIndex(row, rows) && isIndex(col, cols);
|
|
100
99
|
if (block === null || !inside(anchor) || !inside(head)) return false;
|
|
101
100
|
const end2 = chunkWZA5S5EJ_cjs.cellKey(...head);
|
|
102
|
-
const selection =
|
|
101
|
+
const selection = chunkVZZPCYA3_cjs.textSelection(
|
|
103
102
|
{ block: blockId, region: chunkWZA5S5EJ_cjs.cellKey(...anchor), offset: 0 },
|
|
104
103
|
{ block: blockId, region: end2, offset: chunkWZA5S5EJ_cjs.inlineLength(block.regions[end2] ?? []) }
|
|
105
104
|
);
|
|
106
|
-
dispatch?.(new
|
|
105
|
+
dispatch?.(new chunkVZZPCYA3_cjs.Transaction(state).setSelection(selection));
|
|
107
106
|
return true;
|
|
108
107
|
};
|
|
109
108
|
}
|
|
@@ -121,16 +120,16 @@ function firstCell({ block, anchor, head }) {
|
|
|
121
120
|
return { block, region: chunkWZA5S5EJ_cjs.cellKey(Math.min(anchor[0], head[0]), Math.min(anchor[1], head[1])), offset: 0 };
|
|
122
121
|
}
|
|
123
122
|
function emptied(state, range) {
|
|
124
|
-
const tr = new
|
|
123
|
+
const tr = new chunkVZZPCYA3_cjs.Transaction(state);
|
|
125
124
|
for (const { region, length } of filledCells(state.doc, range)) {
|
|
126
|
-
tr.step(
|
|
125
|
+
tr.step(chunkVZZPCYA3_cjs.replaceInlineStep(range.block, region, 0, length, []));
|
|
127
126
|
}
|
|
128
127
|
return tr;
|
|
129
128
|
}
|
|
130
129
|
var deleteCellContents = (state, dispatch) => {
|
|
131
130
|
const range = cellSelection(state);
|
|
132
131
|
if (range === null) return false;
|
|
133
|
-
dispatch?.(emptied(state, range).setSelection(
|
|
132
|
+
dispatch?.(emptied(state, range).setSelection(chunkVZZPCYA3_cjs.textSelection(firstCell(range))));
|
|
134
133
|
return true;
|
|
135
134
|
};
|
|
136
135
|
function typeOverCells(text) {
|
|
@@ -138,7 +137,7 @@ function typeOverCells(text) {
|
|
|
138
137
|
const range = cellSelection(state);
|
|
139
138
|
if (range === null || text === "") return false;
|
|
140
139
|
const tr = emptied(state, range);
|
|
141
|
-
dispatch?.(tr.setSelection(
|
|
140
|
+
dispatch?.(tr.setSelection(chunkVZZPCYA3_cjs.textSelection(chunkVZZPCYA3_cjs.insertTextAt(tr, state.schema, firstCell(range), text))));
|
|
142
141
|
return true;
|
|
143
142
|
};
|
|
144
143
|
}
|
|
@@ -148,12 +147,12 @@ function setCellsMark(type, attrs) {
|
|
|
148
147
|
const cells = range === null ? [] : filledCells(state.doc, range);
|
|
149
148
|
const regions = range === null ? void 0 : chunkWZA5S5EJ_cjs.blockById(state.doc, range.block)?.regions;
|
|
150
149
|
if (range === null || regions === void 0 || cells.length === 0) return false;
|
|
151
|
-
const carried = cells.every(({ region }) =>
|
|
152
|
-
const mark = carried ?
|
|
153
|
-
const tr = new
|
|
150
|
+
const carried = cells.every(({ region }) => chunkVZZPCYA3_cjs.markCoverage(regions[region], type, attrs).every);
|
|
151
|
+
const mark = carried ? chunkVZZPCYA3_cjs.toggleMark(type, attrs) : chunkVZZPCYA3_cjs.setMark(type, attrs);
|
|
152
|
+
const tr = new chunkVZZPCYA3_cjs.Transaction(state);
|
|
154
153
|
for (const { region, length } of cells) {
|
|
155
154
|
const start = { block: range.block, region, offset: 0 };
|
|
156
|
-
const whole =
|
|
155
|
+
const whole = chunkVZZPCYA3_cjs.textSelection(start, { ...start, offset: length });
|
|
157
156
|
mark({ ...state, doc: tr.doc, selection: whole, storedMarks: null }, (cell) => {
|
|
158
157
|
for (const step of cell.steps) tr.step(step);
|
|
159
158
|
});
|
|
@@ -168,7 +167,7 @@ function setCellsMark(type, attrs) {
|
|
|
168
167
|
var CONTROLS_SLOT = "data-quoin-table-controls";
|
|
169
168
|
var controlsSlot = (controller, blockId) => controller.blockElement(blockId)?.querySelector(`[${CONTROLS_SLOT}]`) ?? null;
|
|
170
169
|
var TableCell = react.memo(function TableCell2({ controller, blockId, row, col, header, align, label }) {
|
|
171
|
-
const inRange =
|
|
170
|
+
const inRange = chunkQJ34MOFV_cjs.useEditorState(
|
|
172
171
|
controller,
|
|
173
172
|
react.useCallback(
|
|
174
173
|
(state) => {
|
|
@@ -187,7 +186,7 @@ var TableCell = react.memo(function TableCell2({ controller, blockId, row, col,
|
|
|
187
186
|
"data-col": col,
|
|
188
187
|
"data-in-range": inRange ? "" : void 0,
|
|
189
188
|
style: align === null ? void 0 : { textAlign: align },
|
|
190
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
189
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(chunkQJ34MOFV_cjs.EditableRegion, { block: blockId, region: chunkWZA5S5EJ_cjs.cellKey(row, col), label, className: "quoin-table-text" })
|
|
191
190
|
}
|
|
192
191
|
);
|
|
193
192
|
});
|
|
@@ -230,7 +229,7 @@ function changeTable(blockId, change, plan) {
|
|
|
230
229
|
const block = tableBlock(state.doc, blockId);
|
|
231
230
|
const next = block && change(block);
|
|
232
231
|
if (!next) return false;
|
|
233
|
-
const tr = new
|
|
232
|
+
const tr = new chunkVZZPCYA3_cjs.Transaction(state).step(chunkVZZPCYA3_cjs.replaceBlockStep(next));
|
|
234
233
|
dispatch?.(plan ? tr.setSelection(followedSelection(state.selection, blockId, plan)) : tr);
|
|
235
234
|
return true;
|
|
236
235
|
};
|
|
@@ -347,11 +346,11 @@ function emptyCells({ rows, cols }) {
|
|
|
347
346
|
function insertTable(rows, cols, options = {}) {
|
|
348
347
|
return (state, dispatch) => {
|
|
349
348
|
const { doc, schema } = state;
|
|
350
|
-
const id =
|
|
349
|
+
const id = chunkVZZPCYA3_cjs.headBlockId(state.selection);
|
|
351
350
|
if (id === null || !isCount(rows) || !isCount(cols)) return false;
|
|
352
351
|
const index = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, id);
|
|
353
352
|
const current = doc.blocks[index];
|
|
354
|
-
const fills =
|
|
353
|
+
const fills = chunkVZZPCYA3_cjs.isParagraph(current) && chunkVZZPCYA3_cjs.regionLength(current, chunkVZZPCYA3_cjs.primaryRegion(schema, current) ?? "") === 0;
|
|
355
354
|
const table = {
|
|
356
355
|
id: fills ? current.id : (options.newId ?? chunkWZA5S5EJ_cjs.newId)(),
|
|
357
356
|
type: "TABLE",
|
|
@@ -359,10 +358,10 @@ function insertTable(rows, cols, options = {}) {
|
|
|
359
358
|
attrs: { header: true, align: Array.from({ length: cols }, () => null), rows, cols },
|
|
360
359
|
regions: emptyCells({ rows, cols })
|
|
361
360
|
};
|
|
362
|
-
const tr = new
|
|
363
|
-
fills ?
|
|
361
|
+
const tr = new chunkVZZPCYA3_cjs.Transaction(state).step(
|
|
362
|
+
fills ? chunkVZZPCYA3_cjs.replaceBlockStep(table) : chunkVZZPCYA3_cjs.insertBlocksStep(chunkVZZPCYA3_cjs.descendantsEnd(doc, index), [table])
|
|
364
363
|
);
|
|
365
|
-
dispatch?.(tr.setSelection(
|
|
364
|
+
dispatch?.(tr.setSelection(chunkVZZPCYA3_cjs.textSelection({ block: table.id, region: chunkWZA5S5EJ_cjs.cellKey(0, 0), offset: 0 })));
|
|
366
365
|
return true;
|
|
367
366
|
};
|
|
368
367
|
}
|
|
@@ -381,9 +380,9 @@ var cellPos = (block, cell, atEnd = false) => ({
|
|
|
381
380
|
region: chunkWZA5S5EJ_cjs.cellKey(...cell),
|
|
382
381
|
offset: atEnd ? cellLength(block, cell) : 0
|
|
383
382
|
});
|
|
384
|
-
var moveTo = (state, pos) => new
|
|
383
|
+
var moveTo = (state, pos) => new chunkVZZPCYA3_cjs.Transaction(state).setSelection(chunkVZZPCYA3_cjs.textSelection(pos));
|
|
385
384
|
var thenCaretIn = (command, blockId, at) => (state, dispatch) => {
|
|
386
|
-
const caret =
|
|
385
|
+
const caret = chunkVZZPCYA3_cjs.textSelection({ block: blockId, region: chunkWZA5S5EJ_cjs.cellKey(...at), offset: 0 });
|
|
387
386
|
return command(state, dispatch && ((tr) => dispatch(tr.setSelection(caret))));
|
|
388
387
|
};
|
|
389
388
|
var cellAtIndex = (index, { cols }) => [Math.floor(index / cols), index % cols];
|
|
@@ -416,11 +415,11 @@ var enterInCell = (state, dispatch) => {
|
|
|
416
415
|
if (row === shape.rows - 1 && cellLength(block, cell) === 0) {
|
|
417
416
|
return thenCaretIn(addRow(block.id, shape.rows), block.id, [shape.rows, col])(state, dispatch);
|
|
418
417
|
}
|
|
419
|
-
return
|
|
418
|
+
return chunkVZZPCYA3_cjs.insertHardBreak(state, dispatch);
|
|
420
419
|
};
|
|
421
420
|
var stopAtCellEdge = (atEnd) => (state) => {
|
|
422
421
|
const caret = headCell(state);
|
|
423
|
-
if (caret === null || !
|
|
422
|
+
if (caret === null || !chunkVZZPCYA3_cjs.isCollapsed(state.selection)) return false;
|
|
424
423
|
return caret.head.offset === (atEnd ? cellLength(caret.block, caret.cell) : 0);
|
|
425
424
|
};
|
|
426
425
|
var firstThatApplies = (...commands) => (state, dispatch) => commands.some((command) => command(state, dispatch));
|
|
@@ -464,7 +463,7 @@ function useCellPress(controller, blockId, table, editable) {
|
|
|
464
463
|
}, [controller, blockId, table, editable]);
|
|
465
464
|
}
|
|
466
465
|
function useRevealCell(controller, blockId) {
|
|
467
|
-
const region =
|
|
466
|
+
const region = chunkQJ34MOFV_cjs.useEditorState(
|
|
468
467
|
controller,
|
|
469
468
|
react.useCallback(
|
|
470
469
|
(state) => {
|
|
@@ -488,20 +487,20 @@ function caretAtGoal(controller, blockId, cell, direction) {
|
|
|
488
487
|
const region = chunkWZA5S5EJ_cjs.cellKey(...cell);
|
|
489
488
|
const host = controller.registry.get(blockId, region);
|
|
490
489
|
const { goalX } = controller;
|
|
491
|
-
const line = host &&
|
|
490
|
+
const line = host && chunkQJ34MOFV_cjs.lineEdgeRect(host, direction < 0);
|
|
492
491
|
if (!host || !line || goalX === null) return null;
|
|
493
492
|
const box = host.getBoundingClientRect();
|
|
494
493
|
const x = Math.min(Math.max(goalX, box.left), box.right - 1);
|
|
495
|
-
const point =
|
|
496
|
-
const pos = point &&
|
|
494
|
+
const point = chunkQJ34MOFV_cjs.caretFromPoint(host.ownerDocument, x, line.top + line.height / 2);
|
|
495
|
+
const pos = point && chunkQJ34MOFV_cjs.domToPos(controller.registry, point.node, point.offset);
|
|
497
496
|
return pos && pos.block === blockId && pos.region === region ? pos : null;
|
|
498
497
|
}
|
|
499
498
|
var plainArrow = (event) => event.altKey || event.ctrlKey || event.metaKey ? void 0 : VERTICAL[event.key];
|
|
500
499
|
function caretOnEdgeLine(controller, head, direction) {
|
|
501
500
|
const host = controller.registry.get(head.block, head.region);
|
|
502
|
-
const point =
|
|
503
|
-
if (!host || !point || !(direction < 0 ?
|
|
504
|
-
return { left:
|
|
501
|
+
const point = chunkQJ34MOFV_cjs.posToDom(controller.registry, head);
|
|
502
|
+
if (!host || !point || !(direction < 0 ? chunkQJ34MOFV_cjs.isOnFirstLine(host, point) : chunkQJ34MOFV_cjs.isOnLastLine(host, point))) return null;
|
|
503
|
+
return { left: chunkQJ34MOFV_cjs.caretClientRect(point)?.left ?? null };
|
|
505
504
|
}
|
|
506
505
|
function columnAt(controller, blockId, row, x) {
|
|
507
506
|
const cells = Array.from(controller.blockElement(blockId)?.querySelector("table")?.rows[row]?.cells ?? []);
|
|
@@ -514,7 +513,7 @@ function enterTable(controller, blockId, event) {
|
|
|
514
513
|
const { selection } = state;
|
|
515
514
|
const block = tableBlock(state.doc, blockId);
|
|
516
515
|
if (direction === void 0 || event.shiftKey || block === null || selection?.kind !== "text") return false;
|
|
517
|
-
if (!
|
|
516
|
+
if (!chunkVZZPCYA3_cjs.isCollapsed(selection) || chunkQJ34MOFV_cjs.neighbourBlock(state.doc, selection.head.block, direction)?.id !== blockId) return false;
|
|
518
517
|
const caret = caretOnEdgeLine(controller, selection.head, direction);
|
|
519
518
|
if (caret === null) return false;
|
|
520
519
|
controller.goalX ??= caret.left;
|
|
@@ -523,7 +522,7 @@ function enterTable(controller, blockId, event) {
|
|
|
523
522
|
const { goalX } = controller;
|
|
524
523
|
const cell = [row, goalX === null ? direction > 0 ? 0 : cols - 1 : columnAt(controller, blockId, row, goalX)];
|
|
525
524
|
const pos = caretAtGoal(controller, blockId, cell, direction) ?? cellPos(block, cell, direction < 0);
|
|
526
|
-
controller.dispatch(controller.editor.createTransaction().setSelection(
|
|
525
|
+
controller.dispatch(controller.editor.createTransaction().setSelection(chunkVZZPCYA3_cjs.textSelection(pos)));
|
|
527
526
|
return true;
|
|
528
527
|
}
|
|
529
528
|
function moveBetweenRows(controller, blockId, event) {
|
|
@@ -539,7 +538,7 @@ function moveBetweenRows(controller, blockId, event) {
|
|
|
539
538
|
if (edge === null) return false;
|
|
540
539
|
controller.goalX ??= edge.left;
|
|
541
540
|
const pos = caretAtGoal(controller, blockId, target, direction) ?? cellPos(caret.block, target, direction < 0);
|
|
542
|
-
const selection = event.shiftKey ?
|
|
541
|
+
const selection = event.shiftKey ? chunkVZZPCYA3_cjs.textSelection(state.selection.anchor, pos) : chunkVZZPCYA3_cjs.textSelection(pos);
|
|
543
542
|
controller.dispatch(controller.editor.createTransaction().setSelection(selection));
|
|
544
543
|
return true;
|
|
545
544
|
}
|
|
@@ -554,17 +553,17 @@ function useTableKeys(controller, blockId, editable) {
|
|
|
554
553
|
react.useEffect(() => {
|
|
555
554
|
if (!editable) return;
|
|
556
555
|
const intercept = (event) => {
|
|
557
|
-
if (
|
|
556
|
+
if (chunkQJ34MOFV_cjs.isComposingKey(controller, event)) return false;
|
|
558
557
|
const handled = typeOver(controller, blockId, event) || moveBetweenRows(controller, blockId, event) || enterTable(controller, blockId, event);
|
|
559
558
|
if (handled) event.preventDefault();
|
|
560
559
|
return handled;
|
|
561
560
|
};
|
|
562
|
-
return
|
|
561
|
+
return chunk65WK575V_cjs.interceptKeys(controller, intercept);
|
|
563
562
|
}, [controller, blockId, editable]);
|
|
564
563
|
}
|
|
565
564
|
var indexes = (from, to) => Array.from({ length: Math.max(to - from, 0) }, (_, i) => from + i);
|
|
566
565
|
function TableBlock({ block, controller, labels }) {
|
|
567
|
-
const readOnly =
|
|
566
|
+
const readOnly = chunkQJ34MOFV_cjs.useReadOnly(controller);
|
|
568
567
|
const table = react.useRef(null);
|
|
569
568
|
const { rows, cols } = tableShape(block);
|
|
570
569
|
const header = block.attrs.header !== false && rows > 0;
|
|
@@ -588,7 +587,7 @@ function TableBlock({ block, controller, labels }) {
|
|
|
588
587
|
col
|
|
589
588
|
)) }, index);
|
|
590
589
|
const scroller = readOnly ? { role: "region", "aria-label": labels.table, tabIndex: 0 } : void 0;
|
|
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 ?
|
|
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 ? chunk65WK575V_cjs.FOCUS_RING : ""}`, ...scroller, children: [
|
|
592
591
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
593
592
|
"table",
|
|
594
593
|
{
|
|
@@ -640,7 +639,7 @@ function ColumnResizer(props) {
|
|
|
640
639
|
if (!controller.readOnly) controller.run(setColumnWidth(blockId, col, px, widths));
|
|
641
640
|
};
|
|
642
641
|
const onKeyDown = (event) => {
|
|
643
|
-
if (
|
|
642
|
+
if (chunkQJ34MOFV_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
644
643
|
const step = event.shiftKey ? LARGE_STEP : STEP;
|
|
645
644
|
const tab = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
646
645
|
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
@@ -695,7 +694,7 @@ function ColumnResizer(props) {
|
|
|
695
694
|
"aria-valuetext": labels.columnWidth(width),
|
|
696
695
|
className: "quoin-table-resizer",
|
|
697
696
|
style,
|
|
698
|
-
...{ [
|
|
697
|
+
...{ [chunkQJ34MOFV_cjs.NATIVE_INTERACTION]: "" },
|
|
699
698
|
onKeyDown,
|
|
700
699
|
onPointerDown,
|
|
701
700
|
onPointerMove,
|
|
@@ -710,20 +709,20 @@ function HandleMenu({ controller, axis, label, style, items, open, onOpenChange,
|
|
|
710
709
|
if (controller.run(item3.command)) controller.announce(item3.done);
|
|
711
710
|
};
|
|
712
711
|
const item2 = (entry) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
713
|
-
|
|
712
|
+
chunk65WK575V_cjs.DropdownMenuItem,
|
|
714
713
|
{
|
|
715
714
|
disabled: entry.disabled,
|
|
716
715
|
className: entry.destructive ? DESTRUCTIVE : void 0,
|
|
717
716
|
onSelect: () => run(entry),
|
|
718
717
|
children: [
|
|
719
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
718
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk65WK575V_cjs.MenuIcon, { icon: entry.icon }),
|
|
720
719
|
entry.label
|
|
721
720
|
]
|
|
722
721
|
},
|
|
723
722
|
entry.id
|
|
724
723
|
);
|
|
725
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
726
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
724
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunk65WK575V_cjs.DropdownMenu, { open, onOpenChange, children: [
|
|
725
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk65WK575V_cjs.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
727
726
|
"button",
|
|
728
727
|
{
|
|
729
728
|
ref: buttonRef,
|
|
@@ -733,22 +732,22 @@ function HandleMenu({ controller, axis, label, style, items, open, onOpenChange,
|
|
|
733
732
|
"data-axis": axis,
|
|
734
733
|
className: "quoin-table-handle",
|
|
735
734
|
style,
|
|
736
|
-
children: axis === "row" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
735
|
+
children: axis === "row" ? /* @__PURE__ */ jsxRuntime.jsx(chunk65WK575V_cjs.GripVertical, { "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntime.jsx(chunk65WK575V_cjs.GripHorizontal, { "aria-hidden": "true" })
|
|
737
736
|
}
|
|
738
737
|
) }),
|
|
739
738
|
open && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
740
|
-
|
|
739
|
+
chunk65WK575V_cjs.DropdownMenuContent,
|
|
741
740
|
{
|
|
742
741
|
align: "start",
|
|
743
742
|
"aria-label": label,
|
|
744
743
|
"aria-labelledby": void 0,
|
|
745
|
-
onCloseAutoFocus:
|
|
746
|
-
...
|
|
744
|
+
onCloseAutoFocus: chunk65WK575V_cjs.returnFocusToText(controller),
|
|
745
|
+
...chunk65WK575V_cjs.bubblePart(controller),
|
|
747
746
|
children: [
|
|
748
747
|
items.filter((entry) => !entry.destructive).map(item2),
|
|
749
748
|
children,
|
|
750
749
|
items.filter((entry) => entry.destructive).map((entry) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
751
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
750
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk65WK575V_cjs.DropdownMenuSeparator, {}),
|
|
752
751
|
item2(entry)
|
|
753
752
|
] }, entry.id))
|
|
754
753
|
]
|
|
@@ -756,35 +755,37 @@ function HandleMenu({ controller, axis, label, style, items, open, onOpenChange,
|
|
|
756
755
|
)
|
|
757
756
|
] });
|
|
758
757
|
}
|
|
758
|
+
|
|
759
|
+
// src/extensions/table/table-menu-items.ts
|
|
759
760
|
var item = (id, label, icon, command, done, options = {}) => ({ id, label, icon, command, done, ...options });
|
|
760
761
|
function rowMenuItems(labels, blockId, row, { rows }) {
|
|
761
762
|
const { rowInserted, rowMoved, rowDeleted } = labels;
|
|
762
763
|
return [
|
|
763
|
-
item("above", labels.insertRowAbove,
|
|
764
|
-
item("below", labels.insertRowBelow,
|
|
765
|
-
item("up", labels.moveRowUp,
|
|
766
|
-
item("down", labels.moveRowDown,
|
|
767
|
-
item("delete", labels.deleteRow,
|
|
764
|
+
item("above", labels.insertRowAbove, chunk65WK575V_cjs.ArrowUpToLine, addRow(blockId, row), rowInserted),
|
|
765
|
+
item("below", labels.insertRowBelow, chunk65WK575V_cjs.ArrowDownToLine, addRow(blockId, row + 1), rowInserted),
|
|
766
|
+
item("up", labels.moveRowUp, chunk65WK575V_cjs.ArrowUp, moveRow(blockId, row, row - 1), rowMoved, { disabled: row === 0 }),
|
|
767
|
+
item("down", labels.moveRowDown, chunk65WK575V_cjs.ArrowDown, moveRow(blockId, row, row + 1), rowMoved, { disabled: row === rows - 1 }),
|
|
768
|
+
item("delete", labels.deleteRow, chunk65WK575V_cjs.Trash, removeRow(blockId, row), rowDeleted, { disabled: rows === 1, destructive: true })
|
|
768
769
|
];
|
|
769
770
|
}
|
|
770
771
|
function columnMenuItems(labels, blockId, col, { cols }) {
|
|
771
772
|
const { columnInserted, columnMoved, columnDeleted } = labels;
|
|
772
773
|
const last = col === cols - 1;
|
|
773
774
|
return [
|
|
774
|
-
item("left", labels.insertColumnLeft,
|
|
775
|
-
item("right", labels.insertColumnRight,
|
|
776
|
-
item("move-left", labels.moveColumnLeft,
|
|
777
|
-
item("move-right", labels.moveColumnRight,
|
|
778
|
-
item("delete", labels.deleteColumn,
|
|
775
|
+
item("left", labels.insertColumnLeft, chunk65WK575V_cjs.ArrowLeftToLine, addColumn(blockId, col), columnInserted),
|
|
776
|
+
item("right", labels.insertColumnRight, chunk65WK575V_cjs.ArrowRightToLine, addColumn(blockId, col + 1), columnInserted),
|
|
777
|
+
item("move-left", labels.moveColumnLeft, chunk65WK575V_cjs.ArrowLeft, moveColumn(blockId, col, col - 1), columnMoved, { disabled: col === 0 }),
|
|
778
|
+
item("move-right", labels.moveColumnRight, chunk65WK575V_cjs.ArrowRight, moveColumn(blockId, col, col + 1), columnMoved, { disabled: last }),
|
|
779
|
+
item("delete", labels.deleteColumn, chunk65WK575V_cjs.Trash, removeColumn(blockId, col), columnDeleted, {
|
|
779
780
|
disabled: cols === 1,
|
|
780
781
|
destructive: true
|
|
781
782
|
})
|
|
782
783
|
];
|
|
783
784
|
}
|
|
784
785
|
var alignItems = (labels) => [
|
|
785
|
-
{ value: "left", label: labels.alignLeft, icon:
|
|
786
|
-
{ value: "center", label: labels.alignCenter, icon:
|
|
787
|
-
{ value: "right", label: labels.alignRight, icon:
|
|
786
|
+
{ value: "left", label: labels.alignLeft, icon: chunk65WK575V_cjs.AlignLeft, done: labels.alignedLeft },
|
|
787
|
+
{ value: "center", label: labels.alignCenter, icon: chunk65WK575V_cjs.AlignCenter, done: labels.alignedCenter },
|
|
788
|
+
{ value: "right", label: labels.alignRight, icon: chunk65WK575V_cjs.AlignRight, done: labels.alignedRight }
|
|
788
789
|
];
|
|
789
790
|
var BESIDE = 4;
|
|
790
791
|
var end = (span) => span.start + span.size;
|
|
@@ -807,7 +808,7 @@ function TableHandles(props) {
|
|
|
807
808
|
const { rowEdge, colEdge } = target;
|
|
808
809
|
const rowInsertAt = edgeOf(geometry.rows, rowEdge);
|
|
809
810
|
const columnInsertAt = edgeOf(geometry.cols, colEdge);
|
|
810
|
-
|
|
811
|
+
chunkQJ34MOFV_cjs.useIsomorphicLayoutEffect(() => {
|
|
811
812
|
if (!focusRequested) return;
|
|
812
813
|
(columnHandle.current ?? rowHandle.current)?.focus();
|
|
813
814
|
onFocused();
|
|
@@ -818,7 +819,7 @@ function TableHandles(props) {
|
|
|
818
819
|
const onKeyDown = (event) => {
|
|
819
820
|
const handles = [rowHandle.current, columnHandle.current].filter((handle) => handle !== null);
|
|
820
821
|
const index = handles.indexOf(event.target);
|
|
821
|
-
if (index === -1 ||
|
|
822
|
+
if (index === -1 || chunkQJ34MOFV_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
822
823
|
if (event.key === "ArrowLeft" || event.key === "ArrowRight") handles[(index + 1) % handles.length].focus();
|
|
823
824
|
else if (isTab(event) && !event.shiftKey && resizer.current !== null) resizer.current.focus();
|
|
824
825
|
else if (isTab(event) || event.key === "Escape") controller.focus();
|
|
@@ -856,7 +857,7 @@ function TableHandles(props) {
|
|
|
856
857
|
onOpenChange: opener("row"),
|
|
857
858
|
buttonRef: rowHandle,
|
|
858
859
|
children: row === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
859
|
-
|
|
860
|
+
chunk65WK575V_cjs.DropdownMenuCheckboxItem,
|
|
860
861
|
{
|
|
861
862
|
checked: block.attrs.header !== false,
|
|
862
863
|
onCheckedChange: (on) => run(toggleHeaderRow(block.id), on ? labels.headerRowOn : labels.headerRowOff),
|
|
@@ -877,14 +878,14 @@ function TableHandles(props) {
|
|
|
877
878
|
onOpenChange: opener("column"),
|
|
878
879
|
buttonRef: columnHandle,
|
|
879
880
|
children: [
|
|
880
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
881
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
882
|
-
|
|
881
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk65WK575V_cjs.DropdownMenuSeparator, {}),
|
|
882
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk65WK575V_cjs.DropdownMenuRadioGroup, { value: align ?? "", children: alignItems(labels).map(({ value, label, icon, done }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
883
|
+
chunk65WK575V_cjs.DropdownMenuRadioItem,
|
|
883
884
|
{
|
|
884
885
|
value,
|
|
885
886
|
onSelect: () => align === value ? run(setColumnAlign(block.id, col, null), labels.alignmentCleared) : run(setColumnAlign(block.id, col, value), done),
|
|
886
887
|
children: [
|
|
887
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
888
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk65WK575V_cjs.MenuIcon, { icon }),
|
|
888
889
|
label
|
|
889
890
|
]
|
|
890
891
|
},
|
|
@@ -903,10 +904,10 @@ function TableHandles(props) {
|
|
|
903
904
|
"data-axis": "row",
|
|
904
905
|
className: "quoin-table-insert",
|
|
905
906
|
style: place(geometry.left - BESIDE, rowInsertAt),
|
|
906
|
-
onPointerDown:
|
|
907
|
-
onMouseDown:
|
|
907
|
+
onPointerDown: chunk65WK575V_cjs.keepFocus,
|
|
908
|
+
onMouseDown: chunk65WK575V_cjs.keepFocus,
|
|
908
909
|
onClick: () => run(addRow(block.id, rowEdge), labels.rowInserted),
|
|
909
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
910
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(chunk65WK575V_cjs.Plus, { "aria-hidden": "true" })
|
|
910
911
|
}
|
|
911
912
|
),
|
|
912
913
|
colEdge !== null && columnInsertAt !== null && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -918,10 +919,10 @@ function TableHandles(props) {
|
|
|
918
919
|
"data-axis": "column",
|
|
919
920
|
className: "quoin-table-insert",
|
|
920
921
|
style: place(columnInsertAt, geometry.top),
|
|
921
|
-
onPointerDown:
|
|
922
|
-
onMouseDown:
|
|
922
|
+
onPointerDown: chunk65WK575V_cjs.keepFocus,
|
|
923
|
+
onMouseDown: chunk65WK575V_cjs.keepFocus,
|
|
923
924
|
onClick: () => run(addColumn(block.id, colEdge), labels.columnInserted),
|
|
924
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
925
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(chunk65WK575V_cjs.Plus, { "aria-hidden": "true" })
|
|
925
926
|
}
|
|
926
927
|
)
|
|
927
928
|
] });
|
|
@@ -962,7 +963,7 @@ function edgeNear(spans, at, reach) {
|
|
|
962
963
|
// src/extensions/table/use-table-geometry.ts
|
|
963
964
|
function useTableGeometry(controller, blockId, slot) {
|
|
964
965
|
const [geometry, setGeometry] = react.useState(null);
|
|
965
|
-
|
|
966
|
+
chunkQJ34MOFV_cjs.useIsomorphicLayoutEffect(() => {
|
|
966
967
|
const table = controller.blockElement(blockId)?.querySelector("table");
|
|
967
968
|
const view = slot.ownerDocument.defaultView;
|
|
968
969
|
if (!table || !view) return;
|
|
@@ -996,7 +997,7 @@ function useCutCells(controller) {
|
|
|
996
997
|
const onCut = (event) => {
|
|
997
998
|
if (controller.readOnly || cellSelection(controller.editor.state) === null) return;
|
|
998
999
|
event.stopPropagation();
|
|
999
|
-
|
|
1000
|
+
chunkQJ34MOFV_cjs.handleCopy(controller, event, false);
|
|
1000
1001
|
controller.run(deleteCellContents);
|
|
1001
1002
|
};
|
|
1002
1003
|
root.addEventListener("cut", onCut, true);
|
|
@@ -1040,9 +1041,9 @@ function focusOf(root) {
|
|
|
1040
1041
|
function useTableTarget(controller, held) {
|
|
1041
1042
|
const [hovered, setHovered] = react.useState(null);
|
|
1042
1043
|
const [focus, setFocus] = react.useState("none");
|
|
1043
|
-
const caret =
|
|
1044
|
+
const caret = chunkQJ34MOFV_cjs.useEditorState(controller, caretTarget, sameTarget);
|
|
1044
1045
|
const hoveredBlock = hovered?.target.block ?? null;
|
|
1045
|
-
const shape =
|
|
1046
|
+
const shape = chunkQJ34MOFV_cjs.useEditorState(
|
|
1046
1047
|
controller,
|
|
1047
1048
|
react.useCallback((state) => hoveredBlock === null ? null : shapeOf(state, hoveredBlock), [hoveredBlock])
|
|
1048
1049
|
);
|
|
@@ -1081,16 +1082,16 @@ function useTableTarget(controller, held) {
|
|
|
1081
1082
|
return pointed ?? (focus === "editor" ? caret : null);
|
|
1082
1083
|
}
|
|
1083
1084
|
var isFocusKey = (event) => event.key === "F10" && event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
1084
|
-
var takesFocusKey = (state) =>
|
|
1085
|
+
var takesFocusKey = (state) => chunkVZZPCYA3_cjs.isCollapsed(state.selection) || cellSelection(state) !== null;
|
|
1085
1086
|
function TableControls({ controller, labels }) {
|
|
1086
|
-
const readOnly =
|
|
1087
|
+
const readOnly = chunkQJ34MOFV_cjs.useReadOnly(controller);
|
|
1087
1088
|
const [held, setHeld] = react.useState(null);
|
|
1088
1089
|
const [focusFor, setFocusFor] = react.useState(null);
|
|
1089
1090
|
const [slot, setSlot] = react.useState(null);
|
|
1090
1091
|
const target = useTableTarget(controller, held?.target ?? null);
|
|
1091
1092
|
useCutCells(controller);
|
|
1092
1093
|
const blockId = target?.block ?? null;
|
|
1093
|
-
const block =
|
|
1094
|
+
const block = chunkQJ34MOFV_cjs.useEditorState(
|
|
1094
1095
|
controller,
|
|
1095
1096
|
react.useCallback((state) => blockId === null ? null : tableBlock(state.doc, blockId), [blockId])
|
|
1096
1097
|
);
|
|
@@ -1107,13 +1108,13 @@ function TableControls({ controller, labels }) {
|
|
|
1107
1108
|
const intercept = (event) => {
|
|
1108
1109
|
const { state } = controller.editor;
|
|
1109
1110
|
const caret = caretTarget(state);
|
|
1110
|
-
if (!isFocusKey(event) ||
|
|
1111
|
+
if (!isFocusKey(event) || chunkQJ34MOFV_cjs.isComposingKey(controller, event) || caret === null || !takesFocusKey(state)) return false;
|
|
1111
1112
|
event.preventDefault();
|
|
1112
1113
|
setHeld({ target: caret, menu: null });
|
|
1113
1114
|
setFocusFor(caret.block);
|
|
1114
1115
|
return true;
|
|
1115
1116
|
};
|
|
1116
|
-
return
|
|
1117
|
+
return chunk65WK575V_cjs.interceptKeys(controller, intercept);
|
|
1117
1118
|
}, [controller, readOnly]);
|
|
1118
1119
|
const onMenu = react.useCallback(
|
|
1119
1120
|
(menu) => setHeld(menu === null || target === null || block === null ? null : { target, menu, opened: block }),
|
|
@@ -1124,7 +1125,7 @@ function TableControls({ controller, labels }) {
|
|
|
1124
1125
|
setFocusFor(null);
|
|
1125
1126
|
setHeld((current) => current?.menu === null ? null : current);
|
|
1126
1127
|
}, []);
|
|
1127
|
-
|
|
1128
|
+
chunkQJ34MOFV_cjs.useIsomorphicLayoutEffect(() => {
|
|
1128
1129
|
const drawn = block === null || readOnly ? null : controlsSlot(controller, block.id);
|
|
1129
1130
|
setSlot((current) => current === drawn ? current : drawn);
|
|
1130
1131
|
});
|
|
@@ -1197,13 +1198,15 @@ function resolveTableLabels(overrides) {
|
|
|
1197
1198
|
const given = Object.entries(overrides ?? {}).filter(([, value]) => value !== void 0);
|
|
1198
1199
|
return given.length === 0 ? englishTableLabels : { ...englishTableLabels, ...Object.fromEntries(given) };
|
|
1199
1200
|
}
|
|
1201
|
+
|
|
1202
|
+
// src/extensions/table/table-slash-item.ts
|
|
1200
1203
|
var NEW_TABLE = { rows: 3, cols: 3 };
|
|
1201
1204
|
var tableSlashItem = (labels) => ({
|
|
1202
1205
|
id: "table",
|
|
1203
1206
|
title: labels.table,
|
|
1204
1207
|
description: labels.tableDescription,
|
|
1205
1208
|
group: "advanced",
|
|
1206
|
-
icon:
|
|
1209
|
+
icon: chunk65WK575V_cjs.Table,
|
|
1207
1210
|
keywords: ["grid", "rows", "columns", "spreadsheet", "|"],
|
|
1208
1211
|
command: () => insertTable(NEW_TABLE.rows, NEW_TABLE.cols)
|
|
1209
1212
|
});
|
|
@@ -1222,7 +1225,7 @@ function tableExtension(options = {}) {
|
|
|
1222
1225
|
blockNames: { TABLE: labels.table },
|
|
1223
1226
|
overlays: [TableOverlay]
|
|
1224
1227
|
};
|
|
1225
|
-
return
|
|
1228
|
+
return chunkVZZPCYA3_cjs.defineExtension({
|
|
1226
1229
|
name: "table",
|
|
1227
1230
|
priority: ABOVE_CORE_KEYS,
|
|
1228
1231
|
plugins: [cellSelectionPlugin],
|
|
@@ -1251,5 +1254,5 @@ exports.setColumnAlign = setColumnAlign;
|
|
|
1251
1254
|
exports.setColumnWidth = setColumnWidth;
|
|
1252
1255
|
exports.tableExtension = tableExtension;
|
|
1253
1256
|
exports.toggleHeaderRow = toggleHeaderRow;
|
|
1254
|
-
//# sourceMappingURL=chunk-
|
|
1255
|
-
//# sourceMappingURL=chunk-
|
|
1257
|
+
//# sourceMappingURL=chunk-7WSBPD6Z.cjs.map
|
|
1258
|
+
//# sourceMappingURL=chunk-7WSBPD6Z.cjs.map
|