@zipify/wysiwyg 1.0.0-dev.2 → 1.0.0-dev.5

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 (60) hide show
  1. package/README.md +3 -1
  2. package/config/jest/setupTests.js +3 -1
  3. package/example/ExampleApp.vue +39 -31
  4. package/example/example.js +26 -0
  5. package/example/presets.js +2 -0
  6. package/lib/Wysiwyg.vue +6 -0
  7. package/lib/composables/__tests__/useEditor.test.js +12 -3
  8. package/lib/composables/useEditor.js +12 -5
  9. package/lib/extensions/Alignment.js +6 -0
  10. package/lib/extensions/BackgroundColor.js +8 -1
  11. package/lib/extensions/FontColor.js +8 -1
  12. package/lib/extensions/FontFamily.js +7 -0
  13. package/lib/extensions/FontSize.js +12 -0
  14. package/lib/extensions/FontStyle.js +11 -0
  15. package/lib/extensions/FontWeight.js +25 -1
  16. package/lib/extensions/LineHeight.js +17 -0
  17. package/lib/extensions/StylePreset.js +30 -3
  18. package/lib/extensions/TextDecoration.js +11 -0
  19. package/lib/extensions/__tests__/Alignment.test.js +22 -1
  20. package/lib/extensions/__tests__/BackgroundColor.test.js +30 -1
  21. package/lib/extensions/__tests__/CaseStyle.test.js +4 -1
  22. package/lib/extensions/__tests__/FontColor.test.js +30 -1
  23. package/lib/extensions/__tests__/FontFamily.test.js +30 -1
  24. package/lib/extensions/__tests__/FontSize.test.js +30 -1
  25. package/lib/extensions/__tests__/FontStyle.test.js +38 -1
  26. package/lib/extensions/__tests__/FontWeight.test.js +58 -1
  27. package/lib/extensions/__tests__/LineHeight.test.js +41 -1
  28. package/lib/extensions/__tests__/StylePreset.test.js +76 -1
  29. package/lib/extensions/__tests__/TextDecoration.test.js +63 -1
  30. package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +44 -0
  31. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +91 -0
  32. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +91 -0
  33. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +91 -0
  34. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +99 -0
  35. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +120 -0
  36. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +149 -0
  37. package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +92 -0
  38. package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +167 -2
  39. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +207 -0
  40. package/lib/extensions/core/__tests__/NodeProcessor.test.js +4 -1
  41. package/lib/extensions/core/__tests__/SelectionProcessor.test.js +9 -4
  42. package/lib/extensions/core/__tests__/TextProcessor.test.js +4 -1
  43. package/lib/extensions/index.js +1 -0
  44. package/lib/extensions/list/List.js +34 -0
  45. package/lib/extensions/list/__tests__/List.test.js +115 -3
  46. package/lib/extensions/list/__tests__/__snapshots__/List.test.js.snap +457 -6
  47. package/lib/services/ContentNormalizer.js +113 -0
  48. package/lib/services/Storage.js +1 -13
  49. package/lib/services/__tests__/ContentNormalizer.test.js +41 -0
  50. package/lib/services/__tests__/FavoriteColors.test.js +20 -0
  51. package/lib/services/__tests__/JsonSerializer.test.js +23 -0
  52. package/lib/services/__tests__/Storage.test.js +79 -0
  53. package/lib/services/index.js +1 -0
  54. package/lib/utils/__tests__/convertColor.test.js +19 -0
  55. package/lib/utils/__tests__/createKeyboardShortcut.test.js +25 -0
  56. package/lib/utils/__tests__/renderInlineSetting.test.js +26 -0
  57. package/lib/utils/convertColor.js +7 -0
  58. package/lib/utils/index.js +1 -0
  59. package/lib/utils/renderInlineSetting.js +1 -1
  60. package/package.json +4 -4
@@ -4,6 +4,7 @@ import { NodeFactory } from '../../__tests__/utils';
4
4
  import { createCommand } from '../../utils';
