@zipify/wysiwyg 1.3.0-0 → 2.0.0-1

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 (103) hide show
  1. package/.eslintrc.js +1 -1
  2. package/config/build/lib.config.js +4 -2
  3. package/dist/cli.js +10 -2
  4. package/dist/wysiwyg.css +43 -48
  5. package/dist/wysiwyg.mjs +1928 -787
  6. package/example/ExampleApp.vue +3 -1
  7. package/lib/__tests__/utils/buildTestExtensions.js +14 -0
  8. package/lib/__tests__/utils/index.js +1 -0
  9. package/lib/components/base/Button.vue +0 -7
  10. package/lib/components/base/dropdown/Dropdown.vue +1 -7
  11. package/lib/components/base/dropdown/DropdownActivator.vue +4 -19
  12. package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +1 -23
  13. package/lib/components/toolbar/controls/AlignmentControl.vue +1 -11
  14. package/lib/components/toolbar/controls/FontColorControl.vue +0 -13
  15. package/lib/components/toolbar/controls/FontFamilyControl.vue +0 -4
  16. package/lib/components/toolbar/controls/FontSizeControl.vue +1 -6
  17. package/lib/components/toolbar/controls/FontWeightControl.vue +0 -12
  18. package/lib/components/toolbar/controls/ItalicControl.vue +0 -13
  19. package/lib/components/toolbar/controls/LineHeightControl.vue +0 -14
  20. package/lib/components/toolbar/controls/StylePresetControl.vue +1 -1
  21. package/lib/components/toolbar/controls/SuperscriptControl.vue +2 -2
  22. package/lib/components/toolbar/controls/UnderlineControl.vue +0 -12
  23. package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +5 -72
  24. package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +1 -22
  25. package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +0 -1
  26. package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +0 -1
  27. package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +0 -1
  28. package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +1 -23
  29. package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +1 -23
  30. package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +2 -2
  31. package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +2 -2
  32. package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +1 -25
  33. package/lib/composables/__tests__/useEditor.test.js +2 -2
  34. package/lib/enums/TextSettings.js +5 -5
  35. package/lib/extensions/BackgroundColor.js +4 -4
  36. package/lib/extensions/FontColor.js +4 -5
  37. package/lib/extensions/FontFamily.js +4 -5
  38. package/lib/extensions/FontSize.js +5 -7
  39. package/lib/extensions/FontStyle.js +13 -11
  40. package/lib/extensions/FontWeight.js +6 -9
  41. package/lib/extensions/Link.js +1 -1
  42. package/lib/extensions/StylePreset.js +1 -15
  43. package/lib/extensions/Superscript.js +23 -1
  44. package/lib/extensions/TextDecoration.js +16 -20
  45. package/lib/extensions/__tests__/Alignment.test.js +10 -7
  46. package/lib/extensions/__tests__/BackgroundColor.test.js +6 -3
  47. package/lib/extensions/__tests__/CaseStyle.test.js +11 -7
  48. package/lib/extensions/__tests__/FontColor.test.js +6 -3
  49. package/lib/extensions/__tests__/FontFamily.test.js +29 -22
  50. package/lib/extensions/__tests__/FontSize.test.js +24 -17
  51. package/lib/extensions/__tests__/FontStyle.test.js +22 -16
  52. package/lib/extensions/__tests__/FontWeight.test.js +28 -21
  53. package/lib/extensions/__tests__/LineHeight.test.js +14 -11
  54. package/lib/extensions/__tests__/Link.test.js +14 -10
  55. package/lib/extensions/__tests__/Margin.test.js +2 -2
  56. package/lib/extensions/__tests__/StylePreset.test.js +49 -100
  57. package/lib/extensions/__tests__/TextDecoration.test.js +59 -37
  58. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +25 -25
  59. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +25 -25
  60. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +105 -105
  61. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +72 -72
  62. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +54 -46
  63. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +77 -77
  64. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +68 -3
  65. package/lib/extensions/core/Document.js +5 -0
  66. package/lib/extensions/core/Heading.js +10 -0
  67. package/lib/extensions/core/NodeProcessor.js +112 -10
  68. package/lib/extensions/core/Paragraph.js +9 -0
  69. package/lib/extensions/core/TextProcessor.js +9 -16
  70. package/lib/extensions/core/__tests__/NodeProcessor.test.js +137 -10
  71. package/lib/extensions/core/__tests__/SelectionProcessor.test.js +2 -2
  72. package/lib/extensions/core/__tests__/TextProcessor.test.js +18 -41
  73. package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +192 -0
  74. package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +7 -27
  75. package/lib/extensions/core/index.js +5 -5
  76. package/lib/extensions/core/steps/AddNodeMarkStep.js +60 -0
  77. package/lib/extensions/core/steps/AttrStep.js +54 -0
  78. package/lib/extensions/core/steps/RemoveNodeMarkStep.js +50 -0
  79. package/lib/extensions/core/steps/index.js +3 -0
  80. package/lib/extensions/list/List.js +1 -0
  81. package/lib/extensions/list/ListItem.js +5 -0
  82. package/lib/extensions/list/__tests__/List.test.js +30 -25
  83. package/lib/services/NodeFactory.js +25 -21
  84. package/lib/services/index.js +1 -1
  85. package/lib/services/normalizer/BaseNormalizer.js +11 -0
  86. package/lib/services/{BrowserDomParser.js → normalizer/BrowserDomParser.js} +0 -0
  87. package/lib/services/normalizer/ContentNormalizer.js +24 -0
  88. package/lib/services/normalizer/HtmlNormalizer.js +245 -0
  89. package/lib/services/normalizer/JsonNormalizer.js +81 -0
  90. package/lib/services/{__tests__/ContentNormalizer.test.js → normalizer/__tests__/HtmlNormalizer.test.js} +27 -67
  91. package/lib/services/normalizer/__tests__/JsonNormalizer.test.js +70 -0
  92. package/lib/services/normalizer/__tests__/__snapshots__/JsonNormalizer.test.js.snap +159 -0
  93. package/lib/services/normalizer/index.js +1 -0
  94. package/lib/styles/content.css +8 -0
  95. package/lib/utils/findMarkByType.js +5 -0
  96. package/lib/utils/index.js +5 -0
  97. package/lib/utils/isMarkAppliedToParent.js +10 -0
  98. package/lib/utils/isNodeFullySelected.js +10 -0
  99. package/lib/utils/resolveNodePosition.js +6 -0
  100. package/lib/utils/resolveTextPosition.js +6 -0
  101. package/package.json +3 -1
  102. package/lib/assets/icons/indicator.svg +0 -5
  103. package/lib/services/ContentNormalizer.js +0 -293
