quoin-editor 1.2.1 → 1.2.2
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 +11 -0
- package/README.md +15 -5
- package/dist/ai.cjs +66 -66
- package/dist/ai.js +5 -5
- package/dist/catalogue.cjs +20 -20
- package/dist/catalogue.js +12 -12
- package/dist/{chunk-2IY3LET7.js → chunk-25HNTVEI.js} +3 -3
- package/dist/{chunk-2IY3LET7.js.map → chunk-25HNTVEI.js.map} +1 -1
- package/dist/{chunk-YWPFC2PX.cjs → chunk-35CHEARK.cjs} +38 -38
- package/dist/{chunk-YWPFC2PX.cjs.map → chunk-35CHEARK.cjs.map} +1 -1
- package/dist/{chunk-D4ISVKWS.js → chunk-4D7HZRNC.js} +3 -3
- package/dist/{chunk-D4ISVKWS.js.map → chunk-4D7HZRNC.js.map} +1 -1
- package/dist/{chunk-4WRIGF7F.js → chunk-4HFE3YFF.js} +6 -6
- package/dist/{chunk-4WRIGF7F.js.map → chunk-4HFE3YFF.js.map} +1 -1
- package/dist/{chunk-O2VMWE4B.cjs → chunk-5ANJW76W.cjs} +20 -20
- package/dist/{chunk-O2VMWE4B.cjs.map → chunk-5ANJW76W.cjs.map} +1 -1
- package/dist/{chunk-I4KBYVSC.cjs → chunk-A5LIN7FO.cjs} +26 -26
- package/dist/{chunk-I4KBYVSC.cjs.map → chunk-A5LIN7FO.cjs.map} +1 -1
- package/dist/{chunk-EXSNIIOR.cjs → chunk-BJIWN7BQ.cjs} +10 -10
- package/dist/{chunk-EXSNIIOR.cjs.map → chunk-BJIWN7BQ.cjs.map} +1 -1
- package/dist/{chunk-HPQM33PG.js → chunk-BNUQ647G.js} +6 -6
- package/dist/{chunk-HPQM33PG.js.map → chunk-BNUQ647G.js.map} +1 -1
- package/dist/{chunk-535R45JI.js → chunk-BR25RE7U.js} +5 -5
- package/dist/{chunk-535R45JI.js.map → chunk-BR25RE7U.js.map} +1 -1
- package/dist/{chunk-XWKFBLFO.js → chunk-CCOPHCXX.js} +46 -6
- package/dist/chunk-CCOPHCXX.js.map +1 -0
- package/dist/{chunk-YVMPIIMO.cjs → chunk-CZ5ZXBWC.cjs} +224 -225
- package/dist/chunk-CZ5ZXBWC.cjs.map +1 -0
- package/dist/{chunk-WYGSUSZF.cjs → chunk-DQV37F7J.cjs} +66 -66
- package/dist/{chunk-WYGSUSZF.cjs.map → chunk-DQV37F7J.cjs.map} +1 -1
- package/dist/{chunk-3XPVCSFT.js → chunk-FOEEDJ5R.js} +5 -5
- package/dist/{chunk-3XPVCSFT.js.map → chunk-FOEEDJ5R.js.map} +1 -1
- package/dist/{chunk-LROGC3SI.cjs → chunk-G37GQ5JE.cjs} +3 -2
- package/dist/{chunk-LROGC3SI.cjs.map → chunk-G37GQ5JE.cjs.map} +1 -1
- package/dist/{chunk-B3RY7TN2.js → chunk-I7OOIEZZ.js} +5 -5
- package/dist/{chunk-B3RY7TN2.js.map → chunk-I7OOIEZZ.js.map} +1 -1
- package/dist/{chunk-BGPFGNCL.cjs → chunk-IGEWAL2J.cjs} +29 -29
- package/dist/{chunk-BGPFGNCL.cjs.map → chunk-IGEWAL2J.cjs.map} +1 -1
- package/dist/{chunk-O4APV37F.js → chunk-J552D3A7.js} +11 -12
- package/dist/chunk-J552D3A7.js.map +1 -0
- package/dist/{chunk-C4MLW2QA.cjs → chunk-JYKSWEXT.cjs} +6 -6
- package/dist/{chunk-C4MLW2QA.cjs.map → chunk-JYKSWEXT.cjs.map} +1 -1
- package/dist/{chunk-5QLDX75X.cjs → chunk-K7JEN3KT.cjs} +4 -4
- package/dist/{chunk-5QLDX75X.cjs.map → chunk-K7JEN3KT.cjs.map} +1 -1
- package/dist/{chunk-LXSVDRMH.cjs → chunk-KMIWUFNM.cjs} +75 -75
- package/dist/{chunk-LXSVDRMH.cjs.map → chunk-KMIWUFNM.cjs.map} +1 -1
- package/dist/{chunk-4EJ4EGGH.js → chunk-KXOAV7AT.js} +3 -3
- package/dist/{chunk-4EJ4EGGH.js.map → chunk-KXOAV7AT.js.map} +1 -1
- package/dist/{chunk-4SRXM2VS.cjs → chunk-OGBD74IR.cjs} +126 -86
- package/dist/chunk-OGBD74IR.cjs.map +1 -0
- package/dist/{chunk-PX5CFG5J.js → chunk-SAPLIQF2.js} +4 -4
- package/dist/{chunk-PX5CFG5J.js.map → chunk-SAPLIQF2.js.map} +1 -1
- package/dist/{chunk-XT2ZKIYS.cjs → chunk-SCFW4JFT.cjs} +38 -38
- package/dist/{chunk-XT2ZKIYS.cjs.map → chunk-SCFW4JFT.cjs.map} +1 -1
- package/dist/{chunk-XYR7JW23.js → chunk-TARBFPWC.js} +6 -6
- package/dist/{chunk-XYR7JW23.js.map → chunk-TARBFPWC.js.map} +1 -1
- package/dist/{chunk-7GDKCDU4.js → chunk-Y7UKOBSY.js} +5 -5
- package/dist/{chunk-7GDKCDU4.js.map → chunk-Y7UKOBSY.js.map} +1 -1
- package/dist/{chunk-RIGAO2QT.js → chunk-YCVNFRL3.js} +4 -4
- package/dist/{chunk-RIGAO2QT.js.map → chunk-YCVNFRL3.js.map} +1 -1
- package/dist/{chunk-RBYK3RGX.cjs → chunk-ZVCBTQA3.cjs} +10 -10
- package/dist/{chunk-RBYK3RGX.cjs.map → chunk-ZVCBTQA3.cjs.map} +1 -1
- package/dist/comments.cjs +48 -48
- package/dist/comments.js +4 -4
- package/dist/docx.cjs +1 -1
- package/dist/docx.js +1 -1
- package/dist/embed.cjs +6 -6
- package/dist/embed.js +4 -4
- package/dist/emoji.cjs +7 -7
- package/dist/emoji.js +4 -4
- package/dist/engine.cjs +43 -43
- package/dist/engine.js +1 -1
- package/dist/find.cjs +8 -8
- package/dist/find.js +4 -4
- package/dist/headless.cjs +59 -59
- package/dist/headless.d.cts +2 -2
- package/dist/headless.d.ts +2 -2
- package/dist/headless.js +2 -2
- package/dist/index.cjs +71 -71
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/math.cjs +7 -7
- package/dist/math.js +5 -5
- package/dist/mention.cjs +7 -7
- package/dist/mention.js +5 -5
- package/dist/presence.cjs +33 -33
- package/dist/presence.js +5 -5
- package/dist/stats.cjs +7 -7
- package/dist/stats.d.cts +1 -1
- package/dist/stats.d.ts +1 -1
- package/dist/stats.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/table.cjs +23 -23
- package/dist/table.js +4 -4
- package/dist/toc.cjs +7 -7
- package/dist/toc.js +4 -4
- package/dist/{view-controller-BD1KwYfE.d.cts → view-controller-cxQJ5rQb.d.cts} +7 -0
- package/dist/{view-controller-y4cb60ue.d.ts → view-controller-zNqHm_Qg.d.ts} +7 -0
- package/dist/yjs.cjs +99 -99
- package/dist/yjs.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-4SRXM2VS.cjs.map +0 -1
- package/dist/chunk-O4APV37F.js.map +0 -1
- package/dist/chunk-XWKFBLFO.js.map +0 -1
- package/dist/chunk-YVMPIIMO.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkCZ5ZXBWC_cjs = require('./chunk-CZ5ZXBWC.cjs');
|
|
4
|
+
var chunkOGBD74IR_cjs = require('./chunk-OGBD74IR.cjs');
|
|
5
|
+
var chunkG37GQ5JE_cjs = require('./chunk-G37GQ5JE.cjs');
|
|
6
6
|
var chunkWZA5S5EJ_cjs = require('./chunk-WZA5S5EJ.cjs');
|
|
7
7
|
var react = require('react');
|
|
8
8
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -56,11 +56,11 @@ function followedSelection(selection, blockId, plan) {
|
|
|
56
56
|
if (selection?.kind !== "text") return selection;
|
|
57
57
|
const anchor = followedPos(selection.anchor, blockId, plan);
|
|
58
58
|
const head = followedPos(selection.head, blockId, plan);
|
|
59
|
-
return anchor === selection.anchor && head === selection.head ? selection :
|
|
59
|
+
return anchor === selection.anchor && head === selection.head ? selection : chunkG37GQ5JE_cjs.textSelection(anchor, head);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// src/engine/state/cell-selection.ts
|
|
63
|
-
var cellSelectionKey =
|
|
63
|
+
var cellSelectionKey = chunkG37GQ5JE_cjs.createPluginKey("cellSelection");
|
|
64
64
|
function rangeOfSelection({ doc, selection }) {
|
|
65
65
|
if (selection?.kind !== "text") return null;
|
|
66
66
|
const { anchor, head } = selection;
|
|
@@ -99,11 +99,11 @@ function selectCells(blockId, anchor, head) {
|
|
|
99
99
|
const inside = ([row, col]) => isIndex(row, rows) && isIndex(col, cols);
|
|
100
100
|
if (block === null || !inside(anchor) || !inside(head)) return false;
|
|
101
101
|
const end2 = chunkWZA5S5EJ_cjs.cellKey(...head);
|
|
102
|
-
const selection =
|
|
102
|
+
const selection = chunkG37GQ5JE_cjs.textSelection(
|
|
103
103
|
{ block: blockId, region: chunkWZA5S5EJ_cjs.cellKey(...anchor), offset: 0 },
|
|
104
104
|
{ block: blockId, region: end2, offset: chunkWZA5S5EJ_cjs.inlineLength(block.regions[end2] ?? []) }
|
|
105
105
|
);
|
|
106
|
-
dispatch?.(new
|
|
106
|
+
dispatch?.(new chunkG37GQ5JE_cjs.Transaction(state).setSelection(selection));
|
|
107
107
|
return true;
|
|
108
108
|
};
|
|
109
109
|
}
|
|
@@ -121,16 +121,16 @@ function firstCell({ block, anchor, head }) {
|
|
|
121
121
|
return { block, region: chunkWZA5S5EJ_cjs.cellKey(Math.min(anchor[0], head[0]), Math.min(anchor[1], head[1])), offset: 0 };
|
|
122
122
|
}
|
|
123
123
|
function emptied(state, range) {
|
|
124
|
-
const tr = new
|
|
124
|
+
const tr = new chunkG37GQ5JE_cjs.Transaction(state);
|
|
125
125
|
for (const { region, length } of filledCells(state.doc, range)) {
|
|
126
|
-
tr.step(
|
|
126
|
+
tr.step(chunkG37GQ5JE_cjs.replaceInlineStep(range.block, region, 0, length, []));
|
|
127
127
|
}
|
|
128
128
|
return tr;
|
|
129
129
|
}
|
|
130
130
|
var deleteCellContents = (state, dispatch) => {
|
|
131
131
|
const range = cellSelection(state);
|
|
132
132
|
if (range === null) return false;
|
|
133
|
-
dispatch?.(emptied(state, range).setSelection(
|
|
133
|
+
dispatch?.(emptied(state, range).setSelection(chunkG37GQ5JE_cjs.textSelection(firstCell(range))));
|
|
134
134
|
return true;
|
|
135
135
|
};
|
|
136
136
|
function typeOverCells(text) {
|
|
@@ -138,7 +138,7 @@ function typeOverCells(text) {
|
|
|
138
138
|
const range = cellSelection(state);
|
|
139
139
|
if (range === null || text === "") return false;
|
|
140
140
|
const tr = emptied(state, range);
|
|
141
|
-
dispatch?.(tr.setSelection(
|
|
141
|
+
dispatch?.(tr.setSelection(chunkG37GQ5JE_cjs.textSelection(chunkG37GQ5JE_cjs.insertTextAt(tr, state.schema, firstCell(range), text))));
|
|
142
142
|
return true;
|
|
143
143
|
};
|
|
144
144
|
}
|
|
@@ -148,12 +148,12 @@ function setCellsMark(type, attrs) {
|
|
|
148
148
|
const cells = range === null ? [] : filledCells(state.doc, range);
|
|
149
149
|
const regions = range === null ? void 0 : chunkWZA5S5EJ_cjs.blockById(state.doc, range.block)?.regions;
|
|
150
150
|
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
|
|
151
|
+
const carried = cells.every(({ region }) => chunkG37GQ5JE_cjs.markCoverage(regions[region], type, attrs).every);
|
|
152
|
+
const mark = carried ? chunkG37GQ5JE_cjs.toggleMark(type, attrs) : chunkG37GQ5JE_cjs.setMark(type, attrs);
|
|
153
|
+
const tr = new chunkG37GQ5JE_cjs.Transaction(state);
|
|
154
154
|
for (const { region, length } of cells) {
|
|
155
155
|
const start = { block: range.block, region, offset: 0 };
|
|
156
|
-
const whole =
|
|
156
|
+
const whole = chunkG37GQ5JE_cjs.textSelection(start, { ...start, offset: length });
|
|
157
157
|
mark({ ...state, doc: tr.doc, selection: whole, storedMarks: null }, (cell) => {
|
|
158
158
|
for (const step of cell.steps) tr.step(step);
|
|
159
159
|
});
|
|
@@ -168,7 +168,7 @@ function setCellsMark(type, attrs) {
|
|
|
168
168
|
var CONTROLS_SLOT = "data-quoin-table-controls";
|
|
169
169
|
var controlsSlot = (controller, blockId) => controller.blockElement(blockId)?.querySelector(`[${CONTROLS_SLOT}]`) ?? null;
|
|
170
170
|
var TableCell = react.memo(function TableCell2({ controller, blockId, row, col, header, align, label }) {
|
|
171
|
-
const inRange =
|
|
171
|
+
const inRange = chunkOGBD74IR_cjs.useEditorState(
|
|
172
172
|
controller,
|
|
173
173
|
react.useCallback(
|
|
174
174
|
(state) => {
|
|
@@ -187,7 +187,7 @@ var TableCell = react.memo(function TableCell2({ controller, blockId, row, col,
|
|
|
187
187
|
"data-col": col,
|
|
188
188
|
"data-in-range": inRange ? "" : void 0,
|
|
189
189
|
style: align === null ? void 0 : { textAlign: align },
|
|
190
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
190
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(chunkOGBD74IR_cjs.EditableRegion, { block: blockId, region: chunkWZA5S5EJ_cjs.cellKey(row, col), label, className: "quoin-table-text" })
|
|
191
191
|
}
|
|
192
192
|
);
|
|
193
193
|
});
|
|
@@ -230,7 +230,7 @@ function changeTable(blockId, change, plan) {
|
|
|
230
230
|
const block = tableBlock(state.doc, blockId);
|
|
231
231
|
const next = block && change(block);
|
|
232
232
|
if (!next) return false;
|
|
233
|
-
const tr = new
|
|
233
|
+
const tr = new chunkG37GQ5JE_cjs.Transaction(state).step(chunkG37GQ5JE_cjs.replaceBlockStep(next));
|
|
234
234
|
dispatch?.(plan ? tr.setSelection(followedSelection(state.selection, blockId, plan)) : tr);
|
|
235
235
|
return true;
|
|
236
236
|
};
|
|
@@ -347,11 +347,11 @@ function emptyCells({ rows, cols }) {
|
|
|
347
347
|
function insertTable(rows, cols, options = {}) {
|
|
348
348
|
return (state, dispatch) => {
|
|
349
349
|
const { doc, schema } = state;
|
|
350
|
-
const id =
|
|
350
|
+
const id = chunkG37GQ5JE_cjs.headBlockId(state.selection);
|
|
351
351
|
if (id === null || !isCount(rows) || !isCount(cols)) return false;
|
|
352
352
|
const index = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, id);
|
|
353
353
|
const current = doc.blocks[index];
|
|
354
|
-
const fills =
|
|
354
|
+
const fills = chunkG37GQ5JE_cjs.isParagraph(current) && chunkG37GQ5JE_cjs.regionLength(current, chunkG37GQ5JE_cjs.primaryRegion(schema, current) ?? "") === 0;
|
|
355
355
|
const table = {
|
|
356
356
|
id: fills ? current.id : (options.newId ?? chunkWZA5S5EJ_cjs.newId)(),
|
|
357
357
|
type: "TABLE",
|
|
@@ -359,10 +359,10 @@ function insertTable(rows, cols, options = {}) {
|
|
|
359
359
|
attrs: { header: true, align: Array.from({ length: cols }, () => null), rows, cols },
|
|
360
360
|
regions: emptyCells({ rows, cols })
|
|
361
361
|
};
|
|
362
|
-
const tr = new
|
|
363
|
-
fills ?
|
|
362
|
+
const tr = new chunkG37GQ5JE_cjs.Transaction(state).step(
|
|
363
|
+
fills ? chunkG37GQ5JE_cjs.replaceBlockStep(table) : chunkG37GQ5JE_cjs.insertBlocksStep(chunkG37GQ5JE_cjs.descendantsEnd(doc, index), [table])
|
|
364
364
|
);
|
|
365
|
-
dispatch?.(tr.setSelection(
|
|
365
|
+
dispatch?.(tr.setSelection(chunkG37GQ5JE_cjs.textSelection({ block: table.id, region: chunkWZA5S5EJ_cjs.cellKey(0, 0), offset: 0 })));
|
|
366
366
|
return true;
|
|
367
367
|
};
|
|
368
368
|
}
|
|
@@ -381,9 +381,9 @@ var cellPos = (block, cell, atEnd = false) => ({
|
|
|
381
381
|
region: chunkWZA5S5EJ_cjs.cellKey(...cell),
|
|
382
382
|
offset: atEnd ? cellLength(block, cell) : 0
|
|
383
383
|
});
|
|
384
|
-
var moveTo = (state, pos) => new
|
|
384
|
+
var moveTo = (state, pos) => new chunkG37GQ5JE_cjs.Transaction(state).setSelection(chunkG37GQ5JE_cjs.textSelection(pos));
|
|
385
385
|
var thenCaretIn = (command, blockId, at) => (state, dispatch) => {
|
|
386
|
-
const caret =
|
|
386
|
+
const caret = chunkG37GQ5JE_cjs.textSelection({ block: blockId, region: chunkWZA5S5EJ_cjs.cellKey(...at), offset: 0 });
|
|
387
387
|
return command(state, dispatch && ((tr) => dispatch(tr.setSelection(caret))));
|
|
388
388
|
};
|
|
389
389
|
var cellAtIndex = (index, { cols }) => [Math.floor(index / cols), index % cols];
|
|
@@ -416,11 +416,11 @@ var enterInCell = (state, dispatch) => {
|
|
|
416
416
|
if (row === shape.rows - 1 && cellLength(block, cell) === 0) {
|
|
417
417
|
return thenCaretIn(addRow(block.id, shape.rows), block.id, [shape.rows, col])(state, dispatch);
|
|
418
418
|
}
|
|
419
|
-
return
|
|
419
|
+
return chunkG37GQ5JE_cjs.insertHardBreak(state, dispatch);
|
|
420
420
|
};
|
|
421
421
|
var stopAtCellEdge = (atEnd) => (state) => {
|
|
422
422
|
const caret = headCell(state);
|
|
423
|
-
if (caret === null || !
|
|
423
|
+
if (caret === null || !chunkG37GQ5JE_cjs.isCollapsed(state.selection)) return false;
|
|
424
424
|
return caret.head.offset === (atEnd ? cellLength(caret.block, caret.cell) : 0);
|
|
425
425
|
};
|
|
426
426
|
var firstThatApplies = (...commands) => (state, dispatch) => commands.some((command) => command(state, dispatch));
|
|
@@ -464,7 +464,7 @@ function useCellPress(controller, blockId, table, editable) {
|
|
|
464
464
|
}, [controller, blockId, table, editable]);
|
|
465
465
|
}
|
|
466
466
|
function useRevealCell(controller, blockId) {
|
|
467
|
-
const region =
|
|
467
|
+
const region = chunkOGBD74IR_cjs.useEditorState(
|
|
468
468
|
controller,
|
|
469
469
|
react.useCallback(
|
|
470
470
|
(state) => {
|
|
@@ -488,20 +488,20 @@ function caretAtGoal(controller, blockId, cell, direction) {
|
|
|
488
488
|
const region = chunkWZA5S5EJ_cjs.cellKey(...cell);
|
|
489
489
|
const host = controller.registry.get(blockId, region);
|
|
490
490
|
const { goalX } = controller;
|
|
491
|
-
const line = host &&
|
|
491
|
+
const line = host && chunkOGBD74IR_cjs.lineEdgeRect(host, direction < 0);
|
|
492
492
|
if (!host || !line || goalX === null) return null;
|
|
493
493
|
const box = host.getBoundingClientRect();
|
|
494
494
|
const x = Math.min(Math.max(goalX, box.left), box.right - 1);
|
|
495
|
-
const point =
|
|
496
|
-
const pos = point &&
|
|
495
|
+
const point = chunkOGBD74IR_cjs.caretFromPoint(host.ownerDocument, x, line.top + line.height / 2);
|
|
496
|
+
const pos = point && chunkOGBD74IR_cjs.domToPos(controller.registry, point.node, point.offset);
|
|
497
497
|
return pos && pos.block === blockId && pos.region === region ? pos : null;
|
|
498
498
|
}
|
|
499
499
|
var plainArrow = (event) => event.altKey || event.ctrlKey || event.metaKey ? void 0 : VERTICAL[event.key];
|
|
500
500
|
function caretOnEdgeLine(controller, head, direction) {
|
|
501
501
|
const host = controller.registry.get(head.block, head.region);
|
|
502
|
-
const point =
|
|
503
|
-
if (!host || !point || !(direction < 0 ?
|
|
504
|
-
return { left:
|
|
502
|
+
const point = chunkOGBD74IR_cjs.posToDom(controller.registry, head);
|
|
503
|
+
if (!host || !point || !(direction < 0 ? chunkOGBD74IR_cjs.isOnFirstLine(host, point) : chunkOGBD74IR_cjs.isOnLastLine(host, point))) return null;
|
|
504
|
+
return { left: chunkOGBD74IR_cjs.caretClientRect(point)?.left ?? null };
|
|
505
505
|
}
|
|
506
506
|
function columnAt(controller, blockId, row, x) {
|
|
507
507
|
const cells = Array.from(controller.blockElement(blockId)?.querySelector("table")?.rows[row]?.cells ?? []);
|
|
@@ -514,7 +514,7 @@ function enterTable(controller, blockId, event) {
|
|
|
514
514
|
const { selection } = state;
|
|
515
515
|
const block = tableBlock(state.doc, blockId);
|
|
516
516
|
if (direction === void 0 || event.shiftKey || block === null || selection?.kind !== "text") return false;
|
|
517
|
-
if (!
|
|
517
|
+
if (!chunkG37GQ5JE_cjs.isCollapsed(selection) || chunkOGBD74IR_cjs.neighbourBlock(state.doc, selection.head.block, direction)?.id !== blockId) return false;
|
|
518
518
|
const caret = caretOnEdgeLine(controller, selection.head, direction);
|
|
519
519
|
if (caret === null) return false;
|
|
520
520
|
controller.goalX ??= caret.left;
|
|
@@ -523,7 +523,7 @@ function enterTable(controller, blockId, event) {
|
|
|
523
523
|
const { goalX } = controller;
|
|
524
524
|
const cell = [row, goalX === null ? direction > 0 ? 0 : cols - 1 : columnAt(controller, blockId, row, goalX)];
|
|
525
525
|
const pos = caretAtGoal(controller, blockId, cell, direction) ?? cellPos(block, cell, direction < 0);
|
|
526
|
-
controller.dispatch(controller.editor.createTransaction().setSelection(
|
|
526
|
+
controller.dispatch(controller.editor.createTransaction().setSelection(chunkG37GQ5JE_cjs.textSelection(pos)));
|
|
527
527
|
return true;
|
|
528
528
|
}
|
|
529
529
|
function moveBetweenRows(controller, blockId, event) {
|
|
@@ -539,7 +539,7 @@ function moveBetweenRows(controller, blockId, event) {
|
|
|
539
539
|
if (edge === null) return false;
|
|
540
540
|
controller.goalX ??= edge.left;
|
|
541
541
|
const pos = caretAtGoal(controller, blockId, target, direction) ?? cellPos(caret.block, target, direction < 0);
|
|
542
|
-
const selection = event.shiftKey ?
|
|
542
|
+
const selection = event.shiftKey ? chunkG37GQ5JE_cjs.textSelection(state.selection.anchor, pos) : chunkG37GQ5JE_cjs.textSelection(pos);
|
|
543
543
|
controller.dispatch(controller.editor.createTransaction().setSelection(selection));
|
|
544
544
|
return true;
|
|
545
545
|
}
|
|
@@ -554,17 +554,17 @@ function useTableKeys(controller, blockId, editable) {
|
|
|
554
554
|
react.useEffect(() => {
|
|
555
555
|
if (!editable) return;
|
|
556
556
|
const intercept = (event) => {
|
|
557
|
-
if (
|
|
557
|
+
if (chunkOGBD74IR_cjs.isComposingKey(controller, event)) return false;
|
|
558
558
|
const handled = typeOver(controller, blockId, event) || moveBetweenRows(controller, blockId, event) || enterTable(controller, blockId, event);
|
|
559
559
|
if (handled) event.preventDefault();
|
|
560
560
|
return handled;
|
|
561
561
|
};
|
|
562
|
-
return
|
|
562
|
+
return chunkCZ5ZXBWC_cjs.interceptKeys(controller, intercept);
|
|
563
563
|
}, [controller, blockId, editable]);
|
|
564
564
|
}
|
|
565
565
|
var indexes = (from, to) => Array.from({ length: Math.max(to - from, 0) }, (_, i) => from + i);
|
|
566
566
|
function TableBlock({ block, controller, labels }) {
|
|
567
|
-
const readOnly =
|
|
567
|
+
const readOnly = chunkOGBD74IR_cjs.useReadOnly(controller);
|
|
568
568
|
const table = react.useRef(null);
|
|
569
569
|
const { rows, cols } = tableShape(block);
|
|
570
570
|
const header = block.attrs.header !== false && rows > 0;
|
|
@@ -588,7 +588,7 @@ function TableBlock({ block, controller, labels }) {
|
|
|
588
588
|
col
|
|
589
589
|
)) }, index);
|
|
590
590
|
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 ?
|
|
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 ? chunkCZ5ZXBWC_cjs.FOCUS_RING : ""}`, ...scroller, children: [
|
|
592
592
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
593
593
|
"table",
|
|
594
594
|
{
|
|
@@ -640,7 +640,7 @@ function ColumnResizer(props) {
|
|
|
640
640
|
if (!controller.readOnly) controller.run(setColumnWidth(blockId, col, px, widths));
|
|
641
641
|
};
|
|
642
642
|
const onKeyDown = (event) => {
|
|
643
|
-
if (
|
|
643
|
+
if (chunkOGBD74IR_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
644
644
|
const step = event.shiftKey ? LARGE_STEP : STEP;
|
|
645
645
|
const tab = event.key === "Tab" && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
646
646
|
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
|
@@ -695,7 +695,7 @@ function ColumnResizer(props) {
|
|
|
695
695
|
"aria-valuetext": labels.columnWidth(width),
|
|
696
696
|
className: "quoin-table-resizer",
|
|
697
697
|
style,
|
|
698
|
-
...{ [
|
|
698
|
+
...{ [chunkOGBD74IR_cjs.NATIVE_INTERACTION]: "" },
|
|
699
699
|
onKeyDown,
|
|
700
700
|
onPointerDown,
|
|
701
701
|
onPointerMove,
|
|
@@ -710,20 +710,20 @@ function HandleMenu({ controller, axis, label, style, items, open, onOpenChange,
|
|
|
710
710
|
if (controller.run(item3.command)) controller.announce(item3.done);
|
|
711
711
|
};
|
|
712
712
|
const item2 = (entry) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
713
|
-
|
|
713
|
+
chunkCZ5ZXBWC_cjs.DropdownMenuItem,
|
|
714
714
|
{
|
|
715
715
|
disabled: entry.disabled,
|
|
716
716
|
className: entry.destructive ? DESTRUCTIVE : void 0,
|
|
717
717
|
onSelect: () => run(entry),
|
|
718
718
|
children: [
|
|
719
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
719
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkCZ5ZXBWC_cjs.MenuIcon, { icon: entry.icon }),
|
|
720
720
|
entry.label
|
|
721
721
|
]
|
|
722
722
|
},
|
|
723
723
|
entry.id
|
|
724
724
|
);
|
|
725
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
726
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
725
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkCZ5ZXBWC_cjs.DropdownMenu, { open, onOpenChange, children: [
|
|
726
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkCZ5ZXBWC_cjs.DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
727
727
|
"button",
|
|
728
728
|
{
|
|
729
729
|
ref: buttonRef,
|
|
@@ -737,18 +737,18 @@ function HandleMenu({ controller, axis, label, style, items, open, onOpenChange,
|
|
|
737
737
|
}
|
|
738
738
|
) }),
|
|
739
739
|
open && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
740
|
-
|
|
740
|
+
chunkCZ5ZXBWC_cjs.DropdownMenuContent,
|
|
741
741
|
{
|
|
742
742
|
align: "start",
|
|
743
743
|
"aria-label": label,
|
|
744
744
|
"aria-labelledby": void 0,
|
|
745
|
-
onCloseAutoFocus:
|
|
746
|
-
...
|
|
745
|
+
onCloseAutoFocus: chunkCZ5ZXBWC_cjs.returnFocusToText(controller),
|
|
746
|
+
...chunkCZ5ZXBWC_cjs.bubblePart(controller),
|
|
747
747
|
children: [
|
|
748
748
|
items.filter((entry) => !entry.destructive).map(item2),
|
|
749
749
|
children,
|
|
750
750
|
items.filter((entry) => entry.destructive).map((entry) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
751
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
751
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkCZ5ZXBWC_cjs.DropdownMenuSeparator, {}),
|
|
752
752
|
item2(entry)
|
|
753
753
|
] }, entry.id))
|
|
754
754
|
]
|
|
@@ -807,7 +807,7 @@ function TableHandles(props) {
|
|
|
807
807
|
const { rowEdge, colEdge } = target;
|
|
808
808
|
const rowInsertAt = edgeOf(geometry.rows, rowEdge);
|
|
809
809
|
const columnInsertAt = edgeOf(geometry.cols, colEdge);
|
|
810
|
-
|
|
810
|
+
chunkOGBD74IR_cjs.useIsomorphicLayoutEffect(() => {
|
|
811
811
|
if (!focusRequested) return;
|
|
812
812
|
(columnHandle.current ?? rowHandle.current)?.focus();
|
|
813
813
|
onFocused();
|
|
@@ -818,7 +818,7 @@ function TableHandles(props) {
|
|
|
818
818
|
const onKeyDown = (event) => {
|
|
819
819
|
const handles = [rowHandle.current, columnHandle.current].filter((handle) => handle !== null);
|
|
820
820
|
const index = handles.indexOf(event.target);
|
|
821
|
-
if (index === -1 ||
|
|
821
|
+
if (index === -1 || chunkOGBD74IR_cjs.isComposingKey(controller, event.nativeEvent)) return;
|
|
822
822
|
if (event.key === "ArrowLeft" || event.key === "ArrowRight") handles[(index + 1) % handles.length].focus();
|
|
823
823
|
else if (isTab(event) && !event.shiftKey && resizer.current !== null) resizer.current.focus();
|
|
824
824
|
else if (isTab(event) || event.key === "Escape") controller.focus();
|
|
@@ -856,7 +856,7 @@ function TableHandles(props) {
|
|
|
856
856
|
onOpenChange: opener("row"),
|
|
857
857
|
buttonRef: rowHandle,
|
|
858
858
|
children: row === 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
859
|
-
|
|
859
|
+
chunkCZ5ZXBWC_cjs.DropdownMenuCheckboxItem,
|
|
860
860
|
{
|
|
861
861
|
checked: block.attrs.header !== false,
|
|
862
862
|
onCheckedChange: (on) => run(toggleHeaderRow(block.id), on ? labels.headerRowOn : labels.headerRowOff),
|
|
@@ -877,14 +877,14 @@ function TableHandles(props) {
|
|
|
877
877
|
onOpenChange: opener("column"),
|
|
878
878
|
buttonRef: columnHandle,
|
|
879
879
|
children: [
|
|
880
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
881
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
882
|
-
|
|
880
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkCZ5ZXBWC_cjs.DropdownMenuSeparator, {}),
|
|
881
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkCZ5ZXBWC_cjs.DropdownMenuRadioGroup, { value: align ?? "", children: alignItems(labels).map(({ value, label, icon, done }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
882
|
+
chunkCZ5ZXBWC_cjs.DropdownMenuRadioItem,
|
|
883
883
|
{
|
|
884
884
|
value,
|
|
885
885
|
onSelect: () => align === value ? run(setColumnAlign(block.id, col, null), labels.alignmentCleared) : run(setColumnAlign(block.id, col, value), done),
|
|
886
886
|
children: [
|
|
887
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
887
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkCZ5ZXBWC_cjs.MenuIcon, { icon }),
|
|
888
888
|
label
|
|
889
889
|
]
|
|
890
890
|
},
|
|
@@ -903,8 +903,8 @@ function TableHandles(props) {
|
|
|
903
903
|
"data-axis": "row",
|
|
904
904
|
className: "quoin-table-insert",
|
|
905
905
|
style: place(geometry.left - BESIDE, rowInsertAt),
|
|
906
|
-
onPointerDown:
|
|
907
|
-
onMouseDown:
|
|
906
|
+
onPointerDown: chunkCZ5ZXBWC_cjs.keepFocus,
|
|
907
|
+
onMouseDown: chunkCZ5ZXBWC_cjs.keepFocus,
|
|
908
908
|
onClick: () => run(addRow(block.id, rowEdge), labels.rowInserted),
|
|
909
909
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { "aria-hidden": "true" })
|
|
910
910
|
}
|
|
@@ -918,8 +918,8 @@ function TableHandles(props) {
|
|
|
918
918
|
"data-axis": "column",
|
|
919
919
|
className: "quoin-table-insert",
|
|
920
920
|
style: place(columnInsertAt, geometry.top),
|
|
921
|
-
onPointerDown:
|
|
922
|
-
onMouseDown:
|
|
921
|
+
onPointerDown: chunkCZ5ZXBWC_cjs.keepFocus,
|
|
922
|
+
onMouseDown: chunkCZ5ZXBWC_cjs.keepFocus,
|
|
923
923
|
onClick: () => run(addColumn(block.id, colEdge), labels.columnInserted),
|
|
924
924
|
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { "aria-hidden": "true" })
|
|
925
925
|
}
|
|
@@ -962,7 +962,7 @@ function edgeNear(spans, at, reach) {
|
|
|
962
962
|
// src/extensions/table/use-table-geometry.ts
|
|
963
963
|
function useTableGeometry(controller, blockId, slot) {
|
|
964
964
|
const [geometry, setGeometry] = react.useState(null);
|
|
965
|
-
|
|
965
|
+
chunkOGBD74IR_cjs.useIsomorphicLayoutEffect(() => {
|
|
966
966
|
const table = controller.blockElement(blockId)?.querySelector("table");
|
|
967
967
|
const view = slot.ownerDocument.defaultView;
|
|
968
968
|
if (!table || !view) return;
|
|
@@ -996,7 +996,7 @@ function useCutCells(controller) {
|
|
|
996
996
|
const onCut = (event) => {
|
|
997
997
|
if (controller.readOnly || cellSelection(controller.editor.state) === null) return;
|
|
998
998
|
event.stopPropagation();
|
|
999
|
-
|
|
999
|
+
chunkOGBD74IR_cjs.handleCopy(controller, event, false);
|
|
1000
1000
|
controller.run(deleteCellContents);
|
|
1001
1001
|
};
|
|
1002
1002
|
root.addEventListener("cut", onCut, true);
|
|
@@ -1040,9 +1040,9 @@ function focusOf(root) {
|
|
|
1040
1040
|
function useTableTarget(controller, held) {
|
|
1041
1041
|
const [hovered, setHovered] = react.useState(null);
|
|
1042
1042
|
const [focus, setFocus] = react.useState("none");
|
|
1043
|
-
const caret =
|
|
1043
|
+
const caret = chunkOGBD74IR_cjs.useEditorState(controller, caretTarget, sameTarget);
|
|
1044
1044
|
const hoveredBlock = hovered?.target.block ?? null;
|
|
1045
|
-
const shape =
|
|
1045
|
+
const shape = chunkOGBD74IR_cjs.useEditorState(
|
|
1046
1046
|
controller,
|
|
1047
1047
|
react.useCallback((state) => hoveredBlock === null ? null : shapeOf(state, hoveredBlock), [hoveredBlock])
|
|
1048
1048
|
);
|
|
@@ -1081,16 +1081,16 @@ function useTableTarget(controller, held) {
|
|
|
1081
1081
|
return pointed ?? (focus === "editor" ? caret : null);
|
|
1082
1082
|
}
|
|
1083
1083
|
var isFocusKey = (event) => event.key === "F10" && event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey;
|
|
1084
|
-
var takesFocusKey = (state) =>
|
|
1084
|
+
var takesFocusKey = (state) => chunkG37GQ5JE_cjs.isCollapsed(state.selection) || cellSelection(state) !== null;
|
|
1085
1085
|
function TableControls({ controller, labels }) {
|
|
1086
|
-
const readOnly =
|
|
1086
|
+
const readOnly = chunkOGBD74IR_cjs.useReadOnly(controller);
|
|
1087
1087
|
const [held, setHeld] = react.useState(null);
|
|
1088
1088
|
const [focusFor, setFocusFor] = react.useState(null);
|
|
1089
1089
|
const [slot, setSlot] = react.useState(null);
|
|
1090
1090
|
const target = useTableTarget(controller, held?.target ?? null);
|
|
1091
1091
|
useCutCells(controller);
|
|
1092
1092
|
const blockId = target?.block ?? null;
|
|
1093
|
-
const block =
|
|
1093
|
+
const block = chunkOGBD74IR_cjs.useEditorState(
|
|
1094
1094
|
controller,
|
|
1095
1095
|
react.useCallback((state) => blockId === null ? null : tableBlock(state.doc, blockId), [blockId])
|
|
1096
1096
|
);
|
|
@@ -1107,13 +1107,13 @@ function TableControls({ controller, labels }) {
|
|
|
1107
1107
|
const intercept = (event) => {
|
|
1108
1108
|
const { state } = controller.editor;
|
|
1109
1109
|
const caret = caretTarget(state);
|
|
1110
|
-
if (!isFocusKey(event) ||
|
|
1110
|
+
if (!isFocusKey(event) || chunkOGBD74IR_cjs.isComposingKey(controller, event) || caret === null || !takesFocusKey(state)) return false;
|
|
1111
1111
|
event.preventDefault();
|
|
1112
1112
|
setHeld({ target: caret, menu: null });
|
|
1113
1113
|
setFocusFor(caret.block);
|
|
1114
1114
|
return true;
|
|
1115
1115
|
};
|
|
1116
|
-
return
|
|
1116
|
+
return chunkCZ5ZXBWC_cjs.interceptKeys(controller, intercept);
|
|
1117
1117
|
}, [controller, readOnly]);
|
|
1118
1118
|
const onMenu = react.useCallback(
|
|
1119
1119
|
(menu) => setHeld(menu === null || target === null || block === null ? null : { target, menu, opened: block }),
|
|
@@ -1124,7 +1124,7 @@ function TableControls({ controller, labels }) {
|
|
|
1124
1124
|
setFocusFor(null);
|
|
1125
1125
|
setHeld((current) => current?.menu === null ? null : current);
|
|
1126
1126
|
}, []);
|
|
1127
|
-
|
|
1127
|
+
chunkOGBD74IR_cjs.useIsomorphicLayoutEffect(() => {
|
|
1128
1128
|
const drawn = block === null || readOnly ? null : controlsSlot(controller, block.id);
|
|
1129
1129
|
setSlot((current) => current === drawn ? current : drawn);
|
|
1130
1130
|
});
|
|
@@ -1222,7 +1222,7 @@ function tableExtension(options = {}) {
|
|
|
1222
1222
|
blockNames: { TABLE: labels.table },
|
|
1223
1223
|
overlays: [TableOverlay]
|
|
1224
1224
|
};
|
|
1225
|
-
return
|
|
1225
|
+
return chunkG37GQ5JE_cjs.defineExtension({
|
|
1226
1226
|
name: "table",
|
|
1227
1227
|
priority: ABOVE_CORE_KEYS,
|
|
1228
1228
|
plugins: [cellSelectionPlugin],
|
|
@@ -1251,5 +1251,5 @@ exports.setColumnAlign = setColumnAlign;
|
|
|
1251
1251
|
exports.setColumnWidth = setColumnWidth;
|
|
1252
1252
|
exports.tableExtension = tableExtension;
|
|
1253
1253
|
exports.toggleHeaderRow = toggleHeaderRow;
|
|
1254
|
-
//# sourceMappingURL=chunk-
|
|
1255
|
-
//# sourceMappingURL=chunk-
|
|
1254
|
+
//# sourceMappingURL=chunk-KMIWUFNM.cjs.map
|
|
1255
|
+
//# sourceMappingURL=chunk-KMIWUFNM.cjs.map
|