5
5
  import { CORE_EXTENSIONS } from '../core';
6
6
  import { FontColor } from '../FontColor';
7
+ import { ContentNormalizer } from '../../services';
7
8
 
8
9
  const MockStylePreset = Extension.create({
9
10
  name: 'style_preset',
@@ -18,8 +19,10 @@ const MockStylePreset = Extension.create({
18
19
  });
19
20
 
20
21
  function createEditor({ content }) {
22
+ const normalizer = new ContentNormalizer();
23
+
21
24
  return new Editor({
22
- content,
25
+ content: normalizer.normalize(content),
23
26
  extensions: CORE_EXTENSIONS.concat(MockStylePreset, FontColor)
24
27
  });
25
28
  }
@@ -83,3 +86,29 @@ describe('rendering', () => {
83
86
  expect(editor.getHTML()).toMatchSnapshot();
84
87
  });
85
88
  });
89
+
90
+ describe('parsing html', () => {
91
+ test('should get value from paragraph', () => {
92
+ const editor = createEditor({
93
+ content: '<p style="color: red">test</p>'
94
+ });
95
+
96
+ expect(editor.getJSON()).toMatchSnapshot();
97
+ });
98
+
99
+ test('should get value from text', () => {
100
+ const editor = createEditor({
101
+ content: '<p><span style="color: red">lorem</span> ipsum</p>'
102
+ });
103
+
104
+ expect(editor.getJSON()).toMatchSnapshot();
105
+ });
106
+
107
+ test('should merge paragraph and text settings', () => {
108
+ const editor = createEditor({
109
+ content: '<p style="color: red"><span style="color: #000">lorem</span> ipsum</p>'
110
+ });
111
+
112
+ expect(editor.getJSON()).toMatchSnapshot();
113
+ });
114
+ });
@@ -7,6 +7,7 @@ import { Font } from '../../models';
7
7
  import { FontFamily } from '../FontFamily';
8
8
  import { FontWeight } from '../FontWeight';
9
9
  import { FontStyle } from '../FontStyle';
10
+ import { ContentNormalizer } from '../../services';
10
11
 