@@ -103,8 +103,10 @@ export default {
103
103
 
104
104
  if (content) {
105
105
  sessionStorage.setItem('wswg-data', content);
106
- window.location.reload();
106
+ } else {
107
+ sessionStorage.removeItem('wswg-data');
107
108
  }
109
+ window.location.reload();
108
110
  }
109
111
 
110
112
  document.addEventListener('click', (event) => {
@@ -0,0 +1,14 @@
1
+ import { Mark } from '@tiptap/vue-2';
2
+ import { buildCoreExtensions } from '../../extensions/core';
3
+
4
+ // each node allows using 'settings' group of marks,
5
+ // and it fails when there are no nodes with this group
6
+ const SettingMark = Mark.create({
7
+ name: 'placeholder_setting',
8
+ group: 'settings',
9
+ renderHTML: () => []
10
+ });
11
+
12
+ export function buildTestExtensions({ include } = {}) {
13
+ return buildCoreExtensions().concat(SettingMark, include || []);
14
+ }
@@ -1,3 +1,4 @@
1
1
  export { waitAsyncOperation } from './waitAsyncOperation';
2
2
  export { withComponentContext } from './withComponentContext';
3
3
  export { setReadonlyProperty } from './setReadonlyProperty';
4
+ export { buildTestExtensions } from './buildTestExtensions';
@@ -135,11 +135,4 @@ export default {
135
135
  color: rgb(var(--zw-color-white));
136
136
  background-color: rgb(var(--zw-color-n5));
137
137
  }
138
-
139
- .zw-button__customized-indicator {
140
- display: inline-block !important;
141
- position: absolute;
142
- top: calc(0px - var(--zw-offset-xxs));
143
- right: 2px;
144
- }
145
138
  </style>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="zw-dropdown" ref="dropdownRef">
3
- <DropdownActivator :color="color" :is-customized="isCustomized">
3
+ <DropdownActivator :color="color">
4
4
  <template #default="attrs">
5
5
  <slot name="activator" v-bind="attrs" />
6
6
  </template>
@@ -60,12 +60,6 @@ export default {
60
60
  type: String,
61
61
  required: false,
62
62
  default: 'none'
63
- },
64
-
65
- isCustomized: {
66
- type: Boolean,
67
- required: false,
68
- default: false
69
63
  }
70
64
  },
71
65
 
@@ -12,14 +12,6 @@
12
12
  {{ activeOptionTitle }}
13
13
  </span>
14
14
 
15
- <Icon
16
- v-if="isCustomized"
17
- class="zw-dropdown__customized-indicator"
18
- name="indicator"
19
- size="9px"
20
- data-test-selector="customizedIndicator"
21
- />
22
-
23
15
  <Icon
24
16
  class="zw-dropdown__activator-arrow"
25
17
  name="arrow"
@@ -55,12 +47,6 @@ export default {
55
47
  type: String,
56
48
  required: false,
57
49
  default: 'none'
58
- },
59
-
60
- isCustomized: {
61
- type: Boolean,
62
- required: false,
63
- default: false
64
50
  }
65
51
  },
