@zipify/wysiwyg 1.0.0-dev.2 → 1.0.0-dev.22
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/.eslintignore +1 -0
- package/.github/dependabot.yaml +1 -0
- package/.release-it.json +3 -1
- package/.stylelintignore +1 -0
- package/README.md +3 -1
- package/config/jest/setupTests.js +7 -1
- package/config/webpack/example.config.js +2 -0
- package/config/webpack/lib.config.js +44 -0
- package/config/webpack/loaders/style-loader.js +3 -1
- package/config/webpack/loaders/svg-loader.js +1 -1
- package/dist/wysiwyg.css +1226 -0
- package/dist/wysiwyg.js +7024 -0
- package/example/ExampleApp.vue +51 -32
- package/example/example.js +26 -0
- package/example/pageBlocks.js +31 -0
- package/example/presets.js +4 -2
- package/lib/Wysiwyg.vue +41 -21
- package/lib/assets/icons/alignment-center.svg +3 -0
- package/lib/assets/icons/alignment-justify.svg +3 -0
- package/lib/assets/icons/alignment-left.svg +3 -0
- package/lib/assets/icons/alignment-right.svg +3 -0
- package/lib/assets/icons/arrow.svg +3 -0
- package/lib/assets/icons/background-color.svg +3 -0
- package/lib/assets/icons/case-style.svg +3 -0
- package/lib/assets/icons/font-color.svg +5 -0
- package/lib/assets/icons/italic.svg +3 -0
- package/lib/assets/icons/line-height.svg +3 -0
- package/lib/assets/icons/link.svg +3 -0
- package/lib/assets/icons/list-circle.svg +3 -0
- package/lib/assets/icons/list-decimal.svg +3 -0
- package/lib/assets/icons/list-disc.svg +3 -0
- package/lib/assets/icons/list-latin.svg +3 -0
- package/lib/assets/icons/list-roman.svg +3 -0
- package/lib/assets/icons/list-square.svg +3 -0
- package/lib/assets/icons/remove-format.svg +3 -0
- package/lib/assets/icons/reset-styles.svg +3 -0
- package/lib/assets/icons/strike-through.svg +3 -0
- package/lib/assets/icons/superscript.svg +3 -0
- package/lib/assets/icons/underline.svg +3 -0
- package/lib/assets/icons/unlink.svg +3 -0
- package/lib/components/base/Button.vue +21 -1
- package/lib/components/base/Checkbox.vue +89 -0
- package/lib/components/base/FieldLabel.vue +2 -1
- package/lib/components/base/Icon.vue +18 -10
- package/lib/components/base/Modal.vue +0 -1
- package/lib/components/base/TextField.vue +106 -0
- package/lib/components/base/__tests__/Icon.test.js +6 -13
- package/lib/components/base/__tests__/TextField.test.js +57 -0
- package/lib/components/base/__tests__/__snapshots__/TextField.test.js.snap +9 -0
- package/lib/components/base/colorPicker/composables/usePickerHotkeys.js +2 -1
- package/lib/components/base/composables/index.js +1 -0
- package/lib/components/base/composables/useValidator.js +19 -0
- package/lib/components/base/dropdown/Dropdown.vue +15 -3
- package/lib/components/base/dropdown/DropdownActivator.vue +19 -3
- package/lib/components/base/index.js +3 -1
- package/lib/components/toolbar/Toolbar.vue +49 -9
- package/lib/components/toolbar/ToolbarFull.vue +10 -2
- package/lib/components/toolbar/__tests__/Toolbar.test.js +6 -0
- package/lib/components/toolbar/controls/FontSizeControl.vue +7 -0
- package/lib/components/toolbar/controls/ListControl.vue +1 -5
- package/lib/components/toolbar/controls/UnderlineControl.vue +2 -2
- package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +4 -0
- package/lib/components/toolbar/controls/index.js +1 -0
- package/lib/components/toolbar/controls/link/LinkControl.vue +152 -0
- package/lib/components/toolbar/controls/link/LinkControlApply.vue +35 -0
- package/lib/components/toolbar/controls/link/LinkControlHeader.vue +67 -0
- package/lib/components/toolbar/controls/link/composables/index.js +1 -0
- package/lib/components/toolbar/controls/link/composables/useLink.js +61 -0
- package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +103 -0
- package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +54 -0
- package/lib/components/toolbar/controls/link/destination/LinkControlUrl.vue +52 -0
- package/lib/components/toolbar/controls/link/destination/index.js +1 -0
- package/lib/components/toolbar/controls/link/index.js +1 -0
- package/lib/composables/__tests__/useEditor.test.js +14 -5
- package/lib/composables/useEditor.js +13 -8
- package/lib/composables/useToolbar.js +14 -29
- package/lib/directives/outClick.js +20 -4
- package/lib/enums/LinkDestinations.js +4 -0
- package/lib/enums/LinkTargets.js +4 -0
- package/lib/enums/TextSettings.js +3 -1
- package/lib/enums/index.js +2 -0
- package/lib/extensions/Alignment.js +21 -3
- package/lib/extensions/BackgroundColor.js +16 -1
- package/lib/extensions/FontColor.js +16 -1
- package/lib/extensions/FontFamily.js +26 -2
- package/lib/extensions/FontSize.js +28 -3
- package/lib/extensions/FontStyle.js +23 -2
- package/lib/extensions/FontWeight.js +33 -1
- package/lib/extensions/LineHeight.js +29 -3
- package/lib/extensions/Link.js +101 -0
- package/lib/extensions/StylePreset.js +36 -6
- package/lib/extensions/TextDecoration.js +29 -3
- package/lib/extensions/__tests__/Alignment.test.js +30 -3
- package/lib/extensions/__tests__/BackgroundColor.test.js +38 -3
- package/lib/extensions/__tests__/CaseStyle.test.js +4 -3
- package/lib/extensions/__tests__/FontColor.test.js +38 -3
- package/lib/extensions/__tests__/FontFamily.test.js +59 -5
- package/lib/extensions/__tests__/FontSize.test.js +38 -3
- package/lib/extensions/__tests__/FontStyle.test.js +46 -3
- package/lib/extensions/__tests__/FontWeight.test.js +66 -3
- package/lib/extensions/__tests__/LineHeight.test.js +49 -3
- package/lib/extensions/__tests__/StylePreset.test.js +143 -4
- package/lib/extensions/__tests__/TextDecoration.test.js +87 -3
- package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +70 -2
- package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +121 -1
- package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +109 -1
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +179 -1
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +132 -2
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +142 -1
- package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +179 -1
- package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +118 -2
- package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +171 -2
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +300 -3
- package/lib/extensions/core/CopyPasteProcessor.js +10 -0
- package/lib/extensions/core/TextProcessor.js +10 -0
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +4 -3
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +9 -6
- package/lib/extensions/core/__tests__/TextProcessor.test.js +139 -10
- package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +26 -0
- package/lib/extensions/core/index.js +11 -2
- package/lib/extensions/core/plugins/PastePlugin.js +48 -0
- package/lib/extensions/core/plugins/ProseMirrorPlugin.js +20 -0
- package/lib/extensions/core/plugins/index.js +1 -0
- package/lib/extensions/index.js +41 -33
- package/lib/extensions/list/List.js +34 -0
- package/lib/extensions/list/__tests__/List.test.js +115 -5
- package/lib/extensions/list/__tests__/__snapshots__/List.test.js.snap +481 -0
- package/lib/injectionTokens.js +2 -1
- package/lib/services/ContentNormalizer.js +157 -0
- package/lib/services/ContextWidnow.js +23 -0
- package/lib/services/Storage.js +1 -13
- package/lib/services/__tests__/ContentNormalizer.test.js +74 -0
- package/lib/services/__tests__/FavoriteColors.test.js +20 -0
- package/lib/services/__tests__/JsonSerializer.test.js +23 -0
- package/lib/services/__tests__/Storage.test.js +79 -0
- package/lib/services/index.js +2 -0
- package/lib/styles/content.css +96 -9
- package/lib/styles/helpers/offsets.css +16 -0
- package/lib/styles/variables.css +6 -0
- package/lib/utils/__tests__/__snapshots__/renderInlineSetting.test.js.snap +4 -4
- package/lib/utils/__tests__/convertColor.test.js +19 -0
- package/lib/utils/__tests__/createKeyboardShortcut.test.js +25 -0
- package/lib/utils/__tests__/renderInlineSetting.test.js +26 -0
- package/lib/utils/convertColor.js +7 -0
- package/lib/utils/importIcon.js +12 -0
- package/lib/utils/index.js +2 -0
- package/lib/utils/renderInlineSetting.js +2 -2
- package/package.json +18 -14
- package/lib/assets/icons.svg +0 -69
- package/lib/composables/__tests__/useToolbar.test.js +0 -56
|
@@ -2,10 +2,11 @@ import { Editor, Extension } from '@tiptap/vue-2';
|
|
|
2
2
|
import { ref } from '@vue/composition-api';
|
|
3
3
|
import { NodeFactory } from '../../__tests__/utils';
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
6
5
|
import { Alignment } from '../Alignment';
|
|
7
6
|
import { DeviceManager } from '../DeviceManager';
|
|
8
7
|
import { Alignments } from '../../enums';
|
|
8
|
+
import { ContentNormalizer } from '../../services';
|
|
9
|
+
import { buildCoreExtensions } from '../core';
|
|
9
10
|
|
|
10
11
|
const MockStylePreset = Extension.create({
|
|
11
12
|
name: 'style_preset',
|
|
@@ -23,8 +24,8 @@ const MockStylePreset = Extension.create({
|
|
|
23
24
|
|
|
24
25
|
function createEditor({ content }) {
|
|
25
26
|
return new Editor({
|
|
26
|
-
content,
|
|
27
|
-
extensions:
|
|
27
|
+
content: ContentNormalizer.normalize(content),
|
|
28
|
+
extensions: buildCoreExtensions().concat(
|
|
28
29
|
MockStylePreset,
|
|
29
30
|
DeviceManager.configure({ deviceRef: ref('desktop') }),
|
|
30
31
|
Alignment
|
|
@@ -105,3 +106,29 @@ describe('rendering', () => {
|
|
|
105
106
|
expect(editor.getHTML()).toMatchSnapshot();
|
|
106
107
|
});
|
|
107
108
|
});
|
|
109
|
+
|
|
110
|
+
describe('parsing html', () => {
|
|
111
|
+
test('should get alignment from text', () => {
|
|
112
|
+
const editor = createEditor({
|
|
113
|
+
content: '<p style="text-align:center">test</p>'
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('should get alignment from rendered view', () => {
|
|
120
|
+
const editor = createEditor({
|
|
121
|
+
content: '<p style="--zw-text-align-mobile:center;--zw-text-align-desktop:right">test</p>'
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('should set null if no alignment', () => {
|
|
128
|
+
const editor = createEditor({
|
|
129
|
+
content: '<p>test</p>'
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
@@ -2,8 +2,9 @@ import { Editor, Extension } from '@tiptap/vue-2';
|
|
|
2
2
|
import { ref } from '@vue/composition-api';
|
|
3
3
|
import { NodeFactory } from '../../__tests__/utils';
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
6
5
|
import { BackgroundColor } from '../BackgroundColor';
|
|
6
|
+
import { ContentNormalizer } from '../../services';
|
|
7
|
+
import { buildCoreExtensions } from '../core';
|
|
7
8
|
|
|
8
9
|
const MockStylePreset = Extension.create({
|
|
9
10
|
name: 'style_preset',
|
|
@@ -19,8 +20,8 @@ const MockStylePreset = Extension.create({
|
|
|
19
20
|
|
|
20
21
|
function createEditor({ content }) {
|
|
21
22
|
return new Editor({
|
|
22
|
-
content,
|
|
23
|
-
extensions:
|
|
23
|
+
content: ContentNormalizer.normalize(content),
|
|
24
|
+
extensions: buildCoreExtensions().concat(MockStylePreset, BackgroundColor)
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -73,3 +74,37 @@ describe('rendering', () => {
|
|
|
73
74
|
expect(editor.getHTML()).toMatchSnapshot();
|
|
74
75
|
});
|
|
75
76
|
});
|
|
77
|
+
|
|
78
|
+
describe('parsing html', () => {
|
|
79
|
+
test('should get value from paragraph', () => {
|
|
80
|
+
const editor = createEditor({
|
|
81
|
+
content: '<p style="background-color: red">test</p>'
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('should get value from text', () => {
|
|
88
|
+
const editor = createEditor({
|
|
89
|
+
content: '<p><span style="background-color: red">lorem</span> ipsum</p>'
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test('should get value from rendered view', () => {
|
|
96
|
+
const editor = createEditor({
|
|
97
|
+
content: '<p><span style="--zw-background-color: red">lorem</span> ipsum</p>'
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
test('should merge paragraph and text settings', () => {
|
|
104
|
+
const editor = createEditor({
|
|
105
|
+
content: '<p style="background-color: red"><span style="background-color: #000">lorem</span> ipsum</p>'
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { Editor } from '@tiptap/vue-2';
|
|
2
2
|
import { NodeFactory } from '../../__tests__/utils';
|
|
3
3
|
import { CaseStyles } from '../../enums';
|
|
4
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
5
4
|
import { CaseStyle } from '../CaseStyle';
|
|
5
|
+
import { ContentNormalizer } from '../../services';
|
|
6
|
+
import { buildCoreExtensions } from '../core';
|
|
6
7
|
|
|
7
8
|
function createEditor({ content }) {
|
|
8
9
|
return new Editor({
|
|
9
|
-
content,
|
|
10
|
-
extensions:
|
|
10
|
+
content: ContentNormalizer.normalize(content),
|
|
11
|
+
extensions: buildCoreExtensions().concat(CaseStyle)
|
|
11
12
|
});
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -2,8 +2,9 @@ import { Editor, Extension } from '@tiptap/vue-2';
|
|
|
2
2
|
import { ref } from '@vue/composition-api';
|
|
3
3
|
import { NodeFactory } from '../../__tests__/utils';
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
6
5
|
import { FontColor } from '../FontColor';
|
|
6
|
+
import { ContentNormalizer } from '../../services';
|
|
7
|
+
import { buildCoreExtensions } from '../core';
|
|
7
8
|
|
|
8
9
|
const MockStylePreset = Extension.create({
|
|
9
10
|
name: 'style_preset',
|
|
@@ -19,8 +20,8 @@ const MockStylePreset = Extension.create({
|
|
|
19
20
|
|
|
20
21
|
function createEditor({ content }) {
|
|
21
22
|
return new Editor({
|
|
22
|
-
content,
|
|
23
|
-
extensions:
|
|
23
|
+
content: ContentNormalizer.normalize(content),
|
|
24
|
+
extensions: buildCoreExtensions().concat(MockStylePreset, FontColor)
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
|
|
@@ -83,3 +84,37 @@ describe('rendering', () => {
|
|
|
83
84
|
expect(editor.getHTML()).toMatchSnapshot();
|
|
84
85
|
});
|
|
85
86
|
});
|
|
87
|
+
|
|
88
|
+
describe('parsing html', () => {
|
|
89
|
+
test('should get value from paragraph', () => {
|
|
90
|
+
const editor = createEditor({
|
|
91
|
+
content: '<p style="color: red">test</p>'
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('should get value from text', () => {
|
|
98
|
+
const editor = createEditor({
|
|
99
|
+
content: '<p><span style="color: red">lorem</span> ipsum</p>'
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('should get value from parsed view', () => {
|
|
106
|
+
const editor = createEditor({
|
|
107
|
+
content: '<p><span style="--zw-color: red">lorem</span> ipsum</p>'
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('should merge paragraph and text settings', () => {
|
|
114
|
+
const editor = createEditor({
|
|
115
|
+
content: '<p style="color: red"><span style="color: #000">lorem</span> ipsum</p>'
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -2,11 +2,12 @@ import { Editor, Extension } from '@tiptap/vue-2';
|
|
|
2
2
|
import { ref } from '@vue/composition-api';
|
|
3
3
|
import { NodeFactory } from '../../__tests__/utils';
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
6
5
|
import { Font } from '../../models';
|
|
7
6
|
import { FontFamily } from '../FontFamily';
|
|
8
7
|
import { FontWeight } from '../FontWeight';
|
|
9
8
|
import { FontStyle } from '../FontStyle';
|
|
9
|
+
import { ContentNormalizer } from '../../services';
|
|
10
|
+
import { buildCoreExtensions } from '../core';
|
|
10
11
|
|
|
11
12
|
const MockStylePreset = Extension.create({
|
|
12
13
|
name: 'style_preset',
|
|
@@ -25,14 +26,17 @@ const MockStylePreset = Extension.create({
|
|
|
25
26
|
|
|
26
27
|
function createEditor({ content }) {
|
|
27
28
|
return new Editor({
|
|
28
|
-
content,
|
|
29
|
-
extensions:
|
|
29
|
+
content: ContentNormalizer.normalize(content),
|
|
30
|
+
extensions: buildCoreExtensions().concat(
|
|
30
31
|
MockStylePreset,
|
|
31
32
|
FontFamily.configure({
|
|
32
33
|
fonts: [
|
|
33
34
|
new Font({ name: 'Lato', styles: ['400', '700', '700i'] }),
|
|
34
|
-
new Font({ name: 'Bungee', styles: ['400'] })
|
|
35
|
-
|
|
35
|
+
new Font({ name: 'Bungee', styles: ['400'] }),
|
|
36
|
+
new Font({ name: 'Roboto', styles: ['400'] }),
|
|
37
|
+
new Font({ name: 'Josefin Slab', styles: ['400'] })
|
|
38
|
+
],
|
|
39
|
+
defaultFont: 'Lato'
|
|
36
40
|
}),
|
|
37
41
|
FontWeight,
|
|
38
42
|
FontStyle
|
|
@@ -169,3 +173,53 @@ describe('rendering', () => {
|
|
|
169
173
|
expect(editor.getHTML()).toMatchSnapshot();
|
|
170
174
|
});
|
|
171
175
|
});
|
|
176
|
+
|
|
177
|
+
describe('parsing html', () => {
|
|
178
|
+
test('should get value from paragraph', () => {
|
|
179
|
+
const editor = createEditor({
|
|
180
|
+
content: '<p style="font-family: Lato">test</p>'
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test('should get value from text', () => {
|
|
187
|
+
const editor = createEditor({
|
|
188
|
+
content: '<p><span style="font-family: Lato">lorem</span> ipsum</p>'
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test('should get value from rendered view', () => {
|
|
195
|
+
const editor = createEditor({
|
|
196
|
+
content: '<p><span style="--zw-font-family: Lato">lorem</span> ipsum</p>'
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
test('should get set default if undefined font', () => {
|
|
203
|
+
const editor = createEditor({
|
|
204
|
+
content: '<p><span style="--zw-font-family: Arial">lorem</span> ipsum</p>'
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
test('should merge paragraph and text settings', () => {
|
|
211
|
+
const editor = createEditor({
|
|
212
|
+
content: '<p style="font-family: Lato"><span style="font-family: Roboto">lorem</span> ipsum</p>'
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
test('should get parse font name with quotes', () => {
|
|
219
|
+
const editor = createEditor({
|
|
220
|
+
content: '<p>hello <span style="font-family: "Josefin Slab";">world</span></p>'
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
224
|
+
});
|
|
225
|
+
});
|
|
@@ -2,9 +2,10 @@ import { Editor, Extension } from '@tiptap/vue-2';
|
|
|
2
2
|
import { ref } from '@vue/composition-api';
|
|
3
3
|
import { NodeFactory } from '../../__tests__/utils';
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
6
5
|
import { FontSize } from '../FontSize';
|
|
7
6
|
import { DeviceManager } from '../DeviceManager';
|
|
7
|
+
import { ContentNormalizer } from '../../services';
|
|
8
|
+
import { buildCoreExtensions } from '../core';
|
|
8
9
|
|
|
9
10
|
const MockStylePreset = Extension.create({
|
|
10
11
|
name: 'style_preset',
|
|
@@ -22,8 +23,8 @@ const MockStylePreset = Extension.create({
|
|
|
22
23
|
|
|
23
24
|
function createEditor({ content }) {
|
|
24
25
|
return new Editor({
|
|
25
|
-
content,
|
|
26
|
-
extensions:
|
|
26
|
+
content: ContentNormalizer.normalize(content),
|
|
27
|
+
extensions: buildCoreExtensions().concat(
|
|
27
28
|
MockStylePreset,
|
|
28
29
|
DeviceManager.configure({
|
|
29
30
|
deviceRef: ref('desktop')
|
|
@@ -181,3 +182,37 @@ describe('rendering', () => {
|
|
|
181
182
|
expect(editor.getHTML()).toMatchSnapshot();
|
|
182
183
|
});
|
|
183
184
|
});
|
|
185
|
+
|
|
186
|
+
describe('parsing html', () => {
|
|
187
|
+
test('should get value from paragraph', () => {
|
|
188
|
+
const editor = createEditor({
|
|
189
|
+
content: '<p style="font-size: 24px">test</p>'
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test('should get value from text', () => {
|
|
196
|
+
const editor = createEditor({
|
|
197
|
+
content: '<p><span style="font-size: 24px">lorem</span> ipsum</p>'
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
test('should get value from rendered view', () => {
|
|
204
|
+
const editor = createEditor({
|
|
205
|
+
content: '<p><span style="--zw-font-size-mobile: 24px; --zw-font-size-desktop:30px">lorem</span> ipsum</p>'
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
test('should merge paragraph and text settings', () => {
|
|
212
|
+
const editor = createEditor({
|
|
213
|
+
content: '<p style="font-size: 24px"><span style="font-size: 20px">lorem</span> ipsum</p>'
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
217
|
+
});
|
|
218
|
+
});
|
|
@@ -2,11 +2,12 @@ import { Editor, Extension } from '@tiptap/vue-2';
|
|
|
2
2
|
import { ref } from '@vue/composition-api';
|
|
3
3
|
import { NodeFactory } from '../../__tests__/utils';
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
6
5
|
import { FontStyle } from '../FontStyle';
|
|
7
6
|
import { FontFamily } from '../FontFamily';
|
|
8
7
|
import { Font } from '../../models';
|
|
9
8
|
import { FontWeight } from '../FontWeight';
|
|
9
|
+
import { ContentNormalizer } from '../../services';
|
|
10
|
+
import { buildCoreExtensions } from '../core';
|
|
10
11
|
|
|
11
12
|
const MockStylePreset = Extension.create({
|
|
12
13
|
name: 'style_preset',
|
|
@@ -26,8 +27,8 @@ const MockStylePreset = Extension.create({
|
|
|
26
27
|
|
|
27
28
|
function createEditor({ content }) {
|
|
28
29
|
return new Editor({
|
|
29
|
-
content,
|
|
30
|
-
extensions:
|
|
30
|
+
content: ContentNormalizer.normalize(content),
|
|
31
|
+
extensions: buildCoreExtensions().concat(
|
|
31
32
|
MockStylePreset,
|
|
32
33
|
FontStyle,
|
|
33
34
|
FontWeight,
|
|
@@ -134,3 +135,45 @@ describe('rendering', () => {
|
|
|
134
135
|
expect(editor.getHTML()).toMatchSnapshot();
|
|
135
136
|
});
|
|
136
137
|
});
|
|
138
|
+
|
|
139
|
+
describe('parsing html', () => {
|
|
140
|
+
test('should get value from paragraph', () => {
|
|
141
|
+
const editor = createEditor({
|
|
142
|
+
content: '<p style="font-style: italic">test</p>'
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
test('should get value from text', () => {
|
|
149
|
+
const editor = createEditor({
|
|
150
|
+
content: '<p><span style="font-style: italic">lorem</span> ipsum</p>'
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('should get value from rendered view', () => {
|
|
157
|
+
const editor = createEditor({
|
|
158
|
+
content: '<p><span style="--zw-font-style: italic">lorem</span> ipsum</p>'
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('should get value from i tag', () => {
|
|
165
|
+
const editor = createEditor({
|
|
166
|
+
content: '<p><i>lorem</i> ipsum</p>'
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test('should merge paragraph and text settings', () => {
|
|
173
|
+
const editor = createEditor({
|
|
174
|
+
content: '<p style="font-style: italic"><span style="font-style: normal">lorem</span> ipsum</p>'
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -2,11 +2,12 @@ import { Editor, Extension } from '@tiptap/vue-2';
|
|
|
2
2
|
import { ref } from '@vue/composition-api';
|
|
3
3
|
import { NodeFactory } from '../../__tests__/utils';
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
6
5
|
import { Font } from '../../models';
|
|
7
6
|
import { FontWeight } from '../FontWeight';
|
|
8
7
|
import { FontFamily } from '../FontFamily';
|
|
9
8
|
import { FontStyle } from '../FontStyle';
|
|
9
|
+
import { ContentNormalizer } from '../../services';
|
|
10
|
+
import { buildCoreExtensions } from '../core';
|
|
10
11
|
|
|
11
12
|
const MockStylePreset = Extension.create({
|
|
12
13
|
name: 'style_preset',
|
|
@@ -25,8 +26,8 @@ const MockStylePreset = Extension.create({
|
|
|
25
26
|
|
|
26
27
|
function createEditor({ content }) {
|
|
27
28
|
return new Editor({
|
|
28
|
-
content,
|
|
29
|
-
extensions:
|
|
29
|
+
content: ContentNormalizer.normalize(content),
|
|
30
|
+
extensions: buildCoreExtensions().concat(
|
|
30
31
|
MockStylePreset,
|
|
31
32
|
FontFamily.configure({
|
|
32
33
|
fonts: [
|
|
@@ -74,6 +75,18 @@ describe('get font weight', () => {
|
|
|
74
75
|
|
|
75
76
|
expect(editor.commands.getFontWeight().value).toEqual('400');
|
|
76
77
|
});
|
|
78
|
+
|
|
79
|
+
test('should get closest available font weight', () => {
|
|
80
|
+
const editor = createEditor({
|
|
81
|
+
content: createContent(NodeFactory.text('hello world', [
|
|
82
|
+
NodeFactory.mark('font_weight', { value: '800' })
|
|
83
|
+
]))
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
editor.commands.selectAll();
|
|
87
|
+
|
|
88
|
+
expect(editor.commands.getFontWeight().value).toEqual('700');
|
|
89
|
+
});
|
|
77
90
|
});
|
|
78
91
|
|
|
79
92
|
describe('apply font weight', () => {
|
|
@@ -149,3 +162,53 @@ describe('rendering', () => {
|
|
|
149
162
|
expect(editor.getHTML()).toMatchSnapshot();
|
|
150
163
|
});
|
|
151
164
|
});
|
|
165
|
+
|
|
166
|
+
describe('parsing html', () => {
|
|
167
|
+
test('should get value from paragraph', () => {
|
|
168
|
+
const editor = createEditor({
|
|
169
|
+
content: '<p style="font-weight: 700">test</p>'
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test('should get value from text', () => {
|
|
176
|
+
const editor = createEditor({
|
|
177
|
+
content: '<p><span style="font-weight: 700">lorem</span> ipsum</p>'
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
test('should get value from rendered view', () => {
|
|
184
|
+
const editor = createEditor({
|
|
185
|
+
content: '<p><span style="--zw-font-weight: 700">lorem</span> ipsum</p>'
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
test('should get value from b tag', () => {
|
|
192
|
+
const editor = createEditor({
|
|
193
|
+
content: '<p><b>lorem</b> ipsum</p>'
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
test('should get value from strong tag', () => {
|
|
200
|
+
const editor = createEditor({
|
|
201
|
+
content: '<p><strong>lorem</strong> ipsum</p>'
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test('should merge paragraph and text settings', () => {
|
|
208
|
+
const editor = createEditor({
|
|
209
|
+
content: '<p style="font-weight: 500"><span style="font-weight: 700">lorem</span> ipsum</p>'
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
213
|
+
});
|
|
214
|
+
});
|
|
@@ -2,9 +2,10 @@ import { Editor, Extension } from '@tiptap/vue-2';
|
|
|
2
2
|
import { ref } from '@vue/composition-api';
|
|
3
3
|
import { NodeFactory } from '../../__tests__/utils';
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
6
5
|
import { DeviceManager } from '../DeviceManager';
|
|
7
6
|
import { LineHeight } from '../LineHeight';
|
|
7
|
+
import { ContentNormalizer } from '../../services';
|
|
8
|
+
import { buildCoreExtensions } from '../core';
|
|
8
9
|
|
|
9
10
|
const MockStylePreset = Extension.create({
|
|
10
11
|
name: 'style_preset',
|
|
@@ -22,8 +23,8 @@ const MockStylePreset = Extension.create({
|
|
|
22
23
|
|
|
23
24
|
function createEditor({ content }) {
|
|
24
25
|
return new Editor({
|
|
25
|
-
content,
|
|
26
|
-
extensions:
|
|
26
|
+
content: ContentNormalizer.normalize(content),
|
|
27
|
+
extensions: buildCoreExtensions().concat(
|
|
27
28
|
MockStylePreset,
|
|
28
29
|
DeviceManager.configure({ deviceRef: ref('desktop') }),
|
|
29
30
|
LineHeight
|
|
@@ -104,3 +105,48 @@ describe('rendering', () => {
|
|
|
104
105
|
expect(editor.getHTML()).toMatchSnapshot();
|
|
105
106
|
});
|
|
106
107
|
});
|
|
108
|
+
|
|
109
|
+
describe('parsing html', () => {
|
|
110
|
+
test('should get value from text in relative units', () => {
|
|
111
|
+
const editor = createEditor({
|
|
112
|
+
content: '<p style="line-height: 1.2">test</p>'
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('should get value from text in px units with font size', () => {
|
|
119
|
+
const editor = createEditor({
|
|
120
|
+
content: '<p style="line-height: 24px; font-size: 20px;">test</p>'
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test('should get value from text in px units with no font size', () => {
|
|
127
|
+
global.document.body.style.fontSize = '20px';
|
|
128
|
+
|
|
129
|
+
const editor = createEditor({
|
|
130
|
+
content: '<p style="line-height: 24px">test</p>'
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
134
|
+
global.document.body.style.removeProperty('font-size');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('should get value from rendered view', () => {
|
|
138
|
+
const editor = createEditor({
|
|
139
|
+
content: '<p style="--zw-line-height-mobile:1.2;--zw-line-height-desktop:1.4">test</p>'
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('should set null if no alignment', () => {
|
|
146
|
+
const editor = createEditor({
|
|
147
|
+
content: '<p>test</p>'
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
151
|
+
});
|
|
152
|
+
});
|