@zipify/wysiwyg 2.1.0-builder-modes.1 → 2.1.0-builder-modes.2
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/.github/workflows/frontend-ci.yaml +0 -28
- package/dist/cli.js +1 -1
- package/dist/wysiwyg.mjs +22 -5
- package/example/presets.js +24 -24
- package/lib/components/base/colorPicker/ColorPicker.vue +3 -1
- package/lib/components/toolbar/controls/AlignmentControl.vue +7 -7
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +3 -3
- package/lib/extensions/Alignment.js +9 -0
- package/lib/extensions/__tests__/Alignment.test.js +26 -2
- package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +45 -1
- package/lib/extensions/core/NodeProcessor.js +6 -0
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +34 -0
- package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +62 -0
- package/package.json +1 -1
- package/.github/actions/deploy-example/action.yaml +0 -61
package/dist/wysiwyg.mjs
CHANGED
|
@@ -22161,6 +22161,8 @@ const __vue2_script$p = {
|
|
|
22161
22161
|
const pickerRef = ref(null);
|
|
22162
22162
|
const api = usePickerApi({
|
|
22163
22163
|
onChange: (color) => {
|
|
22164
|
+
if (!unref(api.isOpened))
|
|
22165
|
+
return false;
|
|
22164
22166
|
emit("change", color);
|
|
22165
22167
|
editor.chain().focus().restoreSelection().run();
|
|
22166
22168
|
},
|
|
@@ -23161,7 +23163,7 @@ var render$d = function __render__32() {
|
|
|
23161
23163
|
"options": _vm.$options.alignments
|
|
23162
23164
|
},
|
|
23163
23165
|
on: {
|
|
23164
|
-
"change": _vm.
|
|
23166
|
+
"change": _vm.toggle
|
|
23165
23167
|
},
|
|
23166
23168
|
scopedSlots: _vm._u([{
|
|
23167
23169
|
key: "option",
|
|
@@ -23241,16 +23243,20 @@ const __vue2_script$d = {
|
|
|
23241
23243
|
},
|
|
23242
23244
|
setup(_, { emit }) {
|
|
23243
23245
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
23244
|
-
const
|
|
23246
|
+
const alignment = editor.commands.getAlignment();
|
|
23247
|
+
const currentValue = computed(() => {
|
|
23248
|
+
var _a;
|
|
23249
|
+
return (_a = unref(alignment)) != null ? _a : "none";
|
|
23250
|
+
});
|
|
23245
23251
|
const isCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
|
|
23246
|
-
function
|
|
23247
|
-
editor.chain().focus().
|
|
23252
|
+
function toggle(value) {
|
|
23253
|
+
editor.chain().focus().toggleAlignment(value).run();
|
|
23248
23254
|
emit("applied");
|
|
23249
23255
|
}
|
|
23250
23256
|
return {
|
|
23251
23257
|
currentValue,
|
|
23252
23258
|
isCustomized,
|
|
23253
|
-
|
|
23259
|
+
toggle
|
|
23254
23260
|
};
|
|
23255
23261
|
}
|
|
23256
23262
|
};
|
|
@@ -25548,6 +25554,11 @@ const NodeProcessor = Extension.create({
|
|
|
25548
25554
|
}
|
|
25549
25555
|
return Object.keys(attrs).length ? attrs : null;
|
|
25550
25556
|
})),
|
|
25557
|
+
removeBlockAttributes: createCommand(({ commands: commands2 }, names) => {
|
|
25558
|
+
for (const type of NodeTypes.blocks) {
|
|
25559
|
+
commands2.resetAttributes(type, names);
|
|
25560
|
+
}
|
|
25561
|
+
}),
|
|
25551
25562
|
applyMark: createCommand(({ state, commands: commands2 }, name, value, customizer = {}) => {
|
|
25552
25563
|
const { tr, doc: doc2, schema } = state;
|
|
25553
25564
|
const { $from, $to } = tr.selection;
|
|
@@ -26367,10 +26378,16 @@ const Alignment = Extension.create({
|
|
|
26367
26378
|
],
|
|
26368
26379
|
addCommands() {
|
|
26369
26380
|
return {
|
|
26381
|
+
toggleAlignment: createCommand(({ commands: commands2 }, value) => {
|
|
26382
|
+
const currentValue = commands2.getAlignment();
|
|
26383
|
+
const isCurrentValue = unref(currentValue) === value;
|
|
26384
|
+
!isCurrentValue ? commands2.applyAlignment(value) : commands2.removeAlignment();
|
|
26385
|
+
}),
|
|
26370
26386
|
applyAlignment: createCommand(({ commands: commands2 }, value) => {
|
|
26371
26387
|
const device = unref(commands2.getDevice());
|
|
26372
26388
|
commands2.setBlockAttributes(this.name, { [device]: value }, DEFAULTS$1);
|
|
26373
26389
|
}),
|
|
26390
|
+
removeAlignment: createCommand(({ commands: commands2 }) => commands2.removeBlockAttributes(this.name)),
|
|
26374
26391
|
getAlignment: createCommand(({ commands: commands2 }) => {
|
|
26375
26392
|
const attribute = commands2.getBlockAttributes(this.name, DEFAULTS$1);
|
|
26376
26393
|
const device = commands2.getDevice();
|
package/example/presets.js
CHANGED
|
@@ -7,7 +7,7 @@ export const PRESETS = [
|
|
|
7
7
|
'level': 1
|
|
8
8
|
},
|
|
9
9
|
'desktop': {
|
|
10
|
-
'alignment':
|
|
10
|
+
'alignment': null,
|
|
11
11
|
'line_height': '1.2',
|
|
12
12
|
'font_size': '40px'
|
|
13
13
|
},
|
|
@@ -19,12 +19,12 @@ export const PRESETS = [
|
|
|
19
19
|
'text_decoration': 'none'
|
|
20
20
|
},
|
|
21
21
|
'tablet': {
|
|
22
|
-
'alignment':
|
|
22
|
+
'alignment': null,
|
|
23
23
|
'line_height': '1.2',
|
|
24
24
|
'font_size': '40px'
|
|
25
25
|
},
|
|
26
26
|
'mobile': {
|
|
27
|
-
'alignment':
|
|
27
|
+
'alignment': null,
|
|
28
28
|
'line_height': '1.2',
|
|
29
29
|
'font_size': '28px'
|
|
30
30
|
}
|
|
@@ -37,7 +37,7 @@ export const PRESETS = [
|
|
|
37
37
|
'level': 2
|
|
38
38
|
},
|
|
39
39
|
'desktop': {
|
|
40
|
-
'alignment':
|
|
40
|
+
'alignment': null,
|
|
41
41
|
'line_height': '1.2',
|
|
42
42
|
'font_size': '32px'
|
|
43
43
|
},
|
|
@@ -49,12 +49,12 @@ export const PRESETS = [
|
|
|
49
49
|
'text_decoration': 'none'
|
|
50
50
|
},
|
|
51
51
|
'tablet': {
|
|
52
|
-
'alignment':
|
|
52
|
+
'alignment': null,
|
|
53
53
|
'line_height': '1.2',
|
|
54
54
|
'font_size': '32px'
|
|
55
55
|
},
|
|
56
56
|
'mobile': {
|
|
57
|
-
'alignment':
|
|
57
|
+
'alignment': null,
|
|
58
58
|
'line_height': '1.2',
|
|
59
59
|
'font_size': '24px'
|
|
60
60
|
}
|
|
@@ -67,7 +67,7 @@ export const PRESETS = [
|
|
|
67
67
|
'level': 3
|
|
68
68
|
},
|
|
69
69
|
'desktop': {
|
|
70
|
-
'alignment':
|
|
70
|
+
'alignment': null,
|
|
71
71
|
'line_height': '1.2',
|
|
72
72
|
'font_size': '28px'
|
|
73
73
|
},
|
|
@@ -79,12 +79,12 @@ export const PRESETS = [
|
|
|
79
79
|
'text_decoration': 'none'
|
|
80
80
|
},
|
|
81
81
|
'tablet': {
|
|
82
|
-
'alignment':
|
|
82
|
+
'alignment': null,
|
|
83
83
|
'line_height': '1.2',
|
|
84
84
|
'font_size': '28px'
|
|
85
85
|
},
|
|
86
86
|
'mobile': {
|
|
87
|
-
'alignment':
|
|
87
|
+
'alignment': null,
|
|
88
88
|
'line_height': '1.2',
|
|
89
89
|
'font_size': '20px'
|
|
90
90
|
}
|
|
@@ -97,7 +97,7 @@ export const PRESETS = [
|
|
|
97
97
|
'level': 4
|
|
98
98
|
},
|
|
99
99
|
'desktop': {
|
|
100
|
-
'alignment':
|
|
100
|
+
'alignment': null,
|
|
101
101
|
'line_height': '1.2',
|
|
102
102
|
'font_size': '24px'
|
|
103
103
|
},
|
|
@@ -109,12 +109,12 @@ export const PRESETS = [
|
|
|
109
109
|
'text_decoration': 'none'
|
|
110
110
|
},
|
|
111
111
|
'tablet': {
|
|
112
|
-
'alignment':
|
|
112
|
+
'alignment': null,
|
|
113
113
|
'line_height': '1.2',
|
|
114
114
|
'font_size': '24px'
|
|
115
115
|
},
|
|
116
116
|
'mobile': {
|
|
117
|
-
'alignment':
|
|
117
|
+
'alignment': null,
|
|
118
118
|
'line_height': '1.2',
|
|
119
119
|
'font_size': '18px'
|
|
120
120
|
}
|
|
@@ -124,7 +124,7 @@ export const PRESETS = [
|
|
|
124
124
|
'name': 'Link',
|
|
125
125
|
'hidden': true,
|
|
126
126
|
'desktop': {
|
|
127
|
-
'alignment':
|
|
127
|
+
'alignment': null,
|
|
128
128
|
'line_height': 'inherit',
|
|
129
129
|
'font_size': 'inherit'
|
|
130
130
|
},
|
|
@@ -136,12 +136,12 @@ export const PRESETS = [
|
|
|
136
136
|
'text_decoration': 'underline'
|
|
137
137
|
},
|
|
138
138
|
'tablet': {
|
|
139
|
-
'alignment':
|
|
139
|
+
'alignment': null,
|
|
140
140
|
'line_height': 'inherit',
|
|
141
141
|
'font_size': 'inherit'
|
|
142
142
|
},
|
|
143
143
|
'mobile': {
|
|
144
|
-
'alignment':
|
|
144
|
+
'alignment': null,
|
|
145
145
|
'line_height': 'inherit',
|
|
146
146
|
'font_size': 'inherit'
|
|
147
147
|
}
|
|
@@ -150,7 +150,7 @@ export const PRESETS = [
|
|
|
150
150
|
'id': 'regular-1',
|
|
151
151
|
'name': 'Regular',
|
|
152
152
|
'desktop': {
|
|
153
|
-
'alignment':
|
|
153
|
+
'alignment': null,
|
|
154
154
|
'line_height': '1.43',
|
|
155
155
|
'font_size': '18px'
|
|
156
156
|
},
|
|
@@ -162,12 +162,12 @@ export const PRESETS = [
|
|
|
162
162
|
'text_decoration': 'none'
|
|
163
163
|
},
|
|
164
164
|
'tablet': {
|
|
165
|
-
'alignment':
|
|
165
|
+
'alignment': null,
|
|
166
166
|
'line_height': '1.43',
|
|
167
167
|
'font_size': '18px'
|
|
168
168
|
},
|
|
169
169
|
'mobile': {
|
|
170
|
-
'alignment':
|
|
170
|
+
'alignment': null,
|
|
171
171
|
'line_height': '1.43',
|
|
172
172
|
'font_size': '18px'
|
|
173
173
|
}
|
|
@@ -177,7 +177,7 @@ export const PRESETS = [
|
|
|
177
177
|
'name': 'Regular 2',
|
|
178
178
|
'fallbackClass': 'zpa-regular2',
|
|
179
179
|
'desktop': {
|
|
180
|
-
'alignment':
|
|
180
|
+
'alignment': null,
|
|
181
181
|
'line_height': '1.43',
|
|
182
182
|
'font_size': '16px'
|
|
183
183
|
},
|
|
@@ -189,12 +189,12 @@ export const PRESETS = [
|
|
|
189
189
|
'text_decoration': 'none'
|
|
190
190
|
},
|
|
191
191
|
'tablet': {
|
|
192
|
-
'alignment':
|
|
192
|
+
'alignment': null,
|
|
193
193
|
'line_height': '1.43',
|
|
194
194
|
'font_size': '16px'
|
|
195
195
|
},
|
|
196
196
|
'mobile': {
|
|
197
|
-
'alignment':
|
|
197
|
+
'alignment': null,
|
|
198
198
|
'line_height': '1.43',
|
|
199
199
|
'font_size': '16px'
|
|
200
200
|
}
|
|
@@ -204,7 +204,7 @@ export const PRESETS = [
|
|
|
204
204
|
'name': 'Regular 3',
|
|
205
205
|
'fallbackClass': 'zpa-regular3',
|
|
206
206
|
'desktop': {
|
|
207
|
-
'alignment':
|
|
207
|
+
'alignment': null,
|
|
208
208
|
'line_height': '1.43',
|
|
209
209
|
'font_size': '12px'
|
|
210
210
|
},
|
|
@@ -216,12 +216,12 @@ export const PRESETS = [
|
|
|
216
216
|
'text_decoration': 'none'
|
|
217
217
|
},
|
|
218
218
|
'tablet': {
|
|
219
|
-
'alignment':
|
|
219
|
+
'alignment': null,
|
|
220
220
|
'line_height': '1.43',
|
|
221
221
|
'font_size': '12px'
|
|
222
222
|
},
|
|
223
223
|
'mobile': {
|
|
224
|
-
'alignment':
|
|
224
|
+
'alignment': null,
|
|
225
225
|
'line_height': '1.43',
|
|
226
226
|
'font_size': '12px'
|
|
227
227
|
}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
<script>
|
|
25
25
|
import { ZipifyColorPicker } from '@zipify/colorpicker';
|
|
26
|
-
import { inject, ref, toRef } from 'vue';
|
|
26
|
+
import { inject, ref, toRef, unref } from 'vue';
|
|
27
27
|
import { outClick } from '../../../directives';
|
|
28
28
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
29
29
|
import { ContextWindow } from '../../../services';
|
|
@@ -55,6 +55,8 @@ export default {
|
|
|
55
55
|
|
|
56
56
|
const api = usePickerApi({
|
|
57
57
|
onChange: (color) => {
|
|
58
|
+
if (!unref(api.isOpened)) return false;
|
|
59
|
+
|
|
58
60
|
emit('change', color);
|
|
59
61
|
editor.chain().focus().restoreSelection().run();
|
|
60
62
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<ButtonToggle :value="currentValue" :options="$options.alignments" @change="
|
|
2
|
+
<ButtonToggle :value="currentValue" :options="$options.alignments" @change="toggle">
|
|
3
3
|
<template #option="{ isActive, option, activate }">
|
|
4
4
|
<Button
|
|
5
5
|
class="zw-position--relative"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script>
|
|
27
|
-
import { inject } from 'vue';
|
|
27
|
+
import { inject, computed, unref } from 'vue';
|
|
28
28
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
29
29
|
import { Alignments, TextSettings } from '../../../enums';
|
|
30
30
|
import { ButtonToggle, Button, Icon } from '../../base';
|
|
@@ -64,19 +64,19 @@ export default {
|
|
|
64
64
|
|
|
65
65
|
setup(_, { emit }) {
|
|
66
66
|
const editor = inject(InjectionTokens.EDITOR);
|
|
67
|
-
|
|
68
|
-
const currentValue =
|
|
67
|
+
const alignment = editor.commands.getAlignment();
|
|
68
|
+
const currentValue = computed(() => unref(alignment) ?? 'none');
|
|
69
69
|
const isCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
|
|
70
70
|
|
|
71
|
-
function
|
|
72
|
-
editor.chain().focus().
|
|
71
|
+
function toggle(value) {
|
|
72
|
+
editor.chain().focus().toggleAlignment(value).run();
|
|
73
73
|
emit('applied');
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
return {
|
|
77
77
|
currentValue,
|
|
78
78
|
isCustomized,
|
|
79
|
-
|
|
79
|
+
toggle
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
82
|
};
|
|
@@ -14,7 +14,7 @@ const createEditor = ({ alignment, isSettingCustomized } = {}) => ({
|
|
|
14
14
|
getAlignment: () => ref(alignment),
|
|
15
15
|
isSettingCustomized: () => ref(isSettingCustomized ?? false),
|
|
16
16
|
focus: jest.fn().mockReturnThis(),
|
|
17
|
-
|
|
17
|
+
toggleAlignment: jest.fn().mockReturnThis(),
|
|
18
18
|
run: jest.fn()
|
|
19
19
|
},
|
|
20
20
|
|
|
@@ -60,7 +60,7 @@ describe('selection value', () => {
|
|
|
60
60
|
expect(buttonWrapper.props('value')).toBe(Alignments.RIGHT);
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
test('should
|
|
63
|
+
test('should toggle new value', () => {
|
|
64
64
|
const editor = createEditor({ alignment: Alignments.RIGHT });
|
|
65
65
|
const wrapper = createComponent({
|
|
66
66
|
editor,
|
|
@@ -76,7 +76,7 @@ describe('selection value', () => {
|
|
|
76
76
|
|
|
77
77
|
buttonWrapper.vm.$emit('change', Alignments.CENTER);
|
|
78
78
|
|
|
79
|
-
expect(editor.commands.
|
|
79
|
+
expect(editor.commands.toggleAlignment).toHaveBeenCalledWith(Alignments.CENTER);
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
82
|
|
|
@@ -51,12 +51,21 @@ export const Alignment = Extension.create({
|
|
|
51
51
|
|
|
52
52
|
addCommands() {
|
|
53
53
|
return {
|
|
54
|
+
toggleAlignment: createCommand(({ commands }, value) => {
|
|
55
|
+
const currentValue = commands.getAlignment();
|
|
56
|
+
const isCurrentValue = unref(currentValue) === value;
|
|
57
|
+
|
|
58
|
+
!isCurrentValue ? commands.applyAlignment(value) : commands.removeAlignment();
|
|
59
|
+
}),
|
|
60
|
+
|
|
54
61
|
applyAlignment: createCommand(({ commands }, value) => {
|
|
55
62
|
const device = unref(commands.getDevice());
|
|
56
63
|
|
|
57
64
|
commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
|
|
58
65
|
}),
|
|
59
66
|
|
|
67
|
+
removeAlignment: createCommand(({ commands }) => commands.removeBlockAttributes(this.name)),
|
|
68
|
+
|
|
60
69
|
getAlignment: createCommand(({ commands }) => {
|
|
61
70
|
const attribute = commands.getBlockAttributes(this.name, DEFAULTS);
|
|
62
71
|
const device = commands.getDevice();
|
|
@@ -70,8 +70,19 @@ describe('get value', () => {
|
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
describe('
|
|
74
|
-
test('should
|
|
73
|
+
describe('change value', () => {
|
|
74
|
+
test('should toggle value', () => {
|
|
75
|
+
const editor = createEditor({
|
|
76
|
+
content: createContent({ alignment: null })
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
editor.commands.selectAll();
|
|
80
|
+
editor.commands.toggleAlignment(Alignments.RIGHT);
|
|
81
|
+
|
|
82
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('should apply value', () => {
|
|
75
86
|
const editor = createEditor({
|
|
76
87
|
content: createContent({ alignment: null })
|
|
77
88
|
});
|
|
@@ -81,6 +92,19 @@ describe('apply value', () => {
|
|
|
81
92
|
|
|
82
93
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
83
94
|
});
|
|
95
|
+
|
|
96
|
+
test('should remove value', () => {
|
|
97
|
+
const editor = createEditor({
|
|
98
|
+
content: createContent({
|
|
99
|
+
alignment: { desktop: Alignments.CENTER }
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
editor.commands.selectAll();
|
|
104
|
+
editor.commands.removeAlignment(TextSettings.ALIGNMENT);
|
|
105
|
+
|
|
106
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
107
|
+
});
|
|
84
108
|
});
|
|
85
109
|
|
|
86
110
|
describe('rendering', () => {
|
|
@@ -1,6 +1,50 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`change value should apply value 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"content": Array [
|
|
6
|
+
Object {
|
|
7
|
+
"attrs": Object {
|
|
8
|
+
"alignment": Object {
|
|
9
|
+
"desktop": "right",
|
|
10
|
+
"mobile": null,
|
|
11
|
+
"tablet": null,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
"content": Array [
|
|
15
|
+
Object {
|
|
16
|
+
"text": "hello world",
|
|
17
|
+
"type": "text",
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
"type": "paragraph",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
"type": "doc",
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
exports[`change value should remove value 1`] = `
|
|
28
|
+
Object {
|
|
29
|
+
"content": Array [
|
|
30
|
+
Object {
|
|
31
|
+
"attrs": Object {
|
|
32
|
+
"alignment": null,
|
|
33
|
+
},
|
|
34
|
+
"content": Array [
|
|
35
|
+
Object {
|
|
36
|
+
"text": "hello world",
|
|
37
|
+
"type": "text",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
"type": "paragraph",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
"type": "doc",
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
exports[`change value should toggle value 1`] = `
|
|
4
48
|
Object {
|
|
5
49
|
"content": Array [
|
|
6
50
|
Object {
|
|
@@ -37,6 +37,12 @@ export const NodeProcessor = Extension.create({
|
|
|
37
37
|
return Object.keys(attrs).length ? attrs : null;
|
|
38
38
|
})),
|
|
39
39
|
|
|
40
|
+
removeBlockAttributes: createCommand(({ commands }, names) => {
|
|
41
|
+
for (const type of NodeTypes.blocks) {
|
|
42
|
+
commands.resetAttributes(type, names);
|
|
43
|
+
}
|
|
44
|
+
}),
|
|
45
|
+
|
|
40
46
|
applyMark: createCommand(({ state, commands }, name, value, customizer = {}) => {
|
|
41
47
|
const { tr, doc, schema } = state;
|
|
42
48
|
const { $from, $to } = tr.selection;
|
|
@@ -16,6 +16,9 @@ const MockLineHeight = Extension.create({
|
|
|
16
16
|
line_height: {
|
|
17
17
|
isRequired: false,
|
|
18
18
|
renderHTML: (attrs) => ({ style: `line-height: ${attrs.line_height}` })
|
|
19
|
+
},
|
|
20
|
+
alignment: {
|
|
21
|
+
isRequired: false
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
24
|
}
|
|
@@ -138,6 +141,37 @@ describe('block attributes', () => {
|
|
|
138
141
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
139
142
|
});
|
|
140
143
|
|
|
144
|
+
test('should remove some attribute', () => {
|
|
145
|
+
const editor = createEditor({
|
|
146
|
+
content: createContent({
|
|
147
|
+
line_height: { mobile: '1.2' }
|
|
148
|
+
})
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
editor.commands.selectAll();
|
|
152
|
+
editor.commands.removeBlockAttributes(TextSettings.LINE_HEIGHT);
|
|
153
|
+
|
|
154
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test('should remove a few some attributes', () => {
|
|
158
|
+
const editor = createEditor({
|
|
159
|
+
content: createContent({
|
|
160
|
+
line_height: { mobile: '1.2' },
|
|
161
|
+
alignment: {
|
|
162
|
+
mobile: 'center',
|
|
163
|
+
tablet: 'center',
|
|
164
|
+
desktop: 'center'
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
editor.commands.selectAll();
|
|
170
|
+
editor.commands.removeBlockAttributes([TextSettings.LINE_HEIGHT, TextSettings.ALIGNMENT]);
|
|
171
|
+
|
|
172
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
173
|
+
});
|
|
174
|
+
|
|
141
175
|
test('should set attributes with defaults', () => {
|
|
142
176
|
const editor = createEditor({
|
|
143
177
|
content: createContent({ line_height: null })
|