@openleaf-editor/plugins-table 0.1.0-beta.0 → 0.1.0-beta.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/dist/commands.d.ts +101 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +445 -0
- package/dist/commands.js.map +1 -0
- package/dist/dialogs.d.ts +14 -0
- package/dist/dialogs.d.ts.map +1 -0
- package/dist/dialogs.js +159 -0
- package/dist/dialogs.js.map +1 -0
- package/dist/grid.d.ts +15 -0
- package/dist/grid.d.ts.map +1 -0
- package/dist/grid.js +225 -0
- package/dist/grid.js.map +1 -0
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +4 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +7 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +112 -105
- package/dist/index.js.map +1 -1
- package/dist/menu.d.ts +15 -0
- package/dist/menu.d.ts.map +1 -0
- package/dist/menu.js +195 -0
- package/dist/menu.js.map +1 -0
- package/dist/styles.d.ts +9 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +93 -0
- package/dist/styles.js.map +1 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
*
|
|
13
13
|
* So everyone gets tables that read and write correctly, for about a kilobyte.
|
|
14
14
|
* What is opt-in is the weight: cell selection, column resizing, the row and
|
|
15
|
-
* column commands,
|
|
16
|
-
*
|
|
15
|
+
* column commands, property dialogs, the insert grid, the context menu, and the
|
|
16
|
+
* toolbar controls.
|
|
17
17
|
*
|
|
18
18
|
* ## Loading it
|
|
19
19
|
*
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* ```
|
|
26
26
|
*
|
|
27
27
|
* The second bundle shares the first one's ProseMirror runtime rather than
|
|
28
|
-
* carrying its own copy
|
|
28
|
+
* carrying its own copy.
|
|
29
29
|
*
|
|
30
30
|
* Or as a module:
|
|
31
31
|
*
|
|
@@ -34,12 +34,21 @@
|
|
|
34
34
|
* installTableEditing()
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
import {
|
|
38
|
-
import { registerIcons, registerToolbarItem } from '@openleaf-editor/ui';
|
|
37
|
+
import { registerEditorPlugin } from '@openleaf-editor/core';
|
|
38
|
+
import { registerIcons, registerStyles, registerToolbarItem } from '@openleaf-editor/ui';
|
|
39
|
+
import { columnResizing, deleteColumn, deleteRow, deleteTable, mergeCells, splitCell, tableEditing, TableView, } from 'prosemirror-tables';
|
|
40
|
+
import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, colgroupSyncPlugin, inTable, insertTable, toggleHeaderRow, } from './commands.js';
|
|
41
|
+
import { openCaptionDialog, openCellProperties, openRowProperties, openTableProperties } from './dialogs.js';
|
|
42
|
+
import { buildInsertGrid } from './grid.js';
|
|
39
43
|
import { TABLE_ICON_PATHS } from './icons.js';
|
|
40
|
-
import {
|
|
44
|
+
import { tableContextMenu } from './menu.js';
|
|
45
|
+
import { TABLE_UI_CSS } from './styles.js';
|
|
41
46
|
export const TABLE_TOOLBAR_ITEMS = [
|
|
42
47
|
'insertTable',
|
|
48
|
+
'tableProperties',
|
|
49
|
+
'rowProperties',
|
|
50
|
+
'cellProperties',
|
|
51
|
+
'tableCaption',
|
|
43
52
|
'addRowBefore',
|
|
44
53
|
'addRowAfter',
|
|
45
54
|
'deleteRow',
|
|
@@ -53,112 +62,90 @@ export const TABLE_TOOLBAR_ITEMS = [
|
|
|
53
62
|
];
|
|
54
63
|
/** A layout string for the default toolbar plus the table controls. */
|
|
55
64
|
export const TABLE_LAYOUT_SUFFIX = ` | ${TABLE_TOOLBAR_ITEMS.join(' ')}`;
|
|
56
|
-
/** Is the selection inside a table? Table commands are useless outside one. */
|
|
57
|
-
export function inTable(state) {
|
|
58
|
-
return isNodeActive(state, 'table');
|
|
59
|
-
}
|
|
60
65
|
/**
|
|
61
|
-
*
|
|
66
|
+
* `TableView`, plus the caption it does not know about.
|
|
62
67
|
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
|
|
67
|
-
export function insertTable(rows = 3, cols = 3) {
|
|
68
|
-
return (state, dispatch) => {
|
|
69
|
-
if (!canInsert(state, 'table'))
|
|
70
|
-
return false;
|
|
71
|
-
if (dispatch) {
|
|
72
|
-
// From the state's schema, not an imported singleton: a plugin that
|
|
73
|
-
// captured one schema would build nodes the editor's schema rejects.
|
|
74
|
-
const cell = state.schema.nodes['table_cell'];
|
|
75
|
-
const header = state.schema.nodes['table_header'];
|
|
76
|
-
const row = state.schema.nodes['table_row'];
|
|
77
|
-
const tableType = state.schema.nodes['table'];
|
|
78
|
-
if (!cell || !header || !row || !tableType)
|
|
79
|
-
return false;
|
|
80
|
-
const headerCells = Array.from({ length: cols }, () => header.createAndFill({ scope: 'col' })).filter((n) => n !== null);
|
|
81
|
-
const bodyRows = Array.from({ length: Math.max(0, rows - 1) }, () => row.create(null, Array.from({ length: cols }, () => cell.createAndFill()).filter((n) => n !== null)));
|
|
82
|
-
const table = tableType.create(null, [row.create(null, headerCells), ...bodyRows]);
|
|
83
|
-
dispatch(state.tr.replaceSelectionWith(table).scrollIntoView());
|
|
84
|
-
}
|
|
85
|
-
return true;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Keep `scope` valid when cells change role.
|
|
68
|
+
* `columnResizing` installs a node view for tables, and that node view builds
|
|
69
|
+
* the element itself: a wrapper div, a `<colgroup>` it owns for resize widths,
|
|
70
|
+
* and a `<tbody>`. It never consults the table node's `toDOM`, so once this
|
|
71
|
+
* bundle loads, the caption core renders is simply absent from the editor.
|
|
90
72
|
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
73
|
+
* That produced the worst version of the bug it was meant to fix. Saving still
|
|
74
|
+
* kept the caption -- serialization goes through `toDOM` and never through a
|
|
75
|
+
* node view -- so the caption was invisible while editing and reappeared in the
|
|
76
|
+
* stored HTML. An author would reasonably conclude it had been deleted, and the
|
|
77
|
+
* only way to find out otherwise is to read the database.
|
|
78
|
+
*
|
|
79
|
+
* Only the caption is re-added. The preserved `<colgroup>` markup deliberately
|
|
80
|
+
* is not: this view's own colgroup is what drives column resizing, and a second
|
|
81
|
+
* one would fight it for the same columns. The author's colgroup is still
|
|
82
|
+
* stored and still emitted on save; it is the resize widths that win on screen,
|
|
83
|
+
* which is the same bargain the resizing feature already makes.
|
|
95
84
|
*/
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (
|
|
104
|
-
|
|
105
|
-
|
|
85
|
+
class CaptionedTableView extends TableView {
|
|
86
|
+
constructor(node, defaultCellMinWidth) {
|
|
87
|
+
super(node, defaultCellMinWidth);
|
|
88
|
+
this.syncCaption(node);
|
|
89
|
+
}
|
|
90
|
+
update(node) {
|
|
91
|
+
const handled = super.update(node);
|
|
92
|
+
if (handled)
|
|
93
|
+
this.syncCaption(node);
|
|
94
|
+
return handled;
|
|
95
|
+
}
|
|
96
|
+
ignoreMutation(record) {
|
|
97
|
+
// The caption is ours, not content. Without this, ProseMirror treats a
|
|
98
|
+
// change inside it as an edit to the document and tries to re-read it.
|
|
99
|
+
const caption = this.currentCaption();
|
|
100
|
+
if (caption && record.target instanceof Node && caption.contains(record.target))
|
|
101
|
+
return true;
|
|
102
|
+
return super.ignoreMutation(record);
|
|
103
|
+
}
|
|
104
|
+
currentCaption() {
|
|
105
|
+
const first = this.table.firstElementChild;
|
|
106
|
+
return first && first.nodeName === 'CAPTION' ? first : null;
|
|
107
|
+
}
|
|
108
|
+
syncCaption(node) {
|
|
109
|
+
const html = node.attrs['caption'] ?? null;
|
|
110
|
+
const existing = this.currentCaption();
|
|
111
|
+
if (!html) {
|
|
112
|
+
existing?.remove();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
// Rebuild only when the markup actually changed. Replacing it on every
|
|
116
|
+
// update would discard the DOM under the user's selection on every
|
|
117
|
+
// keystroke inside the table.
|
|
118
|
+
if (existing && existing.getAttribute('data-openleaf-caption') === html)
|
|
119
|
+
return;
|
|
120
|
+
const tpl = document.createElement('template');
|
|
121
|
+
tpl.innerHTML = html;
|
|
122
|
+
const rebuilt = tpl.content.firstElementChild;
|
|
123
|
+
if (!rebuilt || rebuilt.nodeName !== 'CAPTION') {
|
|
124
|
+
existing?.remove();
|
|
125
|
+
return;
|
|
106
126
|
}
|
|
127
|
+
// Editor-only, exactly as in core's `toDOM`: the caption renders inside the
|
|
128
|
+
// editable area but is not part of `contentDOM`, so a caret must not enter
|
|
129
|
+
// it. Neither attribute reaches the stored HTML, which is produced by
|
|
130
|
+
// serialization and never by this view.
|
|
131
|
+
rebuilt.setAttribute('contenteditable', 'false');
|
|
132
|
+
rebuilt.setAttribute('data-openleaf-caption', html);
|
|
133
|
+
// A caption must be the table's first child for the browser to render it.
|
|
134
|
+
if (existing)
|
|
135
|
+
existing.replaceWith(rebuilt);
|
|
136
|
+
else
|
|
137
|
+
this.table.insertBefore(rebuilt, this.table.firstChild);
|
|
107
138
|
}
|
|
108
|
-
if (tablePos < 0)
|
|
109
|
-
return tr;
|
|
110
|
-
const table = tr.doc.nodeAt(tablePos);
|
|
111
|
-
if (!table)
|
|
112
|
-
return tr;
|
|
113
|
-
// Walked by row and column rather than as a flat descendant list, because a
|
|
114
|
-
// header's scope depends on where it sits. `setNodeMarkup` only changes
|
|
115
|
-
// attributes, so every node keeps its size and these positions stay valid.
|
|
116
|
-
table.forEach((row, rowOffset, rowIndex) => {
|
|
117
|
-
const rowPos = tablePos + 1 + rowOffset;
|
|
118
|
-
row.forEach((cellNode, cellOffset, cellIndex) => {
|
|
119
|
-
const pos = rowPos + 1 + cellOffset;
|
|
120
|
-
if (cellNode.type === cell && cellNode.attrs['scope']) {
|
|
121
|
-
tr.setNodeMarkup(pos, undefined, { ...cellNode.attrs, scope: null });
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (cellNode.type !== header)
|
|
125
|
-
return;
|
|
126
|
-
const scope = cellNode.attrs['scope'];
|
|
127
|
-
if (scope !== null && scope !== undefined && scope !== '')
|
|
128
|
-
return;
|
|
129
|
-
// A header in the top row labels a column. A header that opens a later
|
|
130
|
-
// row labels that row -- writing "col" there tells a screen reader the
|
|
131
|
-
// opposite of the truth, which is worse than the missing scope this
|
|
132
|
-
// replaces.
|
|
133
|
-
tr.setNodeMarkup(pos, undefined, {
|
|
134
|
-
...cellNode.attrs,
|
|
135
|
-
scope: rowIndex === 0 || cellIndex > 0 ? 'col' : 'row',
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
return tr;
|
|
140
|
-
}
|
|
141
|
-
function withCellScope(command) {
|
|
142
|
-
return (state, dispatch, view) => {
|
|
143
|
-
if (!dispatch)
|
|
144
|
-
return command(state, undefined, view);
|
|
145
|
-
return command(state, (tr) => {
|
|
146
|
-
dispatch(applyCellScope(tr));
|
|
147
|
-
}, view);
|
|
148
|
-
};
|
|
149
139
|
}
|
|
150
|
-
export const addColumnAfter = withCellScope(addColumnAfterRaw);
|
|
151
|
-
export const addColumnBefore = withCellScope(addColumnBeforeRaw);
|
|
152
|
-
export const addRowAfter = withCellScope(addRowAfterRaw);
|
|
153
|
-
export const addRowBefore = withCellScope(addRowBeforeRaw);
|
|
154
|
-
export const toggleHeaderRow = withCellScope(toggleHeaderRowRaw);
|
|
155
140
|
/** The ProseMirror plugins table editing needs. */
|
|
156
141
|
export function tableEditingPlugins() {
|
|
157
142
|
return [
|
|
158
143
|
// Resizing must come first: it reads cell geometry that tableEditing's
|
|
159
144
|
// selection handling would otherwise have already consumed.
|
|
160
|
-
columnResizing(),
|
|
145
|
+
columnResizing({ View: CaptionedTableView }),
|
|
161
146
|
tableEditing({ allowTableNodeSelection: true }),
|
|
147
|
+
colgroupSyncPlugin(),
|
|
148
|
+
tableContextMenu(),
|
|
162
149
|
];
|
|
163
150
|
}
|
|
164
151
|
let installed = false;
|
|
@@ -173,15 +160,35 @@ export function installTableEditing() {
|
|
|
173
160
|
return;
|
|
174
161
|
installed = true;
|
|
175
162
|
registerIcons(TABLE_ICON_PATHS);
|
|
163
|
+
registerStyles(TABLE_UI_CSS);
|
|
176
164
|
registerEditorPlugin(() => tableEditingPlugins());
|
|
177
165
|
registerToolbarItem({
|
|
178
166
|
id: 'insertTable',
|
|
179
|
-
type: '
|
|
180
|
-
kind: 'action',
|
|
167
|
+
type: 'custom',
|
|
181
168
|
label: 'Insert table',
|
|
182
169
|
icon: 'table',
|
|
183
|
-
|
|
170
|
+
render: (ctx) => buildInsertGrid(ctx),
|
|
171
|
+
isEnabled: (state) => insertTable()(state),
|
|
184
172
|
});
|
|
173
|
+
const dialogs = [
|
|
174
|
+
['tableProperties', 'Table properties', 'tableProperties', openTableProperties],
|
|
175
|
+
['rowProperties', 'Row properties', 'rowProperties', openRowProperties],
|
|
176
|
+
['cellProperties', 'Cell properties', 'cellProperties', openCellProperties],
|
|
177
|
+
['tableCaption', 'Table caption', 'tableCaption', openCaptionDialog],
|
|
178
|
+
];
|
|
179
|
+
for (const [id, label, icon, open] of dialogs) {
|
|
180
|
+
registerToolbarItem({
|
|
181
|
+
id,
|
|
182
|
+
type: 'button',
|
|
183
|
+
kind: 'action',
|
|
184
|
+
label,
|
|
185
|
+
icon,
|
|
186
|
+
run: ({ view, host }) => {
|
|
187
|
+
void open(view, host);
|
|
188
|
+
},
|
|
189
|
+
isEnabled: (state) => inTable(state),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
185
192
|
const commands = [
|
|
186
193
|
['addRowBefore', 'Insert row above', addRowBefore],
|
|
187
194
|
['addRowAfter', 'Insert row below', addRowAfter],
|
|
@@ -214,12 +221,12 @@ export function installTableEditing() {
|
|
|
214
221
|
label,
|
|
215
222
|
...(icons[id] ? { icon: icons[id] } : {}),
|
|
216
223
|
command,
|
|
217
|
-
// Every one of these is meaningless outside a table. Reporting them as
|
|
218
|
-
// disabled rather than letting them silently no-op is the difference
|
|
219
|
-
// between a control that looks broken and one that looks unavailable.
|
|
220
224
|
isEnabled: (state) => inTable(state) && command(state),
|
|
221
225
|
});
|
|
222
226
|
}
|
|
223
227
|
}
|
|
228
|
+
export { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, colgroupHtmlWithWidths, colgroupSyncPlugin, inTable, insertTable, mergeStyle, setCellAttrs, setCellVerticalAlign, setRowAttrs, setTableAttrs, setTableCaption, setTableColgroup, styleValueOrNull, toggleHeaderRow, widthsFromColgroup, } from './commands.js';
|
|
229
|
+
export { buildInsertGrid, GRID_SIZE } from './grid.js';
|
|
230
|
+
export { tableContextMenu } from './menu.js';
|
|
224
231
|
export { deleteColumn, deleteRow, deleteTable, mergeCells, splitCell, } from 'prosemirror-tables';
|
|
225
232
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAIxF,OAAO,EACL,cAAc,EACd,YAAY,EACZ,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,SAAS,GACV,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,eAAe,GA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EAAE,cAAc;QAC5B,UAAU,EAAE,YAAY;QACxB,SAAS,EAAE,WAAW;QACtB,eAAe,EAAE,WAAW;QAC5B,WAAW,EAAE,aAAa;KAC3B,CAAA;IAED,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC5C,mBAAmB,CAAC;YAClB,EAAE;YACF,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,KAAK;YACL,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACzC,OAAO;YACP,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC;SACvD,CAAC,CAAA;IACJ,CAAC;AACH,CAAC;AAED,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,OAAO,EACP,WAAW,EACX,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,kBAAkB,GACnB,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,EACL,YAAY,EACZ,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,GACV,MAAM,oBAAoB,CAAA"}
|
package/dist/menu.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table context menu.
|
|
3
|
+
*
|
|
4
|
+
* Right-click (and Shift+F10, which fires `contextmenu`) on a table opens the
|
|
5
|
+
* same commands the toolbar exposes, plus the property dialogs. Authors who
|
|
6
|
+
* live in the document rather than the bar should not have to leave the cell
|
|
7
|
+
* they are editing to add a row.
|
|
8
|
+
*
|
|
9
|
+
* Bound on `view.dom` rather than `handleDOMEvents`, because cell-selection
|
|
10
|
+
* handling in `prosemirror-tables` can swallow the event before a later plugin
|
|
11
|
+
* sees it. A capture listener on the editable surface always runs first.
|
|
12
|
+
*/
|
|
13
|
+
import { Plugin } from 'prosemirror-state';
|
|
14
|
+
export declare function tableContextMenu(): Plugin;
|
|
15
|
+
//# sourceMappingURL=menu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.d.ts","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,MAAM,EAAiB,MAAM,mBAAmB,CAAA;AAuFzD,wBAAgB,gBAAgB,IAAI,MAAM,CAqHzC"}
|
package/dist/menu.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Table context menu.
|
|
3
|
+
*
|
|
4
|
+
* Right-click (and Shift+F10, which fires `contextmenu`) on a table opens the
|
|
5
|
+
* same commands the toolbar exposes, plus the property dialogs. Authors who
|
|
6
|
+
* live in the document rather than the bar should not have to leave the cell
|
|
7
|
+
* they are editing to add a row.
|
|
8
|
+
*
|
|
9
|
+
* Bound on `view.dom` rather than `handleDOMEvents`, because cell-selection
|
|
10
|
+
* handling in `prosemirror-tables` can swallow the event before a later plugin
|
|
11
|
+
* sees it. A capture listener on the editable surface always runs first.
|
|
12
|
+
*/
|
|
13
|
+
import { Plugin, TextSelection } from 'prosemirror-state';
|
|
14
|
+
import { deleteColumn, deleteRow, deleteTable, mergeCells, splitCell } from 'prosemirror-tables';
|
|
15
|
+
import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, findTable, inTable, toggleHeaderRow, } from './commands.js';
|
|
16
|
+
import { openCaptionDialog, openCellProperties, openRowProperties, openTableProperties } from './dialogs.js';
|
|
17
|
+
function commandItem(label, command) {
|
|
18
|
+
return {
|
|
19
|
+
label,
|
|
20
|
+
enabled: (view) => command(view.state),
|
|
21
|
+
run: (view) => {
|
|
22
|
+
command(view.state, view.dispatch, view);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function groups() {
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
items: [
|
|
30
|
+
commandItem('Insert row above', addRowBefore),
|
|
31
|
+
commandItem('Insert row below', addRowAfter),
|
|
32
|
+
commandItem('Delete row', deleteRow),
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
items: [
|
|
37
|
+
commandItem('Insert column before', addColumnBefore),
|
|
38
|
+
commandItem('Insert column after', addColumnAfter),
|
|
39
|
+
commandItem('Delete column', deleteColumn),
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
items: [
|
|
44
|
+
commandItem('Merge cells', mergeCells),
|
|
45
|
+
commandItem('Split cell', splitCell),
|
|
46
|
+
commandItem('Toggle header row', toggleHeaderRow),
|
|
47
|
+
],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
items: [
|
|
51
|
+
{
|
|
52
|
+
label: 'Table properties',
|
|
53
|
+
run: (view, host) => {
|
|
54
|
+
void openTableProperties(view, host);
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: 'Row properties',
|
|
59
|
+
run: (view, host) => {
|
|
60
|
+
void openRowProperties(view, host);
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
label: 'Cell properties',
|
|
65
|
+
run: (view, host) => {
|
|
66
|
+
void openCellProperties(view, host);
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: 'Caption',
|
|
71
|
+
run: (view, host) => {
|
|
72
|
+
void openCaptionDialog(view, host);
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
items: [commandItem('Delete table', deleteTable)],
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
}
|
|
82
|
+
export function tableContextMenu() {
|
|
83
|
+
return new Plugin({
|
|
84
|
+
view(view) {
|
|
85
|
+
let menu = null;
|
|
86
|
+
let open = false;
|
|
87
|
+
const hostFor = () => view.dom.closest('openleaf-editor') ??
|
|
88
|
+
view.dom.parentElement ??
|
|
89
|
+
view.dom;
|
|
90
|
+
const close = () => {
|
|
91
|
+
if (!open || !menu)
|
|
92
|
+
return;
|
|
93
|
+
menu.hidden = true;
|
|
94
|
+
open = false;
|
|
95
|
+
view.dom.ownerDocument.removeEventListener('pointerdown', onPointerDown, true);
|
|
96
|
+
};
|
|
97
|
+
const onPointerDown = (event) => {
|
|
98
|
+
const target = event.target;
|
|
99
|
+
if (!(target instanceof Node) || menu?.contains(target))
|
|
100
|
+
return;
|
|
101
|
+
close();
|
|
102
|
+
};
|
|
103
|
+
const fill = () => {
|
|
104
|
+
if (!menu)
|
|
105
|
+
return;
|
|
106
|
+
menu.replaceChildren();
|
|
107
|
+
const doc = menu.ownerDocument;
|
|
108
|
+
for (const group of groups()) {
|
|
109
|
+
const list = doc.createElement('div');
|
|
110
|
+
list.className = 'ol-table-menu-group';
|
|
111
|
+
for (const item of group.items) {
|
|
112
|
+
const button = doc.createElement('button');
|
|
113
|
+
button.type = 'button';
|
|
114
|
+
button.className = 'ol-table-menu-item';
|
|
115
|
+
button.setAttribute('role', 'menuitem');
|
|
116
|
+
button.textContent = item.label;
|
|
117
|
+
const enabled = item.enabled ? item.enabled(view) : true;
|
|
118
|
+
button.setAttribute('aria-disabled', enabled ? 'false' : 'true');
|
|
119
|
+
button.addEventListener('click', () => {
|
|
120
|
+
if (!enabled)
|
|
121
|
+
return;
|
|
122
|
+
close();
|
|
123
|
+
item.run(view, hostFor());
|
|
124
|
+
});
|
|
125
|
+
list.appendChild(button);
|
|
126
|
+
}
|
|
127
|
+
menu.appendChild(list);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
const showAt = (x, y) => {
|
|
131
|
+
const host = hostFor();
|
|
132
|
+
if (!menu) {
|
|
133
|
+
menu = host.ownerDocument.createElement('div');
|
|
134
|
+
menu.className = 'ol-table-menu';
|
|
135
|
+
menu.setAttribute('role', 'menu');
|
|
136
|
+
menu.setAttribute('aria-label', 'Table');
|
|
137
|
+
host.appendChild(menu);
|
|
138
|
+
}
|
|
139
|
+
fill();
|
|
140
|
+
menu.hidden = false;
|
|
141
|
+
menu.style.position = 'fixed';
|
|
142
|
+
menu.style.left = `${Math.round(x)}px`;
|
|
143
|
+
menu.style.top = `${Math.round(y)}px`;
|
|
144
|
+
open = true;
|
|
145
|
+
view.dom.ownerDocument.addEventListener('pointerdown', onPointerDown, true);
|
|
146
|
+
menu.querySelector('button:not([aria-disabled="true"])')?.focus();
|
|
147
|
+
};
|
|
148
|
+
const onContextMenu = (event) => {
|
|
149
|
+
if (!(event instanceof MouseEvent))
|
|
150
|
+
return;
|
|
151
|
+
// Every item in this menu acts on `state.selection`, and a secondary
|
|
152
|
+
// click does not always move it -- right-clicking a second table while a
|
|
153
|
+
// cell selection is live in the first leaves the old one in place. Read
|
|
154
|
+
// the position under the pointer and work from that, or Delete table
|
|
155
|
+
// deletes the table the author did not click.
|
|
156
|
+
const at = view.posAtCoords({ left: event.clientX, top: event.clientY });
|
|
157
|
+
if (!at)
|
|
158
|
+
return;
|
|
159
|
+
const $pos = view.state.doc.resolve(at.pos);
|
|
160
|
+
if (!findTable($pos))
|
|
161
|
+
return;
|
|
162
|
+
// Only retargeted when the click lands outside the current selection: a
|
|
163
|
+
// right-click inside a multi-cell selection has to keep it, or "Delete
|
|
164
|
+
// row" would silently narrow to the one row under the pointer.
|
|
165
|
+
const { from, to } = view.state.selection;
|
|
166
|
+
if (at.pos < from || at.pos > to) {
|
|
167
|
+
view.dispatch(view.state.tr.setSelection(TextSelection.near($pos)));
|
|
168
|
+
}
|
|
169
|
+
if (!inTable(view.state))
|
|
170
|
+
return;
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
event.stopPropagation();
|
|
173
|
+
showAt(event.clientX, event.clientY);
|
|
174
|
+
};
|
|
175
|
+
const onKeyDown = (event) => {
|
|
176
|
+
if (event.key === 'Escape' && open) {
|
|
177
|
+
event.preventDefault();
|
|
178
|
+
close();
|
|
179
|
+
view.focus();
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
view.dom.addEventListener('contextmenu', onContextMenu);
|
|
183
|
+
view.dom.addEventListener('keydown', onKeyDown);
|
|
184
|
+
return {
|
|
185
|
+
destroy() {
|
|
186
|
+
view.dom.removeEventListener('contextmenu', onContextMenu);
|
|
187
|
+
view.dom.removeEventListener('keydown', onKeyDown);
|
|
188
|
+
close();
|
|
189
|
+
menu?.remove();
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=menu.js.map
|
package/dist/menu.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"menu.js","sourceRoot":"","sources":["../src/menu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEzD,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAChG,OAAO,EACL,cAAc,EACd,eAAe,EACf,WAAW,EACX,YAAY,EACZ,SAAS,EACT,OAAO,EACP,eAAe,GAChB,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAQ5G,SAAS,WAAW,CAAC,KAAa,EAAE,OAAgB;IAClD,OAAO;QACL,KAAK;QACL,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AAS,EAAE,SAAS,CAAC,CAAA;YAE/C,OAAO;gBACL,OAAO;oBACL,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC,CAAA;oBAC1D,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;oBAClD,KAAK,EAAE,CAAA;oBACP,IAAI,EAAE,MAAM,EAAE,CAAA;gBAChB,CAAC;aACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Styles for the insert grid and the table context menu.
|
|
3
|
+
*
|
|
4
|
+
* Registered through `registerStyles` so they ride the same constructable
|
|
5
|
+
* stylesheet path as the toolbar -- no `<style>` injection, which a strict CSP
|
|
6
|
+
* would block silently.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TABLE_UI_CSS = "\n.ol-table-grid { display: inline-flex; }\n.ol-table-pop, .ol-table-menu {\n box-sizing: border-box;\n margin: 0;\n padding: 8px;\n border: 1px solid var(--openleaf-color-border, #d1d9e0);\n border-radius: var(--openleaf-radius, 6px);\n background: var(--openleaf-color-surface, #fff);\n color: var(--openleaf-color-text, #1f2328);\n box-shadow: 0 8px 24px rgb(0 0 0 / 18%);\n font-family: var(--openleaf-font, system-ui, -apple-system, sans-serif);\n font-size: var(--openleaf-font-size, 14px);\n z-index: var(--openleaf-z-index, 1);\n}\n.ol-table-pop[hidden], .ol-table-menu[hidden] { display: none; }\n.ol-table-pop-status {\n margin: 0 0 6px;\n font-size: .9em;\n opacity: .8;\n text-align: center;\n}\n.ol-table-size { display: grid; gap: 2px; }\n.ol-table-size-row { display: flex; gap: 2px; }\n.ol-table-size-cell {\n box-sizing: border-box;\n width: 16px;\n height: 16px;\n padding: 0;\n border: 1px solid var(--openleaf-color-border, #d1d9e0);\n border-radius: 2px;\n background: var(--openleaf-color-surface, #fff);\n cursor: pointer;\n appearance: none;\n -webkit-appearance: none;\n}\n.ol-table-size-cell[aria-pressed=\"true\"] {\n background: var(--openleaf-color-surface-active, #dbe9ff);\n border-color: var(--openleaf-color-accent, #0550ae);\n}\n.ol-table-size-cell:focus-visible {\n outline: 2px solid var(--openleaf-color-focus, #0969da);\n outline-offset: 1px;\n}\n.ol-table-menu {\n min-width: 12rem;\n padding: 4px;\n}\n.ol-table-menu-group + .ol-table-menu-group {\n margin-top: 4px;\n padding-top: 4px;\n border-top: 1px solid var(--openleaf-color-border, #d1d9e0);\n}\n.ol-table-menu-item {\n display: block;\n box-sizing: border-box;\n width: 100%;\n margin: 0;\n padding: 6px 10px;\n border: 0;\n border-radius: var(--openleaf-radius, 4px);\n background: transparent;\n color: inherit;\n font: inherit;\n text-align: start;\n cursor: pointer;\n appearance: none;\n -webkit-appearance: none;\n}\n.ol-table-menu-item:hover, .ol-table-menu-item:focus-visible {\n background: var(--openleaf-color-surface-hover, #f0f1f3);\n}\n.ol-table-menu-item:focus-visible {\n outline: 2px solid var(--openleaf-color-focus, #0969da);\n outline-offset: -2px;\n}\n.ol-table-menu-item[aria-disabled=\"true\"] {\n opacity: .55;\n cursor: default;\n}\n@media (forced-colors: active) {\n .ol-table-size-cell { border: 1px solid ButtonBorder; }\n .ol-table-size-cell[aria-pressed=\"true\"] { outline: 2px solid Highlight; }\n}\n";
|
|
9
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,YAAY,27EAoFxB,CAAA"}
|