11
12
  const MockStylePreset = Extension.create({
12
13
  name: 'style_preset',
@@ -24,8 +25,10 @@ const MockStylePreset = Extension.create({
24
25
  });
25
26
 
26
27
  function createEditor({ content }) {
28
+ const normalizer = new ContentNormalizer();
29
+
27
30
  return new Editor({
28
- content,
31
+ content: normalizer.normalize(content),
29
32
  extensions: CORE_EXTENSIONS.concat(
30
33
  MockStylePreset,
31
34
  FontFamily.configure({
@@ -169,3 +172,29 @@ describe('rendering', () => {
169
172
  expect(editor.getHTML()).toMatchSnapshot();
170
173
  });
171
174
  });
175
+
176
+ describe('parsing html', () => {
177
+ test('should get value from paragraph', () => {
178
+ const editor = createEditor({
179
+ content: '<p style="font-family: Lato">test</p>'
180
+ });
181
+
182
+ expect(editor.getJSON()).toMatchSnapshot();
183
+ });
184
+
185
+ test('should get value from text', () => {
186
+ const editor = createEditor({
187
+ content: '<p><span style="font-family: Lato">lorem</span> ipsum</p>'
188
+ });
189
+
190
+ expect(editor.getJSON()).toMatchSnapshot();
191
+ });
192
+
193
+ test('should merge paragraph and text settings', () => {
194
+ const editor = createEditor({
195
+ content: '<p style="font-family: Lato"><span style="font-family: Roboto">lorem</span> ipsum</p>'
196
+ });
197
+
198
+ expect(editor.getJSON()).toMatchSnapshot();
199
+ });
200
+ });
@@ -5,6 +5,7 @@ import { createCommand } from '../../utils';
5
5
  import { CORE_EXTENSIONS } from '../core';
6
6
  import { FontSize } from '../FontSize';
7
7
  import { DeviceManager } from '../DeviceManager';
8
+ import { ContentNormalizer } from '../../services';
8
9
 
9
10
  const MockStylePreset = Extension.create({
10
11
  name: 'style_preset',
@@ -21,8 +22,10 @@ const MockStylePreset = Extension.create({
21
22
  });
22
23
 
23
24
  function createEditor({ content }) {
25
+ const normalizer = new ContentNormalizer();
26
+
24
27
  return new Editor({
25
- content,
28
+ content: normalizer.normalize(content),
26
29
  extensions: CORE_EXTENSIONS.concat(
27
30
  MockStylePreset,
28
31
  DeviceManager.configure({
@@ -181,3 +184,29 @@ describe('rendering', () => {
181
184
  expect(editor.getHTML()).toMatchSnapshot();
182
185
  });
183
186
  });
187
+
188
+ describe('parsing html', () => {
189
+ test('should get value from paragraph', () => {
190
+ const editor = createEditor({
191
+ content: '<p style="font-size: 24px">test</p>'
192
+ });
193
+
194
+ expect(editor.getJSON()).toMatchSnapshot();
195
+ });
196
+
197
+ test('should get value from text', () => {
198
+ const editor = createEditor({
199
+ content: '<p><span style="font-size: 24px">lorem</span> ipsum</p>'
200
+ });
201
+
202
+ expect(editor.getJSON()).toMatchSnapshot();
203
+ });
204
+
205
+ test('should merge paragraph and text settings', () => {
206
+ const editor = createEditor({
207
+ content: '<p style="font-size: 24px"><span style="font-size: 20px">lorem</span> ipsum</p>'
208
+ });
209
+
210
+ expect(editor.getJSON()).toMatchSnapshot();
211
+ });
212
+ });
@@ -7,6 +7,7 @@ import { FontStyle } from '../FontStyle';
7
7
  import { FontFamily } from '../FontFamily';
8
8
  import { Font } from '../../models';
9
9
  import { FontWeight } from '../FontWeight';
10
+ import { ContentNormalizer } from '../../services';
10
11
 
11
12
  const MockStylePreset = Extension.create({
12
13
  name: 'style_preset',
@@ -25,8 +26,10 @@ const MockStylePreset = Extension.create({
25
26
  });
26
27
 
27
28
  function createEditor({ content }) {
29
+ const normalizer = new ContentNormalizer();
30
+
28
31
  return new Editor({
29
- content,
32
+ content: normalizer.normalize(content),
30
33
  extensions: CORE_EXTENSIONS.concat(
31
34
  MockStylePreset,
32
35
  FontStyle,
@@ -134,3 +137,37 @@ describe('rendering', () => {
134
137
  expect(editor.getHTML()).toMatchSnapshot();
135
138
  });
136
139
  });
140
+
141
+ describe('parsing html', () => {
142
+ test('should get value from paragraph', () => {
143
+ const editor = createEditor({
144
+ content: '<p style="font-style: italic">test</p>'
145
+ });
146
+
147
+ expect(editor.getJSON()).toMatchSnapshot();
148
+ });
149
+
150
+ test('should get value from text', () => {
151
+ const editor = createEditor({
152
+ content: '<p><span style="font-style: italic">lorem</span> ipsum</p>'
153
+ });
154
+
155
+ expect(editor.getJSON()).toMatchSnapshot();
156
+ });
157
+
158
+ test('should get value from i tag', () => {
159
+ const editor = createEditor({
160
+ content: '<p><i>lorem</i> ipsum</p>'
161
+ });
162
+
163
+ expect(editor.getJSON()).toMatchSnapshot();
164
+ });
165
+
166
+ test('should merge paragraph and text settings', () => {
167
+ const editor = createEditor({
168
+ content: '<p style="font-style: italic"><span style="font-style: normal">lorem</span> ipsum</p>'
169
+ });
170
+
171
+ expect(editor.getJSON()).toMatchSnapshot();
172
+ });
173
+ });
@@ -7,6 +7,7 @@ import { Font } from '../../models';
7
7
  import { FontWeight } from '../FontWeight';
8
8
  import { FontFamily } from '../FontFamily';
9
9
  import { FontStyle } from '../FontStyle';
10
+ import { ContentNormalizer } from '../../services';
10
11
 
11
12
  const MockStylePreset = Extension.create({
12
13
  name: 'style_preset',
@@ -24,8 +25,10 @@ const MockStylePreset = Extension.create({
24
25
  });
25
26
 
26
27
  function createEditor({ content }) {
28
+ const normalizer = new ContentNormalizer();
29
+
27
30
  return new Editor({
28
- content,
31
+ content: normalizer.normalize(content),
29
32
  extensions: CORE_EXTENSIONS.concat(
30
33
  MockStylePreset,
31
34
  FontFamily.configure({
@@ -74,6 +77,18 @@ describe('get font weight', () => {
74
77
 
75
78
  expect(editor.commands.getFontWeight().value).toEqual('400');
76
79
  });
80
+
81
+ test('should get closest available font weight', () => {
82
+ const editor = createEditor({
83
+ content: createContent(NodeFactory.text('hello world', [
84
+ NodeFactory.mark('font_weight', { value: '800' })
85
+ ]))
86
+ });
87
+
88
+ editor.commands.selectAll();
89
+
90
+ expect(editor.commands.getFontWeight().value).toEqual('700');
91
+ });
77
92
  });
78
93
 
79
94
  describe('apply font weight', () => {
@@ -149,3 +164,45 @@ describe('rendering', () => {
149
164
  expect(editor.getHTML()).toMatchSnapshot();
150
165
  });
151
166
  });
167
+
168
+ describe('parsing html', () => {
169
+ test('should get value from paragraph', () => {
170
+ const editor = createEditor({
171
+ content: '<p style="font-weight: 700">test</p>'
172
+ });
173
+
174
+ expect(editor.getJSON()).toMatchSnapshot();
175
+ });
176
+
177
+ test('should get value from text', () => {
178
+ const editor = createEditor({
179
+ content: '<p><span style="font-weight: 700">lorem</span> ipsum</p>'
180
+ });
181
+
182
+ expect(editor.getJSON()).toMatchSnapshot();
183
+ });
184
+
185
+ test('should get value from b tag', () => {
186
+ const editor = createEditor({
187
+ content: '<p><b>lorem</b> ipsum</p>'
188
+ });
189
+
190
+ expect(editor.getJSON()).toMatchSnapshot();
191
+ });
192
+
193
+ test('should get value from strong tag', () => {
194
+ const editor = createEditor({
195
+ content: '<p><strong>lorem</strong> ipsum</p>'
196
+ });
197
+
198
+ expect(editor.getJSON()).toMatchSnapshot();
199
+ });
200
+
201
+ test('should merge paragraph and text settings', () => {
202
+ const editor = createEditor({
203
+ content: '<p style="font-weight: 500"><span style="font-weight: 700">lorem</span> ipsum</p>'
204
+ });
205
+
206
+ expect(editor.getJSON()).toMatchSnapshot();
207
+ });
208
+ });
@@ -5,6 +5,7 @@ import { createCommand } from '../../utils';
5
5
  import { CORE_EXTENSIONS } from '../core';
6
6
  import { DeviceManager } from '../DeviceManager';
7
7
  import { LineHeight } from '../LineHeight';
8
+ import { ContentNormalizer } from '../../services';
8
9
 
9
10
  const MockStylePreset = Extension.create({
10
11
  name: 'style_preset',
@@ -21,8 +22,10 @@ const MockStylePreset = Extension.create({
21
22
  });
22
23
 
23
24
  function createEditor({ content }) {
25
+ const normalizer = new ContentNormalizer();
26
+
24
27
  return new Editor({
25
- content,
28
+ content: normalizer.normalize(content),
26
29
  extensions: CORE_EXTENSIONS.concat(
27
30
  MockStylePreset,
28
31
  DeviceManager.configure({ deviceRef: ref('desktop') }),
@@ -104,3 +107,40 @@ describe('rendering', () => {
104
107
  expect(editor.getHTML()).toMatchSnapshot();
105
108
  });
106
109
  });
110
+
111
+ describe('parsing html', () => {
112
+ test('should get value from text in relative units', () => {
113
+ const editor = createEditor({
114
+ content: '<p style="line-height: 1.2">test</p>'
115
+ });
116
+
117
+ expect(editor.getJSON()).toMatchSnapshot();
118
+ });
119
+
120
+ test('should get value from text in px units with font size', () => {
121
+ const editor = createEditor({
122
+ content: '<p style="line-height: 24px; font-size: 20px;">test</p>'
123
+ });
124
+
125
+ expect(editor.getJSON()).toMatchSnapshot();
126
+ });
127
+
128
+ test('should get value from text in px units with no font size', () => {
129
+ global.document.body.style.fontSize = '20px';
130
+
131
+ const editor = createEditor({
132
+ content: '<p style="line-height: 24px">test</p>'
133
+ });
134
+
135
+ expect(editor.getJSON()).toMatchSnapshot();
136
+ global.document.body.style.removeProperty('font-size');
137
+ });
138
+
139
+ test('should set null if no alignment', () => {
140
+ const editor = createEditor({
141
+ content: '<p>test</p>'
142
+ });
143
+
144
+ expect(editor.getJSON()).toMatchSnapshot();
145
+ });
146
+ });
@@ -5,6 +5,7 @@ import { CORE_EXTENSIONS } from '../core';
5
5
  import { StylePreset } from '../StylePreset';
6
6
  import { List } from '../list';
7
7
  import { ListTypes, NodeTypes, TextSettings } from '../../enums';
8
+ import { ContentNormalizer } from '../../services';
8
9
 
9
10
  const MockFontSize = Mark.create({
10
11
  name: TextSettings.FONT_SIZE,
@@ -44,13 +45,16 @@ const MockAlignment = Extension.create({
44
45
 
45
46
  function createEditor({ content, presets, defaultId }) {
46
47
  return new Promise((resolve) => {
48
+ const normalizer = new ContentNormalizer();
49
+
47
50
  const editor = new Editor({
48
- content,
51
+ content: normalizer.normalize(content),
49
52
  onCreate: () => resolve(editor),
50
53
 
51
54
  extensions: CORE_EXTENSIONS.concat(
52
55
  StylePreset.configure({
53
56
  presetsRef: ref(presets),
57
+ baseClass: 'zw ts-',
54
58
  defaultId,
55
59
 
56
60
  makeVariable({ device, preset, property }) {
@@ -398,3 +402,74 @@ describe('remove preset customization', () => {
398
402
  );
399
403
  });
400
404
  });
405
+
406
+ describe('parsing html', () => {
407
+ test('should get by fallback class', async () => {
408
+ const editor = await createEditor({
409
+ content: '<p class="zpa-regular2">lorem ipsum</p>',
410
+ defaultId: 'regular-1',
411
+ presets: [
412
+ createPreset({ id: 'regular-1' }),
413
+ createPreset({ id: 'regular-2', fallbackClass: 'zpa-regular2' })
414
+ ]
415
+ });
416
+
417
+ expect(editor.getJSON()).toMatchSnapshot();
418
+ });
419
+
420
+ test('should get by preset class', async () => {
421
+ const editor = await createEditor({
422
+ content: '<p class="zw ts-regular-2">lorem ipsum</p>',
423
+ defaultId: 'regular-1',
424
+ presets: [
425
+ createPreset({ id: 'regular-1' }),
426
+ createPreset({ id: 'regular-2' })
427
+ ]
428
+ });
429
+
430
+ expect(editor.getJSON()).toMatchSnapshot();
431
+ });
432
+
433
+ test('should get by heading tag', async () => {
434
+ const editor = await createEditor({
435
+ content: '<h3>lorem ipsum</h3>',
436
+ defaultId: 'regular-1',
437
+ presets: [
438
+ createPreset({ id: 'regular-1' }),
439
+ createPreset({ id: 'h3', node: { type: 'heading', level: 3 } })
440
+ ]
441
+ });
442
+
443
+ expect(editor.getJSON()).toMatchSnapshot();
444
+ });
445
+
446
+ test('should set default preset to unstyled paragraph', async () => {
447
+ const editor = await createEditor({
448
+ content: '<p>lorem ipsum</p>',
449
+ defaultId: 'regular-1',
450
+ presets: [createPreset({ id: 'regular-1' })]
451
+ });
452
+
453
+ expect(editor.getJSON()).toMatchSnapshot();
454
+ });
455
+
456
+ test('should set null to list item', async () => {
457
+ const editor = await createEditor({
458
+ content: '<ul><li>lorem ipsum</li></ul>',
459
+ defaultId: 'regular-1',
460
+ presets: [createPreset({ id: 'regular-1' })]
461
+ });
462
+
463
+ expect(editor.getJSON()).toMatchSnapshot();
464
+ });
465
+
466
+ test('should set null to list item with preset', async () => {
467
+ const editor = await createEditor({
468
+ content: '<ul class="zw regular-1"><li>lorem ipsum</li></ul>',
469
+ defaultId: 'regular-1',
470
+ presets: [createPreset({ id: 'regular-1' })]
471
+ });
472
+
473
+ expect(editor.getJSON()).toMatchSnapshot();
474
+ });
475
+ });
@@ -4,6 +4,7 @@ import { NodeFactory } from '../../__tests__/utils';
4
4
  import { createCommand } from '../../utils';
5
5
  import { CORE_EXTENSIONS } from '../core';
6
6
  import { TextDecoration } from '../TextDecoration';
7
+ import { ContentNormalizer } from '../../services';
7
8
 
8
9
  const MockStylePreset = Extension.create({
9
10
  name: 'style_preset',
@@ -18,8 +19,10 @@ const MockStylePreset = Extension.create({
18
19
  });
19
20
 
20
21
  function createEditor({ content }) {
22
+ const normalizer = new ContentNormalizer();
23
+
21
24
  return new Editor({
22
- content,
25
+ content: normalizer.normalize(content),
23
26
  extensions: CORE_EXTENSIONS.concat(MockStylePreset, TextDecoration)
24
27
  });
25
28
  }
@@ -256,3 +259,62 @@ describe('rendering', () => {
256
259
  expect(editor.getHTML()).toMatchSnapshot();
257
260
  });
258
261
  });
262
+
263
+
264
+ describe('parsing html', () => {
265
+ test('should get underline from paragraph', () => {
266
+ const editor = createEditor({
267
+ content: '<p style="text-decoration-line: underline">test</p>'
268
+ });
269
+
270
+ expect(editor.getJSON()).toMatchSnapshot();
271
+ });
272
+
273
+ test('should get strike through from paragraph', () => {
274
+ const editor = createEditor({
275
+ content: '<p style="text-decoration-line: line-through">test</p>'
276
+ });
277
+
278
+ expect(editor.getJSON()).toMatchSnapshot();
279
+ });
280
+
281
+ test('should get both from paragraph', () => {
282
+ const editor = createEditor({
283
+ content: '<p style="text-decoration-line: line-through underline">test</p>'
284
+ });
285
+
286
+ expect(editor.getJSON()).toMatchSnapshot();
287
+ });
288
+
289
+ test('should get underline from text', () => {
290
+ const editor = createEditor({
291
+ content: '<p><span style="text-decoration-line: underline">lorem</span> ipsum</p>'
292
+ });
293
+
294
+ expect(editor.getJSON()).toMatchSnapshot();
295
+ });
296
+
297
+ test('should get strike through from text', () => {
298
+ const editor = createEditor({
299
+ content: '<p><span style="text-decoration-line: line-through">lorem</span> ipsum</p>'
300
+ });
301
+
302
+ expect(editor.getJSON()).toMatchSnapshot();
303
+ });
304
+
305
+ test('should get both from text', () => {
306
+ const editor = createEditor({
307
+ content: '<p><span style="text-decoration-line: underline line-through">lorem</span> ipsum</p>'
308
+ });
309
+
310
+ expect(editor.getJSON()).toMatchSnapshot();
311
+ });
312
+
313
+ test('should merge paragraph and text settings', () => {
314
+ const editor = createEditor({
315
+ content: '<p style="text-decoration-line: underline"><span style="text-decoration-line: line-through">lorem</span> ipsum</p>'
316
+ });
317
+
318
+ expect(editor.getJSON()).toMatchSnapshot();
319
+ });
320
+ });
@@ -24,6 +24,50 @@ Object {
24
24
  }
25
25
  `;
26
26
 
27
+ exports[`parsing html should get alignment from text 1`] = `
28
+ Object {
29
+ "content": Array [
30
+ Object {
31
+ "attrs": Object {
32
+ "alignment": Object {
33
+ "desktop": "center",
34
+ "mobile": "center",
35
+ "tablet": "center",
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
+
51
+ exports[`parsing html should set null if no alignment 1`] = `
52
+ Object {
53
+ "content": Array [
54
+ Object {
55
+ "attrs": Object {
56
+ "alignment": null,
57
+ },
58
+ "content": Array [
59
+ Object {
60
+ "text": "test",
61
+ "type": "text",
62
+ },
63
+ ],
64
+ "type": "paragraph",
65
+ },
66
+ ],
67
+ "type": "doc",
68
+ }
69
+ `;
70
+
27
71
  exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-mobile-text-align: left; --zw-tablet-text-align: right; --zw-desktop-text-align: center;\\">hello world</p>"`;
28
72
 
29
73
  exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-desktop-text-align: center;\\">hello world</p>"`;
@@ -25,4 +25,95 @@ Object {
25
25
  }
26
26
  `;
27
27
 
28
+ exports[`parsing html should get value from paragraph 1`] = `
29
+ Object {
30
+ "content": Array [
31
+ Object {
32
+ "content": Array [
33
+ Object {
34
+ "marks": Array [
35
+ Object {
36
+ "attrs": Object {
37
+ "value": "#FF0000",
38
+ },
39
+ "type": "background_color",
40
+ },
41
+ ],
42
+ "text": "test",
43
+ "type": "text",
44
+ },
45
+ ],
46
+ "type": "paragraph",
47
+ },
48
+ ],
49
+ "type": "doc",
50
+ }
51
+ `;
52
+
53
+ exports[`parsing html should get value from text 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
+
82
+ exports[`parsing html should merge paragraph and text settings 1`] = `
83
+ Object {
84
+ "content": Array [
85
+ Object {
86
+ "content": Array [
87
+ Object {
88
+ "marks": Array [
89
+ Object {
90
+ "attrs": Object {
91
+ "value": "#000000",
92
+ },
93
+ "type": "background_color",
94
+ },
95
+ ],
96
+ "text": "lorem",
97
+ "type": "text",
98
+ },
99
+ Object {
100
+ "marks": Array [
101
+ Object {
102
+ "attrs": Object {
103
+ "value": "#FF0000",
104
+ },
105
+ "type": "background_color",
106
+ },
107
+ ],
108
+ "text": " ipsum",
109
+ "type": "text",
110
+ },
111
+ ],
112
+ "type": "paragraph",
113
+ },
114
+ ],
115
+ "type": "doc",
116
+ }
117
+ `;
118
+
28
119
  exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-background-color: green;\\" class=\\"zw-style\\">hello world</span></p>"`;