@tiptap/extension-table 3.0.0-next.2 → 3.0.0-next.4

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 (57) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/cell/index.cjs +68 -0
  4. package/dist/cell/index.cjs.map +1 -0
  5. package/dist/cell/index.d.cts +17 -0
  6. package/dist/cell/index.d.ts +17 -0
  7. package/dist/cell/index.js +41 -0
  8. package/dist/cell/index.js.map +1 -0
  9. package/dist/header/index.cjs +68 -0
  10. package/dist/header/index.cjs.map +1 -0
  11. package/dist/header/index.d.cts +17 -0
  12. package/dist/header/index.d.ts +17 -0
  13. package/dist/header/index.js +41 -0
  14. package/dist/header/index.js.map +1 -0
  15. package/dist/index.cjs +148 -31
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +79 -8
  18. package/dist/index.d.ts +79 -8
  19. package/dist/index.js +139 -31
  20. package/dist/index.js.map +1 -1
  21. package/dist/kit/index.cjs +497 -0
  22. package/dist/kit/index.cjs.map +1 -0
  23. package/dist/kit/index.d.cts +249 -0
  24. package/dist/kit/index.d.ts +249 -0
  25. package/dist/kit/index.js +490 -0
  26. package/dist/kit/index.js.map +1 -0
  27. package/dist/row/index.cjs +49 -0
  28. package/dist/row/index.cjs.map +1 -0
  29. package/dist/row/index.d.cts +17 -0
  30. package/dist/row/index.d.ts +17 -0
  31. package/dist/row/index.js +22 -0
  32. package/dist/row/index.js.map +1 -0
  33. package/dist/table/index.cjs +384 -0
  34. package/dist/table/index.cjs.map +1 -0
  35. package/dist/table/index.d.cts +217 -0
  36. package/dist/table/index.d.ts +217 -0
  37. package/dist/table/index.js +373 -0
  38. package/dist/table/index.js.map +1 -0
  39. package/package.json +50 -6
  40. package/src/cell/index.ts +1 -0
  41. package/src/cell/table-cell.ts +58 -0
  42. package/src/header/index.ts +1 -0
  43. package/src/header/table-header.ts +58 -0
  44. package/src/index.ts +5 -7
  45. package/src/kit/index.ts +60 -0
  46. package/src/row/index.ts +1 -0
  47. package/src/row/table-row.ts +36 -0
  48. package/src/{TableView.ts → table/TableView.ts} +4 -7
  49. package/src/table/index.ts +3 -0
  50. package/src/{table.ts → table/table.ts} +55 -47
  51. package/src/{utilities → table/utilities}/colStyle.ts +0 -1
  52. package/src/{utilities → table/utilities}/createColGroup.ts +10 -14
  53. /package/src/{utilities → table/utilities}/createCell.ts +0 -0
  54. /package/src/{utilities → table/utilities}/createTable.ts +0 -0
  55. /package/src/{utilities → table/utilities}/deleteTableWhenAllCellsSelected.ts +0 -0
  56. /package/src/{utilities → table/utilities}/getTableNodeTypes.ts +0 -0
  57. /package/src/{utilities → table/utilities}/isCellSelection.ts +0 -0
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024, Tiptap GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,14 +1,18 @@
1
1
  # @tiptap/extension-table