66
52
 
@@ -91,6 +77,10 @@ export default {
91
77
  width: 100%;
92
78
  }
93
79
 
80
+ .zw-dropdown__activator-title {
81
+ margin-right: var(--zw-offset-xs);
82
+ }
83
+
94
84
  .zw-dropdown__activator-arrow {
95
85
  margin-left: auto;
96
86
  }
@@ -104,9 +94,4 @@ export default {
104
94
  font-size: var(--zw-font-size-xxs);
105
95
  color: rgb(var(--zw-color-white));
106
96
  }
107
-
108
- .zw-dropdown__customized-indicator {
109
- position: relative;
110
- top: calc(0px - var(--zw-offset-xs));
111
- }
112
97
  </style>
@@ -4,10 +4,6 @@ import DropdownActivator from '../DropdownActivator';
4
4
  import { InjectionTokens } from '../injectionTokens';
5
5
  import Button from '../../Button';
6
6
 
7
- const SELECTORS = {
8
- INDICATOR: '[data-test-selector="customizedIndicator"]'
9
- };
10
-
11
7
  const createToggler = ({ isOpened } = {}) => ({
12
8
  isOpened: ref(isOpened ?? false),
13
9
  open: jest.fn()
@@ -17,12 +13,8 @@ const createActiveOptionManager = ({ activeOption } = {}) => ({
17
13
  activeOption: ref(activeOption ?? { id: 'test' })
18
14
  });
19
15
 
20
- function createComponent({ toggler, isCustomized, activeOptionManager } = {}) {
16
+ function createComponent({ toggler, activeOptionManager } = {}) {
21
17
  return shallowMount(DropdownActivator, {
22
- propsData: {
23
- isCustomized: ref(isCustomized ?? false)
24
- },
25
-
26
18
  provide: {
27
19
  [InjectionTokens.TOGGLER]: toggler ?? createToggler(),
28
20
  [InjectionTokens.ACTIVE_MANAGER]: activeOptionManager ?? createActiveOptionManager()
@@ -48,20 +40,6 @@ describe('rendering', () => {
48
40
  expect(buttonWrapper.props('active')).toBe(false);
49
41
  expect(buttonWrapper.classes('zw-dropdown__activator--active')).toBeFalsy();
50
42
  });
51
-
52
- test('should render indicator of customized styles', () => {
53
- const toggler = createToggler({ isOpened: false });
54
- const wrapper = createComponent({ toggler, isCustomized: true });
55
-
56
- expect(wrapper).toVueContainComponent(SELECTORS.INDICATOR);
57
- });
58
-
59
- test('should not render indicator of customized styles', () => {
60
- const toggler = createToggler({ isOpened: false });
61
- const wrapper = createComponent({ toggler });
62
-
63
- expect(wrapper).not.toVueContainComponent(SELECTORS.INDICATOR);
64
- });
65
43
  });
66
44
 
67
45
  describe('open dropdown', () => {
@@ -2,20 +2,12 @@
2
2
  <ButtonToggle :value="currentValue" :options="$options.alignments" @change="apply">
3
3
  <template #option="{ isActive, option, activate }">
4
4
  <Button
5
- class="zw-position--relative"
6
5
  icon
7
6
  skin="toolbar"
8
7
  :active="isActive"
9
8
  @click="activate"
10
9
  v-tooltip="option.tooltip"
11
10
  >
12
- <Icon
13
- v-if="isCustomized && isActive"
14
- class="zw-button__customized-indicator"
15
- name="indicator"
16
- size="9px"
17
- data-test-selector="customizedIndicator"
18
- />
19
11
  <Icon :name="`alignment-${option.id}`" size="28px" auto-color />
20
12
  </Button>
21
13
  </template>
@@ -25,7 +17,7 @@
25
17
  <script>
26
18
  import { inject } from 'vue';
27
19
  import { InjectionTokens } from '../../../injectionTokens';
28
- import { Alignments, TextSettings } from '../../../enums';
20
+ import { Alignments } from '../../../enums';
29
21
  import { ButtonToggle, Button, Icon } from '../../base';
30
22
  import { tooltip } from '../../../directives';
31
23
 
@@ -65,7 +57,6 @@ export default {
65
57
  const editor = inject(InjectionTokens.EDITOR);
66
58
 
67
59
  const currentValue = editor.commands.getAlignment();
68
- const isCustomized = editor.commands.isSettingCustomized('attributes', TextSettings.ALIGNMENT);
69
60
 
70
61
  function apply(value) {
71
62
  editor.chain().focus().applyAlignment(value).run();
@@ -74,7 +65,6 @@ export default {
74
65
 
75
66
  return {
76
67
  currentValue,
77
- isCustomized,
78
68
  apply
79
69
  };
80
70
  }
@@ -2,7 +2,6 @@
2
2
  <ColorPicker :value="currentValue" @change="apply">
3
3
  <template #activator="{ toggle, isOpened }">
4
4
  <Button
5
- class="zw-position--relative"
6
5
  icon
7
6
  skin="toolbar"
8
7
  :active="isOpened"
@@ -10,14 +9,6 @@
10
9
  v-tooltip="'Font Color'"
11
10
  >
12
11
  <Icon name="font-color" size="28px" auto-color />
13
-
14
- <Icon
15
- v-if="isCustomized"
16
- class="zw-button__customized-indicator"
17
- name="indicator"
18
- size="9px"
19
- data-test-selector="customizedIndicator"
20
- />
21
12
  </Button>
22
13
  </template>
23
14
  </ColorPicker>
@@ -28,7 +19,6 @@ import { inject } from 'vue';
28
19
  import { ColorPicker, Button, Icon } from '../../base';
29
20
  import { InjectionTokens } from '../../../injectionTokens';
30
21
  import { tooltip } from '../../../directives';
31
- import { TextSettings } from '../../../enums';
32
22
 
33
23
  export default {
34
24
  name: 'FontColorControl',
@@ -47,13 +37,10 @@ export default {
47
37
  const editor = inject(InjectionTokens.EDITOR);
48
38
 
49
39
  const currentValue = editor.commands.getFontColor();
50
- const isCustomized = editor.commands.isSettingCustomized('marks', TextSettings.FONT_COLOR);
51
-
52
40
  const apply = (color) => editor.chain().applyFontColor(color).run();
53
41
 
54
42
  return {
55
43
  currentValue,
56
- isCustomized,
57
44
  apply
58
45
  };
59
46
  }
@@ -3,7 +3,6 @@
3
3
  class="zw-font-family-control"
4
4
  :options="options"
5
5
  :value="currentValue"
6
- :is-customized="isCustomized"
7
6
  @change="apply"
8
7
  v-tooltip="'Font Name'"
9
8
  >
@@ -23,7 +22,6 @@ import { computed, inject } from 'vue';
23
22
  import { InjectionTokens } from '../../../injectionTokens';
24
23
  import { tooltip } from '../../../directives';
25
24
  import { Dropdown, DropdownOption } from '../../base';
26
- import { TextSettings } from '../../../enums';
27
25
  import { useRecentFonts } from './composables';
28
26
 
29
27
  export default {
@@ -69,7 +67,6 @@ export default {
69
67
  }
70
68
 
71
69
  const currentValue = editor.commands.getFontFamily();
72
- const isCustomized = editor.commands.isSettingCustomized('marks', TextSettings.FONT_FAMILY);
73
70
 
74
71
  const apply = (fontFamily) => {
75
72
  recentFontNames.add(fontFamily);
@@ -79,7 +76,6 @@ export default {
79
76
  return {
80
77
  options,
81
78
  currentValue,
82
- isCustomized,
83
79
  renderOptionStyles,
84
80
  apply
85
81
  };
@@ -3,7 +3,6 @@
3
3
  class="zw-font-size-control"
4
4
  :options="options"
5
5
  :value="currentValue"
6
- :is-customized="isCustomized"
7
6
  @change="apply"
8
7
  v-tooltip="{ text: 'Font Size', hotkey: 'Mod Shift +/-' }"
9
8
  />
@@ -14,7 +13,6 @@ import { computed, inject } from 'vue';
14
13
  import { Dropdown } from '../../base';
15
14
  import { InjectionTokens } from '../../../injectionTokens';
16
15
  import { tooltip } from '../../../directives';
17
- import { TextSettings } from '../../../enums';
18
16
 
19
17
  export default {
20
18
  name: 'FontSizeControl',
@@ -36,14 +34,11 @@ export default {
36
34
  });
37
35
 
38
36
  const currentValue = editor.commands.getFontSize();
39
- const isCustomized = editor.commands.isSettingCustomized('marks', TextSettings.FONT_SIZE);
40
-
41
37
  const apply = (value) => editor.chain().focus().applyFontSize(value).run();
42
38
 
43
39
  return {
44
40
  options,
45
41
  currentValue,
46
- isCustomized,
47
42
  apply
48
43
  };
49
44
  }
@@ -52,6 +47,6 @@ export default {
52
47
 
53
48
  <style scoped>
54
49
  .zw-font-size-control {
55
- width: 72px;
50
+ width: 64px;
56
51
  }
57
52
  </style>
@@ -1,9 +1,7 @@
1
1
  <template>
2
2
  <Dropdown
3
- class="zw-font-weight-control"
4
3
  :options="options"
5
4
  :value="currentValue"
6
- :is-customized="isCustomized"
7
5
  @change="apply"
8
6
  v-tooltip="{ text: 'Font Weight', hotkey: 'Mod B' }"
9
7
  />
@@ -14,7 +12,6 @@ import { computed, inject, unref } from 'vue';
14
12
  import { InjectionTokens } from '../../../injectionTokens';
15
13
  import { Dropdown } from '../../base';
16
14
  import { tooltip } from '../../../directives';
17
- import { TextSettings } from '../../../enums';
18
15
 
19
16
  export default {
20
17
  name: 'FontWeightControl',
@@ -32,24 +29,15 @@ export default {
32
29
  const font = editor.commands.getFont();
33
30
 
34
31
  const options = computed(() => unref(font).weights.map((style) => ({ id: style })));
35
-
36
32
  const currentValue = editor.commands.getFontWeight();
37
- const isCustomized = editor.commands.isSettingCustomized('marks', TextSettings.FONT_WEIGHT);
38
33
 
39
34
  const apply = (value) => editor.chain().focus().applyFontWeight(value).run();
40
35
 
41
36
  return {
42
37
  options,
43
38
  currentValue,
44
- isCustomized,
45
39
  apply
46
40
  };
47
41
  }
48
42
  };
49
43
  </script>
50
-
51
- <style scoped>
52
- .zw-font-weight-control {
53
- width: 60px;
54
- }
55
- </style>
@@ -1,6 +1,5 @@
1
1
  <template>
2
2
  <Button
3
- class="zw-position--relative"
4
3
  skin="toolbar"
5
4
  icon
6
5
  :active="currentValue"
@@ -9,14 +8,6 @@
9
8
  v-tooltip="{ text: 'Italic', hotkey: 'Mod I' }"
10
9
  >
11
10
  <Icon name="italic" size="28px" auto-color />
12
-
13
- <Icon
14
- v-if="isCustomized"
15
- class="zw-button__customized-indicator"
16
- name="indicator"
17
- size="9px"
18
- data-test-selector="customizedIndicator"
19
- />
20
11
  </Button>
21
12
  </template>
22
13
 
@@ -25,7 +16,6 @@ import { inject } from 'vue';
25
16
  import { Button, Icon } from '../../base';
26
17
  import { InjectionTokens } from '../../../injectionTokens';
27
18
  import { tooltip } from '../../../directives';
28
- import { TextSettings } from '../../../enums';
29
19
 
30
20
  export default {
31
21
  name: 'ItalicControl',
@@ -43,15 +33,12 @@ export default {
43
33
  const editor = inject(InjectionTokens.EDITOR);
44
34
 
45
35
  const currentValue = editor.commands.isItalic();
46
- const isCustomized = editor.commands.isSettingCustomized('marks', TextSettings.FONT_STYLE);
47
-
48
36
  const isAvailable = editor.commands.isItalicAvailable();
49
37
  const apply = () => editor.chain().focus().toggleItalic().run();
50
38
 
51
39
  return {
52
40
  isAvailable,
53
41
  currentValue,
54
- isCustomized,
55
42
  apply
56
43
  };
57
44
  }
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <div class="zw-position--relative" ref="wrapperRef">
3
3
  <Button
4
- class="zw-position--relative"
5
4
  icon
6
5
  skin="toolbar"
7
6
  :active="isOpened"
@@ -9,14 +8,6 @@
9
8
  v-tooltip="'Line Height'"
10
9
  >
11
10
  <Icon name="line-height" size="28px" auto-color />
12
-
13
- <Icon
14
- v-if="isCustomized"
15
- class="zw-button__customized-indicator"
16
- name="indicator"
17
- size="9px"
18
- data-test-selector="customizedIndicator"
19
- />
20
11
  </Button>
21
12
 
22
13
  <Modal class="zw-line-height-control__modal" ref="modalRef" :toggler="toggler">
@@ -53,7 +44,6 @@ import { inject, ref } from 'vue';
53
44
  import { Button, Icon, Modal, Range, NumberField, FieldLabel, useModalToggler } from '../../base';
54
45
  import { InjectionTokens } from '../../../injectionTokens';
55
46
  import { tooltip } from '../../../directives';
56
- import { TextSettings } from '../../../enums';
57
47
 
58
48
  export default {
59
49
  name: 'LineHeightControl',
@@ -76,17 +66,13 @@ export default {
76
66
  const modalRef = ref(null);
77
67
  const editor = inject(InjectionTokens.EDITOR);
78
68
  const toggler = useModalToggler({ wrapperRef, modalRef });
79
-
80
69
  const currentValue = editor.commands.getLineHeight();
81
- const isCustomized = editor.commands.isSettingCustomized('attributes', TextSettings.LINE_HEIGHT);
82
-
83
70
  const apply = (value) => editor.commands.applyLineHeight(String(value));
84
71
 
85
72
  return {
86
73
  wrapperRef,
87
74
  modalRef,
88
75
  isOpened: toggler.isOpened,
89
- isCustomized,
90
76
  toggler,
91
77
  currentValue,
92
78
  apply
@@ -68,7 +68,7 @@ export default {
68
68
  .applyPreset(value)
69
69
  .storeSelection()
70
70
  .expandSelectionToBlock()
71
- .unsetMarks(CLEAR_MARKS)
71
+ .removeMarks(CLEAR_MARKS)
72
72
  .restoreSelection()
73
73
  .run();
74
74
  };
@@ -11,7 +11,7 @@
11
11
  </template>
12
12
 
13
13
  <script>
14
- import { computed, inject } from 'vue';
14
+ import { inject } from 'vue';
15
15
  import { Button, Icon } from '../../base';
16
16
  import { InjectionTokens } from '../../../injectionTokens';
17
17
  import { tooltip } from '../../../directives';
@@ -31,7 +31,7 @@ export default {
31
31
  setup() {
32
32
  const editor = inject(InjectionTokens.EDITOR);
33
33
 
34
- const currentValue = computed(() => editor.isActive('superscript'));
34
+ const currentValue = editor.commands.isSuperscript();
35
35
  const apply = () => editor.chain().focus().toggleSuperscript().run();
36
36
 
37
37
  return {
@@ -1,6 +1,5 @@
1
1
  <template>
2
2
  <Button
3
- class="zw-position--relative"
4
3
  skin="toolbar"
5
4
  icon
6
5
  :active="currentValue"
@@ -8,14 +7,6 @@
8
7
  v-tooltip="{ text: 'Underline', hotkey: 'Mod U' }"
9
8
  >
10
9
  <Icon name="underline" size="28px" auto-color />
11
-
12
- <Icon
13
- v-if="isCustomized"
14
- class="zw-button__customized-indicator"
15
- name="indicator"
16
- size="9px"
17
- data-test-selector="customizedIndicator"
18
- />
19
10
  </Button>
20
11
  </template>
21
12
 
@@ -41,13 +32,10 @@ export default {
41
32
  const editor = inject(InjectionTokens.EDITOR);
42
33
 
43
34
  const currentValue = editor.commands.isUnderline();
44
- const isCustomized = editor.commands.isUnderlineCustomized();
45
-
46
35
  const apply = () => editor.chain().focus().toggleUnderline().run();
47
36
 
48
37
  return {
49
38
  currentValue,
50
- isCustomized,
51
39
  apply
52
40
  };
53
41
  }
@@ -5,14 +5,9 @@ import { Alignments } from '../../../../enums';
5
5
  import { ButtonToggle } from '../../../base';
6
6
  import AlignmentControl from '../AlignmentControl';
7
7
 
8
- const SELECTORS = {
9
- INDICATOR: '[data-test-selector="customizedIndicator"]'
10
- };
11
-
12
- const createEditor = ({ alignment, isSettingCustomized } = {}) => ({
8
+ const createEditor = ({ alignment } = {}) => ({
13
9
  commands: {
14
10
  getAlignment: () => ref(alignment),
15
- isSettingCustomized: () => ref(isSettingCustomized ?? false),
16
11
  focus: jest.fn().mockReturnThis(),
17
12
  applyAlignment: jest.fn().mockReturnThis(),
18
13
  run: jest.fn()
@@ -23,18 +18,11 @@ const createEditor = ({ alignment, isSettingCustomized } = {}) => ({
23
18
  }
24
19
  });
25
20
 
26
- function createComponent({ editor, slotParams }) {
21
+ function createComponent({ editor }) {
27
22
  return shallowMount(AlignmentControl, {
28
23
  stubs: {
29
24
  ButtonToggle: {
30
- render() {
31
- const children = this.$scopedSlots.option({
32
- ...slotParams,
33
- activate: jest.fn()
34
- });
35
-
36
- return h('div', null, children);
37
- },
25
+ render: () => h('div'),
38
26
  props: ['value']
39
27
  }
40
28
  },
@@ -45,16 +33,7 @@ function createComponent({ editor, slotParams }) {
45
33
  describe('selection value', () => {
46
34
  test('should render value from selection', () => {
47
35
  const editor = createEditor({ alignment: Alignments.RIGHT });
48
- const wrapper = createComponent({
49
- editor,
50
- slotParams: {
51
- option: {
52
- id: Alignments.RIGHT,
53
- tooltip: { text: 'Align Right', hotkey: 'Mod Shift R' }
54
- },
55
- isActive: true
56
- }
57
- });
36
+ const wrapper = createComponent({ editor });
58
37
  const buttonWrapper = wrapper.findComponent(ButtonToggle);
59
38
 
60
39
  expect(buttonWrapper.props('value')).toBe(Alignments.RIGHT);
@@ -62,16 +41,7 @@ describe('selection value', () => {
62
41
 
63
42
  test('should apply new value', () => {
64
43
  const editor = createEditor({ alignment: Alignments.RIGHT });
65
- const wrapper = createComponent({
66
- editor,
67
- slotParams: {
68
- option: {
69
- id: Alignments.RIGHT,
70
- tooltip: { text: 'Align Right', hotkey: 'Mod Shift R' }
71
- },
72
- isActive: true
73
- }
74
- });
44
+ const wrapper = createComponent({ editor });
75
45
  const buttonWrapper = wrapper.findComponent(ButtonToggle);
76
46
 
77
47
  buttonWrapper.vm.$emit('change', Alignments.CENTER);
@@ -79,40 +49,3 @@ describe('selection value', () => {
79
49
  expect(editor.commands.applyAlignment).toHaveBeenCalledWith(Alignments.CENTER);
80
50
  });
81
51
  });
82
-
83
- describe('render indicator of customized styles', () => {
84
- test('should render indicator', () => {
85
- const editor = createEditor({
86
- alignment: Alignments.LEFT,
87
- isSettingCustomized: true
88
- });
89
- const wrapper = createComponent({
90
- editor,
91
- slotParams: {
92
- option: {
93
- id: Alignments.LEFT,
94
- tooltip: { text: 'Align Left', hotkey: 'Mod Shift L' }
95
- },
96
- isActive: true
97
- }
98
- });
99
-
100
- expect(wrapper).toVueContainComponent(SELECTORS.INDICATOR);
101
- });
102
-
103
- test('should not render indicator', () => {
104
- const editor = createEditor({ alignment: Alignments.LEFT });
105
- const wrapper = createComponent({
106
- editor,
107
- slotParams: {
108
- option: {
109
- id: Alignments.LEFT,
110
- tooltip: { text: 'Align Left', hotkey: 'Mod Shift L' }
111
- },
112
- isActive: true
113
- }
114
- });
115
-
116
- expect(wrapper).not.toVueContainComponent(SELECTORS.INDICATOR);
117
- });
118
- });
@@ -4,14 +4,9 @@ import { InjectionTokens } from '../../../../injectionTokens';
4
4
  import { ColorPicker } from '../../../base';
5
5
  import FontColorControl from '../FontColorControl';
6
6
 
7
- const SELECTORS = {
8
- INDICATOR: '[data-test-selector="customizedIndicator"]'
9
- };
10
-
11
- const createEditor = ({ fontColor, isSettingCustomized } = {}) => ({
7
+ const createEditor = ({ fontColor } = {}) => ({
12
8
  commands: {
13
9
  getFontColor: () => ref(fontColor),
14
- isSettingCustomized: () => ref( isSettingCustomized ?? false),
15
10
  focus: jest.fn().mockReturnThis(),
16
11
  applyFontColor: jest.fn().mockReturnThis(),
17
12
  run: jest.fn()
@@ -62,19 +57,3 @@ describe('selection value', () => {
62
57
  expect(editor.commands.applyFontColor).toHaveBeenCalledWith('green');
63
58
  });
64
59
  });
65
-
66
- describe('render indicator of customized styles', () => {
67
- test('should render indicator', () => {
68
- const editor = createEditor({ fontColor: 'red', isSettingCustomized: true });
69
- const wrapper = createComponent({ editor });
70
-
71
- expect(wrapper).toVueContainComponent(SELECTORS.INDICATOR);
72
- });
73
-
74
- test('should not render indicator', () => {
75
- const editor = createEditor({ fontColor: 'red' });
76
- const wrapper = createComponent({ editor });
77
-
78
- expect(wrapper).not.toVueContainComponent(SELECTORS.INDICATOR);
79
- });
80
- });
@@ -7,7 +7,6 @@ import FontFamilyControl from '../FontFamilyControl';
7
7
  const createEditor = ({ fontFamily } = {}) => ({
8
8
  commands: {
9
9
  getFontFamily: () => ref(fontFamily),
10
- isSettingCustomized: () => ref(false),
11
10
  focus: jest.fn().mockReturnThis(),
12
11
  applyFontFamily: jest.fn().mockReturnThis(),
13
12
  run: jest.fn()