@fibery/prosemirror-schema 4.25.0 → 5.0.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 (45) hide show
  1. package/lib/attr-constraints.d.ts +10 -11
  2. package/lib/attr-constraints.js +6 -0
  3. package/lib/block-id-utils.d.ts +7 -8
  4. package/lib/create-schema.d.ts +3 -4
  5. package/lib/create-schema.js +3 -0
  6. package/lib/index.d.ts +3 -1
  7. package/lib/marks/code.d.ts +2 -3
  8. package/lib/marks/em.d.ts +2 -3
  9. package/lib/marks/hint-query.d.ts +2 -3
  10. package/lib/marks/link.d.ts +2 -3
  11. package/lib/marks/linked-highlight.d.ts +5 -6
  12. package/lib/marks/strike.d.ts +2 -3
  13. package/lib/marks/strong.d.ts +2 -3
  14. package/lib/marks/suggestions.d.ts +11 -12
  15. package/lib/marks/text-background-color.d.ts +5 -6
  16. package/lib/marks/underline.d.ts +2 -3
  17. package/lib/nodes/callout.d.ts +4 -5
  18. package/lib/nodes/check-item.d.ts +3 -4
  19. package/lib/nodes/check-list.d.ts +4 -5
  20. package/lib/nodes/code-block.d.ts +2 -3
  21. package/lib/nodes/column.d.ts +2 -3
  22. package/lib/nodes/columns.d.ts +2 -3
  23. package/lib/nodes/emoji.d.ts +3 -4
  24. package/lib/nodes/entity.d.ts +4 -5
  25. package/lib/nodes/fibery-view.d.ts +2 -3
  26. package/lib/nodes/file-block.d.ts +42 -0
  27. package/lib/nodes/file-block.js +35 -0
  28. package/lib/nodes/file.d.ts +15 -5
  29. package/lib/nodes/file.js +16 -14
  30. package/lib/nodes/heading.d.ts +2 -3
  31. package/lib/nodes/image-block.d.ts +2 -3
  32. package/lib/nodes/important.d.ts +2 -3
  33. package/lib/nodes/math-display.d.ts +2 -3
  34. package/lib/nodes/math-inline.d.ts +2 -3
  35. package/lib/nodes/media.d.ts +2 -3
  36. package/lib/nodes/mention.d.ts +4 -5
  37. package/lib/nodes/note.d.ts +2 -3
  38. package/lib/nodes/paragraph.d.ts +2 -3
  39. package/lib/nodes/table-nodes.d.ts +4 -5
  40. package/lib/nodes/types/inline-content.d.ts +4 -5
  41. package/lib/nodes/types/text.d.ts +2 -3
  42. package/lib/nodes/video.d.ts +4 -5
  43. package/lib/resizable-node-attrs.d.ts +6 -7
  44. package/lib/transcription-node-attrs.d.ts +2 -3
  45. package/package.json +1 -1
@@ -1,20 +1,19 @@
1
1
  //#region src/attr-constraints.d.ts
