@bigfootai/bigfoot-types 3.5.4 → 3.5.5
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/editor.js +47 -34
- package/editor.ts +54 -35
- package/package.json +1 -2
package/editor.js
CHANGED
@@ -1,45 +1,58 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
exports.bigfootSchema = void 0;
|
7
4
|
const prosemirror_model_1 = require("prosemirror-model");
|
8
5
|
const prosemirror_schema_basic_1 = require("prosemirror-schema-basic");
|
9
6
|
const prosemirror_schema_list_1 = require("prosemirror-schema-list");
|
10
|
-
const
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
const tag = {
|
8
|
+
attrs: {
|
9
|
+
tagId: { default: null },
|
10
|
+
tagType: { default: null },
|
11
|
+
recommendationId: { default: null },
|
12
|
+
},
|
13
|
+
inclusive: false,
|
14
|
+
parseDOM: [
|
15
|
+
{
|
16
|
+
tag: 'span[data-tag-id][data-recommendation-id][data-tag-type]',
|
17
|
+
getAttrs(dom) {
|
18
|
+
return {
|
19
|
+
tagId: dom.getAttribute('data-tag-id'),
|
20
|
+
tagType: dom.getAttribute('data-tag-type'),
|
21
|
+
recommendationId: dom.getAttribute('data-recommendation-id'),
|
22
|
+
};
|
23
|
+
},
|
18
24
|
},
|
19
|
-
|
20
|
-
|
25
|
+
],
|
26
|
+
toDOM(node) {
|
27
|
+
const { tagId, tagType, recommendationId } = node.attrs;
|
28
|
+
return [
|
29
|
+
'span',
|
21
30
|
{
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
tagId: dom.getAttribute('data-tag-id'),
|
26
|
-
tagType: dom.getAttribute('data-tag-type'),
|
27
|
-
recommendationId: dom.getAttribute('data-recommendation-id'),
|
28
|
-
};
|
29
|
-
},
|
31
|
+
'data-tag-id': tagId,
|
32
|
+
'data-tag-type': tagType,
|
33
|
+
'data-recommendation-id': recommendationId,
|
30
34
|
},
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
0,
|
42
|
-
];
|
35
|
+
0,
|
36
|
+
];
|
37
|
+
},
|
38
|
+
};
|
39
|
+
const strong = {
|
40
|
+
parseDOM: [
|
41
|
+
{ tag: 'strong' },
|
42
|
+
{
|
43
|
+
tag: 'b',
|
44
|
+
getAttrs: (node) => node.style.fontWeight != 'normal' && null,
|
43
45
|
},
|
44
|
-
|
46
|
+
],
|
47
|
+
toDOM: () => ['strong', 0],
|
48
|
+
};
|
49
|
+
exports.bigfootSchema = new prosemirror_model_1.Schema({
|
50
|
+
nodes: (0, prosemirror_schema_list_1.addListNodes)(prosemirror_schema_basic_1.schema.spec.nodes, 'paragraph block*', 'block'),
|
51
|
+
marks: {
|
52
|
+
...prosemirror_schema_basic_1.schema.spec.marks,
|
53
|
+
// @ts-expect-error - I will do a better job typing this later. Your friend in time, past you.
|
54
|
+
tag,
|
55
|
+
// @ts-expect-error - I will do a better job typing this later. Your friend in time, past you.
|
56
|
+
strong,
|
57
|
+
},
|
45
58
|
});
|
package/editor.ts
CHANGED
@@ -1,44 +1,63 @@
|
|
1
1
|
import { Schema } from 'prosemirror-model';
|
2
2
|
import { schema } from 'prosemirror-schema-basic';
|
3
3
|
import { addListNodes } from 'prosemirror-schema-list';
|
4
|
-
import orderedMap from 'orderedmap';
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
const tag = {
|
6
|
+
attrs: {
|
7
|
+
tagId: { default: null },
|
8
|
+
tagType: { default: null },
|
9
|
+
recommendationId: { default: null },
|
10
|
+
},
|
11
|
+
inclusive: false,
|
12
|
+
parseDOM: [
|
13
|
+
{
|
14
|
+
tag: 'span[data-tag-id][data-recommendation-id][data-tag-type]',
|
15
|
+
getAttrs(dom: HTMLElement) {
|
16
|
+
return {
|
17
|
+
tagId: (dom as HTMLElement).getAttribute('data-tag-id'),
|
18
|
+
tagType: (dom as HTMLElement).getAttribute('data-tag-type'),
|
19
|
+
recommendationId: (dom as HTMLElement).getAttribute(
|
20
|
+
'data-recommendation-id'
|
21
|
+
),
|
22
|
+
};
|
23
|
+
},
|
13
24
|
},
|
14
|
-
|
15
|
-
|
25
|
+
],
|
26
|
+
toDOM(node: {
|
27
|
+
attrs: { tagId: string; tagType: string; recommendationId: string };
|
28
|
+
}) {
|
29
|
+
const { tagId, tagType, recommendationId } = node.attrs;
|
30
|
+
return [
|
31
|
+
'span',
|
16
32
|
{
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
tagId: (dom as HTMLElement).getAttribute('data-tag-id'),
|
21
|
-
tagType: (dom as HTMLElement).getAttribute(
|
22
|
-
'data-tag-type'
|
23
|
-
),
|
24
|
-
recommendationId: (dom as HTMLElement).getAttribute(
|
25
|
-
'data-recommendation-id'
|
26
|
-
),
|
27
|
-
};
|
28
|
-
},
|
33
|
+
'data-tag-id': tagId,
|
34
|
+
'data-tag-type': tagType,
|
35
|
+
'data-recommendation-id': recommendationId,
|
29
36
|
},
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
0,
|
38
|
+
];
|
39
|
+
},
|
40
|
+
};
|
41
|
+
|
42
|
+
const strong = {
|
43
|
+
parseDOM: [
|
44
|
+
{ tag: 'strong' },
|
45
|
+
{
|
46
|
+
tag: 'b',
|
47
|
+
getAttrs: (node: HTMLElement) =>
|
48
|
+
node.style.fontWeight != 'normal' && null,
|
42
49
|
},
|
43
|
-
|
50
|
+
],
|
51
|
+
toDOM: () => ['strong', 0],
|
52
|
+
};
|
53
|
+
|
54
|
+
export const bigfootSchema = new Schema({
|
55
|
+
nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),
|
56
|
+
marks: {
|
57
|
+
...schema.spec.marks,
|
58
|
+
// @ts-expect-error - I will do a better job typing this later. Your friend in time, past you.
|
59
|
+
tag,
|
60
|
+
// @ts-expect-error - I will do a better job typing this later. Your friend in time, past you.
|
61
|
+
strong,
|
62
|
+
},
|
44
63
|
});
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"author": "Bigfoot",
|
3
3
|
"name": "@bigfootai/bigfoot-types",
|
4
|
-
"version": "3.5.
|
4
|
+
"version": "3.5.5",
|
5
5
|
"description": "The internal library for the types used in the Bigfoot platform",
|
6
6
|
"main": "model.js",
|
7
7
|
"license": "ISC",
|
@@ -14,7 +14,6 @@
|
|
14
14
|
"dev": "node model.js"
|
15
15
|
},
|
16
16
|
"dependencies": {
|
17
|
-
"orderedmap": "^2.1.1",
|
18
17
|
"prosemirror-model": "^1.19.4",
|
19
18
|
"prosemirror-schema-basic": "^1.2.2",
|
20
19
|
"prosemirror-schema-list": "^1.3.0",
|