@zipify/wysiwyg 1.4.0-0 → 1.4.0-1
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/config/build/cli.config.js +6 -2
- package/dist/cli.js +2 -2
- package/dist/wysiwyg.css +26 -27
- package/dist/wysiwyg.mjs +66 -5
- package/lib/cli/commands/Command.js +34 -0
- package/lib/cli/commands/ToJsonCommand.js +45 -0
- package/lib/cli/commands/index.js +1 -0
- package/lib/cli/index.js +1 -0
- package/lib/components/base/Button.vue +1 -2
- package/lib/components/base/dropdown/DropdownActivator.vue +6 -0
- package/lib/components/toolbar/controls/AlignmentControl.vue +1 -0
- package/lib/components/toolbar/controls/FontColorControl.vue +1 -0
- package/lib/components/toolbar/controls/ItalicControl.vue +1 -0
- package/lib/components/toolbar/controls/LineHeightControl.vue +1 -0
- package/lib/components/toolbar/controls/UnderlineControl.vue +1 -0
- package/lib/directives/__tests__/tooltip.test.js +22 -4
- package/lib/directives/tooltip.js +4 -1
- package/lib/entry-cli.js +6 -20
- package/lib/extensions/FontFamily.js +1 -1
- package/package.json +3 -2
package/dist/wysiwyg.css
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
column-gap: var(--zw-offset-xxs);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
.zw-button[data-v-
|
|
26
|
+
.zw-button[data-v-1ea5f7a2] {
|
|
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-1ea5f7a2]::-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-1ea5f7a2]:hover,
|
|
50
|
+
.zw-button[data-v-1ea5f7a2]:focus {
|
|
51
51
|
text-decoration: none;
|
|
52
52
|
outline: none;
|
|
53
53
|
}
|
|
54
|
-
.zw-button[data-v-
|
|
54
|
+
.zw-button[data-v-1ea5f7a2]: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-1ea5f7a2] {
|
|
61
61
|
border-radius: 1px;
|
|
62
62
|
min-height: 28px;
|
|
63
63
|
font-weight: var(--zw-font-weight-semibold);
|
|
@@ -67,36 +67,35 @@
|
|
|
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-1ea5f7a2] {
|
|
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-1ea5f7a2],
|
|
77
|
+
.zw-button--secondary[data-v-1ea5f7a2] {
|
|
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-1ea5f7a2]:not(:disabled):hover,
|
|
84
|
+
.zw-button--secondary[data-v-1ea5f7a2]:not(:disabled):hover {
|
|
85
85
|
opacity: 0.9;
|
|
86
86
|
}
|
|
87
|
-
.zw-button--toolbar[data-v-
|
|
87
|
+
.zw-button--toolbar[data-v-1ea5f7a2]: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-1ea5f7a2]:not(:disabled):hover,
|
|
91
|
+
.zw-button--toolbar[data-v-1ea5f7a2]:not(:disabled):focus,
|
|
92
|
+
.zw-button--toolbar.zw-button--active[data-v-1ea5f7a2]:not(:disabled) {
|
|
93
93
|
color: rgb(var(--zw-color-white));
|
|
94
94
|
background-color: rgb(var(--zw-color-n5));
|
|
95
95
|
}
|
|
96
|
-
.zw-button__customized-indicator[data-v-
|
|
97
|
-
display: inline-block !important;
|
|
96
|
+
.zw-button__customized-indicator[data-v-1ea5f7a2] {
|
|
98
97
|
position: absolute;
|
|
99
|
-
top:
|
|
98
|
+
top: 0;
|
|
100
99
|
right: 2px;
|
|
101
100
|
}
|
|
102
101
|
|
|
@@ -461,21 +460,21 @@
|
|
|
461
460
|
font-size: var(--zw-font-size-xs);
|
|
462
461
|
}
|
|
463
462
|
|
|
464
|
-
.zw-dropdown__activator[data-v-
|
|
463
|
+
.zw-dropdown__activator[data-v-0f1c87fd] {
|
|
465
464
|
width: 100%;
|
|
466
465
|
}
|
|
467
|
-
.zw-dropdown__activator-arrow[data-v-
|
|
466
|
+
.zw-dropdown__activator-arrow[data-v-0f1c87fd] {
|
|
468
467
|
margin-left: auto;
|
|
469
468
|
}
|
|
470
|
-
.zw-dropdown__activator--active .zw-dropdown__activator-arrow[data-v-
|
|
469
|
+
.zw-dropdown__activator--active .zw-dropdown__activator-arrow[data-v-0f1c87fd] {
|
|
471
470
|
transform: rotateX(180deg);
|
|
472
471
|
}
|
|
473
|
-
.zw-dropdown__activator--gray[data-v-
|
|
472
|
+
.zw-dropdown__activator--gray[data-v-0f1c87fd] {
|
|
474
473
|
background-color: rgb(var(--zw-color-n20));
|
|
475
474
|
font-size: var(--zw-font-size-xxs);
|
|
476
475
|
color: rgb(var(--zw-color-white));
|
|
477
476
|
}
|
|
478
|
-
.zw-dropdown__customized-indicator[data-v-
|
|
477
|
+
.zw-dropdown__customized-indicator[data-v-0f1c87fd] {
|
|
479
478
|
position: relative;
|
|
480
479
|
top: calc(0px - var(--zw-offset-xs));
|
|
481
480
|
}
|
|
@@ -572,17 +571,17 @@
|
|
|
572
571
|
flex-direction: column;
|
|
573
572
|
}
|
|
574
573
|
|
|
575
|
-
.zw-line-height-control__modal[data-v-
|
|
574
|
+
.zw-line-height-control__modal[data-v-c316d7dc] {
|
|
576
575
|
padding: var(--zw-offset-sm);
|
|
577
576
|
}
|
|
578
|
-
.zw-line-height-control__row[data-v-
|
|
577
|
+
.zw-line-height-control__row[data-v-c316d7dc] {
|
|
579
578
|
display: flex;
|
|
580
579
|
align-items: center;
|
|
581
580
|
}
|
|
582
|
-
.zw-line-height-control__range[data-v-
|
|
581
|
+
.zw-line-height-control__range[data-v-c316d7dc] {
|
|
583
582
|
width: 156px;
|
|
584
583
|
}
|
|
585
|
-
.zw-line-height-control__field[data-v-
|
|
584
|
+
.zw-line-height-control__field[data-v-c316d7dc] {
|
|
586
585
|
width: 64px;
|
|
587
586
|
margin-left: var(--zw-offset-sm);
|
|
588
587
|
}
|
package/dist/wysiwyg.mjs
CHANGED
|
@@ -14286,7 +14286,7 @@ var __component__$F = /* @__PURE__ */ normalizeComponent(
|
|
|
14286
14286
|
staticRenderFns$F,
|
|
14287
14287
|
false,
|
|
14288
14288
|
__vue2_injectStyles$F,
|
|
14289
|
-
"
|
|
14289
|
+
"1ea5f7a2",
|
|
14290
14290
|
null,
|
|
14291
14291
|
null
|
|
14292
14292
|
);
|
|
@@ -19840,13 +19840,17 @@ const outClick = {
|
|
|
19840
19840
|
toggleListener(false, dataStorage.get(el).callback);
|
|
19841
19841
|
}
|
|
19842
19842
|
};
|
|
19843
|
-
function tooltip(el, { value }) {
|
|
19843
|
+
function tooltip(el, { value, modifiers: modifiers2 }) {
|
|
19844
19844
|
const options = typeof value === "string" ? { text: value } : value;
|
|
19845
19845
|
const { text: text2, hotkey } = options;
|
|
19846
19846
|
if (text2)
|
|
19847
19847
|
el.dataset.tooltip = text2;
|
|
19848
19848
|
if (text2 && hotkey)
|
|
19849
19849
|
el.dataset.tooltipHotkey = hotkey;
|
|
19850
|
+
if (modifiers2.xs)
|
|
19851
|
+
el.dataset.tooltipSize = "xs";
|
|
19852
|
+
if (modifiers2.lg)
|
|
19853
|
+
el.dataset.tooltipSize = "lg";
|
|
19850
19854
|
}
|
|
19851
19855
|
var render$y = function __render__11() {
|
|
19852
19856
|
var _vm = this;
|
|
@@ -20145,6 +20149,15 @@ var render$v = function __render__14() {
|
|
|
20145
20149
|
}, [_c("span", {
|
|
20146
20150
|
staticClass: "zw-dropdown__activator-title zw-text--truncate"
|
|
20147
20151
|
}, [_vm._v(" " + _vm._s(_vm.activeOptionTitle) + " ")]), _vm.isCustomized ? _c("Icon", {
|
|
20152
|
+
directives: [{
|
|
20153
|
+
name: "tooltip",
|
|
20154
|
+
rawName: "v-tooltip.xs",
|
|
20155
|
+
value: "Default parameter setting is changed",
|
|
20156
|
+
expression: "'Default parameter setting is changed'",
|
|
20157
|
+
modifiers: {
|
|
20158
|
+
"xs": true
|
|
20159
|
+
}
|
|
20160
|
+
}],
|
|
20148
20161
|
staticClass: "zw-dropdown__customized-indicator",
|
|
20149
20162
|
attrs: {
|
|
20150
20163
|
"name": "indicator",
|
|
@@ -20172,6 +20185,9 @@ const __vue2_script$v = {
|
|
|
20172
20185
|
Icon,
|
|
20173
20186
|
Button
|
|
20174
20187
|
},
|
|
20188
|
+
directives: {
|
|
20189
|
+
tooltip
|
|
20190
|
+
},
|
|
20175
20191
|
model: {
|
|
20176
20192
|
event: "change"
|
|
20177
20193
|
},
|
|
@@ -20211,7 +20227,7 @@ var __component__$v = /* @__PURE__ */ normalizeComponent(
|
|
|
20211
20227
|
staticRenderFns$v,
|
|
20212
20228
|
false,
|
|
20213
20229
|
__vue2_injectStyles$v,
|
|
20214
|
-
"
|
|
20230
|
+
"0f1c87fd",
|
|
20215
20231
|
null,
|
|
20216
20232
|
null
|
|
20217
20233
|
);
|
|
@@ -21162,6 +21178,15 @@ var render$k = function __render__25() {
|
|
|
21162
21178
|
"auto-color": ""
|
|
21163
21179
|
}
|
|
21164
21180
|
}), _vm.isCustomized ? _c("Icon", {
|
|
21181
|
+
directives: [{
|
|
21182
|
+
name: "tooltip",
|
|
21183
|
+
rawName: "v-tooltip.xs",
|
|
21184
|
+
value: "Default parameter setting is changed",
|
|
21185
|
+
expression: "'Default parameter setting is changed'",
|
|
21186
|
+
modifiers: {
|
|
21187
|
+
"xs": true
|
|
21188
|
+
}
|
|
21189
|
+
}],
|
|
21165
21190
|
staticClass: "zw-button__customized-indicator",
|
|
21166
21191
|
attrs: {
|
|
21167
21192
|
"name": "indicator",
|
|
@@ -21327,6 +21352,15 @@ var render$i = function __render__27() {
|
|
|
21327
21352
|
"auto-color": ""
|
|
21328
21353
|
}
|
|
21329
21354
|
}), _vm.isCustomized ? _c("Icon", {
|
|
21355
|
+
directives: [{
|
|
21356
|
+
name: "tooltip",
|
|
21357
|
+
rawName: "v-tooltip.xs",
|
|
21358
|
+
value: "Default parameter setting is changed",
|
|
21359
|
+
expression: "'Default parameter setting is changed'",
|
|
21360
|
+
modifiers: {
|
|
21361
|
+
"xs": true
|
|
21362
|
+
}
|
|
21363
|
+
}],
|
|
21330
21364
|
staticClass: "zw-button__customized-indicator",
|
|
21331
21365
|
attrs: {
|
|
21332
21366
|
"name": "indicator",
|
|
@@ -21408,6 +21442,15 @@ var render$h = function __render__28() {
|
|
|
21408
21442
|
"auto-color": ""
|
|
21409
21443
|
}
|
|
21410
21444
|
}), _vm.isCustomized ? _c("Icon", {
|
|
21445
|
+
directives: [{
|
|
21446
|
+
name: "tooltip",
|
|
21447
|
+
rawName: "v-tooltip.xs",
|
|
21448
|
+
value: "Default parameter setting is changed",
|
|
21449
|
+
expression: "'Default parameter setting is changed'",
|
|
21450
|
+
modifiers: {
|
|
21451
|
+
"xs": true
|
|
21452
|
+
}
|
|
21453
|
+
}],
|
|
21411
21454
|
staticClass: "zw-button__customized-indicator",
|
|
21412
21455
|
attrs: {
|
|
21413
21456
|
"name": "indicator",
|
|
@@ -21704,6 +21747,15 @@ var render$d = function __render__32() {
|
|
|
21704
21747
|
"click": activate
|
|
21705
21748
|
}
|
|
21706
21749
|
}, [_vm.isCustomized && isActive2 ? _c("Icon", {
|
|
21750
|
+
directives: [{
|
|
21751
|
+
name: "tooltip",
|
|
21752
|
+
rawName: "v-tooltip.xs",
|
|
21753
|
+
value: "Default parameter setting is changed",
|
|
21754
|
+
expression: "'Default parameter setting is changed'",
|
|
21755
|
+
modifiers: {
|
|
21756
|
+
"xs": true
|
|
21757
|
+
}
|
|
21758
|
+
}],
|
|
21707
21759
|
staticClass: "zw-button__customized-indicator",
|
|
21708
21760
|
attrs: {
|
|
21709
21761
|
"name": "indicator",
|
|
@@ -21902,6 +21954,15 @@ var render$b = function __render__34() {
|
|
|
21902
21954
|
"auto-color": ""
|
|
21903
21955
|
}
|
|
21904
21956
|
}), _vm.isCustomized ? _c("Icon", {
|
|
21957
|
+
directives: [{
|
|
21958
|
+
name: "tooltip",
|
|
21959
|
+
rawName: "v-tooltip.xs",
|
|
21960
|
+
value: "Default parameter setting is changed",
|
|
21961
|
+
expression: "'Default parameter setting is changed'",
|
|
21962
|
+
modifiers: {
|
|
21963
|
+
"xs": true
|
|
21964
|
+
}
|
|
21965
|
+
}],
|
|
21905
21966
|
staticClass: "zw-button__customized-indicator",
|
|
21906
21967
|
attrs: {
|
|
21907
21968
|
"name": "indicator",
|
|
@@ -21987,7 +22048,7 @@ var __component__$b = /* @__PURE__ */ normalizeComponent(
|
|
|
21987
22048
|
staticRenderFns$b,
|
|
21988
22049
|
false,
|
|
21989
22050
|
__vue2_injectStyles$b,
|
|
21990
|
-
"
|
|
22051
|
+
"c316d7dc",
|
|
21991
22052
|
null,
|
|
21992
22053
|
null
|
|
21993
22054
|
);
|
|
@@ -23082,7 +23143,7 @@ const FontFamily = Mark.create({
|
|
|
23082
23143
|
},
|
|
23083
23144
|
parseHTML() {
|
|
23084
23145
|
const getAttrs = (input) => {
|
|
23085
|
-
const parsed = input.replace(/"/g, "");
|
|
23146
|
+
const parsed = input.replace(/["']/g, "");
|
|
23086
23147
|
const isExists = this.options.fonts.some((font) => font.name === parsed);
|
|
23087
23148
|
const value = isExists ? parsed : unref(this.options.defaultPreset).common.font_family;
|
|
23088
23149
|
return { value };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export class Command {
|
|
2
|
+
name;
|
|
3
|
+
argument;
|
|
4
|
+
options = [];
|
|
5
|
+
|
|
6
|
+
doCommand() {
|
|
7
|
+
throw new Error('Command "doCommand" is required');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
install(program) {
|
|
11
|
+
if (!this.name) {
|
|
12
|
+
throw new Error('Command "name" is required');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let building = program.command(this.name);
|
|
16
|
+
|
|
17
|
+
if (this.argument) {
|
|
18
|
+
building = building.argument(this.argument);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (this.options.length) {
|
|
22
|
+
for (const option of this.options) {
|
|
23
|
+
building = building.option(option.flags, option.description, option.default);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
building.action(this.doCommand.bind(this));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
output(data) {
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.log(data);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { ContentSerializer } from '../ContentSerializer';
|
|
3
|
+
import { Command } from './Command';
|
|
4
|
+
|
|
5
|
+
export class ToJsonCommand extends Command {
|
|
6
|
+
name = 'to-json';
|
|
7
|
+
argument = '<html>';
|
|
8
|
+
|
|
9
|
+
options = [
|
|
10
|
+
{
|
|
11
|
+
flags: '--config <path>',
|
|
12
|
+
description: 'Generator config',
|
|
13
|
+
// Relative to dist folder
|
|
14
|
+
default: resolve(__dirname, '../bin/zp.config.json')
|
|
15
|
+
}
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
doCommand(html, { config }) {
|
|
19
|
+
const configPath = resolve(process.cwd(), config);
|
|
20
|
+
const serializer = ContentSerializer.build(require(configPath).editor);
|
|
21
|
+
const json = serializer.toJSON(this.#formatInputHtml(html));
|
|
22
|
+
|
|
23
|
+
this.output(this.#formatOutputJson(json));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#formatInputHtml(html) {
|
|
27
|
+
return html
|
|
28
|
+
.replace(/\\(["'])/g, '$1')
|
|
29
|
+
.replace(/rgba\(\d{1,3}, ?\d{1,3}, ?\d{1,3}, (\d{1,2}%)\)/g, (substring, alpha) => {
|
|
30
|
+
return substring.replace(alpha, parseFloat(alpha) / 100);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#formatOutputJson(object) {
|
|
35
|
+
const skipNullValue = (_, value) => value === null ? undefined : value;
|
|
36
|
+
const json = JSON.stringify(object, skipNullValue, 2);
|
|
37
|
+
|
|
38
|
+
return json
|
|
39
|
+
.replace(/\\"/g, '"')
|
|
40
|
+
.replace(/font-family: ?'(.+)'/g, 'font-family: "$1"')
|
|
41
|
+
.replace(/'/g, '\\\'')
|
|
42
|
+
.replace(/^[\t ]*"[^:\n\r]+(?<!\\)":/gm, (match) => match.replace(/"/g, ''))
|
|
43
|
+
.replace(/: "(.+)"([,\n])/g, ': \'$1\'$2');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ToJsonCommand } from './ToJsonCommand';
|
package/lib/cli/index.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
name="indicator"
|
|
19
19
|
size="9px"
|
|
20
20
|
data-test-selector="customizedIndicator"
|
|
21
|
+
v-tooltip.xs="'Default parameter setting is changed'"
|
|
21
22
|
/>
|
|
22
23
|
|
|
23
24
|
<Icon
|
|
@@ -35,6 +36,7 @@
|
|
|
35
36
|
import { computed, inject, toRef } from 'vue';
|
|
36
37
|
import Button from '../Button';
|
|
37
38
|
import Icon from '../Icon';
|
|
39
|
+
import { tooltip } from '../../../directives';
|
|
38
40
|
import { InjectionTokens } from './injectionTokens';
|
|
39
41
|
import { useDropdownEntityTitle } from './composables';
|
|
40
42
|
|
|
@@ -46,6 +48,10 @@ export default {
|
|
|
46
48
|
Button
|
|
47
49
|
},
|
|
48
50
|
|
|
51
|
+
directives: {
|
|
52
|
+
tooltip
|
|
53
|
+
},
|
|
54
|
+
|
|
49
55
|
model: {
|
|
50
56
|
event: 'change'
|
|
51
57
|
},
|
|
@@ -4,7 +4,7 @@ describe('rendering', () => {
|
|
|
4
4
|
test('should render text only tooltip', () => {
|
|
5
5
|
const el = document.createElement('div');
|
|
6
6
|
|
|
7
|
-
tooltip(el, { value: 'Test' });
|
|
7
|
+
tooltip(el, { value: 'Test', modifiers: {} });
|
|
8
8
|
|
|
9
9
|
expect(el.dataset.tooltip).toBe('Test');
|
|
10
10
|
});
|
|
@@ -13,7 +13,8 @@ describe('rendering', () => {
|
|
|
13
13
|
const el = document.createElement('div');
|
|
14
14
|
|
|
15
15
|
tooltip(el, {
|
|
16
|
-
value: { text: 'Test' }
|
|
16
|
+
value: { text: 'Test' },
|
|
17
|
+
modifiers: {}
|
|
17
18
|
});
|
|
18
19
|
|
|
19
20
|
expect(el.dataset.tooltip).toBe('Test');
|
|
@@ -23,7 +24,8 @@ describe('rendering', () => {
|
|
|
23
24
|
const el = document.createElement('div');
|
|
24
25
|
|
|
25
26
|
tooltip(el, {
|
|
26
|
-
value: { text: 'Test', hotkey: 'Mod B' }
|
|
27
|
+
value: { text: 'Test', hotkey: 'Mod B' },
|
|
28
|
+
modifiers: {}
|
|
27
29
|
});
|
|
28
30
|
|
|
29
31
|
expect(el.dataset.tooltipHotkey).toBe('Mod B');
|
|
@@ -32,8 +34,24 @@ describe('rendering', () => {
|
|
|
32
34
|
test('should not render tooltip if no value passed', () => {
|
|
33
35
|
const el = document.createElement('div');
|
|
34
36
|
|
|
35
|
-
tooltip(el, { value: '' });
|
|
37
|
+
tooltip(el, { value: '', modifiers: {} });
|
|
36
38
|
|
|
37
39
|
expect(el.dataset).not.toHaveProperty('tooltip');
|
|
38
40
|
});
|
|
41
|
+
|
|
42
|
+
test('should render xs size', () => {
|
|
43
|
+
const el = document.createElement('div');
|
|
44
|
+
|
|
45
|
+
tooltip(el, { value: '', modifiers: { xs: true } });
|
|
46
|
+
|
|
47
|
+
expect(el.dataset).toHaveProperty('tooltipSize', 'xs');
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('should render lg size', () => {
|
|
51
|
+
const el = document.createElement('div');
|
|
52
|
+
|
|
53
|
+
tooltip(el, { value: '', modifiers: { lg: true } });
|
|
54
|
+
|
|
55
|
+
expect(el.dataset).toHaveProperty('tooltipSize', 'lg');
|
|
56
|
+
});
|
|
39
57
|
});
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
export function tooltip(el, { value }) {
|
|
1
|
+
export function tooltip(el, { value, modifiers }) {
|
|
2
2
|
const options = typeof value === 'string' ? { text: value } : value;
|
|
3
3
|
const { text, hotkey } = options;
|
|
4
4
|
|
|
5
5
|
if (text) el.dataset.tooltip = text;
|
|
6
6
|
if (text && hotkey) el.dataset.tooltipHotkey = hotkey;
|
|
7
|
+
|
|
8
|
+
if (modifiers.xs) el.dataset.tooltipSize = 'xs';
|
|
9
|
+
if (modifiers.lg) el.dataset.tooltipSize = 'lg';
|
|
7
10
|
}
|
package/lib/entry-cli.js
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
1
|
import { Command } from 'commander';
|
|
3
|
-
import {
|
|
2
|
+
import { ToJsonCommand } from './cli';
|
|
4
3
|
|
|
5
4
|
const program = new Command();
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const commands = [
|
|
7
|
+
ToJsonCommand
|
|
8
|
+
];
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.replace(/: "(.+)"([,\n])/g, ': \'$1\'$2');
|
|
10
|
+
for (const CommandClass of commands) {
|
|
11
|
+
new CommandClass().install(program);
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
program.command('to-json')
|
|
17
|
-
.argument('<html>')
|
|
18
|
-
.option('--config <path>', 'generator config', resolve(__dirname, '../bin/zp.config.json'))
|
|
19
|
-
.action((html, { config }) => {
|
|
20
|
-
const configPath = resolve(process.cwd(), config);
|
|
21
|
-
const serializer = ContentSerializer.build(require(configPath).editor);
|
|
22
|
-
const json = rubifyJSON(serializer.toJSON(html));
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line no-console
|
|
25
|
-
console.log(json);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
14
|
program.parse();
|
|
@@ -62,7 +62,7 @@ export const FontFamily = Mark.create({
|
|
|
62
62
|
|
|
63
63
|
parseHTML() {
|
|
64
64
|
const getAttrs = (input) => {
|
|
65
|
-
const parsed = input.replace(/"/g, '');
|
|
65
|
+
const parsed = input.replace(/["']/g, '');
|
|
66
66
|
const isExists = this.options.fonts.some((font) => font.name === parsed);
|
|
67
67
|
const value = isExists ? parsed : unref(this.options.defaultPreset).common.font_family;
|
|
68
68
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zipify/wysiwyg",
|
|
3
|
-
"version": "1.4.0-
|
|
3
|
+
"version": "1.4.0-1",
|
|
4
4
|
"description": "Zipify modification of TipTap text editor",
|
|
5
5
|
"main": "dist/wysiwyg.mjs",
|
|
6
6
|
"bin": {
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"lib:build": "vite build --config config/build/lib.config.js",
|
|
21
21
|
"lib:pre-release": "run-s lint:js lint:css test:unit",
|
|
22
22
|
"lib:release": "export $(cat ./.env | xargs) && run-s lib:pre-release lib:build cli:build && release-it",
|
|
23
|
-
"cli:build": "rollup --config config/build/cli.config.js",
|
|
23
|
+
"cli:build": "NODE_ENV=production rollup --config config/build/cli.config.js",
|
|
24
|
+
"cli:dev": "NODE_ENV=development rollup --config config/build/cli.config.js --watch",
|
|
24
25
|
"example:start": "NODE_ENV=development vite serve --config config/build/example.config.js",
|
|
25
26
|
"example:build": "NODE_ENV=production vite build --config config/build/example.config.js",
|
|
26
27
|
"test:unit": "jest .",
|