@zipify/wysiwyg 2.4.4 → 2.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/dist/wysiwyg.css +2 -2
- package/dist/wysiwyg.mjs +11470 -11491
- package/lib/cli/ContentSerializer.js +4 -3
- package/lib/cli/NodeDomParser.js +4 -0
- package/lib/extensions/Alignment.js +5 -2
- package/lib/extensions/FontSize.js +4 -24
- package/lib/extensions/LineHeight.js +8 -2
- package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +4 -4
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +5 -5
- package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +1 -1
- package/lib/services/NodeFactory.js +4 -1
- package/lib/services/__tests__/__snapshots__/NodeFactory.test.js.snap +1 -1
- package/lib/styles/variables.css +2 -2
- package/lib/utils/convertFontSize.js +3 -1
- package/lib/utils/convertLineHeight.js +3 -2
- package/package.json +1 -1
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { ref } from 'vue';
|
|
2
2
|
import { getSchema } from '@tiptap/core';
|
|
3
3
|
import { DOMParser } from 'prosemirror-model';
|
|
4
|
-
import { JSDOM } from 'jsdom';
|
|
5
4
|
import { buildExtensions } from '../extensions';
|
|
6
5
|
import { Devices } from '../enums';
|
|
7
|
-
import { ContentNormalizer } from '../services';
|
|
6
|
+
import { ContentNormalizer, ContextWindow } from '../services';
|
|
8
7
|
import { NodeDomParser } from './NodeDomParser';
|
|
9
8
|
|
|
10
9
|
export class ContentSerializer {
|
|
11
10
|
static build(options) {
|
|
11
|
+
ContextWindow.use(NodeDomParser.createWindow());
|
|
12
|
+
|
|
12
13
|
const extensions = buildExtensions({
|
|
13
14
|
fonts: options.fonts,
|
|
14
15
|
minFontSize: 0,
|
|
@@ -21,7 +22,7 @@ export class ContentSerializer {
|
|
|
21
22
|
baseListClass: options.baseListClass,
|
|
22
23
|
deviceRef: ref(Devices.DESKTOP),
|
|
23
24
|
pageBlocksRef: ref([]),
|
|
24
|
-
wrapperRef:
|
|
25
|
+
wrapperRef: ContextWindow.document.createElement('p')
|
|
25
26
|
});
|
|
26
27
|
const schema = getSchema(extensions);
|
|
27
28
|
|
package/lib/cli/NodeDomParser.js
CHANGED
|
@@ -59,9 +59,12 @@ export const Alignment = Extension.create({
|
|
|
59
59
|
}),
|
|
60
60
|
|
|
61
61
|
applyAlignment: createCommand(({ commands }, value) => {
|
|
62
|
-
const device = unref(commands.getDevice());
|
|
62
|
+
// const device = unref(commands.getDevice());
|
|
63
|
+
//
|
|
64
|
+
// commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
// Temporary until release BUILDER_MODES
|
|
67
|
+
commands.setBlockAttributes(this.name, { desktop: value, tablet: value, mobile: value });
|
|
65
68
|
}),
|
|
66
69
|
|
|
67
70
|
removeAlignment: createCommand(({ commands }) => commands.removeBlockAttributes(this.name)),
|
|
@@ -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,
|
|
@@ -35,31 +34,12 @@ export const FontSize = Mark.create({
|
|
|
35
34
|
}),
|
|
36
35
|
|
|
37
36
|
applyFontSize: createCommand(({ commands }, value) => {
|
|
38
|
-
const device = unref(commands.getDevice());
|
|
37
|
+
// const device = unref(commands.getDevice());
|
|
39
38
|
|
|
40
|
-
commands.applyMark(this.name, { [device]: value }
|
|
41
|
-
isAppliedToParent: (parentMark, mark) => {
|
|
42
|
-
if (parentMark.type.name !== mark.type.name) return false;
|
|
39
|
+
// commands.applyMark(this.name, { [device]: value });
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
onAppliedToParent: ({ tr, node, position, mark }) => {
|
|
48
|
-
const attrs = { ...mark.attrs, [device]: null };
|
|
49
|
-
const canRemove = !Object.values(attrs).some((value) => !!value);
|
|
50
|
-
|
|
51
|
-
if (canRemove) return false;
|
|
52
|
-
|
|
53
|
-
const updated = mark.type.create(attrs);
|
|
54
|
-
|
|
55
|
-
if (node.isText) {
|
|
56
|
-
tr.addMark(position, position + node.nodeSize, updated);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
tr.step(new AddNodeMarkStep(position, updated));
|
|
61
|
-
}
|
|
62
|
-
});
|
|
41
|
+
// Temporary until release BUILDER_MODES
|
|
42
|
+
commands.applyMark(this.name, { desktop: value, tablet: value, mobile: null });
|
|
63
43
|
}),
|
|
64
44
|
|
|
65
45
|
increaseFontSize: createCommand(({ commands }) => {
|
|
@@ -36,6 +36,9 @@ export const LineHeight = Extension.create({
|
|
|
36
36
|
const wrapperEl = unref(this.options.wrapperRef);
|
|
37
37
|
const converted = convertLineHeight(value, element, wrapperEl);
|
|
38
38
|
|
|
39
|
+
// return { desktop: converted, tablet: converted, mobile: converted };
|
|
40
|
+
|
|
41
|
+
// Temporary until release BUILDER_MODES
|
|
39
42
|
return { desktop: converted, tablet: converted, mobile: null };
|
|
40
43
|
},
|
|
41
44
|
|
|
@@ -72,9 +75,12 @@ export const LineHeight = Extension.create({
|
|
|
72
75
|
}),
|
|
73
76
|
|
|
74
77
|
applyLineHeight: createCommand(({ commands }, value) => {
|
|
75
|
-
const device = unref(commands.getDevice());
|
|
78
|
+
// const device = unref(commands.getDevice());
|
|
79
|
+
//
|
|
80
|
+
// commands.setBlockAttributes(this.name, { [device]: value }, DEFAULTS);
|
|
76
81
|
|
|
77
|
-
|
|
82
|
+
// Temporary until release BUILDER_MODES
|
|
83
|
+
commands.setBlockAttributes(this.name, { desktop: value, tablet: value, mobile: null }, DEFAULTS);
|
|
78
84
|
})
|
|
79
85
|
};
|
|
80
86
|
}
|
|
@@ -7,8 +7,8 @@ Object {
|
|
|
7
7
|
"attrs": Object {
|
|
8
8
|
"alignment": Object {
|
|
9
9
|
"desktop": "right",
|
|
10
|
-
"mobile":
|
|
11
|
-
"tablet":
|
|
10
|
+
"mobile": "right",
|
|
11
|
+
"tablet": "right",
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
"content": Array [
|
|
@@ -51,8 +51,8 @@ Object {
|
|
|
51
51
|
"attrs": Object {
|
|
52
52
|
"alignment": Object {
|
|
53
53
|
"desktop": "right",
|
|
54
|
-
"mobile":
|
|
55
|
-
"tablet":
|
|
54
|
+
"mobile": "right",
|
|
55
|
+
"tablet": "right",
|
|
56
56
|
},
|
|
57
57
|
},
|
|
58
58
|
"content": Array [
|
|
@@ -15,7 +15,7 @@ Object {
|
|
|
15
15
|
"attrs": Object {
|
|
16
16
|
"desktop": "16",
|
|
17
17
|
"mobile": null,
|
|
18
|
-
"tablet":
|
|
18
|
+
"tablet": "16",
|
|
19
19
|
},
|
|
20
20
|
"type": "font_size",
|
|
21
21
|
},
|
|
@@ -42,7 +42,7 @@ Object {
|
|
|
42
42
|
"attrs": Object {
|
|
43
43
|
"desktop": "13",
|
|
44
44
|
"mobile": null,
|
|
45
|
-
"tablet":
|
|
45
|
+
"tablet": "13",
|
|
46
46
|
},
|
|
47
47
|
"type": "font_size",
|
|
48
48
|
},
|
|
@@ -69,7 +69,7 @@ Object {
|
|
|
69
69
|
"attrs": Object {
|
|
70
70
|
"desktop": "15",
|
|
71
71
|
"mobile": null,
|
|
72
|
-
"tablet":
|
|
72
|
+
"tablet": "15",
|
|
73
73
|
},
|
|
74
74
|
"type": "font_size",
|
|
75
75
|
},
|
|
@@ -96,7 +96,7 @@ Object {
|
|
|
96
96
|
"attrs": Object {
|
|
97
97
|
"desktop": "5",
|
|
98
98
|
"mobile": null,
|
|
99
|
-
"tablet":
|
|
99
|
+
"tablet": "5",
|
|
100
100
|
},
|
|
101
101
|
"type": "font_size",
|
|
102
102
|
},
|
|
@@ -123,7 +123,7 @@ Object {
|
|
|
123
123
|
"attrs": Object {
|
|
124
124
|
"desktop": "20",
|
|
125
125
|
"mobile": null,
|
|
126
|
-
"tablet":
|
|
126
|
+
"tablet": "20",
|
|
127
127
|
},
|
|
128
128
|
"type": "font_size",
|
|
129
129
|
},
|
|
@@ -136,6 +136,9 @@ export class NodeFactory {
|
|
|
136
136
|
* @returns {{tablet, desktop, mobile}}
|
|
137
137
|
*/
|
|
138
138
|
static populateAllDevices(value) {
|
|
139
|
-
return { mobile: value, tablet: value, desktop: value };
|
|
139
|
+
// return { mobile: value, tablet: value, desktop: value };
|
|
140
|
+
|
|
141
|
+
// Temporary until release BUILDER_MODES
|
|
142
|
+
return { mobile: null, tablet: value, desktop: value };
|
|
140
143
|
}
|
|
141
144
|
}
|
package/lib/styles/variables.css
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
--zw-color-n200: 194, 200, 209; /* #C2C8D1 */
|
|
12
12
|
--zw-color-black: 0, 0, 0;
|
|
13
13
|
--zw-color-white: 255, 255, 255;
|
|
14
|
-
--zw-color-green: 59, 180, 74;
|
|
15
|
-
--zw-color-red: 234, 58, 58;
|
|
14
|
+
--zw-color-green: 59, 180, 74; /* #3BB44A */
|
|
15
|
+
--zw-color-red: 234, 58, 58; /* #EA3A3A */
|
|
16
16
|
|
|
17
17
|
--zw-offset-xxs: 4px;
|
|
18
18
|
--zw-offset-xs: 8px;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { ContextWindow } from '../services';
|
|
2
|
+
|
|
1
3
|
export function convertFontSize(value, wrapperEl) {
|
|
2
4
|
if (!value.includes('em')) return parseInt(value);
|
|
3
5
|
|
|
4
|
-
const containerValue =
|
|
6
|
+
const containerValue = ContextWindow.getComputedStyle(wrapperEl).fontSize;
|
|
5
7
|
const size = parseFloat(value) * parseFloat(containerValue);
|
|
6
8
|
|
|
7
9
|
return Math.round(size);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { ContextWindow } from '../services';
|
|
1
2
|
import { convertFontSize } from './convertFontSize';
|
|
2
3
|
|
|
3
4
|
function getFontSize(sourceEl, wrapperEl) {
|
|
4
5
|
const source = sourceEl.firstElementChild || sourceEl;
|
|
5
6
|
const fontSize = source.style.fontSize;
|
|
6
7
|
|
|
7
|
-
return fontSize ||
|
|
8
|
+
return fontSize || ContextWindow.getComputedStyle(wrapperEl).fontSize;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
export function convertLineHeight(value, sourceEl, wrapperEl) {
|
|
@@ -13,5 +14,5 @@ export function convertLineHeight(value, sourceEl, wrapperEl) {
|
|
|
13
14
|
const rawFontSize = getFontSize(sourceEl, wrapperEl);
|
|
14
15
|
const fontSize = convertFontSize(rawFontSize, wrapperEl);
|
|
15
16
|
|
|
16
|
-
return (parseInt(value) / fontSize).toFixed(2);
|
|
17
|
+
return fontSize ? (parseInt(value) / fontSize).toFixed(2) : null;
|
|
17
18
|
}
|