@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,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.paragraph = void 0;
4
- const uuid_1 = require("uuid");
5
- exports.paragraph = {
6
- content: "inline*",
7
- group: "block",
8
- attrs: {
9
- // "id" is the unified block identifier; "guid" is deprecated and mirrors
10
- // "id" until all consumers (client editor, fibery backend) read "id".
11
- id: { default: null },
12
- guid: { default: "" },
13
- },
14
- parseDOM: [
15
- {
16
- tag: "p",
17
- getAttrs: (dom) => {
18
- const id = dom.getAttribute("data-guid") || (0, uuid_1.v4)();
19
- return { id, guid: id };
20
- },
21
- },
22
- ],
23
- toDOM(node) {
24
- const id = node.attrs.id || node.attrs.guid;
25
- return ["p", { "data-id": id, "data-guid": id }, 0];
26
- },
27
- };
@@ -1,2 +0,0 @@
1
- import type { NodeSpec } from "prosemirror-model";
2
- export declare const tableNodes: Record<string, NodeSpec>;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tableNodes = void 0;
4
- const prosemirror_tables_1 = require("prosemirror-tables");
5
- exports.tableNodes = (0, prosemirror_tables_1.tableNodes)({
6
- tableGroup: "block",
7
- cellContent: "block+",
8
- cellAttributes: {
9
- background: {
10
- default: null,
11
- getFromDOM(dom) {
12
- return dom.style.backgroundColor || null;
13
- },
14
- setDOMAttr(value, attrs) {
15
- if (value) {
16
- attrs.style = (attrs.style || "") + `background-color: ${value};`;
17
- }
18
- },
19
- },
20
- },
21
- });
@@ -1,10 +0,0 @@
1
- import type { EntityDefinition as Entity } from "../entity";
2
- import type { MentionDefinition as Mention } from "../mention";
3
- import type { TextDefinition as Text } from "./text";
4
- interface MarksObject<T> {
5
- marks?: Array<T>;
6
- }
7
- export type InlineFormattedText = Text & MarksObject<unknown>;
8
- export type InlineAtomic = Mention | Entity | unknown;
9
- export type Inline = InlineFormattedText | InlineAtomic;
10
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export interface TextDefinition {
2
- type: "text";
3
- text: string;
4
- marks?: Array<any>;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- import type { NodeSpec } from "prosemirror-model";
2
- export declare const DEFAULT_VIDEO_WIDTH = 400;
3
- export declare const DEFAULT_VIDEO_HEIGHT = 200;
4
- export declare const video: NodeSpec;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.video = exports.DEFAULT_VIDEO_HEIGHT = exports.DEFAULT_VIDEO_WIDTH = void 0;
4
- const resizable_node_attrs_1 = require("../resizable-node-attrs");
5
- const transcription_node_attrs_1 = require("../transcription-node-attrs");
6
- exports.DEFAULT_VIDEO_WIDTH = 400;
7
- exports.DEFAULT_VIDEO_HEIGHT = 200;
8
- exports.video = {
9
- inline: false,
10
- attrs: {
11
- src: {},
12
- type: {},
13
- width: { default: exports.DEFAULT_VIDEO_WIDTH },
14
- height: { default: exports.DEFAULT_VIDEO_HEIGHT },
15
- title: { default: "" },
16
- alignment: { default: ":alignment/block-center" },
17
- ...(0, resizable_node_attrs_1.createDefaultAttrs)(),
18
- ...(0, transcription_node_attrs_1.createDefaultAttrs)(),
19
- },
20
- group: "block",
21
- draggable: true,
22
- parseDOM: [
23
- {
24
- tag: "video",
25
- getAttrs(domNode) {
26
- const dom = domNode;
27
- return {
28
- src: dom.getAttribute("src"),
29
- type: dom.getAttribute("type"),
30
- width: Number(dom.getAttribute("width")) || exports.DEFAULT_VIDEO_WIDTH,
31
- height: Number(dom.getAttribute("height")) || exports.DEFAULT_VIDEO_HEIGHT,
32
- title: dom.getAttribute("title"),
33
- ...(0, resizable_node_attrs_1.createParseDomAttrs)(dom),
34
- };
35
- },
36
- },
37
- ],
38
- toDOM(node) {
39
- const { src, type, width = exports.DEFAULT_VIDEO_WIDTH, height = exports.DEFAULT_VIDEO_HEIGHT, title } = node.attrs;
40
- return [
41
- "video",
42
- {
43
- src,
44
- type,
45
- width,
46
- height,
47
- title,
48
- playsinline: "",
49
- controls: "",
50
- preload: "metadata",
51
- ...(0, resizable_node_attrs_1.createToDomAttrs)(node.attrs),
52
- },
53
- ];
54
- },
55
- };
@@ -1,29 +0,0 @@
1
- import type { Attrs } from "prosemirror-model";
2
- export declare const defaultHeight = 400;
3
- export declare const defaultWidth = 900;
4
- export declare function createDefaultAttrs(): {
5
- nodeHeight: {
6
- default: number;
7
- };
8
- nodeWidth: {
9
- default: number;
10
- };
11
- nodePageWidth: {
12
- default: boolean;
13
- };
14
- nodeFullWidth: {
15
- default: boolean;
16
- };
17
- };
18
- export declare function createParseDomAttrs(dom: HTMLElement): {
19
- nodeHeight: string | null;
20
- nodeWidth: string | null;
21
- nodePageWidth: string | null;
22
- nodeFullWidth: string | null;
23
- };
24
- export declare function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth }: Attrs): {
25
- "data-node-height": any;
26
- "data-node-width": any;
27
- "data-node-page-width": any;
28
- "data-node-full-width": any;
29
- };
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultWidth = exports.defaultHeight = void 0;
4
- exports.createDefaultAttrs = createDefaultAttrs;
5
- exports.createParseDomAttrs = createParseDomAttrs;
6
- exports.createToDomAttrs = createToDomAttrs;
7
- exports.defaultHeight = 400;
8
- exports.defaultWidth = 900;
9
- function createDefaultAttrs() {
10
- return {
11
- nodeHeight: {
12
- default: exports.defaultHeight,
13
- },
14
- nodeWidth: {
15
- default: exports.defaultWidth,
16
- },
17
- nodePageWidth: {
18
- default: true,
19
- },
20
- nodeFullWidth: {
21
- default: false,
22
- },
23
- };
24
- }
25
- function createParseDomAttrs(dom) {
26
- return {
27
- nodeHeight: dom.getAttribute("data-node-height"),
28
- nodeWidth: dom.getAttribute("data-node-width"),
29
- nodePageWidth: dom.getAttribute("data-node-page-width"),
30
- nodeFullWidth: dom.getAttribute("data-node-full-width"),
31
- };
32
- }
33
- function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth }) {
34
- return {
35
- "data-node-height": nodeHeight,
36
- "data-node-width": nodeWidth,
37
- "data-node-page-width": nodePageWidth,
38
- "data-node-full-width": nodeFullWidth,
39
- };
40
- }
@@ -1,9 +0,0 @@
1
- export declare function createDefaultAttrs(): {
2
- transcription: {
3
- default: {
4
- status: string;
5
- userId: string;
6
- inserted: boolean;
7
- };
8
- };
9
- };
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createDefaultAttrs = createDefaultAttrs;
4
- function createDefaultAttrs() {
5
- return {
6
- transcription: {
7
- default: { status: "IDLE", userId: "", inserted: false },
8
- },
9
- };
10
- }
@@ -1,4 +0,0 @@
1
- import type { Schema, Node as PMNode, ParseOptions } from "prosemirror-model";
2
- export declare const fromHTML: (html: string, schema: Schema, options?: ParseOptions) => PMNode;
3
- export declare const toDOM: (node: PMNode, schema: Schema) => Node;
4
- export declare const toHTML: (node: PMNode, schema: Schema) => string;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toHTML = exports.toDOM = exports.fromHTML = void 0;
4
- const prosemirror_model_1 = require("prosemirror-model");
5
- const fromHTML = (html, schema, options) => {
6
- const el = document.createElement("div");
7
- el.innerHTML = html;
8
- return prosemirror_model_1.DOMParser.fromSchema(schema).parse(el, options);
9
- };
10
- exports.fromHTML = fromHTML;
11
- const toDOM = (node, schema) => {
12
- const serializer = prosemirror_model_1.DOMSerializer.fromSchema(schema);
13
- return serializer.serializeFragment(prosemirror_model_1.Fragment.from(node));
14
- };
15
- exports.toDOM = toDOM;
16
- const toHTML = (node, schema) => {
17
- const el = document.createElement("div");
18
- el.appendChild((0, exports.toDOM)(node, schema));
19
- return el.innerHTML;
20
- };
21
- exports.toHTML = toHTML;