@zipify/wysiwyg 4.11.0 → 4.11.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/.release-it.json +2 -1
- package/dist/cli.js +28 -28
- package/dist/node.js +26 -26
- package/dist/types/Wysiwyg.vue.d.ts +7 -8
- package/dist/types/components/base/Button.vue.d.ts +5 -10
- package/dist/types/components/base/ButtonToggle.vue.d.ts +9 -14
- package/dist/types/components/base/Checkbox.vue.d.ts +1 -1
- package/dist/types/components/base/FieldLabel.vue.d.ts +5 -10
- package/dist/types/components/base/Icon.vue.d.ts +1 -1
- package/dist/types/components/base/Modal.vue.d.ts +5 -14
- package/dist/types/components/base/ModalFloating.vue.d.ts +5 -14
- package/dist/types/components/base/NumberField.vue.d.ts +1 -1
- package/dist/types/components/base/Range.vue.d.ts +1 -1
- package/dist/types/components/base/ScrollView.vue.d.ts +5 -14
- package/dist/types/components/base/TextField.vue.d.ts +1 -1
- package/dist/types/components/base/colorPicker/ColorPicker.vue.d.ts +10 -517
- package/dist/types/components/base/dropdown/Dropdown.vue.d.ts +6 -15
- package/dist/types/components/base/dropdown/DropdownActivator.vue.d.ts +7 -12
- package/dist/types/components/base/dropdown/DropdownDivider.vue.d.ts +1 -1
- package/dist/types/components/base/dropdown/DropdownGroup.vue.d.ts +7 -12
- package/dist/types/components/base/dropdown/DropdownMenu.vue.d.ts +6 -12
- package/dist/types/components/base/dropdown/DropdownOption.vue.d.ts +5 -14
- package/dist/types/components/toolbar/ToolbarFloating.vue.d.ts +5 -14
- package/dist/types/components/toolbar/controls/AlignmentControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/CaseStyleControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/FontFamilyControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/FontSizeControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/FontWeightControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/ItalicControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/LineHeightControl.vue.d.ts +1 -3
- package/dist/types/components/toolbar/controls/ListControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/RemoveFormatControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/StrikeThroughControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/SuperscriptControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/UnderlineControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/link/LinkControl.vue.d.ts +1 -3
- package/dist/types/components/toolbar/controls/link/LinkControlHeader.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/link/composables/useLink.d.ts +11 -9
- package/dist/types/components/toolbar/controls/link/destination/LinkControlDestination.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/link/destination/LinkControlPageBlock.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/link/destination/LinkControlUrl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/stylePreset/StylePresetControl.vue.d.ts +1 -1
- package/dist/types/components/toolbar/controls/stylePreset/StylePresetOption.vue.d.ts +2 -4
- package/dist/types/enums/Alignment.d.ts +7 -0
- package/dist/types/enums/CaseStyle.d.ts +5 -0
- package/dist/types/enums/Device.d.ts +7 -0
- package/dist/types/enums/LinkDestination.d.ts +4 -0
- package/dist/types/enums/LinkTarget.d.ts +4 -0
- package/dist/types/enums/ListType.d.ts +10 -0
- package/dist/types/enums/MarkGroup.d.ts +4 -0
- package/dist/types/enums/NodeType.d.ts +9 -0
- package/dist/types/enums/TextSetting.d.ts +19 -0
- package/dist/types/enums/index.d.ts +9 -9
- package/dist/types/extensions/Alignment.d.ts +2 -1
- package/dist/types/extensions/CaseStyle.d.ts +2 -1
- package/dist/types/models/Font.d.ts +1 -0
- package/dist/wysiwyg.css +27 -27
- package/dist/wysiwyg.mjs +135 -165
- package/example/fonts.js +111 -111
- package/lib/Wysiwyg.vue +3 -3
- package/lib/__tests__/utils/buildTestExtensions.js +6 -6
- package/lib/components/toolbar/Toolbar.vue +2 -2
- package/lib/components/toolbar/__tests__/Toolbar.test.js +5 -5
- package/lib/components/toolbar/controls/AlignmentControl.vue +7 -7
- package/lib/components/toolbar/controls/CaseStyleControl.vue +5 -5
- package/lib/components/toolbar/controls/FontColorControl.vue +2 -2
- package/lib/components/toolbar/controls/FontFamilyControl.vue +2 -2
- package/lib/components/toolbar/controls/FontSizeControl.vue +2 -2
- package/lib/components/toolbar/controls/FontWeightControl.vue +2 -2
- package/lib/components/toolbar/controls/ItalicControl.vue +2 -2
- package/lib/components/toolbar/controls/LineHeightControl.vue +2 -2
- package/lib/components/toolbar/controls/ListControl.vue +5 -5
- package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +13 -13
- package/lib/components/toolbar/controls/__tests__/CaseStyleControl.test.js +4 -4
- package/lib/components/toolbar/controls/__tests__/ListControl.test.js +10 -10
- package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +6 -6
- package/lib/components/toolbar/controls/link/LinkControl.vue +5 -5
- package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +20 -20
- package/lib/components/toolbar/controls/link/composables/useLink.js +10 -10
- package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +10 -7
- package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +1 -1
- package/lib/enums/{Alignments.ts → Alignment.ts} +0 -8
- package/lib/enums/{CaseStyles.ts → CaseStyle.ts} +0 -6
- package/lib/enums/{Devices.ts → Device.ts} +0 -8
- package/lib/enums/LinkDestination.ts +4 -0
- package/lib/enums/LinkTarget.ts +4 -0
- package/lib/enums/{ListTypes.ts → ListType.ts} +0 -9
- package/lib/enums/MarkGroup.ts +4 -0
- package/lib/enums/{NodeTypes.ts → NodeType.ts} +0 -8
- package/lib/enums/{TextSettings.ts → TextSetting.ts} +0 -11
- package/lib/enums/index.ts +9 -9
- package/lib/extensions/Alignment.js +13 -11
- package/lib/extensions/BackgroundColor.js +2 -2
- package/lib/extensions/CaseStyle.js +8 -6
- package/lib/extensions/FontColor.js +4 -4
- package/lib/extensions/FontFamily.js +8 -6
- package/lib/extensions/FontSize.js +3 -3
- package/lib/extensions/FontStyle.js +3 -3
- package/lib/extensions/FontWeight.js +3 -3
- package/lib/extensions/LineHeight.js +4 -4
- package/lib/extensions/Link.js +11 -11
- package/lib/extensions/Margin.js +4 -4
- package/lib/extensions/StylePreset.js +18 -12
- package/lib/extensions/Superscript.js +2 -2
- package/lib/extensions/TextDecoration.js +2 -2
- package/lib/extensions/__tests__/Alignment.test.js +21 -21
- package/lib/extensions/__tests__/BackgroundColor.test.js +4 -4
- package/lib/extensions/__tests__/CaseStyle.test.js +6 -6
- package/lib/extensions/__tests__/FontColor.test.js +4 -4
- package/lib/extensions/__tests__/FontFamily.test.js +10 -10
- package/lib/extensions/__tests__/FontSize.test.js +9 -9
- package/lib/extensions/__tests__/FontStyle.test.js +6 -6
- package/lib/extensions/__tests__/FontWeight.test.js +11 -11
- package/lib/extensions/__tests__/LineHeight.test.js +2 -2
- package/lib/extensions/__tests__/Link.test.js +13 -13
- package/lib/extensions/__tests__/StylePreset.test.js +29 -29
- package/lib/extensions/__tests__/Superscript.test.js +5 -5
- package/lib/extensions/__tests__/TextDecoration.test.js +14 -14
- package/lib/extensions/core/Document.js +3 -3
- package/lib/extensions/core/Heading.js +2 -2
- package/lib/extensions/core/NodeProcessor.js +8 -8
- package/lib/extensions/core/Paragraph.js +2 -2
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +68 -68
- package/lib/extensions/core/__tests__/TextProcessor.test.js +13 -13
- package/lib/extensions/list/ListItem.js +5 -5
- package/lib/extensions/list/__tests__/List.test.js +11 -11
- package/lib/extensions/proseMirror/PasteLinkPlugin.js +4 -4
- package/lib/extensions/proseMirror/PastePlugin.js +2 -2
- package/lib/models/Font.ts +4 -0
- package/lib/services/ContentSerializer.js +3 -3
- package/lib/services/StylePresetRenderer.js +4 -4
- package/lib/services/__tests__/NodeFactory.test.js +11 -11
- package/lib/services/__tests__/NodeSelector.test.js +18 -18
- package/lib/services/normalizer/JsonNormalizer.js +5 -5
- package/lib/services/normalizer/__tests__/JsonNormalizer.test.js +15 -15
- package/lib/utils/__tests__/convertAlignment.test.js +3 -3
- package/lib/utils/convertAlignment.js +4 -4
- package/package.json +17 -17
- package/lib/enums/LinkDestinations.ts +0 -9
- package/lib/enums/LinkTargets.ts +0 -9
- package/lib/enums/MarkGroups.ts +0 -9
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Editor, Mark } from '@tiptap/vue-3';
|
|
2
2
|
import { buildTestExtensions } from '@/__tests__/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { ListType, TextSetting } from '@/enums';
|
|
4
4
|
import { ContentNormalizer, NodeFactory } from '@/services';
|
|
5
5
|
import { StylePreset } from '../../StylePreset';
|
|
6
6
|
import { List } from '../List';
|
|
7
7
|
|
|
8
8
|
const MockFontWeight = Mark.create({
|
|
9
|
-
name:
|
|
9
|
+
name: TextSetting.FONT_WEIGHT,
|
|
10
10
|
renderHTML: () => ['span', {}, 0],
|
|
11
11
|
addAttributes: () => ({ value: { required: true } })
|
|
12
12
|
});
|
|
@@ -46,7 +46,7 @@ describe('get list type', () => {
|
|
|
46
46
|
test('should get list from selection', () => {
|
|
47
47
|
const editor = createEditor({
|
|
48
48
|
content: NodeFactory.doc([
|
|
49
|
-
NodeFactory.list(
|
|
49
|
+
NodeFactory.list(ListType.LATIN, [
|
|
50
50
|
NodeFactory.paragraph('Item 1'),
|
|
51
51
|
NodeFactory.paragraph('Item 2')
|
|
52
52
|
])
|
|
@@ -55,7 +55,7 @@ describe('get list type', () => {
|
|
|
55
55
|
|
|
56
56
|
editor.commands.selectAll();
|
|
57
57
|
|
|
58
|
-
expect(editor.commands.getListType().value).toBe(
|
|
58
|
+
expect(editor.commands.getListType().value).toBe(ListType.LATIN);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
test('should return null if no list in selection', () => {
|
|
@@ -79,7 +79,7 @@ describe('apply list', () => {
|
|
|
79
79
|
])
|
|
80
80
|
});
|
|
81
81
|
|
|
82
|
-
editor.chain().selectAll().applyList(
|
|
82
|
+
editor.chain().selectAll().applyList(ListType.LATIN).run();
|
|
83
83
|
|
|
84
84
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
85
85
|
});
|
|
@@ -87,14 +87,14 @@ describe('apply list', () => {
|
|
|
87
87
|
test('should toggle list', async () => {
|
|
88
88
|
const editor = createEditor({
|
|
89
89
|
content: NodeFactory.doc([
|
|
90
|
-
NodeFactory.list(
|
|
90
|
+
NodeFactory.list(ListType.LATIN, [
|
|
91
91
|
NodeFactory.paragraph('Item 1'),
|
|
92
92
|
NodeFactory.paragraph('Item 2')
|
|
93
93
|
])
|
|
94
94
|
])
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
editor.chain().selectAll().applyList(
|
|
97
|
+
editor.chain().selectAll().applyList(ListType.LATIN).run();
|
|
98
98
|
|
|
99
99
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
100
100
|
});
|
|
@@ -102,14 +102,14 @@ describe('apply list', () => {
|
|
|
102
102
|
test('should change list type', () => {
|
|
103
103
|
const editor = createEditor({
|
|
104
104
|
content: NodeFactory.doc([
|
|
105
|
-
NodeFactory.list(
|
|
105
|
+
NodeFactory.list(ListType.LATIN, [
|
|
106
106
|
NodeFactory.paragraph('Item 1'),
|
|
107
107
|
NodeFactory.paragraph('Item 2')
|
|
108
108
|
])
|
|
109
109
|
])
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
editor.chain().selectAll().applyList(
|
|
112
|
+
editor.chain().selectAll().applyList(ListType.ROMAN).run();
|
|
113
113
|
|
|
114
114
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
115
115
|
});
|
|
@@ -122,7 +122,7 @@ describe('apply list', () => {
|
|
|
122
122
|
])
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
-
editor.chain().selectAll().applyList(
|
|
125
|
+
editor.chain().selectAll().applyList(ListType.LATIN).run();
|
|
126
126
|
|
|
127
127
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
128
128
|
});
|
|
@@ -132,7 +132,7 @@ describe('remove list', () => {
|
|
|
132
132
|
test('should remove list', () => {
|
|
133
133
|
const editor = createEditor({
|
|
134
134
|
content: NodeFactory.doc([
|
|
135
|
-
NodeFactory.list(
|
|
135
|
+
NodeFactory.list(ListType.LATIN, [
|
|
136
136
|
NodeFactory.paragraph('Item 1'),
|
|
137
137
|
NodeFactory.paragraph('Item 2')
|
|
138
138
|
])
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test as testLink } from 'linkifyjs';
|
|
2
2
|
import { NodeSelector } from '../../services';
|
|
3
|
-
import {
|
|
3
|
+
import { NodeType, TextSetting } from '../../enums';
|
|
4
4
|
import { ProseMirrorPlugin } from './ProseMirrorPlugin';
|
|
5
5
|
|
|
6
6
|
export class PasteLinkPlugin extends ProseMirrorPlugin {
|
|
@@ -25,9 +25,9 @@ export class PasteLinkPlugin extends ProseMirrorPlugin {
|
|
|
25
25
|
|
|
26
26
|
_createLinkAttrs(text, nodes) {
|
|
27
27
|
const pastingLink = NodeSelector.query(nodes, {
|
|
28
|
-
typeName:
|
|
29
|
-
mark: { typeName:
|
|
30
|
-
getMark: { typeName:
|
|
28
|
+
typeName: NodeType.TEXT,
|
|
29
|
+
mark: { typeName: TextSetting.LINK },
|
|
30
|
+
getMark: { typeName: TextSetting.LINK }
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
// Fallback to linked text if copied not from wswg
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContentNormalizer } from '../../services';
|
|
2
|
-
import {
|
|
2
|
+
import { NodeType } from '../../enums';
|
|
3
3
|
import { ProseMirrorPlugin } from './ProseMirrorPlugin';
|
|
4
4
|
|
|
5
5
|
export class PastePlugin extends ProseMirrorPlugin {
|
|
@@ -65,7 +65,7 @@ export class PastePlugin extends ProseMirrorPlugin {
|
|
|
65
65
|
let to = selection.to;
|
|
66
66
|
|
|
67
67
|
doc.nodesBetween(from, to, (node, position, parent) => {
|
|
68
|
-
if (parent.type.name !==
|
|
68
|
+
if (parent.type.name !== NodeType.DOCUMENT) return;
|
|
69
69
|
|
|
70
70
|
from = Math.min(from, position + 1);
|
|
71
71
|
to = Math.max(to, position + node.nodeSize - 1);
|
package/lib/models/Font.ts
CHANGED
|
@@ -23,6 +23,10 @@ export class Font {
|
|
|
23
23
|
return Array.from(new Set(weights));
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
get isItalicOnly(): boolean {
|
|
27
|
+
return this.styles.every((style) => style.endsWith('i'));
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
isWeightSupported(weight: string): boolean {
|
|
27
31
|
return this.weights.includes(weight);
|
|
28
32
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
2
|
import { getSchema } from '@tiptap/core';
|
|
3
3
|
import { DOMParser } from '@tiptap/pm/model';
|
|
4
|
-
import { buildExtensions } from '
|
|
5
|
-
import {
|
|
4
|
+
import { buildExtensions } from '@/extensions';
|
|
5
|
+
import { Device } from '@/enums';
|
|
6
6
|
import { ContentNormalizer } from './normalizer';
|
|
7
7
|
import { ContextWindow } from './ContextWindow';
|
|
8
8
|
|
|
@@ -18,7 +18,7 @@ export class ContentSerializer {
|
|
|
18
18
|
makePresetVariable: () => '',
|
|
19
19
|
basePresetClass: config.basePresetClass,
|
|
20
20
|
baseListClass: config.baseListClass,
|
|
21
|
-
deviceRef: ref(
|
|
21
|
+
deviceRef: ref(Device.DESKTOP),
|
|
22
22
|
pageBlocksRef: ref([]),
|
|
23
23
|
wrapperRef: ContextWindow.document.createElement('p')
|
|
24
24
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Device, DeviceList, TextAttributeSettingList } from '@/enums';
|
|
2
2
|
import { ContextWindow } from './ContextWindow';
|
|
3
3
|
|
|
4
4
|
export class StylePresetRenderer {
|
|
@@ -33,7 +33,7 @@ export class StylePresetRenderer {
|
|
|
33
33
|
|
|
34
34
|
css += ` ${className} {`;
|
|
35
35
|
|
|
36
|
-
for (const device of
|
|
36
|
+
for (const device of DeviceList) {
|
|
37
37
|
for (const setting of Object.keys(preset[device])) {
|
|
38
38
|
const variable = this._makeVariable({ device, preset, property: setting });
|
|
39
39
|
const internalVariable = this._makeInternalVariableName(setting, device);
|
|
@@ -42,7 +42,7 @@ export class StylePresetRenderer {
|
|
|
42
42
|
|
|
43
43
|
// Encapsulate link styles in editor from parent
|
|
44
44
|
|
|
45
|
-
if (isLink && !
|
|
45
|
+
if (isLink && !TextAttributeSettingList.includes(setting)) {
|
|
46
46
|
const overrideVariable = internalVariable.replace('preset-', '');
|
|
47
47
|
|
|
48
48
|
css += `${overrideVariable}: var(${internalVariable});`;
|
|
@@ -58,7 +58,7 @@ export class StylePresetRenderer {
|
|
|
58
58
|
|
|
59
59
|
_makeInternalVariableName(setting, device) {
|
|
60
60
|
const property = setting === 'color' ? 'font-color' : setting.replace(/_/i, '-');
|
|
61
|
-
const prefix = device ===
|
|
61
|
+
const prefix = device === Device.COMMON ? '' : `-${device}`;
|
|
62
62
|
|
|
63
63
|
return `--zw-preset-${property}${prefix}`;
|
|
64
64
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ListType, TextSetting } from '@/enums';
|
|
1
2
|
import { NodeFactory } from '../NodeFactory';
|
|
2
|
-
import { ListTypes, TextSettings } from '../../enums';
|
|
3
3
|
|
|
4
4
|
describe('build node', () => {
|
|
5
5
|
test('should build doc node', () => {
|
|
@@ -7,7 +7,7 @@ describe('build node', () => {
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
test('should build list node with text items', () => {
|
|
10
|
-
const node = NodeFactory.list(
|
|
10
|
+
const node = NodeFactory.list(ListType.DISC, [
|
|
11
11
|
'lorem ipsum 1',
|
|
12
12
|
'lorem ipsum 2'
|
|
13
13
|
]);
|
|
@@ -16,7 +16,7 @@ describe('build node', () => {
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
test('should build list node with node items', () => {
|
|
19
|
-
const node = NodeFactory.list(
|
|
19
|
+
const node = NodeFactory.list(ListType.DISC, [
|
|
20
20
|
NodeFactory.paragraph('lorem ipsum 1'),
|
|
21
21
|
NodeFactory.paragraph('lorem ipsum 2')
|
|
22
22
|
]);
|
|
@@ -25,13 +25,13 @@ describe('build node', () => {
|
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
test('should build list node with custom list item nodes', () => {
|
|
28
|
-
const node = NodeFactory.list(
|
|
28
|
+
const node = NodeFactory.list(ListType.DISC, [
|
|
29
29
|
NodeFactory.listItem(null, [
|
|
30
|
-
NodeFactory.mark(
|
|
30
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
31
31
|
], 'lorem ipsum 1'),
|
|
32
32
|
|
|
33
33
|
NodeFactory.listItem(null, [
|
|
34
|
-
NodeFactory.mark(
|
|
34
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
35
35
|
], 'lorem ipsum 2')
|
|
36
36
|
]);
|
|
37
37
|
|
|
@@ -52,7 +52,7 @@ describe('build node', () => {
|
|
|
52
52
|
|
|
53
53
|
test('should build heading node with marks', () => {
|
|
54
54
|
const node = NodeFactory.heading(1, null, [
|
|
55
|
-
NodeFactory.mark(
|
|
55
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
56
56
|
], 'lorem ipsum');
|
|
57
57
|
|
|
58
58
|
expect(node).toMatchSnapshot();
|
|
@@ -61,7 +61,7 @@ describe('build node', () => {
|
|
|
61
61
|
test('should build heading with custom text node', () => {
|
|
62
62
|
const node = NodeFactory.heading(1, [
|
|
63
63
|
NodeFactory.text('lorem ipsum', [
|
|
64
|
-
NodeFactory.mark(
|
|
64
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
65
65
|
])
|
|
66
66
|
]);
|
|
67
67
|
|
|
@@ -82,7 +82,7 @@ describe('build node', () => {
|
|
|
82
82
|
|
|
83
83
|
test('should build paragraph node with marks', () => {
|
|
84
84
|
const node = NodeFactory.paragraph(null, [
|
|
85
|
-
NodeFactory.mark(
|
|
85
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
86
86
|
], 'lorem ipsum');
|
|
87
87
|
|
|
88
88
|
expect(node).toMatchSnapshot();
|
|
@@ -91,7 +91,7 @@ describe('build node', () => {
|
|
|
91
91
|
test('should build paragraph with custom text node', () => {
|
|
92
92
|
const node = NodeFactory.paragraph([
|
|
93
93
|
NodeFactory.text('lorem ipsum', [
|
|
94
|
-
NodeFactory.mark(
|
|
94
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
95
95
|
])
|
|
96
96
|
]);
|
|
97
97
|
|
|
@@ -111,7 +111,7 @@ describe('build node', () => {
|
|
|
111
111
|
});
|
|
112
112
|
|
|
113
113
|
test('should build mark', () => {
|
|
114
|
-
const mark = NodeFactory.mark(
|
|
114
|
+
const mark = NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' });
|
|
115
115
|
|
|
116
116
|
expect(mark).toMatchSnapshot();
|
|
117
117
|
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { Schema } from '@tiptap/pm/model';
|
|
2
2
|
import { NodeFactory } from '../NodeFactory';
|
|
3
3
|
import { NodeSelector } from '../NodeSelector';
|
|
4
|
-
import {
|
|
4
|
+
import { NodeType, TextSetting } from '../../enums';
|
|
5
5
|
|
|
6
6
|
const createSchema = () => new Schema({
|
|
7
7
|
nodes: {
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
8
|
+
[NodeType.DOCUMENT]: { content: 'paragraph+' },
|
|
9
|
+
[NodeType.PARAGRAPH]: { content: 'text*' },
|
|
10
|
+
[NodeType.TEXT]: { inline: true }
|
|
11
11
|
},
|
|
12
12
|
marks: {
|
|
13
|
-
[
|
|
13
|
+
[TextSetting.FONT_SIZE]: {}
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
|
|
@@ -21,7 +21,7 @@ describe('match node', () => {
|
|
|
21
21
|
const schema = createSchema();
|
|
22
22
|
const selector = createSelector();
|
|
23
23
|
const node = schema.nodeFromJSON(NodeFactory.text('lorem ipsum'));
|
|
24
|
-
const isMatch = selector.matchNode(node, { typeName:
|
|
24
|
+
const isMatch = selector.matchNode(node, { typeName: NodeType.TEXT });
|
|
25
25
|
|
|
26
26
|
expect(isMatch).toBe(true);
|
|
27
27
|
});
|
|
@@ -30,7 +30,7 @@ describe('match node', () => {
|
|
|
30
30
|
const schema = createSchema();
|
|
31
31
|
const selector = createSelector();
|
|
32
32
|
const node = schema.nodeFromJSON(NodeFactory.text('lorem ipsum'));
|
|
33
|
-
const isMatch = selector.matchNode(node, { typeName:
|
|
33
|
+
const isMatch = selector.matchNode(node, { typeName: NodeType.PARAGRAPH });
|
|
34
34
|
|
|
35
35
|
expect(isMatch).toBe(false);
|
|
36
36
|
});
|
|
@@ -40,11 +40,11 @@ describe('match node', () => {
|
|
|
40
40
|
const selector = createSelector();
|
|
41
41
|
|
|
42
42
|
const node = schema.nodeFromJSON(NodeFactory.text('lorem ipsum', [
|
|
43
|
-
NodeFactory.mark(
|
|
43
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, {})
|
|
44
44
|
]));
|
|
45
45
|
|
|
46
46
|
const isMatch = selector.matchNode(node, {
|
|
47
|
-
mark: { typeName:
|
|
47
|
+
mark: { typeName: TextSetting.FONT_SIZE }
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
expect(isMatch).toBe(true);
|
|
@@ -55,11 +55,11 @@ describe('match node', () => {
|
|
|
55
55
|
const selector = createSelector();
|
|
56
56
|
|
|
57
57
|
const node = schema.nodeFromJSON(NodeFactory.text('lorem ipsum', [
|
|
58
|
-
NodeFactory.mark(
|
|
58
|
+
NodeFactory.mark(TextSetting.FONT_SIZE, {})
|
|
59
59
|
]));
|
|
60
60
|
|
|
61
61
|
const isMatch = selector.matchNode(node, {
|
|
62
|
-
mark: { typeName:
|
|
62
|
+
mark: { typeName: TextSetting.FONT_FAMILY }
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
expect(isMatch).toBe(false);
|
|
@@ -70,8 +70,8 @@ describe('match mark', () => {
|
|
|
70
70
|
test('should match mark by type name', () => {
|
|
71
71
|
const schema = createSchema();
|
|
72
72
|
const selector = createSelector();
|
|
73
|
-
const mark = schema.markFromJSON(NodeFactory.mark(
|
|
74
|
-
const isMatch = selector.matchMark(mark, { typeName:
|
|
73
|
+
const mark = schema.markFromJSON(NodeFactory.mark(TextSetting.FONT_SIZE, {}));
|
|
74
|
+
const isMatch = selector.matchMark(mark, { typeName: TextSetting.FONT_SIZE });
|
|
75
75
|
|
|
76
76
|
expect(isMatch).toBe(true);
|
|
77
77
|
});
|
|
@@ -79,8 +79,8 @@ describe('match mark', () => {
|
|
|
79
79
|
test('should not match mark by type name', () => {
|
|
80
80
|
const schema = createSchema();
|
|
81
81
|
const selector = createSelector();
|
|
82
|
-
const mark = schema.markFromJSON(NodeFactory.mark(
|
|
83
|
-
const isMatch = selector.matchMark(mark, { typeName:
|
|
82
|
+
const mark = schema.markFromJSON(NodeFactory.mark(TextSetting.FONT_SIZE, {}));
|
|
83
|
+
const isMatch = selector.matchMark(mark, { typeName: TextSetting.FONT_FAMILY });
|
|
84
84
|
|
|
85
85
|
expect(isMatch).toBe(false);
|
|
86
86
|
});
|
|
@@ -95,7 +95,7 @@ describe('query node', () => {
|
|
|
95
95
|
NodeFactory.paragraph('lorem ipsum')
|
|
96
96
|
]));
|
|
97
97
|
|
|
98
|
-
const textNode = selector.query(doc, { typeName:
|
|
98
|
+
const textNode = selector.query(doc, { typeName: NodeType.TEXT });
|
|
99
99
|
|
|
100
100
|
expect(textNode.text).toBe('lorem ipsum');
|
|
101
101
|
});
|
|
@@ -109,7 +109,7 @@ describe('query node', () => {
|
|
|
109
109
|
NodeFactory.paragraph('lorem ipsum 2')
|
|
110
110
|
]));
|
|
111
111
|
|
|
112
|
-
const textNode = selector.query(doc, { typeName:
|
|
112
|
+
const textNode = selector.query(doc, { typeName: NodeType.TEXT });
|
|
113
113
|
|
|
114
114
|
expect(textNode.text).toBe('lorem ipsum 1');
|
|
115
115
|
});
|
|
@@ -122,7 +122,7 @@ describe('query node', () => {
|
|
|
122
122
|
NodeFactory.paragraph('lorem ipsum 1')
|
|
123
123
|
]));
|
|
124
124
|
|
|
125
|
-
const node = selector.query(doc, { typeName:
|
|
125
|
+
const node = selector.query(doc, { typeName: NodeType.LIST });
|
|
126
126
|
|
|
127
127
|
expect(node).toBeNull();
|
|
128
128
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isEqual } from 'lodash';
|
|
2
|
-
import {
|
|
2
|
+
import { NodeType, TextInlineMarkList, TextSetting } from '../../enums';
|
|
3
3
|
import { BaseNormalizer } from './BaseNormalizer';
|
|
4
4
|
|
|
5
5
|
export class JsonNormalizer extends BaseNormalizer {
|
|
@@ -21,7 +21,7 @@ export class JsonNormalizer extends BaseNormalizer {
|
|
|
21
21
|
|
|
22
22
|
_bubbleMarks(node) {
|
|
23
23
|
if (!node.content) return;
|
|
24
|
-
if (node.type ===
|
|
24
|
+
if (node.type === NodeType.LIST) return;
|
|
25
25
|
|
|
26
26
|
for (const child of node.content) {
|
|
27
27
|
if (this._isLink(child)) continue;
|
|
@@ -42,11 +42,11 @@ export class JsonNormalizer extends BaseNormalizer {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
_canBubbleMark(node, childMark) {
|
|
45
|
-
if (
|
|
45
|
+
if (TextInlineMarkList.includes(childMark.type)) return false;
|
|
46
46
|
if (this._includesMarkType(node, childMark.type)) return false;
|
|
47
47
|
|
|
48
48
|
for (const child of node.content) {
|
|
49
|
-
if (!child.content && node.type ===
|
|
49
|
+
if (!child.content && node.type === NodeType.LIST_ITEM) continue;
|
|
50
50
|
if (!child.marks) return false;
|
|
51
51
|
if (!this._includesMark(child, childMark)) return false;
|
|
52
52
|
}
|
|
@@ -63,7 +63,7 @@ export class JsonNormalizer extends BaseNormalizer {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
_isLink(node) {
|
|
66
|
-
return node.type ===
|
|
66
|
+
return node.type === NodeType.TEXT && this._includesMarkType(node, TextSetting.LINK);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
_removeMark(node, mark) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { LinkDestination, LinkTarget, ListType, TextSetting } from '@/enums';
|
|
1
2
|
import { NodeFactory } from '../../NodeFactory';
|
|
2
|
-
import { LinkDestinations, LinkTargets, ListTypes, TextSettings } from '../../../enums';
|
|
3
3
|
import { ContentNormalizer } from '../ContentNormalizer';
|
|
4
4
|
|
|
5
5
|
describe('normalize json content', () => {
|
|
@@ -7,7 +7,7 @@ describe('normalize json content', () => {
|
|
|
7
7
|
const input = NodeFactory.doc([
|
|
8
8
|
NodeFactory.paragraph([
|
|
9
9
|
NodeFactory.text('lorem ipsum', [
|
|
10
|
-
NodeFactory.mark(
|
|
10
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
11
11
|
])
|
|
12
12
|
])
|
|
13
13
|
]);
|
|
@@ -19,11 +19,11 @@ describe('normalize json content', () => {
|
|
|
19
19
|
const input = NodeFactory.doc([
|
|
20
20
|
NodeFactory.paragraph([
|
|
21
21
|
NodeFactory.text('lorem', [
|
|
22
|
-
NodeFactory.mark(
|
|
22
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
23
23
|
]),
|
|
24
24
|
NodeFactory.text(' ipsum', [
|
|
25
|
-
NodeFactory.mark(
|
|
26
|
-
NodeFactory.mark(
|
|
25
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' }),
|
|
26
|
+
NodeFactory.mark(TextSetting.FONT_COLOR, { value: '#FF0000' })
|
|
27
27
|
])
|
|
28
28
|
])
|
|
29
29
|
]);
|
|
@@ -33,10 +33,10 @@ describe('normalize json content', () => {
|
|
|
33
33
|
|
|
34
34
|
test('should bubble mark from text to list item', () => {
|
|
35
35
|
const input = NodeFactory.doc([
|
|
36
|
-
NodeFactory.list(
|
|
36
|
+
NodeFactory.list(ListType.DISC, [
|
|
37
37
|
NodeFactory.paragraph([
|
|
38
38
|
NodeFactory.text('lorem ipsum', [
|
|
39
|
-
NodeFactory.mark(
|
|
39
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
40
40
|
])
|
|
41
41
|
])
|
|
42
42
|
])
|
|
@@ -49,8 +49,8 @@ describe('normalize json content', () => {
|
|
|
49
49
|
const input = NodeFactory.doc([
|
|
50
50
|
NodeFactory.paragraph([
|
|
51
51
|
NodeFactory.text('hello world', [
|
|
52
|
-
NodeFactory.mark(
|
|
53
|
-
NodeFactory.mark(
|
|
52
|
+
NodeFactory.mark(TextSetting.FONT_FAMILY, { value: 'Bungee' }),
|
|
53
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '800' })
|
|
54
54
|
])
|
|
55
55
|
])
|
|
56
56
|
]);
|
|
@@ -62,7 +62,7 @@ describe('normalize json content', () => {
|
|
|
62
62
|
const input = NodeFactory.doc([
|
|
63
63
|
NodeFactory.paragraph([
|
|
64
64
|
NodeFactory.text('hello world', [
|
|
65
|
-
NodeFactory.mark(
|
|
65
|
+
NodeFactory.mark(TextSetting.TEXT_DECORATION, { underline: true })
|
|
66
66
|
])
|
|
67
67
|
])
|
|
68
68
|
]);
|
|
@@ -74,10 +74,10 @@ describe('normalize json content', () => {
|
|
|
74
74
|
const input = NodeFactory.doc([
|
|
75
75
|
NodeFactory.paragraph([
|
|
76
76
|
NodeFactory.text('lorem', [
|
|
77
|
-
NodeFactory.mark(
|
|
77
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '700' })
|
|
78
78
|
]),
|
|
79
79
|
NodeFactory.text(' ipsum', [
|
|
80
|
-
NodeFactory.mark(
|
|
80
|
+
NodeFactory.mark(TextSetting.FONT_WEIGHT, { value: '400' })
|
|
81
81
|
])
|
|
82
82
|
])
|
|
83
83
|
]);
|
|
@@ -90,10 +90,10 @@ describe('normalize json content', () => {
|
|
|
90
90
|
NodeFactory.paragraph([
|
|
91
91
|
NodeFactory.link('lorem', {
|
|
92
92
|
href: '/about',
|
|
93
|
-
target:
|
|
94
|
-
destination:
|
|
93
|
+
target: LinkTarget.BLANK,
|
|
94
|
+
destination: LinkDestination.URL
|
|
95
95
|
}, [
|
|
96
|
-
NodeFactory.mark(
|
|
96
|
+
NodeFactory.mark(TextSetting.FONT_COLOR, { value: '#FF5533' })
|
|
97
97
|
])
|
|
98
98
|
])
|
|
99
99
|
]);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { Alignment } from '@/enums';
|
|
1
2
|
import { convertAlignment } from '../convertAlignment';
|
|
2
|
-
import { Alignments } from '../../enums';
|
|
3
3
|
|
|
4
4
|
describe('convert alignment', () => {
|
|
5
5
|
test('should try convert non supported value', () => {
|
|
6
|
-
expect(convertAlignment('start')).toBe(
|
|
6
|
+
expect(convertAlignment('start')).toBe(Alignment.LEFT);
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
test('should not change supported value', () => {
|
|
10
|
-
expect(convertAlignment('center')).toBe(
|
|
10
|
+
expect(convertAlignment('center')).toBe(Alignment.CENTER);
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
test('should return null if cannot convert', () => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Alignment, AlignmentList } from '@/enums';
|
|
2
2
|
|
|
3
3
|
const MAPPING = {
|
|
4
|
-
start:
|
|
5
|
-
end:
|
|
4
|
+
start: Alignment.LEFT,
|
|
5
|
+
end: Alignment.RIGHT
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
export function convertAlignment(alignment) {
|
|
9
9
|
const mapped = MAPPING[alignment] || alignment;
|
|
10
10
|
|
|
11
|
-
return
|
|
11
|
+
return AlignmentList.includes(mapped) ? mapped : null;
|
|
12
12
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zipify/wysiwyg",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.2",
|
|
4
4
|
"description": "Zipify modification of TipTap text editor",
|
|
5
5
|
"main": "dist/wysiwyg.mjs",
|
|
6
6
|
"types": "dist/wysiwyg.d.ts",
|
|
@@ -70,44 +70,44 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@babel/core": "^7.26.
|
|
74
|
-
"@babel/plugin-transform-runtime": "^7.26.
|
|
73
|
+
"@babel/core": "^7.26.10",
|
|
74
|
+
"@babel/plugin-transform-runtime": "^7.26.10",
|
|
75
75
|
"@babel/preset-env": "^7.26.9",
|
|
76
|
-
"@babel/runtime": "^7.
|
|
76
|
+
"@babel/runtime": "^7.27.0",
|
|
77
77
|
"@optimize-lodash/rollup-plugin": "^5.0.2",
|
|
78
78
|
"@rollup/plugin-alias": "^5.1.1",
|
|
79
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
79
|
+
"@rollup/plugin-commonjs": "^28.0.3",
|
|
80
80
|
"@rollup/plugin-json": "^6.1.0",
|
|
81
|
-
"@rollup/plugin-node-resolve": "^16.0.
|
|
81
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
82
82
|
"@rollup/plugin-replace": "^6.0.2",
|
|
83
83
|
"@stylistic/stylelint-plugin": "^3.1.2",
|
|
84
84
|
"@types/jest": "^29.5.14",
|
|
85
|
-
"@types/lodash": "^4.17.
|
|
86
|
-
"@types/node": "^22.13.
|
|
87
|
-
"@vitejs/plugin-vue": "^5.2.
|
|
85
|
+
"@types/lodash": "^4.17.16",
|
|
86
|
+
"@types/node": "^22.13.13",
|
|
87
|
+
"@vitejs/plugin-vue": "^5.2.3",
|
|
88
88
|
"@vue/test-utils": "^2.4.6",
|
|
89
89
|
"@vue/tsconfig": "^0.7.0",
|
|
90
90
|
"@vue/vue3-jest": "^29.2.6",
|
|
91
|
-
"@zipify/colorpicker": "^4.1.
|
|
91
|
+
"@zipify/colorpicker": "^4.1.4",
|
|
92
92
|
"@zipify/eslint-config": "^3.0.8",
|
|
93
93
|
"babel-jest": "^29.7.0",
|
|
94
94
|
"esbuild-jest-transform": "^2.0.1",
|
|
95
95
|
"husky": "^9.1.7",
|
|
96
96
|
"jest": "^29.7.0",
|
|
97
97
|
"jest-environment-jsdom": "^29.7.0",
|
|
98
|
-
"lint-staged": "^15.
|
|
98
|
+
"lint-staged": "^15.5.0",
|
|
99
99
|
"postcss-html": "^1.8.0",
|
|
100
100
|
"release-it": "^18.1.2",
|
|
101
|
-
"rollup": "^4.
|
|
102
|
-
"rollup-plugin-esbuild": "^6.2.
|
|
101
|
+
"rollup": "^4.37.0",
|
|
102
|
+
"rollup-plugin-esbuild": "^6.2.1",
|
|
103
103
|
"rollup-plugin-esbuild-minify": "^1.2.0",
|
|
104
104
|
"simplebar": "^6.3.0",
|
|
105
|
-
"stylelint": "^16.
|
|
105
|
+
"stylelint": "^16.16.0",
|
|
106
106
|
"svgo": "^3.3.2",
|
|
107
|
-
"typescript": "^5.
|
|
108
|
-
"vite": "^6.
|
|
107
|
+
"typescript": "^5.8.2",
|
|
108
|
+
"vite": "^6.2.3",
|
|
109
109
|
"vue": "3.5.13",
|
|
110
|
-
"vue-tsc": "^2.2.
|
|
110
|
+
"vue-tsc": "^2.2.8"
|
|
111
111
|
},
|
|
112
112
|
"engines": {
|
|
113
113
|
"node": ">=22.11.0"
|
package/lib/enums/LinkTargets.ts
DELETED