@zipify/wysiwyg 3.1.0-0 → 3.1.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/.eslintrc.js +17 -235
- package/.github/actions/setup/action.yaml +1 -1
- package/README.md +2 -0
- package/config/build/cli.config.js +7 -7
- package/config/build/lib.config.js +6 -4
- package/config/svgo.js +6 -3
- package/dist/cli.js +5 -4
- package/dist/wysiwyg.css +36 -33
- package/dist/wysiwyg.mjs +12403 -11604
- package/example/ExampleApp.vue +1 -1
- package/example/presets.js +7 -7
- package/example/tooltip/Tooltip.js +94 -69
- package/example/tooltip/tooltip.css +8 -31
- package/lib/Wysiwyg.vue +3 -0
- package/lib/__tests__/utils/buildTestExtensions.js +24 -2
- package/lib/cli/commands/ToJsonCommand.js +6 -6
- package/lib/components/base/__tests__/Button.test.js +1 -1
- package/lib/components/base/composables/__tests__/useDeselectionLock.test.js +2 -2
- package/lib/components/base/composables/__tests__/useElementRef.test.js +1 -1
- package/lib/components/base/composables/__tests__/useModalToggler.test.js +0 -2
- package/lib/components/base/composables/__tests__/useValidator.test.js +2 -2
- package/lib/components/base/composables/useModalToggler.js +30 -21
- package/lib/components/base/dropdown/DropdownActivator.vue +4 -0
- package/lib/components/toolbar/Toolbar.vue +1 -1
- package/lib/components/toolbar/base/__tests__/ToolbarDivider.test.js +1 -1
- package/lib/components/toolbar/controls/StylePresetControl.vue +2 -2
- package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +0 -2
- package/lib/components/toolbar/controls/composables/__tests__/useRecentFonts.test.js +1 -1
- package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +2 -2
- package/lib/composables/useToolbar.js +24 -19
- package/lib/{entry-cli.js → entryCli.js} +0 -0
- package/lib/{entry-lib.js → entryLib.js} +0 -0
- package/lib/extensions/Alignment.js +6 -6
- package/lib/extensions/FontSize.js +1 -2
- package/lib/extensions/Link.js +2 -0
- package/lib/extensions/StylePreset.js +8 -46
- package/lib/extensions/__tests__/Alignment.test.js +1 -1
- package/lib/extensions/__tests__/BackgroundColor.test.js +2 -2
- package/lib/extensions/__tests__/FontColor.test.js +3 -3
- package/lib/extensions/__tests__/FontFamily.test.js +3 -3
- package/lib/extensions/__tests__/FontSize.test.js +3 -3
- package/lib/extensions/__tests__/FontWeight.test.js +4 -4
- package/lib/extensions/__tests__/LineHeight.test.js +2 -2
- package/lib/extensions/__tests__/Link.test.js +33 -5
- package/lib/extensions/__tests__/StylePreset.test.js +90 -119
- package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +2 -2
- package/lib/extensions/__tests__/__snapshots__/Link.test.js.snap +27 -0
- package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +0 -2
- package/lib/extensions/core/NodeProcessor.js +9 -6
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +6 -8
- package/lib/extensions/core/__tests__/TextProcessor.test.js +1 -1
- package/lib/extensions/core/index.js +0 -2
- package/lib/extensions/core/plugins/PlaceholderPlugin.js +2 -2
- package/lib/extensions/index.js +7 -3
- package/lib/extensions/list/List.js +4 -5
- package/lib/extensions/list/ListItem.js +1 -2
- package/lib/extensions/list/__tests__/List.test.js +7 -2
- package/lib/models/Font.js +2 -2
- package/lib/models/__tests__/Font.test.js +3 -9
- package/lib/services/ContentSerializer.js +9 -9
- package/lib/services/{ContextWidnow.js → ContextWindow.js} +0 -0
- package/lib/services/HtmlToJsonParser.js +3 -3
- package/lib/services/NodeFactory.js +6 -6
- package/lib/services/StylePresetRenderer.js +73 -0
- package/lib/services/__tests__/JsonSerializer.test.js +1 -1
- package/lib/services/__tests__/Storage.test.js +1 -1
- package/lib/services/__tests__/StylePresetRenderer.test.js +98 -0
- package/lib/services/__tests__/__snapshots__/StylePresetRenderer.test.js.snap +5 -0
- package/lib/services/index.js +2 -1
- package/lib/services/normalizer/BrowserDomParser.js +2 -2
- package/lib/services/normalizer/ContentNormalizer.js +3 -3
- package/lib/services/normalizer/HtmlNormalizer.js +52 -52
- package/lib/services/normalizer/JsonNormalizer.js +21 -21
- package/lib/styles/content.css +10 -10
- package/lib/utils/__tests__/convertAlignment.test.js +1 -1
- package/lib/utils/__tests__/renderInlineSetting.test.js +2 -2
- package/package.json +48 -46
- package/lib/extensions/core/steps/AddNodeMarkStep.js +0 -66
- package/lib/extensions/core/steps/AttrStep.js +0 -60
- package/lib/extensions/core/steps/RemoveNodeMarkStep.js +0 -56
- package/lib/extensions/core/steps/index.js +0 -3
|
@@ -1,32 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createPopper } from '@popperjs/core';
|
|
2
|
+
import { inject, nextTick, ref, onUnmounted } from 'vue';
|
|
3
3
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
4
4
|
import { useElementRef } from './useElementRef';
|
|
5
5
|
|
|
6
6
|
export function useModalToggler({ onBeforeOpened, onClosed, wrapperRef, modalRef } = {}) {
|
|
7
7
|
const editor = inject(InjectionTokens.EDITOR);
|
|
8
8
|
const isOpened = ref(false);
|
|
9
|
-
let
|
|
9
|
+
let popper;
|
|
10
10
|
|
|
11
|
-
function
|
|
11
|
+
function initPopper() {
|
|
12
12
|
const wrapperEl = useElementRef(wrapperRef);
|
|
13
13
|
const modalEl = useElementRef(modalRef);
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
popper = createPopper(wrapperEl.value, modalEl.value, {
|
|
16
|
+
placement: 'bottom',
|
|
17
|
+
strategy: 'fixed',
|
|
18
|
+
modifiers: [
|
|
19
|
+
{
|
|
20
|
+
name: 'offset',
|
|
21
|
+
options: {
|
|
22
|
+
offset: [0, 4]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'preventOverflow',
|
|
27
|
+
options: {
|
|
28
|
+
padding: 16
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'flip',
|
|
33
|
+
enabled: false
|
|
34
|
+
}
|
|
35
|
+
]
|
|
30
36
|
});
|
|
31
37
|
}
|
|
32
38
|
|
|
@@ -37,16 +43,19 @@ export function useModalToggler({ onBeforeOpened, onClosed, wrapperRef, modalRef
|
|
|
37
43
|
|
|
38
44
|
await nextTick();
|
|
39
45
|
|
|
40
|
-
|
|
46
|
+
initPopper();
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
function close() {
|
|
44
50
|
isOpened.value = false;
|
|
45
|
-
floatingInstance?.();
|
|
46
51
|
editor.commands.restoreSelection();
|
|
47
52
|
onClosed?.();
|
|
48
53
|
}
|
|
49
54
|
|
|
55
|
+
onUnmounted(() => {
|
|
56
|
+
popper?.destroy();
|
|
57
|
+
});
|
|
58
|
+
|
|
50
59
|
const toggle = (toOpen) => toOpen ? open() : close();
|
|
51
60
|
|
|
52
61
|
return { isOpened, open, close, toggle };
|
|
@@ -18,7 +18,7 @@ describe('rendering', () => {
|
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
test('should render
|
|
21
|
+
test('should render horizontal divider', () => {
|
|
22
22
|
const wrapper = createComponent({ isHorizontal: true });
|
|
23
23
|
|
|
24
24
|
expect(wrapper.classes('zw-toolbar__divider--horizontal')).toBeTruthy();
|
|
@@ -73,7 +73,7 @@ export default {
|
|
|
73
73
|
.run();
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
const tooltip = computed(() => isCustomized.value ? 'Reset Styles to
|
|
76
|
+
const tooltip = computed(() => isCustomized.value ? 'Reset Styles to Page Styles' : '');
|
|
77
77
|
|
|
78
78
|
const removeCustomization = () => editor.chain().focus().removePresetCustomization().run();
|
|
79
79
|
|
|
@@ -96,7 +96,7 @@ export default {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
.zw-style-preset-control__dropdown {
|
|
99
|
-
width:
|
|
99
|
+
width: 120px;
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
.zw-style-preset-control__reset {
|
|
@@ -4,8 +4,6 @@ import { InjectionTokens } from '../../../../injectionTokens';
|
|
|
4
4
|
import { Button, Modal, NumberField, Range } from '../../../base';
|
|
5
5
|
import LineHeightControl from '../LineHeightControl';
|
|
6
6
|
|
|
7
|
-
jest.mock('@floating-ui/dom');
|
|
8
|
-
|
|
9
7
|
const createEditor = ({ height } = {}) => {
|
|
10
8
|
const heightRef = ref(height ?? '1.2');
|
|
11
9
|
|
|
@@ -57,7 +57,7 @@ describe('list of fonts', () => {
|
|
|
57
57
|
expect(recentFonts.fonts.value).toEqual(['Lato', 'Roboto', 'Source Sans']);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
test('should move up font in list', () => {
|
|
60
|
+
test('should move up font in list new font', () => {
|
|
61
61
|
const recentFonts = createWrapper({
|
|
62
62
|
initial: ['Roboto', 'Source Sans', 'Times New Roman']
|
|
63
63
|
});
|
|
@@ -97,7 +97,7 @@ describe('actions with link', () => {
|
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
test('should apply link target', () => {
|
|
100
|
+
test('should apply link target to new window', () => {
|
|
101
101
|
const link = useComposable();
|
|
102
102
|
|
|
103
103
|
link.updateTarget(false);
|
|
@@ -105,7 +105,7 @@ describe('actions with link', () => {
|
|
|
105
105
|
expect(link.linkData.value.target).toBe(LinkTargets.SELF);
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
test('should apply link target', () => {
|
|
108
|
+
test('should apply link target to current window', () => {
|
|
109
109
|
const link = useComposable();
|
|
110
110
|
|
|
111
111
|
link.updateTarget(true);
|
|
@@ -1,33 +1,38 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { autoUpdate, computePosition, limitShift, offset, shift } from '@floating-ui/dom';
|
|
1
|
+
import { createPopper } from '@popperjs/core';
|
|
3
2
|
import { useElementRef } from '../components/base';
|
|
4
3
|
|
|
5
4
|
export function useToolbar({ wrapperRef, offsets, isActiveRef, placementRef }) {
|
|
6
5
|
const wrapperEl = useElementRef(wrapperRef);
|
|
7
|
-
let
|
|
6
|
+
let popper;
|
|
8
7
|
|
|
9
8
|
function mount(element) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
popper = createPopper(wrapperEl.value, element, {
|
|
10
|
+
placement: placementRef.value,
|
|
11
|
+
strategy: 'fixed',
|
|
12
|
+
modifiers: [
|
|
13
|
+
{
|
|
14
|
+
name: 'offset',
|
|
15
|
+
options: { offset: offsets }
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'preventOverflow',
|
|
19
|
+
options: {
|
|
20
|
+
altAxis: true,
|
|
21
|
+
padding: 2
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'flip',
|
|
26
|
+
enabled: false
|
|
27
|
+
}
|
|
28
|
+
]
|
|
25
29
|
});
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
|
|
32
|
+
const update = () => popper?.update();
|
|
29
33
|
|
|
30
34
|
return {
|
|
35
|
+
update,
|
|
31
36
|
mount,
|
|
32
37
|
isActiveRef,
|
|
33
38
|
offsets
|
|
File without changes
|
|
File without changes
|
|
@@ -26,9 +26,9 @@ export const Alignment = Extension.create({
|
|
|
26
26
|
return { desktop: textAlign, tablet: textAlign, mobile: textAlign };
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const mobile = style.getPropertyValue('--zw-
|
|
30
|
-
const tablet = style.getPropertyValue('--zw-
|
|
31
|
-
const desktop = style.getPropertyValue('--zw-
|
|
29
|
+
const mobile = style.getPropertyValue('--zw-alignment-mobile') || null;
|
|
30
|
+
const tablet = style.getPropertyValue('--zw-alignment-tablet') || null;
|
|
31
|
+
const desktop = style.getPropertyValue('--zw-alignment-desktop') || null;
|
|
32
32
|
|
|
33
33
|
if (!mobile && !tablet && !desktop) return null;
|
|
34
34
|
|
|
@@ -39,9 +39,9 @@ export const Alignment = Extension.create({
|
|
|
39
39
|
if (!attrs.alignment) return null;
|
|
40
40
|
|
|
41
41
|
return renderInlineSetting({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
alignment_mobile: attrs.alignment.mobile,
|
|
43
|
+
alignment_tablet: attrs.alignment.tablet,
|
|
44
|
+
alignment_desktop: attrs.alignment.desktop
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -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,
|
|
@@ -57,7 +56,7 @@ export const FontSize = Mark.create({
|
|
|
57
56
|
return;
|
|
58
57
|
}
|
|
59
58
|
|
|
60
|
-
tr.
|
|
59
|
+
tr.addNodeMark(position, updated);
|
|
61
60
|
}
|
|
62
61
|
});
|
|
63
62
|
}),
|
package/lib/extensions/Link.js
CHANGED
|
@@ -55,6 +55,8 @@ export const Link = Base.extend({
|
|
|
55
55
|
...this.parent?.(),
|
|
56
56
|
|
|
57
57
|
applyLink: createCommand(({ commands, chain }, attributes) => {
|
|
58
|
+
commands.setMeta('preventAutolink', true);
|
|
59
|
+
|
|
58
60
|
if (!commands.getSelectedText()) {
|
|
59
61
|
return commands.insertContent(NodeFactory.text(attributes.text, [
|
|
60
62
|
NodeFactory.mark(TextSettings.LINK, attributes)
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-2';
|
|
2
2
|
import { computed, toRef, unref } from 'vue';
|
|
3
3
|
import { createCommand } from '../utils';
|
|
4
|
-
import {
|
|
4
|
+
import { NodeTypes, TextSettings } from '../enums';
|
|
5
5
|
import { ContextWindow } from '../services';
|
|
6
6
|
|
|
7
|
-
function makePresetClass(base, preset) {
|
|
8
|
-
const baseClass = base.split(' ').map((part) => `.${part}`).join('');
|
|
9
|
-
|
|
10
|
-
return baseClass + preset.id;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
7
|
export const StylePreset = Extension.create({
|
|
14
8
|
name: TextSettings.STYLE_PRESET,
|
|
15
9
|
|
|
16
|
-
addStorage: () => ({
|
|
17
|
-
presetStyleEl: null
|
|
18
|
-
}),
|
|
19
|
-
|
|
20
10
|
addGlobalAttributes() {
|
|
21
11
|
return [
|
|
22
12
|
{
|
|
@@ -32,13 +22,13 @@ export const StylePreset = Extension.create({
|
|
|
32
22
|
if (element.parentElement.tagName === 'LI') return null;
|
|
33
23
|
|
|
34
24
|
for (const { id, node, fallbackClass } of presets) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
25
|
+
if (fallbackClass && element.classList.contains(fallbackClass)) {
|
|
26
|
+
return { id };
|
|
27
|
+
}
|
|
38
28
|
|
|
39
|
-
const
|
|
29
|
+
const presetSelector = this.options.styleRenderer.makePresetCssClass({ id });
|
|
40
30
|
|
|
41
|
-
if (element.matches(
|
|
31
|
+
if (element.matches(presetSelector)) return { id };
|
|
42
32
|
if (element.tagName === `H${node?.level}`) return { id };
|
|
43
33
|
}
|
|
44
34
|
|
|
@@ -49,7 +39,7 @@ export const StylePreset = Extension.create({
|
|
|
49
39
|
renderHTML: (attrs) => {
|
|
50
40
|
if (!attrs.preset) return null;
|
|
51
41
|
|
|
52
|
-
return { class: this.options.
|
|
42
|
+
return { class: this.options.styleRenderer.makePresetHtmlClass(attrs.preset) };
|
|
53
43
|
}
|
|
54
44
|
}
|
|
55
45
|
}
|
|
@@ -208,34 +198,6 @@ export const StylePreset = Extension.create({
|
|
|
208
198
|
},
|
|
209
199
|
|
|
210
200
|
onCreate() {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (existingStyleEl) {
|
|
214
|
-
this.storage.presetStyleEl = existingStyleEl;
|
|
215
|
-
return;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
this.storage.presetStyleEl = ContextWindow.document.createElement('style');
|
|
219
|
-
this.storage.presetStyleEl.dataset.zwStyles = '';
|
|
220
|
-
|
|
221
|
-
for (const preset of this.options.presets) {
|
|
222
|
-
const className = makePresetClass(this.options.baseClass, preset);
|
|
223
|
-
const css = [` ${className} {`];
|
|
224
|
-
|
|
225
|
-
for (const device of Devices.values) {
|
|
226
|
-
for (const setting of Object.keys(preset[device])) {
|
|
227
|
-
const variable = this.options.makeVariable({ device, preset, property: setting });
|
|
228
|
-
const property = setting.replace(/_/i, '-');
|
|
229
|
-
const prefix = device === Devices.COMMON ? 'preset' : `preset-${device}`;
|
|
230
|
-
|
|
231
|
-
css.push(`--zw-${prefix}-${property}: var(${variable}, inherit);`);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
css.push('}');
|
|
236
|
-
this.storage.presetStyleEl.innerHTML += css.join(' ');
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
ContextWindow.head.append(this.storage.presetStyleEl);
|
|
201
|
+
this.options.styleRenderer.inject(ContextWindow.head, this.options.presets);
|
|
240
202
|
}
|
|
241
203
|
});
|
|
@@ -144,7 +144,7 @@ describe('parsing html', () => {
|
|
|
144
144
|
|
|
145
145
|
test('should get alignment from rendered view', () => {
|
|
146
146
|
const editor = createEditor({
|
|
147
|
-
content: '<p style="--zw-
|
|
147
|
+
content: '<p style="--zw-alignment-mobile:center;--zw-alignment-desktop:right">test</p>'
|
|
148
148
|
});
|
|
149
149
|
|
|
150
150
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
@@ -41,7 +41,7 @@ describe('get background color', () => {
|
|
|
41
41
|
|
|
42
42
|
editor.commands.selectAll();
|
|
43
43
|
|
|
44
|
-
expect(editor.commands.getBackgroundColor().value).
|
|
44
|
+
expect(editor.commands.getBackgroundColor().value).toBe('green');
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
test('should get default background color', () => {
|
|
@@ -49,7 +49,7 @@ describe('get background color', () => {
|
|
|
49
49
|
content: createContent(NodeFactory.text('hello world'))
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
expect(editor.commands.getBackgroundColor().value).
|
|
52
|
+
expect(editor.commands.getBackgroundColor().value).toBe('rgba(255, 255, 255, 0%)');
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
|
|
@@ -41,7 +41,7 @@ describe('get font color', () => {
|
|
|
41
41
|
|
|
42
42
|
editor.commands.selectAll();
|
|
43
43
|
|
|
44
|
-
expect(editor.commands.getFontColor().value).
|
|
44
|
+
expect(editor.commands.getFontColor().value).toBe('green');
|
|
45
45
|
});
|
|
46
46
|
|
|
47
47
|
test('should get default font color', () => {
|
|
@@ -49,7 +49,7 @@ describe('get font color', () => {
|
|
|
49
49
|
content: createContent(NodeFactory.text('hello world'))
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
expect(editor.commands.getDefaultFontColor().value).
|
|
52
|
+
expect(editor.commands.getDefaultFontColor().value).toBe('red');
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
test('should get from preset', () => {
|
|
@@ -59,7 +59,7 @@ describe('get font color', () => {
|
|
|
59
59
|
|
|
60
60
|
editor.commands.selectAll();
|
|
61
61
|
|
|
62
|
-
expect(editor.commands.getFontColor().value).
|
|
62
|
+
expect(editor.commands.getFontColor().value).toBe('red');
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
|
|
@@ -62,7 +62,7 @@ describe('get font family', () => {
|
|
|
62
62
|
|
|
63
63
|
editor.commands.selectAll();
|
|
64
64
|
|
|
65
|
-
expect(editor.commands.getFontFamily().value).
|
|
65
|
+
expect(editor.commands.getFontFamily().value).toBe('Bungee');
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
test('should get default font family', () => {
|
|
@@ -70,7 +70,7 @@ describe('get font family', () => {
|
|
|
70
70
|
content: createContent(NodeFactory.text('hello world'))
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
expect(editor.commands.getDefaultFontFamily().value).
|
|
73
|
+
expect(editor.commands.getDefaultFontFamily().value).toBe('Lato');
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
test('should get from preset', () => {
|
|
@@ -80,7 +80,7 @@ describe('get font family', () => {
|
|
|
80
80
|
|
|
81
81
|
editor.commands.selectAll();
|
|
82
82
|
|
|
83
|
-
expect(editor.commands.getFontFamily().value).
|
|
83
|
+
expect(editor.commands.getFontFamily().value).toBe('Lato');
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
test('should find font model by name', () => {
|
|
@@ -58,7 +58,7 @@ describe('get font size', () => {
|
|
|
58
58
|
|
|
59
59
|
editor.commands.selectAll();
|
|
60
60
|
|
|
61
|
-
expect(editor.commands.getFontSize().value).
|
|
61
|
+
expect(editor.commands.getFontSize().value).toBe('14');
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
test('should default value', () => {
|
|
@@ -66,7 +66,7 @@ describe('get font size', () => {
|
|
|
66
66
|
content: createContent(NodeFactory.text('hello world'))
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
expect(editor.commands.getDefaultFontSize().value).
|
|
69
|
+
expect(editor.commands.getDefaultFontSize().value).toBe('14');
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
test('should get from preset', () => {
|
|
@@ -76,7 +76,7 @@ describe('get font size', () => {
|
|
|
76
76
|
|
|
77
77
|
editor.commands.selectAll();
|
|
78
78
|
|
|
79
|
-
expect(editor.commands.getFontSize().value).
|
|
79
|
+
expect(editor.commands.getFontSize().value).toBe('14');
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
82
|
|
|
@@ -60,7 +60,7 @@ describe('get font weight', () => {
|
|
|
60
60
|
|
|
61
61
|
editor.commands.selectAll();
|
|
62
62
|
|
|
63
|
-
expect(editor.commands.getFontWeight().value).
|
|
63
|
+
expect(editor.commands.getFontWeight().value).toBe('700');
|
|
64
64
|
});
|
|
65
65
|
|
|
66
66
|
test('should default value', () => {
|
|
@@ -68,7 +68,7 @@ describe('get font weight', () => {
|
|
|
68
68
|
content: createContent(NodeFactory.text('hello world'))
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
expect(editor.commands.getDefaultFontWeight().value).
|
|
71
|
+
expect(editor.commands.getDefaultFontWeight().value).toBe('400');
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
test('should get from preset', () => {
|
|
@@ -78,7 +78,7 @@ describe('get font weight', () => {
|
|
|
78
78
|
|
|
79
79
|
editor.commands.selectAll();
|
|
80
80
|
|
|
81
|
-
expect(editor.commands.getFontWeight().value).
|
|
81
|
+
expect(editor.commands.getFontWeight().value).toBe('400');
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
test('should get closest available font weight', () => {
|
|
@@ -90,7 +90,7 @@ describe('get font weight', () => {
|
|
|
90
90
|
|
|
91
91
|
editor.commands.selectAll();
|
|
92
92
|
|
|
93
|
-
expect(editor.commands.getFontWeight().value).
|
|
93
|
+
expect(editor.commands.getFontWeight().value).toBe('700');
|
|
94
94
|
});
|
|
95
95
|
});
|
|
96
96
|
|
|
@@ -62,7 +62,7 @@ describe('get value', () => {
|
|
|
62
62
|
content: createContent({ line_height: null })
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
expect(editor.commands.getDefaultLineHeight().value).
|
|
65
|
+
expect(editor.commands.getDefaultLineHeight().value).toBe('1.2');
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
test('should get from preset', () => {
|
|
@@ -70,7 +70,7 @@ describe('get value', () => {
|
|
|
70
70
|
content: createContent({ line_height: null })
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
expect(editor.commands.getLineHeight().value).
|
|
73
|
+
expect(editor.commands.getLineHeight().value).toBe('1.2');
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
|
|
@@ -3,7 +3,7 @@ import { Editor, Mark } from '@tiptap/vue-2';
|
|
|
3
3
|
import { buildTestExtensions } from '../../__tests__/utils';
|
|
4
4
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
5
5
|
import { Link } from '../Link';
|
|
6
|
-
import { TextSettings } from '../../enums';
|
|
6
|
+
import { LinkDestinations, LinkTargets, TextSettings } from '../../enums';
|
|
7
7
|
|
|
8
8
|
const MockFontWeight = Mark.create({
|
|
9
9
|
name: TextSettings.FONT_WEIGHT,
|
|
@@ -27,11 +27,12 @@ function createEditor({ content }) {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const createLink = (
|
|
31
|
-
href:
|
|
30
|
+
const createLink = (attrs = {}) => ({
|
|
31
|
+
href: '/test',
|
|
32
32
|
text: 'Hello world link',
|
|
33
|
-
target:
|
|
34
|
-
destination:
|
|
33
|
+
target: LinkTargets.SELF,
|
|
34
|
+
destination: LinkDestinations.URL,
|
|
35
|
+
...attrs
|
|
35
36
|
});
|
|
36
37
|
|
|
37
38
|
describe('get link', () => {
|
|
@@ -108,6 +109,33 @@ describe('apply link', () => {
|
|
|
108
109
|
|
|
109
110
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
110
111
|
});
|
|
112
|
+
|
|
113
|
+
test('should apply link to text with link', () => {
|
|
114
|
+
const editor = createEditor({
|
|
115
|
+
content: NodeFactory.doc([
|
|
116
|
+
NodeFactory.paragraph([
|
|
117
|
+
NodeFactory.text('https://google.com', [
|
|
118
|
+
NodeFactory.mark(TextSettings.LINK, {
|
|
119
|
+
href: 'https://google.com',
|
|
120
|
+
destination: LinkDestinations.URL,
|
|
121
|
+
target: LinkTargets.SELF
|
|
122
|
+
})
|
|
123
|
+
])
|
|
124
|
+
])
|
|
125
|
+
])
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
editor.commands.selectAll();
|
|
129
|
+
|
|
130
|
+
editor.commands.applyLink({
|
|
131
|
+
text: 'https://google.com',
|
|
132
|
+
href: 'https://google.com',
|
|
133
|
+
destination: LinkDestinations.URL,
|
|
134
|
+
target: LinkTargets.BLANK
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
expect(editor.getJSON()).toMatchSnapshot();
|
|
138
|
+
});
|
|
111
139
|
});
|
|
112
140
|
|
|
113
141
|
describe('parse html', () => {
|