@fibery/prosemirror-schema 1.1.3 → 1.2.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.
- package/lib/index.js +49 -7
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -65,7 +65,7 @@ const tableNodes = (0,external_prosemirror_tables_namespaceObject.tableNodes)({
|
|
|
65
65
|
|
|
66
66
|
setDOMAttr(value, attrs) {
|
|
67
67
|
if (value) {
|
|
68
|
-
attrs.style = (attrs.style || "") +
|
|
68
|
+
attrs.style = (attrs.style || "") + "background-color: ".concat(value, ";");
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -390,6 +390,46 @@ const check_item = {
|
|
|
390
390
|
}
|
|
391
391
|
|
|
392
392
|
};
|
|
393
|
+
;// CONCATENATED MODULE: ./src/nodes/codeBlock.js
|
|
394
|
+
const code_block = {
|
|
395
|
+
content: "text*",
|
|
396
|
+
marks: "",
|
|
397
|
+
group: "block",
|
|
398
|
+
code: true,
|
|
399
|
+
defining: true,
|
|
400
|
+
attrs: {
|
|
401
|
+
language: {
|
|
402
|
+
default: null
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
parseDOM: [{
|
|
406
|
+
tag: "pre",
|
|
407
|
+
preserveWhitespace: "full",
|
|
408
|
+
getAttrs: dom => {
|
|
409
|
+
const language = getLanguageFromCode(dom);
|
|
410
|
+
return {
|
|
411
|
+
language
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
}],
|
|
415
|
+
|
|
416
|
+
toDOM(node) {
|
|
417
|
+
return ["pre", ["code", {
|
|
418
|
+
"data-language": node.attrs.language
|
|
419
|
+
}, 0]];
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
}; // If there is a child code element, check that for data-language
|
|
423
|
+
|
|
424
|
+
const getLanguageFromCode = dom => {
|
|
425
|
+
const firstChild = dom.firstElementChild;
|
|
426
|
+
|
|
427
|
+
if (firstChild && firstChild.nodeName === "CODE") {
|
|
428
|
+
return firstChild.getAttribute("data-language") || undefined;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
return undefined;
|
|
432
|
+
};
|
|
393
433
|
;// CONCATENATED MODULE: ./src/nodes/video.js
|
|
394
434
|
const DEFAULT_VIDEO_WIDTH = 400;
|
|
395
435
|
const DEFAULT_VIDEO_HEIGHT = 200;
|
|
@@ -516,7 +556,7 @@ const highlight = {
|
|
|
516
556
|
return ["span", {
|
|
517
557
|
"data-highlight": "true",
|
|
518
558
|
"data-guid": node.attrs.guid,
|
|
519
|
-
style:
|
|
559
|
+
style: "background-color:".concat(node.attrs.color)
|
|
520
560
|
}];
|
|
521
561
|
}
|
|
522
562
|
|
|
@@ -525,8 +565,8 @@ const highlight = {
|
|
|
525
565
|
const hyphenatePascal = str => str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z]{2})[a-z]/, "$1-").toLowerCase();
|
|
526
566
|
|
|
527
567
|
const createMark = (markType, sharedColorGenerator) => {
|
|
528
|
-
const markTag =
|
|
529
|
-
const markClassName =
|
|
568
|
+
const markTag = "span.".concat(markType);
|
|
569
|
+
const markClassName = "".concat(markType);
|
|
530
570
|
|
|
531
571
|
const preserveBool = attr => attr === "true" ? true : attr === "false" ? false : attr;
|
|
532
572
|
|
|
@@ -568,13 +608,13 @@ const createMark = (markType, sharedColorGenerator) => {
|
|
|
568
608
|
} = meta.links && meta.links.length > 0 ? meta.links[0] : {};
|
|
569
609
|
const color = sharedColorGenerator ? sharedColorGenerator.generate(typeId) : "#eeeeee";
|
|
570
610
|
return [markTag, {
|
|
571
|
-
class: [markClassName, hidden ?
|
|
611
|
+
class: [markClassName, hidden ? "".concat(markClassName, "--collapsed") : ""].join(" "),
|
|
572
612
|
contenteditable: !hidden,
|
|
573
|
-
style: color ?
|
|
613
|
+
style: color ? "background-color:".concat(color) : "",
|
|
574
614
|
"data-id": id,
|
|
575
615
|
...Object.keys(meta).filter(key => meta[key] !== false) // remove specials
|
|
576
616
|
.reduce((out, key) => ({ ...out,
|
|
577
|
-
[
|
|
617
|
+
["data-".concat(hyphenatePascal(key))]: JSON.stringify(meta[key])
|
|
578
618
|
}), {})
|
|
579
619
|
}];
|
|
580
620
|
}
|
|
@@ -624,12 +664,14 @@ const makeLink = baseLink => {
|
|
|
624
664
|
|
|
625
665
|
|
|
626
666
|
|
|
667
|
+
|
|
627
668
|
|
|
628
669
|
const createSchema = ({
|
|
629
670
|
sharedColorGenerator = null,
|
|
630
671
|
headingToDOM = null,
|
|
631
672
|
mediaToDom = null
|
|
632
673
|
} = {}) => {
|
|
674
|
+
external_prosemirror_schema_basic_namespaceObject.nodes.code_block = code_block;
|
|
633
675
|
external_prosemirror_schema_basic_namespaceObject.nodes.paragraph = paragraph;
|
|
634
676
|
external_prosemirror_schema_basic_namespaceObject.nodes.heading = makeHeading({
|
|
635
677
|
headingToDOM
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/prosemirror-schema",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Fibery prosemirror schema",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"browser": "./index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"uuid": "8.3.2"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"prosemirror-model": "^1.
|
|
22
|
+
"prosemirror-model": "^1.16.0",
|
|
23
23
|
"prosemirror-schema-list": "^1.0.2",
|
|
24
24
|
"prosemirror-tables": "^0.7.5"
|
|
25
25
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"babel-preset-fibery": "7.2.0",
|
|
29
29
|
"eslint-config-fibery": "7.0.0",
|
|
30
30
|
"jest": "27.0.6",
|
|
31
|
-
"webpack": "5.
|
|
31
|
+
"webpack": "5.64.2",
|
|
32
32
|
"webpack-cli": "4.7.2"
|
|
33
33
|
},
|
|
34
34
|
"jest": {
|