@kerebron/extension-tables 0.4.26 → 0.4.27
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/package.json +3 -2
- package/assets/tables.css +0 -85
- package/esm/ExtensionTables.d.ts +0 -10
- package/esm/ExtensionTables.d.ts.map +0 -1
- package/esm/ExtensionTables.js +0 -14
- package/esm/NodeTable.d.ts +0 -21
- package/esm/NodeTable.d.ts.map +0 -1
- package/esm/NodeTable.js +0 -86
- package/esm/NodeTableCell.d.ts +0 -13
- package/esm/NodeTableCell.d.ts.map +0 -1
- package/esm/NodeTableCell.js +0 -56
- package/esm/NodeTableHeader.d.ts +0 -8
- package/esm/NodeTableHeader.d.ts.map +0 -1
- package/esm/NodeTableHeader.js +0 -43
- package/esm/NodeTableRow.d.ts +0 -13
- package/esm/NodeTableRow.d.ts.map +0 -1
- package/esm/NodeTableRow.js +0 -26
- package/esm/_dnt.shims.d.ts +0 -2
- package/esm/_dnt.shims.d.ts.map +0 -1
- package/esm/_dnt.shims.js +0 -57
- package/esm/package.json +0 -3
- package/esm/utilities/CellSelection.d.ts +0 -53
- package/esm/utilities/CellSelection.d.ts.map +0 -1
- package/esm/utilities/CellSelection.js +0 -364
- package/esm/utilities/TableMap.d.ts +0 -92
- package/esm/utilities/TableMap.d.ts.map +0 -1
- package/esm/utilities/TableMap.js +0 -319
- package/esm/utilities/TableView.d.ts +0 -21
- package/esm/utilities/TableView.d.ts.map +0 -1
- package/esm/utilities/TableView.js +0 -80
- package/esm/utilities/columnResizing.d.ts +0 -50
- package/esm/utilities/columnResizing.d.ts.map +0 -1
- package/esm/utilities/columnResizing.js +0 -299
- package/esm/utilities/commands.d.ts +0 -164
- package/esm/utilities/commands.d.ts.map +0 -1
- package/esm/utilities/commands.js +0 -702
- package/esm/utilities/copypaste.d.ts +0 -35
- package/esm/utilities/copypaste.d.ts.map +0 -1
- package/esm/utilities/copypaste.js +0 -283
- package/esm/utilities/createCell.d.ts +0 -3
- package/esm/utilities/createCell.d.ts.map +0 -1
- package/esm/utilities/createCell.js +0 -6
- package/esm/utilities/createTable.d.ts +0 -3
- package/esm/utilities/createTable.d.ts.map +0 -1
- package/esm/utilities/createTable.js +0 -31
- package/esm/utilities/fixTables.d.ts +0 -20
- package/esm/utilities/fixTables.d.ts.map +0 -1
- package/esm/utilities/fixTables.js +0 -146
- package/esm/utilities/getTableNodeTypes.d.ts +0 -5
- package/esm/utilities/getTableNodeTypes.d.ts.map +0 -1
- package/esm/utilities/getTableNodeTypes.js +0 -14
- package/esm/utilities/input.d.ts +0 -21
- package/esm/utilities/input.d.ts.map +0 -1
- package/esm/utilities/input.js +0 -241
- package/esm/utilities/tableEditing.d.ts +0 -23
- package/esm/utilities/tableEditing.d.ts.map +0 -1
- package/esm/utilities/tableEditing.js +0 -63
- package/esm/utilities/tableNodeTypes.d.ts +0 -14
- package/esm/utilities/tableNodeTypes.d.ts.map +0 -1
- package/esm/utilities/tableNodeTypes.js +0 -16
- package/esm/utilities/util.d.ts +0 -73
- package/esm/utilities/util.d.ts.map +0 -1
- package/esm/utilities/util.js +0 -155
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/extension-tables",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.27",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"module": "./esm/ExtensionTables.js",
|
|
6
6
|
"exports": {
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"scripts": {},
|
|
27
|
+
"files": [],
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@kerebron/editor": "0.4.
|
|
29
|
+
"@kerebron/editor": "0.4.27",
|
|
29
30
|
"prosemirror-model": "1.25.3",
|
|
30
31
|
"prosemirror-state": "1.4.3",
|
|
31
32
|
"prosemirror-transform": "1.10.4",
|
package/assets/tables.css
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
.kb-editor .tableWrapper {
|
|
2
|
-
overflow-x: auto;
|
|
3
|
-
}
|
|
4
|
-
.kb-editor table {
|
|
5
|
-
border-collapse: collapse;
|
|
6
|
-
table-layout: fixed;
|
|
7
|
-
width: 100%;
|
|
8
|
-
overflow: hidden;
|
|
9
|
-
}
|
|
10
|
-
.kb-editor td,
|
|
11
|
-
.kb-editor th {
|
|
12
|
-
vertical-align: top;
|
|
13
|
-
box-sizing: border-box;
|
|
14
|
-
position: relative;
|
|
15
|
-
border: 1px solid var(--kb-color-border);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.kb-editor td:not([data-colwidth]):not(.column-resize-dragging),
|
|
19
|
-
.kb-editor th:not([data-colwidth]):not(.column-resize-dragging) {
|
|
20
|
-
/* if there's no explicit width set and the column is not being resized, set a default width */
|
|
21
|
-
min-width: var(--default-cell-min-width);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.kb-editor .column-resize-handle {
|
|
25
|
-
position: absolute;
|
|
26
|
-
right: -2px;
|
|
27
|
-
top: 0;
|
|
28
|
-
bottom: 0;
|
|
29
|
-
width: 4px;
|
|
30
|
-
z-index: 20;
|
|
31
|
-
background-color: #adf;
|
|
32
|
-
pointer-events: none;
|
|
33
|
-
}
|
|
34
|
-
.kb-editor.resize-cursor {
|
|
35
|
-
cursor: ew-resize;
|
|
36
|
-
cursor: col-resize;
|
|
37
|
-
}
|
|
38
|
-
/* Give selected cells a blue overlay */
|
|
39
|
-
.kb-editor .selectedCell:after {
|
|
40
|
-
z-index: 2;
|
|
41
|
-
position: absolute;
|
|
42
|
-
content: '';
|
|
43
|
-
left: 0;
|
|
44
|
-
right: 0;
|
|
45
|
-
top: 0;
|
|
46
|
-
bottom: 0;
|
|
47
|
-
background: rgba(200, 200, 255, 0.4);
|
|
48
|
-
pointer-events: none;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/* Touch-optimized table editing */
|
|
52
|
-
@media (max-width: 767px) {
|
|
53
|
-
.kb-editor table {
|
|
54
|
-
font-size: var(--kb-text-sm);
|
|
55
|
-
border-collapse: collapse;
|
|
56
|
-
width: 100%;
|
|
57
|
-
overflow-x: auto;
|
|
58
|
-
display: block;
|
|
59
|
-
white-space: nowrap;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.kb-editor th,
|
|
63
|
-
.kb-editor td {
|
|
64
|
-
min-width: 120px;
|
|
65
|
-
padding: var(--kb-space-md);
|
|
66
|
-
border: 1px solid var(--kb-color-border);
|
|
67
|
-
vertical-align: top;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/* Hide complex table controls on mobile */
|
|
71
|
-
.tableWrapper .column-resize-handle {
|
|
72
|
-
display: none !important;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.kb-editor .tableWrapper {
|
|
76
|
-
overflow-x: auto;
|
|
77
|
-
-webkit-overflow-scrolling: touch;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/* Table selection visual feedback */
|
|
81
|
-
.kb-editor .selectedCell {
|
|
82
|
-
background: rgba(var(--kb-color-primary-rgb), 0.1);
|
|
83
|
-
border: 2px solid var(--kb-color-primary);
|
|
84
|
-
}
|
|
85
|
-
}
|
package/esm/ExtensionTables.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@kerebron/editor';
|
|
2
|
-
import { NodeTable } from './NodeTable.js';
|
|
3
|
-
import { NodeTableRow } from './NodeTableRow.js';
|
|
4
|
-
import { NodeTableHeader } from './NodeTableHeader.js';
|
|
5
|
-
import { NodeTableCell } from './NodeTableCell.js';
|
|
6
|
-
export declare class ExtensionTables extends Extension {
|
|
7
|
-
name: string;
|
|
8
|
-
requires: (NodeTable | NodeTableRow | NodeTableHeader | NodeTableCell)[];
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=ExtensionTables.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionTables.d.ts","sourceRoot":"","sources":["../src/ExtensionTables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,IAAI,SAAsB;IAC1B,QAAQ,iEAKN;CACH"}
|
package/esm/ExtensionTables.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Extension } from '@kerebron/editor';
|
|
2
|
-
import { NodeTable } from './NodeTable.js';
|
|
3
|
-
import { NodeTableRow } from './NodeTableRow.js';
|
|
4
|
-
import { NodeTableHeader } from './NodeTableHeader.js';
|
|
5
|
-
import { NodeTableCell } from './NodeTableCell.js';
|
|
6
|
-
export class ExtensionTables extends Extension {
|
|
7
|
-
name = 'extension-tables';
|
|
8
|
-
requires = [
|
|
9
|
-
new NodeTable(),
|
|
10
|
-
new NodeTableHeader(),
|
|
11
|
-
new NodeTableRow(),
|
|
12
|
-
new NodeTableCell(),
|
|
13
|
-
];
|
|
14
|
-
}
|
package/esm/NodeTable.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { NodeSpec, NodeType } from 'prosemirror-model';
|
|
2
|
-
import { type CoreEditor, Node } from '@kerebron/editor';
|
|
3
|
-
import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
|
|
4
|
-
import { type InputRule } from '@kerebron/editor/plugins/input-rules';
|
|
5
|
-
import { Plugin } from 'prosemirror-state';
|
|
6
|
-
export declare class NodeTable extends Node {
|
|
7
|
-
name: string;
|
|
8
|
-
requires: string[];
|
|
9
|
-
attributes: {
|
|
10
|
-
class: {
|
|
11
|
-
default: string;
|
|
12
|
-
fromDom(element: HTMLElement): any;
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
|
-
getNodeSpec(): NodeSpec;
|
|
16
|
-
getInputRules(type: NodeType): InputRule[];
|
|
17
|
-
getCommandFactories(editor: CoreEditor, type: NodeType): Partial<CommandFactories>;
|
|
18
|
-
getKeyboardShortcuts(): Partial<CommandShortcuts>;
|
|
19
|
-
getProseMirrorPlugins(): Plugin[];
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=NodeTable.d.ts.map
|
package/esm/NodeTable.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTable.d.ts","sourceRoot":"","sources":["../src/NodeTable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGvD,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sCAAsC,CAAC;AA2BtE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,qBAAa,SAAU,SAAQ,IAAI;IACxB,IAAI,SAAW;IACxB,QAAQ,WAAW;IAEV,UAAU;;;6BAGE,WAAW;;MAM9B;IAEO,WAAW,IAAI,QAAQ;IAgBvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAI1C,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAsDnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAKjD,qBAAqB,IAAI,MAAM,EAAE;CAM3C"}
|
package/esm/NodeTable.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { TextSelection } from 'prosemirror-state';
|
|
2
|
-
import { Node } from '@kerebron/editor';
|
|
3
|
-
import { getHtmlAttributes, setHtmlAttributes, } from '@kerebron/editor/utilities';
|
|
4
|
-
import { createTable } from './utilities/createTable.js';
|
|
5
|
-
import { CellSelection } from './utilities/CellSelection.js';
|
|
6
|
-
import { columnResizing } from './utilities/columnResizing.js';
|
|
7
|
-
import { tableEditing } from './utilities/tableEditing.js';
|
|
8
|
-
import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, deleteColumn, deleteRow, deleteTable, goToNextCell, mergeCells, setCellAttr, splitCell, toggleHeader, toggleHeaderCell, toggleHeaderColumn, toggleHeaderRow, } from './utilities/commands.js';
|
|
9
|
-
export class NodeTable extends Node {
|
|
10
|
-
name = 'table';
|
|
11
|
-
requires = ['doc'];
|
|
12
|
-
attributes = {
|
|
13
|
-
class: {
|
|
14
|
-
default: 'table',
|
|
15
|
-
fromDom(element) {
|
|
16
|
-
return element.hasAttribute('class')
|
|
17
|
-
? element.getAttribute('class')
|
|
18
|
-
: undefined;
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
getNodeSpec() {
|
|
23
|
-
return {
|
|
24
|
-
content: 'table_row+',
|
|
25
|
-
tableRole: 'table',
|
|
26
|
-
isolating: true,
|
|
27
|
-
group: 'block',
|
|
28
|
-
parseDOM: [{
|
|
29
|
-
tag: 'table',
|
|
30
|
-
getAttrs: (element) => setHtmlAttributes(this, element),
|
|
31
|
-
}],
|
|
32
|
-
toDOM: (node) => ['table', getHtmlAttributes(this, node), ['tbody', 0]],
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
getInputRules(type) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
getCommandFactories(editor, type) {
|
|
39
|
-
const commands = {
|
|
40
|
-
addColumnAfter: () => (state, dispatch) => addColumnAfter(state, dispatch),
|
|
41
|
-
addColumnBefore: () => (state, dispatch) => addColumnBefore(state, dispatch),
|
|
42
|
-
addRowAfter: () => (state, dispatch) => addRowAfter(state, dispatch),
|
|
43
|
-
addRowBefore: () => (state, dispatch) => addRowBefore(state, dispatch),
|
|
44
|
-
deleteColumn: () => (state, dispatch) => deleteColumn(state, dispatch),
|
|
45
|
-
deleteRow: () => (state, dispatch) => deleteRow(state, dispatch),
|
|
46
|
-
deleteTable: () => (state, dispatch) => deleteTable(state, dispatch),
|
|
47
|
-
goToNextCell: (direction) => goToNextCell(direction),
|
|
48
|
-
mergeCells: () => (state, dispatch) => mergeCells(state, dispatch),
|
|
49
|
-
setCellAttr: (...args) => setCellAttr(...args),
|
|
50
|
-
splitCell: () => (state, dispatch) => splitCell(state, dispatch),
|
|
51
|
-
toggleHeader: (...args) => toggleHeader(...args),
|
|
52
|
-
toggleHeaderCell: () => (state, dispatch) => toggleHeaderCell(state, dispatch),
|
|
53
|
-
toggleHeaderRow: () => (state, dispatch) => toggleHeaderRow(state, dispatch),
|
|
54
|
-
toggleHeaderColumn: () => (state, dispatch) => toggleHeaderColumn(state, dispatch),
|
|
55
|
-
insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => (state, dispatch) => {
|
|
56
|
-
const tr = state.tr;
|
|
57
|
-
const node = createTable(editor.schema, rows, cols, withHeaderRow);
|
|
58
|
-
if (dispatch) {
|
|
59
|
-
const offset = tr.selection.from + 1;
|
|
60
|
-
tr.replaceSelectionWith(node)
|
|
61
|
-
.scrollIntoView()
|
|
62
|
-
.setSelection(TextSelection.near(tr.doc.resolve(offset)));
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
},
|
|
66
|
-
setCellSelection: (position) => (state, dispatch) => {
|
|
67
|
-
if (dispatch) {
|
|
68
|
-
const selection = CellSelection.create(state.doc, position.anchorCell, position.headCell);
|
|
69
|
-
state.tr.setSelection(selection);
|
|
70
|
-
}
|
|
71
|
-
return true;
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
return commands;
|
|
75
|
-
}
|
|
76
|
-
getKeyboardShortcuts() {
|
|
77
|
-
const keys = {};
|
|
78
|
-
return keys;
|
|
79
|
-
}
|
|
80
|
-
getProseMirrorPlugins() {
|
|
81
|
-
return [
|
|
82
|
-
columnResizing(),
|
|
83
|
-
tableEditing(),
|
|
84
|
-
];
|
|
85
|
-
}
|
|
86
|
-
}
|
package/esm/NodeTableCell.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NodeSpec, NodeType } from 'prosemirror-model';
|
|
2
|
-
import { type CoreEditor, Node } from '@kerebron/editor';
|
|
3
|
-
import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
|
|
4
|
-
import { type InputRule } from '@kerebron/editor/plugins/input-rules';
|
|
5
|
-
export declare class NodeTableCell extends Node {
|
|
6
|
-
name: string;
|
|
7
|
-
requires: string[];
|
|
8
|
-
getNodeSpec(): NodeSpec;
|
|
9
|
-
getInputRules(type: NodeType): InputRule[];
|
|
10
|
-
getCommandFactories(editor: CoreEditor, type: NodeType): Partial<CommandFactories>;
|
|
11
|
-
getKeyboardShortcuts(): Partial<CommandShortcuts>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=NodeTableCell.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTableCell.d.ts","sourceRoot":"","sources":["../src/NodeTableCell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sCAAsC,CAAC;AA2BtE,qBAAa,aAAc,SAAQ,IAAI;IAC5B,IAAI,SAAgB;IAC7B,QAAQ,WAAiB;IAEhB,WAAW,IAAI,QAAQ;IAmBvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAI1C,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAKnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAI3D"}
|
package/esm/NodeTableCell.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Node } from '@kerebron/editor';
|
|
2
|
-
function getCellAttrs(dom) {
|
|
3
|
-
if (typeof dom === 'string') {
|
|
4
|
-
return {};
|
|
5
|
-
}
|
|
6
|
-
const widthAttr = dom.getAttribute('data-colwidth');
|
|
7
|
-
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr)
|
|
8
|
-
? widthAttr.split(',').map((s) => Number(s))
|
|
9
|
-
: null;
|
|
10
|
-
const colspan = Number(dom.getAttribute('colspan') || 1);
|
|
11
|
-
return {
|
|
12
|
-
colspan,
|
|
13
|
-
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
|
14
|
-
colwidth: widths && widths.length == colspan ? widths : null,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function setCellAttrs(node) {
|
|
18
|
-
return {
|
|
19
|
-
colspan: (node.attrs.colspan != 1) ? node.attrs.colspan : undefined,
|
|
20
|
-
rowspan: (node.attrs.rowspan != 1) ? node.attrs.rowspan : undefined,
|
|
21
|
-
'data-colwidth': node.attrs.colwidth?.join(','),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export class NodeTableCell extends Node {
|
|
25
|
-
name = 'table_cell';
|
|
26
|
-
requires = ['table_row'];
|
|
27
|
-
getNodeSpec() {
|
|
28
|
-
return {
|
|
29
|
-
content: 'block+',
|
|
30
|
-
attrs: {
|
|
31
|
-
colspan: { default: 1 },
|
|
32
|
-
rowspan: { default: 1 },
|
|
33
|
-
colwidth: { default: null },
|
|
34
|
-
},
|
|
35
|
-
tableRole: 'cell',
|
|
36
|
-
isolating: true,
|
|
37
|
-
parseDOM: [
|
|
38
|
-
{ tag: 'td', getAttrs: (dom) => getCellAttrs(dom) },
|
|
39
|
-
],
|
|
40
|
-
toDOM(node) {
|
|
41
|
-
return ['td', setCellAttrs(node), 0];
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
getInputRules(type) {
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
getCommandFactories(editor, type) {
|
|
49
|
-
const commands = {};
|
|
50
|
-
return commands;
|
|
51
|
-
}
|
|
52
|
-
getKeyboardShortcuts() {
|
|
53
|
-
const keys = {};
|
|
54
|
-
return keys;
|
|
55
|
-
}
|
|
56
|
-
}
|
package/esm/NodeTableHeader.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTableHeader.d.ts","sourceRoot":"","sources":["../src/NodeTableHeader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAyB,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AA2BxC,qBAAa,eAAgB,SAAQ,IAAI;IAC9B,IAAI,SAAkB;IAC/B,QAAQ,WAAa;IAEZ,WAAW,IAAI,QAAQ;CAgBjC"}
|
package/esm/NodeTableHeader.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Node } from '@kerebron/editor';
|
|
2
|
-
function getCellAttrs(dom) {
|
|
3
|
-
if (typeof dom === 'string') {
|
|
4
|
-
return {};
|
|
5
|
-
}
|
|
6
|
-
const widthAttr = dom.getAttribute('data-colwidth');
|
|
7
|
-
const widths = widthAttr && /^\d+(,\d+)*$/.test(widthAttr)
|
|
8
|
-
? widthAttr.split(',').map((s) => Number(s))
|
|
9
|
-
: null;
|
|
10
|
-
const colspan = Number(dom.getAttribute('colspan') || 1);
|
|
11
|
-
return {
|
|
12
|
-
colspan,
|
|
13
|
-
rowspan: Number(dom.getAttribute('rowspan') || 1),
|
|
14
|
-
colwidth: widths && widths.length == colspan ? widths : null,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function setCellAttrs(node) {
|
|
18
|
-
return {
|
|
19
|
-
colspan: (node.attrs.colspan != 1) ? node.attrs.colspan : undefined,
|
|
20
|
-
rowspan: (node.attrs.rowspan != 1) ? node.attrs.rowspan : undefined,
|
|
21
|
-
'data-colwidth': node.attrs.colwidth?.join(','),
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export class NodeTableHeader extends Node {
|
|
25
|
-
name = 'table_header';
|
|
26
|
-
requires = ['table'];
|
|
27
|
-
getNodeSpec() {
|
|
28
|
-
return {
|
|
29
|
-
content: 'block+',
|
|
30
|
-
attrs: {
|
|
31
|
-
colspan: { default: 1 },
|
|
32
|
-
rowspan: { default: 1 },
|
|
33
|
-
colwidth: { default: null },
|
|
34
|
-
},
|
|
35
|
-
tableRole: 'header_cell',
|
|
36
|
-
isolating: true,
|
|
37
|
-
parseDOM: [
|
|
38
|
-
{ tag: 'th', getAttrs: (dom) => getCellAttrs(dom) },
|
|
39
|
-
],
|
|
40
|
-
toDOM: (node) => ['th', setCellAttrs(node), 0],
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
package/esm/NodeTableRow.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NodeSpec, NodeType } from 'prosemirror-model';
|
|
2
|
-
import { type CoreEditor, Node } from '@kerebron/editor';
|
|
3
|
-
import { type CommandFactories, type CommandShortcuts } from '@kerebron/editor/commands';
|
|
4
|
-
import { type InputRule } from '@kerebron/editor/plugins/input-rules';
|
|
5
|
-
export declare class NodeTableRow extends Node {
|
|
6
|
-
name: string;
|
|
7
|
-
requires: string[];
|
|
8
|
-
getNodeSpec(): NodeSpec;
|
|
9
|
-
getInputRules(type: NodeType): InputRule[];
|
|
10
|
-
getCommandFactories(editor: CoreEditor, type: NodeType): Partial<CommandFactories>;
|
|
11
|
-
getKeyboardShortcuts(): Partial<CommandShortcuts>;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=NodeTableRow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NodeTableRow.d.ts","sourceRoot":"","sources":["../src/NodeTableRow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,sCAAsC,CAAC;AAE9C,qBAAa,YAAa,SAAQ,IAAI;IAC3B,IAAI,SAAe;IAC5B,QAAQ,WAAa;IAEZ,WAAW,IAAI,QAAQ;IAWvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAI1C,mBAAmB,CAC1B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,GACb,OAAO,CAAC,gBAAgB,CAAC;IAMnB,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAI3D"}
|
package/esm/NodeTableRow.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Node } from '@kerebron/editor';
|
|
2
|
-
export class NodeTableRow extends Node {
|
|
3
|
-
name = 'table_row';
|
|
4
|
-
requires = ['table'];
|
|
5
|
-
getNodeSpec() {
|
|
6
|
-
return {
|
|
7
|
-
content: '(table_cell | table_header)*',
|
|
8
|
-
tableRole: 'row',
|
|
9
|
-
parseDOM: [{ tag: 'tr' }],
|
|
10
|
-
toDOM() {
|
|
11
|
-
return ['tr', 0];
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
getInputRules(type) {
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
getCommandFactories(editor, type) {
|
|
19
|
-
const commands = {};
|
|
20
|
-
return commands;
|
|
21
|
-
}
|
|
22
|
-
getKeyboardShortcuts() {
|
|
23
|
-
const keys = {};
|
|
24
|
-
return keys;
|
|
25
|
-
}
|
|
26
|
-
}
|
package/esm/_dnt.shims.d.ts
DELETED
package/esm/_dnt.shims.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAA2C,CAAC"}
|
package/esm/_dnt.shims.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const dntGlobals = {};
|
|
2
|
-
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
3
|
-
function createMergeProxy(baseObj, extObj) {
|
|
4
|
-
return new Proxy(baseObj, {
|
|
5
|
-
get(_target, prop, _receiver) {
|
|
6
|
-
if (prop in extObj) {
|
|
7
|
-
return extObj[prop];
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
return baseObj[prop];
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
set(_target, prop, value) {
|
|
14
|
-
if (prop in extObj) {
|
|
15
|
-
delete extObj[prop];
|
|
16
|
-
}
|
|
17
|
-
baseObj[prop] = value;
|
|
18
|
-
return true;
|
|
19
|
-
},
|
|
20
|
-
deleteProperty(_target, prop) {
|
|
21
|
-
let success = false;
|
|
22
|
-
if (prop in extObj) {
|
|
23
|
-
delete extObj[prop];
|
|
24
|
-
success = true;
|
|
25
|
-
}
|
|
26
|
-
if (prop in baseObj) {
|
|
27
|
-
delete baseObj[prop];
|
|
28
|
-
success = true;
|
|
29
|
-
}
|
|
30
|
-
return success;
|
|
31
|
-
},
|
|
32
|
-
ownKeys(_target) {
|
|
33
|
-
const baseKeys = Reflect.ownKeys(baseObj);
|
|
34
|
-
const extKeys = Reflect.ownKeys(extObj);
|
|
35
|
-
const extKeysSet = new Set(extKeys);
|
|
36
|
-
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
37
|
-
},
|
|
38
|
-
defineProperty(_target, prop, desc) {
|
|
39
|
-
if (prop in extObj) {
|
|
40
|
-
delete extObj[prop];
|
|
41
|
-
}
|
|
42
|
-
Reflect.defineProperty(baseObj, prop, desc);
|
|
43
|
-
return true;
|
|
44
|
-
},
|
|
45
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
46
|
-
if (prop in extObj) {
|
|
47
|
-
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
has(_target, prop) {
|
|
54
|
-
return prop in extObj || prop in baseObj;
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
package/esm/package.json
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Node, ResolvedPos, Slice } from 'prosemirror-model';
|
|
2
|
-
import { EditorState, Selection, Transaction } from 'prosemirror-state';
|
|
3
|
-
import { DecorationSource } from 'prosemirror-view';
|
|
4
|
-
import { Mappable } from 'prosemirror-transform';
|
|
5
|
-
/**
|
|
6
|
-
* @public
|
|
7
|
-
*/
|
|
8
|
-
export interface CellSelectionJSON {
|
|
9
|
-
type: string;
|
|
10
|
-
anchor: number;
|
|
11
|
-
head: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* A [`Selection`](http://prosemirror.net/docs/ref/#state.Selection)
|
|
15
|
-
* subclass that represents a cell selection spanning part of a table.
|
|
16
|
-
* With the plugin enabled, these will be created when the user
|
|
17
|
-
* selects across cells, and will be drawn by giving selected cells a
|
|
18
|
-
* `selectedCell` CSS class.
|
|
19
|
-
*
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export declare class CellSelection extends Selection {
|
|
23
|
-
$anchorCell: ResolvedPos;
|
|
24
|
-
$headCell: ResolvedPos;
|
|
25
|
-
constructor($anchorCell: ResolvedPos, $headCell?: ResolvedPos);
|
|
26
|
-
map(doc: Node, mapping: Mappable): CellSelection | Selection;
|
|
27
|
-
content(): Slice;
|
|
28
|
-
replace(tr: Transaction, content?: Slice): void;
|
|
29
|
-
replaceWith(tr: Transaction, node: Node): void;
|
|
30
|
-
forEachCell(f: (node: Node, pos: number) => void): void;
|
|
31
|
-
isColSelection(): boolean;
|
|
32
|
-
static colSelection($anchorCell: ResolvedPos, $headCell?: ResolvedPos): CellSelection;
|
|
33
|
-
isRowSelection(): boolean;
|
|
34
|
-
eq(other: unknown): boolean;
|
|
35
|
-
static rowSelection($anchorCell: ResolvedPos, $headCell?: ResolvedPos): CellSelection;
|
|
36
|
-
toJSON(): CellSelectionJSON;
|
|
37
|
-
static fromJSON(doc: Node, json: CellSelectionJSON): CellSelection;
|
|
38
|
-
static create(doc: Node, anchorCell: number, headCell?: number): CellSelection;
|
|
39
|
-
getBookmark(): CellBookmark;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* @public
|
|
43
|
-
*/
|
|
44
|
-
export declare class CellBookmark {
|
|
45
|
-
anchor: number;
|
|
46
|
-
head: number;
|
|
47
|
-
constructor(anchor: number, head: number);
|
|
48
|
-
map(mapping: Mappable): CellBookmark;
|
|
49
|
-
resolve(doc: Node): CellSelection | Selection;
|
|
50
|
-
}
|
|
51
|
-
export declare function drawCellSelection(state: EditorState): DecorationSource | null;
|
|
52
|
-
export declare function normalizeSelection(state: EditorState, tr: Transaction | undefined, allowTableNodeSelection: boolean): Transaction | undefined;
|
|
53
|
-
//# sourceMappingURL=CellSelection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CellSelection.d.ts","sourceRoot":"","sources":["../../src/utilities/CellSelection.ts"],"names":[],"mappings":"AAKA,OAAO,EAAY,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EACL,WAAW,EAEX,SAAS,EAGT,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA6B,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAIjD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;GAQG;AACH,qBAAa,aAAc,SAAQ,SAAS;IAGnC,WAAW,EAAE,WAAW,CAAC;IAIzB,SAAS,EAAE,WAAW,CAAC;gBAMlB,WAAW,EAAE,WAAW,EAAE,SAAS,GAAE,WAAyB;IAgCnE,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,GAAG,aAAa,GAAG,SAAS;IAoBnD,OAAO,IAAI,KAAK;IA6EhB,OAAO,CAAC,EAAE,EAAE,WAAW,EAAE,OAAO,GAAE,KAAmB,GAAG,IAAI;IAmB5D,WAAW,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI;IAIvD,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI;IAkBvD,cAAc,IAAI,OAAO;WAelB,YAAY,CACxB,WAAW,EAAE,WAAW,EACxB,SAAS,GAAE,WAAyB,GACnC,aAAa;IAmCT,cAAc,IAAI,OAAO;IAczB,EAAE,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;WAUpB,YAAY,CACxB,WAAW,EAAE,WAAW,EACxB,SAAS,GAAE,WAAyB,GACnC,aAAa;IAiCT,MAAM,IAAI,iBAAiB;WAQlB,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,iBAAiB,GAAG,aAAa;IAI3E,MAAM,CAAC,MAAM,CACX,GAAG,EAAE,IAAI,EACT,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,MAAmB,GAC5B,aAAa;IAIP,WAAW,IAAI,YAAY;CAGrC;AAMD;;GAEG;AACH,qBAAa,YAAY;IAEd,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,MAAM;gBADZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM;IAGrB,GAAG,CAAC,OAAO,EAAE,QAAQ,GAAG,YAAY;IAIpC,OAAO,CAAC,GAAG,EAAE,IAAI,GAAG,aAAa,GAAG,SAAS;CAa9C;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,gBAAgB,GAAG,IAAI,CAS7E;AAgDD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,WAAW,EAClB,EAAE,EAAE,WAAW,GAAG,SAAS,EAC3B,uBAAuB,EAAE,OAAO,GAC/B,WAAW,GAAG,SAAS,CAwBzB"}
|