@zipify/wysiwyg 4.12.0-beta.2 → 4.12.0

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 (48) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +27 -27
  3. package/dist/node.js +21 -21
  4. package/dist/types/enums/Device.d.ts +2 -1
  5. package/dist/types/enums/TextSetting.d.ts +0 -1
  6. package/dist/types/services/NodeFactory.d.ts +1 -1
  7. package/dist/types/utils/clone.d.ts +1 -0
  8. package/dist/types/utils/index.d.ts +1 -1
  9. package/dist/wysiwyg.css +28 -46
  10. package/dist/wysiwyg.mjs +184 -326
  11. package/example/ExampleApp.vue +6 -3
  12. package/example/presets.js +203 -227
  13. package/lib/components/base/NumberField.vue +2 -2
  14. package/lib/components/toolbar/controls/index.js +0 -1
  15. package/lib/components/toolbar/layouts/ToolbarDesktop.vue +0 -2
  16. package/lib/components/toolbar/layouts/ToolbarMobile.vue +0 -2
  17. package/lib/enums/Device.ts +2 -1
  18. package/lib/enums/TextSetting.ts +0 -2
  19. package/lib/extensions/Alignment.js +3 -2
  20. package/lib/extensions/DeviceManager.js +20 -3
  21. package/lib/extensions/FontSize.js +12 -6
  22. package/lib/extensions/LineHeight.js +3 -2
  23. package/lib/extensions/__tests__/Alignment.test.js +14 -2
  24. package/lib/extensions/__tests__/FontSize.test.js +14 -2
  25. package/lib/extensions/__tests__/LineHeight.test.js +14 -2
  26. package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +27 -0
  27. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +30 -0
  28. package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +27 -0
  29. package/lib/extensions/core/NodeProcessor.js +4 -2
  30. package/lib/extensions/core/__tests__/NodeProcessor.test.js +10 -1
  31. package/lib/extensions/index.js +0 -2
  32. package/lib/services/NodeFactory.ts +1 -1
  33. package/lib/styles/content.css +0 -3
  34. package/lib/utils/clone.ts +3 -0
  35. package/lib/utils/convertFontSize.js +7 -2
  36. package/lib/utils/index.ts +1 -1
  37. package/package.json +3 -2
  38. package/dist/types/components/toolbar/controls/LetterSpacingControl.vue.d.ts +0 -2
  39. package/dist/types/extensions/LetterSpacing.d.ts +0 -2
  40. package/dist/types/utils/convertEmToPx.d.ts +0 -1
  41. package/dist/types/utils/convertLetterSpacing.d.ts +0 -1
  42. package/lib/assets/icons/letter-spacing.svg +0 -3
  43. package/lib/components/toolbar/controls/LetterSpacingControl.vue +0 -96
  44. package/lib/extensions/LetterSpacing.js +0 -78
  45. package/lib/extensions/__tests__/LetterSpacing.test.js +0 -117
  46. package/lib/extensions/__tests__/__snapshots__/LetterSpacing.test.js.snap +0 -121
  47. package/lib/utils/convertEmToPx.ts +0 -8
  48. package/lib/utils/convertLetterSpacing.ts +0 -5
@@ -1,6 +1,9 @@
1
1
  <template>
2
2
  <div>
3
3
  <select class="zw-device-switcher" v-model="device">
4
+ <option value="all">
5
+ All devices
6
+ </option>
4
7
  <option value="desktop">
5
8
  Desktop
6
9
  </option>
@@ -51,7 +54,7 @@
51
54
 
52
55
  <script>
53
56
  import { computed, onMounted, ref, unref } from 'vue';
54
- import { Wysiwyg } from '@/entryLib';
57
+ import { Device, Wysiwyg } from '@/entryLib';
55
58
  import { FONTS } from './fonts';
56
59
  import { PRESETS, renderPresetVariable } from './presets';
57
60
  import { PAGE_BLOCKS } from './pageBlocks';
