@fibery/prosemirror-schema 4.22.0 → 4.23.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 (153) hide show
  1. package/lib/attr-constraints.d.ts +17 -0
  2. package/lib/attr-constraints.js +145 -0
  3. package/lib/block-id-utils.d.ts +10 -0
  4. package/lib/block-id-utils.js +26 -0
  5. package/lib/create-schema.d.ts +19 -0
  6. package/lib/create-schema.js +206 -0
  7. package/lib/index.d.ts +10 -10
  8. package/lib/index.js +9 -31
  9. package/lib/marks/code.d.ts +8 -0
  10. package/lib/marks/code.js +13 -0
  11. package/lib/marks/em.d.ts +9 -0
  12. package/lib/marks/em.js +22 -0
  13. package/lib/marks/hint-query.d.ts +5 -0
  14. package/lib/marks/hint-query.js +20 -0
  15. package/lib/marks/link.d.ts +10 -0
  16. package/lib/marks/link.js +43 -0
  17. package/lib/marks/linked-highlight.d.ts +13 -0
  18. package/lib/marks/linked-highlight.js +44 -0
  19. package/lib/marks/strike.d.ts +5 -0
  20. package/lib/marks/strike.js +7 -0
  21. package/lib/marks/strong.d.ts +9 -0
  22. package/lib/marks/strong.js +32 -0
  23. package/lib/marks/text-background-color.d.ts +16 -0
  24. package/lib/marks/text-background-color.js +72 -0
  25. package/lib/marks/underline.d.ts +5 -0
  26. package/lib/marks/underline.js +7 -0
  27. package/lib/nodes/callout.d.ts +31 -0
  28. package/lib/nodes/callout.js +59 -0
  29. package/lib/nodes/check-item.d.ts +14 -0
  30. package/lib/nodes/check-item.js +33 -0
  31. package/lib/nodes/check-list.d.ts +16 -0
  32. package/lib/nodes/check-list.js +24 -0
  33. package/lib/nodes/code-block.d.ts +5 -0
  34. package/lib/nodes/code-block.js +81 -0
  35. package/lib/nodes/column.d.ts +5 -0
  36. package/lib/nodes/column.js +29 -0
  37. package/lib/nodes/columns.d.ts +5 -0
  38. package/lib/nodes/columns.js +35 -0
  39. package/lib/nodes/emoji.d.ts +33 -0
  40. package/lib/nodes/emoji.js +42 -0
  41. package/lib/nodes/entity.d.ts +22 -0
  42. package/lib/nodes/entity.js +49 -0
  43. package/lib/nodes/fibery-view.d.ts +5 -0
  44. package/lib/nodes/fibery-view.js +39 -0
  45. package/lib/nodes/file.d.ts +39 -0
  46. package/lib/nodes/file.js +42 -0
  47. package/lib/nodes/heading.d.ts +7 -0
  48. package/lib/nodes/heading.js +63 -0
  49. package/lib/nodes/image-block.d.ts +5 -0
  50. package/lib/nodes/image-block.js +44 -0
  51. package/lib/nodes/important.d.ts +5 -0
  52. package/lib/nodes/important.js +15 -0
  53. package/lib/nodes/math-display.d.ts +5 -0
  54. package/lib/nodes/math-display.js +15 -0
  55. package/lib/nodes/math-inline.d.ts +5 -0
  56. package/lib/nodes/math-inline.js +15 -0
  57. package/lib/nodes/media.d.ts +7 -0
  58. package/lib/nodes/media.js +58 -0
  59. package/lib/nodes/mention.d.ts +14 -0
  60. package/lib/nodes/mention.js +37 -0
  61. package/lib/nodes/note.d.ts +5 -0
  62. package/lib/nodes/note.js +15 -0
  63. package/lib/nodes/paragraph.d.ts +5 -0
  64. package/lib/nodes/paragraph.js +33 -0
  65. package/lib/nodes/table-nodes.d.ts +5 -0
  66. package/lib/nodes/table-nodes.js +17 -0
  67. package/lib/nodes/types/inline-content.d.ts +12 -0
  68. package/lib/nodes/types/inline-content.js +0 -0
  69. package/lib/nodes/types/text.d.ts +8 -0
  70. package/lib/nodes/types/text.js +0 -0
  71. package/lib/nodes/video.d.ts +7 -0
  72. package/lib/nodes/video.js +50 -0
  73. package/lib/resizable-node-attrs.d.ts +32 -0
  74. package/lib/resizable-node-attrs.js +29 -0
  75. package/lib/transcription-node-attrs.d.ts +12 -0
  76. package/lib/transcription-node-attrs.js +10 -0
  77. package/package.json +8 -27
  78. package/lib/src/attr-constraints.d.ts +0 -14
  79. package/lib/src/attr-constraints.js +0 -185
  80. package/lib/src/block-id-utils.d.ts +0 -7
  81. package/lib/src/block-id-utils.js +0 -49
  82. package/lib/src/create-schema.d.ts +0 -18
  83. package/lib/src/create-schema.js +0 -251
  84. package/lib/src/marks/code.d.ts +0 -5
  85. package/lib/src/marks/code.js +0 -13
  86. package/lib/src/marks/em.d.ts +0 -6
  87. package/lib/src/marks/em.js +0 -19
  88. package/lib/src/marks/hint-query.d.ts +0 -2
  89. package/lib/src/marks/hint-query.js +0 -23
  90. package/lib/src/marks/link.d.ts +0 -7
  91. package/lib/src/marks/link.js +0 -39
  92. package/lib/src/marks/linked-highlight.d.ts +0 -11
  93. package/lib/src/marks/linked-highlight.js +0 -57
  94. package/lib/src/marks/strike.d.ts +0 -2
  95. package/lib/src/marks/strike.js +0 -7
  96. package/lib/src/marks/strong.d.ts +0 -6
  97. package/lib/src/marks/strong.js +0 -32
  98. package/lib/src/marks/text-background-color.d.ts +0 -13
  99. package/lib/src/marks/text-background-color.js +0 -90
  100. package/lib/src/marks/underline.d.ts +0 -2
  101. package/lib/src/marks/underline.js +0 -7
  102. package/lib/src/nodes/callout.d.ts +0 -28
  103. package/lib/src/nodes/callout.js +0 -62
  104. package/lib/src/nodes/check-item.d.ts +0 -11
  105. package/lib/src/nodes/check-item.js +0 -34
  106. package/lib/src/nodes/check-list.d.ts +0 -13
  107. package/lib/src/nodes/check-list.js +0 -31
  108. package/lib/src/nodes/code-block.d.ts +0 -2
  109. package/lib/src/nodes/code-block.js +0 -112
  110. package/lib/src/nodes/column.d.ts +0 -2
  111. package/lib/src/nodes/column.js +0 -35
  112. package/lib/src/nodes/columns.d.ts +0 -2
  113. package/lib/src/nodes/columns.js +0 -37
  114. package/lib/src/nodes/emoji.d.ts +0 -31
  115. package/lib/src/nodes/emoji.js +0 -51
  116. package/lib/src/nodes/entity.d.ts +0 -20
  117. package/lib/src/nodes/entity.js +0 -50
  118. package/lib/src/nodes/fibery-view.d.ts +0 -2
  119. package/lib/src/nodes/fibery-view.js +0 -43
  120. package/lib/src/nodes/file.d.ts +0 -36
  121. package/lib/src/nodes/file.js +0 -41
  122. package/lib/src/nodes/heading.d.ts +0 -4
  123. package/lib/src/nodes/heading.js +0 -39
  124. package/lib/src/nodes/image-block.d.ts +0 -2
  125. package/lib/src/nodes/image-block.js +0 -43
  126. package/lib/src/nodes/important.d.ts +0 -2
  127. package/lib/src/nodes/important.js +0 -11
  128. package/lib/src/nodes/math-display.d.ts +0 -2
  129. package/lib/src/nodes/math-display.js +0 -16
  130. package/lib/src/nodes/math-inline.d.ts +0 -2
  131. package/lib/src/nodes/math-inline.js +0 -16
  132. package/lib/src/nodes/media.d.ts +0 -4
  133. package/lib/src/nodes/media.js +0 -74
  134. package/lib/src/nodes/mention.d.ts +0 -11
  135. package/lib/src/nodes/mention.js +0 -38
  136. package/lib/src/nodes/note.d.ts +0 -2
  137. package/lib/src/nodes/note.js +0 -11
  138. package/lib/src/nodes/paragraph.d.ts +0 -2
  139. package/lib/src/nodes/paragraph.js +0 -27
  140. package/lib/src/nodes/table-nodes.d.ts +0 -2
  141. package/lib/src/nodes/table-nodes.js +0 -21
  142. package/lib/src/nodes/types/inline-content.d.ts +0 -10
  143. package/lib/src/nodes/types/inline-content.js +0 -2
  144. package/lib/src/nodes/types/text.d.ts +0 -5
  145. package/lib/src/nodes/types/text.js +0 -2
  146. package/lib/src/nodes/video.d.ts +0 -4
  147. package/lib/src/nodes/video.js +0 -55
  148. package/lib/src/resizable-node-attrs.d.ts +0 -29
  149. package/lib/src/resizable-node-attrs.js +0 -40
  150. package/lib/src/transcription-node-attrs.d.ts +0 -9
  151. package/lib/src/transcription-node-attrs.js +0 -10
  152. package/lib/test-helpers/index.d.ts +0 -4
  153. package/lib/test-helpers/index.js +0 -21
