@fibery/prosemirror-schema 4.22.0 → 4.23.0

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 (79) hide show
  1. package/lib/index.d.ts +10 -10
  2. package/lib/index.js +9 -31
  3. package/lib/src/attr-constraints.d.ts +15 -12
  4. package/lib/src/attr-constraints.js +128 -168
  5. package/lib/src/block-id-utils.d.ts +10 -7
  6. package/lib/src/block-id-utils.js +16 -39
  7. package/lib/src/create-schema.d.ts +16 -15
  8. package/lib/src/create-schema.js +204 -249
  9. package/lib/src/marks/code.d.ts +5 -2
  10. package/lib/src/marks/code.js +10 -10
  11. package/lib/src/marks/em.d.ts +5 -2
  12. package/lib/src/marks/em.js +19 -16
  13. package/lib/src/marks/hint-query.d.ts +5 -2
  14. package/lib/src/marks/hint-query.js +19 -22
  15. package/lib/src/marks/link.d.ts +5 -2
  16. package/lib/src/marks/link.js +40 -36
  17. package/lib/src/marks/linked-highlight.d.ts +9 -7
  18. package/lib/src/marks/linked-highlight.js +38 -51
  19. package/lib/src/marks/strike.d.ts +5 -2
  20. package/lib/src/marks/strike.js +6 -6
  21. package/lib/src/marks/strong.d.ts +5 -2
  22. package/lib/src/marks/strong.js +29 -29
  23. package/lib/src/marks/text-background-color.d.ts +15 -12
  24. package/lib/src/marks/text-background-color.js +63 -81
  25. package/lib/src/marks/underline.d.ts +5 -2
  26. package/lib/src/marks/underline.js +6 -6
  27. package/lib/src/nodes/callout.d.ts +29 -26
  28. package/lib/src/nodes/callout.js +55 -58
  29. package/lib/src/nodes/check-item.d.ts +13 -10
  30. package/lib/src/nodes/check-item.js +32 -33
  31. package/lib/src/nodes/check-list.d.ts +14 -11
  32. package/lib/src/nodes/check-list.js +23 -30
  33. package/lib/src/nodes/code-block.d.ts +5 -2
  34. package/lib/src/nodes/code-block.js +70 -101
  35. package/lib/src/nodes/column.d.ts +5 -2
  36. package/lib/src/nodes/column.js +28 -34
  37. package/lib/src/nodes/columns.d.ts +5 -2
  38. package/lib/src/nodes/columns.js +34 -36
  39. package/lib/src/nodes/emoji.d.ts +28 -26
  40. package/lib/src/nodes/emoji.js +38 -47
  41. package/lib/src/nodes/entity.d.ts +18 -16
  42. package/lib/src/nodes/entity.js +48 -49
  43. package/lib/src/nodes/fibery-view.d.ts +5 -2
  44. package/lib/src/nodes/fibery-view.js +38 -42
  45. package/lib/src/nodes/file.d.ts +37 -34
  46. package/lib/src/nodes/file.js +41 -40
  47. package/lib/src/nodes/heading.d.ts +6 -3
  48. package/lib/src/nodes/heading.js +57 -33
  49. package/lib/src/nodes/image-block.d.ts +5 -2
  50. package/lib/src/nodes/image-block.js +43 -42
  51. package/lib/src/nodes/important.d.ts +5 -2
  52. package/lib/src/nodes/important.js +14 -10
  53. package/lib/src/nodes/math-display.d.ts +5 -2
  54. package/lib/src/nodes/math-display.js +14 -15
  55. package/lib/src/nodes/math-inline.d.ts +5 -2
  56. package/lib/src/nodes/math-inline.js +14 -15
  57. package/lib/src/nodes/media.d.ts +6 -3
  58. package/lib/src/nodes/media.js +52 -68
  59. package/lib/src/nodes/mention.d.ts +12 -9
  60. package/lib/src/nodes/mention.js +36 -37
  61. package/lib/src/nodes/note.d.ts +5 -2
  62. package/lib/src/nodes/note.js +14 -10
  63. package/lib/src/nodes/paragraph.d.ts +5 -2
  64. package/lib/src/nodes/paragraph.js +32 -26
  65. package/lib/src/nodes/table-nodes.d.ts +5 -2
  66. package/lib/src/nodes/table-nodes.js +16 -20
  67. package/lib/src/nodes/types/inline-content.d.ts +10 -8
  68. package/lib/src/nodes/types/inline-content.js +0 -2
  69. package/lib/src/nodes/types/text.d.ts +7 -4
  70. package/lib/src/nodes/types/text.js +0 -2
  71. package/lib/src/nodes/video.d.ts +7 -4
  72. package/lib/src/nodes/video.js +49 -54
  73. package/lib/src/resizable-node-attrs.d.ts +29 -26
  74. package/lib/src/resizable-node-attrs.js +23 -34
  75. package/lib/src/transcription-node-attrs.d.ts +10 -7
  76. package/lib/src/transcription-node-attrs.js +8 -8
  77. package/lib/test-helpers/index.d.ts +7 -4
  78. package/lib/test-helpers/index.js +11 -15
  79. package/package.json +11 -4
