@fibery/prosemirror-schema 3.0.0-next.2 → 3.1.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.
@@ -2,11 +2,9 @@ import { Schema, Node } from "prosemirror-model";
2
2
  interface SchemaProps {
3
3
  isImageBlockEnabled?: boolean;
4
4
  fiberyViewEnabled?: boolean;
5
- fiberySectionEnabled?: boolean;
6
- fiberySectionStrictMode?: boolean;
7
5
  sharedColorGenerator?: any;
8
6
  headingToDOM?: ((node: Node) => HTMLElement) | null;
9
7
  mediaToDom?: ((node: Node) => HTMLElement) | null;
10
8
  }
11
- export declare const createSchema: ({ sharedColorGenerator, headingToDOM, mediaToDom, isImageBlockEnabled, fiberyViewEnabled, fiberySectionEnabled, fiberySectionStrictMode, }?: SchemaProps) => Schema;
9
+ export declare const createSchema: ({ sharedColorGenerator, headingToDOM, mediaToDom, isImageBlockEnabled, fiberyViewEnabled, }?: SchemaProps) => Schema;
12
10
  export {};
@@ -20,14 +20,14 @@ const check_list_1 = require("./nodes/check-list");
20
20
  const check_item_1 = require("./nodes/check-item");
21
21
  const code_block_1 = require("./nodes/code-block");
22
22
  const video_1 = require("./nodes/video");
23
+ const file_1 = require("./nodes/file");
23
24
  const strike_1 = require("./marks/strike");
24
25
  const underline_1 = require("./marks/underline");
25
26
  const hint_query_1 = require("./marks/hint-query");
26
27
  const highlight_1 = require("./marks/highlight");
27
28
  const linked_highlight_1 = require("./marks/linked-highlight");
28
29
  const link_1 = require("./marks/link");
29
- const fibery_section_1 = require("./nodes/fibery-section");
30
- const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, fiberySectionEnabled = false, fiberySectionStrictMode = true, } = {}) => {
30
+ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaToDom = null, isImageBlockEnabled = false, fiberyViewEnabled = false, } = {}) => {
31
31
  prosemirror_schema_basic_1.nodes.code_block = code_block_1.code_block;
32
32
  prosemirror_schema_basic_1.nodes.paragraph = paragraph_1.paragraph;
33
33
  prosemirror_schema_basic_1.nodes.heading = (0, heading_1.makeHeading)({ headingToDOM });
@@ -42,6 +42,7 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
42
42
  check_item: check_item_1.check_item,
43
43
  check_list: check_list_1.check_list,
44
44
  video: video_1.video,
45
+ file: file_1.file,
45
46
  };
46
47
  let actualNodes = (0, prosemirror_schema_list_1.addListNodes)(base.spec.nodes, "paragraph block*", "block")
47
48
  .append({ ...table_nodes_1.tableNodes })
@@ -55,21 +56,6 @@ const createSchema = ({ sharedColorGenerator = null, headingToDOM = null, mediaT
55
56
  else {
56
57
  actualNodes = actualNodes.addToEnd("imageBlock", image_block_1.imageBlock);
57
58
  }
58
- if (fiberySectionEnabled) {
59
- actualNodes = actualNodes.append({
60
- [fibery_section_1.fiberySectionNodeTypeName]: fibery_section_1.fiberySection,
61
- });
62
- if (fiberySectionStrictMode) {
63
- actualNodes = actualNodes.update("doc", {
64
- content: `${fibery_section_1.fiberySectionNodeTypeName}+`,
65
- });
66
- }
67
- else {
68
- actualNodes = actualNodes.update("doc", {
69
- content: `(${fibery_section_1.fiberySectionNodeTypeName} | block)+`,
70
- });
71
- }
72
- }
73
59
  return new prosemirror_model_1.Schema({
74
60
  nodes: actualNodes,
75
61
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -0,0 +1,32 @@
1
+ export declare const file: {
2
+ attrs: {
3
+ src: {};
4
+ title: {
5
+ default: null;
6
+ };
7
+ size: {
8
+ default: null;
9
+ };
10
+ type: {
11
+ default: null;
12
+ };
13
+ };
14
+ inline: false;
15
+ group: string;
16
+ selectable: false;
17
+ draggable: true;
18
+ parseDOM: {
19
+ tag: string;
20
+ getAttrs(domNode: string | HTMLElement): {
21
+ src: string | null;
22
+ title: string | null;
23
+ size: string | null;
24
+ type: string | null;
25
+ };
26
+ }[];
27
+ toDOM(node: import("prosemirror-model").Node): [string, {
28
+ "data-file-href": any;
29
+ "data-size": any;
30
+ "data-type": any;
31
+ }, any];
32
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.file = void 0;
4
+ exports.file = {
5
+ attrs: {
6
+ src: {},
7
+ title: { default: null },
8
+ size: { default: null },
9
+ type: { default: null },
10
+ },
11
+ inline: false,
12
+ group: "block",
13
+ selectable: false,
14
+ draggable: true,
15
+ parseDOM: [
16
+ {
17
+ tag: "div[data-file-href]",
18
+ getAttrs(domNode) {
19
+ const dom = domNode;
20
+ return {
21
+ src: dom.getAttribute("data-file-href"),
22
+ title: dom.textContent,
23
+ size: dom.getAttribute("data-size"),
24
+ type: dom.getAttribute("data-type"),
25
+ };
26
+ },
27
+ },
28
+ ],
29
+ toDOM(node) {
30
+ const { src, title, type, size } = node.attrs;
31
+ const attrs = {
32
+ "data-file-href": src,
33
+ "data-size": size,
34
+ "data-type": type,
35
+ };
36
+ return ["div", attrs, title];
37
+ },
38
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "3.0.0-next.2",
3
+ "version": "3.1.0",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -1,3 +0,0 @@
1
- import { NodeSpec } from "prosemirror-model";
2
- export declare const fiberySectionNodeTypeName = "fiberySection";
3
- export declare const fiberySection: NodeSpec;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fiberySection = exports.fiberySectionNodeTypeName = void 0;
4
- const sectionIdAttrName = "data-section-id";
5
- const tagName = "fibery-section";
6
- exports.fiberySectionNodeTypeName = "fiberySection";
7
- exports.fiberySection = {
8
- content: "block+",
9
- attrs: {
10
- id: { default: "" },
11
- },
12
- parseDOM: [
13
- {
14
- tag: `${tagName}[${sectionIdAttrName}]`,
15
- getAttrs: (domNode) => {
16
- const dom = domNode;
17
- return {
18
- id: dom.getAttribute(sectionIdAttrName),
19
- };
20
- },
21
- },
22
- ],
23
- toDOM(node) {
24
- const { id } = node.attrs;
25
- const attrs = {
26
- [sectionIdAttrName]: id,
27
- };
28
- return [tagName, attrs, 0];
29
- },
30
- };