2
+
2
3
  [![Version](https://img.shields.io/npm/v/@tiptap/extension-table.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-table)
3
4
  [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-table.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
4
5
  [![License](https://img.shields.io/npm/l/@tiptap/extension-table.svg)](https://www.npmjs.com/package/@tiptap/extension-table)
5
6
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
7
 
7
8
  ## Introduction
8
- Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
9
+
10
+ Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_.
9
11
 
10
12
  ## Official Documentation
13
+
11
14
  Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
15
 
13
16
  ## License
17
+
14
18
  Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/cell/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ TableCell: () => TableCell
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/cell/table-cell.ts
28
+ var import_core = require("@tiptap/core");
29
+ var TableCell = import_core.Node.create({
30
+ name: "tableCell",
31
+ addOptions() {
32
+ return {
33
+ HTMLAttributes: {}
34
+ };
35
+ },
36
+ content: "block+",
37
+ addAttributes() {
38
+ return {
39
+ colspan: {
40
+ default: 1
41
+ },
42
+ rowspan: {
43
+ default: 1
44
+ },
45
+ colwidth: {
46
+ default: null,
47
+ parseHTML: (element) => {
48
+ const colwidth = element.getAttribute("colwidth");
49
+ const value = colwidth ? colwidth.split(",").map((width) => parseInt(width, 10)) : null;
50
+ return value;
51
+ }
52
+ }
53
+ };
54
+ },
55
+ tableRole: "cell",
56
+ isolating: true,
57
+ parseHTML() {
58
+ return [{ tag: "td" }];
59
+ },
60
+ renderHTML({ HTMLAttributes }) {
61
+ return ["td", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
62
+ }
63
+ });
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ TableCell
67
+ });
68
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cell/index.ts","../../src/cell/table-cell.ts"],"sourcesContent":["export * from './table-cell.js'\n","import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface TableCellOptions {\n /**\n * The HTML attributes for a table cell node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n}\n\n/**\n * This extension allows you to create table cells.\n * @see https://www.tiptap.dev/api/nodes/table-cell\n */\nexport const TableCell = Node.create<TableCellOptions>({\n name: 'tableCell',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n content: 'block+',\n\n addAttributes() {\n return {\n colspan: {\n default: 1,\n },\n rowspan: {\n default: 1,\n },\n colwidth: {\n default: null,\n parseHTML: element => {\n const colwidth = element.getAttribute('colwidth')\n const value = colwidth ? colwidth.split(',').map(width => parseInt(width, 10)) : null\n\n return value\n },\n },\n }\n },\n\n tableRole: 'cell',\n\n isolating: true,\n\n parseHTML() {\n return [{ tag: 'td' }]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['td', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAsC;AAe/B,IAAM,YAAY,iBAAK,OAAyB;AAAA,EACrD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,SAAS;AAAA,EAET,gBAAgB;AACd,WAAO;AAAA,MACL,SAAS;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,SAAS;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,UAAU;AAAA,QACR,SAAS;AAAA,QACT,WAAW,aAAW;AACpB,gBAAM,WAAW,QAAQ,aAAa,UAAU;AAChD,gBAAM,QAAQ,WAAW,SAAS,MAAM,GAAG,EAAE,IAAI,WAAS,SAAS,OAAO,EAAE,CAAC,IAAI;AAEjF,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW;AAAA,EAEX,WAAW;AAAA,EAEX,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA,EACvB;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,UAAM,6BAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EAC/E;AACF,CAAC;","names":[]}
@@ -0,0 +1,17 @@
1
+ import { Node } from '@tiptap/core';
2
+
3
+ interface TableCellOptions {
4
+ /**
5
+ * The HTML attributes for a table cell node.
6
+ * @default {}
7
+ * @example { class: 'foo' }
8
+ */
9
+ HTMLAttributes: Record<string, any>;
10
+ }
11
+ /**
12
+ * This extension allows you to create table cells.
13
+ * @see https://www.tiptap.dev/api/nodes/table-cell
14
+ */
15
+ declare const TableCell: Node<TableCellOptions, any>;
16
+
17
+ export { TableCell, type TableCellOptions };
@@ -0,0 +1,17 @@
1
+ import { Node } from '@tiptap/core';
2
+
3
+ interface TableCellOptions {
4
+ /**
5
+ * The HTML attributes for a table cell node.
6
+ * @default {}
7
+ * @example { class: 'foo' }
8
+ */
9
+ HTMLAttributes: Record<string, any>;
10
+ }
11
+ /**
12
+ * This extension allows you to create table cells.
13
+ * @see https://www.tiptap.dev/api/nodes/table-cell
14
+ */
15
+ declare const TableCell: Node<TableCellOptions, any>;
16
+
17
+ export { TableCell, type TableCellOptions };
@@ -0,0 +1,41 @@
1
+ // src/cell/table-cell.ts
2
+ import { mergeAttributes, Node } from "@tiptap/core";
3
+ var TableCell = Node.create({
4
+ name: "tableCell",
5
+ addOptions() {
6
+ return {
7
+ HTMLAttributes: {}
8
+ };
9
+ },
10
+ content: "block+",
11
+ addAttributes() {
12
+ return {
13
+ colspan: {
14
+ default: 1
15
+ },
16
+ rowspan: {
17
+ default: 1
18
+ },
19
+ colwidth: {
20
+ default: null,
21
+ parseHTML: (element) => {
22
+ const colwidth = element.getAttribute("colwidth");
23
+ const value = colwidth ? colwidth.split(",").map((width) => parseInt(width, 10)) : null;
24
+ return value;
25
+ }
26
+ }
27
+ };
28
+ },
29
+ tableRole: "cell",
30
+ isolating: true,
31
+ parseHTML() {
32
+ return [{ tag: "td" }];
33
+ },
34
+ renderHTML({ HTMLAttributes }) {
35
+ return ["td", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
36
+ }
37
+ });
38
+ export {
39
+ TableCell
40
+ };
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/cell/table-cell.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface TableCellOptions {\n /**\n * The HTML attributes for a table cell node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n}\n\n/**\n * This extension allows you to create table cells.\n * @see https://www.tiptap.dev/api/nodes/table-cell\n */\nexport const TableCell = Node.create<TableCellOptions>({\n name: 'tableCell',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n content: 'block+',\n\n addAttributes() {\n return {\n colspan: {\n default: 1,\n },\n rowspan: {\n default: 1,\n },\n colwidth: {\n default: null,\n parseHTML: element => {\n const colwidth = element.getAttribute('colwidth')\n const value = colwidth ? colwidth.split(',').map(width => parseInt(width, 10)) : null\n\n return value\n },\n },\n }\n },\n\n tableRole: 'cell',\n\n isolating: true,\n\n parseHTML() {\n return [{ tag: 'td' }]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['td', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n})\n"],"mappings":";AAAA,SAAS,iBAAiB,YAAY;AAe/B,IAAM,YAAY,KAAK,OAAyB;AAAA,EACrD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,SAAS;AAAA,EAET,gBAAgB;AACd,WAAO;AAAA,MACL,SAAS;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,SAAS;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,UAAU;AAAA,QACR,SAAS;AAAA,QACT,WAAW,aAAW;AACpB,gBAAM,WAAW,QAAQ,aAAa,UAAU;AAChD,gBAAM,QAAQ,WAAW,SAAS,MAAM,GAAG,EAAE,IAAI,WAAS,SAAS,OAAO,EAAE,CAAC,IAAI;AAEjF,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW;AAAA,EAEX,WAAW;AAAA,EAEX,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA,EACvB;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,MAAM,gBAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EAC/E;AACF,CAAC;","names":[]}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/header/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ TableHeader: () => TableHeader
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/header/table-header.ts
28
+ var import_core = require("@tiptap/core");
29
+ var TableHeader = import_core.Node.create({
30
+ name: "tableHeader",
31
+ addOptions() {
32
+ return {
33
+ HTMLAttributes: {}
34
+ };
35
+ },
36
+ content: "block+",
37
+ addAttributes() {
38
+ return {
39
+ colspan: {
40
+ default: 1
41
+ },
42
+ rowspan: {
43
+ default: 1
44
+ },
45
+ colwidth: {
46
+ default: null,
47
+ parseHTML: (element) => {
48
+ const colwidth = element.getAttribute("colwidth");
49
+ const value = colwidth ? colwidth.split(",").map((width) => parseInt(width, 10)) : null;
50
+ return value;
51
+ }
52
+ }
53
+ };
54
+ },
55
+ tableRole: "header_cell",
56
+ isolating: true,
57
+ parseHTML() {
58
+ return [{ tag: "th" }];
59
+ },
60
+ renderHTML({ HTMLAttributes }) {
61
+ return ["th", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
62
+ }
63
+ });
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ TableHeader
67
+ });
68
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/header/index.ts","../../src/header/table-header.ts"],"sourcesContent":["export * from './table-header.js'\n","import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface TableHeaderOptions {\n /**\n * The HTML attributes for a table header node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n}\n\n/**\n * This extension allows you to create table headers.\n * @see https://www.tiptap.dev/api/nodes/table-header\n */\nexport const TableHeader = Node.create<TableHeaderOptions>({\n name: 'tableHeader',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n content: 'block+',\n\n addAttributes() {\n return {\n colspan: {\n default: 1,\n },\n rowspan: {\n default: 1,\n },\n colwidth: {\n default: null,\n parseHTML: element => {\n const colwidth = element.getAttribute('colwidth')\n const value = colwidth ? colwidth.split(',').map(width => parseInt(width, 10)) : null\n\n return value\n },\n },\n }\n },\n\n tableRole: 'header_cell',\n\n isolating: true,\n\n parseHTML() {\n return [{ tag: 'th' }]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['th', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAsC;AAe/B,IAAM,cAAc,iBAAK,OAA2B;AAAA,EACzD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,SAAS;AAAA,EAET,gBAAgB;AACd,WAAO;AAAA,MACL,SAAS;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,SAAS;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,UAAU;AAAA,QACR,SAAS;AAAA,QACT,WAAW,aAAW;AACpB,gBAAM,WAAW,QAAQ,aAAa,UAAU;AAChD,gBAAM,QAAQ,WAAW,SAAS,MAAM,GAAG,EAAE,IAAI,WAAS,SAAS,OAAO,EAAE,CAAC,IAAI;AAEjF,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW;AAAA,EAEX,WAAW;AAAA,EAEX,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA,EACvB;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,UAAM,6BAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EAC/E;AACF,CAAC;","names":[]}
@@ -0,0 +1,17 @@
1
+ import { Node } from '@tiptap/core';
2
+
3
+ interface TableHeaderOptions {
4
+ /**
5
+ * The HTML attributes for a table header node.
6
+ * @default {}
7
+ * @example { class: 'foo' }
8
+ */
9
+ HTMLAttributes: Record<string, any>;
10
+ }
11
+ /**
12
+ * This extension allows you to create table headers.
13
+ * @see https://www.tiptap.dev/api/nodes/table-header
14
+ */
15
+ declare const TableHeader: Node<TableHeaderOptions, any>;
16
+
17
+ export { TableHeader, type TableHeaderOptions };
@@ -0,0 +1,17 @@
1
+ import { Node } from '@tiptap/core';
2
+
3
+ interface TableHeaderOptions {
4
+ /**
5
+ * The HTML attributes for a table header node.
6
+ * @default {}
7
+ * @example { class: 'foo' }
8
+ */
9
+ HTMLAttributes: Record<string, any>;
10
+ }
11
+ /**
12
+ * This extension allows you to create table headers.
13
+ * @see https://www.tiptap.dev/api/nodes/table-header
14
+ */
15
+ declare const TableHeader: Node<TableHeaderOptions, any>;
16
+
17
+ export { TableHeader, type TableHeaderOptions };
@@ -0,0 +1,41 @@
1
+ // src/header/table-header.ts
2
+ import { mergeAttributes, Node } from "@tiptap/core";
3
+ var TableHeader = Node.create({
4
+ name: "tableHeader",
5
+ addOptions() {
6
+ return {
7
+ HTMLAttributes: {}
8
+ };
9
+ },
10
+ content: "block+",
11
+ addAttributes() {
12
+ return {
13
+ colspan: {
14
+ default: 1
15
+ },
16
+ rowspan: {
17
+ default: 1
18
+ },
19
+ colwidth: {
20
+ default: null,
21
+ parseHTML: (element) => {
22
+ const colwidth = element.getAttribute("colwidth");
23
+ const value = colwidth ? colwidth.split(",").map((width) => parseInt(width, 10)) : null;
24
+ return value;
25
+ }
26
+ }
27
+ };
28
+ },
29
+ tableRole: "header_cell",
30
+ isolating: true,
31
+ parseHTML() {
32
+ return [{ tag: "th" }];
33
+ },
34
+ renderHTML({ HTMLAttributes }) {
35
+ return ["th", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
36
+ }
37
+ });
38
+ export {
39
+ TableHeader
40
+ };
41
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/header/table-header.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\n\nexport interface TableHeaderOptions {\n /**\n * The HTML attributes for a table header node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n}\n\n/**\n * This extension allows you to create table headers.\n * @see https://www.tiptap.dev/api/nodes/table-header\n */\nexport const TableHeader = Node.create<TableHeaderOptions>({\n name: 'tableHeader',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n content: 'block+',\n\n addAttributes() {\n return {\n colspan: {\n default: 1,\n },\n rowspan: {\n default: 1,\n },\n colwidth: {\n default: null,\n parseHTML: element => {\n const colwidth = element.getAttribute('colwidth')\n const value = colwidth ? colwidth.split(',').map(width => parseInt(width, 10)) : null\n\n return value\n },\n },\n }\n },\n\n tableRole: 'header_cell',\n\n isolating: true,\n\n parseHTML() {\n return [{ tag: 'th' }]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['th', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n})\n"],"mappings":";AAAA,SAAS,iBAAiB,YAAY;AAe/B,IAAM,cAAc,KAAK,OAA2B;AAAA,EACzD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,SAAS;AAAA,EAET,gBAAgB;AACd,WAAO;AAAA,MACL,SAAS;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,SAAS;AAAA,QACP,SAAS;AAAA,MACX;AAAA,MACA,UAAU;AAAA,QACR,SAAS;AAAA,QACT,WAAW,aAAW;AACpB,gBAAM,WAAW,QAAQ,aAAa,UAAU;AAChD,gBAAM,QAAQ,WAAW,SAAS,MAAM,GAAG,EAAE,IAAI,WAAS,SAAS,OAAO,EAAE,CAAC,IAAI;AAEjF,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW;AAAA,EAEX,WAAW;AAAA,EAEX,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,KAAK,CAAC;AAAA,EACvB;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,MAAM,gBAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EAC/E;AACF,CAAC;","names":[]}
package/dist/index.cjs CHANGED
@@ -18,21 +18,122 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var src_exports = {};
22
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
23
  Table: () => Table,
24
+ TableCell: () => TableCell,
25
+ TableHeader: () => TableHeader,
26
+ TableKit: () => TableKit,
27
+ TableRow: () => TableRow,
24
28
  createColGroup: () => createColGroup,
25
- createTable: () => createTable,
26
- default: () => src_default
29
+ createTable: () => createTable
27
30
  });
28
- module.exports = __toCommonJS(src_exports);
31
+ module.exports = __toCommonJS(index_exports);
29
32
 
30
- // src/table.ts
33
+ // src/cell/table-cell.ts
34
+ var import_core = require("@tiptap/core");
35
+ var TableCell = import_core.Node.create({
36
+ name: "tableCell",
37
+ addOptions() {
38
+ return {
39
+ HTMLAttributes: {}
40
+ };
41
+ },
42
+ content: "block+",
43
+ addAttributes() {
44
+ return {
45
+ colspan: {
46
+ default: 1
47
+ },
48
+ rowspan: {
49
+ default: 1
50
+ },
51
+ colwidth: {
52
+ default: null,
53
+ parseHTML: (element) => {
54
+ const colwidth = element.getAttribute("colwidth");
55
+ const value = colwidth ? colwidth.split(",").map((width) => parseInt(width, 10)) : null;
56
+ return value;
57
+ }
58
+ }
59
+ };
60
+ },
61
+ tableRole: "cell",
62
+ isolating: true,
63
+ parseHTML() {
64
+ return [{ tag: "td" }];
65
+ },
66
+ renderHTML({ HTMLAttributes }) {
67
+ return ["td", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
68
+ }
69
+ });
70
+
71
+ // src/header/table-header.ts
31
72
  var import_core2 = require("@tiptap/core");
73
+ var TableHeader = import_core2.Node.create({
74
+ name: "tableHeader",
75
+ addOptions() {
76
+ return {
77
+ HTMLAttributes: {}
78
+ };
79
+ },
80
+ content: "block+",
81
+ addAttributes() {
82
+ return {
83
+ colspan: {
84
+ default: 1
85
+ },
86
+ rowspan: {
87
+ default: 1
88
+ },
89
+ colwidth: {
90
+ default: null,
91
+ parseHTML: (element) => {
92
+ const colwidth = element.getAttribute("colwidth");
93
+ const value = colwidth ? colwidth.split(",").map((width) => parseInt(width, 10)) : null;
94
+ return value;
95
+ }
96
+ }
97
+ };
98
+ },
99
+ tableRole: "header_cell",
100
+ isolating: true,
101
+ parseHTML() {
102
+ return [{ tag: "th" }];
103
+ },
104
+ renderHTML({ HTMLAttributes }) {
105
+ return ["th", (0, import_core2.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
106
+ }
107
+ });
108
+
109
+ // src/kit/index.ts
110
+ var import_core6 = require("@tiptap/core");
111
+
112
+ // src/row/table-row.ts
113
+ var import_core3 = require("@tiptap/core");
114
+ var TableRow = import_core3.Node.create({
115
+ name: "tableRow",
116
+ addOptions() {
117
+ return {
118
+ HTMLAttributes: {}
119
+ };
120
+ },
121
+ content: "(tableCell | tableHeader)*",
122
+ tableRole: "row",
123
+ parseHTML() {
124
+ return [{ tag: "tr" }];
125
+ },
126
+ renderHTML({ HTMLAttributes }) {
127
+ return ["tr", (0, import_core3.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
128
+ }
129
+ });
130
+
131
+ // src/table/table.ts
132
+ var import_core5 = require("@tiptap/core");
32
133
  var import_state = require("@tiptap/pm/state");
33
134
  var import_tables2 = require("@tiptap/pm/tables");
34
135
 
35
- // src/utilities/colStyle.ts
136
+ // src/table/utilities/colStyle.ts
36
137
  function getColStyleDeclaration(minWidth, width) {
37
138
  if (width) {
38
139
  return ["width", `${Math.max(width, minWidth)}px`];
@@ -40,7 +141,7 @@ function getColStyleDeclaration(minWidth, width) {
40
141
  return ["min-width", `${minWidth}px`];
41
142
  }
42
143
 
43
- // src/TableView.ts
144
+ // src/table/TableView.ts
44
145
  function updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {
45
146
  var _a;
46
147
  let totalWidth = 0;
@@ -109,7 +210,7 @@ var TableView = class {
109
210
  }
110
211
  };
111
212
 
112
- // src/utilities/createColGroup.ts
213
+ // src/table/utilities/createColGroup.ts
113
214
  function createColGroup(node, cellMinWidth, overrideCol, overrideValue) {
114
215
  let totalWidth = 0;
115
216
  let fixedWidth = true;
@@ -127,10 +228,7 @@ function createColGroup(node, cellMinWidth, overrideCol, overrideValue) {
127
228
  fixedWidth = false;
128
229
  }
129
230
  const [property, value] = getColStyleDeclaration(cellMinWidth, hasWidth);
130
- cols.push([
131
- "col",
132
- { style: `${property}: ${value}` }
133
- ]);
231
+ cols.push(["col", { style: `${property}: ${value}` }]);
134
232
  }
135
233
  }
136
234
  const tableWidth = fixedWidth ? `${totalWidth}px` : "";
@@ -139,7 +237,7 @@ function createColGroup(node, cellMinWidth, overrideCol, overrideValue) {
139
237
  return { colgroup, tableWidth, tableMinWidth };
140
238
  }
141
239
 
142
- // src/utilities/createCell.ts
240
+ // src/table/utilities/createCell.ts
143
241
  function createCell(cellType, cellContent) {
144
242
  if (cellContent) {
145
243
  return cellType.createChecked(null, cellContent);
@@ -147,7 +245,7 @@ function createCell(cellType, cellContent) {
147
245
  return cellType.createAndFill();
148
246
  }
149
247
 
150
- // src/utilities/getTableNodeTypes.ts
248
+ // src/table/utilities/getTableNodeTypes.ts
151
249
  function getTableNodeTypes(schema) {
152
250
  if (schema.cached.tableNodeTypes) {
153
251
  return schema.cached.tableNodeTypes;
@@ -163,7 +261,7 @@ function getTableNodeTypes(schema) {
163
261
  return roles;
164
262
  }
165
263
 
166
- // src/utilities/createTable.ts
264
+ // src/table/utilities/createTable.ts
167
265
  function createTable(schema, rowsCount, colsCount, withHeaderRow, cellContent) {
168
266
  const types = getTableNodeTypes(schema);
169
267
  const headerCells = [];
@@ -187,23 +285,23 @@ function createTable(schema, rowsCount, colsCount, withHeaderRow, cellContent) {
187
285
  return types.table.createChecked(null, rows);
188
286
  }
189
287
 
190
- // src/utilities/deleteTableWhenAllCellsSelected.ts
191
- var import_core = require("@tiptap/core");
288
+ // src/table/utilities/deleteTableWhenAllCellsSelected.ts
289
+ var import_core4 = require("@tiptap/core");
192
290
 
193
- // src/utilities/isCellSelection.ts
291
+ // src/table/utilities/isCellSelection.ts
194
292
  var import_tables = require("@tiptap/pm/tables");
195
293
  function isCellSelection(value) {
196
294
  return value instanceof import_tables.CellSelection;
197
295
  }
198
296
 
199
- // src/utilities/deleteTableWhenAllCellsSelected.ts
297
+ // src/table/utilities/deleteTableWhenAllCellsSelected.ts
200
298
  var deleteTableWhenAllCellsSelected = ({ editor }) => {
201
299
  const { selection } = editor.state;
202
300
  if (!isCellSelection(selection)) {
203
301
  return false;
204
302
  }
205
303
  let cellCount = 0;
206
- const table = (0, import_core.findParentNodeClosestToPos)(selection.ranges[0].$from, (node) => {
304
+ const table = (0, import_core4.findParentNodeClosestToPos)(selection.ranges[0].$from, (node) => {
207
305
  return node.type.name === "table";
208
306
  });
209
307
  table == null ? void 0 : table.node.descendants((node) => {
@@ -222,8 +320,8 @@ var deleteTableWhenAllCellsSelected = ({ editor }) => {
222
320
  return true;
223
321
  };
224
322
 
225
- // src/table.ts
226
- var Table = import_core2.Node.create({
323
+ // src/table/table.ts
324
+ var Table = import_core5.Node.create({
227
325
  name: "table",
228
326
  // @ts-ignore
229
327
  addOptions() {
@@ -246,13 +344,10 @@ var Table = import_core2.Node.create({
246
344
  return [{ tag: "table" }];
247
345
  },
248
346
  renderHTML({ node, HTMLAttributes }) {
249
- const { colgroup, tableWidth, tableMinWidth } = createColGroup(
250
- node,
251
- this.options.cellMinWidth
252
- );
347
+ const { colgroup, tableWidth, tableMinWidth } = createColGroup(node, this.options.cellMinWidth);
253
348
  const table = [
254
349
  "table",
255
- (0, import_core2.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
350
+ (0, import_core5.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, {
256
351
  style: tableWidth ? `width: ${tableWidth}` : `min-width: ${tableMinWidth}`
257
352
  }),
258
353
  colgroup,
@@ -378,16 +473,38 @@ var Table = import_core2.Node.create({
378
473
  storage: extension.storage
379
474
  };
380
475
  return {
381
- tableRole: (0, import_core2.callOrReturn)((0, import_core2.getExtensionField)(extension, "tableRole", context))
476
+ tableRole: (0, import_core5.callOrReturn)((0, import_core5.getExtensionField)(extension, "tableRole", context))
382
477
  };
383
478
  }
384
479
  });
385
480
 
386
- // src/index.ts
387
- var src_default = Table;
481
+ // src/kit/index.ts
482
+ var TableKit = import_core6.Extension.create({
483
+ name: "tableKit",
484
+ addExtensions() {
485
+ const extensions = [];
486
+ if (this.options.table !== false) {
487
+ extensions.push(Table.configure(this.options.table));
488
+ }
489
+ if (this.options.tableCell !== false) {
490
+ extensions.push(TableCell.configure(this.options.tableCell));
491
+ }
492
+ if (this.options.tableHeader !== false) {
493
+ extensions.push(TableHeader.configure(this.options.tableHeader));
494
+ }
495
+ if (this.options.tableRow !== false) {
496
+ extensions.push(TableRow.configure(this.options.tableRow));
497
+ }
498
+ return extensions;
499
+ }
500
+ });
388
501
  // Annotate the CommonJS export names for ESM import in node:
389
502
  0 && (module.exports = {
390
503
  Table,
504
+ TableCell,
505
+ TableHeader,
506
+ TableKit,
507
+ TableRow,
391
508
  createColGroup,
392
509
  createTable
393
510
  });