@zipify/wysiwyg 2.4.5 → 2.4.7-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.
@@ -4,18 +4,18 @@
4
4
  placement="bottom-end"
5
5
  placement-strategy="fixed"
6
6
  :favorite-colors="favoriteColors"
7
- :window="window"
7
+ :window="contextWindow"
8
8
  @changeFavoriteColors="updateFavoriteColors"
9
- v-model="editingColor"
10
- v-out-click="{ onOutClick: close, isDisabled: !isOpened }"
9
+ v-model="api.editingColor"
10
+ v-out-click="{ onOutClick: api.close, isDisabled: !api.isOpened }"
11
11
  >
12
12
  <template #activator>
13
13
  <slot
14
14
  name="activator"
15
- :isOpened="isOpened"
16
- :open="open"
17
- :close="close"
18
- :toggle="toggle"
15
+ :isOpened="api.isOpened"
16
+ :open="api.open"
17
+ :close="api.close"
18
+ :toggle="api.toggle"
19
19
  />
20
20
  </template>
21
21
  </ZipifyColorPicker>
@@ -23,11 +23,10 @@
23
23
 
24
24
  <script>
25
25
  import { ZipifyColorPicker } from '@zipify/colorpicker';
26
- import { inject, ref, toRef, unref } from 'vue';
26
+ import { inject, ref, toRef } from 'vue';
27
27
  import { outClick } from '../../../directives';
28
28
  import { InjectionTokens } from '../../../injectionTokens';
29
29
  import { ContextWindow } from '../../../services';
30
- import { useDeselectionLock } from '../composables';
31
30
  import { usePickerApi, usePickerHotkeys } from './composables';
32
31
 
33
32
  export default {
@@ -55,8 +54,6 @@ export default {
55
54
 
56
55
  const api = usePickerApi({
57
56
  onChange: (color) => {
58
- if (!unref(api.isOpened)) return false;
59
-
60
57
  emit('change', color);
61
58
  editor.chain().focus().restoreSelection().run();
62
59
  },
@@ -65,32 +62,22 @@ export default {
65
62
  colorRef: toRef(props, 'value'),
66
63
  pickerRef
67
64
  });
65
+ const isOpenedRef = toRef(api, 'isOpened');
68
66
 
69
67
  usePickerHotkeys({
70
- isOpenedRef: api.isOpened,
71
- onCancel: () => api.cancel(),
72
- onApply: () => api.close()
73
- });
74
-
75
- useDeselectionLock({
76
- hostRef: pickerRef,
77
- isActiveRef: api.isOpened
68
+ isOpenedRef,
69
+ onCancel: api.cancel,
70
+ onApply: api.close
78
71
  });
79
72
 
80
- function updateFavoriteColors(colors) {
81
- favoriteColors.triggerUpdate(colors);
82
- }
73
+ const updateFavoriteColors = (colors) => favoriteColors.triggerUpdate(colors);
83
74
 
84
75
  return {
85
76
  pickerRef,
86
- isOpened: api.isOpened,
87
- editingColor: api.editingColor,
88
- open: api.open,
89
- close: api.close,
90
- toggle: api.toggle,
77
+ api,
91
78
  favoriteColors: favoriteColors.listRef,
92
79
  updateFavoriteColors,
93
- window: ContextWindow.window
80
+ contextWindow: ContextWindow.window
94
81
  };
95
82
  }
96
83
  };
@@ -23,7 +23,7 @@ describe('open/close picker', () => {
23
23
  colorRef: ref('red')
24
24
  });
25
25
 
26
- expect(toggler.isOpened.value).toBe(true);
26
+ expect(toggler.isOpened).toBe(true);
27
27
  });
28
28
 
29
29
  test('should return non opened status if picker not rendered yet', () => {
@@ -34,7 +34,7 @@ describe('open/close picker', () => {
34
34
  colorRef: ref('red')
35
35
  });
36
36
 
37
- expect(toggler.isOpened.value).toBe(false);
37
+ expect(toggler.isOpened).toBe(false);
38
38
  });
39
39
 
