@kerebron/extension-tables 0.0.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.
Files changed (65) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +34 -0
  3. package/assets/tables.css +48 -0
  4. package/esm/ExtensionTables.d.ts +10 -0
  5. package/esm/ExtensionTables.d.ts.map +1 -0
  6. package/esm/ExtensionTables.js +27 -0
  7. package/esm/NodeTable.d.ts +24 -0
  8. package/esm/NodeTable.d.ts.map +1 -0
  9. package/esm/NodeTable.js +115 -0
  10. package/esm/NodeTableCell.d.ts +16 -0
  11. package/esm/NodeTableCell.d.ts.map +1 -0
  12. package/esm/NodeTableCell.js +77 -0
  13. package/esm/NodeTableHeader.d.ts +16 -0
  14. package/esm/NodeTableHeader.d.ts.map +1 -0
  15. package/esm/NodeTableHeader.js +75 -0
  16. package/esm/NodeTableRow.d.ts +16 -0
  17. package/esm/NodeTableRow.d.ts.map +1 -0
  18. package/esm/NodeTableRow.js +47 -0
  19. package/esm/_dnt.shims.d.ts +6 -0
  20. package/esm/_dnt.shims.d.ts.map +1 -0
  21. package/esm/_dnt.shims.js +61 -0
  22. package/esm/package.json +3 -0
  23. package/esm/utilities/CellSelection.d.ts +53 -0
  24. package/esm/utilities/CellSelection.d.ts.map +1 -0
  25. package/esm/utilities/CellSelection.js +382 -0
  26. package/esm/utilities/TableMap.d.ts +92 -0
  27. package/esm/utilities/TableMap.d.ts.map +1 -0
  28. package/esm/utilities/TableMap.js +335 -0
  29. package/esm/utilities/TableView.d.ts +21 -0
  30. package/esm/utilities/TableView.d.ts.map +1 -0
  31. package/esm/utilities/TableView.js +108 -0
  32. package/esm/utilities/columnResizing.d.ts +50 -0
  33. package/esm/utilities/columnResizing.d.ts.map +1 -0
  34. package/esm/utilities/columnResizing.js +307 -0
  35. package/esm/utilities/commands.d.ts +166 -0
  36. package/esm/utilities/commands.d.ts.map +1 -0
  37. package/esm/utilities/commands.js +702 -0
  38. package/esm/utilities/copypaste.d.ts +35 -0
  39. package/esm/utilities/copypaste.d.ts.map +1 -0
  40. package/esm/utilities/copypaste.js +283 -0
  41. package/esm/utilities/createCell.d.ts +3 -0
  42. package/esm/utilities/createCell.d.ts.map +1 -0
  43. package/esm/utilities/createCell.js +6 -0
  44. package/esm/utilities/createTable.d.ts +3 -0
  45. package/esm/utilities/createTable.d.ts.map +1 -0
  46. package/esm/utilities/createTable.js +30 -0
  47. package/esm/utilities/fixTables.d.ts +18 -0
  48. package/esm/utilities/fixTables.d.ts.map +1 -0
  49. package/esm/utilities/fixTables.js +146 -0
  50. package/esm/utilities/getTableNodeTypes.d.ts +5 -0
  51. package/esm/utilities/getTableNodeTypes.d.ts.map +1 -0
  52. package/esm/utilities/getTableNodeTypes.js +14 -0
  53. package/esm/utilities/input.d.ts +21 -0
  54. package/esm/utilities/input.d.ts.map +1 -0
  55. package/esm/utilities/input.js +241 -0
  56. package/esm/utilities/tableEditing.d.ts +23 -0
  57. package/esm/utilities/tableEditing.d.ts.map +1 -0
  58. package/esm/utilities/tableEditing.js +63 -0
  59. package/esm/utilities/tableNodeTypes.d.ts +14 -0
  60. package/esm/utilities/tableNodeTypes.d.ts.map +1 -0
  61. package/esm/utilities/tableNodeTypes.js +16 -0
  62. package/esm/utilities/util.d.ts +73 -0
  63. package/esm/utilities/util.d.ts.map +1 -0
  64. package/esm/utilities/util.js +155 -0
  65. package/package.json +30 -0
