@bigfootai/bigfoot-types 3.7.7 → 3.7.9
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 +82 -36
- package/editor.ts +97 -40
- package/model.js +2 -0
- package/model.ts +3 -0
- package/package.json +1 -1
package/editor.js
CHANGED
@@ -1,48 +1,94 @@
|
|
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
|
-
|
18
|
-
|
7
|
+
const tag = {
|
8
|
+
attrs: {
|
9
|
+
tagId: { default: null },
|
10
|
+
tagType: { default: null },
|
11
|
+
recommendationId: { default: null },
|
12
|
+
ignore: { default: null },
|
13
|
+
},
|
14
|
+
inclusive: false,
|
15
|
+
parseDOM: [
|
16
|
+
{
|
17
|
+
tag: 'span[data-tag-id][data-tag-type][data-recommendation-id][data-ignore]',
|
18
|
+
getAttrs(dom) {
|
19
|
+
return {
|
20
|
+
tagId: dom.getAttribute('data-tag-id'),
|
21
|
+
tagType: dom.getAttribute('data-tag-type'),
|
22
|
+
recommendationId: dom.getAttribute('data-recommendation-id'),
|
23
|
+
ignore: dom.getAttribute('data-ignore'),
|
24
|
+
};
|
25
|
+
},
|
19
26
|
},
|
20
|
-
|
21
|
-
|
27
|
+
],
|
28
|
+
//@ts-expect-error Not sure why this is throwing an error, but will revisit
|
29
|
+
toDOM(node) {
|
30
|
+
const { tagId, tagType, recommendationId, ignore } = node.attrs;
|
31
|
+
return [
|
32
|
+
'span',
|
22
33
|
{
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
34
|
+
'data-tag-id': tagId,
|
35
|
+
'data-tag-type': tagType,
|
36
|
+
'data-recommendation-id': recommendationId,
|
37
|
+
'data-ignore': ignore,
|
38
|
+
},
|
39
|
+
0,
|
40
|
+
];
|
41
|
+
},
|
42
|
+
};
|
43
|
+
const checklist = {
|
44
|
+
content: 'checklistItem+',
|
45
|
+
group: 'block',
|
46
|
+
toDOM: () => ['ul', 0],
|
47
|
+
parseDOM: [{ tag: 'ul.checklist' }],
|
48
|
+
};
|
49
|
+
const checklistItem = {
|
50
|
+
content: 'text*',
|
51
|
+
attrs: { checked: { default: false } },
|
52
|
+
//@ts-expect-error Not sure why this is throwing an error, but will revisit
|
53
|
+
toDOM: (node) => [
|
54
|
+
'li',
|
55
|
+
{ 'data-checked': node?.attrs?.checked ? 'true' : 'false' },
|
56
|
+
[
|
57
|
+
'input',
|
58
|
+
{
|
59
|
+
type: 'checkbox',
|
60
|
+
checked: node?.attrs?.checked ? 'checked' : '',
|
32
61
|
},
|
33
62
|
],
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
63
|
+
['span', {}],
|
64
|
+
],
|
65
|
+
parseDOM: [
|
66
|
+
{
|
67
|
+
tag: 'li[data-checked]',
|
68
|
+
getAttrs: (dom) => ({
|
69
|
+
checked: dom.getAttribute('data-checked') === 'true',
|
70
|
+
}),
|
71
|
+
},
|
72
|
+
],
|
73
|
+
};
|
74
|
+
const strong = {
|
75
|
+
parseDOM: [
|
76
|
+
{ tag: 'strong' },
|
77
|
+
{
|
78
|
+
tag: 'b',
|
79
|
+
getAttrs: (node) => node.style.fontWeight != 'normal' && null,
|
46
80
|
},
|
47
|
-
|
81
|
+
],
|
82
|
+
toDOM: () => ['strong', 0],
|
83
|
+
};
|
84
|
+
exports.bigfootSchema = new prosemirror_model_1.Schema({
|
85
|
+
nodes: (0, prosemirror_schema_list_1.addListNodes)(prosemirror_schema_basic_1.schema.spec.nodes, 'paragraph block*', 'block')
|
86
|
+
.addToEnd('checklist', checklist)
|
87
|
+
.addToEnd('checklistItem', checklistItem),
|
88
|
+
//@ts-expect-error Not sure why this is throwing an error, but will revisit
|
89
|
+
marks: {
|
90
|
+
...prosemirror_schema_basic_1.schema.spec.marks,
|
91
|
+
tag,
|
92
|
+
strong,
|
93
|
+
},
|
48
94
|
});
|
package/editor.ts
CHANGED
@@ -1,49 +1,106 @@
|
|
1
|
-
import { Schema } from 'prosemirror-model';
|
1
|
+
import { MarkSpec, NodeSpec, 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
|
-
|
13
|
-
|
5
|
+
const tag: MarkSpec = {
|
6
|
+
attrs: {
|
7
|
+
tagId: { default: null },
|
8
|
+
tagType: { default: null },
|
9
|
+
recommendationId: { default: null },
|
10
|
+
ignore: { default: null },
|
11
|
+
},
|
12
|
+
inclusive: false,
|
13
|
+
parseDOM: [
|
14
|
+
{
|
15
|
+
tag: 'span[data-tag-id][data-tag-type][data-recommendation-id][data-ignore]',
|
16
|
+
getAttrs(dom: string | HTMLElement) {
|
17
|
+
return {
|
18
|
+
tagId: (dom as HTMLElement).getAttribute('data-tag-id'),
|
19
|
+
tagType: (dom as HTMLElement).getAttribute('data-tag-type'),
|
20
|
+
recommendationId: (dom as HTMLElement).getAttribute(
|
21
|
+
'data-recommendation-id'
|
22
|
+
),
|
23
|
+
ignore: (dom as HTMLElement).getAttribute('data-ignore'),
|
24
|
+
};
|
25
|
+
},
|
14
26
|
},
|
15
|
-
|
16
|
-
|
27
|
+
],
|
28
|
+
//@ts-expect-error Not sure why this is throwing an error, but will revisit
|
29
|
+
toDOM(node: {
|
30
|
+
attrs: {
|
31
|
+
tagId: string;
|
32
|
+
tagType: string;
|
33
|
+
recommendationId: string;
|
34
|
+
ignore: string;
|
35
|
+
};
|
36
|
+
}) {
|
37
|
+
const { tagId, tagType, recommendationId, ignore } = node.attrs;
|
38
|
+
return [
|
39
|
+
'span',
|
40
|
+
{
|
41
|
+
'data-tag-id': tagId,
|
42
|
+
'data-tag-type': tagType,
|
43
|
+
'data-recommendation-id': recommendationId,
|
44
|
+
'data-ignore': ignore,
|
45
|
+
},
|
46
|
+
0,
|
47
|
+
];
|
48
|
+
},
|
49
|
+
};
|
50
|
+
|
51
|
+
const checklist: NodeSpec = {
|
52
|
+
content: 'checklistItem+',
|
53
|
+
group: 'block',
|
54
|
+
toDOM: () => ['ul', 0],
|
55
|
+
parseDOM: [{ tag: 'ul.checklist' }],
|
56
|
+
};
|
57
|
+
|
58
|
+
const checklistItem: NodeSpec = {
|
59
|
+
content: 'text*',
|
60
|
+
attrs: { checked: { default: false } },
|
61
|
+
//@ts-expect-error Not sure why this is throwing an error, but will revisit
|
62
|
+
toDOM: (node: NodeSpec) => [
|
63
|
+
'li',
|
64
|
+
{ 'data-checked': node?.attrs?.checked ? 'true' : 'false' },
|
65
|
+
[
|
66
|
+
'input',
|
17
67
|
{
|
18
|
-
|
19
|
-
|
20
|
-
return {
|
21
|
-
tagId: (dom as HTMLElement).getAttribute('data-tag-id'),
|
22
|
-
tagType: (dom as HTMLElement).getAttribute(
|
23
|
-
'data-tag-type'
|
24
|
-
),
|
25
|
-
recommendationId: (dom as HTMLElement).getAttribute(
|
26
|
-
'data-recommendation-id'
|
27
|
-
),
|
28
|
-
ignore: (dom as HTMLElement).getAttribute(
|
29
|
-
'data-ignore'
|
30
|
-
),
|
31
|
-
};
|
32
|
-
},
|
68
|
+
type: 'checkbox',
|
69
|
+
checked: node?.attrs?.checked ? 'checked' : '',
|
33
70
|
},
|
34
71
|
],
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
72
|
+
['span', {}],
|
73
|
+
],
|
74
|
+
parseDOM: [
|
75
|
+
{
|
76
|
+
tag: 'li[data-checked]',
|
77
|
+
getAttrs: (dom: HTMLElement) => ({
|
78
|
+
checked: dom.getAttribute('data-checked') === 'true',
|
79
|
+
}),
|
80
|
+
},
|
81
|
+
],
|
82
|
+
};
|
83
|
+
|
84
|
+
const strong: MarkSpec = {
|
85
|
+
parseDOM: [
|
86
|
+
{ tag: 'strong' },
|
87
|
+
{
|
88
|
+
tag: 'b',
|
89
|
+
getAttrs: (node: HTMLElement) =>
|
90
|
+
node.style.fontWeight != 'normal' && null,
|
47
91
|
},
|
48
|
-
|
92
|
+
],
|
93
|
+
toDOM: () => ['strong', 0],
|
94
|
+
};
|
95
|
+
|
96
|
+
export const bigfootSchema = new Schema({
|
97
|
+
nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block')
|
98
|
+
.addToEnd('checklist', checklist)
|
99
|
+
.addToEnd('checklistItem', checklistItem),
|
100
|
+
//@ts-expect-error Not sure why this is throwing an error, but will revisit
|
101
|
+
marks: {
|
102
|
+
...schema.spec.marks,
|
103
|
+
tag,
|
104
|
+
strong,
|
105
|
+
},
|
49
106
|
});
|
package/model.js
CHANGED
@@ -509,11 +509,13 @@ type Article {${exports.PrimitiveFields}
|
|
509
509
|
recommendations: [TagRecommendation]
|
510
510
|
relations: [RelationEntry]
|
511
511
|
archived: Boolean!
|
512
|
+
favorite: Boolean!
|
512
513
|
}`;
|
513
514
|
class Article extends Primitive {
|
514
515
|
constructor(referenceBlock) {
|
515
516
|
super();
|
516
517
|
this.archived = false;
|
518
|
+
this.favorite = false;
|
517
519
|
this.referenceBlock = referenceBlock;
|
518
520
|
}
|
519
521
|
}
|
package/model.ts
CHANGED
@@ -759,6 +759,7 @@ type Article {${PrimitiveFields}
|
|
759
759
|
recommendations: [TagRecommendation]
|
760
760
|
relations: [RelationEntry]
|
761
761
|
archived: Boolean!
|
762
|
+
favorite: Boolean!
|
762
763
|
}`;
|
763
764
|
export class Article extends Primitive {
|
764
765
|
referenceBlock: ReferenceBlock;
|
@@ -772,6 +773,7 @@ export class Article extends Primitive {
|
|
772
773
|
recommendations?: TagRecommendation[];
|
773
774
|
relations?: RelationEntry[];
|
774
775
|
archived: boolean;
|
776
|
+
favorite: boolean;
|
775
777
|
_changes?: Changes;
|
776
778
|
_tasks?: Task[];
|
777
779
|
_entitiesPerson?: EntityEntry[];
|
@@ -783,6 +785,7 @@ export class Article extends Primitive {
|
|
783
785
|
super();
|
784
786
|
|
785
787
|
this.archived = false;
|
788
|
+
this.favorite = false;
|
786
789
|
|
787
790
|
this.referenceBlock = referenceBlock;
|
788
791
|
}
|