@zipify/wysiwyg 1.3.2 → 1.3.3
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 +1 -1
- package/lib/cli/commands/ToJsonCommand.js +15 -6
- package/package.json +9 -1
|
@@ -8,19 +8,25 @@ export class ToJsonCommand extends Command {
|
|
|
8
8
|
|
|
9
9
|
options = [
|
|
10
10
|
{
|
|
11
|
-
flags: '--config <path>',
|
|
11
|
+
flags: '-c, --config <path>',
|
|
12
12
|
description: 'Generator config',
|
|
13
13
|
// Relative to dist folder
|
|
14
14
|
default: resolve(__dirname, '../bin/zp.config.json')
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
flags: '-f, --format <type>',
|
|
18
|
+
description: 'Set output format',
|
|
19
|
+
default: 'rb'
|
|
15
20
|
}
|
|
16
21
|
];
|
|
17
22
|
|
|
18
|
-
doCommand(html, { config }) {
|
|
23
|
+
doCommand(html, { config, format }) {
|
|
19
24
|
const configPath = resolve(process.cwd(), config);
|
|
20
25
|
const serializer = ContentSerializer.build(require(configPath).editor);
|
|
21
|
-
const
|
|
26
|
+
const content = serializer.toJSON(this.#formatInputHtml(html));
|
|
27
|
+
const json = this.#stringifyContent(content);
|
|
22
28
|
|
|
23
|
-
this.output(this.#
|
|
29
|
+
this.output(format === 'rb' ? this.#formatOutputRb(json) : json);
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
#formatInputHtml(html) {
|
|
@@ -31,10 +37,13 @@ export class ToJsonCommand extends Command {
|
|
|
31
37
|
});
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
#
|
|
40
|
+
#stringifyContent(content) {
|
|
35
41
|
const skipNullValue = (_, value) => value === null ? undefined : value;
|
|
36
|
-
const json = JSON.stringify(object, skipNullValue, 2);
|
|
37
42
|
|
|
43
|
+
return JSON.stringify(content, skipNullValue, 2);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
#formatOutputRb(json) {
|
|
38
47
|
return json
|
|
39
48
|
.replace(/\\"/g, '"')
|
|
40
49
|
.replace(/font-family: ?'(.+)'/g, 'font-family: "$1"')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zipify/wysiwyg",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.3",
|
|
4
4
|
"description": "Zipify modification of TipTap text editor",
|
|
5
5
|
"main": "dist/wysiwyg.mjs",
|
|
6
6
|
"bin": {
|
|
@@ -52,6 +52,14 @@
|
|
|
52
52
|
"@zipify/colorpicker": "^2.2",
|
|
53
53
|
"vue": "^2.7"
|
|
54
54
|
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"@zipify/colorpicker": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"vue": {
|
|
60
|
+
"optional": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
55
63
|
"devDependencies": {
|
|
56
64
|
"@babel/core": "^7.19.0",
|
|
57
65
|
"@babel/eslint-parser": "^7.18.9",
|