@mekari/pixel3-rich-text-editor 0.1.2 → 0.1.3-dev.0
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-25RKPG44.mjs → chunk-47IOAHWN.mjs} +4 -2
- 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-Q7QLZISF.mjs → chunk-IFRJVX2K.mjs} +29 -1
- package/dist/{chunk-YE6FEVD4.mjs → chunk-UD5PDCGC.mjs} +18 -9
- 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/{chunk-XNM3YX37.mjs → chunk-ZYSEHV5N.mjs} +13 -3
- package/dist/editor-toolbar.d.mts +2 -1
- package/dist/editor-toolbar.d.ts +2 -1
- package/dist/editor-toolbar.js +366 -16
- 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 +347 -2
- 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 +1 -1
- package/dist/extensions/single-extension.d.ts +1 -1
- package/dist/extensions/single-extension.js +28 -0
- 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 +596 -57
- 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 +10 -3
- package/dist/modules/rich-text-editor.types.d.ts +10 -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 +596 -57
- 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 +7 -7
- /package/dist/{chunk-VYCDVS5I.mjs → chunk-HIHIKPNN.mjs} +0 -0
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EditorToolbar
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UD5PDCGC.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Variable
|
|
6
|
+
} from "./chunk-ENKUUZPM.mjs";
|
|
4
7
|
import {
|
|
5
8
|
MpRTEStyleProvider
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-AIWY3FHJ.mjs";
|
|
7
10
|
import {
|
|
8
11
|
useRichTextEditor
|
|
9
12
|
} from "./chunk-ZRAXSVO5.mjs";
|
|
10
13
|
import {
|
|
11
14
|
richTextEditorEmits,
|
|
12
15
|
richTextEditorProps
|
|
13
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6O4HSL2C.mjs";
|
|
14
17
|
import {
|
|
15
18
|
createMentionSuggestion
|
|
16
19
|
} from "./chunk-4KJOYLJI.mjs";
|
|
20
|
+
import {
|
|
21
|
+
createVariableSuggestion
|
|
22
|
+
} from "./chunk-BWRU2WZN.mjs";
|
|
17
23
|
import {
|
|
18
24
|
__name
|
|
19
25
|
} from "./chunk-QZ7VFGWC.mjs";
|
|
@@ -89,6 +95,9 @@ var MpRichTextEditor = defineComponent({
|
|
|
89
95
|
}),
|
|
90
96
|
...props.suggestions && props.suggestions.length > 0 ? [Mention.configure({
|
|
91
97
|
suggestion: createMentionSuggestion(() => props.suggestions || [])
|
|
98
|
+
})] : [],
|
|
99
|
+
...props.variables && props.variables.length > 0 ? [Variable.configure({
|
|
100
|
+
suggestion: createVariableSuggestion(() => props.variables || [])
|
|
92
101
|
})] : []
|
|
93
102
|
],
|
|
94
103
|
onFocus({
|
|
@@ -119,6 +128,7 @@ var MpRichTextEditor = defineComponent({
|
|
|
119
128
|
onClickFile: () => onClickToolbar("file"),
|
|
120
129
|
onClickAudio: () => onClickToolbar("audio"),
|
|
121
130
|
onClickMention: () => onClickToolbar("mention"),
|
|
131
|
+
onClickVariable: () => onClickToolbar("variable"),
|
|
122
132
|
onClickLocation: () => onClickToolbar("location")
|
|
123
133
|
};
|
|
124
134
|
return () => {
|
|
@@ -21,7 +21,7 @@ declare const EditorToolbar: vue.DefineComponent<{
|
|
|
21
21
|
transformLink: {
|
|
22
22
|
type: PropType<(url: string) => string>;
|
|
23
23
|
};
|
|
24
|
-
}, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickLocation")[], "clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickLocation", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
24
|
+
}, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickVariable" | "clickLocation")[], "clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickVariable" | "clickLocation", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
25
25
|
editor: {
|
|
26
26
|
type: PropType<Editor>;
|
|
27
27
|
};
|
|
@@ -42,6 +42,7 @@ declare const EditorToolbar: vue.DefineComponent<{
|
|
|
42
42
|
onClickFile?: ((...args: any[]) => any) | undefined;
|
|
43
43
|
onClickAudio?: ((...args: any[]) => any) | undefined;
|
|
44
44
|
onClickMention?: ((...args: any[]) => any) | undefined;
|
|
45
|
+
onClickVariable?: ((...args: any[]) => any) | undefined;
|
|
45
46
|
onClickLocation?: ((...args: any[]) => any) | undefined;
|
|
46
47
|
}, {}, {}>;
|
|
47
48
|
|
package/dist/editor-toolbar.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare const EditorToolbar: vue.DefineComponent<{
|
|
|
21
21
|
transformLink: {
|
|
22
22
|
type: PropType<(url: string) => string>;
|
|
23
23
|
};
|
|
24
|
-
}, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickLocation")[], "clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickLocation", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
24
|
+
}, () => vue_jsx_runtime.JSX.Element, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, ("clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickVariable" | "clickLocation")[], "clickImage" | "clickFile" | "clickAudio" | "clickMention" | "clickVariable" | "clickLocation", vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
25
25
|
editor: {
|
|
26
26
|
type: PropType<Editor>;
|
|
27
27
|
};
|
|
@@ -42,6 +42,7 @@ declare const EditorToolbar: vue.DefineComponent<{
|
|
|
42
42
|
onClickFile?: ((...args: any[]) => any) | undefined;
|
|
43
43
|
onClickAudio?: ((...args: any[]) => any) | undefined;
|
|
44
44
|
onClickMention?: ((...args: any[]) => any) | undefined;
|
|
45
|
+
onClickVariable?: ((...args: any[]) => any) | undefined;
|
|
45
46
|
onClickLocation?: ((...args: any[]) => any) | undefined;
|
|
46
47
|
}, {}, {}>;
|
|
47
48
|
|
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)({
|
|
@@ -710,6 +747,7 @@ var SingleExtention = (0, import_vue8.defineComponent)({
|
|
|
710
747
|
file: (0, import_vue7.createVNode)(FileIcon, null, null),
|
|
711
748
|
audio: (0, import_vue7.createVNode)(AudioIcon, null, null),
|
|
712
749
|
mention: (0, import_vue7.createVNode)(MentionIcon, null, null),
|
|
750
|
+
variable: (0, import_vue7.createVNode)(VariableIcon, null, null),
|
|
713
751
|
location: (0, import_vue7.createVNode)(LocationIcon, null, null)
|
|
714
752
|
};
|
|
715
753
|
return () => (0, import_vue7.withDirectives)((0, import_vue7.createVNode)("button", {
|
|
@@ -1036,10 +1074,313 @@ var LinkExtension = (0, import_vue12.defineComponent)({
|
|
|
1036
1074
|
}
|
|
1037
1075
|
});
|
|
1038
1076
|
|
|
1077
|
+
// src/extensions/variable-extension.ts
|
|
1078
|
+
var import_core2 = require("@tiptap/core");
|
|
1079
|
+
var import_suggestion = __toESM(require("@tiptap/suggestion"));
|
|
1080
|
+
var Variable = import_core2.Node.create({
|
|
1081
|
+
name: "variable",
|
|
1082
|
+
addOptions() {
|
|
1083
|
+
return {
|
|
1084
|
+
HTMLAttributes: {},
|
|
1085
|
+
renderLabel({
|
|
1086
|
+
node
|
|
1087
|
+
}) {
|
|
1088
|
+
var _a;
|
|
1089
|
+
return `{${(_a = node.attrs.label) != null ? _a : node.attrs.id}}`;
|
|
1090
|
+
},
|
|
1091
|
+
suggestion: {}
|
|
1092
|
+
};
|
|
1093
|
+
},
|
|
1094
|
+
group: "inline",
|
|
1095
|
+
inline: true,
|
|
1096
|
+
selectable: false,
|
|
1097
|
+
atom: true,
|
|
1098
|
+
addAttributes() {
|
|
1099
|
+
return {
|
|
1100
|
+
id: {
|
|
1101
|
+
default: null,
|
|
1102
|
+
parseHTML: (element) => element.getAttribute("data-id"),
|
|
1103
|
+
renderHTML: (attributes) => {
|
|
1104
|
+
if (!attributes.id) {
|
|
1105
|
+
return {};
|
|
1106
|
+
}
|
|
1107
|
+
return {
|
|
1108
|
+
"data-id": attributes.id
|
|
1109
|
+
};
|
|
1110
|
+
}
|
|
1111
|
+
},
|
|
1112
|
+
label: {
|
|
1113
|
+
default: null,
|
|
1114
|
+
parseHTML: (element) => element.getAttribute("data-label"),
|
|
1115
|
+
renderHTML: (attributes) => {
|
|
1116
|
+
if (!attributes.label) {
|
|
1117
|
+
return {};
|
|
1118
|
+
}
|
|
1119
|
+
return {
|
|
1120
|
+
"data-label": attributes.label
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
},
|
|
1124
|
+
category: {
|
|
1125
|
+
default: null,
|
|
1126
|
+
parseHTML: (element) => element.getAttribute("data-category"),
|
|
1127
|
+
renderHTML: (attributes) => {
|
|
1128
|
+
if (!attributes.category) {
|
|
1129
|
+
return {};
|
|
1130
|
+
}
|
|
1131
|
+
return {
|
|
1132
|
+
"data-category": attributes.category
|
|
1133
|
+
};
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
},
|
|
1138
|
+
parseHTML() {
|
|
1139
|
+
return [{
|
|
1140
|
+
tag: `span[data-type="${this.name}"]`
|
|
1141
|
+
}];
|
|
1142
|
+
},
|
|
1143
|
+
renderHTML({
|
|
1144
|
+
node,
|
|
1145
|
+
HTMLAttributes
|
|
1146
|
+
}) {
|
|
1147
|
+
return ["span", (0, import_core2.mergeAttributes)({
|
|
1148
|
+
"data-type": this.name
|
|
1149
|
+
}, this.options.HTMLAttributes, HTMLAttributes), this.options.renderLabel({
|
|
1150
|
+
options: this.options,
|
|
1151
|
+
node
|
|
1152
|
+
})];
|
|
1153
|
+
},
|
|
1154
|
+
renderText({
|
|
1155
|
+
node
|
|
1156
|
+
}) {
|
|
1157
|
+
return this.options.renderLabel({
|
|
1158
|
+
options: this.options,
|
|
1159
|
+
node
|
|
1160
|
+
});
|
|
1161
|
+
},
|
|
1162
|
+
addKeyboardShortcuts() {
|
|
1163
|
+
return {
|
|
1164
|
+
Backspace: () => this.editor.commands.command(({
|
|
1165
|
+
tr,
|
|
1166
|
+
state
|
|
1167
|
+
}) => {
|
|
1168
|
+
let isVariable = false;
|
|
1169
|
+
const {
|
|
1170
|
+
selection
|
|
1171
|
+
} = state;
|
|
1172
|
+
const {
|
|
1173
|
+
empty,
|
|
1174
|
+
anchor
|
|
1175
|
+
} = selection;
|
|
1176
|
+
if (!empty) {
|
|
1177
|
+
return false;
|
|
1178
|
+
}
|
|
1179
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
1180
|
+
if (node.type.name === this.name) {
|
|
1181
|
+
isVariable = true;
|
|
1182
|
+
tr.insertText(this.options.suggestion.char || "", pos, pos + node.nodeSize);
|
|
1183
|
+
return false;
|
|
1184
|
+
}
|
|
1185
|
+
});
|
|
1186
|
+
return isVariable;
|
|
1187
|
+
})
|
|
1188
|
+
};
|
|
1189
|
+
},
|
|
1190
|
+
addProseMirrorPlugins() {
|
|
1191
|
+
return [(0, import_suggestion.default)({
|
|
1192
|
+
editor: this.editor,
|
|
1193
|
+
...this.options.suggestion
|
|
1194
|
+
})];
|
|
1195
|
+
}
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1198
|
+
// src/extensions/variable-list-extension.tsx
|
|
1199
|
+
var import_vue13 = require("vue");
|
|
1200
|
+
var import_vue14 = require("vue");
|
|
1201
|
+
var import_css5 = require("@mekari/pixel3-styled-system/css");
|
|
1202
|
+
var import_pixel3_popover3 = require("@mekari/pixel3-popover");
|
|
1203
|
+
var import_pixel3_text2 = require("@mekari/pixel3-text");
|
|
1204
|
+
var VariableList = (0, import_vue14.defineComponent)({
|
|
1205
|
+
name: "VariableList",
|
|
1206
|
+
props: {
|
|
1207
|
+
items: {
|
|
1208
|
+
type: Array,
|
|
1209
|
+
default: () => []
|
|
1210
|
+
},
|
|
1211
|
+
command: {
|
|
1212
|
+
type: Function,
|
|
1213
|
+
required: true
|
|
1214
|
+
}
|
|
1215
|
+
},
|
|
1216
|
+
setup(props, {
|
|
1217
|
+
expose
|
|
1218
|
+
}) {
|
|
1219
|
+
const selectedIndex = (0, import_vue14.ref)(0);
|
|
1220
|
+
const listRef = (0, import_vue14.ref)(null);
|
|
1221
|
+
const groupedItems = (0, import_vue14.computed)(() => {
|
|
1222
|
+
const groups = {};
|
|
1223
|
+
props.items.forEach((item) => {
|
|
1224
|
+
const category = item.category || "OTHER";
|
|
1225
|
+
if (!groups[category]) {
|
|
1226
|
+
groups[category] = [];
|
|
1227
|
+
}
|
|
1228
|
+
groups[category].push(item);
|
|
1229
|
+
});
|
|
1230
|
+
return Object.entries(groups).map(([category, items]) => ({
|
|
1231
|
+
category,
|
|
1232
|
+
items
|
|
1233
|
+
}));
|
|
1234
|
+
});
|
|
1235
|
+
const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
|
|
1236
|
+
(0, import_vue14.nextTick)(() => {
|
|
1237
|
+
if (!listRef.value)
|
|
1238
|
+
return;
|
|
1239
|
+
const targetItem = listRef.value.querySelector('[data-active="true"], [data-highlight]');
|
|
1240
|
+
if (targetItem) {
|
|
1241
|
+
targetItem.scrollIntoView({
|
|
1242
|
+
block: "nearest"
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}, "scrollToFocusedItem");
|
|
1247
|
+
(0, import_vue14.watch)(() => props.items, () => {
|
|
1248
|
+
selectedIndex.value = 0;
|
|
1249
|
+
});
|
|
1250
|
+
const onSelect = /* @__PURE__ */ __name((index) => {
|
|
1251
|
+
const item = props.items[index];
|
|
1252
|
+
if (item) {
|
|
1253
|
+
props.command({
|
|
1254
|
+
...item,
|
|
1255
|
+
label: item.id
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
}, "onSelect");
|
|
1259
|
+
const onKeyDown = /* @__PURE__ */ __name(({
|
|
1260
|
+
event
|
|
1261
|
+
}) => {
|
|
1262
|
+
if (!props.items.length) {
|
|
1263
|
+
return false;
|
|
1264
|
+
}
|
|
1265
|
+
if (event.key === "ArrowUp") {
|
|
1266
|
+
event.preventDefault();
|
|
1267
|
+
const total = props.items.length;
|
|
1268
|
+
selectedIndex.value = (selectedIndex.value + total - 1) % total;
|
|
1269
|
+
scrollToFocusedItem();
|
|
1270
|
+
return true;
|
|
1271
|
+
}
|
|
1272
|
+
if (event.key === "ArrowDown") {
|
|
1273
|
+
event.preventDefault();
|
|
1274
|
+
selectedIndex.value = (selectedIndex.value + 1) % props.items.length;
|
|
1275
|
+
scrollToFocusedItem();
|
|
1276
|
+
return true;
|
|
1277
|
+
}
|
|
1278
|
+
if (event.key === "Enter") {
|
|
1279
|
+
event.preventDefault();
|
|
1280
|
+
onSelect(selectedIndex.value);
|
|
1281
|
+
return true;
|
|
1282
|
+
}
|
|
1283
|
+
return false;
|
|
1284
|
+
}, "onKeyDown");
|
|
1285
|
+
expose({
|
|
1286
|
+
onKeyDown
|
|
1287
|
+
});
|
|
1288
|
+
return () => (0, import_vue13.createVNode)(import_pixel3_popover3.MpPopover, {
|
|
1289
|
+
"id": "popover-rte-variable-list",
|
|
1290
|
+
"is-manual": true,
|
|
1291
|
+
"is-default-open": true,
|
|
1292
|
+
"is-open": true
|
|
1293
|
+
}, {
|
|
1294
|
+
default: () => [(0, import_vue13.createVNode)(import_pixel3_popover3.MpPopoverContent, {
|
|
1295
|
+
"class": (0, import_css5.css)({
|
|
1296
|
+
width: "280px",
|
|
1297
|
+
maxHeight: "284px",
|
|
1298
|
+
overflowY: "auto"
|
|
1299
|
+
})
|
|
1300
|
+
}, {
|
|
1301
|
+
default: () => [(0, import_vue13.createVNode)(import_pixel3_popover3.MpPopoverList, {
|
|
1302
|
+
"ref": (element) => {
|
|
1303
|
+
var _a;
|
|
1304
|
+
if (!element) {
|
|
1305
|
+
listRef.value = null;
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
listRef.value = (_a = element.$el) != null ? _a : element;
|
|
1309
|
+
},
|
|
1310
|
+
"data-pixel-rte": true
|
|
1311
|
+
}, {
|
|
1312
|
+
default: () => [!props.items.length && (0, import_vue13.createVNode)(import_pixel3_text2.MpText, {
|
|
1313
|
+
"color": "text.secondary",
|
|
1314
|
+
"class": (0, import_css5.css)({
|
|
1315
|
+
px: "3",
|
|
1316
|
+
py: "2"
|
|
1317
|
+
})
|
|
1318
|
+
}, {
|
|
1319
|
+
default: () => [(0, import_vue13.createTextVNode)("No result")]
|
|
1320
|
+
}), groupedItems.value.map((group) => {
|
|
1321
|
+
return (0, import_vue13.createVNode)(import_vue13.Fragment, null, [(0, import_vue13.createVNode)(import_pixel3_text2.MpText, {
|
|
1322
|
+
"size": "label-small",
|
|
1323
|
+
"color": "text.secondary",
|
|
1324
|
+
"class": (0, import_css5.css)({
|
|
1325
|
+
px: "3",
|
|
1326
|
+
py: "2",
|
|
1327
|
+
textTransform: "uppercase",
|
|
1328
|
+
textAlign: "left",
|
|
1329
|
+
letterSpacing: "0.05em",
|
|
1330
|
+
display: "block",
|
|
1331
|
+
width: "full"
|
|
1332
|
+
})
|
|
1333
|
+
}, {
|
|
1334
|
+
default: () => [group.category]
|
|
1335
|
+
}), group.items.map((item) => {
|
|
1336
|
+
const itemIndex = props.items.indexOf(item);
|
|
1337
|
+
return (0, import_vue13.createVNode)(import_pixel3_popover3.MpPopoverListItem, {
|
|
1338
|
+
"key": `${item.id}-${itemIndex}`,
|
|
1339
|
+
"onMousedown": (event) => event.preventDefault(),
|
|
1340
|
+
"onMouseenter": () => {
|
|
1341
|
+
selectedIndex.value = itemIndex;
|
|
1342
|
+
},
|
|
1343
|
+
"onClick": () => {
|
|
1344
|
+
onSelect(itemIndex);
|
|
1345
|
+
}
|
|
1346
|
+
}, {
|
|
1347
|
+
default: () => [(0, import_vue13.createVNode)("div", {
|
|
1348
|
+
"class": (0, import_css5.css)({
|
|
1349
|
+
display: "flex",
|
|
1350
|
+
flexDirection: "column",
|
|
1351
|
+
alignItems: "flex-start",
|
|
1352
|
+
minWidth: "0",
|
|
1353
|
+
width: "full",
|
|
1354
|
+
gap: "0.5"
|
|
1355
|
+
})
|
|
1356
|
+
}, [(0, import_vue13.createVNode)(import_pixel3_text2.MpText, {
|
|
1357
|
+
"size": "label",
|
|
1358
|
+
"is-truncated": true
|
|
1359
|
+
}, {
|
|
1360
|
+
default: () => [item.name || "Unknown"]
|
|
1361
|
+
}), (0, import_vue13.createVNode)(import_pixel3_text2.MpText, {
|
|
1362
|
+
"size": "label-small",
|
|
1363
|
+
"color": "text.secondary",
|
|
1364
|
+
"is-truncated": true,
|
|
1365
|
+
"class": (0, import_css5.css)({
|
|
1366
|
+
fontFamily: "mono"
|
|
1367
|
+
})
|
|
1368
|
+
}, {
|
|
1369
|
+
default: () => [`{${item.id}}`]
|
|
1370
|
+
})])]
|
|
1371
|
+
});
|
|
1372
|
+
})]);
|
|
1373
|
+
})]
|
|
1374
|
+
})]
|
|
1375
|
+
})]
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
});
|
|
1379
|
+
|
|
1039
1380
|
// src/editor-toolbar.tsx
|
|
1040
|
-
var EditorToolbar = (0,
|
|
1381
|
+
var EditorToolbar = (0, import_vue16.defineComponent)({
|
|
1041
1382
|
name: "EditorToolbar",
|
|
1042
|
-
emits: ["clickImage", "clickFile", "clickAudio", "clickMention", "clickLocation"],
|
|
1383
|
+
emits: ["clickImage", "clickFile", "clickAudio", "clickMention", "clickVariable", "clickLocation"],
|
|
1043
1384
|
props: {
|
|
1044
1385
|
editor: {
|
|
1045
1386
|
type: Object
|
|
@@ -1062,7 +1403,7 @@ var EditorToolbar = (0, import_vue14.defineComponent)({
|
|
|
1062
1403
|
}, {
|
|
1063
1404
|
emit
|
|
1064
1405
|
}) {
|
|
1065
|
-
const items = ["heading", "bold", "italic", "underline", "strike", "blockquote", "bulletList", "orderedList", "textColor", "fillColor", "textLink", "align", "undo", "redo", "clear", "image", "file", "audio", "mention", "location"];
|
|
1406
|
+
const items = ["heading", "bold", "italic", "underline", "strike", "blockquote", "bulletList", "orderedList", "textColor", "fillColor", "textLink", "align", "undo", "redo", "clear", "image", "file", "audio", "mention", "variable", "location"];
|
|
1066
1407
|
const itemOptions = {
|
|
1067
1408
|
heading: {
|
|
1068
1409
|
tooltipLabel: "Text style",
|
|
@@ -1147,6 +1488,15 @@ var EditorToolbar = (0, import_vue14.defineComponent)({
|
|
|
1147
1488
|
emit("clickMention");
|
|
1148
1489
|
}
|
|
1149
1490
|
},
|
|
1491
|
+
variable: {
|
|
1492
|
+
tooltipLabel: "Insert variable",
|
|
1493
|
+
editor,
|
|
1494
|
+
onClick: () => {
|
|
1495
|
+
;
|
|
1496
|
+
(editor == null ? void 0 : editor.chain()).focus().insertContent("{").run();
|
|
1497
|
+
emit("clickVariable");
|
|
1498
|
+
}
|
|
1499
|
+
},
|
|
1150
1500
|
location: {
|
|
1151
1501
|
tooltipLabel: "Add location",
|
|
1152
1502
|
onClick: () => emit("clickLocation")
|
|
@@ -1177,31 +1527,31 @@ var EditorToolbar = (0, import_vue14.defineComponent)({
|
|
|
1177
1527
|
const tooltipLabel = tooltip || resolvedOptions.tooltipLabel;
|
|
1178
1528
|
switch (resolvedItem) {
|
|
1179
1529
|
case "heading":
|
|
1180
|
-
return (0,
|
|
1530
|
+
return (0, import_vue15.createVNode)(HeadingExtention, {
|
|
1181
1531
|
"tooltipLabel": tooltipLabel,
|
|
1182
1532
|
"editor": editor
|
|
1183
1533
|
}, null);
|
|
1184
1534
|
case "align":
|
|
1185
|
-
return (0,
|
|
1535
|
+
return (0, import_vue15.createVNode)(AlignExtention, {
|
|
1186
1536
|
"tooltipLabel": tooltipLabel,
|
|
1187
1537
|
"editor": editor
|
|
1188
1538
|
}, null);
|
|
1189
1539
|
case "textColor":
|
|
1190
1540
|
case "fillColor":
|
|
1191
|
-
return (0,
|
|
1541
|
+
return (0, import_vue15.createVNode)(ColorExtension, {
|
|
1192
1542
|
"tooltipLabel": tooltipLabel,
|
|
1193
1543
|
"editor": editor,
|
|
1194
1544
|
"type": resolvedOptions.type
|
|
1195
1545
|
}, null);
|
|
1196
1546
|
case "textLink":
|
|
1197
|
-
return (0,
|
|
1547
|
+
return (0, import_vue15.createVNode)(LinkExtension, {
|
|
1198
1548
|
"tooltipLabel": tooltipLabel,
|
|
1199
1549
|
"editor": editor,
|
|
1200
1550
|
"validateLink": validateLink,
|
|
1201
1551
|
"transformLink": transformLink
|
|
1202
1552
|
}, null);
|
|
1203
1553
|
default:
|
|
1204
|
-
return (0,
|
|
1554
|
+
return (0, import_vue15.createVNode)(SingleExtention, {
|
|
1205
1555
|
"name": resolvedItem,
|
|
1206
1556
|
"tooltipLabel": tooltipLabel,
|
|
1207
1557
|
"onClick": resolvedOptions.onClick,
|
|
@@ -1209,7 +1559,7 @@ var EditorToolbar = (0, import_vue14.defineComponent)({
|
|
|
1209
1559
|
}, null);
|
|
1210
1560
|
}
|
|
1211
1561
|
}, "renderExtension");
|
|
1212
|
-
return () => (0,
|
|
1562
|
+
return () => (0, import_vue15.createVNode)(import_pixel3_scrollbar.MpScrollbar, {
|
|
1213
1563
|
"options": {
|
|
1214
1564
|
overflow: {
|
|
1215
1565
|
y: "hide",
|
|
@@ -1217,18 +1567,18 @@ var EditorToolbar = (0, import_vue14.defineComponent)({
|
|
|
1217
1567
|
}
|
|
1218
1568
|
}
|
|
1219
1569
|
}, {
|
|
1220
|
-
default: () => [(0,
|
|
1221
|
-
"class": (0,
|
|
1570
|
+
default: () => [(0, import_vue15.createVNode)("div", {
|
|
1571
|
+
"class": (0, import_css6.css)({
|
|
1222
1572
|
display: "flex",
|
|
1223
1573
|
alignItems: "stretch",
|
|
1224
1574
|
gap: "1"
|
|
1225
1575
|
})
|
|
1226
|
-
}, [options == null ? void 0 : options.map((option, index) => (0,
|
|
1576
|
+
}, [options == null ? void 0 : options.map((option, index) => (0, import_vue15.createVNode)(import_vue15.Fragment, null, [option.map((item) => {
|
|
1227
1577
|
const resolvedItem = typeof item === "string" ? item : item.value;
|
|
1228
1578
|
if (items.includes(resolvedItem)) {
|
|
1229
1579
|
return renderExtension(item);
|
|
1230
1580
|
}
|
|
1231
|
-
}), index !== (options == null ? void 0 : options.length) - 1 && (0,
|
|
1581
|
+
}), index !== (options == null ? void 0 : options.length) - 1 && (0, import_vue15.createVNode)(import_pixel3_divider.MpDivider, {
|
|
1232
1582
|
"id": "divider-toolbar",
|
|
1233
1583
|
"orientation": "vertical"
|
|
1234
1584
|
}, null)]))])]
|
package/dist/editor-toolbar.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EditorToolbar
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-UD5PDCGC.mjs";
|
|
4
|
+
import "./chunk-HIHIKPNN.mjs";
|
|
5
|
+
import "./chunk-X2CB42A3.mjs";
|
|
6
|
+
import "./chunk-COZ45QUD.mjs";
|
|
7
|
+
import "./chunk-47IOAHWN.mjs";
|
|
8
|
+
import "./chunk-ENKUUZPM.mjs";
|
|
9
|
+
import "./chunk-76GEEOAG.mjs";
|
|
10
|
+
import "./chunk-YWVVMJGP.mjs";
|
|
11
|
+
import "./chunk-Y6UPQ6EU.mjs";
|
|
12
|
+
import "./chunk-IFRJVX2K.mjs";
|
|
11
13
|
import "./chunk-QZ7VFGWC.mjs";
|
|
12
14
|
export {
|
|
13
15
|
EditorToolbar
|
|
@@ -438,6 +438,33 @@ var LocationIcon = (0, import_vue2.defineComponent)({
|
|
|
438
438
|
}, null)]);
|
|
439
439
|
}
|
|
440
440
|
});
|
|
441
|
+
var VariableIcon = (0, import_vue2.defineComponent)({
|
|
442
|
+
name: "VariableIcon",
|
|
443
|
+
setup() {
|
|
444
|
+
return () => (0, import_vue.createVNode)("svg", {
|
|
445
|
+
"class": "mp-icon mp-icon--size_sm",
|
|
446
|
+
"data-pixel-component": "MpIcon",
|
|
447
|
+
"data-icon-name": "text-editor-inline-code",
|
|
448
|
+
"viewBox": "0 0 24 24",
|
|
449
|
+
"role": "presentation",
|
|
450
|
+
"fill": "none",
|
|
451
|
+
"focusable": "false",
|
|
452
|
+
"style": "--mp-icon-color: var(--mp-colors-icon-default);"
|
|
453
|
+
}, [(0, import_vue.createVNode)("path", {
|
|
454
|
+
"d": "M15 6L21 12L15 18",
|
|
455
|
+
"stroke": "currentcolor",
|
|
456
|
+
"stroke-width": "1.5",
|
|
457
|
+
"stroke-linecap": "round",
|
|
458
|
+
"stroke-linejoin": "round"
|
|
459
|
+
}, null), (0, import_vue.createVNode)("path", {
|
|
460
|
+
"d": "M9 6L3 12L9 18",
|
|
461
|
+
"stroke": "currentcolor",
|
|
462
|
+
"stroke-width": "1.5",
|
|
463
|
+
"stroke-linecap": "round",
|
|
464
|
+
"stroke-linejoin": "round"
|
|
465
|
+
}, null)]);
|
|
466
|
+
}
|
|
467
|
+
});
|
|
441
468
|
|
|
442
469
|
// src/extensions/align-extension.tsx
|
|
443
470
|
var AlignExtention = (0, import_vue4.defineComponent)({
|
|
@@ -436,6 +436,33 @@ var LocationIcon = (0, import_vue2.defineComponent)({
|
|
|
436
436
|
}, null)]);
|
|
437
437
|
}
|
|
438
438
|
});
|
|
439
|
+
var VariableIcon = (0, import_vue2.defineComponent)({
|
|
440
|
+
name: "VariableIcon",
|
|
441
|
+
setup() {
|
|
442
|
+
return () => (0, import_vue.createVNode)("svg", {
|
|
443
|
+
"class": "mp-icon mp-icon--size_sm",
|
|
444
|
+
"data-pixel-component": "MpIcon",
|
|
445
|
+
"data-icon-name": "text-editor-inline-code",
|
|
446
|
+
"viewBox": "0 0 24 24",
|
|
447
|
+
"role": "presentation",
|
|
448
|
+
"fill": "none",
|
|
449
|
+
"focusable": "false",
|
|
450
|
+
"style": "--mp-icon-color: var(--mp-colors-icon-default);"
|
|
451
|
+
}, [(0, import_vue.createVNode)("path", {
|
|
452
|
+
"d": "M15 6L21 12L15 18",
|
|
453
|
+
"stroke": "currentcolor",
|
|
454
|
+
"stroke-width": "1.5",
|
|
455
|
+
"stroke-linecap": "round",
|
|
456
|
+
"stroke-linejoin": "round"
|
|
457
|
+
}, null), (0, import_vue.createVNode)("path", {
|
|
458
|
+
"d": "M9 6L3 12L9 18",
|
|
459
|
+
"stroke": "currentcolor",
|
|
460
|
+
"stroke-width": "1.5",
|
|
461
|
+
"stroke-linecap": "round",
|
|
462
|
+
"stroke-linejoin": "round"
|
|
463
|
+
}, null)]);
|
|
464
|
+
}
|
|
465
|
+
});
|
|
439
466
|
|
|
440
467
|
// src/extensions/color-extension.tsx
|
|
441
468
|
var import_pixel3_color_picker = require("@mekari/pixel3-color-picker");
|