@fibery/prosemirror-schema 1.4.0 → 1.6.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 (2) hide show
  1. package/lib/index.js +69 -9
  2. package/package.json +19 -6
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 = {
@@ -327,14 +376,15 @@ const external_uuid_namespaceObject = require("uuid");
327
376
  const check_list = {
328
377
  group: "block",
329
378
  defining: true,
330
- content: "check_item+",
379
+ selectable: false,
380
+ content: "(check_item)+ (check_item|check_list)*",
331
381
  attrs: {
332
382
  id: {
333
383
  default: ""
334
384
  }
335
385
  },
336
386
  parseDOM: [{
337
- tag: "ol[data-check-list-id]",
387
+ tag: "div[data-check-list-id]",
338
388
  // Default priority is 50. We normaly don't change this but since this node type is
339
389
  // also used by ordered-list we need to make sure that we run this parser first.
340
390
  priority: 100,
@@ -348,10 +398,9 @@ const check_list = {
348
398
  id
349
399
  } = node.attrs;
350
400
  const attrs = {
351
- "data-check-list-id": id,
352
- style: "list-style: none; padding-left: 0; margin-left: 0; margin-bottom: 0;"
401
+ "data-check-list-id": id
353
402
  };
354
- return ["ol", attrs, 0];
403
+ return ["div", attrs, 0];
355
404
  }
356
405
 
357
406
  };
@@ -360,6 +409,7 @@ const check_list = {
360
409
  const check_item = {
361
410
  content: "inline*",
362
411
  defining: true,
412
+ selectable: false,
363
413
  marks: "_",
364
414
  attrs: {
365
415
  id: {
@@ -370,7 +420,7 @@ const check_item = {
370
420
  }
371
421
  },
372
422
  parseDOM: [{
373
- tag: "li[data-check-item-id]",
423
+ tag: "div[data-check-item-id]",
374
424
  // Default priority is 50. We normally don't change this but since this node type is
375
425
  // also used by list-item we need to make sure that we run this parser first.
376
426
  priority: 100,
@@ -389,7 +439,7 @@ const check_item = {
389
439
  "data-check-item-id": id,
390
440
  "data-check-item-state": state
391
441
  };
392
- return ["li", attrs, 0];
442
+ return ["div", attrs, 0];
393
443
  }
394
444
 
395
445
  };
@@ -742,11 +792,13 @@ const makeLink = baseLink => {
742
792
 
743
793
 
744
794
 
795
+
745
796
 
746
797
  const createSchema = ({
747
798
  sharedColorGenerator = null,
748
799
  headingToDOM = null,
749
- mediaToDom = null
800
+ mediaToDom = null,
801
+ isImageBlockEnabled = false
750
802
  } = {}) => {
751
803
  external_prosemirror_schema_basic_namespaceObject.nodes.code_block = code_block;
752
804
  external_prosemirror_schema_basic_namespaceObject.nodes.paragraph = paragraph;
@@ -770,8 +822,16 @@ const createSchema = ({
770
822
  check_list: check_list,
771
823
  video: video
772
824
  };
825
+ let actualNodes = (0,external_prosemirror_schema_list_namespaceObject.addListNodes)(base.spec.nodes, "paragraph block*", "block").append(tableNodes).append(customNodes);
826
+
827
+ if (isImageBlockEnabled) {
828
+ actualNodes = actualNodes.addToStart("imageBlock", imageBlock);
829
+ } else {
830
+ actualNodes = actualNodes.addToEnd("imageBlock", imageBlock);
831
+ }
832
+
773
833
  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),
834
+ nodes: actualNodes,
775
835
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
776
836
  // @ts-ignore
777
837
  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.6.1",
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
  },
@@ -24,14 +25,26 @@
24
25
  },
25
26
  "devDependencies": {
26
27
  "@types/prosemirror-model": "1.16.1",
27
- "babel-loader": "8.2.2",
28
+ "babel-loader": "8.2.5",
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",
31
- "webpack": "5.64.2",
32
- "webpack-cli": "4.7.2"
32
+ "jest-junit": "13.0.0",
33
+ "webpack": "5.72.0",
34
+ "webpack-cli": "4.9.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
  }