@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
@@ -1,5 +0,0 @@
1
- import type { MarkSpec } from "prosemirror-model";
2
- /**
3
- Code font mark. Represented as a `<code>` element.
4
- */
5
- export declare const code: MarkSpec;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.code = void 0;
4
- const codeDOM = ["code", 0];
5
- /**
6
- Code font mark. Represented as a `<code>` element.
7
- */
8
- exports.code = {
9
- parseDOM: [{ tag: "code" }],
10
- toDOM() {
11
- return codeDOM;
12
- },
13
- };
@@ -1,6 +0,0 @@
1
- import type { MarkSpec } from "prosemirror-model";
2
- /**
3
- An emphasis mark. Rendered as an `<em>` element. Has parse rules
4
- that also match `<i>` and `font-style: italic`.
5
- */
6
- export declare const em: MarkSpec;
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.em = void 0;
4
- const emDOM = ["em", 0];
5
- /**
6
- An emphasis mark. Rendered as an `<em>` element. Has parse rules
7
- that also match `<i>` and `font-style: italic`.
8
- */
9
- exports.em = {
10
- parseDOM: [
11
- { tag: "i" },
12
- { tag: "em" },
13
- { style: "font-style=italic" },
14
- { style: "font-style=normal", clearMark: (m) => m.type.name === "em" },
15
- ],
16
- toDOM() {
17
- return emDOM;
18
- },
19
- };
@@ -1,2 +0,0 @@
1
- import type { MarkSpec } from "prosemirror-model";
2
- export declare const hintQuery: MarkSpec;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hintQuery = void 0;
4
- exports.hintQuery = {
5
- excludes: "searchQuery",
6
- inclusive: true,
7
- group: "searchQuery",
8
- attrs: {
9
- trigger: { default: "" },
10
- guid: { default: "" },
11
- },
12
- parseDOM: [{ tag: "span[data-hint-query]" }],
13
- toDOM(node) {
14
- return [
15
- "span",
16
- {
17
- "data-hint-query": "true",
18
- "data-trigger": node.attrs.trigger,
19
- "data-guid": node.attrs.guid,
20
- },
21
- ];
22
- },
23
- };
@@ -1,7 +0,0 @@
1
- import type { MarkSpec } from "prosemirror-model";
2
- /**
3
- A link. Has `href` and `title` attributes. `title`
4
- defaults to the empty string. Rendered and parsed as an `<a>`
5
- element.
6
- */
7
- export declare const link: MarkSpec;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.link = void 0;
4
- const httpRegex = /^[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b[-a-zA-Z0-9()@:%_+.~#?&/=]*$/;
5
- /**
6
- A link. Has `href` and `title` attributes. `title`
7
- defaults to the empty string. Rendered and parsed as an `<a>`
8
- element.
9
- */
10
- exports.link = {
11
- attrs: {
12
- href: {},
13
- title: { default: null },
14
- },
15
- inclusive: false,
16
- parseDOM: [
17
- {
18
- tag: "a[href]",
19
- getAttrs(domNode) {
20
- const dom = domNode;
21
- return { href: dom.getAttribute("href"), title: dom.getAttribute("title") };
22
- },
23
- },
24
- ],
25
- toDOM(node) {
26
- const { href } = node.attrs;
27
- let fixedHref = href;
28
- if (href && !href.startsWith("mailto:") && !fixedHref.startsWith("http") && !fixedHref.startsWith("/")) {
29
- if (httpRegex.test(href)) {
30
- fixedHref = `https://${href}`;
31
- }
32
- }
33
- return [
34
- "a",
35
- { href: fixedHref, target: "_blank", class: "prosemirror-link", rel: "noopener noreferrer nofollow" },
36
- 0,
37
- ];
38
- },
39
- };
@@ -1,11 +0,0 @@
1
- import type { MarkSpec } from "prosemirror-model";
2
- type Generator = {
3
- generate: (typeId?: string) => string;
4
- };
5
- export declare const makeLinkedHighlight: ({ sharedColorGenerator }: {
6
- sharedColorGenerator?: Generator;
7
- }) => MarkSpec;
8
- export declare const makeLinkedHighlightEntity: ({ sharedColorGenerator }: {
9
- sharedColorGenerator?: Generator;
10
- }) => MarkSpec;
11
- export {};
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeLinkedHighlightEntity = exports.makeLinkedHighlight = void 0;
4
- const hyphenatePascal = (str) => str
5
- .replace(/([a-z])([A-Z])/g, "$1-$2")
6
- .replace(/([A-Z]{2})[a-z]/, "$1-")
7
- .toLowerCase();
8
- const createMark = (markType, sharedColorGenerator) => {
9
- const markTag = `span.${markType}`;
10
- const markClassName = `${markType}`;
11
- const preserveBool = (attr) => (attr === "true" ? true : attr === "false" ? false : attr);
12
- return {
13
- attrs: {
14
- id: {},
15
- meta: { default: {} },
16
- },
17
- inclusive: false,
18
- parseDOM: [
19
- {
20
- tag: markTag,
21
- getAttrs: ({ dataset }) => {
22
- return {
23
- id: dataset.id || false,
24
- meta: Object.keys(dataset)
25
- .filter((key) => key !== "id" && dataset[key] !== "false")
26
- .reduce((out, key) => ({ ...out, [key]: preserveBool(JSON.parse(dataset[key])) }), { type: markType }),
27
- };
28
- },
29
- },
30
- ],
31
- toDOM: ({ attrs }) => {
32
- const { id, meta } = attrs;
33
- const color = sharedColorGenerator ? sharedColorGenerator.generate(attrs) : "#EEEEEE";
34
- return [
35
- markTag,
36
- {
37
- class: markClassName,
38
- style: color ? `--${markType}-background-color:${color}` : ``,
39
- "data-id": id,
40
- ...Object.fromEntries(Object.keys(meta)
41
- .filter((key) => meta[key] !== false) // remove specials
42
- .map((key) => [`data-${hyphenatePascal(key)}`, JSON.stringify(meta[key])])),
43
- },
44
- ];
45
- },
46
- };
47
- };
48
- const makeLinkedHighlight = ({ sharedColorGenerator }) => {
49
- // @ts-expect-error todo: fix this
50
- return createMark("linkedhighlight", sharedColorGenerator);
51
- };
52
- exports.makeLinkedHighlight = makeLinkedHighlight;
53
- const makeLinkedHighlightEntity = ({ sharedColorGenerator }) => {
54
- // @ts-expect-error todo: fix this
55
- return createMark("linkedhighlightentity", sharedColorGenerator);
56
- };
57
- exports.makeLinkedHighlightEntity = makeLinkedHighlightEntity;
@@ -1,2 +0,0 @@
1
- import type { MarkSpec } from "prosemirror-model";
2
- export declare const strike: MarkSpec;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.strike = void 0;
4
- exports.strike = {
5
- parseDOM: [{ tag: "strike" }, { style: "text-decoration=line-through" }],
6
- toDOM: () => ["strike"],
7
- };
@@ -1,6 +0,0 @@
1
- import type { MarkSpec } from "prosemirror-model";
2
- /**
3
- A strong mark. Rendered as `<strong>`, parse rules also match
4
- `<b>` and `font-weight: bold`.
5
- */
6
- export declare const strong: MarkSpec;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.strong = void 0;
4
- const strongDOM = ["strong", 0];
5
- /**
6
- A strong mark. Rendered as `<strong>`, parse rules also match
7
- `<b>` and `font-weight: bold`.
8
- */
9
- exports.strong = {
10
- parseDOM: [
11
- { tag: "strong" },
12
- // This works around a Google Docs misbehavior where
13
- // pasted content will be inexplicably wrapped in `<b>`
14
- // tags with a font-weight normal.
15
- {
16
- tag: "b",
17
- getAttrs: (dom) => {
18
- return dom.style.fontWeight !== "normal" && null;
19
- },
20
- },
21
- { style: "font-weight=400", clearMark: (m) => m.type.name === "strong" },
22
- {
23
- style: "font-weight",
24
- getAttrs: (value) => {
25
- return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null;
26
- },
27
- },
28
- ],
29
- toDOM() {
30
- return strongDOM;
31
- },
32
- };
@@ -1,13 +0,0 @@
1
- import type { MarkSpec } from "prosemirror-model";
2
- export declare enum ColorToken {
3
- Yellow = "YELLOW",
4
- Green = "GREEN",
5
- Aquamarine = "AQUAMARINE",
6
- Aqua = "AQUA",
7
- Blue = "BLUE",
8
- Purple = "PURPLE",
9
- Pink = "PINK",
10
- Red = "RED",
11
- Grey = "GREY"
12
- }
13
- export declare const textBackgroundColor: MarkSpec;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.textBackgroundColor = exports.ColorToken = void 0;
4
- var ColorToken;
5
- (function (ColorToken) {
6
- ColorToken["Yellow"] = "YELLOW";
7
- ColorToken["Green"] = "GREEN";
8
- ColorToken["Aquamarine"] = "AQUAMARINE";
9
- ColorToken["Aqua"] = "AQUA";
10
- ColorToken["Blue"] = "BLUE";
11
- ColorToken["Purple"] = "PURPLE";
12
- ColorToken["Pink"] = "PINK";
13
- ColorToken["Red"] = "RED";
14
- ColorToken["Grey"] = "GREY";
15
- })(ColorToken || (exports.ColorToken = ColorToken = {}));
16
- const isColorToken = (text) => {
17
- return Object.values(ColorToken).includes(text);
18
- };
19
- // Previously we used to store raw color value in the attribute
20
- const persistedRawColorToColorTokenLookup = {
21
- ["HIGHLIGHT-SEARCH"]: ColorToken.Yellow,
22
- ["#f6f1a2"]: ColorToken.Yellow,
23
- ["#d2faad"]: ColorToken.Green,
24
- ["#befccc"]: ColorToken.Aquamarine,
25
- ["#bbf9f8"]: ColorToken.Aqua,
26
- ["#e0f0fe"]: ColorToken.Blue,
27
- ["#f1ebfe"]: ColorToken.Purple,
28
- ["#fce7fb"]: ColorToken.Pink,
29
- ["#fce9e9"]: ColorToken.Red,
30
- ["#e7e9eb"]: ColorToken.Grey,
31
- };
32
- const validateColorToken = (color) => {
33
- if (!color) {
34
- return undefined;
35
- }
36
- if (isColorToken(color)) {
37
- return color;
38
- }
39
- return persistedRawColorToColorTokenLookup[color] || undefined;
40
- };
41
- const getClassName = (bgColorToken, fgColorToken) => {
42
- return [
43
- `text-background-color`,
44
- bgColorToken ? `bg-${bgColorToken.toLowerCase()}` : null,
45
- fgColorToken
46
- ? bgColorToken
47
- ? `fg-on-bg-${fgColorToken.toLowerCase()}`
48
- : `fg-${fgColorToken.toLowerCase()}`
49
- : null,
50
- ]
51
- .filter(Boolean)
52
- .join(` `);
53
- };
54
- exports.textBackgroundColor = {
55
- attrs: {
56
- guid: { default: "" },
57
- color: { default: undefined },
58
- bgColor: { default: undefined },
59
- fgColor: { default: undefined },
60
- },
61
- parseDOM: [
62
- {
63
- tag: "span[data-text-background-color]",
64
- getAttrs: (domNode) => {
65
- const dom = domNode;
66
- const bgColor = dom.getAttribute("data-bg-color") || dom.getAttribute("data-color") || undefined;
67
- const fgColor = dom.getAttribute("data-fg-color") || undefined;
68
- return {
69
- bgColor: bgColor,
70
- fgColor: fgColor,
71
- };
72
- },
73
- },
74
- ],
75
- toDOM(node) {
76
- const bgColor = node.attrs.bgColor || node.attrs.color;
77
- const fgColor = node.attrs.fgColor;
78
- const bgColorToken = validateColorToken(bgColor);
79
- return [
80
- "span",
81
- {
82
- "data-text-background-color": "true",
83
- "data-guid": node.attrs.guid,
84
- "data-bg-color": bgColor || undefined,
85
- "data-fg-color": fgColor || undefined,
86
- class: getClassName(bgColorToken, fgColor),
87
- },
88
- ];
89
- },
90
- };
@@ -1,2 +0,0 @@
1
- import type { MarkSpec } from "prosemirror-model";
2
- export declare const underline: MarkSpec;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.underline = void 0;
4
- exports.underline = {
5
- parseDOM: [{ tag: "u" }, { style: "text-decoration=underline" }],
6
- toDOM: () => ["u"],
7
- };
@@ -1,28 +0,0 @@
1
- import type { EmojiOptions } from "./emoji";
2
- export declare const DEFAULT_CALLOUT_ICON_TYPE = "icon";
3
- export declare const DEFAULT_CALLOUT_ICON = "exclamation-circle";
4
- export declare const makeCallout: ({ getEmoji }?: EmojiOptions) => {
5
- attrs: {
6
- color: {
7
- default: string;
8
- };
9
- iconType: {
10
- default: string;
11
- };
12
- icon: {
13
- default: string;
14
- };
15
- };
16
- group: string;
17
- content: string;
18
- defining: true;
19
- parseDOM: {
20
- tag: string;
21
- getAttrs(domNode: HTMLElement): {
22
- color: string | null;
23
- iconType: string | null;
24
- icon: string | null;
25
- };
26
- }[];
27
- toDOM(node: import("prosemirror-model").Node): [string, Record<string, string>, number];
28
- };
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeCallout = exports.DEFAULT_CALLOUT_ICON = exports.DEFAULT_CALLOUT_ICON_TYPE = void 0;
4
- const nodeType = "data-callout-node";
5
- exports.DEFAULT_CALLOUT_ICON_TYPE = "icon";
6
- exports.DEFAULT_CALLOUT_ICON = "exclamation-circle";
7
- const aliasAttr = "data-icon-emoji-alias";
8
- const defaultOptions = {
9
- getEmoji() {
10
- return;
11
- },
12
- };
13
- 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
- },
61
- });
62
- exports.makeCallout = makeCallout;
@@ -1,11 +0,0 @@
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
- };
10
- }
11
- export declare const check_item: NodeSpec;
@@ -1,34 +0,0 @@
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
- },
34
- };
@@ -1,13 +0,0 @@
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;
5
- }
6
- export interface CheckListDefinition {
7
- type: "check_list";
8
- content: CheckListContent;
9
- attrs: {
10
- id: string;
11
- };
12
- }
13
- export declare const check_list: NodeSpec;
@@ -1,31 +0,0 @@
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
- },
31
- };
@@ -1,2 +0,0 @@
1
- import type { NodeSpec } from "prosemirror-model";
2
- export declare const code_block: NodeSpec;
@@ -1,112 +0,0 @@
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");
6
- const getLanguageFromEditorStyle = (dom) => {
7
- return dom.getAttribute("data-language") || undefined;
8
- };
9
- // example of BB style:
10
- // <div class="codehilite language-javascript"><pre><span>hello world</span><span>\n</span></pre></div>
11
- 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;
17
- };
18
- // If there is a child code element, check that for data-language
19
- 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;
25
- };
26
- 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;
33
- };
34
- 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;
40
- };
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
- },
112
- };