@@ -82,8 +85,8 @@ export default {
82
85
  const content = ref(getInitialContent());
83
86
  const presets = ref(PRESETS);
84
87
  const pageBlocks = ref(PAGE_BLOCKS);
85
- const device = ref('desktop');
86
- const updatedAt = new Date(ZW_UPDATED_AT).toLocaleString('ua-UA');
88
+ const device = ref(Device.ALL);
89
+ const updatedAt = new Date(window.ZW_UPDATED_AT).toLocaleString('ua-UA');
87
90
  const isActive = ref(false);
88
91
  const isReadonly = ref(false);
89
92
 
@@ -1,253 +1,229 @@
1
1
  export const PRESETS = [
2
2
  {
3
- id: 'h1',
4
- name: 'Heading 1',
5
- node: {
6
- type: 'heading',
7
- level: 1
8
- },
9
- desktop: {
10
- alignment: null,
11
- line_height: '1.2',
12
- letter_spacing: null,
13
- font_size: '40px'
14
- },
15
- common: {
16
- font_family: 'Lato',
17
- font_weight: '700',
18
- color: '',
19
- font_style: 'normal',
20
- text_decoration: 'none'
21
- },
22
- tablet: {
23
- alignment: null,
24
- line_height: '1.2',
25
- letter_spacing: null,
26
- font_size: '40px'
27
- },
28
- mobile: {
29
- alignment: null,
30
- line_height: '1.2',
31
- letter_spacing: null,
32
- font_size: '28px'
3
+ 'id': 'h1',
4
+ 'name': 'Heading 1',
5
+ 'node': {
6
+ 'type': 'heading',
7
+ 'level': 1
8
+ },
9
+ 'desktop': {
10
+ 'alignment': null,
11
+ 'line_height': '1.2',
12
+ 'font_size': '40px'
13
+ },
14
+ 'common': {
15
+ 'font_family': 'Lato',
16
+ 'font_weight': '700',
17
+ 'color': '',
18
+ 'font_style': 'normal',
19
+ 'text_decoration': 'none'
20
+ },
21
+ 'tablet': {
22
+ 'alignment': null,
23
+ 'line_height': '1.2',
24
+ 'font_size': '40px'
25
+ },
26
+ 'mobile': {
27
+ 'alignment': null,
28
+ 'line_height': '1.2',
29
+ 'font_size': '28px'
33
30
  }
34
31
  },
35
32
  {
36
- id: 'h2',
37
- name: 'Heading 2',
38
- node: {
39
- type: 'heading',
40
- level: 2
41
- },
42
- desktop: {
43
- alignment: null,
44
- line_height: '1.2',
45
- font_size: '32px',
46
- letter_spacing: null
47
- },
48
- common: {
49
- font_family: 'Lato',
50
- font_weight: '700',
51
- color: '#262626',
52
- font_style: 'normal',
53
- text_decoration: 'none'
54
- },
55
- tablet: {
56
- alignment: null,
57
- line_height: '1.2',
58
- font_size: '32px',
59
- letter_spacing: null
60
- },
61
- mobile: {
62
- alignment: null,
63
- line_height: '1.2',
64
- font_size: '24px',
65
- letter_spacing: null
33
+ 'id': 'h2',
34
+ 'name': 'Heading 2',
35
+ 'node': {
36
+ 'type': 'heading',
37
+ 'level': 2
38
+ },
39
+ 'desktop': {
40
+ 'alignment': null,
41
+ 'line_height': '1.2',
42
+ 'font_size': '32px'
43
+ },
44
+ 'common': {
45
+ 'font_family': 'Lato',
46
+ 'font_weight': '700',
47
+ 'color': '#262626',
48
+ 'font_style': 'normal',
49
+ 'text_decoration': 'none'
50
+ },
51
+ 'tablet': {
52
+ 'alignment': null,
53
+ 'line_height': '1.2',
54
+ 'font_size': '32px'
55
+ },
56
+ 'mobile': {
57
+ 'alignment': null,
58
+ 'line_height': '1.2',
59
+ 'font_size': '24px'
66
60
  }
67
61
  },
68
62
  {
69
- id: 'h3',
70
- name: 'Sub-heading 1',
71
- node: {
72
- type: 'heading',
73
- level: 3
74
- },
75
- desktop: {
76
- alignment: null,
77
- line_height: '1.2',
78
- font_size: '28px',
79
- letter_spacing: null
80
- },
81
- common: {
82
- font_family: 'Lato',
83
- font_weight: '700',
84
- color: '#262626',
85
- font_style: 'normal',
86
- text_decoration: 'none'
87
- },
88
- tablet: {
89
- alignment: null,
90
- line_height: '1.2',
91
- font_size: '28px',
92
- letter_spacing: null
93
- },
94
- mobile: {
95
- alignment: null,
96
- line_height: '1.2',
97
- font_size: '20px',
98
- letter_spacing: null
63
+ 'id': 'h3',
64
+ 'name': 'Sub-heading 1',
65
+ 'node': {
66
+ 'type': 'heading',
67
+ 'level': 3
68
+ },
69
+ 'desktop': {
70
+ 'alignment': null,
71
+ 'line_height': '1.2',
72
+ 'font_size': '28px'
73
+ },
74
+ 'common': {
75
+ 'font_family': 'Lato',
76
+ 'font_weight': '700',
77
+ 'color': '#262626',
78
+ 'font_style': 'normal',
79
+ 'text_decoration': 'none'
80
+ },
81
+ 'tablet': {
82
+ 'alignment': null,
83
+ 'line_height': '1.2',
84
+ 'font_size': '28px'
85
+ },
86
+ 'mobile': {
87
+ 'alignment': null,
88
+ 'line_height': '1.2',
89
+ 'font_size': '20px'
99
90
  }
100
91
  },
101
92
  {
102
- id: 'h4',
103
- name: 'Sub-heading 2',
104
- node: {
105
- type: 'heading',
106
- level: 4
107
- },
108
- desktop: {
109
- alignment: null,
110
- line_height: '1.2',
111
- font_size: '24px',
112
- letter_spacing: null
113
- },
114
- common: {
115
- font_family: 'Lato',
116
- font_weight: '700',
117
- color: '#262626',
118
- font_style: 'normal',
119
- text_decoration: 'none'
120
- },
121
- tablet: {
122
- alignment: null,
123
- line_height: '1.2',
124
- font_size: '24px',
125
- letter_spacing: null
126
- },
127
- mobile: {
128
- alignment: null,
129
- line_height: '1.2',
130
- font_size: '18px',
131
- letter_spacing: null
93
+ 'id': 'h4',
94
+ 'name': 'Sub-heading 2',
95
+ 'node': {
96
+ 'type': 'heading',
97
+ 'level': 4
98
+ },
99
+ 'desktop': {
100
+ 'alignment': null,
101
+ 'line_height': '1.2',
102
+ 'font_size': '24px'
103
+ },
104
+ 'common': {
105
+ 'font_family': 'Lato',
106
+ 'font_weight': '700',
107
+ 'color': '#262626',
108
+ 'font_style': 'normal',
109
+ 'text_decoration': 'none'
110
+ },
111
+ 'tablet': {
112
+ 'alignment': null,
113
+ 'line_height': '1.2',
114
+ 'font_size': '24px'
115
+ },
116
+ 'mobile': {
117
+ 'alignment': null,
118
+ 'line_height': '1.2',
119
+ 'font_size': '18px'
132
120
  }
133
121
  },
134
122
  {
135
- id: 'link',
136
- name: 'Link',
137
- hidden: true,
138
- desktop: {
139
- alignment: null,
140
- line_height: 'inherit',
141
- font_size: 'inherit',
142
- letter_spacing: null
143
- },
144
- common: {
145
- font_family: 'inherit',
146
- font_weight: 'inherit',
147
- color: 'rgb(0, 0, 238)',
148
- font_style: 'normal',
149
- text_decoration: 'underline'
150
- },
151
- tablet: {
152
- alignment: null,
153
- line_height: 'inherit',
154
- font_size: 'inherit',
155
- letter_spacing: null
156
- },
157
- mobile: {
158
- alignment: null,
159
- line_height: 'inherit',
160
- font_size: 'inherit',
161
- letter_spacing: null
123
+ 'id': 'link',
124
+ 'name': 'Link',
125
+ 'hidden': true,
126
+ 'desktop': {
127
+ 'alignment': null,
128
+ 'line_height': 'inherit',
129
+ 'font_size': 'inherit'
130
+ },
131
+ 'common': {
132
+ 'font_family': 'inherit',
133
+ 'font_weight': 'inherit',
134
+ 'color': 'rgb(0, 0, 238)',
135
+ 'font_style': 'normal',
136
+ 'text_decoration': 'underline'
137
+ },
138
+ 'tablet': {
139
+ 'alignment': null,
140
+ 'line_height': 'inherit',
141
+ 'font_size': 'inherit'
142
+ },
143
+ 'mobile': {
144
+ 'alignment': null,
145
+ 'line_height': 'inherit',
146
+ 'font_size': 'inherit'
162
147
  }
163
148
  },
164
149
  {
165
- id: 'regular-1',
166
- name: 'Body Copy 1',
167
- desktop: {
168
- alignment: null,
169
- line_height: '1.43',
170
- font_size: '18px',
171
- letter_spacing: 1
172
- },
173
- common: {
174
- font_family: 'Lato',
175
- font_weight: '400',
176
- color: '#262626',
177
- font_style: 'normal',
178
- text_decoration: 'none'
179
- },
180
- tablet: {
181
- alignment: null,
182
- line_height: '1.43',
183
- font_size: '18px',
184
- letter_spacing: 1
185
- },
186
- mobile: {
187
- alignment: null,
188
- line_height: '1.43',
189
- font_size: '18px',
190
- letter_spacing: 1
150
+ 'id': 'regular-1',
151
+ 'name': 'Body Copy 1',
152
+ 'desktop': {
153
+ 'alignment': null,
154
+ 'line_height': '1.43',
155
+ 'font_size': '18px'
156
+ },
157
+ 'common': {
158
+ 'font_family': 'Lato',
159
+ 'font_weight': '400',
160
+ 'color': '#262626',
161
+ 'font_style': 'normal',
162
+ 'text_decoration': 'none'
163
+ },
164
+ 'tablet': {
165
+ 'alignment': null,
166
+ 'line_height': '1.43',
167
+ 'font_size': '18px'
168
+ },
169
+ 'mobile': {
170
+ 'alignment': null,
171
+ 'line_height': '1.43',
172
+ 'font_size': '18px'
191
173
  }
192
174
  },
193
175
  {
194
- id: 'regular-2',
195
- name: 'Body Copy 2',
196
- fallbackClass: 'zpa-regular2',
197
- desktop: {
198
- alignment: null,
199
- line_height: '1.43',
200
- font_size: '16px',
201
- letter_spacing: null
202
- },
203
- common: {
204
- font_family: 'Lato',
205
- font_weight: '400',
206
- color: '#262626',
207
- font_style: 'normal',
208
- text_decoration: 'none'
209
- },
210
- tablet: {
211
- alignment: null,
212
- line_height: '1.43',
213
- font_size: '16px',
214
- letter_spacing: null
215
- },
216
- mobile: {
217
- alignment: null,
218
- line_height: '1.43',
219
- font_size: '16px',
220
- letter_spacing: null
176
+ 'id': 'regular-2',
177
+ 'name': 'Body Copy 2',
178
+ 'fallbackClass': 'zpa-regular2',
179
+ 'desktop': {
180
+ 'alignment': null,
181
+ 'line_height': '1.43',
182
+ 'font_size': '16px'
183
+ },
184
+ 'common': {
185
+ 'font_family': 'Lato',
186
+ 'font_weight': '400',
187
+ 'color': '#262626',
188
+ 'font_style': 'normal',
189
+ 'text_decoration': 'none'
190
+ },
191
+ 'tablet': {
192
+ 'alignment': null,
193
+ 'line_height': '1.43',
194
+ 'font_size': '16px'
195
+ },
196
+ 'mobile': {
197
+ 'alignment': null,
198
+ 'line_height': '1.43',
199
+ 'font_size': '16px'
221
200
  }
222
201
  },
223
202
  {
224
- id: 'regular-3',
225
- name: 'Body Copy 3',
226
- fallbackClass: 'zpa-regular3',
227
- desktop: {
228
- alignment: null,
229
- line_height: '1.43',
230
- font_size: '12px',
231
- letter_spacing: null
232
- },
233
- common: {
234
- font_family: 'Lato',
235
- font_weight: '400',
236
- color: '#262626',
237
- font_style: 'normal',
238
- text_decoration: 'none'
239
- },
240
- tablet: {
241
- alignment: null,
242
- line_height: '1.43',
243
- font_size: '12px',
244
- letter_spacing: null
245
- },
246
- mobile: {
247
- alignment: null,
248
- line_height: '1.43',
249
- font_size: '12px',
250
- letter_spacing: null
203
+ 'id': 'regular-3',
204
+ 'name': 'Body Copy 3',
205
+ 'fallbackClass': 'zpa-regular3',
206
+ 'desktop': {
207
+ 'alignment': null,
208
+ 'line_height': '1.43',
209
+ 'font_size': '12px'
210
+ },
211
+ 'common': {
212
+ 'font_family': 'Lato',
213
+ 'font_weight': '400',
214
+ 'color': '#262626',
215
+ 'font_style': 'normal',
216
+ 'text_decoration': 'none'
217
+ },
218
+ 'tablet': {
219
+ 'alignment': null,
220
+ 'line_height': '1.43',
221
+ 'font_size': '12px'
222
+ },
223
+ 'mobile': {
224
+ 'alignment': null,
225
+ 'line_height': '1.43',
226
+ 'font_size': '12px'
251
227
  }
252
228
  }
253
229
  ];
@@ -214,14 +214,14 @@ const elementClasses = computed(() => ({
214
214
  .zw-number-field__units {
215
215
  color: rgb(var(--zw-color-n70));
216
216
  font-size: var(--zw-font-size-xs);
217
+ line-height: var(--zw-line-height-md);
217
218
  text-align: center;
218
219
  display: inline-block;
219
220
  width: 100%;
220
- vertical-align: middle;
221
221
  }
222
222
 
223
223
  .zw-number-field:hover .zw-number-field__units,
224
- .zw-number-field:has(:focus, :active) .zw-number-field__units {
224
+ .zw-number-field:focus .zw-number-field__units {
225
225
  display: none;
226
226
  }
227
227
  </style>
@@ -10,7 +10,6 @@ export { default as SuperscriptControl } from './SuperscriptControl';
10
10
  export { default as CaseStyleControl } from './CaseStyleControl';
11
11
  export { default as AlignmentControl } from './AlignmentControl';
12
12
  export { default as LineHeightControl } from './LineHeightControl';
13
- export { default as LetterSpacingControl } from './LetterSpacingControl';
14
13
  export { default as ListControl } from './ListControl';
15
14
  export { default as RemoveFormatControl } from './RemoveFormatControl';
16
15
  export { LinkControl } from './link';
@@ -36,7 +36,6 @@
36
36
  <ToolbarDivider vertical />
37
37
 
38
38
  <LineHeightControl />
39
- <LetterSpacingControl />
40
39
  <ToolbarDivider vertical />
41
40
 
42
41
  <ListControl />
@@ -62,7 +61,6 @@ import {
62
61
  FontWeightControl,
63
62
  ItalicControl,
64
63
  LineHeightControl,
65
- LetterSpacingControl,
66
64
  StrikeThroughControl,
67
65
  SuperscriptControl,
68
66
  UnderlineControl,
@@ -37,7 +37,6 @@
37
37
  <ToolbarDivider vertical />
38
38
 
39
39
  <LineHeightControl />
40
- <LetterSpacingControl />
41
40
  <ToolbarDivider vertical />
42
41
 
43
42
  <ListControl />
@@ -63,7 +62,6 @@ import {
63
62
  FontWeightControl,
64
63
  ItalicControl,
65
64
  LineHeightControl,
66
- LetterSpacingControl,
67
65
  StrikeThroughControl,
68
66
  SuperscriptControl,
69
67
  UnderlineControl,
@@ -2,7 +2,8 @@ export enum Device {
2
2
  COMMON = 'common',
3
3
  DESKTOP = 'desktop',
4
4
  TABLET = 'tablet',
5
- MOBILE = 'mobile'
5
+ MOBILE = 'mobile',
6
+ ALL = 'all'
6
7
  }
7
8
 
8
9
  export const DeviceList = [
@@ -7,7 +7,6 @@ export enum TextSetting {
7
7
  FONT_STYLE = 'font_style',
8
8
  FONT_WEIGHT = 'font_weight',
9
9
  LINE_HEIGHT = 'line_height',
10
- LETTER_SPACING = 'letter_spacing',
11
10
  TEXT_DECORATION = 'text_decoration',
12
11
  SUPERSCRIPT = 'superscript',
13
12
  MARGIN = 'margin',
@@ -39,7 +38,6 @@ export const TextBlockMarkList = [
39
38
  TextSetting.FONT_SIZE,
40
39
  TextSetting.FONT_STYLE,
41
40
  TextSetting.FONT_WEIGHT,
42
- TextSetting.LETTER_SPACING,
43
41
  TextSetting.TEXT_DECORATION,
44
42
  TextSetting.SUPERSCRIPT
45
43
  ];
@@ -52,9 +52,10 @@ export const AlignmentExtension = Extension.create({
52
52
  addCommands() {
53
53
  return {
54
54
  applyAlignment: createCommand(({ commands }, value) => {
55
- const device = unref(commands.getDevice());
55
+ const targetDevices = commands.getTargetDevices();
56
+ const attrs = Object.fromEntries(targetDevices.map((device) => [device, value]));
56
57
 
57
- commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
58
+ commands.setBlockAttributes(this.name, attrs, DEFAULTS);
58
59
  }),
59
60
 
60
61
  removeAlignment: createCommand(({ commands }) => commands.removeBlockAttributes(this.name)),
@@ -1,13 +1,30 @@
1
- import { toRef } from 'vue';
1
+ import { computed, toRef, unref } from 'vue';
2
2
  import { Extension } from '@tiptap/vue-3';
3
- import { createCommand } from '../utils';
3
+ import { createCommand } from '../utils/createCommand';
4
+ import { Device } from '../enums/Device';
4
5
 
5
6
  export const DeviceManager = Extension.create({
6
7
  name: 'device_manager',
7
8
 
8
9
  addCommands() {
9
10
  return {
10
- getDevice: createCommand(() => toRef(this.options, 'device'))
11
+ getDevice: createCommand(() => {
12
+ const deviceRef = toRef(this.options, 'device');
13
+
14
+ return computed(() => {
15
+ const device = unref(deviceRef);
16
+
17
+ return device === Device.ALL ? Device.DESKTOP : device;
18
+ });
19
+ }),
20
+
21
+ getTargetDevices: createCommand(() => {
22
+ const device = unref(this.options.device);
23
+
24
+ return device === Device.ALL
25
+ ? [Device.DESKTOP, Device.TABLET, Device.MOBILE]
26
+ : [device];
27
+ })
11
28
  };
12
29
  }
13
30
  });