@@ -0,0 +1,44 @@
1
+ //#region src/marks/linked-highlight.ts
2
+ const hyphenatePascal = (str) => str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z]{2})[a-z]/, "$1-").toLowerCase();
3
+ const createMark = (markType, sharedColorGenerator) => {
4
+ const markTag = `span.${markType}`;
5
+ const markClassName = `${markType}`;
6
+ const preserveBool = (attr) => attr === "true" ? true : attr === "false" ? false : attr;
7
+ return {
8
+ attrs: {
9
+ id: {},
10
+ meta: { default: {} }
11
+ },
12
+ inclusive: false,
13
+ parseDOM: [{
14
+ tag: markTag,
15
+ getAttrs: ({ dataset }) => {
16
+ return {
17
+ id: dataset.id || false,
18
+ meta: Object.keys(dataset).filter((key) => key !== "id" && dataset[key] !== "false").reduce((out, key) => ({
19
+ ...out,
20
+ [key]: preserveBool(JSON.parse(dataset[key]))
21
+ }), { type: markType })
22
+ };
23
+ }
24
+ }],
25
+ toDOM: ({ attrs }) => {
26
+ const { id, meta } = attrs;
27
+ const color = sharedColorGenerator ? sharedColorGenerator.generate(attrs) : "#EEEEEE";
28
+ return [markTag, {
29
+ class: markClassName,
30
+ style: color ? `--${markType}-background-color:${color}` : ``,
31
+ "data-id": id,
32
+ ...Object.fromEntries(Object.keys(meta).filter((key) => meta[key] !== false).map((key) => [`data-${hyphenatePascal(key)}`, JSON.stringify(meta[key])]))
33
+ }];
34
+ }
35
+ };
36
+ };
37
+ const makeLinkedHighlight = ({ sharedColorGenerator }) => {
38
+ return createMark("linkedhighlight", sharedColorGenerator);
39
+ };
40
+ const makeLinkedHighlightEntity = ({ sharedColorGenerator }) => {
41
+ return createMark("linkedhighlightentity", sharedColorGenerator);
42
+ };
43
+ //#endregion
44
+ export { makeLinkedHighlight, makeLinkedHighlightEntity };
@@ -0,0 +1,5 @@
1
+ import { MarkSpec } from "prosemirror-model";
2
+ //#region src/marks/strike.d.ts
3
+ declare const strike: MarkSpec;
4
+ //#endregion
5
+ export { strike };
@@ -0,0 +1,7 @@
1
+ //#region src/marks/strike.ts
2
+ const strike = {
3
+ parseDOM: [{ tag: "strike" }, { style: "text-decoration=line-through" }],
4
+ toDOM: () => ["strike"]
5
+ };
6
+ //#endregion
7
+ export { strike };
@@ -0,0 +1,9 @@
1
+ import { MarkSpec } from "prosemirror-model";
2
+ //#region src/marks/strong.d.ts
3
+ /**
4
+ A strong mark. Rendered as `<strong>`, parse rules also match
5
+ `<b>` and `font-weight: bold`.
6
+ */
7
+ declare const strong: MarkSpec;
8
+ //#endregion
9
+ export { strong };
@@ -0,0 +1,32 @@
1
+ //#region src/marks/strong.ts
2
+ const strongDOM = ["strong", 0];
3
+ /**
4
+ A strong mark. Rendered as `<strong>`, parse rules also match
5
+ `<b>` and `font-weight: bold`.
6
+ */
7
+ const strong = {
8
+ parseDOM: [
9
+ { tag: "strong" },
10
+ {
11
+ tag: "b",
12
+ getAttrs: (dom) => {
13
+ return dom.style.fontWeight !== "normal" && null;
14
+ }
15
+ },
16
+ {
17
+ style: "font-weight=400",
18
+ clearMark: (m) => m.type.name === "strong"
19
+ },
20
+ {
21
+ style: "font-weight",
22
+ getAttrs: (value) => {
23
+ return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null;
24
+ }
25
+ }
26
+ ],
27
+ toDOM() {
28
+ return strongDOM;
29
+ }
30
+ };
31
+ //#endregion
32
+ export { strong };
@@ -0,0 +1,16 @@
1
+ import { MarkSpec } from "prosemirror-model";
2
+ //#region src/marks/text-background-color.d.ts
3
+ declare enum ColorToken {
4
+ Yellow = "YELLOW",
5
+ Green = "GREEN",
6
+ Aquamarine = "AQUAMARINE",
7
+ Aqua = "AQUA",
8
+ Blue = "BLUE",
9
+ Purple = "PURPLE",
10
+ Pink = "PINK",
11
+ Red = "RED",
12
+ Grey = "GREY"
13
+ }
14
+ declare const textBackgroundColor: MarkSpec;
15
+ //#endregion
16
+ export { ColorToken, textBackgroundColor };
@@ -0,0 +1,72 @@
1
+ //#region src/marks/text-background-color.ts
2
+ let ColorToken = /* @__PURE__ */ function(ColorToken) {
3
+ ColorToken["Yellow"] = "YELLOW";
4
+ ColorToken["Green"] = "GREEN";
5
+ ColorToken["Aquamarine"] = "AQUAMARINE";
6
+ ColorToken["Aqua"] = "AQUA";
7
+ ColorToken["Blue"] = "BLUE";
8
+ ColorToken["Purple"] = "PURPLE";
9
+ ColorToken["Pink"] = "PINK";
10
+ ColorToken["Red"] = "RED";
11
+ ColorToken["Grey"] = "GREY";
12
+ return ColorToken;
13
+ }({});
14
+ const isColorToken = (text) => {
15
+ return Object.values(ColorToken).includes(text);
16
+ };
17
+ const persistedRawColorToColorTokenLookup = {
18
+ ["HIGHLIGHT-SEARCH"]: "YELLOW",
19
+ ["#f6f1a2"]: "YELLOW",
20
+ ["#d2faad"]: "GREEN",
21
+ ["#befccc"]: "AQUAMARINE",
22
+ ["#bbf9f8"]: "AQUA",
23
+ ["#e0f0fe"]: "BLUE",
24
+ ["#f1ebfe"]: "PURPLE",
25
+ ["#fce7fb"]: "PINK",
26
+ ["#fce9e9"]: "RED",
27
+ ["#e7e9eb"]: "GREY"
28
+ };
29
+ const validateColorToken = (color) => {
30
+ if (!color) return;
31
+ if (isColorToken(color)) return color;
32
+ return persistedRawColorToColorTokenLookup[color] || void 0;
33
+ };
34
+ const getClassName = (bgColorToken, fgColorToken) => {
35
+ return [
36
+ `text-background-color`,
37
+ bgColorToken ? `bg-${bgColorToken.toLowerCase()}` : null,
38
+ fgColorToken ? bgColorToken ? `fg-on-bg-${fgColorToken.toLowerCase()}` : `fg-${fgColorToken.toLowerCase()}` : null
39
+ ].filter(Boolean).join(` `);
40
+ };
41
+ const textBackgroundColor = {
42
+ attrs: {
43
+ guid: { default: "" },
44
+ color: { default: void 0 },
45
+ bgColor: { default: void 0 },
46
+ fgColor: { default: void 0 }
47
+ },
48
+ parseDOM: [{
49
+ tag: "span[data-text-background-color]",
50
+ getAttrs: (domNode) => {
51
+ const dom = domNode;
52
+ return {
53
+ bgColor: dom.getAttribute("data-bg-color") || dom.getAttribute("data-color") || void 0,
54
+ fgColor: dom.getAttribute("data-fg-color") || void 0
55
+ };
56
+ }
57
+ }],
58
+ toDOM(node) {
59
+ const bgColor = node.attrs.bgColor || node.attrs.color;
60
+ const fgColor = node.attrs.fgColor;
61
+ const bgColorToken = validateColorToken(bgColor);
62
+ return ["span", {
63
+ "data-text-background-color": "true",
64
+ "data-guid": node.attrs.guid,
65
+ "data-bg-color": bgColor || void 0,
66
+ "data-fg-color": fgColor || void 0,
67
+ class: getClassName(bgColorToken, fgColor)
68
+ }];
69
+ }
70
+ };
71
+ //#endregion
72
+ export { ColorToken, textBackgroundColor };
@@ -0,0 +1,5 @@
1
+ import { MarkSpec } from "prosemirror-model";
2
+ //#region src/marks/underline.d.ts
3
+ declare const underline: MarkSpec;
4
+ //#endregion
5
+ export { underline };
@@ -0,0 +1,7 @@
1
+ //#region src/marks/underline.ts
2
+ const underline = {
3
+ parseDOM: [{ tag: "u" }, { style: "text-decoration=underline" }],
4
+ toDOM: () => ["u"]
5
+ };
6
+ //#endregion
7
+ export { underline };
@@ -0,0 +1,31 @@
1
+ import { EmojiOptions } from "./emoji.js";
2
+ //#region src/nodes/callout.d.ts
3
+ declare const DEFAULT_CALLOUT_ICON_TYPE = "icon";
4
+ declare const DEFAULT_CALLOUT_ICON = "exclamation-circle";
5
+ declare const makeCallout: ({ getEmoji }?: EmojiOptions) => {
6
+ attrs: {
7
+ color: {
8
+ default: string;
9
+ };
10
+ iconType: {
11
+ default: string;
12
+ };
13
+ icon: {
14
+ default: string;
15
+ };
16
+ };
17
+ group: string;
18
+ content: string;
19
+ defining: true;
20
+ parseDOM: {
21
+ tag: string;
22
+ getAttrs(domNode: HTMLElement): {
23
+ color: string | null;
24
+ iconType: string | null;
25
+ icon: string | null;
26
+ };
27
+ }[];
28
+ toDOM(node: import("prosemirror-model").Node): [string, Record<string, string>, number];
29
+ };
30
+ //#endregion
31
+ export { DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, makeCallout };
@@ -0,0 +1,59 @@
1
+ //#region src/nodes/callout.ts
2
+ const nodeType = "data-callout-node";
3
+ const DEFAULT_CALLOUT_ICON_TYPE = "icon";
4
+ const DEFAULT_CALLOUT_ICON = "exclamation-circle";
5
+ const aliasAttr = "data-icon-emoji-alias";
6
+ const defaultOptions = { getEmoji() {} };
7
+ const makeCallout = ({ getEmoji } = defaultOptions) => ({
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
+ }
57
+ });
58
+ //#endregion
59
+ export { DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, makeCallout };
@@ -0,0 +1,14 @@
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
+ };
11
+ }
12
+ declare const check_item: NodeSpec;
13
+ //#endregion
14
+ export { CheckItemDefinition, check_item };
@@ -0,0 +1,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
+ }
31
+ };
32
+ //#endregion
33
+ export { check_item };
@@ -0,0 +1,16 @@
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;
6
+ }
7
+ interface CheckListDefinition {
8
+ type: "check_list";
9
+ content: CheckListContent;
10
+ attrs: {
11
+ id: string;
12
+ };
13
+ }
14
+ declare const check_list: NodeSpec;
15
+ //#endregion
16
+ export { CheckListContent, CheckListDefinition, check_list };
@@ -0,0 +1,24 @@
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
+ }
22
+ };
23
+ //#endregion
24
+ export { check_list };
@@ -0,0 +1,5 @@
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 };
@@ -0,0 +1,81 @@
1
+ import { createDefaultAttrs, createParseDomAttrs, createToDomAttrs } from "../resizable-node-attrs.js";
2
+ import { v4 } from "uuid";
3
+ //#region src/nodes/code-block.ts
4
+ const getLanguageFromEditorStyle = (dom) => {
5
+ return dom.getAttribute("data-language") || void 0;
6
+ };
7
+ const getLanguageFromBitbucketStyle = (dom) => {
8
+ if (dom && dom.classList.contains("codehilite")) return extractLanguageFromClass(dom.className);
9
+ };
10
+ const getLanguageFromCode = (dom) => {
11
+ const firstChild = dom.firstElementChild;
12
+ if (firstChild && firstChild.nodeName === "CODE") return firstChild.getAttribute("data-language") || void 0;
13
+ };
14
+ const extractLanguageFromClass = (className) => {
15
+ const result = /(?:^|\s)language-([^\s]+)/.exec(className);
16
+ if (result && result[1]) return result[1];
17
+ };
18
+ const removeLastNewLine = (dom) => {
19
+ const parent = dom && dom.parentElement;
20
+ if (parent && parent.classList.contains("codehilite")) dom.textContent = dom.textContent.replace(/\n$/, "");
21
+ return dom;
22
+ };
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
+ }
79
+ };
80
+ //#endregion
81
+ export { code_block };
@@ -0,0 +1,5 @@
1
+ import { NodeSpec } from "prosemirror-model";
2
+ //#region src/nodes/column.d.ts
3
+ declare const column: NodeSpec;
4
+ //#endregion
5
+ export { column };
@@ -0,0 +1,29 @@
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
+ }
27
+ };
28
+ //#endregion
29
+ export { column };
@@ -0,0 +1,5 @@
1
+ import { NodeSpec } from "prosemirror-model";
2
+ //#region src/nodes/columns.d.ts
3
+ declare const columns: NodeSpec;
4
+ //#endregion
5
+ export { columns };
@@ -0,0 +1,35 @@
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
+ }
33
+ };
34
+ //#endregion
35
+ export { columns };
@@ -0,0 +1,33 @@
1
+ //#region src/nodes/emoji.d.ts
2
+ type Emoji = {
3
+ name: string;
4
+ shortNames: string[];
5
+ colons: string;
6
+ native?: string;
7
+ };
8
+ type EmojiOptions = {
9
+ getEmoji: (code: string) => Emoji | void;
10
+ };
11
+ declare const makeEmoji: ({ getEmoji }?: EmojiOptions) => {
12
+ attrs: {
13
+ code: {};
14
+ };
15
+ inline: true;
16
+ atom: true;
17
+ group: string;
18
+ selectable: false;
19
+ draggable: false;
20
+ leafText: (node: import("prosemirror-model").Node) => any;
21
+ parseDOM: {
22
+ tag: string;
23
+ getAttrs(domNode: HTMLElement): {
24
+ code: string;
25
+ };
26
+ }[];
27
+ toDOM(node: import("prosemirror-model").Node): [string, {
28
+ "data-emoji-node": string;
29
+ "data-emoji-code": any;
30
+ }, any];
31
+ };
32
+ //#endregion
33
+ export { EmojiOptions, makeEmoji };
@@ -0,0 +1,42 @@
1
+ //#region src/nodes/emoji.ts
2
+ const typeAttr = "data-emoji-node";
3
+ const codeAttr = "data-emoji-code";
4
+ const defaultOptions = { getEmoji() {} };
5
+ const makeEmoji = ({ getEmoji } = defaultOptions) => ({
6
+ attrs: { code: {} },
7
+ inline: true,
8
+ atom: true,
9
+ group: "inline",
10
+ selectable: false,
11
+ draggable: false,
12
+ leafText: (node) => {
13
+ const { code } = node.attrs;
14
+ const emoji = getEmoji(code);
15
+ return emoji ? emoji.native || `:${emoji.shortNames[0]}:` : code;
16
+ },
17
+ parseDOM: [{
18
+ tag: `span[${typeAttr}]`,
19
+ getAttrs(domNode) {
20
+ const dom = domNode;
21
+ const code = dom.getAttribute(codeAttr);
22
+ const alias = dom.textContent;
23
+ const emoji = code && getEmoji(code) || alias && getEmoji(alias) || null;
24
+ return { code: emoji ? emoji.colons : alias };
25
+ }
26
+ }],
27
+ toDOM(node) {
28
+ const { code } = node.attrs;
29
+ const attrs = {
30
+ [typeAttr]: "",
31
+ [codeAttr]: code
32
+ };
33
+ const emoji = getEmoji(code);
34
+ return [
35
+ "span",
36
+ attrs,
37
+ emoji ? emoji.native || `:${emoji.shortNames[0]}:` : code
38
+ ];
39
+ }
40
+ });
41
+ //#endregion
42
+ export { makeEmoji };
@@ -0,0 +1,22 @@
1
+ import { NodeSpec } from "prosemirror-model";
2
+ //#region src/nodes/entity.d.ts
3
+ type Meta = {
4
+ comment?: string;
5
+ anchor?: string;
6
+ field?: string;
7
+ contextEntityTypeId?: string;
8
+ contextEntityPublicId?: string;
9
+ };
10
+ interface EntityAttributes {
11
+ id: string;
12
+ typeId: string;
13
+ text?: string;
14
+ meta: Meta;
15
+ }
16
+ interface EntityDefinition {
17
+ type: "entity";
18
+ attrs: EntityAttributes;
19
+ }
20
+ declare const entity: NodeSpec;
21
+ //#endregion
22
+ export { EntityAttributes, EntityDefinition, entity };