@mekari/pixel3-rich-text-editor 0.1.2 → 0.1.3-dev.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/dist/{chunk-7BEXEMOE.mjs → chunk-6O4HSL2C.mjs} +4 -0
- package/dist/chunk-76GEEOAG.mjs +189 -0
- package/dist/{chunk-MKTM47RO.mjs → chunk-AIWY3FHJ.mjs} +1 -1
- package/dist/chunk-BWRU2WZN.mjs +202 -0
- package/dist/{chunk-ZO6THAT6.mjs → chunk-COZ45QUD.mjs} +1 -1
- package/dist/chunk-ENKUUZPM.mjs +124 -0
- package/dist/{chunk-25RKPG44.mjs → chunk-FCLBNBXD.mjs} +25 -16
- package/dist/{chunk-Q7QLZISF.mjs → chunk-IFRJVX2K.mjs} +29 -1
- package/dist/{chunk-YE6FEVD4.mjs → chunk-RX7ZEE2M.mjs} +104 -58
- package/dist/{chunk-XNM3YX37.mjs → chunk-T7RFFPSJ.mjs} +13 -3
- package/dist/{chunk-YIEQVTEO.mjs → chunk-X2CB42A3.mjs} +1 -1
- package/dist/{chunk-5S2LSGJV.mjs → chunk-Y6UPQ6EU.mjs} +1 -1
- package/dist/{chunk-UBJOZ2IA.mjs → chunk-YWVVMJGP.mjs} +1 -1
- package/dist/editor-toolbar.d.mts +2 -1
- package/dist/editor-toolbar.d.ts +2 -1
- package/dist/editor-toolbar.js +469 -75
- package/dist/editor-toolbar.mjs +10 -8
- package/dist/extensions/align-extension.js +27 -0
- package/dist/extensions/align-extension.mjs +2 -2
- package/dist/extensions/color-extension.js +27 -0
- package/dist/extensions/color-extension.mjs +2 -2
- package/dist/extensions/heading-extension.js +27 -0
- package/dist/extensions/heading-extension.mjs +2 -2
- package/dist/extensions/icons.d.mts +2 -1
- package/dist/extensions/icons.d.ts +2 -1
- package/dist/extensions/icons.js +31 -2
- package/dist/extensions/icons.mjs +5 -3
- package/dist/extensions/index.d.mts +6 -0
- package/dist/extensions/index.d.ts +6 -0
- package/dist/extensions/index.js +368 -16
- package/dist/extensions/index.mjs +18 -10
- package/dist/extensions/link-extension.js +27 -0
- package/dist/extensions/link-extension.mjs +2 -2
- package/dist/extensions/single-extension.d.mts +12 -2
- package/dist/extensions/single-extension.d.ts +12 -2
- package/dist/extensions/single-extension.js +49 -14
- package/dist/extensions/single-extension.mjs +2 -2
- package/dist/extensions/variable-extension.d.mts +19 -0
- package/dist/extensions/variable-extension.d.ts +19 -0
- package/dist/extensions/variable-extension.js +158 -0
- package/dist/extensions/variable-extension.mjs +7 -0
- package/dist/extensions/variable-list-extension.d.mts +33 -0
- package/dist/extensions/variable-list-extension.d.ts +33 -0
- package/dist/extensions/variable-list-extension.js +210 -0
- package/dist/extensions/variable-list-extension.mjs +7 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +699 -116
- package/dist/index.mjs +14 -11
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/modules/rich-text-editor.props.d.mts +5 -1
- package/dist/modules/rich-text-editor.props.d.ts +5 -1
- package/dist/modules/rich-text-editor.props.js +4 -0
- package/dist/modules/rich-text-editor.props.mjs +1 -1
- package/dist/modules/rich-text-editor.types.d.mts +11 -3
- package/dist/modules/rich-text-editor.types.d.ts +11 -3
- package/dist/rich-text-editor.d.mts +10 -1
- package/dist/rich-text-editor.d.ts +10 -1
- package/dist/rich-text-editor.js +699 -116
- package/dist/rich-text-editor.mjs +14 -11
- package/dist/rte-style-provider.mjs +2 -2
- package/dist/rte-variable-suggestion.d.mts +11 -0
- package/dist/rte-variable-suggestion.d.ts +11 -0
- package/dist/rte-variable-suggestion.js +405 -0
- package/dist/rte-variable-suggestion.mjs +10 -0
- package/package.json +12 -12
- /package/dist/{chunk-VYCDVS5I.mjs → chunk-HIHIKPNN.mjs} +0 -0
package/dist/editor-toolbar.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
9
|
var __export = (target, all) => {
|
|
@@ -16,6 +18,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
18
|
}
|
|
17
19
|
return to;
|
|
18
20
|
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
19
29
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
30
|
|
|
21
31
|
// src/editor-toolbar.tsx
|
|
@@ -24,9 +34,9 @@ __export(editor_toolbar_exports, {
|
|
|
24
34
|
EditorToolbar: () => EditorToolbar
|
|
25
35
|
});
|
|
26
36
|
module.exports = __toCommonJS(editor_toolbar_exports);
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
37
|
+
var import_vue15 = require("vue");
|
|
38
|
+
var import_vue16 = require("vue");
|
|
39
|
+
var import_css6 = require("@mekari/pixel3-styled-system/css");
|
|
30
40
|
var import_pixel3_divider = require("@mekari/pixel3-divider");
|
|
31
41
|
var import_pixel3_scrollbar = require("@mekari/pixel3-scrollbar");
|
|
32
42
|
|
|
@@ -446,6 +456,33 @@ var LocationIcon = (0, import_vue2.defineComponent)({
|
|
|
446
456
|
}, null)]);
|
|
447
457
|
}
|
|
448
458
|
});
|
|
459
|
+
var VariableIcon = (0, import_vue2.defineComponent)({
|
|
460
|
+
name: "VariableIcon",
|
|
461
|
+
setup() {
|
|
462
|
+
return () => (0, import_vue.createVNode)("svg", {
|
|
463
|
+
"class": "mp-icon mp-icon--size_sm",
|
|
464
|
+
"data-pixel-component": "MpIcon",
|
|
465
|
+
"data-icon-name": "text-editor-inline-code",
|
|
466
|
+
"viewBox": "0 0 24 24",
|
|
467
|
+
"role": "presentation",
|
|
468
|
+
"fill": "none",
|
|
469
|
+
"focusable": "false",
|
|
470
|
+
"style": "--mp-icon-color: var(--mp-colors-icon-default);"
|
|
471
|
+
}, [(0, import_vue.createVNode)("path", {
|
|
472
|
+
"d": "M15 6L21 12L15 18",
|
|
473
|
+
"stroke": "currentcolor",
|
|
474
|
+
"stroke-width": "1.5",
|
|
475
|
+
"stroke-linecap": "round",
|
|
476
|
+
"stroke-linejoin": "round"
|
|
477
|
+
}, null), (0, import_vue.createVNode)("path", {
|
|
478
|
+
"d": "M9 6L3 12L9 18",
|
|
479
|
+
"stroke": "currentcolor",
|
|
480
|
+
"stroke-width": "1.5",
|
|
481
|
+
"stroke-linecap": "round",
|
|
482
|
+
"stroke-linejoin": "round"
|
|
483
|
+
}, null)]);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
449
486
|
|
|
450
487
|
// src/extensions/heading-extension.tsx
|
|
451
488
|
var HeadingExtention = (0, import_vue4.defineComponent)({
|
|
@@ -687,14 +724,13 @@ var SingleExtention = (0, import_vue8.defineComponent)({
|
|
|
687
724
|
},
|
|
688
725
|
editor: {
|
|
689
726
|
type: Object
|
|
727
|
+
},
|
|
728
|
+
isDisabled: {
|
|
729
|
+
type: Boolean,
|
|
730
|
+
default: false
|
|
690
731
|
}
|
|
691
732
|
},
|
|
692
|
-
setup({
|
|
693
|
-
name,
|
|
694
|
-
tooltipLabel,
|
|
695
|
-
onClick,
|
|
696
|
-
editor
|
|
697
|
-
}) {
|
|
733
|
+
setup(props) {
|
|
698
734
|
const iconMap = {
|
|
699
735
|
bold: (0, import_vue7.createVNode)(BoldIcon, null, null),
|
|
700
736
|
italic: (0, import_vue7.createVNode)(ItalicIcon, null, null),
|
|
@@ -710,16 +746,25 @@ var SingleExtention = (0, import_vue8.defineComponent)({
|
|
|
710
746
|
file: (0, import_vue7.createVNode)(FileIcon, null, null),
|
|
711
747
|
audio: (0, import_vue7.createVNode)(AudioIcon, null, null),
|
|
712
748
|
mention: (0, import_vue7.createVNode)(MentionIcon, null, null),
|
|
749
|
+
variable: (0, import_vue7.createVNode)(VariableIcon, null, null),
|
|
713
750
|
location: (0, import_vue7.createVNode)(LocationIcon, null, null)
|
|
714
751
|
};
|
|
715
|
-
return () =>
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
752
|
+
return () => {
|
|
753
|
+
var _a;
|
|
754
|
+
return (0, import_vue7.withDirectives)((0, import_vue7.createVNode)("button", {
|
|
755
|
+
"class": {
|
|
756
|
+
"is-active": props.name && ((_a = props.editor) == null ? void 0 : _a.isActive(props.name))
|
|
757
|
+
},
|
|
758
|
+
"style": props.isDisabled ? {
|
|
759
|
+
opacity: "0.4",
|
|
760
|
+
cursor: "not-allowed"
|
|
761
|
+
} : void 0,
|
|
762
|
+
"disabled": props.isDisabled,
|
|
763
|
+
"onClick": props.isDisabled ? void 0 : props.onClick
|
|
764
|
+
}, [props.name && iconMap[props.name]]), [[(0, import_vue7.resolveDirective)("tooltip"), {
|
|
765
|
+
label: props.tooltipLabel
|
|
766
|
+
}]]);
|
|
767
|
+
};
|
|
723
768
|
}
|
|
724
769
|
});
|
|
725
770
|
|
|
@@ -1036,10 +1081,313 @@ var LinkExtension = (0, import_vue12.defineComponent)({
|
|
|
1036
1081
|
}
|
|
1037
1082
|
});
|
|
1038
1083
|
|
|
1084
|
+
// src/extensions/variable-extension.ts
|
|
1085
|
+
var import_core2 = require("@tiptap/core");
|
|
1086
|
+
var import_suggestion = __toESM(require("@tiptap/suggestion"));
|
|
1087
|
+
var Variable = import_core2.Node.create({
|
|
1088
|
+
name: "variable",
|
|
1089
|
+
addOptions() {
|
|
1090
|
+
return {
|
|
1091
|
+
HTMLAttributes: {},
|
|
1092
|
+
renderLabel({
|
|
1093
|
+
node
|
|
1094
|
+
}) {
|
|
1095
|
+
var _a;
|
|
1096
|
+
return `{${(_a = node.attrs.label) != null ? _a : node.attrs.id}}`;
|
|
1097
|
+
},
|
|
1098
|
+
suggestion: {}
|
|
1099
|
+
};
|
|
1100
|
+
},
|
|
1101
|
+
group: "inline",
|
|
1102
|
+
inline: true,
|
|
1103
|
+
selectable: false,
|
|
1104
|
+
atom: true,
|
|
1105
|
+
addAttributes() {
|
|
1106
|
+
return {
|
|
1107
|
+
id: {
|
|
1108
|
+
default: null,
|
|
1109
|
+
parseHTML: (element) => element.getAttribute("data-id"),
|
|
1110
|
+
renderHTML: (attributes) => {
|
|
1111
|
+
if (!attributes.id) {
|
|
1112
|
+
return {};
|
|
1113
|
+
}
|
|
1114
|
+
return {
|
|
1115
|
+
"data-id": attributes.id
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
},
|
|
1119
|
+
label: {
|
|
1120
|
+
default: null,
|
|
1121
|
+
parseHTML: (element) => element.getAttribute("data-label"),
|
|
1122
|
+
renderHTML: (attributes) => {
|
|
1123
|
+
if (!attributes.label) {
|
|
1124
|
+
return {};
|
|
1125
|
+
}
|
|
1126
|
+
return {
|
|
1127
|
+
"data-label": attributes.label
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
},
|
|
1131
|
+
category: {
|
|
1132
|
+
default: null,
|
|
1133
|
+
parseHTML: (element) => element.getAttribute("data-category"),
|
|
1134
|
+
renderHTML: (attributes) => {
|
|
1135
|
+
if (!attributes.category) {
|
|
1136
|
+
return {};
|
|
1137
|
+
}
|
|
1138
|
+
return {
|
|
1139
|
+
"data-category": attributes.category
|
|
1140
|
+
};
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
},
|
|
1145
|
+
parseHTML() {
|
|
1146
|
+
return [{
|
|
1147
|
+
tag: `span[data-type="${this.name}"]`
|
|
1148
|
+
}];
|
|
1149
|
+
},
|
|
1150
|
+
renderHTML({
|
|
1151
|
+
node,
|
|
1152
|
+
HTMLAttributes
|
|
1153
|
+
}) {
|
|
1154
|
+
return ["span", (0, import_core2.mergeAttributes)({
|
|
1155
|
+
"data-type": this.name
|
|
1156
|
+
}, this.options.HTMLAttributes, HTMLAttributes), this.options.renderLabel({
|
|
1157
|
+
options: this.options,
|
|
1158
|
+
node
|
|
1159
|
+
})];
|
|
1160
|
+
},
|
|
1161
|
+
renderText({
|
|
1162
|
+
node
|
|
1163
|
+
}) {
|
|
1164
|
+
return this.options.renderLabel({
|
|
1165
|
+
options: this.options,
|
|
1166
|
+
node
|
|
1167
|
+
});
|
|
1168
|
+
},
|
|
1169
|
+
addKeyboardShortcuts() {
|
|
1170
|
+
return {
|
|
1171
|
+
Backspace: () => this.editor.commands.command(({
|
|
1172
|
+
tr,
|
|
1173
|
+
state
|
|
1174
|
+
}) => {
|
|
1175
|
+
let isVariable = false;
|
|
1176
|
+
const {
|
|
1177
|
+
selection
|
|
1178
|
+
} = state;
|
|
1179
|
+
const {
|
|
1180
|
+
empty,
|
|
1181
|
+
anchor
|
|
1182
|
+
} = selection;
|
|
1183
|
+
if (!empty) {
|
|
1184
|
+
return false;
|
|
1185
|
+
}
|
|
1186
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
1187
|
+
if (node.type.name === this.name) {
|
|
1188
|
+
isVariable = true;
|
|
1189
|
+
tr.insertText(this.options.suggestion.char || "", pos, pos + node.nodeSize);
|
|
1190
|
+
return false;
|
|
1191
|
+
}
|
|
1192
|
+
});
|
|
1193
|
+
return isVariable;
|
|
1194
|
+
})
|
|
1195
|
+
};
|
|
1196
|
+
},
|
|
1197
|
+
addProseMirrorPlugins() {
|
|
1198
|
+
return [(0, import_suggestion.default)({
|
|
1199
|
+
editor: this.editor,
|
|
1200
|
+
...this.options.suggestion
|
|
1201
|
+
})];
|
|
1202
|
+
}
|
|
1203
|
+
});
|
|
1204
|
+
|
|
1205
|
+
// src/extensions/variable-list-extension.tsx
|
|
1206
|
+
var import_vue13 = require("vue");
|
|
1207
|
+
var import_vue14 = require("vue");
|
|
1208
|
+
var import_css5 = require("@mekari/pixel3-styled-system/css");
|
|
1209
|
+
var import_pixel3_popover3 = require("@mekari/pixel3-popover");
|
|
1210
|
+
var import_pixel3_text2 = require("@mekari/pixel3-text");
|
|
1211
|
+
var VariableList = (0, import_vue14.defineComponent)({
|
|
1212
|
+
name: "VariableList",
|
|
1213
|
+
props: {
|
|
1214
|
+
items: {
|
|
1215
|
+
type: Array,
|
|
1216
|
+
default: () => []
|
|
1217
|
+
},
|
|
1218
|
+
command: {
|
|
1219
|
+
type: Function,
|
|
1220
|
+
required: true
|
|
1221
|
+
}
|
|
1222
|
+
},
|
|
1223
|
+
setup(props, {
|
|
1224
|
+
expose
|
|
1225
|
+
}) {
|
|
1226
|
+
const selectedIndex = (0, import_vue14.ref)(0);
|
|
1227
|
+
const listRef = (0, import_vue14.ref)(null);
|
|
1228
|
+
const groupedItems = (0, import_vue14.computed)(() => {
|
|
1229
|
+
const groups = {};
|
|
1230
|
+
props.items.forEach((item) => {
|
|
1231
|
+
const category = item.category || "OTHER";
|
|
1232
|
+
if (!groups[category]) {
|
|
1233
|
+
groups[category] = [];
|
|
1234
|
+
}
|
|
1235
|
+
groups[category].push(item);
|
|
1236
|
+
});
|
|
1237
|
+
return Object.entries(groups).map(([category, items]) => ({
|
|
1238
|
+
category,
|
|
1239
|
+
items
|
|
1240
|
+
}));
|
|
1241
|
+
});
|
|
1242
|
+
const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
|
|
1243
|
+
(0, import_vue14.nextTick)(() => {
|
|
1244
|
+
if (!listRef.value)
|
|
1245
|
+
return;
|
|
1246
|
+
const targetItem = listRef.value.querySelector('[data-active="true"], [data-highlight]');
|
|
1247
|
+
if (targetItem) {
|
|
1248
|
+
targetItem.scrollIntoView({
|
|
1249
|
+
block: "nearest"
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
});
|
|
1253
|
+
}, "scrollToFocusedItem");
|
|
1254
|
+
(0, import_vue14.watch)(() => props.items, () => {
|
|
1255
|
+
selectedIndex.value = 0;
|
|
1256
|
+
});
|
|
1257
|
+
const onSelect = /* @__PURE__ */ __name((index) => {
|
|
1258
|
+
const item = props.items[index];
|
|
1259
|
+
if (item) {
|
|
1260
|
+
props.command({
|
|
1261
|
+
...item,
|
|
1262
|
+
label: item.id
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
}, "onSelect");
|
|
1266
|
+
const onKeyDown = /* @__PURE__ */ __name(({
|
|
1267
|
+
event
|
|
1268
|
+
}) => {
|
|
1269
|
+
if (!props.items.length) {
|
|
1270
|
+
return false;
|
|
1271
|
+
}
|
|
1272
|
+
if (event.key === "ArrowUp") {
|
|
1273
|
+
event.preventDefault();
|
|
1274
|
+
const total = props.items.length;
|
|
1275
|
+
selectedIndex.value = (selectedIndex.value + total - 1) % total;
|
|
1276
|
+
scrollToFocusedItem();
|
|
1277
|
+
return true;
|
|
1278
|
+
}
|
|
1279
|
+
if (event.key === "ArrowDown") {
|
|
1280
|
+
event.preventDefault();
|
|
1281
|
+
selectedIndex.value = (selectedIndex.value + 1) % props.items.length;
|
|
1282
|
+
scrollToFocusedItem();
|
|
1283
|
+
return true;
|
|
1284
|
+
}
|
|
1285
|
+
if (event.key === "Enter") {
|
|
1286
|
+
event.preventDefault();
|
|
1287
|
+
onSelect(selectedIndex.value);
|
|
1288
|
+
return true;
|
|
1289
|
+
}
|
|
1290
|
+
return false;
|
|
1291
|
+
}, "onKeyDown");
|
|
1292
|
+
expose({
|
|
1293
|
+
onKeyDown
|
|
1294
|
+
});
|
|
1295
|
+
return () => (0, import_vue13.createVNode)(import_pixel3_popover3.MpPopover, {
|
|
1296
|
+
"id": "popover-rte-variable-list",
|
|
1297
|
+
"is-manual": true,
|
|
1298
|
+
"is-default-open": true,
|
|
1299
|
+
"is-open": true
|
|
1300
|
+
}, {
|
|
1301
|
+
default: () => [(0, import_vue13.createVNode)(import_pixel3_popover3.MpPopoverContent, {
|
|
1302
|
+
"class": (0, import_css5.css)({
|
|
1303
|
+
width: "280px",
|
|
1304
|
+
maxHeight: "284px",
|
|
1305
|
+
overflowY: "auto"
|
|
1306
|
+
})
|
|
1307
|
+
}, {
|
|
1308
|
+
default: () => [(0, import_vue13.createVNode)(import_pixel3_popover3.MpPopoverList, {
|
|
1309
|
+
"ref": (element) => {
|
|
1310
|
+
var _a;
|
|
1311
|
+
if (!element) {
|
|
1312
|
+
listRef.value = null;
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
listRef.value = (_a = element.$el) != null ? _a : element;
|
|
1316
|
+
},
|
|
1317
|
+
"data-pixel-rte": true
|
|
1318
|
+
}, {
|
|
1319
|
+
default: () => [!props.items.length && (0, import_vue13.createVNode)(import_pixel3_text2.MpText, {
|
|
1320
|
+
"color": "text.secondary",
|
|
1321
|
+
"class": (0, import_css5.css)({
|
|
1322
|
+
px: "3",
|
|
1323
|
+
py: "2"
|
|
1324
|
+
})
|
|
1325
|
+
}, {
|
|
1326
|
+
default: () => [(0, import_vue13.createTextVNode)("No result")]
|
|
1327
|
+
}), groupedItems.value.map((group) => {
|
|
1328
|
+
return (0, import_vue13.createVNode)(import_vue13.Fragment, null, [(0, import_vue13.createVNode)(import_pixel3_text2.MpText, {
|
|
1329
|
+
"size": "label-small",
|
|
1330
|
+
"color": "text.secondary",
|
|
1331
|
+
"class": (0, import_css5.css)({
|
|
1332
|
+
px: "3",
|
|
1333
|
+
py: "2",
|
|
1334
|
+
textTransform: "uppercase",
|
|
1335
|
+
textAlign: "left",
|
|
1336
|
+
letterSpacing: "0.05em",
|
|
1337
|
+
display: "block",
|
|
1338
|
+
width: "full"
|
|
1339
|
+
})
|
|
1340
|
+
}, {
|
|
1341
|
+
default: () => [group.category]
|
|
1342
|
+
}), group.items.map((item) => {
|
|
1343
|
+
const itemIndex = props.items.indexOf(item);
|
|
1344
|
+
return (0, import_vue13.createVNode)(import_pixel3_popover3.MpPopoverListItem, {
|
|
1345
|
+
"key": `${item.id}-${itemIndex}`,
|
|
1346
|
+
"onMousedown": (event) => event.preventDefault(),
|
|
1347
|
+
"onMouseenter": () => {
|
|
1348
|
+
selectedIndex.value = itemIndex;
|
|
1349
|
+
},
|
|
1350
|
+
"onClick": () => {
|
|
1351
|
+
onSelect(itemIndex);
|
|
1352
|
+
}
|
|
1353
|
+
}, {
|
|
1354
|
+
default: () => [(0, import_vue13.createVNode)("div", {
|
|
1355
|
+
"class": (0, import_css5.css)({
|
|
1356
|
+
display: "flex",
|
|
1357
|
+
flexDirection: "column",
|
|
1358
|
+
alignItems: "flex-start",
|
|
1359
|
+
minWidth: "0",
|
|
1360
|
+
width: "full",
|
|
1361
|
+
gap: "0.5"
|
|
1362
|
+
})
|
|
1363
|
+
}, [(0, import_vue13.createVNode)(import_pixel3_text2.MpText, {
|
|
1364
|
+
"size": "label",
|
|
1365
|
+
"is-truncated": true
|
|
1366
|
+
}, {
|
|
1367
|
+
default: () => [item.name || "Unknown"]
|
|
1368
|
+
}), (0, import_vue13.createVNode)(import_pixel3_text2.MpText, {
|
|
1369
|
+
"size": "label-small",
|
|
1370
|
+
"color": "text.secondary",
|
|
1371
|
+
"is-truncated": true,
|
|
1372
|
+
"class": (0, import_css5.css)({
|
|
1373
|
+
fontFamily: "mono"
|
|
1374
|
+
})
|
|
1375
|
+
}, {
|
|
1376
|
+
default: () => [`{${item.id}}`]
|
|
1377
|
+
})])]
|
|
1378
|
+
});
|
|
1379
|
+
})]);
|
|
1380
|
+
})]
|
|
1381
|
+
})]
|
|
1382
|
+
})]
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
});
|
|
1386
|
+
|
|
1039
1387
|
// src/editor-toolbar.tsx
|
|
1040
|
-
var EditorToolbar = (0,
|
|
1388
|
+
var EditorToolbar = (0, import_vue16.defineComponent)({
|
|
1041
1389
|
name: "EditorToolbar",
|
|
1042
|
-
emits: ["clickImage", "clickFile", "clickAudio", "clickMention", "clickLocation"],
|
|
1390
|
+
emits: ["clickImage", "clickFile", "clickAudio", "clickMention", "clickVariable", "clickLocation"],
|
|
1043
1391
|
props: {
|
|
1044
1392
|
editor: {
|
|
1045
1393
|
type: Object
|
|
@@ -1054,77 +1402,102 @@ var EditorToolbar = (0, import_vue14.defineComponent)({
|
|
|
1054
1402
|
type: Function
|
|
1055
1403
|
}
|
|
1056
1404
|
},
|
|
1057
|
-
setup({
|
|
1058
|
-
editor,
|
|
1059
|
-
options,
|
|
1060
|
-
validateLink,
|
|
1061
|
-
transformLink
|
|
1062
|
-
}, {
|
|
1405
|
+
setup(props, {
|
|
1063
1406
|
emit
|
|
1064
1407
|
}) {
|
|
1065
|
-
const items = ["heading", "bold", "italic", "underline", "strike", "blockquote", "bulletList", "orderedList", "textColor", "fillColor", "textLink", "align", "undo", "redo", "clear", "image", "file", "audio", "mention", "location"];
|
|
1066
|
-
const
|
|
1408
|
+
const items = ["heading", "bold", "italic", "underline", "strike", "blockquote", "bulletList", "orderedList", "textColor", "fillColor", "textLink", "align", "undo", "redo", "clear", "image", "file", "audio", "mention", "variable", "location"];
|
|
1409
|
+
const getItemOptions = /* @__PURE__ */ __name(() => ({
|
|
1067
1410
|
heading: {
|
|
1068
1411
|
tooltipLabel: "Text style",
|
|
1069
|
-
editor
|
|
1412
|
+
editor: props.editor
|
|
1070
1413
|
},
|
|
1071
1414
|
bold: {
|
|
1072
1415
|
tooltipLabel: "Bold",
|
|
1073
|
-
onClick: () =>
|
|
1416
|
+
onClick: () => {
|
|
1417
|
+
var _a;
|
|
1418
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleBold().run();
|
|
1419
|
+
}
|
|
1074
1420
|
},
|
|
1075
1421
|
italic: {
|
|
1076
1422
|
tooltipLabel: "Italic",
|
|
1077
|
-
onClick: () =>
|
|
1423
|
+
onClick: () => {
|
|
1424
|
+
var _a;
|
|
1425
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleItalic().run();
|
|
1426
|
+
}
|
|
1078
1427
|
},
|
|
1079
1428
|
underline: {
|
|
1080
1429
|
tooltipLabel: "Underline",
|
|
1081
|
-
onClick: () =>
|
|
1430
|
+
onClick: () => {
|
|
1431
|
+
var _a;
|
|
1432
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleUnderline().run();
|
|
1433
|
+
}
|
|
1082
1434
|
},
|
|
1083
1435
|
strike: {
|
|
1084
1436
|
tooltipLabel: "Strike",
|
|
1085
|
-
onClick: () =>
|
|
1437
|
+
onClick: () => {
|
|
1438
|
+
var _a;
|
|
1439
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleStrike().run();
|
|
1440
|
+
}
|
|
1086
1441
|
},
|
|
1087
1442
|
blockquote: {
|
|
1088
1443
|
tooltipLabel: "Blockquote",
|
|
1089
|
-
onClick: () =>
|
|
1444
|
+
onClick: () => {
|
|
1445
|
+
var _a;
|
|
1446
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleBlockquote().run();
|
|
1447
|
+
}
|
|
1090
1448
|
},
|
|
1091
1449
|
bulletList: {
|
|
1092
1450
|
tooltipLabel: "Bullet list",
|
|
1093
|
-
onClick: () =>
|
|
1451
|
+
onClick: () => {
|
|
1452
|
+
var _a;
|
|
1453
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleBulletList().run();
|
|
1454
|
+
}
|
|
1094
1455
|
},
|
|
1095
1456
|
orderedList: {
|
|
1096
1457
|
tooltipLabel: "Number list",
|
|
1097
|
-
onClick: () =>
|
|
1458
|
+
onClick: () => {
|
|
1459
|
+
var _a;
|
|
1460
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().toggleOrderedList().run();
|
|
1461
|
+
}
|
|
1098
1462
|
},
|
|
1099
1463
|
textColor: {
|
|
1100
1464
|
tooltipLabel: "Text color",
|
|
1101
|
-
editor,
|
|
1465
|
+
editor: props.editor,
|
|
1102
1466
|
type: "text"
|
|
1103
1467
|
},
|
|
1104
1468
|
fillColor: {
|
|
1105
1469
|
tooltipLabel: "Fill color",
|
|
1106
|
-
editor,
|
|
1470
|
+
editor: props.editor,
|
|
1107
1471
|
type: "fill"
|
|
1108
1472
|
},
|
|
1109
1473
|
textLink: {
|
|
1110
1474
|
tooltipLabel: "Insert link",
|
|
1111
|
-
editor
|
|
1475
|
+
editor: props.editor
|
|
1112
1476
|
},
|
|
1113
1477
|
align: {
|
|
1114
1478
|
tooltipLabel: "Text alignment",
|
|
1115
|
-
editor
|
|
1479
|
+
editor: props.editor
|
|
1116
1480
|
},
|
|
1117
1481
|
undo: {
|
|
1118
1482
|
tooltipLabel: "Undo",
|
|
1119
|
-
onClick: () =>
|
|
1483
|
+
onClick: () => {
|
|
1484
|
+
var _a;
|
|
1485
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().undo().run();
|
|
1486
|
+
}
|
|
1120
1487
|
},
|
|
1121
1488
|
redo: {
|
|
1122
1489
|
tooltipLabel: "Redo",
|
|
1123
|
-
onClick: () =>
|
|
1490
|
+
onClick: () => {
|
|
1491
|
+
var _a;
|
|
1492
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().redo().run();
|
|
1493
|
+
}
|
|
1124
1494
|
},
|
|
1125
1495
|
clear: {
|
|
1126
1496
|
tooltipLabel: "Reset format",
|
|
1127
|
-
onClick: () =>
|
|
1497
|
+
onClick: () => {
|
|
1498
|
+
var _a;
|
|
1499
|
+
return ((_a = props.editor) == null ? void 0 : _a.chain()).focus().unsetAllMarks().run();
|
|
1500
|
+
}
|
|
1128
1501
|
},
|
|
1129
1502
|
image: {
|
|
1130
1503
|
tooltipLabel: "Add image",
|
|
@@ -1140,18 +1513,29 @@ var EditorToolbar = (0, import_vue14.defineComponent)({
|
|
|
1140
1513
|
},
|
|
1141
1514
|
mention: {
|
|
1142
1515
|
tooltipLabel: "Mention",
|
|
1143
|
-
editor,
|
|
1516
|
+
editor: props.editor,
|
|
1144
1517
|
onClick: () => {
|
|
1518
|
+
var _a;
|
|
1145
1519
|
;
|
|
1146
|
-
(editor == null ? void 0 :
|
|
1520
|
+
((_a = props.editor) == null ? void 0 : _a.chain()).focus().insertContent("@").run();
|
|
1147
1521
|
emit("clickMention");
|
|
1148
1522
|
}
|
|
1149
1523
|
},
|
|
1524
|
+
variable: {
|
|
1525
|
+
tooltipLabel: "Insert variable",
|
|
1526
|
+
editor: props.editor,
|
|
1527
|
+
onClick: () => {
|
|
1528
|
+
var _a;
|
|
1529
|
+
;
|
|
1530
|
+
((_a = props.editor) == null ? void 0 : _a.chain()).focus().insertContent("{").run();
|
|
1531
|
+
emit("clickVariable");
|
|
1532
|
+
}
|
|
1533
|
+
},
|
|
1150
1534
|
location: {
|
|
1151
1535
|
tooltipLabel: "Add location",
|
|
1152
1536
|
onClick: () => emit("clickLocation")
|
|
1153
1537
|
}
|
|
1154
|
-
};
|
|
1538
|
+
}), "getItemOptions");
|
|
1155
1539
|
const getResolvedItem = /* @__PURE__ */ __name((option) => {
|
|
1156
1540
|
if (typeof option === "string") {
|
|
1157
1541
|
return {
|
|
@@ -1160,56 +1544,60 @@ var EditorToolbar = (0, import_vue14.defineComponent)({
|
|
|
1160
1544
|
}
|
|
1161
1545
|
return {
|
|
1162
1546
|
item: option.value,
|
|
1163
|
-
tooltip: option.tooltip
|
|
1547
|
+
tooltip: option.tooltip,
|
|
1548
|
+
disabled: option.disabled
|
|
1164
1549
|
};
|
|
1165
1550
|
}, "getResolvedItem");
|
|
1166
1551
|
const renderExtension = /* @__PURE__ */ __name((option) => {
|
|
1167
1552
|
const {
|
|
1168
1553
|
item,
|
|
1169
|
-
tooltip
|
|
1554
|
+
tooltip,
|
|
1555
|
+
disabled
|
|
1170
1556
|
} = getResolvedItem(option);
|
|
1171
1557
|
if (!items.includes(item))
|
|
1172
1558
|
return null;
|
|
1173
1559
|
const resolvedItem = item;
|
|
1560
|
+
const itemOptions = getItemOptions();
|
|
1174
1561
|
const resolvedOptions = itemOptions[resolvedItem];
|
|
1175
1562
|
if (!resolvedOptions)
|
|
1176
1563
|
return null;
|
|
1177
1564
|
const tooltipLabel = tooltip || resolvedOptions.tooltipLabel;
|
|
1178
1565
|
switch (resolvedItem) {
|
|
1179
1566
|
case "heading":
|
|
1180
|
-
return (0,
|
|
1567
|
+
return (0, import_vue15.createVNode)(HeadingExtention, {
|
|
1181
1568
|
"tooltipLabel": tooltipLabel,
|
|
1182
|
-
"editor": editor
|
|
1569
|
+
"editor": props.editor
|
|
1183
1570
|
}, null);
|
|
1184
1571
|
case "align":
|
|
1185
|
-
return (0,
|
|
1572
|
+
return (0, import_vue15.createVNode)(AlignExtention, {
|
|
1186
1573
|
"tooltipLabel": tooltipLabel,
|
|
1187
|
-
"editor": editor
|
|
1574
|
+
"editor": props.editor
|
|
1188
1575
|
}, null);
|
|
1189
1576
|
case "textColor":
|
|
1190
1577
|
case "fillColor":
|
|
1191
|
-
return (0,
|
|
1578
|
+
return (0, import_vue15.createVNode)(ColorExtension, {
|
|
1192
1579
|
"tooltipLabel": tooltipLabel,
|
|
1193
|
-
"editor": editor,
|
|
1580
|
+
"editor": props.editor,
|
|
1194
1581
|
"type": resolvedOptions.type
|
|
1195
1582
|
}, null);
|
|
1196
1583
|
case "textLink":
|
|
1197
|
-
return (0,
|
|
1584
|
+
return (0, import_vue15.createVNode)(LinkExtension, {
|
|
1198
1585
|
"tooltipLabel": tooltipLabel,
|
|
1199
|
-
"editor": editor,
|
|
1200
|
-
"validateLink": validateLink,
|
|
1201
|
-
"transformLink": transformLink
|
|
1586
|
+
"editor": props.editor,
|
|
1587
|
+
"validateLink": props.validateLink,
|
|
1588
|
+
"transformLink": props.transformLink
|
|
1202
1589
|
}, null);
|
|
1203
1590
|
default:
|
|
1204
|
-
return (0,
|
|
1591
|
+
return (0, import_vue15.createVNode)(SingleExtention, {
|
|
1205
1592
|
"name": resolvedItem,
|
|
1206
1593
|
"tooltipLabel": tooltipLabel,
|
|
1207
1594
|
"onClick": resolvedOptions.onClick,
|
|
1208
|
-
"editor": editor
|
|
1595
|
+
"editor": props.editor,
|
|
1596
|
+
"isDisabled": disabled
|
|
1209
1597
|
}, null);
|
|
1210
1598
|
}
|
|
1211
1599
|
}, "renderExtension");
|
|
1212
|
-
return () => (0,
|
|
1600
|
+
return () => (0, import_vue15.createVNode)(import_pixel3_scrollbar.MpScrollbar, {
|
|
1213
1601
|
"options": {
|
|
1214
1602
|
overflow: {
|
|
1215
1603
|
y: "hide",
|
|
@@ -1217,21 +1605,27 @@ var EditorToolbar = (0, import_vue14.defineComponent)({
|
|
|
1217
1605
|
}
|
|
1218
1606
|
}
|
|
1219
1607
|
}, {
|
|
1220
|
-
default: () =>
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1608
|
+
default: () => {
|
|
1609
|
+
var _a;
|
|
1610
|
+
return [(0, import_vue15.createVNode)("div", {
|
|
1611
|
+
"class": (0, import_css6.css)({
|
|
1612
|
+
display: "flex",
|
|
1613
|
+
alignItems: "stretch",
|
|
1614
|
+
gap: "1"
|
|
1615
|
+
})
|
|
1616
|
+
}, [(_a = props.options) == null ? void 0 : _a.map((option, index) => {
|
|
1617
|
+
var _a2, _b;
|
|
1618
|
+
return (0, import_vue15.createVNode)(import_vue15.Fragment, null, [option.map((item) => {
|
|
1619
|
+
const resolvedItem = typeof item === "string" ? item : item.value;
|
|
1620
|
+
if (items.includes(resolvedItem)) {
|
|
1621
|
+
return renderExtension(item);
|
|
1622
|
+
}
|
|
1623
|
+
}), index !== ((_b = (_a2 = props.options) == null ? void 0 : _a2.length) != null ? _b : 0) - 1 && (0, import_vue15.createVNode)(import_pixel3_divider.MpDivider, {
|
|
1624
|
+
"id": "divider-toolbar",
|
|
1625
|
+
"orientation": "vertical"
|
|
1626
|
+
}, null)]);
|
|
1627
|
+
})])];
|
|
1628
|
+
}
|
|
1235
1629
|
});
|
|
1236
1630
|
}
|
|
1237
1631
|
});
|