@mekari/pixel3-rich-text-editor 0.1.2-dev.0 → 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
package/dist/rich-text-editor.js
CHANGED
|
@@ -34,8 +34,8 @@ __export(rich_text_editor_exports, {
|
|
|
34
34
|
MpRichTextEditor: () => MpRichTextEditor
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(rich_text_editor_exports);
|
|
37
|
-
var
|
|
38
|
-
var
|
|
37
|
+
var import_vue22 = require("vue");
|
|
38
|
+
var import_vue23 = require("vue");
|
|
39
39
|
var import_pixel3_utils4 = require("@mekari/pixel3-utils");
|
|
40
40
|
|
|
41
41
|
// src/modules/rich-text-editor.props.ts
|
|
@@ -72,6 +72,10 @@ var richTextEditorProps = {
|
|
|
72
72
|
type: Array,
|
|
73
73
|
default: () => []
|
|
74
74
|
},
|
|
75
|
+
variables: {
|
|
76
|
+
type: Array,
|
|
77
|
+
default: () => []
|
|
78
|
+
},
|
|
75
79
|
validateLink: {
|
|
76
80
|
type: Function
|
|
77
81
|
},
|
|
@@ -163,7 +167,7 @@ var useRTEStyleProvider = /* @__PURE__ */ __name((props) => {
|
|
|
163
167
|
}, "useRTEStyleProvider");
|
|
164
168
|
|
|
165
169
|
// src/rich-text-editor.tsx
|
|
166
|
-
var
|
|
170
|
+
var import_vue_33 = require("@tiptap/vue-3");
|
|
167
171
|
var import_starter_kit = __toESM(require("@tiptap/starter-kit"));
|
|
168
172
|
var import_extension_underline = __toESM(require("@tiptap/extension-underline"));
|
|
169
173
|
var import_extension_text_align = __toESM(require("@tiptap/extension-text-align"));
|
|
@@ -178,9 +182,9 @@ var import_tokens = require("@mekari/pixel3-styled-system/tokens");
|
|
|
178
182
|
var import_pixel3_form_control = require("@mekari/pixel3-form-control");
|
|
179
183
|
|
|
180
184
|
// src/editor-toolbar.tsx
|
|
181
|
-
var
|
|
182
|
-
var
|
|
183
|
-
var
|
|
185
|
+
var import_vue16 = require("vue");
|
|
186
|
+
var import_vue17 = require("vue");
|
|
187
|
+
var import_css6 = require("@mekari/pixel3-styled-system/css");
|
|
184
188
|
var import_pixel3_divider = require("@mekari/pixel3-divider");
|
|
185
189
|
var import_pixel3_scrollbar = require("@mekari/pixel3-scrollbar");
|
|
186
190
|
|
|
@@ -600,6 +604,33 @@ var LocationIcon = (0, import_vue3.defineComponent)({
|
|
|
600
604
|
}, null)]);
|
|
601
605
|
}
|
|
602
606
|
});
|
|
607
|
+
var VariableIcon = (0, import_vue3.defineComponent)({
|
|
608
|
+
name: "VariableIcon",
|
|
609
|
+
setup() {
|
|
610
|
+
return () => (0, import_vue2.createVNode)("svg", {
|
|
611
|
+
"class": "mp-icon mp-icon--size_sm",
|
|
612
|
+
"data-pixel-component": "MpIcon",
|
|
613
|
+
"data-icon-name": "text-editor-inline-code",
|
|
614
|
+
"viewBox": "0 0 24 24",
|
|
615
|
+
"role": "presentation",
|
|
616
|
+
"fill": "none",
|
|
617
|
+
"focusable": "false",
|
|
618
|
+
"style": "--mp-icon-color: var(--mp-colors-icon-default);"
|
|
619
|
+
}, [(0, import_vue2.createVNode)("path", {
|
|
620
|
+
"d": "M15 6L21 12L15 18",
|
|
621
|
+
"stroke": "currentcolor",
|
|
622
|
+
"stroke-width": "1.5",
|
|
623
|
+
"stroke-linecap": "round",
|
|
624
|
+
"stroke-linejoin": "round"
|
|
625
|
+
}, null), (0, import_vue2.createVNode)("path", {
|
|
626
|
+
"d": "M9 6L3 12L9 18",
|
|
627
|
+
"stroke": "currentcolor",
|
|
628
|
+
"stroke-width": "1.5",
|
|
629
|
+
"stroke-linecap": "round",
|
|
630
|
+
"stroke-linejoin": "round"
|
|
631
|
+
}, null)]);
|
|
632
|
+
}
|
|
633
|
+
});
|
|
603
634
|
|
|
604
635
|
// src/extensions/heading-extension.tsx
|
|
605
636
|
var HeadingExtention = (0, import_vue5.defineComponent)({
|
|
@@ -864,6 +895,7 @@ var SingleExtention = (0, import_vue9.defineComponent)({
|
|
|
864
895
|
file: (0, import_vue8.createVNode)(FileIcon, null, null),
|
|
865
896
|
audio: (0, import_vue8.createVNode)(AudioIcon, null, null),
|
|
866
897
|
mention: (0, import_vue8.createVNode)(MentionIcon, null, null),
|
|
898
|
+
variable: (0, import_vue8.createVNode)(VariableIcon, null, null),
|
|
867
899
|
location: (0, import_vue8.createVNode)(LocationIcon, null, null)
|
|
868
900
|
};
|
|
869
901
|
return () => (0, import_vue8.withDirectives)((0, import_vue8.createVNode)("button", {
|
|
@@ -1190,10 +1222,313 @@ var LinkExtension = (0, import_vue13.defineComponent)({
|
|
|
1190
1222
|
}
|
|
1191
1223
|
});
|
|
1192
1224
|
|
|
1225
|
+
// src/extensions/variable-extension.ts
|
|
1226
|
+
var import_core2 = require("@tiptap/core");
|
|
1227
|
+
var import_suggestion = __toESM(require("@tiptap/suggestion"));
|
|
1228
|
+
var Variable = import_core2.Node.create({
|
|
1229
|
+
name: "variable",
|
|
1230
|
+
addOptions() {
|
|
1231
|
+
return {
|
|
1232
|
+
HTMLAttributes: {},
|
|
1233
|
+
renderLabel({
|
|
1234
|
+
node
|
|
1235
|
+
}) {
|
|
1236
|
+
var _a;
|
|
1237
|
+
return `{${(_a = node.attrs.label) != null ? _a : node.attrs.id}}`;
|
|
1238
|
+
},
|
|
1239
|
+
suggestion: {}
|
|
1240
|
+
};
|
|
1241
|
+
},
|
|
1242
|
+
group: "inline",
|
|
1243
|
+
inline: true,
|
|
1244
|
+
selectable: false,
|
|
1245
|
+
atom: true,
|
|
1246
|
+
addAttributes() {
|
|
1247
|
+
return {
|
|
1248
|
+
id: {
|
|
1249
|
+
default: null,
|
|
1250
|
+
parseHTML: (element) => element.getAttribute("data-id"),
|
|
1251
|
+
renderHTML: (attributes) => {
|
|
1252
|
+
if (!attributes.id) {
|
|
1253
|
+
return {};
|
|
1254
|
+
}
|
|
1255
|
+
return {
|
|
1256
|
+
"data-id": attributes.id
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1259
|
+
},
|
|
1260
|
+
label: {
|
|
1261
|
+
default: null,
|
|
1262
|
+
parseHTML: (element) => element.getAttribute("data-label"),
|
|
1263
|
+
renderHTML: (attributes) => {
|
|
1264
|
+
if (!attributes.label) {
|
|
1265
|
+
return {};
|
|
1266
|
+
}
|
|
1267
|
+
return {
|
|
1268
|
+
"data-label": attributes.label
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
},
|
|
1272
|
+
category: {
|
|
1273
|
+
default: null,
|
|
1274
|
+
parseHTML: (element) => element.getAttribute("data-category"),
|
|
1275
|
+
renderHTML: (attributes) => {
|
|
1276
|
+
if (!attributes.category) {
|
|
1277
|
+
return {};
|
|
1278
|
+
}
|
|
1279
|
+
return {
|
|
1280
|
+
"data-category": attributes.category
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
},
|
|
1286
|
+
parseHTML() {
|
|
1287
|
+
return [{
|
|
1288
|
+
tag: `span[data-type="${this.name}"]`
|
|
1289
|
+
}];
|
|
1290
|
+
},
|
|
1291
|
+
renderHTML({
|
|
1292
|
+
node,
|
|
1293
|
+
HTMLAttributes
|
|
1294
|
+
}) {
|
|
1295
|
+
return ["span", (0, import_core2.mergeAttributes)({
|
|
1296
|
+
"data-type": this.name
|
|
1297
|
+
}, this.options.HTMLAttributes, HTMLAttributes), this.options.renderLabel({
|
|
1298
|
+
options: this.options,
|
|
1299
|
+
node
|
|
1300
|
+
})];
|
|
1301
|
+
},
|
|
1302
|
+
renderText({
|
|
1303
|
+
node
|
|
1304
|
+
}) {
|
|
1305
|
+
return this.options.renderLabel({
|
|
1306
|
+
options: this.options,
|
|
1307
|
+
node
|
|
1308
|
+
});
|
|
1309
|
+
},
|
|
1310
|
+
addKeyboardShortcuts() {
|
|
1311
|
+
return {
|
|
1312
|
+
Backspace: () => this.editor.commands.command(({
|
|
1313
|
+
tr,
|
|
1314
|
+
state
|
|
1315
|
+
}) => {
|
|
1316
|
+
let isVariable = false;
|
|
1317
|
+
const {
|
|
1318
|
+
selection
|
|
1319
|
+
} = state;
|
|
1320
|
+
const {
|
|
1321
|
+
empty,
|
|
1322
|
+
anchor
|
|
1323
|
+
} = selection;
|
|
1324
|
+
if (!empty) {
|
|
1325
|
+
return false;
|
|
1326
|
+
}
|
|
1327
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
1328
|
+
if (node.type.name === this.name) {
|
|
1329
|
+
isVariable = true;
|
|
1330
|
+
tr.insertText(this.options.suggestion.char || "", pos, pos + node.nodeSize);
|
|
1331
|
+
return false;
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1334
|
+
return isVariable;
|
|
1335
|
+
})
|
|
1336
|
+
};
|
|
1337
|
+
},
|
|
1338
|
+
addProseMirrorPlugins() {
|
|
1339
|
+
return [(0, import_suggestion.default)({
|
|
1340
|
+
editor: this.editor,
|
|
1341
|
+
...this.options.suggestion
|
|
1342
|
+
})];
|
|
1343
|
+
}
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
// src/extensions/variable-list-extension.tsx
|
|
1347
|
+
var import_vue14 = require("vue");
|
|
1348
|
+
var import_vue15 = require("vue");
|
|
1349
|
+
var import_css5 = require("@mekari/pixel3-styled-system/css");
|
|
1350
|
+
var import_pixel3_popover3 = require("@mekari/pixel3-popover");
|
|
1351
|
+
var import_pixel3_text2 = require("@mekari/pixel3-text");
|
|
1352
|
+
var VariableList = (0, import_vue15.defineComponent)({
|
|
1353
|
+
name: "VariableList",
|
|
1354
|
+
props: {
|
|
1355
|
+
items: {
|
|
1356
|
+
type: Array,
|
|
1357
|
+
default: () => []
|
|
1358
|
+
},
|
|
1359
|
+
command: {
|
|
1360
|
+
type: Function,
|
|
1361
|
+
required: true
|
|
1362
|
+
}
|
|
1363
|
+
},
|
|
1364
|
+
setup(props, {
|
|
1365
|
+
expose
|
|
1366
|
+
}) {
|
|
1367
|
+
const selectedIndex = (0, import_vue15.ref)(0);
|
|
1368
|
+
const listRef = (0, import_vue15.ref)(null);
|
|
1369
|
+
const groupedItems = (0, import_vue15.computed)(() => {
|
|
1370
|
+
const groups = {};
|
|
1371
|
+
props.items.forEach((item) => {
|
|
1372
|
+
const category = item.category || "OTHER";
|
|
1373
|
+
if (!groups[category]) {
|
|
1374
|
+
groups[category] = [];
|
|
1375
|
+
}
|
|
1376
|
+
groups[category].push(item);
|
|
1377
|
+
});
|
|
1378
|
+
return Object.entries(groups).map(([category, items]) => ({
|
|
1379
|
+
category,
|
|
1380
|
+
items
|
|
1381
|
+
}));
|
|
1382
|
+
});
|
|
1383
|
+
const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
|
|
1384
|
+
(0, import_vue15.nextTick)(() => {
|
|
1385
|
+
if (!listRef.value)
|
|
1386
|
+
return;
|
|
1387
|
+
const targetItem = listRef.value.querySelector('[data-active="true"], [data-highlight]');
|
|
1388
|
+
if (targetItem) {
|
|
1389
|
+
targetItem.scrollIntoView({
|
|
1390
|
+
block: "nearest"
|
|
1391
|
+
});
|
|
1392
|
+
}
|
|
1393
|
+
});
|
|
1394
|
+
}, "scrollToFocusedItem");
|
|
1395
|
+
(0, import_vue15.watch)(() => props.items, () => {
|
|
1396
|
+
selectedIndex.value = 0;
|
|
1397
|
+
});
|
|
1398
|
+
const onSelect = /* @__PURE__ */ __name((index) => {
|
|
1399
|
+
const item = props.items[index];
|
|
1400
|
+
if (item) {
|
|
1401
|
+
props.command({
|
|
1402
|
+
...item,
|
|
1403
|
+
label: item.id
|
|
1404
|
+
});
|
|
1405
|
+
}
|
|
1406
|
+
}, "onSelect");
|
|
1407
|
+
const onKeyDown = /* @__PURE__ */ __name(({
|
|
1408
|
+
event
|
|
1409
|
+
}) => {
|
|
1410
|
+
if (!props.items.length) {
|
|
1411
|
+
return false;
|
|
1412
|
+
}
|
|
1413
|
+
if (event.key === "ArrowUp") {
|
|
1414
|
+
event.preventDefault();
|
|
1415
|
+
const total = props.items.length;
|
|
1416
|
+
selectedIndex.value = (selectedIndex.value + total - 1) % total;
|
|
1417
|
+
scrollToFocusedItem();
|
|
1418
|
+
return true;
|
|
1419
|
+
}
|
|
1420
|
+
if (event.key === "ArrowDown") {
|
|
1421
|
+
event.preventDefault();
|
|
1422
|
+
selectedIndex.value = (selectedIndex.value + 1) % props.items.length;
|
|
1423
|
+
scrollToFocusedItem();
|
|
1424
|
+
return true;
|
|
1425
|
+
}
|
|
1426
|
+
if (event.key === "Enter") {
|
|
1427
|
+
event.preventDefault();
|
|
1428
|
+
onSelect(selectedIndex.value);
|
|
1429
|
+
return true;
|
|
1430
|
+
}
|
|
1431
|
+
return false;
|
|
1432
|
+
}, "onKeyDown");
|
|
1433
|
+
expose({
|
|
1434
|
+
onKeyDown
|
|
1435
|
+
});
|
|
1436
|
+
return () => (0, import_vue14.createVNode)(import_pixel3_popover3.MpPopover, {
|
|
1437
|
+
"id": "popover-rte-variable-list",
|
|
1438
|
+
"is-manual": true,
|
|
1439
|
+
"is-default-open": true,
|
|
1440
|
+
"is-open": true
|
|
1441
|
+
}, {
|
|
1442
|
+
default: () => [(0, import_vue14.createVNode)(import_pixel3_popover3.MpPopoverContent, {
|
|
1443
|
+
"class": (0, import_css5.css)({
|
|
1444
|
+
width: "280px",
|
|
1445
|
+
maxHeight: "284px",
|
|
1446
|
+
overflowY: "auto"
|
|
1447
|
+
})
|
|
1448
|
+
}, {
|
|
1449
|
+
default: () => [(0, import_vue14.createVNode)(import_pixel3_popover3.MpPopoverList, {
|
|
1450
|
+
"ref": (element) => {
|
|
1451
|
+
var _a;
|
|
1452
|
+
if (!element) {
|
|
1453
|
+
listRef.value = null;
|
|
1454
|
+
return;
|
|
1455
|
+
}
|
|
1456
|
+
listRef.value = (_a = element.$el) != null ? _a : element;
|
|
1457
|
+
},
|
|
1458
|
+
"data-pixel-rte": true
|
|
1459
|
+
}, {
|
|
1460
|
+
default: () => [!props.items.length && (0, import_vue14.createVNode)(import_pixel3_text2.MpText, {
|
|
1461
|
+
"color": "text.secondary",
|
|
1462
|
+
"class": (0, import_css5.css)({
|
|
1463
|
+
px: "3",
|
|
1464
|
+
py: "2"
|
|
1465
|
+
})
|
|
1466
|
+
}, {
|
|
1467
|
+
default: () => [(0, import_vue14.createTextVNode)("No result")]
|
|
1468
|
+
}), groupedItems.value.map((group) => {
|
|
1469
|
+
return (0, import_vue14.createVNode)(import_vue14.Fragment, null, [(0, import_vue14.createVNode)(import_pixel3_text2.MpText, {
|
|
1470
|
+
"size": "label-small",
|
|
1471
|
+
"color": "text.secondary",
|
|
1472
|
+
"class": (0, import_css5.css)({
|
|
1473
|
+
px: "3",
|
|
1474
|
+
py: "2",
|
|
1475
|
+
textTransform: "uppercase",
|
|
1476
|
+
textAlign: "left",
|
|
1477
|
+
letterSpacing: "0.05em",
|
|
1478
|
+
display: "block",
|
|
1479
|
+
width: "full"
|
|
1480
|
+
})
|
|
1481
|
+
}, {
|
|
1482
|
+
default: () => [group.category]
|
|
1483
|
+
}), group.items.map((item) => {
|
|
1484
|
+
const itemIndex = props.items.indexOf(item);
|
|
1485
|
+
return (0, import_vue14.createVNode)(import_pixel3_popover3.MpPopoverListItem, {
|
|
1486
|
+
"key": `${item.id}-${itemIndex}`,
|
|
1487
|
+
"onMousedown": (event) => event.preventDefault(),
|
|
1488
|
+
"onMouseenter": () => {
|
|
1489
|
+
selectedIndex.value = itemIndex;
|
|
1490
|
+
},
|
|
1491
|
+
"onClick": () => {
|
|
1492
|
+
onSelect(itemIndex);
|
|
1493
|
+
}
|
|
1494
|
+
}, {
|
|
1495
|
+
default: () => [(0, import_vue14.createVNode)("div", {
|
|
1496
|
+
"class": (0, import_css5.css)({
|
|
1497
|
+
display: "flex",
|
|
1498
|
+
flexDirection: "column",
|
|
1499
|
+
alignItems: "flex-start",
|
|
1500
|
+
minWidth: "0",
|
|
1501
|
+
width: "full",
|
|
1502
|
+
gap: "0.5"
|
|
1503
|
+
})
|
|
1504
|
+
}, [(0, import_vue14.createVNode)(import_pixel3_text2.MpText, {
|
|
1505
|
+
"size": "label",
|
|
1506
|
+
"is-truncated": true
|
|
1507
|
+
}, {
|
|
1508
|
+
default: () => [item.name || "Unknown"]
|
|
1509
|
+
}), (0, import_vue14.createVNode)(import_pixel3_text2.MpText, {
|
|
1510
|
+
"size": "label-small",
|
|
1511
|
+
"color": "text.secondary",
|
|
1512
|
+
"is-truncated": true,
|
|
1513
|
+
"class": (0, import_css5.css)({
|
|
1514
|
+
fontFamily: "mono"
|
|
1515
|
+
})
|
|
1516
|
+
}, {
|
|
1517
|
+
default: () => [`{${item.id}}`]
|
|
1518
|
+
})])]
|
|
1519
|
+
});
|
|
1520
|
+
})]);
|
|
1521
|
+
})]
|
|
1522
|
+
})]
|
|
1523
|
+
})]
|
|
1524
|
+
});
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
|
|
1193
1528
|
// src/editor-toolbar.tsx
|
|
1194
|
-
var EditorToolbar = (0,
|
|
1529
|
+
var EditorToolbar = (0, import_vue17.defineComponent)({
|
|
1195
1530
|
name: "EditorToolbar",
|
|
1196
|
-
emits: ["clickImage", "clickFile", "clickAudio", "clickMention", "clickLocation"],
|
|
1531
|
+
emits: ["clickImage", "clickFile", "clickAudio", "clickMention", "clickVariable", "clickLocation"],
|
|
1197
1532
|
props: {
|
|
1198
1533
|
editor: {
|
|
1199
1534
|
type: Object
|
|
@@ -1216,7 +1551,7 @@ var EditorToolbar = (0, import_vue15.defineComponent)({
|
|
|
1216
1551
|
}, {
|
|
1217
1552
|
emit
|
|
1218
1553
|
}) {
|
|
1219
|
-
const items = ["heading", "bold", "italic", "underline", "strike", "blockquote", "bulletList", "orderedList", "textColor", "fillColor", "textLink", "align", "undo", "redo", "clear", "image", "file", "audio", "mention", "location"];
|
|
1554
|
+
const items = ["heading", "bold", "italic", "underline", "strike", "blockquote", "bulletList", "orderedList", "textColor", "fillColor", "textLink", "align", "undo", "redo", "clear", "image", "file", "audio", "mention", "variable", "location"];
|
|
1220
1555
|
const itemOptions = {
|
|
1221
1556
|
heading: {
|
|
1222
1557
|
tooltipLabel: "Text style",
|
|
@@ -1301,6 +1636,15 @@ var EditorToolbar = (0, import_vue15.defineComponent)({
|
|
|
1301
1636
|
emit("clickMention");
|
|
1302
1637
|
}
|
|
1303
1638
|
},
|
|
1639
|
+
variable: {
|
|
1640
|
+
tooltipLabel: "Insert variable",
|
|
1641
|
+
editor,
|
|
1642
|
+
onClick: () => {
|
|
1643
|
+
;
|
|
1644
|
+
(editor == null ? void 0 : editor.chain()).focus().insertContent("{").run();
|
|
1645
|
+
emit("clickVariable");
|
|
1646
|
+
}
|
|
1647
|
+
},
|
|
1304
1648
|
location: {
|
|
1305
1649
|
tooltipLabel: "Add location",
|
|
1306
1650
|
onClick: () => emit("clickLocation")
|
|
@@ -1331,31 +1675,31 @@ var EditorToolbar = (0, import_vue15.defineComponent)({
|
|
|
1331
1675
|
const tooltipLabel = tooltip || resolvedOptions.tooltipLabel;
|
|
1332
1676
|
switch (resolvedItem) {
|
|
1333
1677
|
case "heading":
|
|
1334
|
-
return (0,
|
|
1678
|
+
return (0, import_vue16.createVNode)(HeadingExtention, {
|
|
1335
1679
|
"tooltipLabel": tooltipLabel,
|
|
1336
1680
|
"editor": editor
|
|
1337
1681
|
}, null);
|
|
1338
1682
|
case "align":
|
|
1339
|
-
return (0,
|
|
1683
|
+
return (0, import_vue16.createVNode)(AlignExtention, {
|
|
1340
1684
|
"tooltipLabel": tooltipLabel,
|
|
1341
1685
|
"editor": editor
|
|
1342
1686
|
}, null);
|
|
1343
1687
|
case "textColor":
|
|
1344
1688
|
case "fillColor":
|
|
1345
|
-
return (0,
|
|
1689
|
+
return (0, import_vue16.createVNode)(ColorExtension, {
|
|
1346
1690
|
"tooltipLabel": tooltipLabel,
|
|
1347
1691
|
"editor": editor,
|
|
1348
1692
|
"type": resolvedOptions.type
|
|
1349
1693
|
}, null);
|
|
1350
1694
|
case "textLink":
|
|
1351
|
-
return (0,
|
|
1695
|
+
return (0, import_vue16.createVNode)(LinkExtension, {
|
|
1352
1696
|
"tooltipLabel": tooltipLabel,
|
|
1353
1697
|
"editor": editor,
|
|
1354
1698
|
"validateLink": validateLink,
|
|
1355
1699
|
"transformLink": transformLink
|
|
1356
1700
|
}, null);
|
|
1357
1701
|
default:
|
|
1358
|
-
return (0,
|
|
1702
|
+
return (0, import_vue16.createVNode)(SingleExtention, {
|
|
1359
1703
|
"name": resolvedItem,
|
|
1360
1704
|
"tooltipLabel": tooltipLabel,
|
|
1361
1705
|
"onClick": resolvedOptions.onClick,
|
|
@@ -1363,7 +1707,7 @@ var EditorToolbar = (0, import_vue15.defineComponent)({
|
|
|
1363
1707
|
}, null);
|
|
1364
1708
|
}
|
|
1365
1709
|
}, "renderExtension");
|
|
1366
|
-
return () => (0,
|
|
1710
|
+
return () => (0, import_vue16.createVNode)(import_pixel3_scrollbar.MpScrollbar, {
|
|
1367
1711
|
"options": {
|
|
1368
1712
|
overflow: {
|
|
1369
1713
|
y: "hide",
|
|
@@ -1371,18 +1715,18 @@ var EditorToolbar = (0, import_vue15.defineComponent)({
|
|
|
1371
1715
|
}
|
|
1372
1716
|
}
|
|
1373
1717
|
}, {
|
|
1374
|
-
default: () => [(0,
|
|
1375
|
-
"class": (0,
|
|
1718
|
+
default: () => [(0, import_vue16.createVNode)("div", {
|
|
1719
|
+
"class": (0, import_css6.css)({
|
|
1376
1720
|
display: "flex",
|
|
1377
1721
|
alignItems: "stretch",
|
|
1378
1722
|
gap: "1"
|
|
1379
1723
|
})
|
|
1380
|
-
}, [options == null ? void 0 : options.map((option, index) => (0,
|
|
1724
|
+
}, [options == null ? void 0 : options.map((option, index) => (0, import_vue16.createVNode)(import_vue16.Fragment, null, [option.map((item) => {
|
|
1381
1725
|
const resolvedItem = typeof item === "string" ? item : item.value;
|
|
1382
1726
|
if (items.includes(resolvedItem)) {
|
|
1383
1727
|
return renderExtension(item);
|
|
1384
1728
|
}
|
|
1385
|
-
}), index !== (options == null ? void 0 : options.length) - 1 && (0,
|
|
1729
|
+
}), index !== (options == null ? void 0 : options.length) - 1 && (0, import_vue16.createVNode)(import_pixel3_divider.MpDivider, {
|
|
1386
1730
|
"id": "divider-toolbar",
|
|
1387
1731
|
"orientation": "vertical"
|
|
1388
1732
|
}, null)]))])]
|
|
@@ -1391,9 +1735,9 @@ var EditorToolbar = (0, import_vue15.defineComponent)({
|
|
|
1391
1735
|
});
|
|
1392
1736
|
|
|
1393
1737
|
// src/rte-style-provider.tsx
|
|
1394
|
-
var
|
|
1395
|
-
var
|
|
1396
|
-
var MpRTEStyleProvider = (0,
|
|
1738
|
+
var import_vue18 = require("vue");
|
|
1739
|
+
var import_vue19 = require("vue");
|
|
1740
|
+
var MpRTEStyleProvider = (0, import_vue19.defineComponent)({
|
|
1397
1741
|
name: "MpRTEStyleProvider",
|
|
1398
1742
|
props: RTEStyleProviderProps,
|
|
1399
1743
|
setup(props, {
|
|
@@ -1402,27 +1746,27 @@ var MpRTEStyleProvider = (0, import_vue17.defineComponent)({
|
|
|
1402
1746
|
const api = useRTEStyleProvider(props);
|
|
1403
1747
|
return () => {
|
|
1404
1748
|
var _a;
|
|
1405
|
-
return (0,
|
|
1749
|
+
return (0, import_vue18.createVNode)("div", api.value.rootProps, [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
|
|
1406
1750
|
};
|
|
1407
1751
|
}
|
|
1408
1752
|
});
|
|
1409
1753
|
|
|
1410
1754
|
// src/rte-suggestion.ts
|
|
1411
1755
|
var import_vue_3 = require("@tiptap/vue-3");
|
|
1412
|
-
var
|
|
1756
|
+
var import_core3 = require("@popperjs/core");
|
|
1413
1757
|
|
|
1414
1758
|
// src/extensions/mention-list-extension.tsx
|
|
1415
|
-
var
|
|
1416
|
-
var
|
|
1417
|
-
var
|
|
1759
|
+
var import_vue20 = require("vue");
|
|
1760
|
+
var import_vue21 = require("vue");
|
|
1761
|
+
var import_css7 = require("@mekari/pixel3-styled-system/css");
|
|
1418
1762
|
var import_pixel3_avatar = require("@mekari/pixel3-avatar");
|
|
1419
|
-
var
|
|
1420
|
-
var
|
|
1763
|
+
var import_pixel3_popover4 = require("@mekari/pixel3-popover");
|
|
1764
|
+
var import_pixel3_text3 = require("@mekari/pixel3-text");
|
|
1421
1765
|
var avatarVariantColors = ["violet", "lime", "amber", "sky", "pink", "teal", "rose", "stone"];
|
|
1422
1766
|
var getAvatarVariantColor = /* @__PURE__ */ __name((index) => {
|
|
1423
1767
|
return avatarVariantColors[index % avatarVariantColors.length];
|
|
1424
1768
|
}, "getAvatarVariantColor");
|
|
1425
|
-
var MentionList = (0,
|
|
1769
|
+
var MentionList = (0, import_vue21.defineComponent)({
|
|
1426
1770
|
name: "MentionList",
|
|
1427
1771
|
props: {
|
|
1428
1772
|
items: {
|
|
@@ -1437,10 +1781,10 @@ var MentionList = (0, import_vue19.defineComponent)({
|
|
|
1437
1781
|
setup(props, {
|
|
1438
1782
|
expose
|
|
1439
1783
|
}) {
|
|
1440
|
-
const selectedIndex = (0,
|
|
1441
|
-
const listRef = (0,
|
|
1784
|
+
const selectedIndex = (0, import_vue21.ref)(0);
|
|
1785
|
+
const listRef = (0, import_vue21.ref)(null);
|
|
1442
1786
|
const scrollToFocusedItem = /* @__PURE__ */ __name(() => {
|
|
1443
|
-
(0,
|
|
1787
|
+
(0, import_vue21.nextTick)(() => {
|
|
1444
1788
|
if (!listRef.value)
|
|
1445
1789
|
return;
|
|
1446
1790
|
const targetItem = listRef.value.querySelector('[data-active="true"], [data-highlight]');
|
|
@@ -1451,7 +1795,7 @@ var MentionList = (0, import_vue19.defineComponent)({
|
|
|
1451
1795
|
}
|
|
1452
1796
|
});
|
|
1453
1797
|
}, "scrollToFocusedItem");
|
|
1454
|
-
(0,
|
|
1798
|
+
(0, import_vue21.watch)(() => props.items, () => {
|
|
1455
1799
|
selectedIndex.value = 0;
|
|
1456
1800
|
});
|
|
1457
1801
|
const onSelect = /* @__PURE__ */ __name((index) => {
|
|
@@ -1492,20 +1836,20 @@ var MentionList = (0, import_vue19.defineComponent)({
|
|
|
1492
1836
|
expose({
|
|
1493
1837
|
onKeyDown
|
|
1494
1838
|
});
|
|
1495
|
-
return () => (0,
|
|
1839
|
+
return () => (0, import_vue20.createVNode)(import_pixel3_popover4.MpPopover, {
|
|
1496
1840
|
"id": "popover-rte-mention-list",
|
|
1497
1841
|
"is-manual": true,
|
|
1498
1842
|
"is-default-open": true,
|
|
1499
1843
|
"is-open": true
|
|
1500
1844
|
}, {
|
|
1501
|
-
default: () => [(0,
|
|
1502
|
-
"class": (0,
|
|
1845
|
+
default: () => [(0, import_vue20.createVNode)(import_pixel3_popover4.MpPopoverContent, {
|
|
1846
|
+
"class": (0, import_css7.css)({
|
|
1503
1847
|
width: "280px",
|
|
1504
1848
|
maxHeight: "284px",
|
|
1505
1849
|
overflowY: "auto"
|
|
1506
1850
|
})
|
|
1507
1851
|
}, {
|
|
1508
|
-
default: () => [(0,
|
|
1852
|
+
default: () => [(0, import_vue20.createVNode)(import_pixel3_popover4.MpPopoverList, {
|
|
1509
1853
|
"ref": (element) => {
|
|
1510
1854
|
var _a;
|
|
1511
1855
|
if (!element) {
|
|
@@ -1516,16 +1860,16 @@ var MentionList = (0, import_vue19.defineComponent)({
|
|
|
1516
1860
|
},
|
|
1517
1861
|
"data-pixel-rte": true
|
|
1518
1862
|
}, {
|
|
1519
|
-
default: () => [!props.items.length && (0,
|
|
1863
|
+
default: () => [!props.items.length && (0, import_vue20.createVNode)(import_pixel3_text3.MpText, {
|
|
1520
1864
|
"color": "text.secondary",
|
|
1521
|
-
"class": (0,
|
|
1865
|
+
"class": (0, import_css7.css)({
|
|
1522
1866
|
px: "3",
|
|
1523
1867
|
py: "2"
|
|
1524
1868
|
})
|
|
1525
1869
|
}, {
|
|
1526
|
-
default: () => [(0,
|
|
1870
|
+
default: () => [(0, import_vue20.createTextVNode)("No result")]
|
|
1527
1871
|
}), props.items.map((item, index) => {
|
|
1528
|
-
return (0,
|
|
1872
|
+
return (0, import_vue20.createVNode)(import_pixel3_popover4.MpPopoverListItem, {
|
|
1529
1873
|
"key": `${item.id}-${index}`,
|
|
1530
1874
|
"is-active": selectedIndex.value === index,
|
|
1531
1875
|
"onMousedown": (event) => event.preventDefault(),
|
|
@@ -1536,33 +1880,33 @@ var MentionList = (0, import_vue19.defineComponent)({
|
|
|
1536
1880
|
onSelect(index);
|
|
1537
1881
|
}
|
|
1538
1882
|
}, {
|
|
1539
|
-
default: () => [(0,
|
|
1540
|
-
"class": (0,
|
|
1883
|
+
default: () => [(0, import_vue20.createVNode)("div", {
|
|
1884
|
+
"class": (0, import_css7.css)({
|
|
1541
1885
|
display: "flex",
|
|
1542
1886
|
alignItems: "center",
|
|
1543
1887
|
gap: "2",
|
|
1544
1888
|
width: "full",
|
|
1545
1889
|
minWidth: "0"
|
|
1546
1890
|
})
|
|
1547
|
-
}, [item.avatar && (0,
|
|
1891
|
+
}, [item.avatar && (0, import_vue20.createVNode)(import_pixel3_avatar.MpAvatar, {
|
|
1548
1892
|
"id": `avatar-rte-mention-${index}`,
|
|
1549
1893
|
"name": item.avatar,
|
|
1550
1894
|
"size": "lg",
|
|
1551
1895
|
"variant-color": getAvatarVariantColor(index)
|
|
1552
|
-
}, null), (0,
|
|
1553
|
-
"class": (0,
|
|
1896
|
+
}, null), (0, import_vue20.createVNode)("div", {
|
|
1897
|
+
"class": (0, import_css7.css)({
|
|
1554
1898
|
display: "flex",
|
|
1555
1899
|
flexDirection: "column",
|
|
1556
1900
|
alignItems: "flex-start",
|
|
1557
1901
|
minWidth: "0",
|
|
1558
1902
|
flex: "1 1 0%"
|
|
1559
1903
|
})
|
|
1560
|
-
}, [(0,
|
|
1904
|
+
}, [(0, import_vue20.createVNode)(import_pixel3_text3.MpText, {
|
|
1561
1905
|
"size": "label",
|
|
1562
1906
|
"is-truncated": true
|
|
1563
1907
|
}, {
|
|
1564
1908
|
default: () => [item.name || "Unknown"]
|
|
1565
|
-
}), item.description && (0,
|
|
1909
|
+
}), item.description && (0, import_vue20.createVNode)(import_pixel3_text3.MpText, {
|
|
1566
1910
|
"size": "label-small",
|
|
1567
1911
|
"color": "text.secondary",
|
|
1568
1912
|
"is-truncated": true
|
|
@@ -1669,7 +2013,7 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionItems = () =>
|
|
|
1669
2013
|
return;
|
|
1670
2014
|
}
|
|
1671
2015
|
if (!popperInstance) {
|
|
1672
|
-
popperInstance = (0,
|
|
2016
|
+
popperInstance = (0, import_core3.createPopper)(virtualElement, popoverWrapper, {
|
|
1673
2017
|
placement: "bottom-start",
|
|
1674
2018
|
modifiers: [{
|
|
1675
2019
|
name: "offset",
|
|
@@ -1733,8 +2077,199 @@ var createMentionSuggestion = /* @__PURE__ */ __name((getSuggestionItems = () =>
|
|
|
1733
2077
|
};
|
|
1734
2078
|
}, "createMentionSuggestion");
|
|
1735
2079
|
|
|
2080
|
+
// src/rte-variable-suggestion.ts
|
|
2081
|
+
var import_vue_32 = require("@tiptap/vue-3");
|
|
2082
|
+
var import_core4 = require("@popperjs/core");
|
|
2083
|
+
var import_state = require("@tiptap/pm/state");
|
|
2084
|
+
var VariablePluginKey = new import_state.PluginKey("variable");
|
|
2085
|
+
var MAX_SUGGESTION_ITEMS2 = 50;
|
|
2086
|
+
var getFilteredSuggestionItems2 = /* @__PURE__ */ __name((items, query) => {
|
|
2087
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
2088
|
+
return items.filter((item) => {
|
|
2089
|
+
var _a, _b;
|
|
2090
|
+
if (!normalizedQuery) {
|
|
2091
|
+
return true;
|
|
2092
|
+
}
|
|
2093
|
+
const id = item.id.toLowerCase();
|
|
2094
|
+
const name = ((_a = item.name) != null ? _a : "").toLowerCase();
|
|
2095
|
+
const category = ((_b = item.category) != null ? _b : "").toLowerCase();
|
|
2096
|
+
return id.includes(normalizedQuery) || name.includes(normalizedQuery) || category.includes(normalizedQuery);
|
|
2097
|
+
}).slice(0, MAX_SUGGESTION_ITEMS2);
|
|
2098
|
+
}, "getFilteredSuggestionItems");
|
|
2099
|
+
var createVariableSuggestion = /* @__PURE__ */ __name((getSuggestionItems = () => []) => {
|
|
2100
|
+
return {
|
|
2101
|
+
char: "{",
|
|
2102
|
+
pluginKey: VariablePluginKey,
|
|
2103
|
+
command: ({
|
|
2104
|
+
editor,
|
|
2105
|
+
range,
|
|
2106
|
+
props
|
|
2107
|
+
}) => {
|
|
2108
|
+
var _a, _b;
|
|
2109
|
+
const nodeAfter = editor.view.state.selection.$to.nodeAfter;
|
|
2110
|
+
const overrideSpace = (_a = nodeAfter == null ? void 0 : nodeAfter.text) == null ? void 0 : _a.startsWith(" ");
|
|
2111
|
+
if (overrideSpace) {
|
|
2112
|
+
range.to += 1;
|
|
2113
|
+
}
|
|
2114
|
+
editor.chain().focus().insertContentAt(range, [{
|
|
2115
|
+
type: "variable",
|
|
2116
|
+
attrs: props
|
|
2117
|
+
}, {
|
|
2118
|
+
type: "text",
|
|
2119
|
+
text: " "
|
|
2120
|
+
}]).run();
|
|
2121
|
+
(_b = window.getSelection()) == null ? void 0 : _b.collapseToEnd();
|
|
2122
|
+
},
|
|
2123
|
+
allow: ({
|
|
2124
|
+
state,
|
|
2125
|
+
range
|
|
2126
|
+
}) => {
|
|
2127
|
+
const $from = state.doc.resolve(range.from);
|
|
2128
|
+
const type = state.schema.nodes["variable"];
|
|
2129
|
+
const allow = !!$from.parent.type.contentMatch.matchType(type);
|
|
2130
|
+
return allow;
|
|
2131
|
+
},
|
|
2132
|
+
items: ({
|
|
2133
|
+
query
|
|
2134
|
+
}) => {
|
|
2135
|
+
return getFilteredSuggestionItems2(getSuggestionItems(), query);
|
|
2136
|
+
},
|
|
2137
|
+
render: () => {
|
|
2138
|
+
let component = null;
|
|
2139
|
+
let popperInstance = null;
|
|
2140
|
+
let popoverWrapper = null;
|
|
2141
|
+
let clientRectProvider;
|
|
2142
|
+
let editorElement = null;
|
|
2143
|
+
let removeOutsideListeners = null;
|
|
2144
|
+
const destroyVariablePopover = /* @__PURE__ */ __name(() => {
|
|
2145
|
+
removeOutsideListeners == null ? void 0 : removeOutsideListeners();
|
|
2146
|
+
removeOutsideListeners = null;
|
|
2147
|
+
popperInstance == null ? void 0 : popperInstance.destroy();
|
|
2148
|
+
popperInstance = null;
|
|
2149
|
+
popoverWrapper == null ? void 0 : popoverWrapper.remove();
|
|
2150
|
+
popoverWrapper = null;
|
|
2151
|
+
component == null ? void 0 : component.destroy();
|
|
2152
|
+
component = null;
|
|
2153
|
+
}, "destroyVariablePopover");
|
|
2154
|
+
const isWithinVariableContext = /* @__PURE__ */ __name((target) => {
|
|
2155
|
+
if (!(target instanceof Node)) {
|
|
2156
|
+
return false;
|
|
2157
|
+
}
|
|
2158
|
+
return Boolean((editorElement == null ? void 0 : editorElement.contains(target)) || (popoverWrapper == null ? void 0 : popoverWrapper.contains(target)));
|
|
2159
|
+
}, "isWithinVariableContext");
|
|
2160
|
+
const setupOutsideListeners = /* @__PURE__ */ __name(() => {
|
|
2161
|
+
if (!editorElement || removeOutsideListeners) {
|
|
2162
|
+
return;
|
|
2163
|
+
}
|
|
2164
|
+
const handleDocumentFocusIn = /* @__PURE__ */ __name((event) => {
|
|
2165
|
+
if (!isWithinVariableContext(event.target)) {
|
|
2166
|
+
destroyVariablePopover();
|
|
2167
|
+
}
|
|
2168
|
+
}, "handleDocumentFocusIn");
|
|
2169
|
+
const handleDocumentPointerDown = /* @__PURE__ */ __name((event) => {
|
|
2170
|
+
if (!isWithinVariableContext(event.target)) {
|
|
2171
|
+
destroyVariablePopover();
|
|
2172
|
+
}
|
|
2173
|
+
}, "handleDocumentPointerDown");
|
|
2174
|
+
const handleEditorFocusOut = /* @__PURE__ */ __name((event) => {
|
|
2175
|
+
if (!isWithinVariableContext(event.relatedTarget)) {
|
|
2176
|
+
destroyVariablePopover();
|
|
2177
|
+
}
|
|
2178
|
+
}, "handleEditorFocusOut");
|
|
2179
|
+
document.addEventListener("focusin", handleDocumentFocusIn);
|
|
2180
|
+
document.addEventListener("mousedown", handleDocumentPointerDown, true);
|
|
2181
|
+
document.addEventListener("touchstart", handleDocumentPointerDown, true);
|
|
2182
|
+
editorElement.addEventListener("focusout", handleEditorFocusOut);
|
|
2183
|
+
removeOutsideListeners = /* @__PURE__ */ __name(() => {
|
|
2184
|
+
document.removeEventListener("focusin", handleDocumentFocusIn);
|
|
2185
|
+
document.removeEventListener("mousedown", handleDocumentPointerDown, true);
|
|
2186
|
+
document.removeEventListener("touchstart", handleDocumentPointerDown, true);
|
|
2187
|
+
editorElement == null ? void 0 : editorElement.removeEventListener("focusout", handleEditorFocusOut);
|
|
2188
|
+
}, "removeOutsideListeners");
|
|
2189
|
+
}, "setupOutsideListeners");
|
|
2190
|
+
const getVirtualElement = /* @__PURE__ */ __name(() => {
|
|
2191
|
+
if (!clientRectProvider) {
|
|
2192
|
+
return null;
|
|
2193
|
+
}
|
|
2194
|
+
return {
|
|
2195
|
+
getBoundingClientRect: () => {
|
|
2196
|
+
var _a;
|
|
2197
|
+
return (_a = clientRectProvider == null ? void 0 : clientRectProvider()) != null ? _a : new DOMRect();
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
}, "getVirtualElement");
|
|
2201
|
+
const updatePopoverPosition = /* @__PURE__ */ __name(() => {
|
|
2202
|
+
const virtualElement = getVirtualElement();
|
|
2203
|
+
if (!virtualElement || !popoverWrapper) {
|
|
2204
|
+
return;
|
|
2205
|
+
}
|
|
2206
|
+
if (!popperInstance) {
|
|
2207
|
+
popperInstance = (0, import_core4.createPopper)(virtualElement, popoverWrapper, {
|
|
2208
|
+
placement: "bottom-start",
|
|
2209
|
+
modifiers: [{
|
|
2210
|
+
name: "offset",
|
|
2211
|
+
options: {
|
|
2212
|
+
offset: [0, 8]
|
|
2213
|
+
}
|
|
2214
|
+
}, {
|
|
2215
|
+
name: "flip",
|
|
2216
|
+
options: {
|
|
2217
|
+
fallbackPlacements: ["top-start"]
|
|
2218
|
+
}
|
|
2219
|
+
}]
|
|
2220
|
+
});
|
|
2221
|
+
return;
|
|
2222
|
+
}
|
|
2223
|
+
popperInstance.update();
|
|
2224
|
+
}, "updatePopoverPosition");
|
|
2225
|
+
return {
|
|
2226
|
+
onStart: (props) => {
|
|
2227
|
+
clientRectProvider = props.clientRect;
|
|
2228
|
+
editorElement = props.editor.view.dom;
|
|
2229
|
+
component = new import_vue_32.VueRenderer(VariableList, {
|
|
2230
|
+
editor: props.editor,
|
|
2231
|
+
props: {
|
|
2232
|
+
items: props.items,
|
|
2233
|
+
command: props.command
|
|
2234
|
+
}
|
|
2235
|
+
});
|
|
2236
|
+
popoverWrapper = document.createElement("div");
|
|
2237
|
+
popoverWrapper.style.position = "absolute";
|
|
2238
|
+
popoverWrapper.style.zIndex = "var(--mp-z-index-popover)";
|
|
2239
|
+
if (component.element) {
|
|
2240
|
+
popoverWrapper.append(component.element);
|
|
2241
|
+
}
|
|
2242
|
+
document.body.append(popoverWrapper);
|
|
2243
|
+
setupOutsideListeners();
|
|
2244
|
+
updatePopoverPosition();
|
|
2245
|
+
},
|
|
2246
|
+
onUpdate: (props) => {
|
|
2247
|
+
clientRectProvider = props.clientRect;
|
|
2248
|
+
component == null ? void 0 : component.updateProps({
|
|
2249
|
+
items: props.items,
|
|
2250
|
+
command: props.command
|
|
2251
|
+
});
|
|
2252
|
+
updatePopoverPosition();
|
|
2253
|
+
},
|
|
2254
|
+
onKeyDown: (props) => {
|
|
2255
|
+
var _a, _b;
|
|
2256
|
+
if (props.event.key === "Escape") {
|
|
2257
|
+
destroyVariablePopover();
|
|
2258
|
+
return true;
|
|
2259
|
+
}
|
|
2260
|
+
return (_b = (_a = component == null ? void 0 : component.ref) == null ? void 0 : _a.onKeyDown(props)) != null ? _b : false;
|
|
2261
|
+
},
|
|
2262
|
+
onExit: () => {
|
|
2263
|
+
destroyVariablePopover();
|
|
2264
|
+
editorElement = null;
|
|
2265
|
+
}
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2268
|
+
};
|
|
2269
|
+
}, "createVariableSuggestion");
|
|
2270
|
+
|
|
1736
2271
|
// src/rich-text-editor.tsx
|
|
1737
|
-
var MpRichTextEditor = (0,
|
|
2272
|
+
var MpRichTextEditor = (0, import_vue23.defineComponent)({
|
|
1738
2273
|
name: "MpRichTextEditor",
|
|
1739
2274
|
props: richTextEditorProps,
|
|
1740
2275
|
emits: richTextEditorEmits,
|
|
@@ -1743,11 +2278,11 @@ var MpRichTextEditor = (0, import_vue21.defineComponent)({
|
|
|
1743
2278
|
}) {
|
|
1744
2279
|
const formControlProp = (0, import_pixel3_form_control.useFormControlContext)();
|
|
1745
2280
|
const api = useRichTextEditor(props);
|
|
1746
|
-
const isFocused = (0,
|
|
2281
|
+
const isFocused = (0, import_vue23.ref)(false);
|
|
1747
2282
|
const {
|
|
1748
2283
|
isNextTheme
|
|
1749
2284
|
} = (0, import_pixel3_utils4.usePixelTheme)();
|
|
1750
|
-
const editor = new
|
|
2285
|
+
const editor = new import_vue_33.Editor({
|
|
1751
2286
|
content: api.value.value,
|
|
1752
2287
|
editable: (formControlProp == null ? void 0 : formControlProp.value.isDisabled) === void 0 ? !api.value.isDisabled : !(formControlProp == null ? void 0 : formControlProp.value.isDisabled),
|
|
1753
2288
|
editorProps: {
|
|
@@ -1788,6 +2323,9 @@ var MpRichTextEditor = (0, import_vue21.defineComponent)({
|
|
|
1788
2323
|
}),
|
|
1789
2324
|
...props.suggestions && props.suggestions.length > 0 ? [import_extension_mention.default.configure({
|
|
1790
2325
|
suggestion: createMentionSuggestion(() => props.suggestions || [])
|
|
2326
|
+
})] : [],
|
|
2327
|
+
...props.variables && props.variables.length > 0 ? [Variable.configure({
|
|
2328
|
+
suggestion: createVariableSuggestion(() => props.variables || [])
|
|
1791
2329
|
})] : []
|
|
1792
2330
|
],
|
|
1793
2331
|
onFocus({
|
|
@@ -1818,25 +2356,26 @@ var MpRichTextEditor = (0, import_vue21.defineComponent)({
|
|
|
1818
2356
|
onClickFile: () => onClickToolbar("file"),
|
|
1819
2357
|
onClickAudio: () => onClickToolbar("audio"),
|
|
1820
2358
|
onClickMention: () => onClickToolbar("mention"),
|
|
2359
|
+
onClickVariable: () => onClickToolbar("variable"),
|
|
1821
2360
|
onClickLocation: () => onClickToolbar("location")
|
|
1822
2361
|
};
|
|
1823
2362
|
return () => {
|
|
1824
|
-
return (0,
|
|
2363
|
+
return (0, import_vue22.createVNode)("div", (0, import_vue22.mergeProps)(api.value.rootProps, {
|
|
1825
2364
|
"style": {
|
|
1826
2365
|
"--mp-rich-text-editor--border-color-hover": (formControlProp == null ? void 0 : formControlProp.value.isInvalid) || api.value.isInvalid ? isNextTheme.value ? import_tokens.token.var("colors.border.danger") : import_tokens.token.var("colors.red.400") : isFocused.value ? isNextTheme.value ? import_tokens.token.var("colors.border.focused") : import_tokens.token.var("colors.blue.400") : isNextTheme.value ? import_tokens.token.var("colors.border.form") : import_tokens.token.var("colors.gray.400"),
|
|
1827
2366
|
"--mp-rich-text-editor--border-color": (formControlProp == null ? void 0 : formControlProp.value.isInvalid) || api.value.isInvalid ? isNextTheme.value ? import_tokens.token.var("colors.border.danger") : import_tokens.token.var("colors.red.400") : isFocused.value ? isNextTheme.value ? import_tokens.token.var("colors.border.focused") : import_tokens.token.var("colors.blue.400") : isNextTheme.value ? import_tokens.token.var("colors.border.form") : import_tokens.token.var("colors.gray.100"),
|
|
1828
2367
|
"--mp-rich-text-editor--box-shadow": isFocused.value ? isNextTheme.value ? import_tokens.token.var("shadows.focus") : import_tokens.token.var("shadows.outer") : void 0,
|
|
1829
2368
|
"--mp-rich-text-editor--background-color": (formControlProp == null ? void 0 : formControlProp.value.isDisabled) || api.value.isDisabled ? isNextTheme.value ? import_tokens.token.var("colors.background.disabled") : import_tokens.token.var("colors.gray.50") : isNextTheme.value ? import_tokens.token.var("colors.background.neutral") : import_tokens.token.var("colors.white")
|
|
1830
2369
|
}
|
|
1831
|
-
}), [(0,
|
|
2370
|
+
}), [(0, import_vue22.createVNode)(EditorToolbar, (0, import_vue22.mergeProps)({
|
|
1832
2371
|
"editor": editor,
|
|
1833
2372
|
"options": api.value.options,
|
|
1834
2373
|
"validateLink": props.validateLink,
|
|
1835
2374
|
"transformLink": props.transformLink
|
|
1836
|
-
}, api.value.toolbarProps, toolbarActionHandlers), null), (0,
|
|
2375
|
+
}, api.value.toolbarProps, toolbarActionHandlers), null), (0, import_vue22.createVNode)(MpRTEStyleProvider, {
|
|
1837
2376
|
"id": `${api.value.id}-style-provider`
|
|
1838
2377
|
}, {
|
|
1839
|
-
default: () => [(0,
|
|
2378
|
+
default: () => [(0, import_vue22.createVNode)(import_vue_33.EditorContent, (0, import_vue22.mergeProps)({
|
|
1840
2379
|
"editor": editor
|
|
1841
2380
|
}, api.value.areaProps), null)]
|
|
1842
2381
|
})]);
|