@zipify/wysiwyg 1.0.0-dev.9 → 1.0.0-dev.92
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/.editorconfig +1 -1
- package/.eslintrc.js +2 -2
- package/.github/dependabot.yaml +1 -0
- package/.lintstagedrc +2 -2
- package/.release-it.json +3 -1
- package/.stylelintrc +0 -4
- package/README.md +2 -2
- package/config/jest/setupTests.js +0 -3
- package/config/vite/example.config.js +25 -0
- package/config/vite/lib.config.js +30 -0
- package/config/{webpack → vite}/settings.js +0 -0
- package/dist/wysiwyg.css +404 -373
- package/dist/wysiwyg.mjs +26015 -0
- package/example/ExampleApp.vue +35 -4
- package/example/example.js +0 -3
- package/example/{example.html → index.html} +1 -0
- package/example/pageBlocks.js +31 -0
- package/example/presets.js +2 -2
- package/example/tooltip/Tooltip.js +1 -1
- package/jest.config.js +3 -1
- package/lib/Wysiwyg.vue +73 -14
- package/lib/__tests__/utils/index.js +0 -1
- package/lib/__tests__/utils/withComponentContext.js +1 -1
- package/lib/assets/icons/background-color.svg +3 -1
- package/lib/assets/icons/font-color.svg +1 -3
- package/lib/assets/icons/link.svg +3 -0
- package/lib/assets/icons/unlink.svg +3 -0
- package/lib/components/base/Button.vue +23 -2
- package/lib/components/base/Checkbox.vue +89 -0
- package/lib/components/base/FieldLabel.vue +2 -1
- package/lib/components/base/Icon.vue +3 -3
- package/lib/components/base/Modal.vue +1 -2
- package/lib/components/base/NumberField.vue +2 -2
- package/lib/components/base/Range.vue +1 -1
- package/lib/components/base/ScrollView.vue +1 -3
- package/lib/components/base/TextField.vue +108 -0
- package/lib/components/base/__tests__/Modal.test.js +7 -2
- package/lib/components/base/__tests__/TextField.test.js +57 -0
- package/lib/components/base/__tests__/__snapshots__/TextField.test.js.snap +9 -0
- package/lib/components/base/colorPicker/ColorPicker.vue +14 -12
- package/lib/components/base/colorPicker/composables/__tests__/usePickerApi.test.js +6 -6
- package/lib/components/base/colorPicker/composables/usePickerApi.js +15 -8
- package/lib/components/base/colorPicker/composables/usePickerHotkeys.js +3 -2
- package/lib/components/base/composables/__tests__/useActivatedListener.test.js +1 -1
- package/lib/components/base/composables/__tests__/useDeselectionLock.test.js +1 -1
- package/lib/components/base/composables/__tests__/useElementRef.test.js +1 -1
- package/lib/components/base/composables/__tests__/useModalToggler.test.js +1 -1
- package/lib/components/base/composables/__tests__/useNumberValue.test.js +1 -1
- package/lib/components/base/composables/__tests__/useScrollView.test.js +1 -1
- package/lib/components/base/composables/__tests__/useTempValue.test.js +1 -1
- package/lib/components/base/composables/__tests__/useValidator.test.js +44 -0
- package/lib/components/base/composables/index.js +1 -0
- package/lib/components/base/composables/useActivatedListener.js +1 -1
- package/lib/components/base/composables/useDeselectionLock.js +1 -1
- package/lib/components/base/composables/useElementRef.js +1 -1
- package/lib/components/base/composables/useModalToggler.js +6 -2
- package/lib/components/base/composables/useScrollView.js +1 -1
- package/lib/components/base/composables/useTempValue.js +1 -1
- package/lib/components/base/composables/useValidator.js +23 -0
- package/lib/components/base/dropdown/Dropdown.vue +16 -4
- package/lib/components/base/dropdown/DropdownActivator.vue +19 -3
- package/lib/components/base/dropdown/DropdownGroup.vue +1 -1
- package/lib/components/base/dropdown/DropdownMenu.vue +1 -1
- package/lib/components/base/dropdown/DropdownOption.vue +1 -1
- package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +1 -1
- package/lib/components/base/dropdown/__tests__/DropdownMenu.test.js +1 -1
- package/lib/components/base/dropdown/__tests__/DropdownOption.test.js +1 -1
- package/lib/components/base/dropdown/composables/__tests__/useActiveOptionManager.test.js +1 -1
- package/lib/components/base/dropdown/composables/__tests__/useDropdownEntityTitle.test.js +1 -1
- package/lib/components/base/dropdown/composables/useActiveOptionManager.js +1 -1
- package/lib/components/base/dropdown/composables/useDropdownEntityTitle.js +1 -1
- package/lib/components/base/index.js +3 -1
- package/lib/components/toolbar/Toolbar.vue +51 -9
- package/lib/components/toolbar/ToolbarDivider.vue +1 -1
- package/lib/components/toolbar/ToolbarFull.vue +41 -10
- package/lib/components/toolbar/ToolbarRow.vue +1 -0
- package/lib/components/toolbar/__tests__/Toolbar.test.js +6 -0
- package/lib/components/toolbar/controls/AlignmentControl.vue +1 -1
- package/lib/components/toolbar/controls/AlignmentDeviceControl.vue +1 -1
- package/lib/components/toolbar/controls/BackgroundColorControl.vue +1 -1
- package/lib/components/toolbar/controls/CaseStyleControl.vue +1 -1
- package/lib/components/toolbar/controls/FontColorControl.vue +1 -1
- package/lib/components/toolbar/controls/FontFamilyControl.vue +1 -1
- package/lib/components/toolbar/controls/FontSizeControl.vue +8 -1
- package/lib/components/toolbar/controls/FontWeightControl.vue +2 -2
- package/lib/components/toolbar/controls/ItalicControl.vue +1 -1
- package/lib/components/toolbar/controls/LineHeightControl.vue +1 -1
- package/lib/components/toolbar/controls/ListControl.vue +70 -36
- package/lib/components/toolbar/controls/RemoveFormatControl.vue +1 -1
- package/lib/components/toolbar/controls/StrikeThroughControl.vue +1 -1
- package/lib/components/toolbar/controls/StylePresetControl.vue +17 -4
- package/lib/components/toolbar/controls/SuperscriptControl.vue +1 -1
- package/lib/components/toolbar/controls/UnderlineControl.vue +1 -1
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/AlignmentDeviceControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/BackgroundColorControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/CaseStyleControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/ListControl.test.js +18 -3
- package/lib/components/toolbar/controls/__tests__/StrikeThroughControl.test.js +1 -1
- package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +17 -1
- package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +5 -1
- package/lib/components/toolbar/controls/composables/useRecentFonts.js +1 -1
- package/lib/components/toolbar/controls/index.js +1 -0
- package/lib/components/toolbar/controls/link/LinkControl.vue +160 -0
- package/lib/components/toolbar/controls/link/LinkControlApply.vue +35 -0
- package/lib/components/toolbar/controls/link/LinkControlHeader.vue +69 -0
- package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +79 -0
- package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +42 -0
- package/lib/components/toolbar/controls/link/composables/__tests__/__snapshots__/useLink.test.js.snap +15 -0
- package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +172 -0
- package/lib/components/toolbar/controls/link/composables/index.js +1 -0
- package/lib/components/toolbar/controls/link/composables/useLink.js +82 -0
- package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +103 -0
- package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +54 -0
- package/lib/components/toolbar/controls/link/destination/LinkControlUrl.vue +52 -0
- package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlPageBlock.test.js +36 -0
- package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlUrl.test.js +46 -0
- package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlPageBlock.test.js.snap +9 -0
- package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlUrl.test.js.snap +17 -0
- package/lib/components/toolbar/controls/link/destination/index.js +1 -0
- package/lib/components/toolbar/controls/link/index.js +1 -0
- package/lib/composables/__tests__/__snapshots__/useEditor.test.js.snap +1 -0
- package/lib/composables/__tests__/useEditor.test.js +5 -4
- package/lib/composables/useEditor.js +12 -9
- package/lib/composables/useToolbar.js +26 -19
- package/lib/directives/__tests__/outClick.test.js +6 -0
- package/lib/directives/outClick.js +19 -6
- package/lib/enums/Alignments.js +10 -1
- package/lib/enums/LinkDestinations.js +4 -0
- package/lib/enums/LinkTargets.js +4 -0
- package/lib/enums/TextSettings.js +3 -1
- package/lib/enums/index.js +2 -0
- package/lib/extensions/Alignment.js +25 -11
- package/lib/extensions/BackgroundColor.js +15 -7
- package/lib/extensions/DeviceManager.js +2 -5
- package/lib/extensions/FontColor.js +17 -9
- package/lib/extensions/FontFamily.js +30 -13
- package/lib/extensions/FontSize.js +38 -18
- package/lib/extensions/FontStyle.js +30 -20
- package/lib/extensions/FontWeight.js +34 -23
- package/lib/extensions/LineHeight.js +36 -32
- package/lib/extensions/Link.js +92 -0
- package/lib/extensions/StylePreset.js +23 -22
- package/lib/extensions/Superscript.js +5 -1
- package/lib/extensions/TextDecoration.js +52 -19
- package/lib/extensions/__tests__/Alignment.test.js +14 -9
- package/lib/extensions/__tests__/BackgroundColor.test.js +13 -8
- package/lib/extensions/__tests__/CaseStyle.test.js +4 -7
- package/lib/extensions/__tests__/FontColor.test.js +13 -8
- package/lib/extensions/__tests__/FontFamily.test.js +34 -10
- package/lib/extensions/__tests__/FontSize.test.js +16 -10
- package/lib/extensions/__tests__/FontStyle.test.js +13 -8
- package/lib/extensions/__tests__/FontWeight.test.js +21 -8
- package/lib/extensions/__tests__/LineHeight.test.js +25 -14
- package/lib/extensions/__tests__/Link.test.js +101 -0
- package/lib/extensions/__tests__/StylePreset.test.js +72 -10
- package/lib/extensions/__tests__/TextDecoration.test.js +53 -8
- package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +26 -2
- package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +30 -1
- package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +18 -1
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +88 -1
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +33 -2
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +25 -4
- package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +47 -1
- package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +26 -2
- package/lib/extensions/__tests__/__snapshots__/Link.test.js.snap +225 -0
- package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +6 -2
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +183 -3
- package/lib/extensions/core/CopyPasteProcessor.js +10 -0
- package/lib/extensions/core/NodeProcessor.js +2 -2
- package/lib/extensions/core/TextProcessor.js +11 -24
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +4 -7
- package/lib/extensions/core/__tests__/SelectionProcessor.test.js +4 -7
- package/lib/extensions/core/__tests__/TextProcessor.test.js +139 -14
- package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +26 -0
- package/lib/extensions/core/index.js +11 -2
- package/lib/extensions/core/plugins/PastePlugin.js +57 -0
- package/lib/extensions/core/plugins/ProseMirrorPlugin.js +20 -0
- package/lib/extensions/core/plugins/index.js +1 -0
- package/lib/extensions/index.js +46 -34
- package/lib/extensions/list/List.js +7 -6
- package/lib/extensions/list/__tests__/List.test.js +6 -10
- package/lib/extensions/list/__tests__/__snapshots__/List.test.js.snap +60 -20
- package/lib/index.js +3 -0
- package/lib/injectionTokens.js +3 -1
- package/lib/services/ContentNormalizer.js +144 -28
- package/lib/services/ContextWidnow.js +23 -0
- package/lib/{__tests__/utils → services}/NodeFactory.js +5 -1
- package/lib/services/__tests__/ContentNormalizer.test.js +124 -8
- package/lib/services/__tests__/FavoriteColors.test.js +1 -1
- package/lib/services/index.js +2 -0
- package/lib/styles/content.css +108 -13
- package/lib/styles/helpers/offsets.css +16 -0
- package/lib/styles/variables.css +6 -0
- package/lib/utils/__tests__/__snapshots__/renderInlineSetting.test.js.snap +4 -4
- package/lib/utils/__tests__/convertAlignment.test.js +16 -0
- package/lib/utils/__tests__/convertFontSize.test.js +21 -0
- package/lib/utils/__tests__/convertLineHeight.test.js +21 -0
- package/lib/utils/convertAlignment.js +12 -0
- package/lib/utils/convertColor.js +1 -1
- package/lib/utils/convertFontSize.js +8 -0
- package/lib/utils/convertLineHeight.js +17 -0
- package/lib/utils/importIcon.js +7 -6
- package/lib/utils/index.js +4 -0
- package/lib/utils/isWysiwygContent.js +12 -0
- package/lib/utils/renderInlineSetting.js +1 -1
- package/package.json +26 -30
- package/config/webpack/example.config.js +0 -88
- package/config/webpack/lib.config.js +0 -44
- package/config/webpack/loaders/index.js +0 -6
- package/config/webpack/loaders/js-loader.js +0 -5
- package/config/webpack/loaders/style-loader.js +0 -9
- package/config/webpack/loaders/svg-loader.js +0 -4
- package/config/webpack/loaders/vue-loader.js +0 -4
- package/dist/wysiwyg.js +0 -2
- package/dist/wysiwyg.js.LICENSE.txt +0 -1
- package/lib/extensions/core/inputRules/closeDoubleQuote.js +0 -6
- package/lib/extensions/core/inputRules/closeSingleQuote.js +0 -6
- package/lib/extensions/core/inputRules/copyright.js +0 -6
- package/lib/extensions/core/inputRules/ellipsis.js +0 -6
- package/lib/extensions/core/inputRules/emDash.js +0 -6
- package/lib/extensions/core/inputRules/index.js +0 -9
- package/lib/extensions/core/inputRules/openDoubleQuote.js +0 -6
- package/lib/extensions/core/inputRules/openSingleQuote.js +0 -6
- package/lib/extensions/core/inputRules/registeredTrademark.js +0 -6
- package/lib/extensions/core/inputRules/trademark.js +0 -6
|
@@ -1,33 +1,40 @@
|
|
|
1
1
|
import { createPopper } from '@popperjs/core';
|
|
2
|
-
import {
|
|
3
|
-
import { useElementRef } from '../components/base/composables';
|
|
2
|
+
import { useElementRef } from '../components/base';
|
|
4
3
|
|
|
5
|
-
export function useToolbar({ wrapperRef,
|
|
6
|
-
|
|
4
|
+
export function useToolbar({ wrapperRef, offsets, isActiveRef, placementRef }) {
|
|
5
|
+
const wrapperEl = useElementRef(wrapperRef);
|
|
6
|
+
let popper;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
toolbar = createPopper(wrapperEl, toolbarEl, {
|
|
13
|
-
placement: 'top-start',
|
|
8
|
+
function mount(element) {
|
|
9
|
+
popper = createPopper(wrapperEl.value, element, {
|
|
10
|
+
placement: placementRef.value,
|
|
11
|
+
strategy: 'fixed',
|
|
14
12
|
modifiers: [
|
|
15
13
|
{
|
|
16
14
|
name: 'offset',
|
|
15
|
+
options: { offset: offsets }
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'preventOverflow',
|
|
17
19
|
options: {
|
|
18
|
-
|
|
20
|
+
altAxis: true,
|
|
21
|
+
padding: 2
|
|
19
22
|
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: 'flip',
|
|
26
|
+
enabled: false
|
|
20
27
|
}
|
|
21
28
|
]
|
|
22
29
|
});
|
|
23
|
-
}
|
|
24
|
-
const update = () => toolbar.update();
|
|
25
|
-
|
|
26
|
-
watch(isActiveRef, () => {
|
|
27
|
-
if (isActiveRef.value) update();
|
|
28
|
-
});
|
|
30
|
+
}
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
const update = () => popper?.update();
|
|
31
33
|
|
|
32
|
-
return {
|
|
34
|
+
return {
|
|
35
|
+
update,
|
|
36
|
+
mount,
|
|
37
|
+
isActiveRef,
|
|
38
|
+
offsets
|
|
39
|
+
};
|
|
33
40
|
}
|
|
@@ -10,6 +10,7 @@ describe('out click', () => {
|
|
|
10
10
|
await waitAsyncOperation();
|
|
11
11
|
|
|
12
12
|
document.dispatchEvent(new Event('click'));
|
|
13
|
+
await waitAsyncOperation();
|
|
13
14
|
|
|
14
15
|
expect(onOutClick).toHaveBeenCalled();
|
|
15
16
|
});
|
|
@@ -22,6 +23,7 @@ describe('out click', () => {
|
|
|
22
23
|
await waitAsyncOperation();
|
|
23
24
|
|
|
24
25
|
el.dispatchEvent(new Event('click'));
|
|
26
|
+
await waitAsyncOperation();
|
|
25
27
|
|
|
26
28
|
expect(onOutClick).not.toHaveBeenCalled();
|
|
27
29
|
});
|
|
@@ -36,6 +38,7 @@ describe('out click', () => {
|
|
|
36
38
|
await waitAsyncOperation();
|
|
37
39
|
|
|
38
40
|
child.dispatchEvent(new Event('click'));
|
|
41
|
+
await waitAsyncOperation();
|
|
39
42
|
|
|
40
43
|
expect(onOutClick).not.toHaveBeenCalled();
|
|
41
44
|
});
|
|
@@ -50,6 +53,7 @@ describe('out click', () => {
|
|
|
50
53
|
outClick.unbind(el);
|
|
51
54
|
|
|
52
55
|
document.dispatchEvent(new Event('click'));
|
|
56
|
+
await waitAsyncOperation();
|
|
53
57
|
|
|
54
58
|
expect(onOutClick).not.toHaveBeenCalled();
|
|
55
59
|
});
|
|
@@ -65,6 +69,7 @@ describe('out click', () => {
|
|
|
65
69
|
await waitAsyncOperation();
|
|
66
70
|
|
|
67
71
|
document.dispatchEvent(new Event('click'));
|
|
72
|
+
await waitAsyncOperation();
|
|
68
73
|
|
|
69
74
|
expect(onOutClick).toHaveBeenCalled();
|
|
70
75
|
});
|
|
@@ -80,6 +85,7 @@ describe('out click', () => {
|
|
|
80
85
|
await waitAsyncOperation();
|
|
81
86
|
|
|
82
87
|
document.dispatchEvent(new Event('click'));
|
|
88
|
+
await waitAsyncOperation();
|
|
83
89
|
|
|
84
90
|
expect(onOutClick).not.toHaveBeenCalled();
|
|
85
91
|
});
|
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import { ContextWindow } from '../services';
|
|
2
|
+
|
|
1
3
|
const dataStorage = new WeakMap();
|
|
2
4
|
|
|
5
|
+
function toggleListener(toEnable, onClick) {
|
|
6
|
+
const args = ['click', onClick, { capture: true }];
|
|
7
|
+
const action = toEnable ? 'addEventListener' : 'removeEventListener';
|
|
8
|
+
|
|
9
|
+
if (ContextWindow.window !== window) {
|
|
10
|
+
window.document[action](...args);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
ContextWindow.document[action](...args);
|
|
14
|
+
}
|
|
15
|
+
|
|
3
16
|
export const outClick = {
|
|
4
17
|
bind(el, { value }) {
|
|
5
18
|
const onOutClick = value.onOutClick || value;
|
|
@@ -8,13 +21,15 @@ export const outClick = {
|
|
|
8
21
|
function onClick(event) {
|
|
9
22
|
const isInside = event.target === el || el.contains(event.target);
|
|
10
23
|
|
|
11
|
-
if (event.target.isConnected && !isInside)
|
|
24
|
+
if (event.target.isConnected && !isInside) {
|
|
25
|
+
setTimeout(() => onOutClick(event));
|
|
26
|
+
}
|
|
12
27
|
}
|
|
13
28
|
|
|
14
29
|
dataStorage.set(el, { callback: onClick, isEnabled });
|
|
15
30
|
|
|
16
31
|
if (isEnabled) {
|
|
17
|
-
setTimeout(() =>
|
|
32
|
+
setTimeout(() => toggleListener(true, onClick));
|
|
18
33
|
}
|
|
19
34
|
},
|
|
20
35
|
|
|
@@ -24,14 +39,12 @@ export const outClick = {
|
|
|
24
39
|
|
|
25
40
|
if (isEnabled === data.isEnabled) return;
|
|
26
41
|
|
|
27
|
-
isEnabled
|
|
28
|
-
? document.addEventListener('click', data.callback)
|
|
29
|
-
: document.removeEventListener('click', data.callback);
|
|
42
|
+
toggleListener(isEnabled, data.callback);
|
|
30
43
|
|
|
31
44
|
dataStorage.set(el, { callback: data.callback, isEnabled });
|
|
32
45
|
},
|
|
33
46
|
|
|
34
47
|
unbind(el) {
|
|
35
|
-
|
|
48
|
+
toggleListener(false, dataStorage.get(el).callback);
|
|
36
49
|
}
|
|
37
50
|
};
|
package/lib/enums/Alignments.js
CHANGED
|
@@ -8,6 +8,7 @@ export const TextSettings = Object.freeze({
|
|
|
8
8
|
FONT_WEIGHT: 'font_weight',
|
|
9
9
|
LINE_HEIGHT: 'line_height',
|
|
10
10
|
TEXT_DECORATION: 'text_decoration',
|
|
11
|
+
SUPERSCRIPT: 'superscript',
|
|
11
12
|
|
|
12
13
|
get attributes() {
|
|
13
14
|
return [
|
|
@@ -24,7 +25,8 @@ export const TextSettings = Object.freeze({
|
|
|
24
25
|
this.FONT_SIZE,
|
|
25
26
|
this.FONT_STYLE,
|
|
26
27
|
this.FONT_WEIGHT,
|
|
27
|
-
this.TEXT_DECORATION
|
|
28
|
+
this.TEXT_DECORATION,
|
|
29
|
+
this.SUPERSCRIPT
|
|
28
30
|
];
|
|
29
31
|
}
|
|
30
32
|
});
|
package/lib/enums/index.js
CHANGED
|
@@ -4,3 +4,5 @@ export { Alignments } from './Alignments';
|
|
|
4
4
|
export { NodeTypes } from './NodeTypes';
|
|
5
5
|
export { ListTypes } from './ListTypes';
|
|
6
6
|
export { TextSettings } from './TextSettings';
|
|
7
|
+
export { LinkTargets } from './LinkTargets';
|
|
8
|
+
export { LinkDestinations } from './LinkDestinations';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from '
|
|
3
|
-
import { createCommand, createKeyboardShortcut, renderInlineSetting } from '../utils';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
|
+
import { convertAlignment, createCommand, createKeyboardShortcut, renderInlineSetting } from '../utils';
|
|
4
4
|
import { Alignments, NodeTypes, TextSettings } from '../enums';
|
|
5
5
|
|
|
6
6
|
const DEFAULTS = {
|
|
@@ -19,19 +19,33 @@ export const Alignment = Extension.create({
|
|
|
19
19
|
[TextSettings.ALIGNMENT]: {
|
|
20
20
|
isRequired: false,
|
|
21
21
|
|
|
22
|
-
parseHTML(
|
|
23
|
-
const
|
|
22
|
+
parseHTML({ style }) {
|
|
23
|
+
const textAlign = convertAlignment(style.textAlign);
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
if (textAlign) {
|
|
26
|
+
return {
|
|
27
|
+
desktop: textAlign,
|
|
28
|
+
tablet: textAlign,
|
|
29
|
+
mobile: textAlign
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const mobile = style.getPropertyValue('--zw-text-align-mobile') || null;
|
|
34
|
+
const tablet = style.getPropertyValue('--zw-text-align-tablet') || null;
|
|
35
|
+
const desktop = style.getPropertyValue('--zw-text-align-desktop') || null;
|
|
36
|
+
|
|
37
|
+
if (!mobile && !tablet && !desktop) return null;
|
|
38
|
+
|
|
39
|
+
return { desktop, tablet, mobile };
|
|
26
40
|
},
|
|
27
41
|
|
|
28
42
|
renderHTML(attrs) {
|
|
29
43
|
if (!attrs.alignment) return null;
|
|
30
44
|
|
|
31
45
|
return renderInlineSetting({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
46
|
+
text_align_mobile: attrs.alignment.mobile,
|
|
47
|
+
text_align_tablet: attrs.alignment.tablet,
|
|
48
|
+
text_align_desktop: attrs.alignment.desktop
|
|
35
49
|
});
|
|
36
50
|
}
|
|
37
51
|
}
|
|
@@ -42,7 +56,7 @@ export const Alignment = Extension.create({
|
|
|
42
56
|
addCommands() {
|
|
43
57
|
return {
|
|
44
58
|
applyAlignment: createCommand(({ commands }, value) => {
|
|
45
|
-
const device = commands.getDevice()
|
|
59
|
+
const device = unref(commands.getDevice());
|
|
46
60
|
|
|
47
61
|
commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
|
|
48
62
|
}),
|
|
@@ -52,14 +66,14 @@ export const Alignment = Extension.create({
|
|
|
52
66
|
const device = commands.getDevice();
|
|
53
67
|
const defaultValue = commands.getDefaultAlignment();
|
|
54
68
|
|
|
55
|
-
return computed(() => attribute
|
|
69
|
+
return computed(() => unref(attribute)?.[unref(device)] ?? unref(defaultValue));
|
|
56
70
|
}),
|
|
57
71
|
|
|
58
72
|
getDefaultAlignment: createCommand(({ commands }) => {
|
|
59
73
|
const device = commands.getDevice();
|
|
60
74
|
const preset = commands.getPreset();
|
|
61
75
|
|
|
62
|
-
return computed(() => preset
|
|
76
|
+
return computed(() => unref(preset)[unref(device)].alignment);
|
|
63
77
|
})
|
|
64
78
|
};
|
|
65
79
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from '
|
|
2
|
+
import { computed } from 'vue';
|
|
3
3
|
import { convertColor, createCommand, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -22,12 +22,20 @@ export const BackgroundColor = Mark.create({
|
|
|
22
22
|
};
|
|
23
23
|
},
|
|
24
24
|
|
|
25
|
-
parseHTML
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
parseHTML() {
|
|
26
|
+
const getAttrs = (value) => ({ value: convertColor(value) });
|
|
27
|
+
|
|
28
|
+
return [
|
|
29
|
+
{
|
|
30
|
+
style: '--zw-background-color',
|
|
31
|
+
getAttrs
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
style: 'background-color',
|
|
35
|
+
getAttrs
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
},
|
|
31
39
|
|
|
32
40
|
renderHTML({ HTMLAttributes: attrs }) {
|
|
33
41
|
return renderMark({ background_color: attrs.value });
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
+
import { toRef } from 'vue';
|
|
1
2
|
import { Extension } from '@tiptap/vue-2';
|
|
2
3
|
import { createCommand } from '../utils';
|
|
3
4
|
|
|
4
5
|
export const DeviceManager = Extension.create({
|
|
5
6
|
name: 'device_manager',
|
|
6
7
|
|
|
7
|
-
addOptions: () => ({
|
|
8
|
-
deviceRef: null
|
|
9
|
-
}),
|
|
10
|
-
|
|
11
8
|
addCommands() {
|
|
12
9
|
return {
|
|
13
|
-
getDevice: createCommand(() => this.options
|
|
10
|
+
getDevice: createCommand(() => toRef(this.options, 'device'))
|
|
14
11
|
};
|
|
15
12
|
}
|
|
16
13
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from '
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { convertColor, createCommand, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -15,13 +15,13 @@ export const FontColor = Mark.create({
|
|
|
15
15
|
getFontColor: createCommand(({ commands, editor }) => {
|
|
16
16
|
const defaultValue = commands.getDefaultFontColor();
|
|
17
17
|
|
|
18
|
-
return computed(() => editor.getAttributes(this.name)?.value ?? defaultValue
|
|
18
|
+
return computed(() => editor.getAttributes(this.name)?.value ?? unref(defaultValue));
|
|
19
19
|
}),
|
|
20
20
|
|
|
21
21
|
getDefaultFontColor: createCommand(({ commands }) => {
|
|
22
22
|
const preset = commands.getPreset();
|
|
23
23
|
|
|
24
|
-
return computed(() => preset.
|
|
24
|
+
return computed(() => unref(preset).common.color);
|
|
25
25
|
}),
|
|
26
26
|
|
|
27
27
|
applyFontColor: createCommand(({ commands }, value) => {
|
|
@@ -30,12 +30,20 @@ export const FontColor = Mark.create({
|
|
|
30
30
|
};
|
|
31
31
|
},
|
|
32
32
|
|
|
33
|
-
parseHTML
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
parseHTML() {
|
|
34
|
+
const getAttrs = (value) => ({ value: convertColor(value) });
|
|
35
|
+
|
|
36
|
+
return [
|
|
37
|
+
{
|
|
38
|
+
style: '--zw-font-color',
|
|
39
|
+
getAttrs
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
style: 'color',
|
|
43
|
+
getAttrs
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
},
|
|
39
47
|
|
|
40
48
|
renderHTML({ HTMLAttributes: attrs }) {
|
|
41
49
|
return renderMark({ font_color: attrs.value });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from '
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -7,7 +7,8 @@ export const FontFamily = Mark.create({
|
|
|
7
7
|
name: TextSettings.FONT_FAMILY,
|
|
8
8
|
|
|
9
9
|
addOptions: () => ({
|
|
10
|
-
fonts: []
|
|
10
|
+
fonts: [],
|
|
11
|
+
defaultFont: ''
|
|
11
12
|
}),
|
|
12
13
|
|
|
13
14
|
addAttributes: () => ({
|
|
@@ -20,7 +21,7 @@ export const FontFamily = Mark.create({
|
|
|
20
21
|
commands.setMark(this.name, { value });
|
|
21
22
|
|
|
22
23
|
const font = commands.findFontByName(value);
|
|
23
|
-
let fontWeight = commands.getFontWeight()
|
|
24
|
+
let fontWeight = unref(commands.getFontWeight());
|
|
24
25
|
|
|
25
26
|
if (!font.isWeightSupported(fontWeight)) {
|
|
26
27
|
fontWeight = font.findClosestWeight(fontWeight);
|
|
@@ -35,7 +36,7 @@ export const FontFamily = Mark.create({
|
|
|
35
36
|
getFont: createCommand(({ commands }) => {
|
|
36
37
|
const fontFamily = commands.getFontFamily();
|
|
37
38
|
|
|
38
|
-
return computed(() => commands.findFontByName(fontFamily
|
|
39
|
+
return computed(() => commands.findFontByName(unref(fontFamily)));
|
|
39
40
|
}),
|
|
40
41
|
|
|
41
42
|
findFontByName: createCommand((_, name) => {
|
|
@@ -45,25 +46,41 @@ export const FontFamily = Mark.create({
|
|
|
45
46
|
getFontFamily: createCommand(({ editor, commands }) => {
|
|
46
47
|
const defaultValue = commands.getDefaultFontFamily();
|
|
47
48
|
|
|
48
|
-
return computed(() => editor.getAttributes(this.name)?.value ?? defaultValue
|
|
49
|
+
return computed(() => editor.getAttributes(this.name)?.value ?? unref(defaultValue));
|
|
49
50
|
}),
|
|
50
51
|
|
|
51
52
|
getDefaultFontFamily: createCommand(({ commands }) => {
|
|
52
53
|
const preset = commands.getPreset();
|
|
53
54
|
|
|
54
|
-
return computed(() => preset.
|
|
55
|
+
return computed(() => unref(preset).common.font_family);
|
|
55
56
|
})
|
|
56
57
|
};
|
|
57
58
|
},
|
|
58
59
|
|
|
59
|
-
parseHTML
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
parseHTML() {
|
|
61
|
+
const getAttrs = (input) => {
|
|
62
|
+
const parsed = input.replace(/"/g, '');
|
|
63
|
+
const isExists = this.options.fonts.some((font) => font.name === parsed);
|
|
64
|
+
const value = isExists ? parsed : this.options.defaultFont;
|
|
65
|
+
|
|
66
|
+
return { value };
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
style: '--zw-font-family',
|
|
72
|
+
getAttrs
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
style: 'font-family',
|
|
76
|
+
getAttrs
|
|
77
|
+
}
|
|
78
|
+
];
|
|
79
|
+
},
|
|
65
80
|
|
|
66
81
|
renderHTML({ HTMLAttributes: attrs }) {
|
|
67
|
-
|
|
82
|
+
const font_family = attrs.value ? `"${attrs.value}"` : null;
|
|
83
|
+
|
|
84
|
+
return renderMark({ font_family });
|
|
68
85
|
}
|
|
69
86
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from '
|
|
3
|
-
import { createCommand, createKeyboardShortcut, renderMark } from '../utils';
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
|
+
import { convertFontSize, createCommand, createKeyboardShortcut, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
6
6
|
export const FontSize = Mark.create({
|
|
@@ -25,31 +25,31 @@ export const FontSize = Mark.create({
|
|
|
25
25
|
const device = commands.getDevice();
|
|
26
26
|
const defaultValue = commands.getDefaultFontSize();
|
|
27
27
|
|
|
28
|
-
return computed(() => editor.getAttributes(this.name)?.[device
|
|
28
|
+
return computed(() => editor.getAttributes(this.name)?.[unref(device)] ?? unref(defaultValue));
|
|
29
29
|
}),
|
|
30
30
|
|
|
31
31
|
getDefaultFontSize: createCommand(({ commands }) => {
|
|
32
32
|
const device = commands.getDevice();
|
|
33
33
|
const preset = commands.getPreset();
|
|
34
34
|
|
|
35
|
-
return computed(() => preset
|
|
35
|
+
return computed(() => unref(preset)[unref(device)].font_size.replace('px', ''));
|
|
36
36
|
}),
|
|
37
37
|
|
|
38
38
|
applyFontSize: createCommand(({ commands }, value) => {
|
|
39
|
-
const device = commands.getDevice()
|
|
39
|
+
const device = unref(commands.getDevice());
|
|
40
40
|
|
|
41
41
|
commands.setMark(this.name, { [device]: value });
|
|
42
42
|
}),
|
|
43
43
|
|
|
44
44
|
increaseFontSize: createCommand(({ commands }) => {
|
|
45
|
-
const size = Number(commands.getFontSize()
|
|
45
|
+
const size = Number(unref(commands.getFontSize()));
|
|
46
46
|
const nextSize = Math.min(size + 1, this.options.maxSize);
|
|
47
47
|
|
|
48
48
|
commands.applyFontSize(String(nextSize));
|
|
49
49
|
}),
|
|
50
50
|
|
|
51
51
|
decreaseFontSize: createCommand(({ commands }) => {
|
|
52
|
-
const size = Number(commands.getFontSize()
|
|
52
|
+
const size = Number(unref(commands.getFontSize()));
|
|
53
53
|
const nextSize = Math.max(size - 1, this.options.minSize);
|
|
54
54
|
|
|
55
55
|
commands.applyFontSize(String(nextSize));
|
|
@@ -62,25 +62,45 @@ export const FontSize = Mark.create({
|
|
|
62
62
|
'Mod-Shift--': createKeyboardShortcut('decreaseFontSize')
|
|
63
63
|
}),
|
|
64
64
|
|
|
65
|
-
parseHTML
|
|
66
|
-
{
|
|
67
|
-
|
|
65
|
+
parseHTML() {
|
|
66
|
+
const parseSize = (value) => {
|
|
67
|
+
if (!value) return null;
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
const wrapperEl = unref(this.options.wrapperRef);
|
|
70
|
+
const converted = convertFontSize(value, wrapperEl);
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
return String(converted);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
tag: '[style*="--zw-font-size"]',
|
|
78
|
+
|
|
79
|
+
getAttrs: ({ style }) => ({
|
|
80
|
+
mobile: parseSize(style.getPropertyValue('--zw-font-size-mobile')),
|
|
81
|
+
tablet: parseSize(style.getPropertyValue('--zw-font-size-tablet')),
|
|
82
|
+
desktop: parseSize(style.getPropertyValue('--zw-font-size-desktop'))
|
|
83
|
+
})
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
style: 'font-size',
|
|
87
|
+
|
|
88
|
+
getAttrs: (input) => {
|
|
89
|
+
const value = parseSize(input);
|
|
90
|
+
|
|
91
|
+
return { desktop: value, tablet: value, mobile: value };
|
|
92
|
+
}
|
|
73
93
|
}
|
|
74
|
-
|
|
75
|
-
|
|
94
|
+
];
|
|
95
|
+
},
|
|
76
96
|
|
|
77
97
|
renderHTML({ HTMLAttributes: attrs }) {
|
|
78
98
|
const addUnits = (value) => value ? `${value}px` : null;
|
|
79
99
|
|
|
80
100
|
return renderMark({
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
101
|
+
font_size_mobile: addUnits(attrs.mobile),
|
|
102
|
+
font_size_tablet: addUnits(attrs.tablet),
|
|
103
|
+
font_size_desktop: addUnits(attrs.desktop)
|
|
84
104
|
});
|
|
85
105
|
}
|
|
86
106
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mark } from '@tiptap/vue-2';
|
|
2
|
-
import { computed } from '
|
|
2
|
+
import { computed, unref } from 'vue';
|
|
3
3
|
import { createCommand, createKeyboardShortcut, renderMark } from '../utils';
|
|
4
4
|
import { TextSettings } from '../enums';
|
|
5
5
|
|
|
@@ -15,30 +15,30 @@ export const FontStyle = Mark.create({
|
|
|
15
15
|
isItalic: createCommand(({ editor, commands }) => {
|
|
16
16
|
const defaultValue = commands.getDefaultFontStyle();
|
|
17
17
|
|
|
18
|
-
return computed(() => editor.getAttributes(this.name)?.italic ?? defaultValue.
|
|
18
|
+
return computed(() => editor.getAttributes(this.name)?.italic ?? unref(defaultValue).italic);
|
|
19
19
|
}),
|
|
20
20
|
|
|
21
21
|
isItalicAvailable: createCommand(({ commands }) => {
|
|
22
22
|
const font = commands.getFont();
|
|
23
23
|
const fontWeight = commands.getFontWeight();
|
|
24
24
|
|
|
25
|
-
return computed(() => font.
|
|
25
|
+
return computed(() => unref(font).isItalicSupported(unref(fontWeight)));
|
|
26
26
|
}),
|
|
27
27
|
|
|
28
28
|
getDefaultFontStyle: createCommand(({ commands }) => {
|
|
29
29
|
const preset = commands.getPreset();
|
|
30
30
|
|
|
31
31
|
return computed(() => ({
|
|
32
|
-
italic: preset.
|
|
32
|
+
italic: unref(preset).common.font_style === 'italic'
|
|
33
33
|
}));
|
|
34
34
|
}),
|
|
35
35
|
|
|
36
36
|
toggleItalic: createCommand(({ commands }) => {
|
|
37
|
-
const isItalicAvailable = this.editor.commands.isItalicAvailable();
|
|
37
|
+
const isItalicAvailable = unref(this.editor.commands.isItalicAvailable());
|
|
38
38
|
|
|
39
|
-
if (!isItalicAvailable
|
|
39
|
+
if (!isItalicAvailable) return;
|
|
40
40
|
|
|
41
|
-
commands.isItalic()
|
|
41
|
+
unref(commands.isItalic()) ? commands.removeItalic() : commands.applyItalic();
|
|
42
42
|
}),
|
|
43
43
|
|
|
44
44
|
applyItalic: createCommand(({ commands }) => {
|
|
@@ -56,18 +56,28 @@ export const FontStyle = Mark.create({
|
|
|
56
56
|
'Mod-I': createKeyboardShortcut('toggleItalic')
|
|
57
57
|
}),
|
|
58
58
|
|
|
59
|
-
parseHTML
|
|
60
|
-
{
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
59
|
+
parseHTML() {
|
|
60
|
+
const getAttrs = (value) => value.includes('italic') && { italic: true };
|
|
61
|
+
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
style: '--zw-font-style',
|
|
65
|
+
getAttrs
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
style: 'font-style',
|
|
69
|
+
getAttrs
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
tag: 'i',
|
|
73
|
+
attrs: { italic: true }
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
renderHTML({ HTMLAttributes: attrs }) {
|
|
79
|
+
const font_style = attrs.italic ? 'italic' : null;
|
|
80
|
+
|
|
81
|
+
return renderMark({ font_style });
|
|
72
82
|
}
|
|
73
83
|
});
|