@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
|
@@ -18,7 +18,7 @@ import TextAlign from "@tiptap/extension-text-align";
|
|
|
18
18
|
import { Node, mergeAttributes, nodeInputRule, nodePasteRule, getMarksBetween, combineTransactionSteps, getChangedRanges, findChildrenInRange, Mark } from "@tiptap/core";
|
|
19
19
|
import { normalizeComponent } from "../chunks/_plugin-vue2_normalizer-sOSkiPF3.js";
|
|
20
20
|
import { DtEmoji } from "./emoji.js";
|
|
21
|
-
import { codeToEmojiData, emojiShortCodeRegex } from "../
|
|
21
|
+
import { codeToEmojiData, emojiRegex, emojiPattern, emojiShortCodeRegex } from "../chunks/index-ODod4Oj_.js";
|
|
22
22
|
import { PluginKey, Plugin } from "@tiptap/pm/state";
|
|
23
23
|
import Suggestion from "@tiptap/suggestion";
|
|
24
24
|
import { emojisIndexed } from "@dialpad/dialtone-emojis";
|
|
@@ -31,7 +31,6 @@ import { DtLink } from "./link.js";
|
|
|
31
31
|
import { DtAvatar } from "./avatar.js";
|
|
32
32
|
import DtIconHash from "@dialpad/dialtone-icons/vue2/hash";
|
|
33
33
|
import DtIconLock from "@dialpad/dialtone-icons/vue2/lock";
|
|
34
|
-
import emojiRegex from "emoji-regex";
|
|
35
34
|
import "./skeleton.js";
|
|
36
35
|
import "../chunks/icon_constants-Dy4MEUJL.js";
|
|
37
36
|
import "@dialpad/dialtone-icons/icons.json";
|
|
@@ -228,7 +227,7 @@ const suggestionOptions = {
|
|
|
228
227
|
return false;
|
|
229
228
|
});
|
|
230
229
|
return filteredEmoji.map((item) => {
|
|
231
|
-
return {
|
|
230
|
+
return { code: item.shortname };
|
|
232
231
|
});
|
|
233
232
|
},
|
|
234
233
|
command: ({ editor, range, props }) => {
|
|
@@ -275,7 +274,6 @@ const suggestionOptions = {
|
|
|
275
274
|
interactive: true,
|
|
276
275
|
trigger: "manual",
|
|
277
276
|
placement: "top-start",
|
|
278
|
-
contentElement: null,
|
|
279
277
|
zIndex: 650
|
|
280
278
|
});
|
|
281
279
|
},
|
|
@@ -305,8 +303,7 @@ const suggestionOptions = {
|
|
|
305
303
|
};
|
|
306
304
|
const EmojiPluginKey = new PluginKey("emoji");
|
|
307
305
|
const inputShortCodeRegex = new RegExp("(^| |(?<=:))(:\\w+:)$");
|
|
308
|
-
const inputUnicodeRegex =
|
|
309
|
-
const pasteUnicodeRegex = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g;
|
|
306
|
+
const inputUnicodeRegex = new RegExp(emojiPattern + "$");
|
|
310
307
|
const inputRuleMatch = (match) => {
|
|
311
308
|
if (match && codeToEmojiData(match[0])) {
|
|
312
309
|
const text = match[2] || match[0];
|
|
@@ -346,9 +343,6 @@ const Emoji = Node.create({
|
|
|
346
343
|
return {
|
|
347
344
|
code: {
|
|
348
345
|
default: null
|
|
349
|
-
},
|
|
350
|
-
id: {
|
|
351
|
-
default: null
|
|
352
346
|
}
|
|
353
347
|
};
|
|
354
348
|
},
|
|
@@ -391,11 +385,9 @@ const Emoji = Node.create({
|
|
|
391
385
|
},
|
|
392
386
|
type: this.type,
|
|
393
387
|
getAttributes(attrs) {
|
|
394
|
-
const
|
|
395
|
-
const emoji = String.fromCodePoint(parseInt(unicode, 16));
|
|
388
|
+
const emoji = codeToEmojiData(attrs[0]).shortname;
|
|
396
389
|
return {
|
|
397
|
-
code: emoji
|
|
398
|
-
label: "emoji"
|
|
390
|
+
code: emoji
|
|
399
391
|
};
|
|
400
392
|
}
|
|
401
393
|
})
|
|
@@ -413,7 +405,7 @@ const Emoji = Node.create({
|
|
|
413
405
|
}
|
|
414
406
|
}),
|
|
415
407
|
nodePasteRule({
|
|
416
|
-
find:
|
|
408
|
+
find: emojiRegex,
|
|
417
409
|
type: this.type,
|
|
418
410
|
getAttributes(attrs) {
|
|
419
411
|
return {
|
|
@@ -623,34 +615,7 @@ var __component__$6 = /* @__PURE__ */ normalizeComponent(
|
|
|
623
615
|
null
|
|
624
616
|
);
|
|
625
617
|
const MentionComponent = __component__$6.exports;
|
|
626
|
-
const mentionRegex = /@([\w.-]+)[^\w.-]?/g;
|
|
627
|
-
const mentionPasteMatch = (text, suggestions) => {
|
|
628
|
-
const matches = [...text.matchAll(mentionRegex)];
|
|
629
|
-
return matches.filter((match) => suggestions.some(({ id }) => id === match[1].trim())).map((match) => {
|
|
630
|
-
let mention = match[1];
|
|
631
|
-
if (!mention.endsWith(" "))
|
|
632
|
-
mention += " ";
|
|
633
|
-
return {
|
|
634
|
-
index: match.index,
|
|
635
|
-
text: mention,
|
|
636
|
-
match
|
|
637
|
-
};
|
|
638
|
-
});
|
|
639
|
-
};
|
|
640
|
-
const mentionInputMatch = (text, suggestions) => {
|
|
641
|
-
const match = text.match(/@([\w.-]+)[^\w.-]$/);
|
|
642
|
-
if (!match || !suggestions.some(({ id }) => id === match[1]))
|
|
643
|
-
return;
|
|
644
|
-
return {
|
|
645
|
-
index: match.index,
|
|
646
|
-
text: match[0],
|
|
647
|
-
match
|
|
648
|
-
};
|
|
649
|
-
};
|
|
650
618
|
const MentionPlugin = Mention.extend({
|
|
651
|
-
name: "mention",
|
|
652
|
-
group: "inline",
|
|
653
|
-
inline: true,
|
|
654
619
|
addNodeView() {
|
|
655
620
|
return VueNodeViewRenderer(MentionComponent);
|
|
656
621
|
},
|
|
@@ -678,33 +643,7 @@ const MentionPlugin = Mention.extend({
|
|
|
678
643
|
return `@${node.attrs.id}`;
|
|
679
644
|
},
|
|
680
645
|
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
|
-
];
|
|
646
|
+
return ["mention-component", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
708
647
|
}
|
|
709
648
|
}).configure({
|
|
710
649
|
suggestion: {
|
|
@@ -741,34 +680,8 @@ var __component__$5 = /* @__PURE__ */ normalizeComponent(
|
|
|
741
680
|
null
|
|
742
681
|
);
|
|
743
682
|
const ChannelComponent = __component__$5.exports;
|
|
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
683
|
const ChannelPlugin = Mention.extend({
|
|
769
684
|
name: "channel",
|
|
770
|
-
group: "inline",
|
|
771
|
-
inline: true,
|
|
772
685
|
addNodeView() {
|
|
773
686
|
return VueNodeViewRenderer(ChannelComponent);
|
|
774
687
|
},
|
|
@@ -796,33 +709,7 @@ const ChannelPlugin = Mention.extend({
|
|
|
796
709
|
return `#${node.attrs.id}`;
|
|
797
710
|
},
|
|
798
711
|
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
|
-
];
|
|
712
|
+
return ["channel-component", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
826
713
|
}
|
|
827
714
|
}).configure({
|
|
828
715
|
suggestion: {
|
|
@@ -1307,7 +1194,7 @@ const _sfc_main = {
|
|
|
1307
1194
|
*/
|
|
1308
1195
|
outputFormat: {
|
|
1309
1196
|
type: String,
|
|
1310
|
-
default: "
|
|
1197
|
+
default: "html",
|
|
1311
1198
|
validator(outputFormat) {
|
|
1312
1199
|
return RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(outputFormat);
|
|
1313
1200
|
}
|
|
@@ -1607,8 +1494,7 @@ const _sfc_main = {
|
|
|
1607
1494
|
if (newValue === currentValue) {
|
|
1608
1495
|
return;
|
|
1609
1496
|
}
|
|
1610
|
-
this.
|
|
1611
|
-
this.insertContent();
|
|
1497
|
+
this.editor.commands.setContent(newValue, false);
|
|
1612
1498
|
}
|
|
1613
1499
|
},
|
|
1614
1500
|
created() {
|
|
@@ -1624,6 +1510,7 @@ const _sfc_main = {
|
|
|
1624
1510
|
createEditor() {
|
|
1625
1511
|
this.editor = new Editor({
|
|
1626
1512
|
autofocus: this.autoFocus,
|
|
1513
|
+
content: this.value,
|
|
1627
1514
|
editable: this.editable,
|
|
1628
1515
|
extensions: this.extensions,
|
|
1629
1516
|
editorProps: {
|
|
@@ -1633,64 +1520,8 @@ const _sfc_main = {
|
|
|
1633
1520
|
}
|
|
1634
1521
|
}
|
|
1635
1522
|
});
|
|
1636
|
-
this.insertContent();
|
|
1637
1523
|
this.addEditorListeners();
|
|
1638
1524
|
},
|
|
1639
|
-
/**
|
|
1640
|
-
* This function is necessary as tiptap doesn't render the content passed
|
|
1641
|
-
* directly through `editor.commands.setContent` the content passed down to it
|
|
1642
|
-
* should be already parsed. So We're parsing the elements into it's corresponding
|
|
1643
|
-
* HTML version before setting it.
|
|
1644
|
-
*/
|
|
1645
|
-
insertContent() {
|
|
1646
|
-
this.parseMentions();
|
|
1647
|
-
this.parseChannels();
|
|
1648
|
-
this.parseEmojis();
|
|
1649
|
-
this.editor.commands.setContent(this.internalValue, true);
|
|
1650
|
-
},
|
|
1651
|
-
parseEmojis() {
|
|
1652
|
-
const matches = new Set(
|
|
1653
|
-
[...this.value.matchAll(emojiRegex()), ...this.value.matchAll(emojiShortCodeRegex)].map((match) => match[0].trim())
|
|
1654
|
-
);
|
|
1655
|
-
if (!matches)
|
|
1656
|
-
return;
|
|
1657
|
-
matches.forEach((match) => {
|
|
1658
|
-
const emoji = codeToEmojiData(match);
|
|
1659
|
-
if (!emoji)
|
|
1660
|
-
return;
|
|
1661
|
-
this.internalValue = this.internalValue.replace(new RegExp(`${match}`, "g"), `<emoji-component code="${emoji.shortname}"></emoji-component>`);
|
|
1662
|
-
});
|
|
1663
|
-
},
|
|
1664
|
-
parseChannels() {
|
|
1665
|
-
if (!this.channelSuggestion)
|
|
1666
|
-
return;
|
|
1667
|
-
const suggestions = this.channelSuggestion.items({ query: "" });
|
|
1668
|
-
const matches = [...this.value.matchAll(channelRegex)].filter((match) => suggestions.some(({ id }) => id === match[1]));
|
|
1669
|
-
if (!matches)
|
|
1670
|
-
return;
|
|
1671
|
-
matches.forEach((match) => {
|
|
1672
|
-
const channel = suggestions.find(({ id }) => id === match[1]);
|
|
1673
|
-
this.internalValue = this.internalValue.replace(
|
|
1674
|
-
`#${match[1]}`,
|
|
1675
|
-
/** The space at the beginning is important as tiptap removes that while rendering.
|
|
1676
|
-
* So if multiple mentions, channels or emojis are next to each other it will fail
|
|
1677
|
-
*/
|
|
1678
|
-
` <channel-component name="${channel.name}" id="${channel.id}"></channel-component>`
|
|
1679
|
-
);
|
|
1680
|
-
});
|
|
1681
|
-
},
|
|
1682
|
-
parseMentions() {
|
|
1683
|
-
if (!this.mentionSuggestion)
|
|
1684
|
-
return;
|
|
1685
|
-
const suggestions = this.mentionSuggestion.items({ query: "" });
|
|
1686
|
-
const matches = [...this.value.matchAll(mentionRegex)].filter((match) => suggestions.some(({ id }) => id === match[1]));
|
|
1687
|
-
if (!matches)
|
|
1688
|
-
return;
|
|
1689
|
-
matches.forEach((match) => {
|
|
1690
|
-
const mention = suggestions.find(({ id }) => id === match[1]);
|
|
1691
|
-
this.internalValue = this.internalValue.replace(`@${match[1]}`, ` <mention-component name="${mention.name}" id="${mention.id}"></mention-component>`);
|
|
1692
|
-
});
|
|
1693
|
-
},
|
|
1694
1525
|
destroyEditor() {
|
|
1695
1526
|
this.editor.destroy();
|
|
1696
1527
|
},
|