40
40
  test('should open picker', () => {
@@ -1,4 +1,4 @@
1
- import { computed } from 'vue';
1
+ import { computed, reactive } from 'vue';
2
2
 
3
3
  export function usePickerApi({ pickerRef, colorRef, onChange, onClosed, onBeforeOpened }) {
4
4
  const isOpened = computed(() => pickerRef.value?.isVisible ?? false);
@@ -19,24 +19,28 @@ export function usePickerApi({ pickerRef, colorRef, onChange, onClosed, onBefore
19
19
  isOpened.value ? close() : open();
20
20
  }
21
21
 
22
+ function triggerChange(color) {
23
+ if (isOpened.value) onChange(color);
24
+ }
25
+
22
26
  function cancel() {
23
27
  const color = initialColor ?? colorRef.value;
24
28
 
25
- onChange(color);
29
+ triggerChange(color);
26
30
  pickerRef.value?.close(color);
27
31
  }
28
32
 
29
33
  const editingColor = computed({
30
34
  get: () => colorRef.value,
31
- set: (color) => colorRef.value !== color && onChange(color)
35
+ set: (color) => colorRef.value !== color && triggerChange(color)
32
36
  });
33
37
 
34
- return {
38
+ return reactive({
35
39
  isOpened,
36
40
  editingColor,
37
41
  open,
38
42
  close,
39
43
  toggle,
40
44
  cancel
41
- };
45
+ });
42
46
  }
@@ -4,6 +4,8 @@ import { useActivatedListener } from '../../composables';
4
4
 
5
5
  export function usePickerHotkeys({ isOpenedRef, onCancel, onApply }) {
6
6
  function useHotkey(event, handler) {
7
+ if (event.target.closest('input')) return;
8
+
7
9
  event.stopImmediatePropagation();
8
10
  event.preventDefault();
9
11
  handler();
@@ -59,9 +59,12 @@ export const Alignment = Extension.create({
59
59
  }),
60
60
 
61
61
  applyAlignment: createCommand(({ commands }, value) => {
62
- const device = unref(commands.getDevice());
62
+ // const device = unref(commands.getDevice());
63
+ //
64
+ // commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
63
65
 
64
- commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
66
+ // Temporary until release BUILDER_MODES
67
+ commands.setBlockAttributes(this.name, { desktop: value, tablet: value, mobile: value });
65
68
  }),
66
69
 
67
70
  removeAlignment: createCommand(({ commands }) => commands.removeBlockAttributes(this.name)),
@@ -2,7 +2,6 @@ import { Mark } from '@tiptap/vue-2';
2
2
  import { computed, unref } from 'vue';
3
3
  import { convertFontSize, createCommand, createKeyboardShortcut, renderMark } from '../utils';
4
4
  import { MarkGroups, TextSettings } from '../enums';
5
- import { AddNodeMarkStep } from './core';
6
5
 
7
6
  export const FontSize = Mark.create({
8
7
  name: TextSettings.FONT_SIZE,
@@ -35,31 +34,12 @@ export const FontSize = Mark.create({
35
34
  }),
36
35
 
37
36
  applyFontSize: createCommand(({ commands }, value) => {
38
- const device = unref(commands.getDevice());
37
+ // const device = unref(commands.getDevice());
39
38
 
40
- commands.applyMark(this.name, { [device]: value }, {
41
- isAppliedToParent: (parentMark, mark) => {
42
- if (parentMark.type.name !== mark.type.name) return false;
39
+ // commands.applyMark(this.name, { [device]: value });
43
40
 
44
- return parentMark.attrs[device] === mark.attrs[device];
45
- },
46
-
47
- onAppliedToParent: ({ tr, node, position, mark }) => {
48
- const attrs = { ...mark.attrs, [device]: null };
49
- const canRemove = !Object.values(attrs).some((value) => !!value);
50
-
51
- if (canRemove) return false;
52
-
53
- const updated = mark.type.create(attrs);
54
-
55
- if (node.isText) {
56
- tr.addMark(position, position + node.nodeSize, updated);
57
- return;
58
- }
59
-
60
- tr.step(new AddNodeMarkStep(position, updated));
61
- }
62
- });
41
+ // Temporary until release BUILDER_MODES
42
+ commands.applyMark(this.name, { desktop: value, tablet: value, mobile: null });
63
43
  }),
64
44
 
65
45
  increaseFontSize: createCommand(({ commands }) => {
@@ -36,7 +36,10 @@ export const LineHeight = Extension.create({
36
36
  const wrapperEl = unref(this.options.wrapperRef);
37
37
  const converted = convertLineHeight(value, element, wrapperEl);
38
38
 
39
- return converted ? { desktop: converted, tablet: converted, mobile: null } : null;
39
+ // return { desktop: converted, tablet: converted, mobile: converted };
40
+
41
+ // Temporary until release BUILDER_MODES
42
+ return { desktop: converted, tablet: converted, mobile: null };
40
43
  },
41
44
 
42
45
  renderHTML(attrs) {
@@ -72,9 +75,12 @@ export const LineHeight = Extension.create({
72
75
  }),
73
76
 
74
77
  applyLineHeight: createCommand(({ commands }, value) => {
75
- const device = unref(commands.getDevice());
78
+ // const device = unref(commands.getDevice());
79
+ //
80
+ // commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
76
81
 
77
- commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
82
+ // Temporary until release BUILDER_MODES
83
+ commands.setBlockAttributes(this.name, { desktop: value, tablet: value, mobile: null }, DEFAULTS);
78
84
  })
79
85
  };
80
86
  }
@@ -7,8 +7,8 @@ Object {
7
7
  "attrs": Object {
8
8
  "alignment": Object {
9
9
  "desktop": "right",
10
- "mobile": null,
11
- "tablet": null,
10
+ "mobile": "right",
11
+ "tablet": "right",
12
12
  },
13
13
  },
14
14
  "content": Array [
@@ -51,8 +51,8 @@ Object {
51
51
  "attrs": Object {
52
52
  "alignment": Object {
53
53
  "desktop": "right",
54
- "mobile": null,
55
- "tablet": null,
54
+ "mobile": "right",
55
+ "tablet": "right",
56
56
  },
57
57
  },
58
58
  "content": Array [
@@ -15,7 +15,7 @@ Object {
15
15
  "attrs": Object {
16
16
  "desktop": "16",
17
17
  "mobile": null,
18
- "tablet": null,
18
+ "tablet": "16",
19
19
  },
20
20
  "type": "font_size",
21
21
  },
@@ -42,7 +42,7 @@ Object {
42
42
  "attrs": Object {
43
43
  "desktop": "13",
44
44
  "mobile": null,
45
- "tablet": null,
45
+ "tablet": "13",
46
46
  },
47
47
  "type": "font_size",
48
48
  },
@@ -69,7 +69,7 @@ Object {
69
69
  "attrs": Object {
70
70
  "desktop": "15",
71
71
  "mobile": null,
72
- "tablet": null,
72
+ "tablet": "15",
73
73
  },
74
74
  "type": "font_size",
75
75
  },
@@ -96,7 +96,7 @@ Object {
96
96
  "attrs": Object {
97
97
  "desktop": "5",
98
98
  "mobile": null,
99
- "tablet": null,
99
+ "tablet": "5",
100
100
  },
101
101
  "type": "font_size",
102
102
  },
@@ -123,7 +123,7 @@ Object {
123
123
  "attrs": Object {
124
124
  "desktop": "20",
125
125
  "mobile": null,
126
- "tablet": null,
126
+ "tablet": "20",
127
127
  },
128
128
  "type": "font_size",
129
129
  },
@@ -8,7 +8,7 @@ Object {
8
8
  "line_height": Object {
9
9
  "desktop": "1.41",
10
10
  "mobile": null,
11
- "tablet": null,
11
+ "tablet": "1.41",
12
12
  },
13
13
  },
14
14
  "content": Array [
@@ -136,6 +136,9 @@ export class NodeFactory {
136
136
  * @returns {{tablet, desktop, mobile}}
137
137
  */
138
138
  static populateAllDevices(value) {
139
- return { mobile: value, tablet: value, desktop: value };
139
+ // return { mobile: value, tablet: value, desktop: value };
140
+
141
+ // Temporary until release BUILDER_MODES
142
+ return { mobile: null, tablet: value, desktop: value };
140
143
  }
141
144
  }
@@ -320,7 +320,7 @@ Object {
320
320
  exports[`build node should populate value to all devices 1`] = `
321
321
  Object {
322
322
  "desktop": "18",
323
- "mobile": "18",
323
+ "mobile": null,
324
324
  "tablet": "18",
325
325
  }
326
326
  `;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "2.4.5",
3
+ "version": "2.4.7-0",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "bin": {