@zipify/wysiwyg 1.0.0-dev.6 → 1.0.0-dev.62
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/.editorconfig +1 -1
- package/.eslintrc.js +2 -2
- package/.github/dependabot.yaml +1 -0
- package/.lintstagedrc +2 -2
- package/.release-it.json +3 -1
- package/.stylelintrc +0 -4
- package/README.md +2 -2
- package/config/jest/setupTests.js +0 -3
- package/config/vite/example.config.js +25 -0
- package/config/vite/lib.config.js +28 -0
- package/config/{webpack → vite}/settings.js +0 -0
- package/dist/wysiwyg.css +1 -837
- package/dist/wysiwyg.mjs +18353 -0
- package/example/ExampleApp.vue +41 -3
- package/example/example.js +0 -3
- package/example/{example.html → index.html} +1 -0
- package/example/pageBlocks.js +31 -0
- package/example/presets.js +2 -2
- package/example/tooltip/Tooltip.js +1 -1
- package/jest.config.js +3 -1
- package/lib/Wysiwyg.vue +65 -26
- package/lib/__tests__/utils/NodeFactory.js +13 -0
- package/lib/__tests__/utils/withComponentContext.js +1 -1
- package/lib/assets/icons/link.svg +3 -0
- package/lib/assets/icons/unlink.svg +3 -0
- package/lib/components/base/Button.vue +22 -2
- package/lib/components/base/Checkbox.vue +89 -0
- package/lib/components/base/FieldLabel.vue +2 -1
- package/lib/components/base/Icon.vue +3 -3
- package/lib/components/base/Modal.vue +1 -2
- package/lib/components/base/NumberField.vue +2 -2
- package/lib/components/base/Range.vue +1 -1
- package/lib/components/base/ScrollView.vue +1 -3
- package/lib/components/base/TextField.vue +106 -0
- package/lib/components/base/__tests__/Modal.test.js +7 -2
- 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/ColorPicker.vue +2 -2
- package/lib/components/base/colorPicker/composables/__tests__/usePickerApi.test.js +1 -1
- package/lib/components/base/colorPicker/composables/usePickerApi.js +3 -3
- package/lib/components/base/colorPicker/composables/usePickerHotkeys.js +3 -2
- package/lib/components/base/composables/__tests__/useActivatedListener.test.js +1 -1
- package/lib/components/base/composables/__tests__/useDeselectionLock.test.js +1 -1
- package/lib/components/base/composables/__tests__/useElementRef.test.js +1 -1
- package/lib/components/base/composables/__tests__/useModalToggler.test.js +1 -1
- package/lib/components/base/composables/__tests__/useNumberValue.test.js +1 -1
- package/lib/components/base/composables/__tests__/useScrollView.test.js +1 -1
- package/lib/components/base/composables/__tests__/useTempValue.test.js +1 -1
- package/lib/components/base/composables/__tests__/useValidator.test.js +44 -0
- package/lib/components/base/composables/index.js +1 -0
- package/lib/components/base/composables/useActivatedListener.js +1 -1
- package/lib/components/base/composables/useDeselectionLock.js +1 -1
- package/lib/components/base/composables/useElementRef.js +1 -1
- package/lib/components/base/composables/useModalToggler.js +1 -1
- package/lib/components/base/composables/useScrollView.js +1 -1
- package/lib/components/base/composables/useTempValue.js +1 -1
- package/lib/components/base/composables/useValidator.js +23 -0
- package/lib/components/base/dropdown/Dropdown.vue +16 -4
- package/lib/components/base/dropdown/DropdownActivator.vue +19 -3
- package/lib/components/base/dropdown/DropdownGroup.vue +1 -1
- package/lib/components/base/dropdown/DropdownMenu.vue +1 -1
- package/lib/components/base/dropdown/DropdownOption.vue +1 -1
- package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +1 -1
- package/lib/components/base/dropdown/__tests__/DropdownMenu.test.js +1 -1
- package/lib/components/base/dropdown/__tests__/DropdownOption.test.js +1 -1
- package/lib/components/base/dropdown/composables/__tests__/useActiveOptionManager.test.js +1 -1
- package/lib/components/base/dropdown/composables/__tests__/useDropdownEntityTitle.test.js +1 -1
- package/lib/components/base/dropdown/composables/useActiveOptionManager.js +1 -1
- package/lib/components/base/dropdown/composables/useDropdownEntityTitle.js +1 -1
- package/lib/components/base/index.js +3 -1
- package/lib/components/toolbar/Toolbar.vue +49 -9
- package/lib/components/toolbar/ToolbarDivider.vue +1 -1
- package/lib/components/toolbar/ToolbarFull.vue +10 -2
- package/lib/components/toolbar/ToolbarRow.vue +1 -0
- package/lib/components/toolbar/__tests__/Toolbar.test.js +6 -0
- package/lib/components/toolbar/controls/AlignmentControl.vue +1 -1
- package/lib/components/toolbar/controls/AlignmentDeviceControl.vue +1 -1
- package/lib/components/toolbar/controls/BackgroundColorControl.vue +1 -1
- package/lib/components/toolbar/controls/CaseStyleControl.vue +1 -1
- package/lib/components/toolbar/controls/FontColorControl.vue +1 -1
- package/lib/components/toolbar/controls/FontFamilyControl.vue +1 -1
- package/lib/components/toolbar/controls/FontSizeControl.vue +8 -1
- package/lib/components/toolbar/controls/FontWeightControl.vue +1 -1
- package/lib/components/toolbar/controls/ItalicControl.vue +1 -1
- package/lib/components/toolbar/controls/LineHeightControl.vue +1 -1
- package/lib/components/toolbar/controls/ListControl.vue +68 -34
- package/lib/components/toolbar/controls/RemoveFormatControl.vue +1 -1
- package/lib/components/toolbar/controls/StrikeThroughControl.vue +1 -1
- package/lib/components/toolbar/controls/StylePresetControl.vue +15 -2
- package/lib/components/toolbar/controls/SuperscriptControl.vue +1 -1
- package/lib/components/toolbar/controls/UnderlineControl.vue +2 -2
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/AlignmentDeviceControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/BackgroundColorControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/CaseStyleControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/ListControl.test.js +18 -3
- package/lib/components/toolbar/controls/__tests__/StrikeThroughControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +17 -1
- package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +5 -1
- package/lib/components/toolbar/controls/composables/useRecentFonts.js +1 -1
- package/lib/components/toolbar/controls/index.js +1 -0
- package/lib/components/toolbar/controls/link/LinkControl.vue +155 -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/__tests__/LinkControl.test.js +79 -0
- package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +42 -0
- package/lib/components/toolbar/controls/link/composables/__tests__/__snapshots__/useLink.test.js.snap +8 -0
- package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +114 -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/__tests__/LinkControlPageBlock.test.js +36 -0
- package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlUrl.test.js +46 -0
- package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlPageBlock.test.js.snap +9 -0
- package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlUrl.test.js.snap +17 -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 +4 -3
- package/lib/composables/useEditor.js +8 -8
- package/lib/composables/useToolbar.js +23 -28
- package/lib/directives/__tests__/outClick.test.js +6 -0
- package/lib/directives/outClick.js +19 -6
- package/lib/enums/Alignments.js +10 -1
- 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 +22 -8
- package/lib/extensions/BackgroundColor.js +15 -7
- package/lib/extensions/DeviceManager.js +2 -5
- package/lib/extensions/FontColor.js +15 -7
- package/lib/extensions/FontFamily.js +26 -9
- package/lib/extensions/FontSize.js +32 -13
- package/lib/extensions/FontStyle.js +24 -14
- package/lib/extensions/FontWeight.js +25 -15
- package/lib/extensions/LineHeight.js +32 -29
- package/lib/extensions/Link.js +90 -0
- package/lib/extensions/StylePreset.js +20 -19
- package/lib/extensions/Superscript.js +5 -1
- package/lib/extensions/TextDecoration.js +46 -13
- package/lib/extensions/__tests__/Alignment.test.js +13 -7
- package/lib/extensions/__tests__/BackgroundColor.test.js +12 -6
- package/lib/extensions/__tests__/CaseStyle.test.js +3 -5
- package/lib/extensions/__tests__/FontColor.test.js +12 -6
- package/lib/extensions/__tests__/FontFamily.test.js +33 -8
- package/lib/extensions/__tests__/FontSize.test.js +15 -8
- package/lib/extensions/__tests__/FontStyle.test.js +12 -6
- package/lib/extensions/__tests__/FontWeight.test.js +20 -6
- package/lib/extensions/__tests__/LineHeight.test.js +24 -12
- package/lib/extensions/__tests__/Link.test.js +102 -0
- package/lib/extensions/__tests__/StylePreset.test.js +71 -8
- package/lib/extensions/__tests__/TextDecoration.test.js +52 -6
- package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +26 -2
- package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +30 -1
- package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +18 -1
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +88 -1
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +33 -2
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +25 -4
- package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +47 -1
- package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +26 -2
- package/lib/extensions/__tests__/__snapshots__/Link.test.js.snap +225 -0
- package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +6 -2
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +183 -3
- package/lib/extensions/core/CopyPasteProcessor.js +10 -0
- package/lib/extensions/core/NodeProcessor.js +1 -1
- package/lib/extensions/core/TextProcessor.js +10 -0
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +3 -5
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +3 -5
- package/lib/extensions/core/__tests__/TextProcessor.test.js +138 -12
- 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 +57 -0
- package/lib/extensions/core/plugins/ProseMirrorPlugin.js +20 -0
- package/lib/extensions/core/plugins/index.js +1 -0
- package/lib/extensions/index.js +46 -34
- package/lib/extensions/list/List.js +2 -3
- package/lib/extensions/list/__tests__/List.test.js +5 -8
- package/lib/extensions/list/__tests__/__snapshots__/List.test.js.snap +60 -20
- package/lib/injectionTokens.js +2 -1
- package/lib/services/ContentNormalizer.js +122 -29
- package/lib/services/ContextWidnow.js +23 -0
- package/lib/services/__tests__/ContentNormalizer.test.js +96 -7
- package/lib/services/__tests__/FavoriteColors.test.js +1 -1
- package/lib/services/index.js +1 -0
- package/lib/styles/content.css +110 -13
- 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__/convertAlignment.test.js +16 -0
- package/lib/utils/__tests__/convertFontSize.test.js +21 -0
- package/lib/utils/__tests__/convertLineHeight.test.js +21 -0
- package/lib/utils/convertAlignment.js +12 -0
- package/lib/utils/convertColor.js +1 -1
- package/lib/utils/convertFontSize.js +8 -0
- package/lib/utils/convertLineHeight.js +17 -0
- package/lib/utils/importIcon.js +7 -6
- package/lib/utils/index.js +3 -0
- package/lib/utils/renderInlineSetting.js +1 -1
- package/package.json +26 -31
- package/config/webpack/example.config.js +0 -88
- package/config/webpack/lib.config.js +0 -40
- package/config/webpack/loaders/index.js +0 -6
- package/config/webpack/loaders/js-loader.js +0 -5
- package/config/webpack/loaders/style-loader.js +0 -9
- package/config/webpack/loaders/svg-loader.js +0 -4
- package/config/webpack/loaders/vue-loader.js +0 -4
- package/dist/wysiwyg.js +0 -2
- package/dist/wysiwyg.js.LICENSE.txt +0 -1
- package/lib/composables/__tests__/useToolbar.test.js +0 -56
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Editor, Extension, Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { ref } from '@vue/composition-api';
|
|
3
2
|
import { NodeFactory } from '../../__tests__/utils';
|
|
4
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
5
3
|
import { StylePreset } from '../StylePreset';
|
|
6
4
|
import { List } from '../list';
|
|
7
5
|
import { ListTypes, NodeTypes, TextSettings } from '../../enums';
|
|
8
6
|
import { ContentNormalizer } from '../../services';
|
|
7
|
+
import { buildCoreExtensions } from '../core';
|
|
9
8
|
|
|
10
9
|
const MockFontSize = Mark.create({
|
|
11
10
|
name: TextSettings.FONT_SIZE,
|
|
@@ -43,17 +42,75 @@ const MockAlignment = Extension.create({
|
|
|
43
42
|
]
|
|
44
43
|
});
|
|
45
44
|
|
|
45
|
+
const MockBackgroundColor = Mark.create({
|
|
46
|
+
name: TextSettings.BACKGROUND_COLOR,
|
|
47
|
+
|
|
48
|
+
addAttributes: () => ({
|
|
49
|
+
value: { default: null }
|
|
50
|
+
}),
|
|
51
|
+
|
|
52
|
+
renderHTML: () => ['span', {}, 0]
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const MockFontColor = Mark.create({
|
|
56
|
+
name: TextSettings.FONT_COLOR,
|
|
57
|
+
|
|
58
|
+
addAttributes: () => ({
|
|
59
|
+
value: { default: null }
|
|
60
|
+
}),
|
|
61
|
+
|
|
62
|
+
renderHTML: () => ['span', {}, 0]
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const MockFontFamily = Mark.create({
|
|
66
|
+
name: TextSettings.FONT_FAMILY,
|
|
67
|
+
|
|
68
|
+
addAttributes: () => ({
|
|
69
|
+
value: { default: null }
|
|
70
|
+
}),
|
|
71
|
+
|
|
72
|
+
renderHTML: () => ['span', {}, 0]
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const MockFontStyle = Mark.create({
|
|
76
|
+
name: TextSettings.FONT_STYLE,
|
|
77
|
+
|
|
78
|
+
addAttributes: () => ({
|
|
79
|
+
value: { default: null }
|
|
80
|
+
}),
|
|
81
|
+
|
|
82
|
+
renderHTML: () => ['span', {}, 0]
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const MockTextDecoration = Mark.create({
|
|
86
|
+
name: TextSettings.TEXT_DECORATION,
|
|
87
|
+
|
|
88
|
+
addAttributes: () => ({
|
|
89
|
+
value: { default: null }
|
|
90
|
+
}),
|
|
91
|
+
|
|
92
|
+
renderHTML: () => ['span', {}, 0]
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const MockSuperscript = Mark.create({
|
|
96
|
+
name: TextSettings.SUPERSCRIPT,
|
|
97
|
+
|
|
98
|
+
addAttributes: () => ({
|
|
99
|
+
value: { default: null }
|
|
100
|
+
}),
|
|
101
|
+
|
|
102
|
+
renderHTML: () => ['span', {}, 0]
|
|
103
|
+
});
|
|
104
|
+
|
|
46
105
|
function createEditor({ content, presets, defaultId }) {
|
|
47
106
|
return new Promise((resolve) => {
|
|
48
|
-
const normalizer = new ContentNormalizer();
|
|
49
|
-
|
|
50
107
|
const editor = new Editor({
|
|
51
|
-
content:
|
|
108
|
+
content: ContentNormalizer.normalize(content),
|
|
52
109
|
onCreate: () => resolve(editor),
|
|
53
110
|
|
|
54
|
-
extensions:
|
|
111
|
+
extensions: buildCoreExtensions().concat(
|
|
55
112
|
StylePreset.configure({
|
|
56
|
-
|
|
113
|
+
presets: presets,
|
|
57
114
|
baseClass: 'zw ts-',
|
|
58
115
|
defaultId,
|
|
59
116
|
|
|
@@ -68,7 +125,13 @@ function createEditor({ content, presets, defaultId }) {
|
|
|
68
125
|
}),
|
|
69
126
|
MockFontSize,
|
|
70
127
|
MockFontWeight,
|
|
71
|
-
MockAlignment
|
|
128
|
+
MockAlignment,
|
|
129
|
+
MockBackgroundColor,
|
|
130
|
+
MockFontColor,
|
|
131
|
+
MockFontFamily,
|
|
132
|
+
MockFontStyle,
|
|
133
|
+
MockTextDecoration,
|
|
134
|
+
MockSuperscript
|
|
72
135
|
)
|
|
73
136
|
});
|
|
74
137
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Editor, Extension } from '@tiptap/vue-2';
|
|
2
|
-
import { ref } from '
|
|
2
|
+
import { ref } from 'vue';
|
|
3
3
|
import { NodeFactory } from '../../__tests__/utils';
|
|
4
4
|
import { createCommand } from '../../utils';
|
|
5
|
-
import { CORE_EXTENSIONS } from '../core';
|
|
6
5
|
import { TextDecoration } from '../TextDecoration';
|
|
7
6
|
import { ContentNormalizer } from '../../services';
|
|
7
|
+
import { buildCoreExtensions } from '../core';
|
|
8
8
|
|
|
9
9
|
const MockStylePreset = Extension.create({
|
|
10
10
|
name: 'style_preset',
|
|
@@ -19,11 +19,9 @@ const MockStylePreset = Extension.create({
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
function createEditor({ content }) {
|
|
22
|
-
const normalizer = new ContentNormalizer();
|
|
23
|
-
|
|
24
22
|
return new Editor({
|
|
25
|
-
content:
|
|
26
|
-
extensions:
|
|
23
|
+
content: ContentNormalizer.normalize(content),
|
|
24
|
+
extensions: buildCoreExtensions().concat(MockStylePreset, TextDecoration)
|
|
27
25
|
});
|
|
28
26
|
}
|
|
29
27
|
|
|
@@ -294,6 +292,14 @@ describe('parsing html', () => {
|
|
|
294
292
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
295
293
|
});
|
|
296
294
|
|
|
295
|
+
test('should get underline from rendered view', () => {
|
|
296
|
+
const editor = createEditor({
|
|
297
|
+
content: '<p><span style="--zw-text-decoration: underline">lorem</span> ipsum</p>'
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
301
|
+
});
|
|
302
|
+
|
|
297
303
|
test('should get strike through from text', () => {
|
|
298
304
|
const editor = createEditor({
|
|
299
305
|
content: '<p><span style="text-decoration-line: line-through">lorem</span> ipsum</p>'
|
|
@@ -302,6 +308,14 @@ describe('parsing html', () => {
|
|
|
302
308
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
303
309
|
});
|
|
304
310
|
|
|
311
|
+
test('should get strike through from rendered view', () => {
|
|
312
|
+
const editor = createEditor({
|
|
313
|
+
content: '<p><span style="--zw-text-decoration: line-through">lorem</span> ipsum</p>'
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
317
|
+
});
|
|
318
|
+
|
|
305
319
|
test('should get both from text', () => {
|
|
306
320
|
const editor = createEditor({
|
|
307
321
|
content: '<p><span style="text-decoration-line: underline line-through">lorem</span> ipsum</p>'
|
|
@@ -310,6 +324,22 @@ describe('parsing html', () => {
|
|
|
310
324
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
311
325
|
});
|
|
312
326
|
|
|
327
|
+
test('should get both from text with property shorthand', () => {
|
|
328
|
+
const editor = createEditor({
|
|
329
|
+
content: '<p><span style="text-decoration: underline line-through">lorem</span> ipsum</p>'
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
test('should get both from rendered view', () => {
|
|
336
|
+
const editor = createEditor({
|
|
337
|
+
content: '<p><span style="--zw-text-decoration: underline line-through">lorem</span> ipsum</p>'
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
341
|
+
});
|
|
342
|
+
|
|
313
343
|
test('should merge paragraph and text settings', () => {
|
|
314
344
|
const editor = createEditor({
|
|
315
345
|
content: '<p style="text-decoration-line: underline"><span style="text-decoration-line: line-through">lorem</span> ipsum</p>'
|
|
@@ -317,4 +347,20 @@ describe('parsing html', () => {
|
|
|
317
347
|
|
|
318
348
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
319
349
|
});
|
|
350
|
+
|
|
351
|
+
test('should parse underline from tag', () => {
|
|
352
|
+
const editor = createEditor({
|
|
353
|
+
content: '<p><u>lorem</u> ipsum</p>'
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
test('should parse strike through from tag', () => {
|
|
360
|
+
const editor = createEditor({
|
|
361
|
+
content: '<p><s>lorem</s> ipsum</p>'
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
365
|
+
});
|
|
320
366
|
});
|
|
@@ -24,6 +24,30 @@ Object {
|
|
|
24
24
|
}
|
|
25
25
|
`;
|
|
26
26
|
|
|
27
|
+
exports[`parsing html should get alignment from rendered view 1`] = `
|
|
28
|
+
Object {
|
|
29
|
+
"content": Array [
|
|
30
|
+
Object {
|
|
31
|
+
"attrs": Object {
|
|
32
|
+
"alignment": Object {
|
|
33
|
+
"desktop": "right",
|
|
34
|
+
"mobile": "center",
|
|
35
|
+
"tablet": null,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
"content": Array [
|
|
39
|
+
Object {
|
|
40
|
+
"text": "test",
|
|
41
|
+
"type": "text",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
"type": "paragraph",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
"type": "doc",
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
27
51
|
exports[`parsing html should get alignment from text 1`] = `
|
|
28
52
|
Object {
|
|
29
53
|
"content": Array [
|
|
@@ -68,6 +92,6 @@ Object {
|
|
|
68
92
|
}
|
|
69
93
|
`;
|
|
70
94
|
|
|
71
|
-
exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-
|
|
95
|
+
exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-text-align-mobile:left;--zw-text-align-tablet:right;--zw-text-align-desktop:center;\\">hello world</p>"`;
|
|
72
96
|
|
|
73
|
-
exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-
|
|
97
|
+
exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-text-align-desktop:center;\\">hello world</p>"`;
|
|
@@ -50,6 +50,35 @@ Object {
|
|
|
50
50
|
}
|
|
51
51
|
`;
|
|
52
52
|
|
|
53
|
+
exports[`parsing html should get value from rendered view 1`] = `
|
|
54
|
+
Object {
|
|
55
|
+
"content": Array [
|
|
56
|
+
Object {
|
|
57
|
+
"content": Array [
|
|
58
|
+
Object {
|
|
59
|
+
"marks": Array [
|
|
60
|
+
Object {
|
|
61
|
+
"attrs": Object {
|
|
62
|
+
"value": "#FF0000",
|
|
63
|
+
},
|
|
64
|
+
"type": "background_color",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
"text": "lorem",
|
|
68
|
+
"type": "text",
|
|
69
|
+
},
|
|
70
|
+
Object {
|
|
71
|
+
"text": " ipsum",
|
|
72
|
+
"type": "text",
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
"type": "paragraph",
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
"type": "doc",
|
|
79
|
+
}
|
|
80
|
+
`;
|
|
81
|
+
|
|
53
82
|
exports[`parsing html should get value from text 1`] = `
|
|
54
83
|
Object {
|
|
55
84
|
"content": Array [
|
|
@@ -116,4 +145,4 @@ Object {
|
|
|
116
145
|
}
|
|
117
146
|
`;
|
|
118
147
|
|
|
119
|
-
exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-background-color:
|
|
148
|
+
exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-background-color:green;\\" class=\\"zw-style\\">hello world</span></p>"`;
|
|
@@ -50,6 +50,23 @@ Object {
|
|
|
50
50
|
}
|
|
51
51
|
`;
|
|
52
52
|
|
|
53
|
+
exports[`parsing html should get value from parsed view 1`] = `
|
|
54
|
+
Object {
|
|
55
|
+
"content": Array [
|
|
56
|
+
Object {
|
|
57
|
+
"content": Array [
|
|
58
|
+
Object {
|
|
59
|
+
"text": "lorem ipsum",
|
|
60
|
+
"type": "text",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
"type": "paragraph",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
"type": "doc",
|
|
67
|
+
}
|
|
68
|
+
`;
|
|
69
|
+
|
|
53
70
|
exports[`parsing html should get value from text 1`] = `
|
|
54
71
|
Object {
|
|
55
72
|
"content": Array [
|
|
@@ -116,4 +133,4 @@ Object {
|
|
|
116
133
|
}
|
|
117
134
|
`;
|
|
118
135
|
|
|
119
|
-
exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-color:
|
|
136
|
+
exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-color:green;\\" class=\\"zw-style\\">hello world</span></p>"`;
|
|
@@ -155,6 +155,64 @@ Object {
|
|
|
155
155
|
}
|
|
156
156
|
`;
|
|
157
157
|
|
|
158
|
+
exports[`parsing html should get parse font name with quotes 1`] = `
|
|
159
|
+
Object {
|
|
160
|
+
"content": Array [
|
|
161
|
+
Object {
|
|
162
|
+
"content": Array [
|
|
163
|
+
Object {
|
|
164
|
+
"text": "hello ",
|
|
165
|
+
"type": "text",
|
|
166
|
+
},
|
|
167
|
+
Object {
|
|
168
|
+
"marks": Array [
|
|
169
|
+
Object {
|
|
170
|
+
"attrs": Object {
|
|
171
|
+
"value": "Josefin Slab",
|
|
172
|
+
},
|
|
173
|
+
"type": "font_family",
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
"text": "world",
|
|
177
|
+
"type": "text",
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
"type": "paragraph",
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
"type": "doc",
|
|
184
|
+
}
|
|
185
|
+
`;
|
|
186
|
+
|
|
187
|
+
exports[`parsing html should get set default if undefined font 1`] = `
|
|
188
|
+
Object {
|
|
189
|
+
"content": Array [
|
|
190
|
+
Object {
|
|
191
|
+
"content": Array [
|
|
192
|
+
Object {
|
|
193
|
+
"marks": Array [
|
|
194
|
+
Object {
|
|
195
|
+
"attrs": Object {
|
|
196
|
+
"value": "Lato",
|
|
197
|
+
},
|
|
198
|
+
"type": "font_family",
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
"text": "lorem",
|
|
202
|
+
"type": "text",
|
|
203
|
+
},
|
|
204
|
+
Object {
|
|
205
|
+
"text": " ipsum",
|
|
206
|
+
"type": "text",
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
"type": "paragraph",
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
"type": "doc",
|
|
213
|
+
}
|
|
214
|
+
`;
|
|
215
|
+
|
|
158
216
|
exports[`parsing html should get value from paragraph 1`] = `
|
|
159
217
|
Object {
|
|
160
218
|
"content": Array [
|
|
@@ -180,6 +238,35 @@ Object {
|
|
|
180
238
|
}
|
|
181
239
|
`;
|
|
182
240
|
|
|
241
|
+
exports[`parsing html should get value from rendered view 1`] = `
|
|
242
|
+
Object {
|
|
243
|
+
"content": Array [
|
|
244
|
+
Object {
|
|
245
|
+
"content": Array [
|
|
246
|
+
Object {
|
|
247
|
+
"marks": Array [
|
|
248
|
+
Object {
|
|
249
|
+
"attrs": Object {
|
|
250
|
+
"value": "Lato",
|
|
251
|
+
},
|
|
252
|
+
"type": "font_family",
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
"text": "lorem",
|
|
256
|
+
"type": "text",
|
|
257
|
+
},
|
|
258
|
+
Object {
|
|
259
|
+
"text": " ipsum",
|
|
260
|
+
"type": "text",
|
|
261
|
+
},
|
|
262
|
+
],
|
|
263
|
+
"type": "paragraph",
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
"type": "doc",
|
|
267
|
+
}
|
|
268
|
+
`;
|
|
269
|
+
|
|
183
270
|
exports[`parsing html should get value from text 1`] = `
|
|
184
271
|
Object {
|
|
185
272
|
"content": Array [
|
|
@@ -246,4 +333,4 @@ Object {
|
|
|
246
333
|
}
|
|
247
334
|
`;
|
|
248
335
|
|
|
249
|
-
exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-family
|
|
336
|
+
exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-family:"Bungee";\\" class=\\"zw-style\\">hello world</span></p>"`;
|
|
@@ -162,6 +162,37 @@ Object {
|
|
|
162
162
|
}
|
|
163
163
|
`;
|
|
164
164
|
|
|
165
|
+
exports[`parsing html should get value from rendered view 1`] = `
|
|
166
|
+
Object {
|
|
167
|
+
"content": Array [
|
|
168
|
+
Object {
|
|
169
|
+
"content": Array [
|
|
170
|
+
Object {
|
|
171
|
+
"marks": Array [
|
|
172
|
+
Object {
|
|
173
|
+
"attrs": Object {
|
|
174
|
+
"desktop": "30",
|
|
175
|
+
"mobile": "24",
|
|
176
|
+
"tablet": null,
|
|
177
|
+
},
|
|
178
|
+
"type": "font_size",
|
|
179
|
+
},
|
|
180
|
+
],
|
|
181
|
+
"text": "lorem",
|
|
182
|
+
"type": "text",
|
|
183
|
+
},
|
|
184
|
+
Object {
|
|
185
|
+
"text": " ipsum",
|
|
186
|
+
"type": "text",
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
"type": "paragraph",
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
"type": "doc",
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
|
|
165
196
|
exports[`parsing html should get value from text 1`] = `
|
|
166
197
|
Object {
|
|
167
198
|
"content": Array [
|
|
@@ -234,6 +265,6 @@ Object {
|
|
|
234
265
|
}
|
|
235
266
|
`;
|
|
236
267
|
|
|
237
|
-
exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-
|
|
268
|
+
exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-size-mobile:12px;--zw-font-size-tablet:14px;--zw-font-size-desktop:16px;\\" class=\\"zw-style\\">hello world</span></p>"`;
|
|
238
269
|
|
|
239
|
-
exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-
|
|
270
|
+
exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-size-desktop:14px;\\" class=\\"zw-style\\">hello world</span></p>"`;
|
|
@@ -138,7 +138,7 @@ Object {
|
|
|
138
138
|
}
|
|
139
139
|
`;
|
|
140
140
|
|
|
141
|
-
exports[`parsing html should get value from
|
|
141
|
+
exports[`parsing html should get value from rendered view 1`] = `
|
|
142
142
|
Object {
|
|
143
143
|
"content": Array [
|
|
144
144
|
Object {
|
|
@@ -167,7 +167,7 @@ Object {
|
|
|
167
167
|
}
|
|
168
168
|
`;
|
|
169
169
|
|
|
170
|
-
exports[`parsing html should
|
|
170
|
+
exports[`parsing html should get value from text 1`] = `
|
|
171
171
|
Object {
|
|
172
172
|
"content": Array [
|
|
173
173
|
Object {
|
|
@@ -176,7 +176,7 @@ Object {
|
|
|
176
176
|
"marks": Array [
|
|
177
177
|
Object {
|
|
178
178
|
"attrs": Object {
|
|
179
|
-
"italic":
|
|
179
|
+
"italic": true,
|
|
180
180
|
},
|
|
181
181
|
"type": "font_style",
|
|
182
182
|
},
|
|
@@ -184,6 +184,27 @@ Object {
|
|
|
184
184
|
"text": "lorem",
|
|
185
185
|
"type": "text",
|
|
186
186
|
},
|
|
187
|
+
Object {
|
|
188
|
+
"text": " ipsum",
|
|
189
|
+
"type": "text",
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
"type": "paragraph",
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
"type": "doc",
|
|
196
|
+
}
|
|
197
|
+
`;
|
|
198
|
+
|
|
199
|
+
exports[`parsing html should merge paragraph and text settings 1`] = `
|
|
200
|
+
Object {
|
|
201
|
+
"content": Array [
|
|
202
|
+
Object {
|
|
203
|
+
"content": Array [
|
|
204
|
+
Object {
|
|
205
|
+
"text": "lorem",
|
|
206
|
+
"type": "text",
|
|
207
|
+
},
|
|
187
208
|
Object {
|
|
188
209
|
"marks": Array [
|
|
189
210
|
Object {
|
|
@@ -204,4 +225,4 @@ Object {
|
|
|
204
225
|
}
|
|
205
226
|
`;
|
|
206
227
|
|
|
207
|
-
exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-style:
|
|
228
|
+
exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-style:italic;\\" class=\\"zw-style\\">hello world</span></p>"`;
|
|
@@ -191,6 +191,35 @@ Object {
|
|
|
191
191
|
}
|
|
192
192
|
`;
|
|
193
193
|
|
|
194
|
+
exports[`parsing html should get value from rendered view 1`] = `
|
|
195
|
+
Object {
|
|
196
|
+
"content": Array [
|
|
197
|
+
Object {
|
|
198
|
+
"content": Array [
|
|
199
|
+
Object {
|
|
200
|
+
"marks": Array [
|
|
201
|
+
Object {
|
|
202
|
+
"attrs": Object {
|
|
203
|
+
"value": "700",
|
|
204
|
+
},
|
|
205
|
+
"type": "font_weight",
|
|
206
|
+
},
|
|
207
|
+
],
|
|
208
|
+
"text": "lorem",
|
|
209
|
+
"type": "text",
|
|
210
|
+
},
|
|
211
|
+
Object {
|
|
212
|
+
"text": " ipsum",
|
|
213
|
+
"type": "text",
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
"type": "paragraph",
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
"type": "doc",
|
|
220
|
+
}
|
|
221
|
+
`;
|
|
222
|
+
|
|
194
223
|
exports[`parsing html should get value from strong tag 1`] = `
|
|
195
224
|
Object {
|
|
196
225
|
"content": Array [
|
|
@@ -249,6 +278,23 @@ Object {
|
|
|
249
278
|
}
|
|
250
279
|
`;
|
|
251
280
|
|
|
281
|
+
exports[`parsing html should ignore invalid value 1`] = `
|
|
282
|
+
Object {
|
|
283
|
+
"content": Array [
|
|
284
|
+
Object {
|
|
285
|
+
"content": Array [
|
|
286
|
+
Object {
|
|
287
|
+
"text": "lorem ipsum",
|
|
288
|
+
"type": "text",
|
|
289
|
+
},
|
|
290
|
+
],
|
|
291
|
+
"type": "paragraph",
|
|
292
|
+
},
|
|
293
|
+
],
|
|
294
|
+
"type": "doc",
|
|
295
|
+
}
|
|
296
|
+
`;
|
|
297
|
+
|
|
252
298
|
exports[`parsing html should merge paragraph and text settings 1`] = `
|
|
253
299
|
Object {
|
|
254
300
|
"content": Array [
|
|
@@ -286,4 +332,4 @@ Object {
|
|
|
286
332
|
}
|
|
287
333
|
`;
|
|
288
334
|
|
|
289
|
-
exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-weight:
|
|
335
|
+
exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-weight:700;\\" class=\\"zw-style\\">hello world</span></p>"`;
|
|
@@ -24,6 +24,30 @@ Object {
|
|
|
24
24
|
}
|
|
25
25
|
`;
|
|
26
26
|
|
|
27
|
+
exports[`parsing html should get value from rendered view 1`] = `
|
|
28
|
+
Object {
|
|
29
|
+
"content": Array [
|
|
30
|
+
Object {
|
|
31
|
+
"attrs": Object {
|
|
32
|
+
"line_height": Object {
|
|
33
|
+
"desktop": "1.4",
|
|
34
|
+
"mobile": "1.2",
|
|
35
|
+
"tablet": null,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
"content": Array [
|
|
39
|
+
Object {
|
|
40
|
+
"text": "test",
|
|
41
|
+
"type": "text",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
"type": "paragraph",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
"type": "doc",
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
|
|
27
51
|
exports[`parsing html should get value from text in px units with font size 1`] = `
|
|
28
52
|
Object {
|
|
29
53
|
"content": Array [
|
|
@@ -116,6 +140,6 @@ Object {
|
|
|
116
140
|
}
|
|
117
141
|
`;
|
|
118
142
|
|
|
119
|
-
exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-
|
|
143
|
+
exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-line-height-mobile:1.21;--zw-line-height-tablet:1.4;--zw-line-height-desktop:1.6;\\">hello world</p>"`;
|
|
120
144
|
|
|
121
|
-
exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-
|
|
145
|
+
exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-line-height-desktop:1.3;\\">hello world</p>"`;
|