2
- type AttrConstraintType = "string" | "number" | "integer" | "boolean" | "null" | "stringMap";
3
- type AttrConstraint = {
2
+ export type AttrConstraintType = "string" | "number" | "integer" | "boolean" | "null" | "stringMap";
3
+ export type AttrConstraint = {
4
4
  type?: ReadonlyArray<AttrConstraintType>;
5
5
  enum?: ReadonlyArray<string | number | boolean | null>;
6
6
  minimum?: number;
7
7
  maximum?: number;
8
8
  };
9
- declare const NODE_ATTR_CONSTRAINTS: Record<string, Record<string, AttrConstraint>>;
10
- declare const MARK_ATTR_CONSTRAINTS: Record<string, Record<string, AttrConstraint>>;
11
- declare const validateAttrValue: (nodeType: string, attr: string, value: unknown) => string | null;
12
- declare const validateMarkAttrValue: (markType: string, attr: string, value: unknown) => string | null;
13
- type AttrValidationIssue = {
9
+ export declare const NODE_ATTR_CONSTRAINTS: Record<string, Record<string, AttrConstraint>>;
10
+ export declare const MARK_ATTR_CONSTRAINTS: Record<string, Record<string, AttrConstraint>>;
11
+ export declare const validateAttrValue: (nodeType: string, attr: string, value: unknown) => string | null;
12
+ export declare const validateMarkAttrValue: (markType: string, attr: string, value: unknown) => string | null;
13
+ export type AttrValidationIssue = {
14
14
  attr: string;
15
15
  message: string;
16
16
  };
17
- declare const validateAttrs: (nodeType: string, attrs: Record<string, unknown>) => AttrValidationIssue[];
18
- declare const validateMarkAttrs: (markType: string, attrs: Record<string, unknown>) => AttrValidationIssue[];
19
- //#endregion
20
- export { AttrConstraint, AttrConstraintType, AttrValidationIssue, MARK_ATTR_CONSTRAINTS, NODE_ATTR_CONSTRAINTS, validateAttrValue, validateAttrs, validateMarkAttrValue, validateMarkAttrs };
17
+ export declare const validateAttrs: (nodeType: string, attrs: Record<string, unknown>) => AttrValidationIssue[];
18
+ export declare const validateMarkAttrs: (markType: string, attrs: Record<string, unknown>) => AttrValidationIssue[];
19
+ //#endregion
@@ -67,6 +67,12 @@ const NODE_ATTR_CONSTRAINTS = {
67
67
  title: { type: ["string", "null"] },
68
68
  ...resizableConstraints()
69
69
  },
70
+ fileBlock: {
71
+ src: { type: ["string"] },
72
+ title: { type: ["string"] },
73
+ size: { type: ["number", "null"] },
74
+ type: { type: ["string", "null"] }
75
+ },
70
76
  fiberyView: { ...resizableConstraints() }
71
77
  };
72
78
  const MARK_ATTR_CONSTRAINTS = {
@@ -1,10 +1,9 @@
1
1
  import { Node, NodeType } from "prosemirror-model";
2
2
  //#region src/block-id-utils.d.ts
3
- declare const getBlockIdAttr: (type: NodeType) => "id" | null;
4
- declare const hasLegacyGuidAttr: (type: NodeType) => boolean;
5
- declare const getBlockId: (node: Node) => string | null;
6
- declare const buildBlockIdAttrs: (node: Node, nextId: string) => Record<string, unknown>;
7
- declare const FIBERY_VIEW_TYPE = "fiberyView";
8
- declare const getFiberyViewRef: (node: Node) => string | null;
9
- //#endregion
10
- export { FIBERY_VIEW_TYPE, buildBlockIdAttrs, getBlockId, getBlockIdAttr, getFiberyViewRef, hasLegacyGuidAttr };
3
+ export declare const getBlockIdAttr: (type: NodeType) => "id" | null;
4
+ export declare const hasLegacyGuidAttr: (type: NodeType) => boolean;
5
+ export declare const getBlockId: (node: Node) => string | null;
6
+ export declare const buildBlockIdAttrs: (node: Node, nextId: string) => Record<string, unknown>;
7
+ export declare const FIBERY_VIEW_TYPE = "fiberyView";
8
+ export declare const getFiberyViewRef: (node: Node) => string | null;
9
+ //#endregion
@@ -9,11 +9,10 @@ type Params = {
9
9
  mediaToDom?: ((node: Node) => HTMLElement) | null;
10
10
  emojiOptions?: EmojiOptions;
11
11
  };
12
- declare const createSchema: ({ sharedColorGenerator, headingToDOM, mediaToDom, isImageBlockEnabled, fiberyViewEnabled, emojiOptions }?: Params) => Schema;
13
- declare const Basic: {
12
+ export declare const createSchema: ({ sharedColorGenerator, headingToDOM, mediaToDom, isImageBlockEnabled, fiberyViewEnabled, emojiOptions }?: Params) => Schema;
13
+ export declare const Basic: {
14
14
  nodes: Record<string, NodeSpec>;
15
15
  marks: Record<string, MarkSpec>;
16
16
  fibery: Record<string, MarkSpec>;
17
17
  };
18
- //#endregion
19
- export { Basic, createSchema };
18
+ //#endregion
@@ -18,6 +18,7 @@ import { makeEmoji } from "./nodes/emoji.js";
18
18
  import { entity } from "./nodes/entity.js";
19
19
  import { fiberyView } from "./nodes/fibery-view.js";
20
20
  import { file } from "./nodes/file.js";
21
+ import { fileBlock } from "./nodes/file-block.js";
21
22
  import { makeHeading } from "./nodes/heading.js";
22
23
  import { imageBlock } from "./nodes/image-block.js";
23
24
  import { important } from "./nodes/important.js";
@@ -77,6 +78,7 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
77
78
  check_list,
78
79
  video,
79
80
  file,
81
+ fileBlock,
80
82
  emoji: makeEmoji(emojiOptions),
81
83
  callout: makeCallout(emojiOptions),
82
84
  columns,
@@ -195,6 +197,7 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
195
197
  "media",
196
198
  "video",
197
199
  "imageBlock",
200
+ "fileBlock",
198
201
  "math_display",
199
202
  "column"
200
203
  ]) {
package/lib/index.d.ts CHANGED
@@ -3,10 +3,12 @@ import { FIBERY_VIEW_TYPE, buildBlockIdAttrs, getBlockId, getBlockIdAttr, getFib
3
3
  import { EmojiOptions } from "./nodes/emoji.js";
4
4
  import { Basic, createSchema } from "./create-schema.js";
5
5
  import { defaultHeight, defaultWidth } from "./resizable-node-attrs.js";
6
+ import { EntityAttributes } from "./nodes/entity.js";
7
+ import { MentionAttributes } from "./nodes/mention.js";
6
8
  import { DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH } from "./nodes/video.js";
7
9
  import { DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE } from "./nodes/callout.js";
8
10
  import { CellAlign, cellAlignValues } from "./nodes/table-nodes.js";
9
11
  import { ColorToken, isColorToken, validateColorToken } from "./marks/text-background-color.js";
10
12
  import { INLINE_SUGGESTION_MARK_NAMES, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, SuggestionBaggage, SuggestionMarkName, isSuggestionBaggage } from "./marks/suggestions.js";
11
13
  import { Node, Schema } from "prosemirror-model";
12
- export { type AttrConstraint, type AttrConstraintType, type AttrValidationIssue, Basic, type CellAlign, ColorToken, DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH, type EmojiOptions, FIBERY_VIEW_TYPE, INLINE_SUGGESTION_MARK_NAMES, MARK_ATTR_CONSTRAINTS, NODE_ATTR_CONSTRAINTS, Node, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, Schema, type SuggestionBaggage, type SuggestionMarkName, buildBlockIdAttrs, cellAlignValues, createSchema, defaultHeight, defaultWidth, getBlockId, getBlockIdAttr, getFiberyViewRef, hasLegacyGuidAttr, isColorToken, isSuggestionBaggage, validateAttrValue, validateAttrs, validateColorToken, validateMarkAttrValue, validateMarkAttrs };
14
+ export { type AttrConstraint, type AttrConstraintType, type AttrValidationIssue, Basic, type CellAlign, ColorToken, DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH, type EmojiOptions, type EntityAttributes, FIBERY_VIEW_TYPE, INLINE_SUGGESTION_MARK_NAMES, MARK_ATTR_CONSTRAINTS, type MentionAttributes, NODE_ATTR_CONSTRAINTS, Node, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, Schema, type SuggestionBaggage, type SuggestionMarkName, buildBlockIdAttrs, cellAlignValues, createSchema, defaultHeight, defaultWidth, getBlockId, getBlockIdAttr, getFiberyViewRef, hasLegacyGuidAttr, isColorToken, isSuggestionBaggage, validateAttrValue, validateAttrs, validateColorToken, validateMarkAttrValue, validateMarkAttrs };
@@ -3,6 +3,5 @@ import { MarkSpec } from "prosemirror-model";
3
3
  /**
4
4
  Code font mark. Represented as a `<code>` element.
5
5
  */
6
- declare const code: MarkSpec;
7
- //#endregion
8
- export { code };
6
+ export declare const code: MarkSpec;
7
+ //#endregion
package/lib/marks/em.d.ts CHANGED
@@ -4,6 +4,5 @@ import { MarkSpec } from "prosemirror-model";
4
4
  An emphasis mark. Rendered as an `<em>` element. Has parse rules
5
5
  that also match `<i>` and `font-style: italic`.
6
6
  */
7
- declare const em: MarkSpec;
8
- //#endregion
9
- export { em };
7
+ export declare const em: MarkSpec;
8
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { MarkSpec } from "prosemirror-model";
2
2
  //#region src/marks/hint-query.d.ts
3
- declare const hintQuery: MarkSpec;
4
- //#endregion
5
- export { hintQuery };
3
+ export declare const hintQuery: MarkSpec;
4
+ //#endregion
@@ -5,6 +5,5 @@ import { MarkSpec } from "prosemirror-model";
5
5
  defaults to the empty string. Rendered and parsed as an `<a>`
6
6
  element.
7
7
  */
8
- declare const link: MarkSpec;
9
- //#endregion
10
- export { link };
8
+ export declare const link: MarkSpec;
9
+ //#endregion
@@ -1,13 +1,12 @@
1
- import { MarkSpec } from "prosemirror-model";
1
+ import { Attrs, MarkSpec } from "prosemirror-model";
2
2
  //#region src/marks/linked-highlight.d.ts
3
3
  type Generator = {
4
- generate: (typeId?: string) => string;
4
+ generate(markAttrs: Attrs): string | null;
5
5
  };
6
- declare const makeLinkedHighlight: ({ sharedColorGenerator }: {
6
+ export declare const makeLinkedHighlight: ({ sharedColorGenerator }: {
7
7
  sharedColorGenerator?: Generator;
8
8
  }) => MarkSpec;
9
- declare const makeLinkedHighlightEntity: ({ sharedColorGenerator }: {
9
+ export declare const makeLinkedHighlightEntity: ({ sharedColorGenerator }: {
10
10
  sharedColorGenerator?: Generator;
11
11
  }) => MarkSpec;
12
- //#endregion
13
- export { makeLinkedHighlight, makeLinkedHighlightEntity };
12
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { MarkSpec } from "prosemirror-model";
2
2
  //#region src/marks/strike.d.ts
3
- declare const strike: MarkSpec;
4
- //#endregion
5
- export { strike };
3
+ export declare const strike: MarkSpec;
4
+ //#endregion
@@ -4,6 +4,5 @@ import { MarkSpec } from "prosemirror-model";
4
4
  A strong mark. Rendered as `<strong>`, parse rules also match
5
5
  `<b>` and `font-weight: bold`.
6
6
  */
7
- declare const strong: MarkSpec;
8
- //#endregion
9
- export { strong };
7
+ export declare const strong: MarkSpec;
8
+ //#endregion
@@ -1,14 +1,13 @@
1
1
  import { MarkSpec } from "prosemirror-model";
2
2
  //#region src/marks/suggestions.d.ts
3
- declare const SUGGESTION_MARK_NAMES: readonly ["insertion", "deletion", "modification", "blockBoundarySuggestion"];
4
- type SuggestionMarkName = (typeof SUGGESTION_MARK_NAMES)[number];
5
- declare const SUGGESTION_MARKS_EXPR: string;
6
- declare const INLINE_SUGGESTION_MARK_NAMES: readonly ["insertion", "deletion"];
7
- type SuggestionBaggage = Record<string, string>;
8
- declare const isSuggestionBaggage: (value: unknown) => value is SuggestionBaggage;
9
- declare const insertion: MarkSpec;
10
- declare const deletion: MarkSpec;
11
- declare const modification: MarkSpec;
12
- declare const blockBoundarySuggestion: MarkSpec;
13
- //#endregion
14
- export { INLINE_SUGGESTION_MARK_NAMES, SUGGESTION_MARKS_EXPR, SUGGESTION_MARK_NAMES, SuggestionBaggage, SuggestionMarkName, blockBoundarySuggestion, deletion, insertion, isSuggestionBaggage, modification };
3
+ export declare const SUGGESTION_MARK_NAMES: readonly ["insertion", "deletion", "modification", "blockBoundarySuggestion"];
4
+ export type SuggestionMarkName = (typeof SUGGESTION_MARK_NAMES)[number];
5
+ export declare const SUGGESTION_MARKS_EXPR: string;
6
+ export declare const INLINE_SUGGESTION_MARK_NAMES: readonly ["insertion", "deletion"];
7
+ export type SuggestionBaggage = Record<string, string>;
8
+ export declare const isSuggestionBaggage: (value: unknown) => value is SuggestionBaggage;
9
+ export declare const insertion: MarkSpec;
10
+ export declare const deletion: MarkSpec;
11
+ export declare const modification: MarkSpec;
12
+ export declare const blockBoundarySuggestion: MarkSpec;
13
+ //#endregion
@@ -1,6 +1,6 @@
1
1
  import { MarkSpec } from "prosemirror-model";
2
2
  //#region src/marks/text-background-color.d.ts
3
- declare enum ColorToken {
3
+ export declare enum ColorToken {
4
4
  Yellow = "YELLOW",
5
5
  Green = "GREEN",
6
6
  Aquamarine = "AQUAMARINE",
@@ -11,8 +11,7 @@ declare enum ColorToken {
11
11
  Red = "RED",
12
12
  Grey = "GREY"
13
13
  }
14
- declare const isColorToken: (text: string) => text is ColorToken;
15
- declare const validateColorToken: (color: string | undefined) => ColorToken | undefined;
16
- declare const textBackgroundColor: MarkSpec;
17
- //#endregion
18
- export { ColorToken, isColorToken, textBackgroundColor, validateColorToken };
14
+ export declare const isColorToken: (text: string) => text is ColorToken;
15
+ export declare const validateColorToken: (color: string | undefined) => ColorToken | undefined;
16
+ export declare const textBackgroundColor: MarkSpec;
17
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { MarkSpec } from "prosemirror-model";
2
2
  //#region src/marks/underline.d.ts
3
- declare const underline: MarkSpec;
4
- //#endregion
5
- export { underline };
3
+ export declare const underline: MarkSpec;
4
+ //#endregion
@@ -1,8 +1,8 @@
1
1
  import { EmojiOptions } from "./emoji.js";
2
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) => {
3
+ export declare const DEFAULT_CALLOUT_ICON_TYPE = "icon";
4
+ export declare const DEFAULT_CALLOUT_ICON = "exclamation-circle";
5
+ export declare const makeCallout: ({ getEmoji }?: EmojiOptions) => {
6
6
  attrs: {
7
7
  color: {
8
8
  default: string;
@@ -27,5 +27,4 @@ declare const makeCallout: ({ getEmoji }?: EmojiOptions) => {
27
27
  }[];
28
28
  toDOM(node: import("prosemirror-model").Node): [string, Record<string, string>, number];
29
29
  };
30
- //#endregion
31
- export { DEFAULT_CALLOUT_ICON, DEFAULT_CALLOUT_ICON_TYPE, makeCallout };
30
+ //#endregion
@@ -1,7 +1,7 @@
1
1
  import { Inline } from "./types/inline-content.js";
2
2
  import { NodeSpec } from "prosemirror-model";
3
3
  //#region src/nodes/check-item.d.ts
4
- interface CheckItemDefinition {
4
+ export interface CheckItemDefinition {
5
5
  type: "check_item";
6
6
  content?: Array<Inline>;
7
7
  attrs: {
@@ -9,6 +9,5 @@ interface CheckItemDefinition {
9
9
  state: "TODO" | "DONE";
10
10
  };
11
11
  }
12
- declare const check_item: NodeSpec;
13
- //#endregion
14
- export { CheckItemDefinition, check_item };
12
+ export declare const check_item: NodeSpec;
13
+ //#endregion
@@ -1,16 +1,15 @@
1
1
  import { CheckItemDefinition } from "./check-item.js";
2
2
  import { NodeSpec } from "prosemirror-model";
3
3
  //#region src/nodes/check-list.d.ts
4
- interface CheckListContent extends Array<CheckItemDefinition | CheckListDefinition> {
4
+ export interface CheckListContent extends Array<CheckItemDefinition | CheckListDefinition> {
5
5
  0: CheckItemDefinition;
6
6
  }
7
- interface CheckListDefinition {
7
+ export interface CheckListDefinition {
8
8
  type: "check_list";
9
9
  content: CheckListContent;
10
10
  attrs: {
11
11
  id: string;
12
12
  };
13
13
  }
14
- declare const check_list: NodeSpec;
15
- //#endregion
16
- export { CheckListContent, CheckListDefinition, check_list };
14
+ export declare const check_list: NodeSpec;
15
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/code-block.d.ts
3
- declare const code_block: NodeSpec;
4
- //#endregion
5
- export { code_block };
3
+ export declare const code_block: NodeSpec;
4
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/column.d.ts
3
- declare const column: NodeSpec;
4
- //#endregion
5
- export { column };
3
+ export declare const column: NodeSpec;
4
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/columns.d.ts
3
- declare const columns: NodeSpec;
4
- //#endregion
5
- export { columns };
3
+ export declare const columns: NodeSpec;
4
+ //#endregion
@@ -5,10 +5,10 @@ type Emoji = {
5
5
  colons: string;
6
6
  native?: string;
7
7
  };
8
- type EmojiOptions = {
8
+ export type EmojiOptions = {
9
9
  getEmoji: (code: string) => Emoji | void;
10
10
  };
11
- declare const makeEmoji: ({ getEmoji }?: EmojiOptions) => {
11
+ export declare const makeEmoji: ({ getEmoji }?: EmojiOptions) => {
12
12
  attrs: {
13
13
  code: {};
14
14
  };
@@ -29,5 +29,4 @@ declare const makeEmoji: ({ getEmoji }?: EmojiOptions) => {
29
29
  "data-emoji-code": any;
30
30
  }, any];
31
31
  };
32
- //#endregion
33
- export { EmojiOptions, makeEmoji };
32
+ //#endregion
@@ -7,16 +7,15 @@ type Meta = {
7
7
  contextEntityTypeId?: string;
8
8
  contextEntityPublicId?: string;
9
9
  };
10
- interface EntityAttributes {
10
+ export interface EntityAttributes {
11
11
  id: string;
12
12
  typeId: string;
13
13
  text?: string;
14
14
  meta: Meta;
15
15
  }
16
- interface EntityDefinition {
16
+ export interface EntityDefinition {
17
17
  type: "entity";
18
18
  attrs: EntityAttributes;
19
19
  }
20
- declare const entity: NodeSpec;
21
- //#endregion
22
- export { EntityAttributes, EntityDefinition, entity };
20
+ export declare const entity: NodeSpec;
21
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/fibery-view.d.ts
3
- declare const fiberyView: NodeSpec;
4
- //#endregion
5
- export { fiberyView };
3
+ export declare const fiberyView: NodeSpec;
4
+ //#endregion
@@ -0,0 +1,42 @@
1
+ //#region src/nodes/file-block.d.ts
2
+ export declare const fileBlock: {
3
+ attrs: {
4
+ transcription: {
5
+ default: {
6
+ status: string;
7
+ userId: string;
8
+ inserted: boolean;
9
+ };
10
+ };
11
+ src: {};
12
+ title: {
13
+ default: string;
14
+ };
15
+ size: {
16
+ default: null;
17
+ };
18
+ type: {
19
+ default: null;
20
+ };
21
+ };
22
+ inline: false;
23
+ group: string;
24
+ atom: true;
25
+ draggable: true;
26
+ leafText: (node: import("prosemirror-model").Node) => any;
27
+ parseDOM: {
28
+ tag: string;
29
+ getAttrs(dom: HTMLElement): {
30
+ src: string | null;
31
+ title: string;
32
+ type: string | null;
33
+ size: number | null;
34
+ };
35
+ }[];
36
+ toDOM(node: import("prosemirror-model").Node): [string, {
37
+ "data-file-href": any;
38
+ "data-size": any;
39
+ "data-type": any;
40
+ }, any];
41
+ };
42
+ //#endregion
@@ -0,0 +1,35 @@
1
+ import { createDefaultAttrs } from "../transcription-node-attrs.js";
2
+ import { fileElementAttrs, parseFileElement } from "./file.js";
3
+ //#region src/nodes/file-block.ts
4
+ const fileBlock = {
5
+ attrs: {
6
+ src: {},
7
+ title: { default: "Untitled" },
8
+ size: { default: null },
9
+ type: { default: null },
10
+ ...createDefaultAttrs()
11
+ },
12
+ inline: false,
13
+ group: "block",
14
+ atom: true,
15
+ draggable: true,
16
+ leafText: (node) => node.attrs.src ? node.attrs.title : "",
17
+ parseDOM: [{
18
+ tag: "div[data-file-href]",
19
+ getAttrs(dom) {
20
+ return {
21
+ ...parseFileElement(dom),
22
+ size: Number(dom.getAttribute("data-size")) || null
23
+ };
24
+ }
25
+ }],
26
+ toDOM(node) {
27
+ return [
28
+ "div",
29
+ fileElementAttrs(node.attrs),
30
+ node.attrs.title
31
+ ];
32
+ }
33
+ };
34
+ //#endregion
35
+ export { fileBlock };
@@ -1,5 +1,16 @@
1
+ import { Attrs } from "prosemirror-model";
1
2
  //#region src/nodes/file.d.ts
2
- declare const file: {
3
+ export declare const parseFileElement: (dom: HTMLElement) => {
4
+ src: string | null;
5
+ title: string;
6
+ type: string | null;
7
+ };
8
+ export declare const fileElementAttrs: ({ src, size, type }: Attrs) => {
9
+ "data-file-href": any;
10
+ "data-size": any;
11
+ "data-type": any;
12
+ };
13
+ export declare const file: {
3
14
  attrs: {
4
15
  transcription: {
5
16
  default: {
@@ -22,11 +33,11 @@ declare const file: {
22
33
  leafText: (node: import("prosemirror-model").Node) => any;
23
34
  parseDOM: {
24
35
  tag: string;
25
- getAttrs(domNode: HTMLElement): {
36
+ getAttrs(dom: HTMLElement): {
26
37
  src: string | null;
27
38
  title: string;
28
- size: string | null;
29
39
  type: string | null;
40
+ size: string | null;
30
41
  };
31
42
  }[];
32
43
  toDOM(node: import("prosemirror-model").Node): [string, {
@@ -35,5 +46,4 @@ declare const file: {
35
46
  "data-type": any;
36
47
  }, any];
37
48
  };
38
- //#endregion
39
- export { file };
49
+ //#endregion
package/lib/nodes/file.js CHANGED
@@ -1,5 +1,15 @@
1
1
  import { createDefaultAttrs } from "../transcription-node-attrs.js";
2
2
  //#region src/nodes/file.ts
3
+ const parseFileElement = (dom) => ({
4
+ src: dom.getAttribute("data-file-href"),
5
+ title: dom.textContent,
6
+ type: dom.getAttribute("data-type")
7
+ });
8
+ const fileElementAttrs = ({ src, size, type }) => ({
9
+ "data-file-href": src,
10
+ "data-size": size,
11
+ "data-type": type
12
+ });
3
13
  const file = {
4
14
  attrs: {
5
15
  src: {},
@@ -15,28 +25,20 @@ const file = {
15
25
  leafText: (node) => node.attrs.title,
16
26
  parseDOM: [{
17
27
  tag: "span[data-file-href]",
18
- getAttrs(domNode) {
19
- const dom = domNode;
28
+ getAttrs(dom) {
20
29
  return {
21
- src: dom.getAttribute("data-file-href"),
22
- title: dom.textContent,
23
- size: dom.getAttribute("data-size"),
24
- type: dom.getAttribute("data-type")
30
+ ...parseFileElement(dom),
31
+ size: dom.getAttribute("data-size")
25
32
  };
26
33
  }
27
34
  }],
28
35
  toDOM(node) {
29
- const { src, title, type, size } = node.attrs;
30
36
  return [
31
37
  "span",
32
- {
33
- "data-file-href": src,
34
- "data-size": size,
35
- "data-type": type
36
- },
37
- title
38
+ fileElementAttrs(node.attrs),
39
+ node.attrs.title
38
40
  ];
39
41
  }
40
42
  };
41
43
  //#endregion
42
- export { file };
44
+ export { file, fileElementAttrs, parseFileElement };
@@ -1,7 +1,6 @@
1
1
  import { Node, NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/heading.d.ts
3
- declare const makeHeading: ({ headingToDOM }: {
3
+ export declare const makeHeading: ({ headingToDOM }: {
4
4
  headingToDOM: ((node: Node) => HTMLElement) | null;
5
5
  }) => NodeSpec;
6
- //#endregion
7
- export { makeHeading };
6
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/image-block.d.ts
3
- declare const imageBlock: NodeSpec;
4
- //#endregion
5
- export { imageBlock };
3
+ export declare const imageBlock: NodeSpec;
4
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/important.d.ts
3
- declare const important: NodeSpec;
4
- //#endregion
5
- export { important };
3
+ export declare const important: NodeSpec;
4
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/math-display.d.ts
3
- declare const math_display: NodeSpec;
4
- //#endregion
5
- export { math_display };
3
+ export declare const math_display: NodeSpec;
4
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/math-inline.d.ts
3
- declare const math_inline: NodeSpec;
4
- //#endregion
5
- export { math_inline };
3
+ export declare const math_inline: NodeSpec;
4
+ //#endregion
@@ -1,7 +1,6 @@
1
1
  import { Node, NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/media.d.ts
3
- declare const makeMedia: ({ mediaToDom }: {
3
+ export declare const makeMedia: ({ mediaToDom }: {
4
4
  mediaToDom: ((node: Node) => HTMLElement) | null;
5
5
  }) => NodeSpec;
6
- //#endregion
7
- export { makeMedia };
6
+ //#endregion
@@ -1,14 +1,13 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/mention.d.ts
3
- interface MentionAttributes {
3
+ export interface MentionAttributes {
4
4
  id: string;
5
5
  typeId: string;
6
6
  name?: string;
7
7
  }
8
- interface MentionDefinition {
8
+ export interface MentionDefinition {
9
9
  type: "mention";
10
10
  attrs: MentionAttributes;
11
11
  }
12
- declare const mention: NodeSpec;
13
- //#endregion
14
- export { MentionAttributes, MentionDefinition, mention };
12
+ export declare const mention: NodeSpec;
13
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/note.d.ts
3
- declare const note: NodeSpec;
4
- //#endregion
5
- export { note };
3
+ export declare const note: NodeSpec;
4
+ //#endregion
@@ -1,5 +1,4 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/paragraph.d.ts
3
- declare const paragraph: NodeSpec;
4
- //#endregion
5
- export { paragraph };
3
+ export declare const paragraph: NodeSpec;
4
+ //#endregion
@@ -1,7 +1,6 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/table-nodes.d.ts
3
- declare const cellAlignValues: readonly ["left", "center", "right"];
4
- type CellAlign = (typeof cellAlignValues)[number];
5
- declare const tableNodes: Record<string, NodeSpec>;
6
- //#endregion
7
- export { CellAlign, cellAlignValues, tableNodes };
3
+ export declare const cellAlignValues: readonly ["left", "center", "right"];
4
+ export type CellAlign = (typeof cellAlignValues)[number];
5
+ export declare const tableNodes: Record<string, NodeSpec>;
6
+ //#endregion
@@ -5,8 +5,7 @@ import { TextDefinition } from "./text.js";
5
5
  interface MarksObject<T> {
6
6
  marks?: Array<T>;
7
7
  }
8
- type InlineFormattedText = TextDefinition & MarksObject<unknown>;
9
- type InlineAtomic = MentionDefinition | EntityDefinition | unknown;
10
- type Inline = InlineFormattedText | InlineAtomic;
11
- //#endregion
12
- export { Inline, InlineAtomic, InlineFormattedText };
8
+ export type InlineFormattedText = TextDefinition & MarksObject<unknown>;
9
+ export type InlineAtomic = MentionDefinition | EntityDefinition | unknown;
10
+ export type Inline = InlineFormattedText | InlineAtomic;
11
+ //#endregion
@@ -1,8 +1,7 @@
1
1
  //#region src/nodes/types/text.d.ts
2
- interface TextDefinition {
2
+ export interface TextDefinition {
3
3
  type: "text";
4
4
  text: string;
5
5
  marks?: Array<any>;
6
6
  }
7
- //#endregion
8
- export { TextDefinition };
7
+ //#endregion
@@ -1,7 +1,6 @@
1
1
  import { NodeSpec } from "prosemirror-model";
2
2
  //#region src/nodes/video.d.ts
3
- declare const DEFAULT_VIDEO_WIDTH = 400;
4
- declare const DEFAULT_VIDEO_HEIGHT = 200;
5
- declare const video: NodeSpec;
6
- //#endregion
7
- export { DEFAULT_VIDEO_HEIGHT, DEFAULT_VIDEO_WIDTH, video };
3
+ export declare const DEFAULT_VIDEO_WIDTH = 400;
4
+ export declare const DEFAULT_VIDEO_HEIGHT = 200;
5
+ export declare const video: NodeSpec;
6
+ //#endregion
@@ -1,8 +1,8 @@
1
1
  import { Attrs } from "prosemirror-model";
2
2
  //#region src/resizable-node-attrs.d.ts
3
- declare const defaultHeight = 400;
4
- declare const defaultWidth = 900;
5
- declare function createDefaultAttrs(): {
3
+ export declare const defaultHeight = 400;
4
+ export declare const defaultWidth = 900;
5
+ export declare function createDefaultAttrs(): {
6
6
  nodeHeight: {
7
7
  default: number;
8
8
  };
@@ -16,17 +16,16 @@ declare function createDefaultAttrs(): {
16
16
  default: boolean;
17
17
  };
18
18
  };
19
- declare function createParseDomAttrs(dom: HTMLElement): {
19
+ export declare function createParseDomAttrs(dom: HTMLElement): {
20
20
  nodeHeight: string | null;
21
21
  nodeWidth: string | null;
22
22
  nodePageWidth: string | null;
23
23
  nodeFullWidth: string | null;
24
24
  };
25
- declare function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth }: Attrs): {
25
+ export declare function createToDomAttrs({ nodeHeight, nodeWidth, nodePageWidth, nodeFullWidth }: Attrs): {
26
26
  "data-node-height": any;
27
27
  "data-node-width": any;
28
28
  "data-node-page-width": any;
29
29
  "data-node-full-width": any;
30
30
  };
31
- //#endregion
32
- export { createDefaultAttrs, createParseDomAttrs, createToDomAttrs, defaultHeight, defaultWidth };
31
+ //#endregion
@@ -1,5 +1,5 @@
1
1
  //#region src/transcription-node-attrs.d.ts
2
- declare function createDefaultAttrs(): {
2
+ export declare function createDefaultAttrs(): {
3
3
  transcription: {
4
4
  default: {
5
5
  status: string;
@@ -8,5 +8,4 @@ declare function createDefaultAttrs(): {
8
8
  };
9
9
  };
10
10
  };
11
- //#endregion
12
- export { createDefaultAttrs };
11
+ //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "4.25.0",
3
+ "version": "5.0.0",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "license": "UNLICENSED",
6
6
  "files": [