@@ -1,62 +1,59 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeCallout = exports.DEFAULT_CALLOUT_ICON = exports.DEFAULT_CALLOUT_ICON_TYPE = void 0;
1
+ //#region src/nodes/callout.ts
4
2
  const nodeType = "data-callout-node";
5
- exports.DEFAULT_CALLOUT_ICON_TYPE = "icon";
6
- exports.DEFAULT_CALLOUT_ICON = "exclamation-circle";
3
+ const DEFAULT_CALLOUT_ICON_TYPE = "icon";
4
+ const DEFAULT_CALLOUT_ICON = "exclamation-circle";
7
5
  const aliasAttr = "data-icon-emoji-alias";
8
- const defaultOptions = {
9
- getEmoji() {
10
- return;
11
- },
12
- };
6
+ const defaultOptions = { getEmoji() {} };
13
7
  const makeCallout = ({ getEmoji } = defaultOptions) => ({
14
- attrs: {
15
- color: { default: "#199EE3" },
16
- iconType: { default: exports.DEFAULT_CALLOUT_ICON_TYPE },
17
- icon: { default: exports.DEFAULT_CALLOUT_ICON },
18
- },
19
- group: "block",
20
- content: "block+",
21
- defining: true,
22
- parseDOM: [
23
- {
24
- tag: `div[${nodeType}]`,
25
- getAttrs(domNode) {
26
- const dom = domNode;
27
- const color = dom.getAttribute("data-color");
28
- const iconType = dom.getAttribute("data-icon-type");
29
- const icon = dom.getAttribute("data-icon");
30
- if (iconType === "emoji") {
31
- // A custom emoji is stored in `icon` as a workspace-specific id (`:<uuid>:`).
32
- // When pasted into another workspace that id doesn't resolve, so fall back to
33
- // the human alias preserved in `data-icon-emoji-alias` (e.g. `:css:`). This
34
- // mirrors the inline emoji node and handles copy-paste between workspaces.
35
- const alias = dom.getAttribute(aliasAttr);
36
- const emoji = (icon && getEmoji(icon)) || (alias && getEmoji(alias)) || null;
37
- return { color, iconType, icon: emoji ? emoji.colons : icon };
38
- }
39
- return { color, iconType, icon };
40
- },
41
- },
42
- ],
43
- toDOM(node) {
44
- const { color, iconType, icon } = node.attrs;
45
- const attrs = {
46
- [nodeType]: "",
47
- "data-color": color,
48
- "data-icon-type": iconType,
49
- "data-icon": icon,
50
- };
51
- if (iconType === "emoji") {
52
- // Preserve the human-readable alias so a custom emoji icon can be re-resolved
53
- // when pasted into another workspace, where its id won't match.
54
- const emoji = getEmoji(icon);
55
- if (emoji) {
56
- attrs[aliasAttr] = emoji.native || `:${emoji.shortNames[0]}:`;
57
- }
58
- }
59
- return ["div", attrs, 0];
60
- },
8
+ attrs: {
9
+ color: { default: "#199EE3" },
10
+ iconType: { default: DEFAULT_CALLOUT_ICON_TYPE },
11
+ icon: { default: DEFAULT_CALLOUT_ICON }
12
+ },
13
+ group: "block",
14
+ content: "block+",
15
+ defining: true,
16
+ parseDOM: [{
17
+ tag: `div[${nodeType}]`,
18
+ getAttrs(domNode) {
19
+ const dom = domNode;
20
+ const color = dom.getAttribute("data-color");
21
+ const iconType = dom.getAttribute("data-icon-type");
22
+ const icon = dom.getAttribute("data-icon");
23
+ if (iconType === "emoji") {
24
+ const alias = dom.getAttribute(aliasAttr);
25
+ const emoji = icon && getEmoji(icon) || alias && getEmoji(alias) || null;
26
+ return {
27
+ color,
28
+ iconType,
29
+ icon: emoji ? emoji.colons : icon
30
+ };
31
+ }
32
+ return {
33
+ color,
34
+ iconType,
35
+ icon
36
+ };
37
+ }
38
+ }],
39
+ toDOM(node) {
40
+ const { color, iconType, icon } = node.attrs;
41
+ const attrs = {
42
+ [nodeType]: "",
43
+ "data-color": color,
44
+ "data-icon-type": iconType,
45
+ "data-icon": icon
46
+ };
47
+ if (iconType === "emoji") {
48
+ const emoji = getEmoji(icon);
49
+ if (emoji) attrs[aliasAttr] = emoji.native || `:${emoji.shortNames[0]}:`;
50
+ }
51
+ return [
52
+ "div",
53
+ attrs,
54
+ 0
55
+ ];
56
+ }
61
57
  });
