@zipify/wysiwyg 1.2.5 → 1.3.0-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.
- package/dist/cli.js +2 -2
- package/dist/wysiwyg.css +42 -31
- package/dist/wysiwyg.mjs +125 -33
- package/lib/assets/icons/indicator.svg +5 -0
- package/lib/components/base/Button.vue +7 -0
- package/lib/components/base/dropdown/Dropdown.vue +7 -1
- package/lib/components/base/dropdown/DropdownActivator.vue +19 -4
- package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +23 -1
- package/lib/components/toolbar/controls/AlignmentControl.vue +11 -1
- package/lib/components/toolbar/controls/FontColorControl.vue +13 -0
- package/lib/components/toolbar/controls/FontFamilyControl.vue +4 -0
- package/lib/components/toolbar/controls/FontSizeControl.vue +6 -1
- package/lib/components/toolbar/controls/FontWeightControl.vue +12 -0
- package/lib/components/toolbar/controls/ItalicControl.vue +13 -0
- package/lib/components/toolbar/controls/LineHeightControl.vue +14 -0
- package/lib/components/toolbar/controls/UnderlineControl.vue +12 -0
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +72 -5
- package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +22 -1
- package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +1 -0
- package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +1 -0
- package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +1 -0
- package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +23 -1
- package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +23 -1
- package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +25 -1
- package/lib/extensions/StylePreset.js +6 -0
- package/lib/extensions/TextDecoration.js +7 -0
- package/lib/extensions/__tests__/StylePreset.test.js +51 -0
- package/lib/extensions/__tests__/TextDecoration.test.js +20 -0
- package/package.json +1 -1
|
@@ -4,9 +4,14 @@ import { InjectionTokens } from '../../../../injectionTokens';
|
|
|
4
4
|
import { Button } from '../../../base';
|
|
5
5
|
import ItalicControl from '../ItalicControl';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const SELECTORS = {
|
|
8
|
+
INDICATOR: '[data-test-selector="customizedIndicator"]'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const createEditor = ({ isItalic, isItalicAvailable, isSettingCustomized } = {}) => ({
|
|
8
12
|
commands: {
|
|
9
13
|
isItalic: () => ref(isItalic),
|
|
14
|
+
isSettingCustomized: () => ref(isSettingCustomized ?? false),
|
|
10
15
|
isItalicAvailable: () => ref(isItalicAvailable ?? true),
|
|
11
16
|
focus: jest.fn().mockReturnThis(),
|
|
12
17
|
toggleItalic: jest.fn().mockReturnThis(),
|
|
@@ -40,6 +45,23 @@ describe('rendering', () => {
|
|
|
40
45
|
|
|
41
46
|
expect(buttonWrapper.props('disabled')).toBe(true);
|
|
42
47
|
});
|
|
48
|
+
|
|
49
|
+
test('should render indicator of customized styles', () => {
|
|
50
|
+
const editor = createEditor({
|
|
51
|
+
isItalic: true,
|
|
52
|
+
isSettingCustomized: true
|
|
53
|
+
});
|
|
54
|
+
const wrapper = createComponent({ editor });
|
|
55
|
+
|
|
56
|
+
expect(wrapper).toVueContainComponent(SELECTORS.INDICATOR);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('should not render indicator of customized styles', () => {
|
|
60
|
+
const editor = createEditor({ isItalic: false });
|
|
61
|
+
const wrapper = createComponent({ editor });
|
|
62
|
+
|
|
63
|
+
expect(wrapper).not.toVueContainComponent(SELECTORS.INDICATOR);
|
|
64
|
+
});
|
|
43
65
|
});
|
|
44
66
|
|
|
45
67
|
describe('selection value', () => {
|
|
@@ -4,12 +4,17 @@ import { InjectionTokens } from '../../../../injectionTokens';
|
|
|
4
4
|
import { Button, Modal, NumberField, Range } from '../../../base';
|
|
5
5
|
import LineHeightControl from '../LineHeightControl';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const SELECTORS = {
|
|
8
|
+
INDICATOR: '[data-test-selector="customizedIndicator"]'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const createEditor = ({ height, isSettingCustomized } = {}) => {
|
|
8
12
|
const heightRef = ref(height ?? '1.2');
|
|
9
13
|
|
|
10
14
|
return {
|
|
11
15
|
commands: {
|
|
12
16
|
getLineHeight: () => heightRef,
|
|
17
|
+
isSettingCustomized: () => ref(isSettingCustomized ?? false),
|
|
13
18
|
applyLineHeight: jest.fn(function (value) {
|
|
14
19
|
heightRef.value = value;
|
|
15
20
|
return this;
|
|
@@ -117,4 +122,21 @@ describe('rendering', () => {
|
|
|
117
122
|
expect(buttonWrapper.props('active')).toBe(true);
|
|
118
123
|
expect(modalWrapper.props('toggler').isOpened.value).toBe(true);
|
|
119
124
|
});
|
|
125
|
+
|
|
126
|
+
test('should render indicator of customized styles', () => {
|
|
127
|
+
const editor = createEditor({
|
|
128
|
+
height: '1.8',
|
|
129
|
+
isSettingCustomized: true
|
|
130
|
+
});
|
|
131
|
+
const wrapper = createComponent({ editor });
|
|
132
|
+
|
|
133
|
+
expect(wrapper).toVueContainComponent(SELECTORS.INDICATOR);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
test('should not render indicator of customized styles', () => {
|
|
137
|
+
const editor = createEditor({ height: '1.2' });
|
|
138
|
+
const wrapper = createComponent({ editor });
|
|
139
|
+
|
|
140
|
+
expect(wrapper).not.toVueContainComponent(SELECTORS.INDICATOR);
|
|
141
|
+
});
|
|
120
142
|
});
|
|
@@ -4,9 +4,14 @@ import { InjectionTokens } from '../../../../injectionTokens';
|
|
|
4
4
|
import { Button } from '../../../base';
|
|
5
5
|
import UnderlineControl from '../UnderlineControl';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const SELECTORS = {
|
|
8
|
+
INDICATOR: '[data-test-selector="customizedIndicator"]'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const createEditor = ({ isUnderline, isSettingCustomized } = {}) => ({
|
|
8
12
|
commands: {
|
|
9
13
|
isUnderline: () => ref(isUnderline),
|
|
14
|
+
isUnderlineCustomized: () => ref(isSettingCustomized ?? false),
|
|
10
15
|
focus: jest.fn().mockReturnThis(),
|
|
11
16
|
toggleUnderline: jest.fn().mockReturnThis(),
|
|
12
17
|
run: jest.fn()
|
|
@@ -46,3 +51,22 @@ describe('selection value', () => {
|
|
|
46
51
|
expect(editor.commands.toggleUnderline).toHaveBeenCalled();
|
|
47
52
|
});
|
|
48
53
|
});
|
|
54
|
+
|
|
55
|
+
describe('render indicator of customized styles', () => {
|
|
56
|
+
test('should render indicator', () => {
|
|
57
|
+
const editor = createEditor({
|
|
58
|
+
isUnderline: true,
|
|
59
|
+
isSettingCustomized: true
|
|
60
|
+
});
|
|
61
|
+
const wrapper = createComponent({ editor });
|
|
62
|
+
|
|
63
|
+
expect(wrapper).toVueContainComponent(SELECTORS.INDICATOR);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('should not render indicator', () => {
|
|
67
|
+
const editor = createEditor({ isUnderline: false });
|
|
68
|
+
const wrapper = createComponent({ editor });
|
|
69
|
+
|
|
70
|
+
expect(wrapper).not.toVueContainComponent(SELECTORS.INDICATOR);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -169,6 +169,12 @@ export const StylePreset = Extension.create({
|
|
|
169
169
|
});
|
|
170
170
|
}),
|
|
171
171
|
|
|
172
|
+
isSettingCustomized: createCommand(({ commands }, group, name) => {
|
|
173
|
+
const customization = commands.getPresetCustomization();
|
|
174
|
+
|
|
175
|
+
return computed(() => unref(customization)[group]?.includes(name) ?? false);
|
|
176
|
+
}),
|
|
177
|
+
|
|
172
178
|
removePresetCustomization: createCommand(({ chain }) => {
|
|
173
179
|
chain()
|
|
174
180
|
.storeSelection()
|
|
@@ -39,6 +39,13 @@ export const TextDecoration = Mark.create({
|
|
|
39
39
|
});
|
|
40
40
|
}),
|
|
41
41
|
|
|
42
|
+
isUnderlineCustomized: createCommand(({ commands }) => {
|
|
43
|
+
const currentValue = commands.isUnderline();
|
|
44
|
+
const defaultValue = commands.getDefaultTextDecoration();
|
|
45
|
+
|
|
46
|
+
return computed(() => unref(currentValue) !== unref(defaultValue).underline);
|
|
47
|
+
}),
|
|
48
|
+
|
|
42
49
|
getDefaultTextDecoration: createCommand(({ commands }) => {
|
|
43
50
|
const preset = commands.getPreset();
|
|
44
51
|
|
|
@@ -396,6 +396,21 @@ describe('get preset customization', () => {
|
|
|
396
396
|
expect(customization.value).toMatchSnapshot();
|
|
397
397
|
});
|
|
398
398
|
|
|
399
|
+
test('should not is setting customized', async () => {
|
|
400
|
+
const editor = await createEditor({
|
|
401
|
+
content: NodeFactory.doc([
|
|
402
|
+
NodeFactory.paragraph({ preset: { id: 'regular-1' } }, 'test')
|
|
403
|
+
]),
|
|
404
|
+
presets: [createPreset({ id: 'regular-1' })]
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
const isFontSizeCustomized = editor.commands.isSettingCustomized('marks', TextSettings.FONT_SIZE);
|
|
408
|
+
const isAlignmentCustomized = editor.commands.isSettingCustomized('attributes', TextSettings.ALIGNMENT);
|
|
409
|
+
|
|
410
|
+
expect(isFontSizeCustomized.value).toBe(false);
|
|
411
|
+
expect(isAlignmentCustomized.value).toBe(false);
|
|
412
|
+
});
|
|
413
|
+
|
|
399
414
|
test('should find marks', async () => {
|
|
400
415
|
const editor = await createEditor({
|
|
401
416
|
content: NodeFactory.doc([
|
|
@@ -416,6 +431,25 @@ describe('get preset customization', () => {
|
|
|
416
431
|
expect(customization.value).toMatchSnapshot();
|
|
417
432
|
});
|
|
418
433
|
|
|
434
|
+
test('should is marks setting customized', async () => {
|
|
435
|
+
const editor = await createEditor({
|
|
436
|
+
content: NodeFactory.doc([
|
|
437
|
+
NodeFactory.paragraph({ preset: { id: 'regular-1' } }, [
|
|
438
|
+
NodeFactory.text('test', [
|
|
439
|
+
NodeFactory.mark(TextSettings.FONT_SIZE, { value: '12' }),
|
|
440
|
+
NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
|
|
441
|
+
])
|
|
442
|
+
])
|
|
443
|
+
]),
|
|
444
|
+
presets: [createPreset({ id: 'regular-1' })]
|
|
445
|
+
});
|
|
446
|
+
|
|
447
|
+
editor.commands.selectAll();
|
|
448
|
+
const isFontSizeCustomized = editor.commands.isSettingCustomized('marks', TextSettings.FONT_SIZE);
|
|
449
|
+
|
|
450
|
+
expect(isFontSizeCustomized.value).toBe(true);
|
|
451
|
+
});
|
|
452
|
+
|
|
419
453
|
test('should find attributes', async () => {
|
|
420
454
|
const editor = await createEditor({
|
|
421
455
|
content: NodeFactory.doc([
|
|
@@ -433,6 +467,23 @@ describe('get preset customization', () => {
|
|
|
433
467
|
|
|
434
468
|
expect(customization.value).toMatchSnapshot();
|
|
435
469
|
});
|
|
470
|
+
|
|
471
|
+
test('should is attributes setting customized', async () => {
|
|
472
|
+
const editor = await createEditor({
|
|
473
|
+
content: NodeFactory.doc([
|
|
474
|
+
NodeFactory.paragraph({
|
|
475
|
+
preset: { id: 'regular-1' },
|
|
476
|
+
alignment: { value: 'center' }
|
|
477
|
+
}, 'test')
|
|
478
|
+
]),
|
|
479
|
+
presets: [createPreset({ id: 'regular-1' })]
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
editor.commands.selectAll();
|
|
483
|
+
const isAlignmentCustomized = editor.commands.isSettingCustomized('attributes', TextSettings.ALIGNMENT);
|
|
484
|
+
|
|
485
|
+
expect(isAlignmentCustomized.value).toBe(true);
|
|
486
|
+
});
|
|
436
487
|
});
|
|
437
488
|
|
|
438
489
|
describe('remove preset customization', () => {
|
|
@@ -70,6 +70,17 @@ describe('get decoration', () => {
|
|
|
70
70
|
expect(editor.commands.isUnderline().value).toBe(true);
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
+
test('should is customized settings', () => {
|
|
74
|
+
const editor = createEditor({
|
|
75
|
+
content: createContent(NodeFactory.text('hello world', [
|
|
76
|
+
NodeFactory.mark(TextSettings.TEXT_DECORATION, { underline: true })
|
|
77
|
+
]))
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
editor.commands.selectAll();
|
|
81
|
+
expect(editor.commands.isUnderlineCustomized().value).toBe(true);
|
|
82
|
+
});
|
|
83
|
+
|
|
73
84
|
test('should get from preset', () => {
|
|
74
85
|
const editor = createEditor({
|
|
75
86
|
content: createContent(NodeFactory.text('hello world'))
|
|
@@ -79,6 +90,15 @@ describe('get decoration', () => {
|
|
|
79
90
|
|
|
80
91
|
expect(editor.commands.isUnderline().value).toBe(false);
|
|
81
92
|
});
|
|
93
|
+
|
|
94
|
+
test('should not is customized settings', () => {
|
|
95
|
+
const editor = createEditor({
|
|
96
|
+
content: createContent(NodeFactory.text('hello world'))
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
editor.commands.selectAll();
|
|
100
|
+
expect(editor.commands.isUnderlineCustomized().value).toBe(false);
|
|
101
|
+
});
|
|
82
102
|
});
|
|
83
103
|
|
|
84
104
|
describe('strike through', () => {
|