quoin-editor 1.1.2 → 1.2.1
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 +30 -0
- package/dist/ai.cjs +78 -78
- package/dist/ai.js +6 -6
- package/dist/catalogue.cjs +24 -24
- package/dist/catalogue.js +16 -16
- package/dist/{chunk-OIQAO7QU.js → chunk-2IY3LET7.js} +4 -4
- package/dist/{chunk-OIQAO7QU.js.map → chunk-2IY3LET7.js.map} +1 -1
- package/dist/{chunk-EDKQQKQR.js → chunk-3XPVCSFT.js} +6 -6
- package/dist/{chunk-EDKQQKQR.js.map → chunk-3XPVCSFT.js.map} +1 -1
- package/dist/{chunk-IVWFPFUG.js → chunk-4EJ4EGGH.js} +83 -35
- package/dist/chunk-4EJ4EGGH.js.map +1 -0
- package/dist/{chunk-VSUGJZ7G.cjs → chunk-4SRXM2VS.cjs} +161 -136
- package/dist/chunk-4SRXM2VS.cjs.map +1 -0
- package/dist/{chunk-K5HWMBWH.cjs → chunk-4T4TJ2QS.cjs} +9 -9
- package/dist/{chunk-K5HWMBWH.cjs.map → chunk-4T4TJ2QS.cjs.map} +1 -1
- package/dist/{chunk-V2ZBA5VC.js → chunk-4WRIGF7F.js} +8 -8
- package/dist/{chunk-V2ZBA5VC.js.map → chunk-4WRIGF7F.js.map} +1 -1
- package/dist/{chunk-AQNVYFEU.js → chunk-535R45JI.js} +6 -6
- package/dist/{chunk-AQNVYFEU.js.map → chunk-535R45JI.js.map} +1 -1
- package/dist/{chunk-PNMBRBAT.cjs → chunk-5QLDX75X.cjs} +4 -4
- package/dist/{chunk-PNMBRBAT.cjs.map → chunk-5QLDX75X.cjs.map} +1 -1
- package/dist/{chunk-PRXIYHSX.js → chunk-7GDKCDU4.js} +6 -6
- package/dist/{chunk-PRXIYHSX.js.map → chunk-7GDKCDU4.js.map} +1 -1
- package/dist/{chunk-JYO2T4MC.js → chunk-AD3NY7NA.js} +3 -3
- package/dist/{chunk-JYO2T4MC.js.map → chunk-AD3NY7NA.js.map} +1 -1
- package/dist/{chunk-J37ORWSG.js → chunk-B3RY7TN2.js} +7 -7
- package/dist/{chunk-J37ORWSG.js.map → chunk-B3RY7TN2.js.map} +1 -1
- package/dist/{chunk-EABO523V.cjs → chunk-BGPFGNCL.cjs} +31 -31
- package/dist/{chunk-EABO523V.cjs.map → chunk-BGPFGNCL.cjs.map} +1 -1
- package/dist/{chunk-QLDXQOHQ.js → chunk-BJTOLCRR.js} +7 -4
- package/dist/{chunk-QLDXQOHQ.js.map → chunk-BJTOLCRR.js.map} +1 -1
- package/dist/{chunk-OAAYF2EI.cjs → chunk-BM2GRZNM.cjs} +47 -30
- package/dist/chunk-BM2GRZNM.cjs.map +1 -0
- package/dist/{chunk-5LWJDRWD.js → chunk-BXSWZEA5.js} +3 -3
- package/dist/{chunk-5LWJDRWD.js.map → chunk-BXSWZEA5.js.map} +1 -1
- package/dist/{chunk-KFIE4OJE.cjs → chunk-C4MLW2QA.cjs} +15 -15
- package/dist/{chunk-KFIE4OJE.cjs.map → chunk-C4MLW2QA.cjs.map} +1 -1
- package/dist/{chunk-3G4ZWUUY.js → chunk-CSKKSXCE.js} +38 -19
- package/dist/chunk-CSKKSXCE.js.map +1 -0
- package/dist/{chunk-ZEQXMRJW.js → chunk-D4ISVKWS.js} +3 -3
- package/dist/{chunk-ZEQXMRJW.js.map → chunk-D4ISVKWS.js.map} +1 -1
- package/dist/{chunk-UGAOEZ3O.cjs → chunk-EXSNIIOR.cjs} +15 -15
- package/dist/{chunk-UGAOEZ3O.cjs.map → chunk-EXSNIIOR.cjs.map} +1 -1
- package/dist/{chunk-RUC5OZXO.js → chunk-GHNQKJMD.js} +3 -3
- package/dist/{chunk-RUC5OZXO.js.map → chunk-GHNQKJMD.js.map} +1 -1
- package/dist/{chunk-E52VO5JT.cjs → chunk-H3C3MJW5.cjs} +4 -4
- package/dist/{chunk-E52VO5JT.cjs.map → chunk-H3C3MJW5.cjs.map} +1 -1
- package/dist/{chunk-36OSSZDK.js → chunk-HPQM33PG.js} +6 -6
- package/dist/{chunk-36OSSZDK.js.map → chunk-HPQM33PG.js.map} +1 -1
- package/dist/{chunk-5DEPLPDS.cjs → chunk-I4KBYVSC.cjs} +28 -28
- package/dist/{chunk-5DEPLPDS.cjs.map → chunk-I4KBYVSC.cjs.map} +1 -1
- package/dist/{chunk-M5FREXRQ.cjs → chunk-LROGC3SI.cjs} +295 -245
- package/dist/chunk-LROGC3SI.cjs.map +1 -0
- package/dist/{chunk-XJ32XESJ.cjs → chunk-LXSVDRMH.cjs} +98 -98
- package/dist/{chunk-XJ32XESJ.cjs.map → chunk-LXSVDRMH.cjs.map} +1 -1
- package/dist/{chunk-KKRQDVBJ.cjs → chunk-O2VMWE4B.cjs} +24 -24
- package/dist/{chunk-KKRQDVBJ.cjs.map → chunk-O2VMWE4B.cjs.map} +1 -1
- package/dist/{chunk-JEFQNZO4.js → chunk-O4APV37F.js} +7 -7
- package/dist/{chunk-JEFQNZO4.js.map → chunk-O4APV37F.js.map} +1 -1
- package/dist/{chunk-5QNNF5ZJ.js → chunk-PX5CFG5J.js} +5 -5
- package/dist/{chunk-5QNNF5ZJ.js.map → chunk-PX5CFG5J.js.map} +1 -1
- package/dist/{chunk-BMEEEI43.cjs → chunk-RBYK3RGX.cjs} +13 -13
- package/dist/{chunk-BMEEEI43.cjs.map → chunk-RBYK3RGX.cjs.map} +1 -1
- package/dist/{chunk-JHA23OOK.js → chunk-RIGAO2QT.js} +6 -6
- package/dist/{chunk-JHA23OOK.js.map → chunk-RIGAO2QT.js.map} +1 -1
- package/dist/{chunk-6QLA3JOU.cjs → chunk-WYGSUSZF.cjs} +90 -90
- package/dist/{chunk-6QLA3JOU.cjs.map → chunk-WYGSUSZF.cjs.map} +1 -1
- package/dist/{chunk-6H76FAI3.cjs → chunk-WZA5S5EJ.cjs} +7 -4
- package/dist/{chunk-6H76FAI3.cjs.map → chunk-WZA5S5EJ.cjs.map} +1 -1
- package/dist/{chunk-ES2QYHXL.cjs → chunk-XT2ZKIYS.cjs} +45 -45
- package/dist/{chunk-ES2QYHXL.cjs.map → chunk-XT2ZKIYS.cjs.map} +1 -1
- package/dist/{chunk-G7HK4OHE.js → chunk-XWKFBLFO.js} +49 -24
- package/dist/chunk-XWKFBLFO.js.map +1 -0
- package/dist/{chunk-ZPGA5UIY.js → chunk-XYR7JW23.js} +7 -7
- package/dist/{chunk-ZPGA5UIY.js.map → chunk-XYR7JW23.js.map} +1 -1
- package/dist/{chunk-P3T5XBYW.cjs → chunk-XZ4NC3Q7.cjs} +6 -6
- package/dist/{chunk-P3T5XBYW.cjs.map → chunk-XZ4NC3Q7.cjs.map} +1 -1
- package/dist/{chunk-ABVSP2XR.cjs → chunk-YVMPIIMO.cjs} +292 -292
- package/dist/{chunk-ABVSP2XR.cjs.map → chunk-YVMPIIMO.cjs.map} +1 -1
- package/dist/{chunk-QAI3CM7V.cjs → chunk-YWPFC2PX.cjs} +55 -55
- package/dist/{chunk-QAI3CM7V.cjs.map → chunk-YWPFC2PX.cjs.map} +1 -1
- package/dist/comments.cjs +58 -58
- package/dist/comments.js +7 -7
- package/dist/diff.cjs +29 -32
- package/dist/diff.cjs.map +1 -1
- package/dist/diff.js +8 -11
- package/dist/diff.js.map +1 -1
- package/dist/docx.cjs +30 -30
- package/dist/docx.js +3 -3
- package/dist/embed.cjs +9 -9
- package/dist/embed.js +7 -7
- package/dist/emoji.cjs +9 -9
- package/dist/emoji.js +6 -6
- package/dist/engine.cjs +58 -58
- package/dist/engine.d.cts +4 -1
- package/dist/engine.d.ts +4 -1
- package/dist/engine.js +3 -3
- package/dist/find.cjs +10 -10
- package/dist/find.js +6 -6
- package/dist/headless.cjs +74 -74
- package/dist/headless.js +4 -4
- package/dist/index.cjs +86 -86
- package/dist/index.js +5 -5
- package/dist/math.cjs +10 -10
- package/dist/math.js +8 -8
- package/dist/mention.cjs +10 -10
- package/dist/mention.js +8 -8
- package/dist/presence.cjs +38 -38
- package/dist/presence.js +7 -7
- package/dist/stats.cjs +10 -10
- package/dist/stats.js +7 -7
- package/dist/styles.css +1 -1
- package/dist/table.cjs +25 -25
- package/dist/table.js +6 -6
- package/dist/toc.cjs +9 -9
- package/dist/toc.js +6 -6
- package/dist/view.cjs +4 -4
- package/dist/view.js +2 -2
- package/dist/yjs.cjs +125 -120
- package/dist/yjs.cjs.map +1 -1
- package/dist/yjs.js +11 -6
- package/dist/yjs.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3G4ZWUUY.js.map +0 -1
- package/dist/chunk-G7HK4OHE.js.map +0 -1
- package/dist/chunk-IVWFPFUG.js.map +0 -1
- package/dist/chunk-M5FREXRQ.cjs.map +0 -1
- package/dist/chunk-OAAYF2EI.cjs.map +0 -1
- package/dist/chunk-VSUGJZ7G.cjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunkYVMPIIMO_cjs = require('./chunk-YVMPIIMO.cjs');
|
|
4
|
+
var chunk4SRXM2VS_cjs = require('./chunk-4SRXM2VS.cjs');
|
|
5
|
+
var chunkLROGC3SI_cjs = require('./chunk-LROGC3SI.cjs');
|
|
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');
|
|
@@ -12,8 +12,8 @@ var lucideReact = require('lucide-react');
|
|
|
12
12
|
// src/engine/commands/table-shape.ts
|
|
13
13
|
var CELL = /^cell:(\d+):(\d+)$/;
|
|
14
14
|
var tableShape = (block) => ({
|
|
15
|
-
rows:
|
|
16
|
-
cols:
|
|
15
|
+
rows: chunkWZA5S5EJ_cjs.countOf(block.attrs.rows),
|
|
16
|
+
cols: chunkWZA5S5EJ_cjs.countOf(block.attrs.cols)
|
|
17
17
|
});
|
|
18
18
|
var ALIGNS = ["left", "center", "right"];
|
|
19
19
|
var columnAligns = (block, cols) => Array.from({ length: cols }, (_, col) => {
|
|
@@ -27,7 +27,7 @@ function cellOf(region) {
|
|
|
27
27
|
return match === null ? null : [Number(match[1]), Number(match[2])];
|
|
28
28
|
}
|
|
29
29
|
function tableBlock(doc, id) {
|
|
30
|
-
const block =
|
|
30
|
+
const block = chunkWZA5S5EJ_cjs.blockById(doc, id);
|
|
31
31
|
return block?.type === "TABLE" ? block : null;
|
|
32
32
|
}
|
|
33
33
|
var isIndex = (index, length) => Number.isInteger(index) && index >= 0 && index < length;
|
|
@@ -41,7 +41,7 @@ function rebuiltTable(block, plan) {
|
|
|
41
41
|
for (let row = 0; row < plan.rows; row++) {
|
|
42
42
|
for (let col = 0; col < plan.cols; col++) {
|
|
43
43
|
const from = plan.source(row, col);
|
|
44
|
-
regions[
|
|
44
|
+
regions[chunkWZA5S5EJ_cjs.cellKey(row, col)] = from === null ? [] : block.regions[chunkWZA5S5EJ_cjs.cellKey(...from)] ?? [];
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
return { ...block, attrs: { ...block.attrs, ...plan.attrs, rows: plan.rows, cols: plan.cols }, regions };
|
|
@@ -50,17 +50,17 @@ function followedPos(pos, blockId, plan) {
|
|
|
50
50
|
const cell = pos.block === blockId ? cellOf(pos.region) : null;
|
|
51
51
|
if (cell === null) return pos;
|
|
52
52
|
const moved = plan.target(cell);
|
|
53
|
-
return moved === null ? { block: blockId, region:
|
|
53
|
+
return moved === null ? { block: blockId, region: chunkWZA5S5EJ_cjs.cellKey(...plan.landing(cell)), offset: 0 } : { ...pos, region: chunkWZA5S5EJ_cjs.cellKey(...moved) };
|
|
54
54
|
}
|
|
55
55
|
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 : chunkLROGC3SI_cjs.textSelection(anchor, head);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// src/engine/state/cell-selection.ts
|
|
63
|
-
var cellSelectionKey =
|
|
63
|
+
var cellSelectionKey = chunkLROGC3SI_cjs.createPluginKey("cellSelection");
|
|
64
64
|
function rangeOfSelection({ doc, selection }) {
|
|
65
65
|
if (selection?.kind !== "text") return null;
|
|
66
66
|
const { anchor, head } = selection;
|
|
@@ -98,39 +98,39 @@ function selectCells(blockId, anchor, head) {
|
|
|
98
98
|
const { rows, cols } = block === null ? { rows: 0, cols: 0 } : tableShape(block);
|
|
99
99
|
const inside = ([row, col]) => isIndex(row, rows) && isIndex(col, cols);
|
|
100
100
|
if (block === null || !inside(anchor) || !inside(head)) return false;
|
|
101
|
-
const end2 =
|
|
102
|
-
const selection =
|
|
103
|
-
{ block: blockId, region:
|
|
104
|
-
{ block: blockId, region: end2, offset:
|
|
101
|
+
const end2 = chunkWZA5S5EJ_cjs.cellKey(...head);
|
|
102
|
+
const selection = chunkLROGC3SI_cjs.textSelection(
|
|
103
|
+
{ block: blockId, region: chunkWZA5S5EJ_cjs.cellKey(...anchor), offset: 0 },
|
|
104
|
+
{ block: blockId, region: end2, offset: chunkWZA5S5EJ_cjs.inlineLength(block.regions[end2] ?? []) }
|
|
105
105
|
);
|
|
106
|
-
dispatch?.(new
|
|
106
|
+
dispatch?.(new chunkLROGC3SI_cjs.Transaction(state).setSelection(selection));
|
|
107
107
|
return true;
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
// src/engine/commands/cell-commands.ts
|
|
112
112
|
function filledCells(doc, range) {
|
|
113
|
-
const regions =
|
|
113
|
+
const regions = chunkWZA5S5EJ_cjs.blockById(doc, range.block)?.regions ?? {};
|
|
114
114
|
return cellsInRange(range).flatMap((cell) => {
|
|
115
|
-
const region =
|
|
116
|
-
const length =
|
|
115
|
+
const region = chunkWZA5S5EJ_cjs.cellKey(...cell);
|
|
116
|
+
const length = chunkWZA5S5EJ_cjs.inlineLength(regions[region] ?? []);
|
|
117
117
|
return length > 0 ? [{ region, length }] : [];
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
120
|
function firstCell({ block, anchor, head }) {
|
|
121
|
-
return { block, region:
|
|
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 chunkLROGC3SI_cjs.Transaction(state);
|
|
125
125
|
for (const { region, length } of filledCells(state.doc, range)) {
|
|
126
|
-
tr.step(
|
|
126
|
+
tr.step(chunkLROGC3SI_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(chunkLROGC3SI_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(chunkLROGC3SI_cjs.textSelection(chunkLROGC3SI_cjs.insertTextAt(tr, state.schema, firstCell(range), text))));
|
|
142
142
|
return true;
|
|
143
143
|
};
|
|
144
144
|
}
|
|
@@ -146,14 +146,14 @@ function setCellsMark(type, attrs) {
|
|
|
146
146
|
return (state, dispatch) => {
|
|
147
147
|
const range = cellSelection(state);
|
|
148
148
|
const cells = range === null ? [] : filledCells(state.doc, range);
|
|
149
|
-
const regions = range === null ? void 0 :
|
|
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 }) => chunkLROGC3SI_cjs.markCoverage(regions[region], type, attrs).every);
|
|
152
|
+
const mark = carried ? chunkLROGC3SI_cjs.toggleMark(type, attrs) : chunkLROGC3SI_cjs.setMark(type, attrs);
|
|
153
|
+
const tr = new chunkLROGC3SI_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 = chunkLROGC3SI_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 = chunk4SRXM2VS_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(chunk4SRXM2VS_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 chunkLROGC3SI_cjs.Transaction(state).step(chunkLROGC3SI_cjs.replaceBlockStep(next));
|
|
234
234
|
dispatch?.(plan ? tr.setSelection(followedSelection(state.selection, blockId, plan)) : tr);
|
|
235
235
|
return true;
|
|
236
236
|
};
|
|
@@ -341,28 +341,28 @@ var setColumnWidth = (blockId, col, px, drawn) => changeTable(blockId, (block) =
|
|
|
341
341
|
var isCount = (value) => Number.isInteger(value) && value > 0;
|
|
342
342
|
function emptyCells({ rows, cols }) {
|
|
343
343
|
const regions = {};
|
|
344
|
-
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[chunkWZA5S5EJ_cjs.cellKey(row, col)] = [];
|
|
345
345
|
return regions;
|
|
346
346
|
}
|
|
347
347
|
function insertTable(rows, cols, options = {}) {
|
|
348
348
|
return (state, dispatch) => {
|
|
349
349
|
const { doc, schema } = state;
|
|
350
|
-
const id =
|
|
350
|
+
const id = chunkLROGC3SI_cjs.headBlockId(state.selection);
|
|
351
351
|
if (id === null || !isCount(rows) || !isCount(cols)) return false;
|
|
352
|
-
const index =
|
|
352
|
+
const index = chunkWZA5S5EJ_cjs.requireBlockIndex(doc, id);
|
|
353
353
|
const current = doc.blocks[index];
|
|
354
|
-
const fills =
|
|
354
|
+
const fills = chunkLROGC3SI_cjs.isParagraph(current) && chunkLROGC3SI_cjs.regionLength(current, chunkLROGC3SI_cjs.primaryRegion(schema, current) ?? "") === 0;
|
|
355
355
|
const table = {
|
|
356
|
-
id: fills ? current.id : (options.newId ??
|
|
356
|
+
id: fills ? current.id : (options.newId ?? chunkWZA5S5EJ_cjs.newId)(),
|
|
357
357
|
type: "TABLE",
|
|
358
358
|
indent: current.indent,
|
|
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 chunkLROGC3SI_cjs.Transaction(state).step(
|
|
363
|
+
fills ? chunkLROGC3SI_cjs.replaceBlockStep(table) : chunkLROGC3SI_cjs.insertBlocksStep(chunkLROGC3SI_cjs.descendantsEnd(doc, index), [table])
|
|
364
364
|
);
|
|
365
|
-
dispatch?.(tr.setSelection(
|
|
365
|
+
dispatch?.(tr.setSelection(chunkLROGC3SI_cjs.textSelection({ block: table.id, region: chunkWZA5S5EJ_cjs.cellKey(0, 0), offset: 0 })));
|
|
366
366
|
return true;
|
|
367
367
|
};
|
|
368
368
|
}
|
|
@@ -375,15 +375,15 @@ function headCell({ doc, selection }) {
|
|
|
375
375
|
const cell = block && cellOf(head.region);
|
|
376
376
|
return block && cell ? { block, cell, head, shape: tableShape(block) } : null;
|
|
377
377
|
}
|
|
378
|
-
var cellLength = (block, [row, col]) =>
|
|
378
|
+
var cellLength = (block, [row, col]) => chunkWZA5S5EJ_cjs.inlineLength(block.regions[chunkWZA5S5EJ_cjs.cellKey(row, col)] ?? []);
|
|
379
379
|
var cellPos = (block, cell, atEnd = false) => ({
|
|
380
380
|
block: block.id,
|
|
381
|
-
region:
|
|
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 chunkLROGC3SI_cjs.Transaction(state).setSelection(chunkLROGC3SI_cjs.textSelection(pos));
|
|
385
385
|
var thenCaretIn = (command, blockId, at) => (state, dispatch) => {
|
|
386
|
-
const caret =
|
|
386
|
+
const caret = chunkLROGC3SI_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 chunkLROGC3SI_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 || !chunkLROGC3SI_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));
|
|
@@ -453,7 +453,7 @@ function useCellPress(controller, blockId, table, editable) {
|
|
|
453
453
|
if (!editable || element === null) return;
|
|
454
454
|
const onPointerDown = (event) => {
|
|
455
455
|
const cell = event.button === 0 && event.pointerType !== "touch" ? cellOf2(event.target) : null;
|
|
456
|
-
const block = cell &&
|
|
456
|
+
const block = cell && chunkWZA5S5EJ_cjs.blockById(controller.editor.state.doc, blockId);
|
|
457
457
|
if (!cell || !block) return;
|
|
458
458
|
event.preventDefault();
|
|
459
459
|
event.stopPropagation();
|
|
@@ -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 = chunk4SRXM2VS_cjs.useEditorState(
|
|
468
468
|
controller,
|
|
469
469
|
react.useCallback(
|
|
470
470
|
(state) => {
|
|
@@ -485,23 +485,23 @@ function useRevealCell(controller, blockId) {
|
|
|
485
485
|
// src/extensions/table/vertical-cell-move.ts
|
|
486
486
|
var VERTICAL = { ArrowUp: -1, ArrowDown: 1 };
|
|
487
487
|
function caretAtGoal(controller, blockId, cell, direction) {
|
|
488
|
-
const region =
|
|
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 && chunk4SRXM2VS_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 = chunk4SRXM2VS_cjs.caretFromPoint(host.ownerDocument, x, line.top + line.height / 2);
|
|
496
|
+
const pos = point && chunk4SRXM2VS_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 = chunk4SRXM2VS_cjs.posToDom(controller.registry, head);
|
|
503
|
+
if (!host || !point || !(direction < 0 ? chunk4SRXM2VS_cjs.isOnFirstLine(host, point) : chunk4SRXM2VS_cjs.isOnLastLine(host, point))) return null;
|
|
504
|
+
return { left: chunk4SRXM2VS_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 (!chunkLROGC3SI_cjs.isCollapsed(selection) || chunk4SRXM2VS_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(chunkLROGC3SI_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 ? chunkLROGC3SI_cjs.textSelection(state.selection.anchor, pos) : chunkLROGC3SI_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 (chunk4SRXM2VS_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 chunkYVMPIIMO_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 = chunk4SRXM2VS_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 ? chunkYVMPIIMO_cjs.FOCUS_RING : ""}`, ...scroller, children: [
|
|
592
592
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
593
593
|
"table",
|
|
594
594
|
{
|
|
@@ -612,10 +612,10 @@ function lineCells(block, index, axis) {
|
|
|
612
612
|
const { rows, cols } = tableShape(block);
|
|
613
613
|
return Array.from(
|
|
614
614
|
{ length: axis === "row" ? cols : rows },
|
|
615
|
-
(_, other) => axis === "row" ? block.regions[
|
|
615
|
+
(_, other) => axis === "row" ? block.regions[chunkWZA5S5EJ_cjs.cellKey(index, other)] ?? EMPTY : block.regions[chunkWZA5S5EJ_cjs.cellKey(other, index)] ?? EMPTY
|
|
616
616
|
);
|
|
617
617
|
}
|
|
618
|
-
var sameLine = (before, after, index, axis) =>
|
|
618
|
+
var sameLine = (before, after, index, axis) => chunkWZA5S5EJ_cjs.sameItems(lineCells(before, index, axis), lineCells(after, index, axis), chunkWZA5S5EJ_cjs.equalInline);
|
|
619
619
|
function sameMenuCells(opened, current, target, axis) {
|
|
620
620
|
const shape = tableShape(opened);
|
|
621
621
|
const lines = axis === "row" ? shape.rows : shape.cols;
|
|
@@ -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 (chunk4SRXM2VS_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
|
+
...{ [chunk4SRXM2VS_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
|
+
chunkYVMPIIMO_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(chunkYVMPIIMO_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(chunkYVMPIIMO_cjs.DropdownMenu, { open, onOpenChange, children: [
|
|
726
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkYVMPIIMO_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
|
+
chunkYVMPIIMO_cjs.DropdownMenuContent,
|
|
741
741
|
{
|
|
742
742
|
align: "start",
|
|
743
743
|
"aria-label": label,
|
|
744
744
|
"aria-labelledby": void 0,
|
|
745
|
-
onCloseAutoFocus:
|
|
746
|
-
...
|
|
745
|
+
onCloseAutoFocus: chunkYVMPIIMO_cjs.returnFocusToText(controller),
|
|
746
|
+
...chunkYVMPIIMO_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(chunkYVMPIIMO_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
|
+
chunk4SRXM2VS_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 || chunk4SRXM2VS_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
|
+
chunkYVMPIIMO_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(chunkYVMPIIMO_cjs.DropdownMenuSeparator, {}),
|
|
881
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkYVMPIIMO_cjs.DropdownMenuRadioGroup, { value: align ?? "", children: alignItems(labels).map(({ value, label, icon, done }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
882
|
+
chunkYVMPIIMO_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(chunkYVMPIIMO_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: chunkYVMPIIMO_cjs.keepFocus,
|
|
907
|
+
onMouseDown: chunkYVMPIIMO_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: chunkYVMPIIMO_cjs.keepFocus,
|
|
922
|
+
onMouseDown: chunkYVMPIIMO_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
|
+
chunk4SRXM2VS_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
|
+
chunk4SRXM2VS_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 = chunk4SRXM2VS_cjs.useEditorState(controller, caretTarget, sameTarget);
|
|
1044
1044
|
const hoveredBlock = hovered?.target.block ?? null;
|
|
1045
|
-
const shape =
|
|
1045
|
+
const shape = chunk4SRXM2VS_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) => chunkLROGC3SI_cjs.isCollapsed(state.selection) || cellSelection(state) !== null;
|
|
1085
1085
|
function TableControls({ controller, labels }) {
|
|
1086
|
-
const readOnly =
|
|
1086
|
+
const readOnly = chunk4SRXM2VS_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 = chunk4SRXM2VS_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) || chunk4SRXM2VS_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 chunkYVMPIIMO_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
|
+
chunk4SRXM2VS_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 chunkLROGC3SI_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-LXSVDRMH.cjs.map
|
|
1255
|
+
//# sourceMappingURL=chunk-LXSVDRMH.cjs.map
|