@zipify/wysiwyg 1.3.0-0 → 2.0.0-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.
- package/.eslintrc.js +1 -1
- package/config/build/lib.config.js +4 -2
- package/dist/cli.js +10 -2
- package/dist/wysiwyg.css +43 -48
- package/dist/wysiwyg.mjs +1928 -787
- package/example/ExampleApp.vue +3 -1
- package/lib/__tests__/utils/buildTestExtensions.js +14 -0
- package/lib/__tests__/utils/index.js +1 -0
- package/lib/components/base/Button.vue +0 -7
- package/lib/components/base/dropdown/Dropdown.vue +1 -7
- package/lib/components/base/dropdown/DropdownActivator.vue +4 -19
- package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +1 -23
- package/lib/components/toolbar/controls/AlignmentControl.vue +1 -11
- package/lib/components/toolbar/controls/FontColorControl.vue +0 -13
- package/lib/components/toolbar/controls/FontFamilyControl.vue +0 -4
- package/lib/components/toolbar/controls/FontSizeControl.vue +1 -6
- package/lib/components/toolbar/controls/FontWeightControl.vue +0 -12
- package/lib/components/toolbar/controls/ItalicControl.vue +0 -13
- package/lib/components/toolbar/controls/LineHeightControl.vue +0 -14
- package/lib/components/toolbar/controls/StylePresetControl.vue +1 -1
- package/lib/components/toolbar/controls/SuperscriptControl.vue +2 -2
- package/lib/components/toolbar/controls/UnderlineControl.vue +0 -12
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +5 -72
- package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +1 -22
- package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +0 -1
- package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +0 -1
- package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +0 -1
- package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +1 -23
- package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +1 -23
- package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +2 -2
- package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +2 -2
- package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +1 -25
- package/lib/composables/__tests__/useEditor.test.js +2 -2
- package/lib/enums/TextSettings.js +5 -5
- package/lib/extensions/BackgroundColor.js +4 -4
- package/lib/extensions/FontColor.js +4 -5
- package/lib/extensions/FontFamily.js +4 -5
- package/lib/extensions/FontSize.js +5 -7
- package/lib/extensions/FontStyle.js +13 -11
- package/lib/extensions/FontWeight.js +6 -9
- package/lib/extensions/Link.js +1 -1
- package/lib/extensions/StylePreset.js +1 -15
- package/lib/extensions/Superscript.js +23 -1
- package/lib/extensions/TextDecoration.js +16 -20
- package/lib/extensions/__tests__/Alignment.test.js +10 -7
- package/lib/extensions/__tests__/BackgroundColor.test.js +6 -3
- package/lib/extensions/__tests__/CaseStyle.test.js +11 -7
- package/lib/extensions/__tests__/FontColor.test.js +6 -3
- package/lib/extensions/__tests__/FontFamily.test.js +29 -22
- package/lib/extensions/__tests__/FontSize.test.js +24 -17
- package/lib/extensions/__tests__/FontStyle.test.js +22 -16
- package/lib/extensions/__tests__/FontWeight.test.js +28 -21
- package/lib/extensions/__tests__/LineHeight.test.js +14 -11
- package/lib/extensions/__tests__/Link.test.js +14 -10
- package/lib/extensions/__tests__/Margin.test.js +2 -2
- package/lib/extensions/__tests__/StylePreset.test.js +49 -100
- package/lib/extensions/__tests__/TextDecoration.test.js +59 -37
- package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +25 -25
- package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +25 -25
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +105 -105
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +72 -72
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +54 -46
- package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +77 -77
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +68 -3
- package/lib/extensions/core/Document.js +5 -0
- package/lib/extensions/core/Heading.js +10 -0
- package/lib/extensions/core/NodeProcessor.js +112 -10
- package/lib/extensions/core/Paragraph.js +9 -0
- package/lib/extensions/core/TextProcessor.js +9 -16
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +137 -10
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +2 -2
- package/lib/extensions/core/__tests__/TextProcessor.test.js +18 -41
- package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +192 -0
- package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +7 -27
- package/lib/extensions/core/index.js +5 -5
- package/lib/extensions/core/steps/AddNodeMarkStep.js +60 -0
- package/lib/extensions/core/steps/AttrStep.js +54 -0
- package/lib/extensions/core/steps/RemoveNodeMarkStep.js +50 -0
- package/lib/extensions/core/steps/index.js +3 -0
- package/lib/extensions/list/List.js +1 -0
- package/lib/extensions/list/ListItem.js +5 -0
- package/lib/extensions/list/__tests__/List.test.js +30 -25
- package/lib/services/NodeFactory.js +25 -21
- package/lib/services/index.js +1 -1
- package/lib/services/normalizer/BaseNormalizer.js +11 -0
- package/lib/services/{BrowserDomParser.js → normalizer/BrowserDomParser.js} +0 -0
- package/lib/services/normalizer/ContentNormalizer.js +24 -0
- package/lib/services/normalizer/HtmlNormalizer.js +245 -0
- package/lib/services/normalizer/JsonNormalizer.js +81 -0
- package/lib/services/{__tests__/ContentNormalizer.test.js → normalizer/__tests__/HtmlNormalizer.test.js} +27 -67
- package/lib/services/normalizer/__tests__/JsonNormalizer.test.js +70 -0
- package/lib/services/normalizer/__tests__/__snapshots__/JsonNormalizer.test.js.snap +159 -0
- package/lib/services/normalizer/index.js +1 -0
- package/lib/styles/content.css +8 -0
- package/lib/utils/findMarkByType.js +5 -0
- package/lib/utils/index.js +5 -0
- package/lib/utils/isMarkAppliedToParent.js +10 -0
- package/lib/utils/isNodeFullySelected.js +10 -0
- package/lib/utils/resolveNodePosition.js +6 -0
- package/lib/utils/resolveTextPosition.js +6 -0
- package/package.json +3 -1
- package/lib/assets/icons/indicator.svg +0 -5
- package/lib/services/ContentNormalizer.js +0 -293
|
@@ -1,42 +1,6 @@
|
|
|
1
1
|
import { ContentNormalizer } from '../ContentNormalizer';
|
|
2
|
-
import { NodeFactory } from '../NodeFactory';
|
|
3
2
|
|
|
4
3
|
describe('normalize text content', () => {
|
|
5
|
-
test('should ignore json content', () => {
|
|
6
|
-
const content = NodeFactory.doc([NodeFactory.paragraph('Test')]);
|
|
7
|
-
|
|
8
|
-
expect(ContentNormalizer.normalize(content)).toBe(content);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test('should flat structure', () => {
|
|
12
|
-
const input = '<p style="text-align: center; color: rgb(255, 255, 255);"><span style="background-color: rgb(255, 0, 0);">lore<span style="color: rgb(0, 0, 0);">m ip</span>sum</span></p>';
|
|
13
|
-
const output = '<p style="text-align: center;">' +
|
|
14
|
-
'<span style="background-color: rgb(255, 0, 0); color: rgb(255, 255, 255);">lore</span>' +
|
|
15
|
-
'<span style="color: rgb(0, 0, 0); background-color: rgb(255, 0, 0);">m ip</span>' +
|
|
16
|
-
'<span style="background-color: rgb(255, 0, 0); color: rgb(255, 255, 255);">sum</span>' +
|
|
17
|
-
'</p>';
|
|
18
|
-
|
|
19
|
-
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('should move styles from paragraph to text', () => {
|
|
23
|
-
const input = '<p style="background-color: red;">lorem ipsum</p>';
|
|
24
|
-
const output = '<p><span style="background-color: red;">lorem ipsum</span></p>';
|
|
25
|
-
|
|
26
|
-
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('should move styles from paragraph to unstyled text', () => {
|
|
30
|
-
const input = '<p style="background-color: red;"><span style="background-color: #000;">lorem</span> ipsum <span style="color: white;">one</span></p>';
|
|
31
|
-
const output = '<p>' +
|
|
32
|
-
'<span style="background-color: #000;">lorem</span>' +
|
|
33
|
-
'<span style="background-color: red;"> ipsum </span>' +
|
|
34
|
-
'<span style="color: white; background-color: red;">one</span' +
|
|
35
|
-
'></p>';
|
|
36
|
-
|
|
37
|
-
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
4
|
test('should wrap list content in paragraph', () => {
|
|
41
5
|
const input = '<ul><li style="line-height: 2;">lorem impsum</li></ul>';
|
|
42
6
|
const output = '<ul><li><p style="line-height: 2;">lorem impsum</p></li></ul>';
|
|
@@ -99,34 +63,6 @@ describe('normalize text content', () => {
|
|
|
99
63
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
100
64
|
});
|
|
101
65
|
|
|
102
|
-
test('should not ignore setting', () => {
|
|
103
|
-
const input = '<p style="text-decoration-line: underline;">lorem ipsum</p>';
|
|
104
|
-
const output = '<p><span style="text-decoration-line: underline;">lorem ipsum</span></p>';
|
|
105
|
-
|
|
106
|
-
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test('should not assign font-weight to b tag', () => {
|
|
110
|
-
const input = '<p style="font-weight: 400;"><b>lorem ipsum</b></p>';
|
|
111
|
-
const output = '<p><b>lorem ipsum</b></p>';
|
|
112
|
-
|
|
113
|
-
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
test('should not assign font-style to i tag', () => {
|
|
117
|
-
const input = '<p style="font-style: normal;"><i>lorem ipsum</i></p>';
|
|
118
|
-
const output = '<p><i>lorem ipsum</i></p>';
|
|
119
|
-
|
|
120
|
-
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
test('should not assign text-decoration to s tag', () => {
|
|
124
|
-
const input = '<p style="text-decoration-line: initial;"><s>lorem ipsum</s></p>';
|
|
125
|
-
const output = '<p><s>lorem ipsum</s></p>';
|
|
126
|
-
|
|
127
|
-
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
66
|
test('should assign block styles from list to paragraph', () => {
|
|
131
67
|
const input = '<ul style="line-height: 2;"><li>lorem ipsum</li></ul>';
|
|
132
68
|
const output = '<ul style="line-height: 2;"><li><p style="line-height: 2;">lorem ipsum</p></li></ul>';
|
|
@@ -165,9 +101,33 @@ describe('normalize text content', () => {
|
|
|
165
101
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
166
102
|
});
|
|
167
103
|
|
|
168
|
-
test('should
|
|
169
|
-
const input = '<p
|
|
170
|
-
const output = '<p
|
|
104
|
+
test('should ignore text decoration on text nodes', () => {
|
|
105
|
+
const input = '<p><span style="text-decoration: underline;">lorem ipsum</span></p>';
|
|
106
|
+
const output = '<p><span style="text-decoration: underline;">lorem ipsum</span></p>';
|
|
107
|
+
|
|
108
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
test('should ignore none text decoration', () => {
|
|
112
|
+
const input = '<p style="text-decoration: none;">lorem ipsum</p>';
|
|
113
|
+
const output = '<p>lorem ipsum</p>';
|
|
114
|
+
|
|
115
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('should move text decoration from block to text only nodes', () => {
|
|
119
|
+
const input = '<p style="text-decoration: underline;">lorem ipsum</p>';
|
|
120
|
+
const output = '<p><span style="text-decoration: underline;">lorem ipsum</span></p>';
|
|
121
|
+
|
|
122
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('should move text decoration from block to mixed content', () => {
|
|
126
|
+
const input = '<p style="text-decoration: underline;"><span style="text-decoration: line-through;">lorem</span> ipsum</p>';
|
|
127
|
+
const output = '<p>' +
|
|
128
|
+
'<span style="text-decoration: underline line-through;">lorem</span>' +
|
|
129
|
+
'<span style="text-decoration: underline;"> ipsum</span>' +
|
|
130
|
+
'</p>';
|
|
171
131
|
|
|
172
132
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
173
133
|
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { NodeFactory } from '../../NodeFactory';
|
|
2
|
+
import { ListTypes, TextSettings } from '../../../enums';
|
|
3
|
+
import { ContentNormalizer } from '../ContentNormalizer';
|
|
4
|
+
|
|
5
|
+
describe('normalize json content', () => {
|
|
6
|
+
test('should bubble mark from single text node to paragraph', () => {
|
|
7
|
+
const input = NodeFactory.doc([
|
|
8
|
+
NodeFactory.paragraph([
|
|
9
|
+
NodeFactory.text('lorem ipsum', [
|
|
10
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
|
|
11
|
+
])
|
|
12
|
+
])
|
|
13
|
+
]);
|
|
14
|
+
|
|
15
|
+
expect(ContentNormalizer.normalize(input)).toMatchSnapshot();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('should bubble mark from two text nodes to paragraph', () => {
|
|
19
|
+
const input = NodeFactory.doc([
|
|
20
|
+
NodeFactory.paragraph([
|
|
21
|
+
NodeFactory.text('lorem', [
|
|
22
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
|
|
23
|
+
]),
|
|
24
|
+
NodeFactory.text(' ipsum', [
|
|
25
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' }),
|
|
26
|
+
NodeFactory.mark(TextSettings.FONT_COLOR, { value: '#FF0000' })
|
|
27
|
+
])
|
|
28
|
+
])
|
|
29
|
+
]);
|
|
30
|
+
|
|
31
|
+
expect(ContentNormalizer.normalize(input)).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test('should bubble mark from text to list item', () => {
|
|
35
|
+
const input = NodeFactory.doc([
|
|
36
|
+
NodeFactory.list(ListTypes.DISC, [
|
|
37
|
+
NodeFactory.paragraph(null, [
|
|
38
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
|
|
39
|
+
], 'lorem ipsum')
|
|
40
|
+
])
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
expect(ContentNormalizer.normalize(input)).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('should bubble two marks', () => {
|
|
47
|
+
const input = NodeFactory.doc([
|
|
48
|
+
NodeFactory.paragraph([
|
|
49
|
+
NodeFactory.text('hello world', [
|
|
50
|
+
NodeFactory.mark(TextSettings.FONT_FAMILY, { value: 'Bungee' }),
|
|
51
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '800' })
|
|
52
|
+
])
|
|
53
|
+
])
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
expect(ContentNormalizer.normalize(input)).toMatchSnapshot();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('should not bubble inline marks', () => {
|
|
60
|
+
const input = NodeFactory.doc([
|
|
61
|
+
NodeFactory.paragraph([
|
|
62
|
+
NodeFactory.text('hello world', [
|
|
63
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, { underline: true })
|
|
64
|
+
])
|
|
65
|
+
])
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
expect(ContentNormalizer.normalize(input)).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`normalize json content should bubble mark from single text node to paragraph 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"content": Array [
|
|
6
|
+
Object {
|
|
7
|
+
"content": Array [
|
|
8
|
+
Object {
|
|
9
|
+
"text": "lorem ipsum",
|
|
10
|
+
"type": "text",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
"marks": Array [
|
|
14
|
+
Object {
|
|
15
|
+
"attrs": Object {
|
|
16
|
+
"value": "700",
|
|
17
|
+
},
|
|
18
|
+
"type": "font_weight",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
"type": "paragraph",
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
"type": "doc",
|
|
25
|
+
}
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
exports[`normalize json content should bubble mark from text to list item 1`] = `
|
|
29
|
+
Object {
|
|
30
|
+
"content": Array [
|
|
31
|
+
Object {
|
|
32
|
+
"attrs": Object {
|
|
33
|
+
"bullet": Object {
|
|
34
|
+
"type": "disc",
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
"content": Array [
|
|
38
|
+
Object {
|
|
39
|
+
"content": Array [
|
|
40
|
+
Object {
|
|
41
|
+
"content": Array [
|
|
42
|
+
Object {
|
|
43
|
+
"text": "lorem ipsum",
|
|
44
|
+
"type": "text",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
"type": "paragraph",
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
"marks": Array [
|
|
51
|
+
Object {
|
|
52
|
+
"attrs": Object {
|
|
53
|
+
"value": "700",
|
|
54
|
+
},
|
|
55
|
+
"type": "font_weight",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
"type": "listItem",
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
"type": "list",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
"type": "doc",
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
exports[`normalize json content should bubble mark from two text nodes to paragraph 1`] = `
|
|
69
|
+
Object {
|
|
70
|
+
"content": Array [
|
|
71
|
+
Object {
|
|
72
|
+
"content": Array [
|
|
73
|
+
Object {
|
|
74
|
+
"text": "lorem",
|
|
75
|
+
"type": "text",
|
|
76
|
+
},
|
|
77
|
+
Object {
|
|
78
|
+
"marks": Array [
|
|
79
|
+
Object {
|
|
80
|
+
"attrs": Object {
|
|
81
|
+
"value": "#FF0000",
|
|
82
|
+
},
|
|
83
|
+
"type": "font_color",
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
"text": " ipsum",
|
|
87
|
+
"type": "text",
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
"marks": Array [
|
|
91
|
+
Object {
|
|
92
|
+
"attrs": Object {
|
|
93
|
+
"value": "700",
|
|
94
|
+
},
|
|
95
|
+
"type": "font_weight",
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
"type": "paragraph",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
"type": "doc",
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
104
|
+
|
|
105
|
+
exports[`normalize json content should bubble two marks 1`] = `
|
|
106
|
+
Object {
|
|
107
|
+
"content": Array [
|
|
108
|
+
Object {
|
|
109
|
+
"content": Array [
|
|
110
|
+
Object {
|
|
111
|
+
"text": "hello world",
|
|
112
|
+
"type": "text",
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
"marks": Array [
|
|
116
|
+
Object {
|
|
117
|
+
"attrs": Object {
|
|
118
|
+
"value": "Bungee",
|
|
119
|
+
},
|
|
120
|
+
"type": "font_family",
|
|
121
|
+
},
|
|
122
|
+
Object {
|
|
123
|
+
"attrs": Object {
|
|
124
|
+
"value": "800",
|
|
125
|
+
},
|
|
126
|
+
"type": "font_weight",
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
"type": "paragraph",
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
"type": "doc",
|
|
133
|
+
}
|
|
134
|
+
`;
|
|
135
|
+
|
|
136
|
+
exports[`normalize json content should not bubble inline marks 1`] = `
|
|
137
|
+
Object {
|
|
138
|
+
"content": Array [
|
|
139
|
+
Object {
|
|
140
|
+
"content": Array [
|
|
141
|
+
Object {
|
|
142
|
+
"marks": Array [
|
|
143
|
+
Object {
|
|
144
|
+
"attrs": Object {
|
|
145
|
+
"underline": true,
|
|
146
|
+
},
|
|
147
|
+
"type": "text_decoration",
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
"text": "hello world",
|
|
151
|
+
"type": "text",
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
"type": "paragraph",
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
"type": "doc",
|
|
158
|
+
}
|
|
159
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ContentNormalizer } from './ContentNormalizer';
|
package/lib/styles/content.css
CHANGED
|
@@ -112,6 +112,14 @@ img.ProseMirror-separator {
|
|
|
112
112
|
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
.ProseMirror span {
|
|
116
|
+
display: block;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.ProseMirror :where(p, h1, h2, h3, h4) span {
|
|
120
|
+
display: initial;
|
|
121
|
+
}
|
|
122
|
+
|
|
115
123
|
@keyframes ProseMirror-cursor-blink {
|
|
116
124
|
|
|
117
125
|
to {
|
package/lib/utils/index.js
CHANGED
|
@@ -8,3 +8,8 @@ export { convertFontSize } from './convertFontSize';
|
|
|
8
8
|
export { convertAlignment } from './convertAlignment';
|
|
9
9
|
export { importIcon } from './importIcon';
|
|
10
10
|
export { isWysiwygContent, markWysiwygContent, unmarkWysiwygContent } from './isWysiwygContent';
|
|
11
|
+
export { resolveNodePosition } from './resolveNodePosition';
|
|
12
|
+
export { resolveTextPosition } from './resolveTextPosition';
|
|
13
|
+
export { isNodeFullySelected } from './isNodeFullySelected';
|
|
14
|
+
export { isMarkAppliedToParent } from './isMarkAppliedToParent';
|
|
15
|
+
export { findMarkByType } from './findMarkByType';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function isMarkAppliedToParent({ doc }, position, checkingMark) {
|
|
2
|
+
const steps = doc.resolve(position).path.reverse();
|
|
3
|
+
|
|
4
|
+
for (const step of steps) {
|
|
5
|
+
if (typeof step === 'number') continue;
|
|
6
|
+
if (checkingMark.isInSet(step.marks)) return true;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { resolveNodePosition } from './resolveNodePosition';
|
|
2
|
+
|
|
3
|
+
export function isNodeFullySelected($from, $to, node, position) {
|
|
4
|
+
const fromPosition = resolveNodePosition($from, node, -1);
|
|
5
|
+
const toPosition = resolveNodePosition($to, node, 1);
|
|
6
|
+
const isFromMatch = fromPosition <= position;
|
|
7
|
+
const isToMatch = toPosition >= node.nodeSize + position;
|
|
8
|
+
|
|
9
|
+
return isFromMatch && isToMatch;
|
|
10
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zipify/wysiwyg",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-1",
|
|
4
4
|
"description": "Zipify modification of TipTap text editor",
|
|
5
5
|
"main": "dist/wysiwyg.mjs",
|
|
6
6
|
"bin": {
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@tiptap/vue-2": "^2.0.0-beta.85",
|
|
46
46
|
"commander": "^9.4.0",
|
|
47
47
|
"jsdom": "^20.0.0",
|
|
48
|
+
"lodash": "^4.17.21",
|
|
48
49
|
"simplebar": "^5.3.8"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
@@ -57,6 +58,7 @@
|
|
|
57
58
|
"@babel/plugin-transform-runtime": "^7.18.10",
|
|
58
59
|
"@babel/preset-env": "^7.19.0",
|
|
59
60
|
"@babel/runtime": "^7.19.0",
|
|
61
|
+
"@optimize-lodash/rollup-plugin": "^3.0.0",
|
|
60
62
|
"@rollup/plugin-babel": "^5.3.1",
|
|
61
63
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
62
64
|
"@rollup/plugin-node-resolve": "^14.0.0",
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
<svg width="9" height="9" viewBox="0 0 9 9" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M0 4.5C0 2.01472 2.01472 0 4.5 0C6.98528 0 9 2.01472 9 4.5C9 6.98528 6.98528 9 4.5 9C2.01472 9 0 6.98528 0 4.5Z" fill="#FFAB00"/>
|
|
3
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.0625 2.25H3.9375V5.625H5.0625V2.25Z" fill="white"/>
|
|
4
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.9375 6.75C3.9375 6.43894 4.18894 6.1875 4.5 6.1875C4.8105 6.1875 5.0625 6.43894 5.0625 6.75C5.0625 7.06106 4.8105 7.3125 4.5 7.3125C4.18894 7.3125 3.9375 7.06106 3.9375 6.75Z" fill="white"/>
|
|
5
|
-
</svg>
|