@zipify/wysiwyg 2.0.0-10 → 2.0.0-11
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/dist/wysiwyg.css +8 -8
- package/dist/wysiwyg.mjs +31 -15
- package/lib/assets/icons/indicator.svg +1 -1
- package/lib/cli/commands/ToJsonCommand.js +15 -6
- package/lib/components/toolbar/controls/AlignmentControl.vue +1 -1
- package/lib/components/toolbar/controls/FontColorControl.vue +1 -1
- package/lib/components/toolbar/controls/FontFamilyControl.vue +1 -1
- package/lib/components/toolbar/controls/FontSizeControl.vue +1 -1
- package/lib/components/toolbar/controls/FontWeightControl.vue +1 -1
- package/lib/components/toolbar/controls/ItalicControl.vue +1 -1
- package/lib/components/toolbar/controls/LineHeightControl.vue +1 -1
- package/lib/extensions/StylePreset.js +2 -1
- package/lib/extensions/__tests__/StylePreset.test.js +4 -4
- package/lib/extensions/list/ListItem.js +25 -3
- package/package.json +9 -1
package/dist/wysiwyg.css
CHANGED
|
@@ -547,20 +547,20 @@
|
|
|
547
547
|
color: rgb(var(--zw-color-white));
|
|
548
548
|
}
|
|
549
549
|
|
|
550
|
-
.zw-font-family-control[data-v-
|
|
550
|
+
.zw-font-family-control[data-v-5f8e49dc] {
|
|
551
551
|
width: 96px;
|
|
552
552
|
}
|
|
553
|
-
.zw-font-family-control__option[data-v-
|
|
553
|
+
.zw-font-family-control__option[data-v-5f8e49dc] {
|
|
554
554
|
font-weight: 400;
|
|
555
555
|
font-family: var(--zw-font-family-option);
|
|
556
556
|
width: 150px;
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
.zw-font-weight-control[data-v-
|
|
559
|
+
.zw-font-weight-control[data-v-00378d67] {
|
|
560
560
|
width: 60px;
|
|
561
561
|
}
|
|
562
562
|
|
|
563
|
-
.zw-font-size-control[data-v-
|
|
563
|
+
.zw-font-size-control[data-v-13bfe2fe] {
|
|
564
564
|
width: 72px;
|
|
565
565
|
}
|
|
566
566
|
|
|
@@ -571,17 +571,17 @@
|
|
|
571
571
|
flex-direction: column;
|
|
572
572
|
}
|
|
573
573
|
|
|
574
|
-
.zw-line-height-control__modal[data-v-
|
|
574
|
+
.zw-line-height-control__modal[data-v-2f58c40f] {
|
|
575
575
|
padding: var(--zw-offset-sm);
|
|
576
576
|
}
|
|
577
|
-
.zw-line-height-control__row[data-v-
|
|
577
|
+
.zw-line-height-control__row[data-v-2f58c40f] {
|
|
578
578
|
display: flex;
|
|
579
579
|
align-items: center;
|
|
580
580
|
}
|
|
581
|
-
.zw-line-height-control__range[data-v-
|
|
581
|
+
.zw-line-height-control__range[data-v-2f58c40f] {
|
|
582
582
|
width: 156px;
|
|
583
583
|
}
|
|
584
|
-
.zw-line-height-control__field[data-v-
|
|
584
|
+
.zw-line-height-control__field[data-v-2f58c40f] {
|
|
585
585
|
width: 64px;
|
|
586
586
|
margin-left: var(--zw-offset-sm);
|
|
587
587
|
}
|
package/dist/wysiwyg.mjs
CHANGED
|
@@ -14427,7 +14427,7 @@ const __vite_glob_0_4 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" sty
|
|
|
14427
14427
|
const __vite_glob_0_5 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="#fff" stroke="#B3B3B3" d="M4.5 4.5h19v19h-19z"/>\n <path fill="#3B3B3B" d="M26 20.7a2.51 2.51 0 0 1-5 0c0-1.31 2.5-4.7 2.5-4.7s2.5 3.39 2.5 4.7Z"/>\n <path fill="#3B3B3B" fill-rule="evenodd" d="M19.64 19.93h-1.715a.75.75 0 0 1-.475-.145.82.82 0 0 1-.268-.359l-.89-2.433h-4.943l-.89 2.433a.78.78 0 0 1-.26.347.73.73 0 0 1-.475.157H8L12.686 8h2.269l4.686 11.93Zm-7.721-4.505h3.803l-1.452-3.968a18.048 18.048 0 0 1-.219-.623c-.08-.24-.158-.5-.235-.78-.077.28-.152.542-.227.784a8.742 8.742 0 0 1-.218.635l-1.452 3.952Z" clip-rule="evenodd"/>\n</svg>\n';
|
|
14428
14428
|
const __vite_glob_0_6 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M16.64 19.93h-1.715a.75.75 0 0 1-.475-.145.82.82 0 0 1-.268-.359l-.89-2.433H8.35l-.891 2.433a.78.78 0 0 1-.26.347.73.73 0 0 1-.475.157H5L9.686 8h2.269l4.686 11.93Zm-7.72-4.505h3.803l-1.452-3.968a18.048 18.048 0 0 1-.219-.623c-.08-.24-.158-.5-.235-.78-.077.28-.152.542-.227.784a8.742 8.742 0 0 1-.218.635L8.92 15.425Zm14.968 4.505h-.915a.987.987 0 0 1-.454-.087c-.11-.058-.192-.175-.248-.35l-.181-.603a7.005 7.005 0 0 1-.631.507c-.206.146-.42.269-.64.368a3.26 3.26 0 0 1-.7.222c-.248.05-.523.075-.826.075-.357 0-.687-.049-.99-.145a2.134 2.134 0 0 1-.78-.433 1.967 1.967 0 0 1-.507-.718 2.545 2.545 0 0 1-.181-.998c0-.319.084-.634.251-.945.168-.31.447-.59.838-.841.39-.25.91-.458 1.559-.623.649-.165 1.455-.258 2.417-.28v-.495c0-.567-.12-.986-.359-1.259-.239-.272-.587-.408-1.043-.408-.33 0-.605.039-.825.116a3.17 3.17 0 0 0-.574.26 25.11 25.11 0 0 1-.45.26.912.912 0 0 1-.453.115.59.59 0 0 1-.355-.107.843.843 0 0 1-.239-.264l-.371-.652c.973-.891 2.148-1.337 3.523-1.337.494 0 .936.081 1.324.244.387.162.716.387.985.676.27.289.475.634.615 1.036.14.401.21.841.21 1.32v5.346Zm-3.96-1.271c.21 0 .402-.02.578-.058.176-.038.342-.096.5-.173.156-.077.307-.172.453-.285a4.13 4.13 0 0 0 .441-.4v-1.427c-.594.027-1.09.078-1.489.153a3.967 3.967 0 0 0-.961.284c-.242.116-.414.25-.516.404a.894.894 0 0 0-.152.504c0 .357.106.613.317.767.212.154.489.231.83.231Z" clip-rule="evenodd"/>\n</svg>\n';
|
|
14429
14429
|
const __vite_glob_0_7 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M22 20.62a2.42 2.42 0 0 1-4.84 0c0-1.25 2.42-4.54 2.42-4.54S22 19.37 22 20.62ZM9.92 15.425l1.452-3.951c.071-.182.145-.394.219-.636.074-.242.149-.503.226-.783a17.223 17.223 0 0 0 .454 1.402l1.452 3.968H9.919Zm5.411 4.199c.226-.795.658-1.684 1.184-2.562L12.955 8h-2.269L6 19.93h1.725a.736.736 0 0 0 .474-.157.792.792 0 0 0 .26-.347l.891-2.434h4.941l.891 2.434c.031.079.097.134.148.198Z" clip-rule="evenodd"/>\n</svg>\n';
|
|
14430
|
-
const __vite_glob_0_8 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 9 9">\n <path fill="#FFAB00" d="M0 4.5a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0Z"/>\n <path fill="#fff" fill-rule="evenodd" d="M5.063 2.25H3.938v3.375h1.124V2.25Zm-1.125 4.5a.562.562 0 1 1 1.123-.001.562.562 0 0 1-1.123.001Z" clip-rule="evenodd"/>\n</svg>\n';
|
|
14430
|
+
const __vite_glob_0_8 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 9 9">\n <path fill="#FFAB00" d="M0 4.5a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0Z"/>\n <path fill="#fff" fill-rule="evenodd" d="M5.063 2.25H3.938v3.375h1.124V2.25Zm-1.125 4.5a.562.562 0 1 1 1.123-.001.562.562 0 0 1-1.123.001Z" clip-rule="evenodd"/>\n</svg>\n';
|
|
14431
14431
|
const __vite_glob_0_9 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M18 9V7h-7v2h2.64l-1.22 10H10v2h7v-2h-2.83L15.4 9H18Z"/>\n</svg>\n';
|
|
14432
14432
|
const __vite_glob_0_10 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="m5 10 3-3 3 3H9v8h2l-3 3-3-3h2v-8H5Zm8-3h10v2H13V7Zm10 6H13v2h10v-2Zm0 6H13v2h10v-2Z" clip-rule="evenodd"/>\n</svg>\n';
|
|
14433
14433
|
const __vite_glob_0_11 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M12 17.5h-2a3.5 3.5 0 1 1 0-7h2V9h-2a5 5 0 0 0 0 10h2v-1.5Zm6-4.5h-8v2h8v-2Zm-2-4h2a5 5 0 0 1 0 10h-2v-1.5h2a3.5 3.5 0 1 0 0-7h-2V9Z" clip-rule="evenodd"/>\n</svg>\n';
|
|
@@ -22401,7 +22401,7 @@ const __vue2_script$n = {
|
|
|
22401
22401
|
return { "--zw-font-family-option": `"${option.id}"` };
|
|
22402
22402
|
}
|
|
22403
22403
|
const currentValue = editor.commands.getFontFamily();
|
|
22404
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
22404
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_FAMILY);
|
|
22405
22405
|
const apply2 = (fontFamily) => {
|
|
22406
22406
|
recentFontNames.add(fontFamily);
|
|
22407
22407
|
editor.chain().focus().applyFontFamily(fontFamily).run();
|
|
@@ -22422,7 +22422,7 @@ var __component__$n = /* @__PURE__ */ normalizeComponent(
|
|
|
22422
22422
|
staticRenderFns$n,
|
|
22423
22423
|
false,
|
|
22424
22424
|
__vue2_injectStyles$n,
|
|
22425
|
-
"
|
|
22425
|
+
"5f8e49dc",
|
|
22426
22426
|
null,
|
|
22427
22427
|
null
|
|
22428
22428
|
);
|
|
@@ -22474,7 +22474,7 @@ const __vue2_script$m = {
|
|
|
22474
22474
|
const font = editor.commands.getFont();
|
|
22475
22475
|
const options = computed(() => unref(font).weights.map((style2) => ({ id: style2 })));
|
|
22476
22476
|
const currentValue = editor.commands.getFontWeight();
|
|
22477
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
22477
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_WEIGHT);
|
|
22478
22478
|
const apply2 = (value) => editor.chain().focus().applyFontWeight(value).run();
|
|
22479
22479
|
return {
|
|
22480
22480
|
options,
|
|
@@ -22491,7 +22491,7 @@ var __component__$m = /* @__PURE__ */ normalizeComponent(
|
|
|
22491
22491
|
staticRenderFns$m,
|
|
22492
22492
|
false,
|
|
22493
22493
|
__vue2_injectStyles$m,
|
|
22494
|
-
"
|
|
22494
|
+
"00378d67",
|
|
22495
22495
|
null,
|
|
22496
22496
|
null
|
|
22497
22497
|
);
|
|
@@ -22545,7 +22545,7 @@ const __vue2_script$l = {
|
|
|
22545
22545
|
return fontSizes.map((size2) => ({ id: size2, title: `${size2}px` }));
|
|
22546
22546
|
});
|
|
22547
22547
|
const currentValue = editor.commands.getFontSize();
|
|
22548
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
22548
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_SIZE);
|
|
22549
22549
|
const apply2 = (value) => editor.chain().focus().applyFontSize(value).run();
|
|
22550
22550
|
return {
|
|
22551
22551
|
options,
|
|
@@ -22562,7 +22562,7 @@ var __component__$l = /* @__PURE__ */ normalizeComponent(
|
|
|
22562
22562
|
staticRenderFns$l,
|
|
22563
22563
|
false,
|
|
22564
22564
|
__vue2_injectStyles$l,
|
|
22565
|
-
"
|
|
22565
|
+
"13bfe2fe",
|
|
22566
22566
|
null,
|
|
22567
22567
|
null
|
|
22568
22568
|
);
|
|
@@ -22646,7 +22646,7 @@ const __vue2_script$k = {
|
|
|
22646
22646
|
setup() {
|
|
22647
22647
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
22648
22648
|
const currentValue = editor.commands.getFontColor();
|
|
22649
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
22649
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_COLOR);
|
|
22650
22650
|
const apply2 = (color) => editor.chain().applyFontColor(color).run();
|
|
22651
22651
|
return {
|
|
22652
22652
|
currentValue,
|
|
@@ -22816,7 +22816,7 @@ const __vue2_script$i = {
|
|
|
22816
22816
|
setup() {
|
|
22817
22817
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
22818
22818
|
const currentValue = editor.commands.isItalic();
|
|
22819
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
22819
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_STYLE);
|
|
22820
22820
|
const isAvailable = editor.commands.isItalicAvailable();
|
|
22821
22821
|
const apply2 = () => editor.chain().focus().toggleItalic().run();
|
|
22822
22822
|
return {
|
|
@@ -23239,7 +23239,7 @@ const __vue2_script$d = {
|
|
|
23239
23239
|
setup(_, { emit }) {
|
|
23240
23240
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
23241
23241
|
const currentValue = editor.commands.getAlignment();
|
|
23242
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
23242
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
|
|
23243
23243
|
function apply2(value) {
|
|
23244
23244
|
editor.chain().focus().applyAlignment(value).run();
|
|
23245
23245
|
emit("applied");
|
|
@@ -23462,7 +23462,7 @@ const __vue2_script$b = {
|
|
|
23462
23462
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
23463
23463
|
const toggler = useModalToggler({ wrapperRef, modalRef });
|
|
23464
23464
|
const currentValue = editor.commands.getLineHeight();
|
|
23465
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
23465
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.LINE_HEIGHT);
|
|
23466
23466
|
const apply2 = (value) => editor.commands.applyLineHeight(String(value));
|
|
23467
23467
|
return {
|
|
23468
23468
|
wrapperRef,
|
|
@@ -23482,7 +23482,7 @@ var __component__$b = /* @__PURE__ */ normalizeComponent(
|
|
|
23482
23482
|
staticRenderFns$b,
|
|
23483
23483
|
false,
|
|
23484
23484
|
__vue2_injectStyles$b,
|
|
23485
|
-
"
|
|
23485
|
+
"2f58c40f",
|
|
23486
23486
|
null,
|
|
23487
23487
|
null
|
|
23488
23488
|
);
|
|
@@ -24721,8 +24721,9 @@ const StylePreset = Extension.create({
|
|
|
24721
24721
|
};
|
|
24722
24722
|
});
|
|
24723
24723
|
}),
|
|
24724
|
-
isSettingCustomized: createCommand(({ commands: commands2 },
|
|
24724
|
+
isSettingCustomized: createCommand(({ commands: commands2 }, name) => {
|
|
24725
24725
|
const customization = commands2.getPresetCustomization();
|
|
24726
|
+
const group = TextSettings.attributes.includes(name) ? "attributes" : "marks";
|
|
24726
24727
|
return computed(() => {
|
|
24727
24728
|
var _a, _b;
|
|
24728
24729
|
return (_b = (_a = unref(customization)[group]) == null ? void 0 : _a.includes(name)) != null ? _b : false;
|
|
@@ -25476,12 +25477,27 @@ const ListItem$1 = Node.create({
|
|
|
25476
25477
|
const ListItem = ListItem$1.extend({
|
|
25477
25478
|
name: NodeTypes.LIST_ITEM,
|
|
25478
25479
|
marks: MarkGroups.SETTINGS,
|
|
25480
|
+
addCommands() {
|
|
25481
|
+
const getSelectedListItem = ({ selection, doc: doc2 }) => {
|
|
25482
|
+
const position = selection.$cursor.before(selection.$cursor.depth - 1);
|
|
25483
|
+
return { position, node: doc2.nodeAt(position) };
|
|
25484
|
+
};
|
|
25485
|
+
return {
|
|
25486
|
+
listItemNewline: createCommand(({ commands: commands2, tr }) => {
|
|
25487
|
+
const { node: initialNode } = getSelectedListItem(tr);
|
|
25488
|
+
commands2.splitListItem(this.name);
|
|
25489
|
+
const { position } = getSelectedListItem(tr);
|
|
25490
|
+
for (const mark of initialNode.marks) {
|
|
25491
|
+
tr.step(new AddNodeMarkStep(position, copyMark(mark)));
|
|
25492
|
+
}
|
|
25493
|
+
})
|
|
25494
|
+
};
|
|
25495
|
+
},
|
|
25479
25496
|
addOptions: () => ({
|
|
25480
25497
|
HTMLAttributes: { class: "zw-style" }
|
|
25481
25498
|
}),
|
|
25482
25499
|
addKeyboardShortcuts() {
|
|
25483
|
-
|
|
25484
|
-
return { Enter };
|
|
25500
|
+
return { Enter: createKeyboardShortcut("listItemNewline") };
|
|
25485
25501
|
}
|
|
25486
25502
|
});
|
|
25487
25503
|
const List = Node.create({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 9 9">
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 9 9">
|
|
2
2
|
<path fill="#FFAB00" d="M0 4.5a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0Z"/>
|
|
3
3
|
<path fill="#fff" fill-rule="evenodd" d="M5.063 2.25H3.938v3.375h1.124V2.25Zm-1.125 4.5a.562.562 0 1 1 1.123-.001.562.562 0 0 1-1.123.001Z" clip-rule="evenodd"/>
|
|
4
4
|
</svg>
|
|
@@ -9,19 +9,25 @@ export class ToJsonCommand extends Command {
|
|
|
9
9
|
|
|
10
10
|
options = [
|
|
11
11
|
{
|
|
12
|
-
flags: '--config <path>',
|
|
12
|
+
flags: '-c, --config <path>',
|
|
13
13
|
description: 'Generator config',
|
|
14
14
|
// Relative to dist folder
|
|
15
15
|
default: resolve(__dirname, '../bin/zp.config.json')
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
flags: '-f, --format <type>',
|
|
19
|
+
description: 'Set output format',
|
|
20
|
+
default: 'rb'
|
|
16
21
|
}
|
|
17
22
|
];
|
|
18
23
|
|
|
19
|
-
doCommand(html, { config }) {
|
|
24
|
+
doCommand(html, { config, format }) {
|
|
20
25
|
const configPath = resolve(process.cwd(), config);
|
|
21
26
|
const serializer = ContentSerializer.build(require(configPath).editor);
|
|
22
|
-
const
|
|
27
|
+
const content = serializer.toJSON(this.#formatInputHtml(html));
|
|
28
|
+
const json = this.#stringifyContent(content);
|
|
23
29
|
|
|
24
|
-
this.output(this.#
|
|
30
|
+
this.output(format === 'rb' ? this.#formatOutputRb(json) : json);
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
#formatInputHtml(html) {
|
|
@@ -32,10 +38,13 @@ export class ToJsonCommand extends Command {
|
|
|
32
38
|
});
|
|
33
39
|
}
|
|
34
40
|
|
|
35
|
-
#
|
|
41
|
+
#stringifyContent(content) {
|
|
36
42
|
const skipNullValue = (_, value) => value === null ? undefined : value;
|
|
37
|
-
const json = JSON.stringify(object, skipNullValue, 2);
|
|
38
43
|
|
|
44
|
+
return JSON.stringify(content, skipNullValue, 2);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
#formatOutputRb(json) {
|
|
39
48
|
return json
|
|
40
49
|
.replace(/\\"/g, '"')
|
|
41
50
|
.replace(/font-family: ?'(.+)'/g, 'font-family: "$1"')
|
|
@@ -66,7 +66,7 @@ export default {
|
|
|
66
66
|
const editor = inject(InjectionTokens.EDITOR);
|
|
67
67
|
|
|
68
68
|
const currentValue = editor.commands.getAlignment();
|
|
69
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
69
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
|
|
70
70
|
|
|
71
71
|
function apply(value) {
|
|
72
72
|
editor.chain().focus().applyAlignment(value).run();
|
|
@@ -48,7 +48,7 @@ export default {
|
|
|
48
48
|
const editor = inject(InjectionTokens.EDITOR);
|
|
49
49
|
|
|
50
50
|
const currentValue = editor.commands.getFontColor();
|
|
51
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
51
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_COLOR);
|
|
52
52
|
|
|
53
53
|
const apply = (color) => editor.chain().applyFontColor(color).run();
|
|
54
54
|
|
|
@@ -69,7 +69,7 @@ export default {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
const currentValue = editor.commands.getFontFamily();
|
|
72
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
72
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_FAMILY);
|
|
73
73
|
|
|
74
74
|
const apply = (fontFamily) => {
|
|
75
75
|
recentFontNames.add(fontFamily);
|
|
@@ -36,7 +36,7 @@ export default {
|
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
const currentValue = editor.commands.getFontSize();
|
|
39
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
39
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_SIZE);
|
|
40
40
|
|
|
41
41
|
const apply = (value) => editor.chain().focus().applyFontSize(value).run();
|
|
42
42
|
|
|
@@ -34,7 +34,7 @@ export default {
|
|
|
34
34
|
const options = computed(() => unref(font).weights.map((style) => ({ id: style })));
|
|
35
35
|
|
|
36
36
|
const currentValue = editor.commands.getFontWeight();
|
|
37
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
37
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_WEIGHT);
|
|
38
38
|
|
|
39
39
|
const apply = (value) => editor.chain().focus().applyFontWeight(value).run();
|
|
40
40
|
|
|
@@ -44,7 +44,7 @@ export default {
|
|
|
44
44
|
const editor = inject(InjectionTokens.EDITOR);
|
|
45
45
|
|
|
46
46
|
const currentValue = editor.commands.isItalic();
|
|
47
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
47
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_STYLE);
|
|
48
48
|
|
|
49
49
|
const isAvailable = editor.commands.isItalicAvailable();
|
|
50
50
|
const apply = () => editor.chain().focus().toggleItalic().run();
|
|
@@ -79,7 +79,7 @@ export default {
|
|
|
79
79
|
const toggler = useModalToggler({ wrapperRef, modalRef });
|
|
80
80
|
|
|
81
81
|
const currentValue = editor.commands.getLineHeight();
|
|
82
|
-
const isCustomized = editor.commands.isSettingCustomized(
|
|
82
|
+
const isCustomized = editor.commands.isSettingCustomized(TextSettings.LINE_HEIGHT);
|
|
83
83
|
|
|
84
84
|
const apply = (value) => editor.commands.applyLineHeight(String(value));
|
|
85
85
|
|
|
@@ -161,8 +161,9 @@ export const StylePreset = Extension.create({
|
|
|
161
161
|
});
|
|
162
162
|
}),
|
|
163
163
|
|
|
164
|
-
isSettingCustomized: createCommand(({ commands },
|
|
164
|
+
isSettingCustomized: createCommand(({ commands }, name) => {
|
|
165
165
|
const customization = commands.getPresetCustomization();
|
|
166
|
+
const group = TextSettings.attributes.includes(name) ? 'attributes' : 'marks';
|
|
166
167
|
|
|
167
168
|
return computed(() => unref(customization)[group]?.includes(name) ?? false);
|
|
168
169
|
}),
|
|
@@ -413,8 +413,8 @@ describe('get preset customization', () => {
|
|
|
413
413
|
presets: [createPreset({ id: 'regular-1' })]
|
|
414
414
|
});
|
|
415
415
|
|
|
416
|
-
const isFontSizeCustomized = editor.commands.isSettingCustomized(
|
|
417
|
-
const isAlignmentCustomized = editor.commands.isSettingCustomized(
|
|
416
|
+
const isFontSizeCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_SIZE);
|
|
417
|
+
const isAlignmentCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
|
|
418
418
|
|
|
419
419
|
expect(isFontSizeCustomized.value).toBe(false);
|
|
420
420
|
expect(isAlignmentCustomized.value).toBe(false);
|
|
@@ -454,7 +454,7 @@ describe('get preset customization', () => {
|
|
|
454
454
|
});
|
|
455
455
|
|
|
456
456
|
editor.commands.selectAll();
|
|
457
|
-
const isFontSizeCustomized = editor.commands.isSettingCustomized(
|
|
457
|
+
const isFontSizeCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_SIZE);
|
|
458
458
|
|
|
459
459
|
expect(isFontSizeCustomized.value).toBe(true);
|
|
460
460
|
});
|
|
@@ -489,7 +489,7 @@ describe('get preset customization', () => {
|
|
|
489
489
|
});
|
|
490
490
|
|
|
491
491
|
editor.commands.selectAll();
|
|
492
|
-
const isAlignmentCustomized = editor.commands.isSettingCustomized(
|
|
492
|
+
const isAlignmentCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
|
|
493
493
|
|
|
494
494
|
expect(isAlignmentCustomized.value).toBe(true);
|
|
495
495
|
});
|
|
@@ -1,17 +1,39 @@
|
|
|
1
1
|
import Base from '@tiptap/extension-list-item';
|
|
2
2
|
import { MarkGroups, NodeTypes } from '../../enums';
|
|
3
|
+
import { copyMark, createCommand, createKeyboardShortcut } from '../../utils';
|
|
4
|
+
import { AddNodeMarkStep } from '../core/steps';
|
|
3
5
|
|
|
4
6
|
export const ListItem = Base.extend({
|
|
5
7
|
name: NodeTypes.LIST_ITEM,
|
|
6
8
|
marks: MarkGroups.SETTINGS,
|
|
7
9
|
|
|
10
|
+
addCommands() {
|
|
11
|
+
const getSelectedListItem = ({ selection, doc }) => {
|
|
12
|
+
const position = selection.$cursor.before(selection.$cursor.depth - 1);
|
|
13
|
+
|
|
14
|
+
return { position, node: doc.nodeAt(position) };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
listItemNewline: createCommand(({ commands, tr }) => {
|
|
19
|
+
const { node: initialNode } = getSelectedListItem(tr);
|
|
20
|
+
|
|
21
|
+
commands.splitListItem(this.name);
|
|
22
|
+
|
|
23
|
+
const { position } = getSelectedListItem(tr);
|
|
24
|
+
|
|
25
|
+
for (const mark of initialNode.marks) {
|
|
26
|
+
tr.step(new AddNodeMarkStep(position, copyMark(mark)));
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
|
|
8
32
|
addOptions: () => ({
|
|
9
33
|
HTMLAttributes: { class: 'zw-style' }
|
|
10
34
|
}),
|
|
11
35
|
|
|
12
36
|
addKeyboardShortcuts() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return { Enter };
|
|
37
|
+
return { Enter: createKeyboardShortcut('listItemNewline') };
|
|
16
38
|
}
|
|
17
39
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zipify/wysiwyg",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-11",
|
|
4
4
|
"description": "Zipify modification of TipTap text editor",
|
|
5
5
|
"main": "dist/wysiwyg.mjs",
|
|
6
6
|
"bin": {
|
|
@@ -54,6 +54,14 @@
|
|
|
54
54
|
"@zipify/colorpicker": "^2.2",
|
|
55
55
|
"vue": "^2.7"
|
|
56
56
|
},
|
|
57
|
+
"peerDependenciesMeta": {
|
|
58
|
+
"@zipify/colorpicker": {
|
|
59
|
+
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"vue": {
|
|
62
|
+
"optional": true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
57
65
|
"devDependencies": {
|
|
58
66
|
"@babel/core": "^7.19.1",
|
|
59
67
|
"@babel/eslint-parser": "^7.19.1",
|