62
- exports.makeCallout = makeCallout;
58
+ //#endregion
59
+ export { DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, makeCallout };
@@ -1,11 +1,14 @@
1
- import type { NodeSpec } from "prosemirror-model";
2
- import type { Inline } from "./types/inline-content";
3
- export interface CheckItemDefinition {
4
- type: "check_item";
5
- content?: Array<Inline>;
6
- attrs: {
7
- id: string;
8
- state: "TODO" | "DONE";
9
- };
1
+ import { Inline } from "./types/inline-content.js";
2
+ import { NodeSpec } from "prosemirror-model";
3
+ //#region src/nodes/check-item.d.ts
4
+ interface CheckItemDefinition {
5
+ type: "check_item";
6
+ content?: Array<Inline>;
7
+ attrs: {
8
+ id: string;
9
+ state: "TODO" | "DONE";
10
+ };
10
11
  }
11
- export declare const check_item: NodeSpec;
12
+ declare const check_item: NodeSpec;
13
+ //#endregion
14
+ export { CheckItemDefinition, check_item };
@@ -1,34 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.check_item = void 0;
4
- const uuid_1 = require("uuid");
5
- exports.check_item = {
6
- content: "inline*",
7
- defining: true,
8
- selectable: true,
9
- marks: "_",
10
- attrs: {
11
- id: { default: "" },
12
- state: { default: "TODO" },
13
- },
14
- parseDOM: [
15
- {
16
- tag: `div[data-check-item-id]`,
17
- // Default priority is 50. We normally don't change this but since this node type is
18
- // also used by list-item we need to make sure that we run this parser first.
19
- priority: 100,
20
- getAttrs: (dom) => ({
21
- id: (0, uuid_1.v4)(),
22
- state: dom.getAttribute("data-check-item-state"),
23
- }),
24
- },
25
- ],
26
- toDOM(node) {
27
- const { id, state } = node.attrs;
28
- const attrs = {
29
- "data-check-item-id": id,
30
- "data-check-item-state": state,
31
- };
32
- return ["div", attrs, 0];
33
- },
1
+ import { v4 } from "uuid";
2
+ //#region src/nodes/check-item.ts
3
+ const check_item = {
4
+ content: "inline*",
5
+ defining: true,
6
+ selectable: true,
7
+ marks: "_",
8
+ attrs: {
9
+ id: { default: "" },
10
+ state: { default: "TODO" }
11
+ },
12
+ parseDOM: [{
13
+ tag: `div[data-check-item-id]`,
14
+ priority: 100,
15
+ getAttrs: (dom) => ({
16
+ id: v4(),
17
+ state: dom.getAttribute("data-check-item-state")
18
+ })
19
+ }],
20
+ toDOM(node) {
21
+ const { id, state } = node.attrs;
22
+ return [
23
+ "div",
24
+ {
25
+ "data-check-item-id": id,
26
+ "data-check-item-state": state
27
+ },
28
+ 0
29
+ ];
30
+ }
34
31
  };
32
+ //#endregion
33
+ export { check_item };
@@ -1,13 +1,16 @@
1
- import type { NodeSpec } from "prosemirror-model";
2
- import type { CheckItemDefinition } from "./check-item";
3
- export interface CheckListContent extends Array<CheckItemDefinition | CheckListDefinition> {
4
- 0: CheckItemDefinition;
1
+ import { CheckItemDefinition } from "./check-item.js";
2
+ import { NodeSpec } from "prosemirror-model";
3
+ //#region src/nodes/check-list.d.ts
4
+ interface CheckListContent extends Array<CheckItemDefinition | CheckListDefinition> {
5
+ 0: CheckItemDefinition;
5
6
  }
6
- export interface CheckListDefinition {
7
- type: "check_list";
8
- content: CheckListContent;
9
- attrs: {
10
- id: string;
11
- };
7
+ interface CheckListDefinition {
8
+ type: "check_list";
9
+ content: CheckListContent;
10
+ attrs: {
11
+ id: string;
12
+ };
12
13
  }
13
- export declare const check_list: NodeSpec;
14
+ declare const check_list: NodeSpec;
15
+ //#endregion
16
+ export { CheckListContent, CheckListDefinition, check_list };
@@ -1,31 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.check_list = void 0;
4
- const uuid_1 = require("uuid");
5
- exports.check_list = {
6
- group: "block",
7
- defining: true,
8
- selectable: true,
9
- content: `(check_item)+ (check_item|check_list)*`,
10
- attrs: {
11
- id: { default: "" },
12
- },
13
- parseDOM: [
14
- {
15
- tag: `div[data-check-list-id]`,
16
- // Default priority is 50. We normaly don't change this but since this node type is
17
- // also used by ordered-list we need to make sure that we run this parser first.
18
- priority: 100,
19
- getAttrs: () => ({
20
- id: (0, uuid_1.v4)(),
21
- }),
22
- },
23
- ],
24
- toDOM(node) {
25
- const { id } = node.attrs;
26
- const attrs = {
27
- "data-check-list-id": id,
28
- };
29
- return ["div", attrs, 0];
30
- },
1
+ import { v4 } from "uuid";
2
+ //#region src/nodes/check-list.ts
3
+ const check_list = {
4
+ group: "block",
5
+ defining: true,
6
+ selectable: true,
7
+ content: `(check_item)+ (check_item|check_list)*`,
8
+ attrs: { id: { default: "" } },
9
+ parseDOM: [{
10
+ tag: `div[data-check-list-id]`,
11
+ priority: 100,
12
+ getAttrs: () => ({ id: v4() })
13
+ }],
14
+ toDOM(node) {
15
+ const { id } = node.attrs;
16
+ return [
17
+ "div",
18
+ { "data-check-list-id": id },
19
+ 0
20
+ ];
21
+ }
31
22
  };
23
+ //#endregion
24
+ export { check_list };
@@ -1,2 +1,5 @@
1
- import type { NodeSpec } from "prosemirror-model";
2
- export declare const code_block: NodeSpec;
1
+ import { NodeSpec } from "prosemirror-model";
2
+ //#region src/nodes/code-block.d.ts
3
+ declare const code_block: NodeSpec;
4
+ //#endregion
5
+ export { code_block };
@@ -1,112 +1,81 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.code_block = void 0;
4
- const uuid_1 = require("uuid");
5
- const resizable_node_attrs_1 = require("../resizable-node-attrs");
1
+ import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
2
+ import { v4 } from "uuid";
3
+ //#region src/nodes/code-block.ts
6
4
  const getLanguageFromEditorStyle = (dom) => {
7
- return dom.getAttribute("data-language") || undefined;
5
+ return dom.getAttribute("data-language") || void 0;
8
6
  };
9
- // example of BB style:
10
- // <div class="codehilite language-javascript"><pre><span>hello world</span><span>\n</span></pre></div>
11
7
  const getLanguageFromBitbucketStyle = (dom) => {
12
- if (dom && dom.classList.contains("codehilite")) {
13
- // code block html from Bitbucket always contains an extra new line
14
- return extractLanguageFromClass(dom.className);
15
- }
16
- return undefined;
8
+ if (dom && dom.classList.contains("codehilite")) return extractLanguageFromClass(dom.className);
17
9
  };
18
- // If there is a child code element, check that for data-language
19
10
  const getLanguageFromCode = (dom) => {
20
- const firstChild = dom.firstElementChild;
21
- if (firstChild && firstChild.nodeName === "CODE") {
22
- return firstChild.getAttribute("data-language") || undefined;
23
- }
24
- return undefined;
11
+ const firstChild = dom.firstElementChild;
12
+ if (firstChild && firstChild.nodeName === "CODE") return firstChild.getAttribute("data-language") || void 0;
25
13
  };
26
14
  const extractLanguageFromClass = (className) => {
27
- const languageRegex = /(?:^|\s)language-([^\s]+)/;
28
- const result = languageRegex.exec(className);
29
- if (result && result[1]) {
30
- return result[1];
31
- }
32
- return undefined;
15
+ const result = /(?:^|\s)language-([^\s]+)/.exec(className);
16
+ if (result && result[1]) return result[1];
33
17
  };
34
18
  const removeLastNewLine = (dom) => {
35
- const parent = dom && dom.parentElement;
36
- if (parent && parent.classList.contains("codehilite")) {
37
- dom.textContent = dom.textContent.replace(/\n$/, "");
38
- }
39
- return dom;
19
+ const parent = dom && dom.parentElement;
20
+ if (parent && parent.classList.contains("codehilite")) dom.textContent = dom.textContent.replace(/\n$/, "");
21
+ return dom;
40
22
  };
41
- exports.code_block = {
42
- content: "text*",
43
- marks: "linkedhighlightentity linkedhighlight",
44
- group: "block",
45
- code: true,
46
- isolating: true,
47
- defining: true,
48
- attrs: {
49
- // "id" is the unified block identifier; "guid" is deprecated and mirrors
50
- // "id" until all consumers (client editor, fibery backend) read "id".
51
- id: { default: null },
52
- guid: { default: "" },
53
- language: { default: null },
54
- wrapCode: { default: false },
55
- mode: { default: "split" },
56
- ...(0, resizable_node_attrs_1.createDefaultAttrs)(),
57
- },
58
- parseDOM: [
59
- {
60
- tag: "pre",
61
- preserveWhitespace: "full",
62
- getAttrs: (domNode) => {
63
- const dom = domNode;
64
- const id = dom.getAttribute("data-guid") || (0, uuid_1.v4)();
65
- const language = getLanguageFromBitbucketStyle(dom.parentElement) ||
66
- getLanguageFromEditorStyle(dom.parentElement) ||
67
- getLanguageFromCode(dom) ||
68
- dom.getAttribute("data-language");
69
- const wrapCodeAttr = dom.getAttribute("data-wrap-code");
70
- const wrapCode = wrapCodeAttr === "true";
71
- removeLastNewLine(dom);
72
- return {
73
- id,
74
- guid: id,
75
- language,
76
- wrapCode,
77
- mode: dom.getAttribute("data-mode") || "split",
78
- ...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
79
- };
80
- },
81
- },
82
- // Handle GitHub/Gist paste
83
- {
84
- tag: "table[style]",
85
- preserveWhitespace: "full",
86
- getAttrs: (dom) => {
87
- if (dom.querySelector('td[class*="blob-code"]')) {
88
- return {};
89
- }
90
- return false;
91
- },
92
- },
93
- ],
94
- toDOM(node) {
95
- const id = node.attrs.id || node.attrs.guid || "";
96
- return [
97
- "pre",
98
- [
99
- "code",
100
- {
101
- "data-language": node.attrs.language,
102
- "data-id": id,
103
- "data-guid": id,
104
- "data-wrap-code": node.attrs.wrapCode || false,
105
- "data-mode": node.attrs.mode || "split",
106
- ...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
107
- },
108
- 0,
109
- ],
110
- ];
111
- },
23
+ const code_block = {
24
+ content: "text*",
25
+ marks: "linkedhighlightentity linkedhighlight",
26
+ group: "block",
27
+ code: true,
28
+ isolating: true,
29
+ defining: true,
30
+ attrs: {
31
+ id: { default: null },
32
+ guid: { default: "" },
33
+ language: { default: null },
34
+ wrapCode: { default: false },
35
+ mode: { default: "split" },
36
+ ...createDefaultAttrs()
37
+ },
38
+ parseDOM: [{
39
+ tag: "pre",
40
+ preserveWhitespace: "full",
41
+ getAttrs: (domNode) => {
42
+ const dom = domNode;
43
+ const id = dom.getAttribute("data-guid") || v4();
44
+ const language = getLanguageFromBitbucketStyle(dom.parentElement) || getLanguageFromEditorStyle(dom.parentElement) || getLanguageFromCode(dom) || dom.getAttribute("data-language");
45
+ const wrapCode = dom.getAttribute("data-wrap-code") === "true";
46
+ removeLastNewLine(dom);
47
+ return {
48
+ id,
49
+ guid: id,
50
+ language,
51
+ wrapCode,
52
+ mode: dom.getAttribute("data-mode") || "split",
53
+ ...createParseDomAttrs(dom)
54
+ };
55
+ }
56
+ }, {
57
+ tag: "table[style]",
58
+ preserveWhitespace: "full",
59
+ getAttrs: (dom) => {
60
+ if (dom.querySelector("td[class*=\"blob-code\"]")) return {};
61
+ return false;
62
+ }
63
+ }],
64
+ toDOM(node) {
65
+ const id = node.attrs.id || node.attrs.guid || "";
66
+ return ["pre", [
67
+ "code",
68
+ {
69
+ "data-language": node.attrs.language,
70
+ "data-id": id,
71
+ "data-guid": id,
72
+ "data-wrap-code": node.attrs.wrapCode || false,
73
+ "data-mode": node.attrs.mode || "split",
74
+ ...createToDomAttrs(node.attrs)
75
+ },
76
+ 0
77
+ ]];
78
+ }
112
79
  };
80
+ //#endregion
81
+ export { code_block };
@@ -1,2 +1,5 @@
1
- import type { NodeSpec } from "prosemirror-model";
2
- export declare const column: NodeSpec;
1
+ import { NodeSpec } from "prosemirror-model";
2
+ //#region src/nodes/column.d.ts
3
+ declare const column: NodeSpec;
4
+ //#endregion
5
+ export { column };
@@ -1,35 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.column = void 0;
4
- exports.column = {
5
- content: "block+",
6
- selectable: true,
7
- draggable: false,
8
- definingAsContext: true,
9
- isolating: true,
10
- attrs: {
11
- columnRatio: {
12
- default: 1,
13
- },
14
- },
15
- parseDOM: [
16
- {
17
- tag: "div.fibery-column-node",
18
- getAttrs: (domNode) => {
19
- const dom = domNode;
20
- return {
21
- columnRatio: dom.getAttribute("data-column-ratio"),
22
- };
23
- },
24
- },
25
- ],
26
- toDOM(node) {
27
- const { columnRatio } = node.attrs;
28
- const attrs = {
29
- class: "fibery-column-node",
30
- "data-column-ratio": columnRatio,
31
- style: "min-width: 0;",
32
- };
33
- return ["div", attrs, 0];
34
- },
1
+ //#region src/nodes/column.ts
2
+ const column = {
3
+ content: "block+",
4
+ selectable: true,
5
+ draggable: false,
6
+ definingAsContext: true,
7
+ isolating: true,
8
+ attrs: { columnRatio: { default: 1 } },
9
+ parseDOM: [{
10
+ tag: "div.fibery-column-node",
11
+ getAttrs: (domNode) => {
12
+ return { columnRatio: domNode.getAttribute("data-column-ratio") };
13
+ }
14
+ }],
15
+ toDOM(node) {
16
+ const { columnRatio } = node.attrs;
17
+ return [
18
+ "div",
19
+ {
20
+ class: "fibery-column-node",
21
+ "data-column-ratio": columnRatio,
22
+ style: "min-width: 0;"
23
+ },
24
+ 0
25
+ ];
26
+ }
35
27
  };
28
+ //#endregion
29
+ export { column };
@@ -1,2 +1,5 @@
1
- import type { NodeSpec } from "prosemirror-model";
2
- export declare const columns: NodeSpec;
1
+ import { NodeSpec } from "prosemirror-model";
2
+ //#region src/nodes/columns.d.ts
3
+ declare const columns: NodeSpec;
4
+ //#endregion
5
+ export { columns };
@@ -1,37 +1,35 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.columns = void 0;
4
- const resizable_node_attrs_1 = require("../resizable-node-attrs");
5
- exports.columns = {
6
- content: "column+",
7
- selectable: true,
8
- draggable: false,
9
- attrs: {
10
- id: { default: "" },
11
- ...(0, resizable_node_attrs_1.createDefaultAttrs)(),
12
- },
13
- parseDOM: [
14
- {
15
- tag: "div.fibery-columns-node",
16
- getAttrs: (domNode) => {
17
- const dom = domNode;
18
- return (0, resizable_node_attrs_1.createParseDomAttrs)(dom);
19
- },
20
- },
21
- ],
22
- toDOM(node) {
23
- let gridTemplateColumns = ``;
24
- node.forEach((node, offset, index) => {
25
- if (index !== 0) {
26
- gridTemplateColumns += ` `;
27
- }
28
- gridTemplateColumns += `${node.attrs.columnRatio}fr`;
29
- });
30
- const attrs = {
31
- class: "fibery-columns-node",
32
- style: `display: grid; gap: 46px; grid-template-columns: ${gridTemplateColumns}`,
33
- ...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
34
- };
35
- return ["div", attrs, 0];
36
- },
1
+ import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
2
+ //#region src/nodes/columns.ts
3
+ const columns = {
4
+ content: "column+",
5
+ selectable: true,
6
+ draggable: false,
7
+ attrs: {
8
+ id: { default: "" },
9
+ ...createDefaultAttrs()
10
+ },
11
+ parseDOM: [{
12
+ tag: "div.fibery-columns-node",
13
+ getAttrs: (domNode) => {
14
+ return createParseDomAttrs(domNode);
15
+ }
16
+ }],
17
+ toDOM(node) {
18
+ let gridTemplateColumns = ``;
19
+ node.forEach((node, offset, index) => {
20
+ if (index !== 0) gridTemplateColumns += ` `;
21
+ gridTemplateColumns += `${node.attrs.columnRatio}fr`;
22
+ });
23
+ return [
24
+ "div",
25
+ {
26
+ class: "fibery-columns-node",
27
+ style: `display: grid; gap: 46px; grid-template-columns: ${gridTemplateColumns}`,
28
+ ...createToDomAttrs(node.attrs)
29
+ },
30
+ 0
31
+ ];
32
+ }
37
33
  };
34
+ //#endregion
35
+ export { columns };