package/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Permission is hereby granted, free of charge, to any
2
+ person obtaining a copy of this software and associated
3
+ documentation files (the "Software"), to deal in the
4
+ Software without restriction, including without
5
+ limitation the rights to use, copy, modify, merge,
6
+ publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software
8
+ is furnished to do so, subject to the following
9
+ conditions:
10
+
11
+ The above copyright notice and this permission notice
12
+ shall be included in all copies or substantial portions
13
+ of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16
+ ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17
+ TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19
+ SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23
+ DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Kerebron - Prosemirror based online editor kit
2
+
3
+ Using vanilla Prosemirror modules is often impossible because of incompatibilities.
4
+
5
+ Kerebron forks several prosemirror projects into one monorepo in order to keep them in sync.
6
+
7
+ Project is inspired on https://tiptap.dev/, but instead of building wrapper around a wrapper it borrows concept of extension and command manager.
8
+
9
+ It has simplified tooling (deno), fewer dependencies and resulting in lower number of output npm modules.
10
+
11
+ **Work in progress**
12
+
13
+ ## Development
14
+
15
+ To start example server:
16
+
17
+ ```
18
+ deno task -f example-server-hono start
19
+ ```
20
+
21
+ ## Build
22
+
23
+ # NPM packages are generated using DNT
24
+
25
+ - https://deno.com/blog/publish-esm-cjs-module-dnt - the easiest way to publish
26
+ a hybrid npm module for ESM and CommonJS
27
+ - https://github.com/denoland/dnt
28
+ - https://gaubee.com/article/Publishing-Your-Deno-Project-as-a-Monorepo-using-dnt/
29
+
30
+ To generate npm packages
31
+
32
+ ```shell
33
+ deno -A ./scripts/build_npm.ts
34
+ ```
@@ -0,0 +1,48 @@
1
+ .ProseMirror .tableWrapper {
2
+ overflow-x: auto;
3
+ }
4
+ .ProseMirror table {
5
+ border-collapse: collapse;
6
+ table-layout: fixed;
7
+ width: 100%;
8
+ overflow: hidden;
9
+ }
10
+ .ProseMirror td,
11
+ .ProseMirror th {
12
+ vertical-align: top;
13
+ box-sizing: border-box;
14
+ position: relative;
15
+ }
16
+
17
+ .ProseMirror td:not([data-colwidth]):not(.column-resize-dragging),
18
+ .ProseMirror th:not([data-colwidth]):not(.column-resize-dragging) {
19
+ /* if there's no explicit width set and the column is not being resized, set a default width */
20
+ min-width: var(--default-cell-min-width);
21
+ }
22
+
23
+ .ProseMirror .column-resize-handle {
24
+ position: absolute;
25
+ right: -2px;
26
+ top: 0;
27
+ bottom: 0;
28
+ width: 4px;
29
+ z-index: 20;
30
+ background-color: #adf;
31
+ pointer-events: none;
32
+ }
33
+ .ProseMirror.resize-cursor {
34
+ cursor: ew-resize;
35
+ cursor: col-resize;
36
+ }
37
+ /* Give selected cells a blue overlay */
38
+ .ProseMirror .selectedCell:after {
39
+ z-index: 2;
40
+ position: absolute;
41
+ content: '';
42
+ left: 0;
43
+ right: 0;
44
+ top: 0;
45
+ bottom: 0;
46
+ background: rgba(200, 200, 255, 0.4);
47
+ pointer-events: none;
48
+ }
@@ -0,0 +1,10 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,27 @@
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
+ constructor() {
8
+ super(...arguments);
9
+ Object.defineProperty(this, "name", {
10
+ enumerable: true,
11
+ configurable: true,
12
+ writable: true,
13
+ value: 'extension-tables'
14
+ });
15
+ Object.defineProperty(this, "requires", {
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true,
19
+ value: [
20
+ new NodeTable(),
21
+ new NodeTableHeader(),
22
+ new NodeTableRow(),
23
+ new NodeTableCell(),
24
+ ]
25
+ });
26
+ }
27
+ }
@@ -0,0 +1,24 @@
1
+ import { NodeSpec, NodeType } from 'prosemirror-model';
2
+ import { type CoreEditor, Node } from '@kerebron/editor';
3
+ import { type Commands, 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
+ automerge: {
10
+ block: string;
11
+ };
12
+ attributes: {
13
+ class: {
14
+ default: string;
15
+ fromDom(element: HTMLElement): any;
16
+ };
17
+ };
18
+ getNodeSpec(): NodeSpec;
19
+ getInputRules(type: NodeType): InputRule[];
20
+ getCommands(editor: CoreEditor, type: NodeType): Partial<Commands>;
21
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
22
+ getProseMirrorPlugins(editor: CoreEditor): Plugin[];
23
+ }
24
+ //# sourceMappingURL=NodeTable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeTable.d.ts","sourceRoot":"","sources":["../src/NodeTable.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,KAAK,UAAU,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EACL,KAAK,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sCAAsC,CAAC;AA4BtE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,qBAAa,SAAU,SAAQ,IAAI;IACxB,IAAI,SAAW;IACxB,QAAQ,WAAW;IAEnB,SAAS;;MAEP;IAEF,UAAU;;;6BAGW,WAAW;;MAM9B;IAEO,WAAW,IAAI,QAAQ;IAcvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAI1C,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAoDlE,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAKjD,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE;CAM7D"}
@@ -0,0 +1,115 @@
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 { fixTables } from './utilities/fixTables.js';
6
+ import { CellSelection } from './utilities/CellSelection.js';
7
+ import { columnResizing } from './utilities/columnResizing.js';
8
+ import { tableEditing } from './utilities/tableEditing.js';
9
+ import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, deleteColumn, deleteRow, deleteTable, goToNextCell, mergeCells, setCellAttr, splitCell, toggleHeader, toggleHeaderCell, toggleHeaderColumn, toggleHeaderRow, } from './utilities/commands.js';
10
+ export class NodeTable extends Node {
11
+ constructor() {
12
+ super(...arguments);
13
+ Object.defineProperty(this, "name", {
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true,
17
+ value: 'table'
18
+ });
19
+ Object.defineProperty(this, "requires", {
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true,
23
+ value: ['doc']
24
+ });
25
+ Object.defineProperty(this, "automerge", {
26
+ enumerable: true,
27
+ configurable: true,
28
+ writable: true,
29
+ value: {
30
+ block: 'table',
31
+ }
32
+ });
33
+ Object.defineProperty(this, "attributes", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: {
38
+ class: {
39
+ default: 'table',
40
+ fromDom(element) {
41
+ return element.hasAttribute('class')
42
+ ? element.getAttribute('class')
43
+ : undefined;
44
+ },
45
+ },
46
+ }
47
+ });
48
+ }
49
+ getNodeSpec() {
50
+ return {
51
+ content: 'table_row+',
52
+ tableRole: 'table',
53
+ isolating: true,
54
+ group: 'block',
55
+ parseDOM: [{
56
+ tag: 'table',
57
+ getAttrs: (element) => setHtmlAttributes(this, element),
58
+ }],
59
+ toDOM: (node) => ['table', getHtmlAttributes(this, node), ['tbody', 0]],
60
+ };
61
+ }
62
+ getInputRules(type) {
63
+ return [];
64
+ }
65
+ getCommands(editor, type) {
66
+ const commands = {
67
+ addColumnAfter: (state, dispatch) => addColumnAfter(state, dispatch),
68
+ addColumnBefore: (state, dispatch) => addColumnBefore(state, dispatch),
69
+ addRowAfter: (state, dispatch) => addRowAfter(state, dispatch),
70
+ addRowBefore: (state, dispatch) => addRowBefore(state, dispatch),
71
+ deleteColumn: (state, dispatch) => deleteColumn(state, dispatch),
72
+ deleteRow: (state, dispatch) => deleteRow(state, dispatch),
73
+ deleteTable: (state, dispatch) => deleteTable(state, dispatch),
74
+ fixTables: (state, dispatch) => fixTables(state, dispatch),
75
+ goToNextCell: (state, dispatch) => goToNextCell(state, dispatch),
76
+ mergeCells: (state, dispatch) => mergeCells(state, dispatch),
77
+ setCellAttr: (state, dispatch) => setCellAttr(state, dispatch),
78
+ splitCell: (state, dispatch) => splitCell(state, dispatch),
79
+ toggleHeader: (state, dispatch) => toggleHeader(state, dispatch),
80
+ toggleHeaderCell: (state, dispatch) => toggleHeaderCell(state, dispatch),
81
+ toggleHeaderRow: (state, dispatch) => toggleHeaderRow(state, dispatch),
82
+ toggleHeaderColumn: (state, dispatch) => toggleHeaderColumn(state, dispatch),
83
+ insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => (state, dispatch) => {
84
+ const tr = state.tr;
85
+ const node = createTable(editor.schema, rows, cols, withHeaderRow);
86
+ if (dispatch) {
87
+ const offset = tr.selection.from + 1;
88
+ tr.replaceSelectionWith(node)
89
+ .scrollIntoView()
90
+ .setSelection(TextSelection.near(tr.doc.resolve(offset)));
91
+ }
92
+ return true;
93
+ },
94
+ setCellSelection: (position) => (state, dispatch) => {
95
+ if (dispatch) {
96
+ const selection = CellSelection.create(state.doc, position.anchorCell, position.headCell);
97
+ state.setSelection(selection);
98
+ // state.tr.setSelection(selection)
99
+ }
100
+ return true;
101
+ },
102
+ };
103
+ return commands;
104
+ }
105
+ getKeyboardShortcuts() {
106
+ const keys = {};
107
+ return keys;
108
+ }
109
+ getProseMirrorPlugins(editor) {
110
+ return [
111
+ columnResizing(),
112
+ tableEditing(),
113
+ ];
114
+ }
115
+ }
@@ -0,0 +1,16 @@
1
+ import { NodeSpec, NodeType } from 'prosemirror-model';
2
+ import { type CoreEditor, Node } from '@kerebron/editor';
3
+ import { type Commands, 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
+ automerge: {
9
+ block: string;
10
+ };
11
+ getNodeSpec(): NodeSpec;
12
+ getInputRules(type: NodeType): InputRule[];
13
+ getCommands(editor: CoreEditor, type: NodeType): Partial<Commands>;
14
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
15
+ }
16
+ //# sourceMappingURL=NodeTableCell.d.ts.map
@@ -0,0 +1 @@
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,QAAQ,EACb,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;IAEzB,SAAS;;MAEP;IAEO,WAAW,IAAI,QAAQ;IAmBvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAI1C,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKlE,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAI3D"}
@@ -0,0 +1,77 @@
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
+ constructor() {
26
+ super(...arguments);
27
+ Object.defineProperty(this, "name", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: 'table_cell'
32
+ });
33
+ Object.defineProperty(this, "requires", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: ['table_row']
38
+ });
39
+ Object.defineProperty(this, "automerge", {
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true,
43
+ value: {
44
+ block: 'table_cell',
45
+ }
46
+ });
47
+ }
48
+ getNodeSpec() {
49
+ return {
50
+ content: 'block+',
51
+ attrs: {
52
+ colspan: { default: 1 },
53
+ rowspan: { default: 1 },
54
+ colwidth: { default: null },
55
+ },
56
+ tableRole: 'cell',
57
+ isolating: true,
58
+ parseDOM: [
59
+ { tag: 'td', getAttrs: (dom) => getCellAttrs(dom) },
60
+ ],
61
+ toDOM(node) {
62
+ return ['td', setCellAttrs(node), 0];
63
+ },
64
+ };
65
+ }
66
+ getInputRules(type) {
67
+ return [];
68
+ }
69
+ getCommands(editor, type) {
70
+ const commands = {};
71
+ return commands;
72
+ }
73
+ getKeyboardShortcuts() {
74
+ const keys = {};
75
+ return keys;
76
+ }
77
+ }
@@ -0,0 +1,16 @@
1
+ import { NodeSpec, NodeType } from 'prosemirror-model';
2
+ import { type CoreEditor, Node } from '@kerebron/editor';
3
+ import { type Commands, type CommandShortcuts } from '@kerebron/editor/commands';
4
+ import { type InputRule } from '@kerebron/editor/plugins/input-rules';
5
+ export declare class NodeTableHeader extends Node {
6
+ name: string;
7
+ requires: string[];
8
+ automerge: {
9
+ block: string;
10
+ };
11
+ getNodeSpec(): NodeSpec;
12
+ getInputRules(type: NodeType): InputRule[];
13
+ getCommands(editor: CoreEditor, type: NodeType): Partial<Commands>;
14
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
15
+ }
16
+ //# sourceMappingURL=NodeTableHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NodeTableHeader.d.ts","sourceRoot":"","sources":["../src/NodeTableHeader.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,QAAQ,EACb,KAAK,gBAAgB,EACtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,sCAAsC,CAAC;AA2BtE,qBAAa,eAAgB,SAAQ,IAAI;IAC9B,IAAI,SAAkB;IAC/B,QAAQ,WAAa;IAErB,SAAS;;MAEP;IAEO,WAAW,IAAI,QAAQ;IAiBvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAI1C,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAKlE,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAI3D"}
@@ -0,0 +1,75 @@
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
+ constructor() {
26
+ super(...arguments);
27
+ Object.defineProperty(this, "name", {
28
+ enumerable: true,
29
+ configurable: true,
30
+ writable: true,
31
+ value: 'table_header'
32
+ });
33
+ Object.defineProperty(this, "requires", {
34
+ enumerable: true,
35
+ configurable: true,
36
+ writable: true,
37
+ value: ['table']
38
+ });
39
+ Object.defineProperty(this, "automerge", {
40
+ enumerable: true,
41
+ configurable: true,
42
+ writable: true,
43
+ value: {
44
+ block: 'table_header',
45
+ }
46
+ });
47
+ }
48
+ getNodeSpec() {
49
+ return {
50
+ content: 'block+',
51
+ attrs: {
52
+ colspan: { default: 1 },
53
+ rowspan: { default: 1 },
54
+ colwidth: { default: null },
55
+ },
56
+ tableRole: 'header_cell',
57
+ isolating: true,
58
+ parseDOM: [
59
+ { tag: 'th', getAttrs: (dom) => getCellAttrs(dom) },
60
+ ],
61
+ toDOM: (node) => ['th', setCellAttrs(node), 0],
62
+ };
63
+ }
64
+ getInputRules(type) {
65
+ return [];
66
+ }
67
+ getCommands(editor, type) {
68
+ const commands = {};
69
+ return commands;
70
+ }
71
+ getKeyboardShortcuts() {
72
+ const keys = {};
73
+ return keys;
74
+ }
75
+ }
@@ -0,0 +1,16 @@
1
+ import { NodeSpec, NodeType } from 'prosemirror-model';
2
+ import { type CoreEditor, Node } from '@kerebron/editor';
3
+ import { type Commands, 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
+ automerge: {
9
+ block: string;
10
+ };
11
+ getNodeSpec(): NodeSpec;
12
+ getInputRules(type: NodeType): InputRule[];
13
+ getCommands(editor: CoreEditor, type: NodeType): Partial<Commands>;
14
+ getKeyboardShortcuts(): Partial<CommandShortcuts>;
15
+ }
16
+ //# sourceMappingURL=NodeTableRow.d.ts.map
@@ -0,0 +1 @@
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,QAAQ,EACb,KAAK,gBAAgB,EAEtB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,KAAK,SAAS,EAEf,MAAM,sCAAsC,CAAC;AAE9C,qBAAa,YAAa,SAAQ,IAAI;IAC3B,IAAI,SAAe;IAC5B,QAAQ,WAAa;IAErB,SAAS;;MAEP;IAEO,WAAW,IAAI,QAAQ;IAWvB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,EAAE;IAI1C,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAMlE,oBAAoB,IAAI,OAAO,CAAC,gBAAgB,CAAC;CAI3D"}
@@ -0,0 +1,47 @@
1
+ import { Node } from '@kerebron/editor';
2
+ export class NodeTableRow extends Node {
3
+ constructor() {
4
+ super(...arguments);
5
+ Object.defineProperty(this, "name", {
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true,
9
+ value: 'table_row'
10
+ });
11
+ Object.defineProperty(this, "requires", {
12
+ enumerable: true,
13
+ configurable: true,
14
+ writable: true,
15
+ value: ['table']
16
+ });
17
+ Object.defineProperty(this, "automerge", {
18
+ enumerable: true,
19
+ configurable: true,
20
+ writable: true,
21
+ value: {
22
+ block: 'table_row',
23
+ }
24
+ });
25
+ }
26
+ getNodeSpec() {
27
+ return {
28
+ content: '(table_cell | table_header)*',
29
+ tableRole: 'row',
30
+ parseDOM: [{ tag: 'tr' }],
31
+ toDOM() {
32
+ return ['tr', 0];
33
+ },
34
+ };
35
+ }
36
+ getInputRules(type) {
37
+ return [];
38
+ }
39
+ getCommands(editor, type) {
40
+ const commands = {};
41
+ return commands;
42
+ }
43
+ getKeyboardShortcuts() {
44
+ const keys = {};
45
+ return keys;
46
+ }
47
+ }
@@ -0,0 +1,6 @@
1
+ import { Deno } from "@deno/shim-deno";
2
+ export { Deno } from "@deno/shim-deno";
3
+ export declare const dntGlobalThis: Omit<typeof globalThis, "Deno"> & {
4
+ Deno: typeof Deno;
5
+ };
6
+ //# sourceMappingURL=_dnt.shims.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAKvC,eAAO,MAAM,aAAa;;CAA2C,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { Deno } from "@deno/shim-deno";
2
+ export { Deno } from "@deno/shim-deno";
3
+ const dntGlobals = {
4
+ Deno,
5
+ };
6
+ export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
7
+ function createMergeProxy(baseObj, extObj) {
8
+ return new Proxy(baseObj, {
9
+ get(_target, prop, _receiver) {
10
+ if (prop in extObj) {
11
+ return extObj[prop];
12
+ }
13
+ else {
14
+ return baseObj[prop];
15
+ }
16
+ },
17
+ set(_target, prop, value) {
18
+ if (prop in extObj) {
19
+ delete extObj[prop];
20
+ }
21
+ baseObj[prop] = value;
22
+ return true;
23
+ },
24
+ deleteProperty(_target, prop) {
25
+ let success = false;
26
+ if (prop in extObj) {
27
+ delete extObj[prop];
28
+ success = true;
29
+ }
30
+ if (prop in baseObj) {
31
+ delete baseObj[prop];
32
+ success = true;
33
+ }
34
+ return success;
35
+ },
36
+ ownKeys(_target) {
37
+ const baseKeys = Reflect.ownKeys(baseObj);
38
+ const extKeys = Reflect.ownKeys(extObj);
39
+ const extKeysSet = new Set(extKeys);
40
+ return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
41
+ },
42
+ defineProperty(_target, prop, desc) {
43
+ if (prop in extObj) {
44
+ delete extObj[prop];
45
+ }
46
+ Reflect.defineProperty(baseObj, prop, desc);
47
+ return true;
48
+ },
49
+ getOwnPropertyDescriptor(_target, prop) {
50
+ if (prop in extObj) {
51
+ return Reflect.getOwnPropertyDescriptor(extObj, prop);
52
+ }
53
+ else {
54
+ return Reflect.getOwnPropertyDescriptor(baseObj, prop);
55
+ }
56
+ },
57
+ has(_target, prop) {
58
+ return prop in extObj || prop in baseObj;
59
+ },
60
+ });
61
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }