@dialpad/dialtone 9.39.0 → 9.41.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/README.md +19 -1
- package/dist/css/dialtone.css +15 -2
- package/dist/css/dialtone.min.css +1 -1
- package/dist/tokens/css/variables-dark.css +1 -1
- package/dist/tokens/css/variables-expressive-dark.css +1 -1
- package/dist/tokens/css/variables-expressive-light.css +1 -1
- package/dist/tokens/css/variables-expressive-sm-dark.css +1 -1
- package/dist/tokens/css/variables-expressive-sm-light.css +1 -1
- package/dist/tokens/css/variables-light.css +1 -1
- package/dist/tokens/css/variables-tmo-dark.css +1 -1
- package/dist/tokens/css/variables-tmo-light.css +1 -1
- package/dist/tokens/less/variables-dark.less +1 -1
- package/dist/tokens/less/variables-expressive-dark.less +1 -1
- package/dist/tokens/less/variables-expressive-light.less +1 -1
- package/dist/tokens/less/variables-expressive-sm-dark.less +1 -1
- package/dist/tokens/less/variables-expressive-sm-light.less +1 -1
- package/dist/tokens/less/variables-light.less +1 -1
- package/dist/tokens/less/variables-tmo-dark.less +1 -1
- package/dist/tokens/less/variables-tmo-light.less +1 -1
- package/dist/vue2/chunks/index-ODod4Oj_.js +175 -0
- package/dist/vue2/chunks/index-ODod4Oj_.js.map +1 -0
- package/dist/vue2/chunks/index-anN_sx1F.js +169 -0
- package/dist/vue2/chunks/index-anN_sx1F.js.map +1 -0
- package/dist/vue2/common/emoji.cjs +40 -163
- package/dist/vue2/common/emoji.cjs.map +1 -1
- package/dist/vue2/common/emoji.js +3 -146
- package/dist/vue2/common/emoji.js.map +1 -1
- package/dist/vue2/component-documentation.json +1 -1
- package/dist/vue2/dialtone-vue.cjs +2 -2
- package/dist/vue2/dialtone-vue.js +2 -2
- package/dist/vue2/dialtone-vue.js.map +1 -1
- package/dist/vue2/lib/badge.cjs +21 -1
- package/dist/vue2/lib/badge.cjs.map +1 -1
- package/dist/vue2/lib/badge.js +21 -1
- package/dist/vue2/lib/badge.js.map +1 -1
- package/dist/vue2/lib/contact-centers-row.cjs +1 -2
- package/dist/vue2/lib/contact-centers-row.cjs.map +1 -1
- package/dist/vue2/lib/contact-centers-row.js +1 -2
- package/dist/vue2/lib/contact-centers-row.js.map +1 -1
- package/dist/vue2/lib/contact-row.cjs +1 -2
- package/dist/vue2/lib/contact-row.cjs.map +1 -1
- package/dist/vue2/lib/contact-row.js +1 -2
- package/dist/vue2/lib/contact-row.js.map +1 -1
- package/dist/vue2/lib/editor.cjs +1 -2
- package/dist/vue2/lib/editor.cjs.map +1 -1
- package/dist/vue2/lib/editor.js +1 -2
- package/dist/vue2/lib/editor.js.map +1 -1
- package/dist/vue2/lib/emoji-row.cjs +1 -2
- package/dist/vue2/lib/emoji-row.cjs.map +1 -1
- package/dist/vue2/lib/emoji-row.js +1 -2
- package/dist/vue2/lib/emoji-row.js.map +1 -1
- package/dist/vue2/lib/emoji-text-wrapper.cjs +1 -2
- package/dist/vue2/lib/emoji-text-wrapper.cjs.map +1 -1
- package/dist/vue2/lib/emoji-text-wrapper.js +1 -2
- package/dist/vue2/lib/emoji-text-wrapper.js.map +1 -1
- package/dist/vue2/lib/emoji.cjs +1 -2
- package/dist/vue2/lib/emoji.cjs.map +1 -1
- package/dist/vue2/lib/emoji.js +1 -2
- package/dist/vue2/lib/emoji.js.map +1 -1
- package/dist/vue2/lib/general-row.cjs +3 -4
- package/dist/vue2/lib/general-row.cjs.map +1 -1
- package/dist/vue2/lib/general-row.js +3 -4
- package/dist/vue2/lib/general-row.js.map +1 -1
- package/dist/vue2/lib/group-row.cjs +1 -2
- package/dist/vue2/lib/group-row.cjs.map +1 -1
- package/dist/vue2/lib/group-row.js +1 -2
- package/dist/vue2/lib/group-row.js.map +1 -1
- package/dist/vue2/lib/message-input.cjs +1 -2
- package/dist/vue2/lib/message-input.cjs.map +1 -1
- package/dist/vue2/lib/message-input.js +1 -2
- package/dist/vue2/lib/message-input.js.map +1 -1
- package/dist/vue2/lib/rich-text-editor.cjs +11 -180
- package/dist/vue2/lib/rich-text-editor.cjs.map +1 -1
- package/dist/vue2/lib/rich-text-editor.js +11 -180
- package/dist/vue2/lib/rich-text-editor.js.map +1 -1
- package/dist/vue2/lib/tooltip.cjs +8 -7
- package/dist/vue2/lib/tooltip.cjs.map +1 -1
- package/dist/vue2/lib/tooltip.js +8 -7
- package/dist/vue2/lib/tooltip.js.map +1 -1
- package/dist/vue2/types/common/emoji/index.d.ts +3 -10
- package/dist/vue2/types/common/emoji/index.d.ts.map +1 -1
- package/dist/vue2/types/components/badge/badge.vue.d.ts +32 -0
- package/dist/vue2/types/components/badge/badge.vue.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/channels/channel.d.ts +0 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/channels/channel.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts +0 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/mentions/mention.d.ts +0 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/mention_suggestion.d.ts +2 -2
- package/dist/vue2/types/components/rich_text_editor/mention_suggestion.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts +0 -10
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
- package/dist/vue2/types/components/tooltip/tooltip.vue.d.ts +4 -2
- package/dist/vue2/types/components/tooltip/tooltip.vue.d.ts.map +1 -1
- package/dist/vue2/types/recipes/leftbar/general_row/general_row_constants.d.ts +1 -1
- package/dist/vue3/chunks/index-GVD15GIB.js +175 -0
- package/dist/vue3/chunks/index-GVD15GIB.js.map +1 -0
- package/dist/vue3/chunks/index-lu2o2f4r.js +169 -0
- package/dist/vue3/chunks/index-lu2o2f4r.js.map +1 -0
- package/dist/vue3/common/emoji.cjs +40 -163
- package/dist/vue3/common/emoji.cjs.map +1 -1
- package/dist/vue3/common/emoji.js +3 -146
- package/dist/vue3/common/emoji.js.map +1 -1
- package/dist/vue3/component-documentation.json +1 -1
- package/dist/vue3/dialtone-vue.cjs +2 -2
- package/dist/vue3/dialtone-vue.js +2 -2
- package/dist/vue3/dialtone-vue.js.map +1 -1
- package/dist/vue3/lib/badge.cjs +21 -1
- package/dist/vue3/lib/badge.cjs.map +1 -1
- package/dist/vue3/lib/badge.js +21 -1
- package/dist/vue3/lib/badge.js.map +1 -1
- package/dist/vue3/lib/contact-centers-row.cjs +1 -2
- package/dist/vue3/lib/contact-centers-row.cjs.map +1 -1
- package/dist/vue3/lib/contact-centers-row.js +1 -2
- package/dist/vue3/lib/contact-centers-row.js.map +1 -1
- package/dist/vue3/lib/contact-row.cjs +1 -2
- package/dist/vue3/lib/contact-row.cjs.map +1 -1
- package/dist/vue3/lib/contact-row.js +1 -2
- package/dist/vue3/lib/contact-row.js.map +1 -1
- package/dist/vue3/lib/editor.cjs +1 -2
- package/dist/vue3/lib/editor.cjs.map +1 -1
- package/dist/vue3/lib/editor.js +1 -2
- package/dist/vue3/lib/editor.js.map +1 -1
- package/dist/vue3/lib/emoji-row.cjs +1 -2
- package/dist/vue3/lib/emoji-row.cjs.map +1 -1
- package/dist/vue3/lib/emoji-row.js +1 -2
- package/dist/vue3/lib/emoji-row.js.map +1 -1
- package/dist/vue3/lib/emoji-text-wrapper.cjs +1 -2
- package/dist/vue3/lib/emoji-text-wrapper.cjs.map +1 -1
- package/dist/vue3/lib/emoji-text-wrapper.js +1 -2
- package/dist/vue3/lib/emoji-text-wrapper.js.map +1 -1
- package/dist/vue3/lib/emoji.cjs +1 -2
- package/dist/vue3/lib/emoji.cjs.map +1 -1
- package/dist/vue3/lib/emoji.js +1 -2
- package/dist/vue3/lib/emoji.js.map +1 -1
- package/dist/vue3/lib/general-row.cjs +3 -4
- package/dist/vue3/lib/general-row.cjs.map +1 -1
- package/dist/vue3/lib/general-row.js +3 -4
- package/dist/vue3/lib/general-row.js.map +1 -1
- package/dist/vue3/lib/group-row.cjs +1 -2
- package/dist/vue3/lib/group-row.cjs.map +1 -1
- package/dist/vue3/lib/group-row.js +1 -2
- package/dist/vue3/lib/group-row.js.map +1 -1
- package/dist/vue3/lib/message-input.cjs +1 -2
- package/dist/vue3/lib/message-input.cjs.map +1 -1
- package/dist/vue3/lib/message-input.js +1 -2
- package/dist/vue3/lib/message-input.js.map +1 -1
- package/dist/vue3/lib/rich-text-editor.cjs +11 -177
- package/dist/vue3/lib/rich-text-editor.cjs.map +1 -1
- package/dist/vue3/lib/rich-text-editor.js +11 -177
- package/dist/vue3/lib/rich-text-editor.js.map +1 -1
- package/dist/vue3/lib/tooltip.cjs +12 -15
- package/dist/vue3/lib/tooltip.cjs.map +1 -1
- package/dist/vue3/lib/tooltip.js +13 -16
- package/dist/vue3/lib/tooltip.js.map +1 -1
- package/dist/vue3/types/common/emoji/index.d.ts +1 -0
- package/dist/vue3/types/common/emoji/index.d.ts.map +1 -1
- package/dist/vue3/types/components/badge/badge.vue.d.ts +32 -0
- package/dist/vue3/types/components/badge/badge.vue.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/channels/channel.d.ts +0 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/channels/channel.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts +0 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/mentions/mention.d.ts +0 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/mention_suggestion.d.ts +2 -2
- package/dist/vue3/types/components/rich_text_editor/mention_suggestion.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts +0 -10
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
- package/dist/vue3/types/components/tooltip/tooltip.vue.d.ts +3 -4
- package/dist/vue3/types/components/tooltip/tooltip.vue.d.ts.map +1 -1
- package/dist/vue3/types/recipes/leftbar/general_row/general_row_constants.d.ts +1 -1
- package/package.json +3 -3
|
@@ -19,7 +19,7 @@ import { Node, mergeAttributes, nodeInputRule, nodePasteRule, getMarksBetween, c
|
|
|
19
19
|
import { resolveComponent, openBlock, createBlock, withCtx, createVNode, createElementBlock, withDirectives, createElementVNode, Fragment, renderList, normalizeClass, withModifiers, resolveDynamicComponent, vShow, createTextVNode, toDisplayString, markRaw, createCommentVNode } from "vue";
|
|
20
20
|
import { _export_sfc } from "../chunks/_plugin-vue_export-helper-caHeSgYY.js";
|
|
21
21
|
import { DtEmoji } from "./emoji.js";
|
|
22
|
-
import { codeToEmojiData, emojiShortCodeRegex } from "../
|
|
22
|
+
import { codeToEmojiData, emojiRegex, emojiPattern, emojiShortCodeRegex } from "../chunks/index-GVD15GIB.js";
|
|
23
23
|
import { PluginKey, Plugin } from "@tiptap/pm/state";
|
|
24
24
|
import Suggestion from "@tiptap/suggestion";
|
|
25
25
|
import { emojisIndexed } from "@dialpad/dialtone-emojis";
|
|
@@ -32,7 +32,6 @@ import { DtLink } from "./link.js";
|
|
|
32
32
|
import { DtAvatar } from "./avatar.js";
|
|
33
33
|
import DtIconHash from "@dialpad/dialtone-icons/vue3/hash";
|
|
34
34
|
import DtIconLock from "@dialpad/dialtone-icons/vue3/lock";
|
|
35
|
-
import emojiRegex from "emoji-regex";
|
|
36
35
|
import "./skeleton.js";
|
|
37
36
|
import "../chunks/icon_constants-Dy4MEUJL.js";
|
|
38
37
|
import "@dialpad/dialtone-icons/icons.json";
|
|
@@ -232,7 +231,7 @@ const suggestionOptions = {
|
|
|
232
231
|
return false;
|
|
233
232
|
});
|
|
234
233
|
return filteredEmoji.map((item) => {
|
|
235
|
-
return {
|
|
234
|
+
return { code: item.shortname };
|
|
236
235
|
});
|
|
237
236
|
},
|
|
238
237
|
command: ({ editor, range, props }) => {
|
|
@@ -278,7 +277,6 @@ const suggestionOptions = {
|
|
|
278
277
|
interactive: true,
|
|
279
278
|
trigger: "manual",
|
|
280
279
|
placement: "top-start",
|
|
281
|
-
contentElement: null,
|
|
282
280
|
zIndex: 650
|
|
283
281
|
});
|
|
284
282
|
},
|
|
@@ -308,8 +306,7 @@ const suggestionOptions = {
|
|
|
308
306
|
};
|
|
309
307
|
const EmojiPluginKey = new PluginKey("emoji");
|
|
310
308
|
const inputShortCodeRegex = new RegExp("(^| |(?<=:))(:\\w+:)$");
|
|
311
|
-
const inputUnicodeRegex =
|
|
312
|
-
const pasteUnicodeRegex = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
|
|
309
|
+
const inputUnicodeRegex = new RegExp(emojiPattern + "$");
|
|
313
310
|
const inputRuleMatch = (match) => {
|
|
314
311
|
if (match && codeToEmojiData(match[0])) {
|
|
315
312
|
const text = match[2] || match[0];
|
|
@@ -349,9 +346,6 @@ const Emoji = Node.create({
|
|
|
349
346
|
return {
|
|
350
347
|
code: {
|
|
351
348
|
default: null
|
|
352
|
-
},
|
|
353
|
-
id: {
|
|
354
|
-
default: null
|
|
355
349
|
}
|
|
356
350
|
};
|
|
357
351
|
},
|
|
@@ -394,11 +388,9 @@ const Emoji = Node.create({
|
|
|
394
388
|
},
|
|
395
389
|
type: this.type,
|
|
396
390
|
getAttributes(attrs) {
|
|
397
|
-
const
|
|
398
|
-
const emoji = String.fromCodePoint(parseInt(unicode, 16));
|
|
391
|
+
const emoji = codeToEmojiData(attrs[0]).shortname;
|
|
399
392
|
return {
|
|
400
|
-
code: emoji
|
|
401
|
-
label: "emoji"
|
|
393
|
+
code: emoji
|
|
402
394
|
};
|
|
403
395
|
}
|
|
404
396
|
})
|
|
@@ -416,7 +408,7 @@ const Emoji = Node.create({
|
|
|
416
408
|
}
|
|
417
409
|
}),
|
|
418
410
|
nodePasteRule({
|
|
419
|
-
find:
|
|
411
|
+
find: emojiRegex,
|
|
420
412
|
type: this.type,
|
|
421
413
|
getAttributes(attrs) {
|
|
422
414
|
return {
|
|
@@ -626,30 +618,6 @@ function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
626
618
|
});
|
|
627
619
|
}
|
|
628
620
|
const MentionComponent = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
|
|
629
|
-
const mentionRegex = /@([\w.-]+)[^\w.-]?/g;
|
|
630
|
-
const mentionPasteMatch = (text, suggestions) => {
|
|
631
|
-
const matches = [...text.matchAll(mentionRegex)];
|
|
632
|
-
return matches.filter((match) => suggestions.some(({ id }) => id === match[1].trim())).map((match) => {
|
|
633
|
-
let mention = match[1];
|
|
634
|
-
if (!mention.endsWith(" "))
|
|
635
|
-
mention += " ";
|
|
636
|
-
return {
|
|
637
|
-
index: match.index,
|
|
638
|
-
text: mention,
|
|
639
|
-
match
|
|
640
|
-
};
|
|
641
|
-
});
|
|
642
|
-
};
|
|
643
|
-
const mentionInputMatch = (text, suggestions) => {
|
|
644
|
-
const match = text.match(/@([\w.-]+)[^\w.-]$/);
|
|
645
|
-
if (!match || !suggestions.some(({ id }) => id === match[1]))
|
|
646
|
-
return;
|
|
647
|
-
return {
|
|
648
|
-
index: match.index,
|
|
649
|
-
text: match[0],
|
|
650
|
-
match
|
|
651
|
-
};
|
|
652
|
-
};
|
|
653
621
|
const MentionPlugin = Mention.extend({
|
|
654
622
|
addNodeView() {
|
|
655
623
|
return VueNodeViewRenderer(MentionComponent);
|
|
@@ -678,33 +646,7 @@ const MentionPlugin = Mention.extend({
|
|
|
678
646
|
return `@${node.attrs.id}`;
|
|
679
647
|
},
|
|
680
648
|
renderHTML({ HTMLAttributes }) {
|
|
681
|
-
return ["mention-component", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
682
|
-
},
|
|
683
|
-
addInputRules() {
|
|
684
|
-
var _a;
|
|
685
|
-
const suggestions = (_a = this.options.suggestion) == null ? void 0 : _a.items({ query: "" });
|
|
686
|
-
return [
|
|
687
|
-
nodeInputRule({
|
|
688
|
-
find: (text) => mentionInputMatch(text, suggestions),
|
|
689
|
-
type: this.type,
|
|
690
|
-
getAttributes(attrs) {
|
|
691
|
-
return suggestions.find(({ id }) => id === attrs[0].replace("@", "").trim());
|
|
692
|
-
}
|
|
693
|
-
})
|
|
694
|
-
];
|
|
695
|
-
},
|
|
696
|
-
addPasteRules() {
|
|
697
|
-
var _a;
|
|
698
|
-
const suggestions = (_a = this.options.suggestion) == null ? void 0 : _a.items({ query: "" });
|
|
699
|
-
return [
|
|
700
|
-
nodePasteRule({
|
|
701
|
-
find: (text) => mentionPasteMatch(text, suggestions),
|
|
702
|
-
type: this.type,
|
|
703
|
-
getAttributes(attrs) {
|
|
704
|
-
return suggestions.find(({ id }) => id === attrs[0].trim());
|
|
705
|
-
}
|
|
706
|
-
})
|
|
707
|
-
];
|
|
649
|
+
return ["mention-component", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
708
650
|
}
|
|
709
651
|
}).configure({
|
|
710
652
|
suggestion: {
|
|
@@ -741,34 +683,8 @@ function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
741
683
|
});
|
|
742
684
|
}
|
|
743
685
|
const ChannelComponent = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
744
|
-
const channelRegex = /#([\w-]+)[^\w-]?/g;
|
|
745
|
-
const channelPasteMatch = (text, suggestions) => {
|
|
746
|
-
const matches = [...text.matchAll(channelRegex)];
|
|
747
|
-
return matches.filter((match) => suggestions.some(({ id }) => id === match[1].trim())).map((match) => {
|
|
748
|
-
let channel = match[1];
|
|
749
|
-
if (!channel.endsWith(" "))
|
|
750
|
-
channel += " ";
|
|
751
|
-
return {
|
|
752
|
-
index: match.index,
|
|
753
|
-
text: channel,
|
|
754
|
-
match
|
|
755
|
-
};
|
|
756
|
-
});
|
|
757
|
-
};
|
|
758
|
-
const channelInputMatch = (text, suggestions) => {
|
|
759
|
-
const match = text.match(/#([\w-]+)[^\w-]$/);
|
|
760
|
-
if (!match || !suggestions.some(({ id }) => id === match[1]))
|
|
761
|
-
return;
|
|
762
|
-
return {
|
|
763
|
-
index: match.index,
|
|
764
|
-
text: match[0],
|
|
765
|
-
match
|
|
766
|
-
};
|
|
767
|
-
};
|
|
768
686
|
const ChannelPlugin = Mention.extend({
|
|
769
687
|
name: "channel",
|
|
770
|
-
group: "inline",
|
|
771
|
-
inline: true,
|
|
772
688
|
addNodeView() {
|
|
773
689
|
return VueNodeViewRenderer(ChannelComponent);
|
|
774
690
|
},
|
|
@@ -796,33 +712,7 @@ const ChannelPlugin = Mention.extend({
|
|
|
796
712
|
return `#${node.attrs.id}`;
|
|
797
713
|
},
|
|
798
714
|
renderHTML({ HTMLAttributes }) {
|
|
799
|
-
return ["channel-component", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
|
|
800
|
-
},
|
|
801
|
-
addInputRules() {
|
|
802
|
-
var _a;
|
|
803
|
-
const suggestions = (_a = this.options.suggestion) == null ? void 0 : _a.items({ query: "" });
|
|
804
|
-
return [
|
|
805
|
-
nodeInputRule({
|
|
806
|
-
find: (text) => channelInputMatch(text, suggestions),
|
|
807
|
-
type: this.type,
|
|
808
|
-
getAttributes(attrs) {
|
|
809
|
-
return suggestions.find(({ id }) => id === attrs[0].replace("#", "").trim());
|
|
810
|
-
}
|
|
811
|
-
})
|
|
812
|
-
];
|
|
813
|
-
},
|
|
814
|
-
addPasteRules() {
|
|
815
|
-
var _a;
|
|
816
|
-
const suggestions = (_a = this.options.suggestion) == null ? void 0 : _a.items({ query: "" });
|
|
817
|
-
return [
|
|
818
|
-
nodePasteRule({
|
|
819
|
-
find: (text) => channelPasteMatch(text, suggestions),
|
|
820
|
-
type: this.type,
|
|
821
|
-
getAttributes(attrs) {
|
|
822
|
-
return suggestions.find(({ id }) => id === attrs[0].trim());
|
|
823
|
-
}
|
|
824
|
-
})
|
|
825
|
-
];
|
|
715
|
+
return ["channel-component", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
826
716
|
}
|
|
827
717
|
}).configure({
|
|
828
718
|
suggestion: {
|
|
@@ -1306,7 +1196,7 @@ const _sfc_main = {
|
|
|
1306
1196
|
*/
|
|
1307
1197
|
outputFormat: {
|
|
1308
1198
|
type: String,
|
|
1309
|
-
default: "
|
|
1199
|
+
default: "html",
|
|
1310
1200
|
validator(outputFormat) {
|
|
1311
1201
|
return RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(outputFormat);
|
|
1312
1202
|
}
|
|
@@ -1606,8 +1496,7 @@ const _sfc_main = {
|
|
|
1606
1496
|
if (newValue === currentValue) {
|
|
1607
1497
|
return;
|
|
1608
1498
|
}
|
|
1609
|
-
this.
|
|
1610
|
-
this.insertContent();
|
|
1499
|
+
this.editor.commands.setContent(newValue, false);
|
|
1611
1500
|
}
|
|
1612
1501
|
},
|
|
1613
1502
|
created() {
|
|
@@ -1623,6 +1512,7 @@ const _sfc_main = {
|
|
|
1623
1512
|
createEditor() {
|
|
1624
1513
|
this.editor = new Editor({
|
|
1625
1514
|
autofocus: this.autoFocus,
|
|
1515
|
+
content: this.modelValue,
|
|
1626
1516
|
editable: this.editable,
|
|
1627
1517
|
extensions: this.extensions,
|
|
1628
1518
|
editorProps: {
|
|
@@ -1632,64 +1522,8 @@ const _sfc_main = {
|
|
|
1632
1522
|
}
|
|
1633
1523
|
}
|
|
1634
1524
|
});
|
|
1635
|
-
this.insertContent();
|
|
1636
1525
|
this.addEditorListeners();
|
|
1637
1526
|
},
|
|
1638
|
-
/**
|
|
1639
|
-
* This function is necessary as tiptap doesn't render the content passed
|
|
1640
|
-
* directly through `editor.commands.setContent` the content passed down to it
|
|
1641
|
-
* should be already parsed. So We're parsing the elements into it's corresponding
|
|
1642
|
-
* HTML version before setting it.
|
|
1643
|
-
*/
|
|
1644
|
-
insertContent() {
|
|
1645
|
-
this.parseMentions();
|
|
1646
|
-
this.parseChannels();
|
|
1647
|
-
this.parseEmojis();
|
|
1648
|
-
this.editor.commands.setContent(this.internalValue, true);
|
|
1649
|
-
},
|
|
1650
|
-
parseEmojis() {
|
|
1651
|
-
const matches = new Set(
|
|
1652
|
-
[...this.modelValue.matchAll(emojiRegex()), ...this.modelValue.matchAll(emojiShortCodeRegex)].map((match) => match[0].trim())
|
|
1653
|
-
);
|
|
1654
|
-
if (!matches)
|
|
1655
|
-
return;
|
|
1656
|
-
matches.forEach((match) => {
|
|
1657
|
-
const emoji = codeToEmojiData(match);
|
|
1658
|
-
if (!emoji)
|
|
1659
|
-
return;
|
|
1660
|
-
this.internalValue = this.internalValue.replace(new RegExp(`${match}`, "g"), `<emoji-component code="${emoji.shortname}"></emoji-component>`);
|
|
1661
|
-
});
|
|
1662
|
-
},
|
|
1663
|
-
parseChannels() {
|
|
1664
|
-
if (!this.channelSuggestion)
|
|
1665
|
-
return;
|
|
1666
|
-
const suggestions = this.channelSuggestion.items({ query: "" });
|
|
1667
|
-
const matches = [...this.modelValue.matchAll(channelRegex)].filter((match) => suggestions.some(({ id }) => id === match[1]));
|
|
1668
|
-
if (!matches)
|
|
1669
|
-
return;
|
|
1670
|
-
matches.forEach((match) => {
|
|
1671
|
-
const channel = suggestions.find(({ id }) => id === match[1]);
|
|
1672
|
-
this.internalValue = this.internalValue.replace(
|
|
1673
|
-
`#${match[1]}`,
|
|
1674
|
-
/** The space at the beginning is important as tiptap removes that while rendering.
|
|
1675
|
-
* So if multiple mentions, channels or emojis are next to each other it will fail
|
|
1676
|
-
*/
|
|
1677
|
-
` <channel-component name="${channel.name}" id="${channel.id}"></channel-component>`
|
|
1678
|
-
);
|
|
1679
|
-
});
|
|
1680
|
-
},
|
|
1681
|
-
parseMentions() {
|
|
1682
|
-
if (!this.mentionSuggestion)
|
|
1683
|
-
return;
|
|
1684
|
-
const suggestions = this.mentionSuggestion.items({ query: "" });
|
|
1685
|
-
const matches = [...this.modelValue.matchAll(mentionRegex)].filter((match) => suggestions.some(({ id }) => id === match[1]));
|
|
1686
|
-
if (!matches)
|
|
1687
|
-
return;
|
|
1688
|
-
matches.forEach((match) => {
|
|
1689
|
-
const mention = suggestions.find(({ id }) => id === match[1]);
|
|
1690
|
-
this.internalValue = this.internalValue.replace(`@${match[1]}`, ` <mention-component name="${mention.name}" id="${mention.id}"></mention-component>`);
|
|
1691
|
-
});
|
|
1692
|
-
},
|
|
1693
1527
|
destroyEditor() {
|
|
1694
1528
|
this.editor.destroy();
|
|
1695
1529
|
},
|