@zipify/wysiwyg 4.11.0-3 → 4.11.0-4
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/.github/pull_request_template.md +1 -1
- package/.oxlintrc.json +11 -3
- package/dist/cli.js +37 -37
- package/dist/node.js +26 -26
- package/dist/wysiwyg.css +7 -7
- package/dist/wysiwyg.mjs +61 -65
- package/lib/components/toolbar/controls/stylePreset/StylePresetControl.vue +8 -10
- package/lib/extensions/core/SelectionProcessor.js +3 -3
- package/lib/extensions/list/List.js +30 -34
- package/package.json +8 -8
package/dist/wysiwyg.css
CHANGED
|
@@ -664,23 +664,23 @@
|
|
|
664
664
|
text-decoration: var(--zw-text-decoration-option);
|
|
665
665
|
}
|
|
666
666
|
|
|
667
|
-
.zw-style-preset-control[data-v-
|
|
667
|
+
.zw-style-preset-control[data-v-b3e7129d] {
|
|
668
668
|
display: flex;
|
|
669
669
|
align-items: center;
|
|
670
670
|
}
|
|
671
|
-
.zw-style-preset-control__dropdown[data-v-
|
|
671
|
+
.zw-style-preset-control__dropdown[data-v-b3e7129d] {
|
|
672
672
|
width: 120px;
|
|
673
673
|
}
|
|
674
|
-
.zw-style-preset-control__reset[data-v-
|
|
674
|
+
.zw-style-preset-control__reset[data-v-b3e7129d] {
|
|
675
675
|
color: rgb(var(--zw-color-n70));
|
|
676
676
|
background-color: rgb(var(--zw-color-n20));
|
|
677
677
|
}
|
|
678
|
-
.zw-style-preset-control__reset[data-v-
|
|
678
|
+
.zw-style-preset-control__reset[data-v-b3e7129d]:disabled {
|
|
679
679
|
background-color: transparent;
|
|
680
680
|
}
|
|
681
|
-
.zw-style-preset-control__reset[data-v-
|
|
682
|
-
.zw-style-preset-control__reset[data-v-
|
|
683
|
-
.zw-style-preset-control__reset[data-v-
|
|
681
|
+
.zw-style-preset-control__reset[data-v-b3e7129d]:not(:disabled):hover,
|
|
682
|
+
.zw-style-preset-control__reset[data-v-b3e7129d]:not(:disabled):focus,
|
|
683
|
+
.zw-style-preset-control__reset[data-v-b3e7129d]:not(:disabled):focus-within {
|
|
684
684
|
color: rgb(var(--zw-color-white));
|
|
685
685
|
background-color: rgb(var(--zw-color-n30));
|
|
686
686
|
}
|
package/dist/wysiwyg.mjs
CHANGED
|
@@ -20369,7 +20369,7 @@ State.prototype = {
|
|
|
20369
20369
|
}
|
|
20370
20370
|
};
|
|
20371
20371
|
const ta = (state, input, next, flags, groups) => state.ta(input, next, flags, groups);
|
|
20372
|
-
const tr
|
|
20372
|
+
const tr = (state, regexp, next, flags, groups) => state.tr(regexp, next, flags, groups);
|
|
20373
20373
|
const ts = (state, input, next, flags, groups) => state.ts(input, next, flags, groups);
|
|
20374
20374
|
const tt = (state, input, next, flags, groups) => state.tt(input, next, flags, groups);
|
|
20375
20375
|
const WORD = "WORD";
|
|
@@ -20547,58 +20547,58 @@ function init$2(customSchemes = []) {
|
|
|
20547
20547
|
tt(Start, "_", UNDERSCORE);
|
|
20548
20548
|
tt(Start, "\\", BACKSLASH);
|
|
20549
20549
|
tt(Start, "・", FULLWIDTHMIDDLEDOT);
|
|
20550
|
-
const Num = tr
|
|
20550
|
+
const Num = tr(Start, DIGIT, NUM, {
|
|
20551
20551
|
[numeric]: true
|
|
20552
20552
|
});
|
|
20553
|
-
tr
|
|
20554
|
-
const Asciinumeric = tr
|
|
20553
|
+
tr(Num, DIGIT, Num);
|
|
20554
|
+
const Asciinumeric = tr(Num, ASCII_LETTER, ASCIINUMERICAL, {
|
|
20555
20555
|
[asciinumeric]: true
|
|
20556
20556
|
});
|
|
20557
|
-
const Alphanumeric = tr
|
|
20557
|
+
const Alphanumeric = tr(Num, LETTER, ALPHANUMERICAL, {
|
|
20558
20558
|
[alphanumeric]: true
|
|
20559
20559
|
});
|
|
20560
|
-
const Word = tr
|
|
20560
|
+
const Word = tr(Start, ASCII_LETTER, WORD, {
|
|
20561
20561
|
[ascii]: true
|
|
20562
20562
|
});
|
|
20563
|
-
tr
|
|
20564
|
-
tr
|
|
20565
|
-
tr
|
|
20566
|
-
tr
|
|
20567
|
-
const UWord = tr
|
|
20563
|
+
tr(Word, DIGIT, Asciinumeric);
|
|
20564
|
+
tr(Word, ASCII_LETTER, Word);
|
|
20565
|
+
tr(Asciinumeric, DIGIT, Asciinumeric);
|
|
20566
|
+
tr(Asciinumeric, ASCII_LETTER, Asciinumeric);
|
|
20567
|
+
const UWord = tr(Start, LETTER, UWORD, {
|
|
20568
20568
|
[alpha]: true
|
|
20569
20569
|
});
|
|
20570
|
-
tr
|
|
20571
|
-
tr
|
|
20572
|
-
tr
|
|
20573
|
-
tr
|
|
20574
|
-
tr
|
|
20575
|
-
tr
|
|
20570
|
+
tr(UWord, ASCII_LETTER);
|
|
20571
|
+
tr(UWord, DIGIT, Alphanumeric);
|
|
20572
|
+
tr(UWord, LETTER, UWord);
|
|
20573
|
+
tr(Alphanumeric, DIGIT, Alphanumeric);
|
|
20574
|
+
tr(Alphanumeric, ASCII_LETTER);
|
|
20575
|
+
tr(Alphanumeric, LETTER, Alphanumeric);
|
|
20576
20576
|
const Nl2 = tt(Start, LF, NL, {
|
|
20577
20577
|
[whitespace]: true
|
|
20578
20578
|
});
|
|
20579
20579
|
const Cr = tt(Start, CR, WS, {
|
|
20580
20580
|
[whitespace]: true
|
|
20581
20581
|
});
|
|
20582
|
-
const Ws = tr
|
|
20582
|
+
const Ws = tr(Start, SPACE, WS, {
|
|
20583
20583
|
[whitespace]: true
|
|
20584
20584
|
});
|
|
20585
20585
|
tt(Start, OBJECT_REPLACEMENT, Ws);
|
|
20586
20586
|
tt(Cr, LF, Nl2);
|
|
20587
20587
|
tt(Cr, OBJECT_REPLACEMENT, Ws);
|
|
20588
|
-
tr
|
|
20588
|
+
tr(Cr, SPACE, Ws);
|
|
20589
20589
|
tt(Ws, CR);
|
|
20590
20590
|
tt(Ws, LF);
|
|
20591
|
-
tr
|
|
20591
|
+
tr(Ws, SPACE, Ws);
|
|
20592
20592
|
tt(Ws, OBJECT_REPLACEMENT, Ws);
|
|
20593
|
-
const Emoji = tr
|
|
20593
|
+
const Emoji = tr(Start, EMOJI, EMOJI$1, {
|
|
20594
20594
|
[emoji]: true
|
|
20595
20595
|
});
|
|
20596
20596
|
tt(Emoji, "#");
|
|
20597
|
-
tr
|
|
20597
|
+
tr(Emoji, EMOJI, Emoji);
|
|
20598
20598
|
tt(Emoji, EMOJI_VARIATION, Emoji);
|
|
20599
20599
|
const EmojiJoiner = tt(Emoji, EMOJI_JOINER);
|
|
20600
20600
|
tt(EmojiJoiner, "#");
|
|
20601
|
-
tr
|
|
20601
|
+
tr(EmojiJoiner, EMOJI, Emoji);
|
|
20602
20602
|
const wordjr = [[ASCII_LETTER, Word], [DIGIT, Asciinumeric]];
|
|
20603
20603
|
const uwordjr = [[ASCII_LETTER, null], [LETTER, UWord], [DIGIT, Alphanumeric]];
|
|
20604
20604
|
for (let i = 0; i < tlds.length; i++) {
|
|
@@ -23345,10 +23345,10 @@ const SelectionProcessor = Extension.create({
|
|
|
23345
23345
|
to = Math.max(to, position + node.nodeSize - offset2);
|
|
23346
23346
|
}
|
|
23347
23347
|
});
|
|
23348
|
-
commands2.setTextSelection({ from: from2, to });
|
|
23348
|
+
return commands2.setTextSelection({ from: from2, to });
|
|
23349
23349
|
}),
|
|
23350
23350
|
expandSelectionToBlock: createCommand(({ commands: commands2 }) => {
|
|
23351
|
-
commands2.expandSelection(({ parent }) => parent.type.name ===
|
|
23351
|
+
return commands2.expandSelection(({ parent }) => parent.type.name === NodeType3.DOCUMENT);
|
|
23352
23352
|
})
|
|
23353
23353
|
};
|
|
23354
23354
|
}
|
|
@@ -24385,7 +24385,7 @@ const ListItem = ListItem$1.extend({
|
|
|
24385
24385
|
})
|
|
24386
24386
|
});
|
|
24387
24387
|
function canBubbleMark(node, childMark) {
|
|
24388
|
-
if (
|
|
24388
|
+
if (TextInlineMarkList.includes(childMark.type)) return false;
|
|
24389
24389
|
if (childMark.type.isInSet(node.marks)) return false;
|
|
24390
24390
|
for (const child of node.content.content) {
|
|
24391
24391
|
if (!child.childCount) continue;
|
|
@@ -24394,22 +24394,22 @@ function canBubbleMark(node, childMark) {
|
|
|
24394
24394
|
}
|
|
24395
24395
|
return true;
|
|
24396
24396
|
}
|
|
24397
|
-
function bubbleListItemMarks(
|
|
24398
|
-
const from2 = selection.$from.start();
|
|
24399
|
-
const to = selection.$to.end();
|
|
24400
|
-
|
|
24401
|
-
if (node.type.name ===
|
|
24402
|
-
if (node.type.name !==
|
|
24397
|
+
function bubbleListItemMarks(tr2) {
|
|
24398
|
+
const from2 = tr2.selection.$from.start();
|
|
24399
|
+
const to = tr2.selection.$to.end();
|
|
24400
|
+
tr2.doc.nodesBetween(from2, to, (node, position) => {
|
|
24401
|
+
if (node.type.name === NodeType3.LIST) return;
|
|
24402
|
+
if (node.type.name !== NodeType3.LIST_ITEM) return false;
|
|
24403
24403
|
const bubbled = [];
|
|
24404
24404
|
node.forEach((child) => {
|
|
24405
24405
|
for (const childMark of child.marks) {
|
|
24406
24406
|
if (childMark.isInSet(bubbled)) {
|
|
24407
|
-
|
|
24407
|
+
tr2.removeNodeMark(position + 1, childMark);
|
|
24408
24408
|
continue;
|
|
24409
24409
|
}
|
|
24410
24410
|
if (canBubbleMark(node, childMark)) {
|
|
24411
|
-
|
|
24412
|
-
|
|
24411
|
+
tr2.removeNodeMark(position + 1, childMark);
|
|
24412
|
+
tr2.addNodeMark(position, copyMark(childMark));
|
|
24413
24413
|
bubbled.push(childMark);
|
|
24414
24414
|
}
|
|
24415
24415
|
}
|
|
@@ -24418,10 +24418,10 @@ function bubbleListItemMarks({ doc: doc2, selection }) {
|
|
|
24418
24418
|
});
|
|
24419
24419
|
}
|
|
24420
24420
|
const List = Node$1.create({
|
|
24421
|
-
name:
|
|
24422
|
-
content: `${
|
|
24421
|
+
name: NodeType3.LIST,
|
|
24422
|
+
content: `${NodeType3.LIST_ITEM}+`,
|
|
24423
24423
|
group: "block list",
|
|
24424
|
-
marks:
|
|
24424
|
+
marks: MarkGroup.SETTINGS,
|
|
24425
24425
|
addExtensions: () => [
|
|
24426
24426
|
ListItem
|
|
24427
24427
|
],
|
|
@@ -24431,17 +24431,17 @@ const List = Node$1.create({
|
|
|
24431
24431
|
}),
|
|
24432
24432
|
addAttributes: () => ({
|
|
24433
24433
|
bullet: {
|
|
24434
|
-
default: { type:
|
|
24434
|
+
default: { type: ListType.DISC }
|
|
24435
24435
|
}
|
|
24436
24436
|
}),
|
|
24437
24437
|
parseHTML() {
|
|
24438
24438
|
const HTML_TYPES = {
|
|
24439
|
-
a:
|
|
24440
|
-
i:
|
|
24441
|
-
1:
|
|
24439
|
+
a: ListType.ROMAN,
|
|
24440
|
+
i: ListType.LATIN,
|
|
24441
|
+
1: ListType.DECIMAL
|
|
24442
24442
|
};
|
|
24443
24443
|
const getBulletType = (element) => {
|
|
24444
|
-
for (const type of
|
|
24444
|
+
for (const type of ListTypeList) {
|
|
24445
24445
|
const bulletClass = `.${unref(this.options.baseClass)}${type}`;
|
|
24446
24446
|
if (element.matches(bulletClass)) return type;
|
|
24447
24447
|
if (HTML_TYPES[element.type.toLowerCase()] === type) return type;
|
|
@@ -24451,13 +24451,13 @@ const List = Node$1.create({
|
|
|
24451
24451
|
{
|
|
24452
24452
|
tag: "ol",
|
|
24453
24453
|
getAttrs: (element) => ({
|
|
24454
|
-
bullet: { type: getBulletType(element) ||
|
|
24454
|
+
bullet: { type: getBulletType(element) || ListType.DECIMAL }
|
|
24455
24455
|
})
|
|
24456
24456
|
},
|
|
24457
24457
|
{
|
|
24458
24458
|
tag: "ul",
|
|
24459
24459
|
getAttrs: (element) => ({
|
|
24460
|
-
bullet: { type: getBulletType(element) ||
|
|
24460
|
+
bullet: { type: getBulletType(element) || ListType.DISC }
|
|
24461
24461
|
})
|
|
24462
24462
|
}
|
|
24463
24463
|
];
|
|
@@ -24467,7 +24467,7 @@ const List = Node$1.create({
|
|
|
24467
24467
|
unref(this.options.baseClass) + attrs.bullet.type,
|
|
24468
24468
|
unref(this.options.presetClass)
|
|
24469
24469
|
];
|
|
24470
|
-
const isOrdered =
|
|
24470
|
+
const isOrdered = ListOrderedTypeList.includes(attrs.bullet.type);
|
|
24471
24471
|
return [isOrdered ? "ol" : "ul", { class: classes.join(" ") }, 0];
|
|
24472
24472
|
},
|
|
24473
24473
|
addCommands() {
|
|
@@ -24481,27 +24481,23 @@ const List = Node$1.create({
|
|
|
24481
24481
|
if (currentType === type) {
|
|
24482
24482
|
return commands2.removeList();
|
|
24483
24483
|
}
|
|
24484
|
-
return chain().applyDefaultPreset().toggleList(
|
|
24484
|
+
return chain().applyDefaultPreset().toggleList(NodeType3.LIST, NodeType3.LIST_ITEM).setBlockAttributes("bullet", { type }).command(({ tr: tr2 }) => bubbleListItemMarks(tr2)).run();
|
|
24485
24485
|
}),
|
|
24486
24486
|
removeList: createCommand(({ chain }) => {
|
|
24487
|
-
return chain().command(({ tr: tr2
|
|
24487
|
+
return chain().expandSelection(({ parent }) => parent.type.name === NodeType3.LIST).command(({ tr: tr2 }) => {
|
|
24488
24488
|
const from2 = tr2.selection.$from.start();
|
|
24489
24489
|
const to = tr2.selection.$to.end();
|
|
24490
|
-
let textFrom;
|
|
24491
24490
|
tr2.doc.nodesBetween(from2, to, (node, position, parent) => {
|
|
24492
|
-
if (node.
|
|
24493
|
-
|
|
24494
|
-
}
|
|
24495
|
-
if ([NodeTypes.LIST, NodeTypes.LIST_ITEM].includes(node.type.name)) return;
|
|
24496
|
-
if (parent.type.name !== NodeTypes.LIST_ITEM) return false;
|
|
24491
|
+
if ([NodeType3.LIST, NodeType3.LIST_ITEM].includes(node.type.name)) return;
|
|
24492
|
+
if (parent.type.name !== NodeType3.LIST_ITEM) return false;
|
|
24497
24493
|
const addingMarks = parent.marks.filter((mark) => !mark.type.isInSet(node.marks));
|
|
24498
24494
|
for (const mark of addingMarks) {
|
|
24499
24495
|
tr2.addNodeMark(position, copyMark(mark));
|
|
24500
24496
|
}
|
|
24501
24497
|
return false;
|
|
24502
24498
|
});
|
|
24503
|
-
return
|
|
24504
|
-
}).liftListItem(
|
|
24499
|
+
return true;
|
|
24500
|
+
}).liftListItem(NodeType3.LIST_ITEM).run();
|
|
24505
24501
|
})
|
|
24506
24502
|
};
|
|
24507
24503
|
},
|
|
@@ -24513,10 +24509,10 @@ const List = Node$1.create({
|
|
|
24513
24509
|
joinPredicate: (_, { attrs }) => attrs.bullet.type === bullet
|
|
24514
24510
|
});
|
|
24515
24511
|
return [
|
|
24516
|
-
wrappingListRule(
|
|
24517
|
-
wrappingListRule(
|
|
24518
|
-
wrappingListRule(
|
|
24519
|
-
wrappingListRule(
|
|
24512
|
+
wrappingListRule(ListType.DISC, /^\s*([-+*])\s$/),
|
|
24513
|
+
wrappingListRule(ListType.DECIMAL, /^(\d+)\.\s$/),
|
|
24514
|
+
wrappingListRule(ListType.LATIN, /^([ivx]{1,3})\.\s$/i),
|
|
24515
|
+
wrappingListRule(ListType.ROMAN, /^([a-z])\.\s$/i)
|
|
24520
24516
|
];
|
|
24521
24517
|
}
|
|
24522
24518
|
});
|
|
@@ -29849,7 +29845,7 @@ const _hoisted_1 = { class: "zw-style-preset-control" };
|
|
|
29849
29845
|
const _sfc_main$6 = {
|
|
29850
29846
|
__name: "StylePresetControl",
|
|
29851
29847
|
setup(__props) {
|
|
29852
|
-
const CLEAR_MARKS = [
|
|
29848
|
+
const CLEAR_MARKS = [TextSetting.FONT_SIZE, TextSetting.FONT_WEIGHT];
|
|
29853
29849
|
const editor = inject(InjectionTokens$1.EDITOR);
|
|
29854
29850
|
const presets = editor.commands.getPresetList();
|
|
29855
29851
|
const preset = editor.commands.getPreset();
|
|
@@ -29868,12 +29864,12 @@ const _sfc_main$6 = {
|
|
|
29868
29864
|
fontFamily: preset2.common.font_family,
|
|
29869
29865
|
fontStyle: preset2.common.font_style,
|
|
29870
29866
|
textDecoration: preset2.common.text_decoration,
|
|
29871
|
-
fontSize: preset2[
|
|
29867
|
+
fontSize: preset2[Device.DESKTOP].font_size
|
|
29872
29868
|
}
|
|
29873
29869
|
}));
|
|
29874
29870
|
});
|
|
29875
29871
|
const apply2 = (value) => {
|
|
29876
|
-
editor.chain().focus().
|
|
29872
|
+
editor.chain().focus().expandSelectionToBlock().applyPreset(value).removeMarks(CLEAR_MARKS).run();
|
|
29877
29873
|
};
|
|
29878
29874
|
const tooltip$1 = computed(() => isCustomized.value ? "Reset Styles to Page Styles" : "");
|
|
29879
29875
|
const removeCustomization = () => editor.chain().focus().removePresetCustomization().run();
|
|
@@ -29894,9 +29890,9 @@ const _sfc_main$6 = {
|
|
|
29894
29890
|
[unref(tooltip), "Text Type"]
|
|
29895
29891
|
]),
|
|
29896
29892
|
withDirectives((openBlock(), createBlock(unref(Button), {
|
|
29893
|
+
icon: "",
|
|
29897
29894
|
class: "zw-style-preset-control__reset",
|
|
29898
29895
|
disabled: !isCustomized.value,
|
|
29899
|
-
icon: "",
|
|
29900
29896
|
onClick: removeCustomization
|
|
29901
29897
|
}, {
|
|
29902
29898
|
default: withCtx(() => [
|
|
@@ -29914,7 +29910,7 @@ const _sfc_main$6 = {
|
|
|
29914
29910
|
};
|
|
29915
29911
|
}
|
|
29916
29912
|
};
|
|
29917
|
-
const StylePresetControl = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-
|
|
29913
|
+
const StylePresetControl = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-b3e7129d"]]);
|
|
29918
29914
|
const _sfc_main$5 = {
|
|
29919
29915
|
__name: "ToolbarDesktop",
|
|
29920
29916
|
props: {
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
</Dropdown>
|
|
15
15
|
|
|
16
16
|
<Button
|
|
17
|
+
icon
|
|
17
18
|
class="zw-style-preset-control__reset"
|
|
18
19
|
:disabled="!isCustomized"
|
|
19
|
-
icon
|
|
20
20
|
@click="removeCustomization"
|
|
21
21
|
v-tooltip="tooltip"
|
|
22
22
|
>
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
|
|
28
28
|
<script setup>
|
|
29
29
|
import { computed, inject, unref } from 'vue';
|
|
30
|
-
import { InjectionTokens } from '
|
|
31
|
-
import { Dropdown, Button, Icon } from '
|
|
32
|
-
import { tooltip as vTooltip } from '
|
|
33
|
-
import {
|
|
30
|
+
import { InjectionTokens } from '@/injectionTokens';
|
|
31
|
+
import { Dropdown, Button, Icon } from '@/components/base';
|
|
32
|
+
import { tooltip as vTooltip } from '@/directives';
|
|
33
|
+
import { Device, TextSetting } from '@/enums';
|
|
34
34
|
import StylePresetOption from './StylePresetOption';
|
|
35
35
|
|
|
36
|
-
const CLEAR_MARKS = [
|
|
36
|
+
const CLEAR_MARKS = [TextSetting.FONT_SIZE, TextSetting.FONT_WEIGHT];
|
|
37
37
|
|
|
38
38
|
const editor = inject(InjectionTokens.EDITOR);
|
|
39
39
|
|
|
@@ -57,7 +57,7 @@ const options = computed(() => {
|
|
|
57
57
|
fontFamily: preset.common.font_family,
|
|
58
58
|
fontStyle: preset.common.font_style,
|
|
59
59
|
textDecoration: preset.common.text_decoration,
|
|
60
|
-
fontSize: preset[
|
|
60
|
+
fontSize: preset[Device.DESKTOP].font_size
|
|
61
61
|
}
|
|
62
62
|
}));
|
|
63
63
|
});
|
|
@@ -65,11 +65,9 @@ const options = computed(() => {
|
|
|
65
65
|
const apply = (value) => {
|
|
66
66
|
editor.chain()
|
|
67
67
|
.focus()
|
|
68
|
-
.applyPreset(value)
|
|
69
|
-
.storeSelection()
|
|
70
68
|
.expandSelectionToBlock()
|
|
69
|
+
.applyPreset(value)
|
|
71
70
|
.removeMarks(CLEAR_MARKS)
|
|
72
|
-
.restoreSelection()
|
|
73
71
|
.run();
|
|
74
72
|
};
|
|
75
73
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Extension } from '@tiptap/vue-3';
|
|
2
2
|
import { createCommand, resolvePositionOffset } from '../../utils';
|
|
3
|
-
import {
|
|
3
|
+
import { NodeType } from '../../enums';
|
|
4
4
|
|
|
5
5
|
export const SelectionProcessor = Extension.create({
|
|
6
6
|
name: 'selection_processor',
|
|
@@ -32,11 +32,11 @@ export const SelectionProcessor = Extension.create({
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
commands.setTextSelection({ from, to });
|
|
35
|
+
return commands.setTextSelection({ from, to });
|
|
36
36
|
}),
|
|
37
37
|
|
|
38
38
|
expandSelectionToBlock: createCommand(({ commands }) => {
|
|
39
|
-
commands.expandSelection(({ parent }) => parent.type.name ===
|
|
39
|
+
return commands.expandSelection(({ parent }) => parent.type.name === NodeType.DOCUMENT);
|
|
40
40
|
})
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { computed, unref } from 'vue';
|
|
2
2
|
import { Node, wrappingInputRule } from '@tiptap/vue-3';
|
|
3
3
|
import { copyMark, createCommand } from '@/utils';
|
|
4
|
-
import {
|
|
4
|
+
import { ListOrderedTypeList, ListType, ListTypeList, MarkGroup, NodeType, TextInlineMarkList } from '@/enums';
|
|
5
5
|
import { ListItem } from './ListItem';
|
|
6
6
|
|
|
7
7
|
function canBubbleMark(node, childMark) {
|
|
8
|
-
if (
|
|
8
|
+
if (TextInlineMarkList.includes(childMark.type)) return false;
|
|
9
9
|
if (childMark.type.isInSet(node.marks)) return false;
|
|
10
10
|
|
|
11
11
|
for (const child of node.content.content) {
|
|
@@ -17,13 +17,13 @@ function canBubbleMark(node, childMark) {
|
|
|
17
17
|
return true;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function bubbleListItemMarks(
|
|
21
|
-
const from = selection.$from.start();
|
|
22
|
-
const to = selection.$to.end();
|
|
20
|
+
function bubbleListItemMarks(tr) {
|
|
21
|
+
const from = tr.selection.$from.start();
|
|
22
|
+
const to = tr.selection.$to.end();
|
|
23
23
|
|
|
24
|
-
doc.nodesBetween(from, to, (node, position) => {
|
|
25
|
-
if (node.type.name ===
|
|
26
|
-
if (node.type.name !==
|
|
24
|
+
tr.doc.nodesBetween(from, to, (node, position) => {
|
|
25
|
+
if (node.type.name === NodeType.LIST) return;
|
|
26
|
+
if (node.type.name !== NodeType.LIST_ITEM) return false;
|
|
27
27
|
|
|
28
28
|
const bubbled = [];
|
|
29
29
|
|
|
@@ -47,10 +47,10 @@ function bubbleListItemMarks({ doc, selection }) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export const List = Node.create({
|
|
50
|
-
name:
|
|
51
|
-
content: `${
|
|
50
|
+
name: NodeType.LIST,
|
|
51
|
+
content: `${NodeType.LIST_ITEM}+`,
|
|
52
52
|
group: 'block list',
|
|
53
|
-
marks:
|
|
53
|
+
marks: MarkGroup.SETTINGS,
|
|
54
54
|
|
|
55
55
|
addExtensions: () => [
|
|
56
56
|
ListItem
|
|
@@ -63,19 +63,19 @@ export const List = Node.create({
|
|
|
63
63
|
|
|
64
64
|
addAttributes: () => ({
|
|
65
65
|
bullet: {
|
|
66
|
-
default: { type:
|
|
66
|
+
default: { type: ListType.DISC }
|
|
67
67
|
}
|
|
68
68
|
}),
|
|
69
69
|
|
|
70
70
|
parseHTML() {
|
|
71
71
|
const HTML_TYPES = {
|
|
72
|
-
a:
|
|
73
|
-
i:
|
|
74
|
-
1:
|
|
72
|
+
a: ListType.ROMAN,
|
|
73
|
+
i: ListType.LATIN,
|
|
74
|
+
1: ListType.DECIMAL
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
const getBulletType = (element) => {
|
|
78
|
-
for (const type of
|
|
78
|
+
for (const type of ListTypeList) {
|
|
79
79
|
const bulletClass = `.${unref(this.options.baseClass)}${type}`;
|
|
80
80
|
|
|
81
81
|
if (element.matches(bulletClass)) return type;
|
|
@@ -88,14 +88,14 @@ export const List = Node.create({
|
|
|
88
88
|
tag: 'ol',
|
|
89
89
|
|
|
90
90
|
getAttrs: (element) => ({
|
|
91
|
-
bullet: { type: getBulletType(element) ||
|
|
91
|
+
bullet: { type: getBulletType(element) || ListType.DECIMAL }
|
|
92
92
|
})
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
tag: 'ul',
|
|
96
96
|
|
|
97
97
|
getAttrs: (element) => ({
|
|
98
|
-
bullet: { type: getBulletType(element) ||
|
|
98
|
+
bullet: { type: getBulletType(element) || ListType.DISC }
|
|
99
99
|
})
|
|
100
100
|
}
|
|
101
101
|
];
|
|
@@ -106,7 +106,7 @@ export const List = Node.create({
|
|
|
106
106
|
unref(this.options.baseClass) + attrs.bullet.type,
|
|
107
107
|
unref(this.options.presetClass)
|
|
108
108
|
];
|
|
109
|
-
const isOrdered =
|
|
109
|
+
const isOrdered = ListOrderedTypeList.includes(attrs.bullet.type);
|
|
110
110
|
|
|
111
111
|
return [isOrdered ? 'ol' : 'ul', { class: classes.join(' ') }, 0];
|
|
112
112
|
},
|
|
@@ -129,7 +129,7 @@ export const List = Node.create({
|
|
|
129
129
|
|
|
130
130
|
return chain()
|
|
131
131
|
.applyDefaultPreset()
|
|
132
|
-
.toggleList(
|
|
132
|
+
.toggleList(NodeType.LIST, NodeType.LIST_ITEM)
|
|
133
133
|
.setBlockAttributes('bullet', { type })
|
|
134
134
|
.command(({ tr }) => bubbleListItemMarks(tr))
|
|
135
135
|
.run();
|
|
@@ -137,18 +137,14 @@ export const List = Node.create({
|
|
|
137
137
|
|
|
138
138
|
removeList: createCommand(({ chain }) => {
|
|
139
139
|
return chain()
|
|
140
|
-
.
|
|
140
|
+
.expandSelection(({ parent }) => parent.type.name === NodeType.LIST)
|
|
141
|
+
.command(({ tr }) => {
|
|
141
142
|
const from = tr.selection.$from.start();
|
|
142
143
|
const to = tr.selection.$to.end();
|
|
143
|
-
let textFrom;
|
|
144
144
|
|
|
145
145
|
tr.doc.nodesBetween(from, to, (node, position, parent) => {
|
|
146
|
-
if (node.
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if ([NodeTypes.LIST, NodeTypes.LIST_ITEM].includes(node.type.name)) return;
|
|
151
|
-
if (parent.type.name !== NodeTypes.LIST_ITEM) return false;
|
|
146
|
+
if ([NodeType.LIST, NodeType.LIST_ITEM].includes(node.type.name)) return;
|
|
147
|
+
if (parent.type.name !== NodeType.LIST_ITEM) return false;
|
|
152
148
|
|
|
153
149
|
const addingMarks = parent.marks.filter((mark) => !mark.type.isInSet(node.marks));
|
|
154
150
|
|
|
@@ -159,9 +155,9 @@ export const List = Node.create({
|
|
|
159
155
|
return false;
|
|
160
156
|
});
|
|
161
157
|
|
|
162
|
-
return
|
|
158
|
+
return true;
|
|
163
159
|
})
|
|
164
|
-
.liftListItem(
|
|
160
|
+
.liftListItem(NodeType.LIST_ITEM)
|
|
165
161
|
.run();
|
|
166
162
|
})
|
|
167
163
|
};
|
|
@@ -176,10 +172,10 @@ export const List = Node.create({
|
|
|
176
172
|
});
|
|
177
173
|
|
|
178
174
|
return [
|
|
179
|
-
wrappingListRule(
|
|
180
|
-
wrappingListRule(
|
|
181
|
-
wrappingListRule(
|
|
182
|
-
wrappingListRule(
|
|
175
|
+
wrappingListRule(ListType.DISC, /^\s*([-+*])\s$/),
|
|
176
|
+
wrappingListRule(ListType.DECIMAL, /^(\d+)\.\s$/),
|
|
177
|
+
wrappingListRule(ListType.LATIN, /^([ivx]{1,3})\.\s$/i),
|
|
178
|
+
wrappingListRule(ListType.ROMAN, /^([a-z])\.\s$/i)
|
|
183
179
|
];
|
|
184
180
|
}
|
|
185
181
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zipify/wysiwyg",
|
|
3
|
-
"version": "4.11.0-
|
|
3
|
+
"version": "4.11.0-4",
|
|
4
4
|
"description": "Zipify modification of TipTap text editor",
|
|
5
5
|
"main": "dist/wysiwyg.mjs",
|
|
6
6
|
"types": "dist/wysiwyg.d.ts",
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@babel/core": "^7.26.
|
|
74
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
75
|
-
"@babel/preset-env": "^7.26.
|
|
76
|
-
"@babel/runtime": "^7.26.
|
|
77
|
-
"@optimize-lodash/rollup-plugin": "^5.0.
|
|
73
|
+
"@babel/core": "^7.26.9",
|
|
74
|
+
"@babel/plugin-transform-runtime": "^7.26.9",
|
|
75
|
+
"@babel/preset-env": "^7.26.9",
|
|
76
|
+
"@babel/runtime": "^7.26.9",
|
|
77
|
+
"@optimize-lodash/rollup-plugin": "^5.0.2",
|
|
78
78
|
"@rollup/plugin-alias": "^5.1.1",
|
|
79
79
|
"@rollup/plugin-commonjs": "^28.0.2",
|
|
80
80
|
"@rollup/plugin-json": "^6.1.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@vue/tsconfig": "^0.7.0",
|
|
90
90
|
"@vue/vue3-jest": "^29.2.6",
|
|
91
91
|
"@zipify/colorpicker": "^4.1.2",
|
|
92
|
-
"@zipify/eslint-config": "^3.0.
|
|
92
|
+
"@zipify/eslint-config": "^3.0.8",
|
|
93
93
|
"babel-jest": "^29.7.0",
|
|
94
94
|
"esbuild-jest-transform": "^2.0.1",
|
|
95
95
|
"husky": "^9.1.7",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"lint-staged": "^15.4.3",
|
|
99
99
|
"postcss-html": "^1.8.0",
|
|
100
100
|
"release-it": "^18.1.2",
|
|
101
|
-
"rollup": "^4.34.
|
|
101
|
+
"rollup": "^4.34.7",
|
|
102
102
|
"rollup-plugin-esbuild": "^6.2.0",
|
|
103
103
|
"rollup-plugin-esbuild-minify": "^1.2.0",
|
|
104
104
|
"simplebar": "^6.3.0",
|