@fibery/prosemirror-schema 1.4.0 → 1.5.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 (2) hide show
  1. package/lib/index.js +61 -2
  2. package/package.json +16 -3
package/lib/index.js CHANGED
@@ -233,6 +233,55 @@ const important = {
233
233
  }, ["p", 0]];
234
234
  }
235
235
 
236
+ };
237
+ ;// CONCATENATED MODULE: ./src/nodes/image-block.ts
238
+ const imageBlock = {
239
+ attrs: {
240
+ src: {},
241
+ alt: {
242
+ default: null
243
+ },
244
+ title: {
245
+ default: null
246
+ }
247
+ },
248
+ // ----------------
249
+ inline: false,
250
+ // inline: true,
251
+ group: "block",
252
+ // group: "inline",
253
+ content: "inline*",
254
+ atom: true,
255
+ // ----------------
256
+ draggable: true,
257
+ parseDOM: [{
258
+ tag: "img[src]",
259
+
260
+ getAttrs(domNode) {
261
+ const dom = domNode;
262
+ return {
263
+ src: dom.getAttribute("src"),
264
+ title: dom.getAttribute("title"),
265
+ alt: dom.getAttribute("alt")
266
+ };
267
+ }
268
+
269
+ }],
270
+
271
+ toDOM(node) {
272
+ const {
273
+ src,
274
+ alt,
275
+ title
276
+ } = node.attrs; // return ["img", {src, alt, title}];
277
+
278
+ return ["div", {}, ["img", {
279
+ src,
280
+ alt,
281
+ title
282
+ }]];
283
+ }
284
+
236
285
  };
237
286
  ;// CONCATENATED MODULE: ./src/nodes/entity.ts
238
287
  const entity = {
@@ -742,11 +791,13 @@ const makeLink = baseLink => {
742
791
 
743
792
 
744
793
 
794
+
745
795
 
746
796
  const createSchema = ({
747
797
  sharedColorGenerator = null,
748
798
  headingToDOM = null,
749
- mediaToDom = null
799
+ mediaToDom = null,
800
+ isImageBlockEnabled = false
750
801
  } = {}) => {
751
802
  external_prosemirror_schema_basic_namespaceObject.nodes.code_block = code_block;
752
803
  external_prosemirror_schema_basic_namespaceObject.nodes.paragraph = paragraph;
@@ -770,8 +821,16 @@ const createSchema = ({
770
821
  check_list: check_list,
771
822
  video: video
772
823
  };
824
+ let actualNodes = (0,external_prosemirror_schema_list_namespaceObject.addListNodes)(base.spec.nodes, "paragraph block*", "block").append(tableNodes).append(customNodes);
825
+
826
+ if (isImageBlockEnabled) {
827
+ actualNodes = actualNodes.addToStart("imageBlock", imageBlock);
828
+ } else {
829
+ actualNodes = actualNodes.addToEnd("imageBlock", imageBlock);
830
+ }
831
+
773
832
  return new external_prosemirror_model_namespaceObject.Schema({
774
- nodes: (0,external_prosemirror_schema_list_namespaceObject.addListNodes)(base.spec.nodes, "paragraph block*", "block").append(tableNodes).append(customNodes),
833
+ nodes: actualNodes,
775
834
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
776
835
  // @ts-ignore
777
836
  marks: base.spec.marks // eslint-disable-next-line @typescript-eslint/ban-ts-comment
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/prosemirror-schema",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Fibery prosemirror schema",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -10,6 +10,7 @@
10
10
  "scripts": {
11
11
  "build": "BABEL_ENV=production webpack",
12
12
  "test": "jest",
13
+ "test:ci": "yarn test --coverage --reporters=default --reporters=jest-junit",
13
14
  "lint": "eslint ",
14
15
  "prepublishOnly": "npm run build"
15
16
  },
@@ -26,12 +27,24 @@
26
27
  "@types/prosemirror-model": "1.16.1",
27
28
  "babel-loader": "8.2.2",
28
29
  "babel-preset-fibery": "7.2.0",
29
- "eslint-config-fibery": "7.0.0",
30
+ "eslint-config-fibery": "7.1.0",
30
31
  "jest": "27.5.1",
32
+ "jest-junit": "13.0.0",
31
33
  "webpack": "5.64.2",
32
34
  "webpack-cli": "4.7.2"
33
35
  },
34
36
  "jest": {
35
- "testEnvironment": "jsdom"
37
+ "testEnvironment": "jsdom",
38
+ "coveragePathIgnorePatterns": [
39
+ "/node_modules/"
40
+ ],
41
+ "collectCoverageFrom": [
42
+ "src/**/*.{js,jsx,ts,tsx}",
43
+ "!src/**/*.d.ts"
44
+ ],
45
+ "coverageReporters": [
46
+ "text",
47
+ "cobertura"
48
+ ]
36
49
  }
37
50
  }