@bigfootai/bigfoot-types 3.7.8 → 3.7.10

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 (3) hide show
  1. package/editor.js +81 -36
  2. package/editor.ts +96 -40
  3. package/package.json +1 -1
package/editor.js CHANGED
@@ -1,48 +1,93 @@
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 orderedmap_1 = __importDefault(require("orderedmap"));
11
- exports.bigfootSchema = new prosemirror_model_1.Schema({
12
- nodes: (0, prosemirror_schema_list_1.addListNodes)(prosemirror_schema_basic_1.schema.spec.nodes, 'paragraph block*', 'block'),
13
- marks: orderedmap_1.default.from(prosemirror_schema_basic_1.schema.spec.marks).addToEnd('tag', {
14
- attrs: {
15
- tagId: { default: null },
16
- tagType: { default: null },
17
- recommendationId: { default: null },
18
- ignore: { default: null },
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
- inclusive: false,
21
- parseDOM: [
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
- tag: 'span[data-tag-id][data-tag-type][data-recommendation-id][data-ignore]',
24
- getAttrs(dom) {
25
- return {
26
- tagId: dom.getAttribute('data-tag-id'),
27
- tagType: dom.getAttribute('data-tag-type'),
28
- recommendationId: dom.getAttribute('data-recommendation-id'),
29
- ignore: dom.getAttribute('data-ignore'),
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
- toDOM(node) {
35
- const { tagId, tagType, recommendationId, ignore } = node.attrs;
36
- return [
37
- 'span',
38
- {
39
- 'data-tag-id': tagId,
40
- 'data-tag-type': tagType,
41
- 'data-recommendation-id': recommendationId,
42
- 'data-ignore': ignore,
43
- },
44
- 0,
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: orderedMap
90
+ .from(prosemirror_schema_basic_1.schema.spec.marks)
91
+ .addToEnd('tag', tag)
92
+ .addToEnd('strong', strong),
48
93
  });
package/editor.ts CHANGED
@@ -1,49 +1,105 @@
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
- export const bigfootSchema = new Schema({
7
- nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),
8
- marks: orderedMap.from(schema.spec.marks).addToEnd('tag', {
9
- attrs: {
10
- tagId: { default: null },
11
- tagType: { default: null },
12
- recommendationId: { default: null },
13
- ignore: { default: null },
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
- inclusive: false,
16
- parseDOM: [
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
- tag: 'span[data-tag-id][data-tag-type][data-recommendation-id][data-ignore]',
19
- getAttrs(dom) {
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
- toDOM(node) {
36
- const { tagId, tagType, recommendationId, ignore } = node.attrs;
37
- return [
38
- 'span',
39
- {
40
- 'data-tag-id': tagId,
41
- 'data-tag-type': tagType,
42
- 'data-recommendation-id': recommendationId,
43
- 'data-ignore': ignore,
44
- },
45
- 0,
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: orderedMap
102
+ .from(schema.spec.marks)
103
+ .addToEnd('tag', tag)
104
+ .addToEnd('strong', strong),
49
105
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Bigfoot",
3
3
  "name": "@bigfootai/bigfoot-types",
4
- "version": "3.7.8",
4
+ "version": "3.7.10",
5
5
  "description": "The internal library for the types used in the Bigfoot platform",
6
6
  "main": "model.js",
7
7
  "license": "ISC",