@zipify/wysiwyg 4.0.2 → 4.0.4-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/dist/cli.js +2 -2
- package/dist/wysiwyg.css +16 -16
- package/dist/wysiwyg.mjs +11 -8
- package/lib/components/base/Button.vue +1 -1
- package/lib/components/toolbar/controls/ItalicControl.vue +2 -4
- package/lib/services/normalizer/HtmlNormalizer.js +9 -2
- package/lib/services/normalizer/__tests__/HtmlNormalizer.test.js +8 -1
- package/package.json +1 -1
package/dist/wysiwyg.css
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
padding: var(--zw-offset-xxs) var(--zw-offset-xs);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.zw-button[data-v-
|
|
26
|
+
.zw-button[data-v-b2d5d74a] {
|
|
27
27
|
display: inline-flex;
|
|
28
28
|
align-items: center;
|
|
29
29
|
vertical-align: middle;
|
|
@@ -43,21 +43,21 @@
|
|
|
43
43
|
transition: 0.1s opacity ease-out;
|
|
44
44
|
will-change: opacity;
|
|
45
45
|
}
|
|
46
|
-
.zw-button[data-v-
|
|
46
|
+
.zw-button[data-v-b2d5d74a]::-moz-focus-inner {
|
|
47
47
|
border: 0 !important;
|
|
48
48
|
}
|
|
49
|
-
.zw-button[data-v-
|
|
50
|
-
.zw-button[data-v-
|
|
49
|
+
.zw-button[data-v-b2d5d74a]:hover,
|
|
50
|
+
.zw-button[data-v-b2d5d74a]:focus {
|
|
51
51
|
text-decoration: none;
|
|
52
52
|
outline: none;
|
|
53
53
|
}
|
|
54
|
-
.zw-button[data-v-
|
|
54
|
+
.zw-button[data-v-b2d5d74a]:disabled {
|
|
55
55
|
user-select: none;
|
|
56
56
|
box-shadow: none;
|
|
57
57
|
cursor: not-allowed;
|
|
58
58
|
opacity: 0.35;
|
|
59
59
|
}
|
|
60
|
-
.zw-button--toolbar[data-v-
|
|
60
|
+
.zw-button--toolbar[data-v-b2d5d74a] {
|
|
61
61
|
border-radius: 1px;
|
|
62
62
|
min-height: 28px;
|
|
63
63
|
font-weight: var(--zw-font-weight-semibold);
|
|
@@ -67,33 +67,33 @@
|
|
|
67
67
|
transition-property: background-color, color, opacity;
|
|
68
68
|
will-change: background-color, color, opacity;
|
|
69
69
|
}
|
|
70
|
-
.zw-button--primary[data-v-
|
|
70
|
+
.zw-button--primary[data-v-b2d5d74a] {
|
|
71
71
|
background-color: rgb(var(--zw-color-green));
|
|
72
72
|
color: rgb(var(--zw-color-white));
|
|
73
73
|
padding: var(--zw-offset-xxs) var(--zw-offset-sm);
|
|
74
74
|
line-height: var(--zw-line-height-md);
|
|
75
75
|
}
|
|
76
|
-
.zw-button--primary[data-v-
|
|
77
|
-
.zw-button--secondary[data-v-
|
|
76
|
+
.zw-button--primary[data-v-b2d5d74a],
|
|
77
|
+
.zw-button--secondary[data-v-b2d5d74a] {
|
|
78
78
|
color: rgb(var(--zw-color-white));
|
|
79
79
|
padding: var(--zw-offset-xxs) var(--zw-offset-sm);
|
|
80
80
|
font-weight: 600;
|
|
81
81
|
font-size: var(--zw-font-size-xs);
|
|
82
82
|
}
|
|
83
|
-
.zw-button--primary[data-v-
|
|
84
|
-
.zw-button--secondary[data-v-
|
|
83
|
+
.zw-button--primary[data-v-b2d5d74a]:not(:disabled):hover,
|
|
84
|
+
.zw-button--secondary[data-v-b2d5d74a]:not(:disabled):hover {
|
|
85
85
|
opacity: 0.9;
|
|
86
86
|
}
|
|
87
|
-
.zw-button--toolbar[data-v-
|
|
87
|
+
.zw-button--toolbar[data-v-b2d5d74a]:not(.zw-button--icon) {
|
|
88
88
|
padding: var(--zw-offset-xxs) var(--zw-offset-xs);
|
|
89
89
|
}
|
|
90
|
-
.zw-button--toolbar[data-v-
|
|
91
|
-
.zw-button--toolbar[data-v-
|
|
92
|
-
.zw-button--toolbar.zw-button--active[data-v-
|
|
90
|
+
.zw-button--toolbar[data-v-b2d5d74a]:not(:disabled):hover,
|
|
91
|
+
.zw-button--toolbar[data-v-b2d5d74a]:not(:disabled):focus,
|
|
92
|
+
.zw-button--toolbar.zw-button--active[data-v-b2d5d74a]:not(:disabled) {
|
|
93
93
|
color: rgb(var(--zw-color-white));
|
|
94
94
|
background-color: rgb(var(--zw-color-n5));
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
[data-v-b2d5d74a] .zw-button__customized-indicator {
|
|
97
97
|
width: 4px;
|
|
98
98
|
height: 4px;
|
|
99
99
|
background-color: rgb(var(--zw-color-y300));
|
package/dist/wysiwyg.mjs
CHANGED
|
@@ -23049,6 +23049,11 @@ const _HtmlNormalizer = class extends BaseNormalizer {
|
|
|
23049
23049
|
}
|
|
23050
23050
|
itemEl.append(fragment);
|
|
23051
23051
|
this._removeStyleProperties(itemEl, _HtmlNormalizer.BLOCK_STYLES);
|
|
23052
|
+
this._removeStyleProperties(itemEl.parentElement, _HtmlNormalizer.BLOCK_STYLES);
|
|
23053
|
+
this._assignElementProperties(itemEl, itemEl.parentElement);
|
|
23054
|
+
if (itemEl.parentElement.lastElementChild === itemEl) {
|
|
23055
|
+
this._removeStyleProperties(itemEl.parentElement);
|
|
23056
|
+
}
|
|
23052
23057
|
}
|
|
23053
23058
|
_isBlockNode(node) {
|
|
23054
23059
|
return _HtmlNormalizer.BLOCK_NODE_NAMES.includes(node.tagName);
|
|
@@ -23056,7 +23061,7 @@ const _HtmlNormalizer = class extends BaseNormalizer {
|
|
|
23056
23061
|
_isRootNode(node) {
|
|
23057
23062
|
return _HtmlNormalizer.ROOT_NODE_NAMES.includes(node.tagName);
|
|
23058
23063
|
}
|
|
23059
|
-
_assignElementProperties(target, source, properties) {
|
|
23064
|
+
_assignElementProperties(target, source, properties = Array.from(source.style)) {
|
|
23060
23065
|
for (const property of properties) {
|
|
23061
23066
|
const value = source.style.getPropertyValue(property);
|
|
23062
23067
|
if (value && !target.style.getPropertyValue(property)) {
|
|
@@ -23064,7 +23069,7 @@ const _HtmlNormalizer = class extends BaseNormalizer {
|
|
|
23064
23069
|
}
|
|
23065
23070
|
}
|
|
23066
23071
|
}
|
|
23067
|
-
_removeStyleProperties(element, properties) {
|
|
23072
|
+
_removeStyleProperties(element, properties = Array.from(element.style)) {
|
|
23068
23073
|
for (const property of properties) {
|
|
23069
23074
|
element.style.removeProperty(property);
|
|
23070
23075
|
}
|
|
@@ -23890,7 +23895,7 @@ function tooltip(el, { value, modifiers: modifiers2 }) {
|
|
|
23890
23895
|
if (modifiers2.lg)
|
|
23891
23896
|
el.dataset.tooltipSize = "lg";
|
|
23892
23897
|
}
|
|
23893
|
-
const
|
|
23898
|
+
const Button_vue_vue_type_style_index_0_scoped_b2d5d74a_lang = "";
|
|
23894
23899
|
const _hoisted_1$n = ["disabled"];
|
|
23895
23900
|
const _sfc_main$G = {
|
|
23896
23901
|
__name: "Button",
|
|
@@ -23937,7 +23942,7 @@ const _sfc_main$G = {
|
|
|
23937
23942
|
};
|
|
23938
23943
|
}
|
|
23939
23944
|
};
|
|
23940
|
-
const Button = /* @__PURE__ */ _export_sfc(_sfc_main$G, [["__scopeId", "data-v-
|
|
23945
|
+
const Button = /* @__PURE__ */ _export_sfc(_sfc_main$G, [["__scopeId", "data-v-b2d5d74a"]]);
|
|
23941
23946
|
const ButtonToggle_vue_vue_type_style_index_0_scoped_bbdc7b20_lang = "";
|
|
23942
23947
|
const _hoisted_1$m = { class: "zw-button-toggle" };
|
|
23943
23948
|
const _sfc_main$F = {
|
|
@@ -26396,9 +26401,7 @@ const _sfc_main$k = {
|
|
|
26396
26401
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
26397
26402
|
const currentValue = editor.commands.isItalic();
|
|
26398
26403
|
const isAvailable = editor.commands.isItalicAvailable();
|
|
26399
|
-
const isCustomized =
|
|
26400
|
-
return editor.commands.isSettingCustomized(TextSettings.FONT_STYLE).value;
|
|
26401
|
-
});
|
|
26404
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_STYLE);
|
|
26402
26405
|
const apply2 = () => editor.chain().focus().toggleItalic().run();
|
|
26403
26406
|
return (_ctx, _cache) => {
|
|
26404
26407
|
return withDirectives((openBlock(), createBlock(unref(Button), {
|
|
@@ -26415,7 +26418,7 @@ const _sfc_main$k = {
|
|
|
26415
26418
|
size: "28px",
|
|
26416
26419
|
"auto-color": ""
|
|
26417
26420
|
}),
|
|
26418
|
-
isCustomized
|
|
26421
|
+
unref(isCustomized) ? withDirectives((openBlock(), createElementBlock("span", _hoisted_1$7, null, 512)), [
|
|
26419
26422
|
[
|
|
26420
26423
|
unref(tooltip),
|
|
26421
26424
|
"Style differs from Page Styles",
|
|
@@ -130,7 +130,7 @@ const classes = computed(() => ({
|
|
|
130
130
|
background-color: rgb(var(--zw-color-n5));
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
-
.zw-button__customized-indicator {
|
|
133
|
+
:deep(.zw-button__customized-indicator) {
|
|
134
134
|
width: 4px;
|
|
135
135
|
height: 4px;
|
|
136
136
|
background-color: rgb(var(--zw-color-y300));
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
</template>
|
|
21
21
|
|
|
22
22
|
<script setup>
|
|
23
|
-
import { inject
|
|
23
|
+
import { inject } from 'vue';
|
|
24
24
|
import { Button, Icon } from '../../base';
|
|
25
25
|
import { InjectionTokens } from '../../../injectionTokens';
|
|
26
26
|
import { tooltip as vTooltip } from '../../../directives';
|
|
@@ -30,9 +30,7 @@ const editor = inject(InjectionTokens.EDITOR);
|
|
|
30
30
|
|
|
31
31
|
const currentValue = editor.commands.isItalic();
|
|
32
32
|
const isAvailable = editor.commands.isItalicAvailable();
|
|
33
|
-
const isCustomized =
|
|
34
|
-
return editor.commands.isSettingCustomized(TextSettings.FONT_STYLE).value;
|
|
35
|
-
});
|
|
33
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_STYLE);
|
|
36
34
|
const apply = () => editor.chain().focus().toggleItalic().run();
|
|
37
35
|
</script>
|
|
38
36
|
|
|
@@ -155,6 +155,13 @@ export class HtmlNormalizer extends BaseNormalizer {
|
|
|
155
155
|
|
|
156
156
|
itemEl.append(fragment);
|
|
157
157
|
this._removeStyleProperties(itemEl, HtmlNormalizer.BLOCK_STYLES);
|
|
158
|
+
this._removeStyleProperties(itemEl.parentElement, HtmlNormalizer.BLOCK_STYLES);
|
|
159
|
+
|
|
160
|
+
this._assignElementProperties(itemEl, itemEl.parentElement);
|
|
161
|
+
|
|
162
|
+
if (itemEl.parentElement.lastElementChild === itemEl) {
|
|
163
|
+
this._removeStyleProperties(itemEl.parentElement);
|
|
164
|
+
}
|
|
158
165
|
}
|
|
159
166
|
|
|
160
167
|
_isBlockNode(node) {
|
|
@@ -165,7 +172,7 @@ export class HtmlNormalizer extends BaseNormalizer {
|
|
|
165
172
|
return HtmlNormalizer.ROOT_NODE_NAMES.includes(node.tagName);
|
|
166
173
|
}
|
|
167
174
|
|
|
168
|
-
_assignElementProperties(target, source, properties) {
|
|
175
|
+
_assignElementProperties(target, source, properties = Array.from(source.style)) {
|
|
169
176
|
for (const property of properties) {
|
|
170
177
|
const value = source.style.getPropertyValue(property);
|
|
171
178
|
|
|
@@ -175,7 +182,7 @@ export class HtmlNormalizer extends BaseNormalizer {
|
|
|
175
182
|
}
|
|
176
183
|
}
|
|
177
184
|
|
|
178
|
-
_removeStyleProperties(element, properties) {
|
|
185
|
+
_removeStyleProperties(element, properties = Array.from(element.style)) {
|
|
179
186
|
for (const property of properties) {
|
|
180
187
|
element.style.removeProperty(property);
|
|
181
188
|
}
|
|
@@ -79,7 +79,14 @@ describe('normalize text content', () => {
|
|
|
79
79
|
|
|
80
80
|
test('should assign block styles from list to paragraph', () => {
|
|
81
81
|
const input = '<ul style="line-height: 2;"><li>lorem ipsum</li></ul>';
|
|
82
|
-
const output = '<ul
|
|
82
|
+
const output = '<ul><li><p style="line-height: 2;">lorem ipsum</p></li></ul>';
|
|
83
|
+
|
|
84
|
+
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('should assign styles from list to item', () => {
|
|
88
|
+
const input = '<ul style="color: red;"><li>lorem ipsum</li></ul>';
|
|
89
|
+
const output = '<ul><li style="color: red;"><p>lorem ipsum</p></li></ul>';
|
|
83
90
|
|
|
84
91
|
expect(ContentNormalizer.normalize(input)).toBe(output);
|
|
85
92
|
});
|