@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.
Files changed (176) hide show
  1. package/README.md +19 -1
  2. package/dist/css/dialtone.css +15 -2
  3. package/dist/css/dialtone.min.css +1 -1
  4. package/dist/tokens/css/variables-dark.css +1 -1
  5. package/dist/tokens/css/variables-expressive-dark.css +1 -1
  6. package/dist/tokens/css/variables-expressive-light.css +1 -1
  7. package/dist/tokens/css/variables-expressive-sm-dark.css +1 -1
  8. package/dist/tokens/css/variables-expressive-sm-light.css +1 -1
  9. package/dist/tokens/css/variables-light.css +1 -1
  10. package/dist/tokens/css/variables-tmo-dark.css +1 -1
  11. package/dist/tokens/css/variables-tmo-light.css +1 -1
  12. package/dist/tokens/less/variables-dark.less +1 -1
  13. package/dist/tokens/less/variables-expressive-dark.less +1 -1
  14. package/dist/tokens/less/variables-expressive-light.less +1 -1
  15. package/dist/tokens/less/variables-expressive-sm-dark.less +1 -1
  16. package/dist/tokens/less/variables-expressive-sm-light.less +1 -1
  17. package/dist/tokens/less/variables-light.less +1 -1
  18. package/dist/tokens/less/variables-tmo-dark.less +1 -1
  19. package/dist/tokens/less/variables-tmo-light.less +1 -1
  20. package/dist/vue2/chunks/index-ODod4Oj_.js +175 -0
  21. package/dist/vue2/chunks/index-ODod4Oj_.js.map +1 -0
  22. package/dist/vue2/chunks/index-anN_sx1F.js +169 -0
  23. package/dist/vue2/chunks/index-anN_sx1F.js.map +1 -0
  24. package/dist/vue2/common/emoji.cjs +40 -163
  25. package/dist/vue2/common/emoji.cjs.map +1 -1
  26. package/dist/vue2/common/emoji.js +3 -146
  27. package/dist/vue2/common/emoji.js.map +1 -1
  28. package/dist/vue2/component-documentation.json +1 -1
  29. package/dist/vue2/dialtone-vue.cjs +2 -2
  30. package/dist/vue2/dialtone-vue.js +2 -2
  31. package/dist/vue2/dialtone-vue.js.map +1 -1
  32. package/dist/vue2/lib/badge.cjs +21 -1
  33. package/dist/vue2/lib/badge.cjs.map +1 -1
  34. package/dist/vue2/lib/badge.js +21 -1
  35. package/dist/vue2/lib/badge.js.map +1 -1
  36. package/dist/vue2/lib/contact-centers-row.cjs +1 -2
  37. package/dist/vue2/lib/contact-centers-row.cjs.map +1 -1
  38. package/dist/vue2/lib/contact-centers-row.js +1 -2
  39. package/dist/vue2/lib/contact-centers-row.js.map +1 -1
  40. package/dist/vue2/lib/contact-row.cjs +1 -2
  41. package/dist/vue2/lib/contact-row.cjs.map +1 -1
  42. package/dist/vue2/lib/contact-row.js +1 -2
  43. package/dist/vue2/lib/contact-row.js.map +1 -1
  44. package/dist/vue2/lib/editor.cjs +1 -2
  45. package/dist/vue2/lib/editor.cjs.map +1 -1
  46. package/dist/vue2/lib/editor.js +1 -2
  47. package/dist/vue2/lib/editor.js.map +1 -1
  48. package/dist/vue2/lib/emoji-row.cjs +1 -2
  49. package/dist/vue2/lib/emoji-row.cjs.map +1 -1
  50. package/dist/vue2/lib/emoji-row.js +1 -2
  51. package/dist/vue2/lib/emoji-row.js.map +1 -1
  52. package/dist/vue2/lib/emoji-text-wrapper.cjs +1 -2
  53. package/dist/vue2/lib/emoji-text-wrapper.cjs.map +1 -1
  54. package/dist/vue2/lib/emoji-text-wrapper.js +1 -2
  55. package/dist/vue2/lib/emoji-text-wrapper.js.map +1 -1
  56. package/dist/vue2/lib/emoji.cjs +1 -2
  57. package/dist/vue2/lib/emoji.cjs.map +1 -1
  58. package/dist/vue2/lib/emoji.js +1 -2
  59. package/dist/vue2/lib/emoji.js.map +1 -1
  60. package/dist/vue2/lib/general-row.cjs +3 -4
  61. package/dist/vue2/lib/general-row.cjs.map +1 -1
  62. package/dist/vue2/lib/general-row.js +3 -4
  63. package/dist/vue2/lib/general-row.js.map +1 -1
  64. package/dist/vue2/lib/group-row.cjs +1 -2
  65. package/dist/vue2/lib/group-row.cjs.map +1 -1
  66. package/dist/vue2/lib/group-row.js +1 -2
  67. package/dist/vue2/lib/group-row.js.map +1 -1
  68. package/dist/vue2/lib/message-input.cjs +1 -2
  69. package/dist/vue2/lib/message-input.cjs.map +1 -1
  70. package/dist/vue2/lib/message-input.js +1 -2
  71. package/dist/vue2/lib/message-input.js.map +1 -1
  72. package/dist/vue2/lib/rich-text-editor.cjs +11 -180
  73. package/dist/vue2/lib/rich-text-editor.cjs.map +1 -1
  74. package/dist/vue2/lib/rich-text-editor.js +11 -180
  75. package/dist/vue2/lib/rich-text-editor.js.map +1 -1
  76. package/dist/vue2/lib/tooltip.cjs +8 -7
  77. package/dist/vue2/lib/tooltip.cjs.map +1 -1
  78. package/dist/vue2/lib/tooltip.js +8 -7
  79. package/dist/vue2/lib/tooltip.js.map +1 -1
  80. package/dist/vue2/types/common/emoji/index.d.ts +3 -10
  81. package/dist/vue2/types/common/emoji/index.d.ts.map +1 -1
  82. package/dist/vue2/types/components/badge/badge.vue.d.ts +32 -0
  83. package/dist/vue2/types/components/badge/badge.vue.d.ts.map +1 -1
  84. package/dist/vue2/types/components/rich_text_editor/extensions/channels/channel.d.ts +0 -1
  85. package/dist/vue2/types/components/rich_text_editor/extensions/channels/channel.d.ts.map +1 -1
  86. package/dist/vue2/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
  87. package/dist/vue2/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts +0 -1
  88. package/dist/vue2/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
  89. package/dist/vue2/types/components/rich_text_editor/extensions/mentions/mention.d.ts +0 -1
  90. package/dist/vue2/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
  91. package/dist/vue2/types/components/rich_text_editor/mention_suggestion.d.ts +2 -2
  92. package/dist/vue2/types/components/rich_text_editor/mention_suggestion.d.ts.map +1 -1
  93. package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts +0 -10
  94. package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
  95. package/dist/vue2/types/components/tooltip/tooltip.vue.d.ts +4 -2
  96. package/dist/vue2/types/components/tooltip/tooltip.vue.d.ts.map +1 -1
  97. package/dist/vue2/types/recipes/leftbar/general_row/general_row_constants.d.ts +1 -1
  98. package/dist/vue3/chunks/index-GVD15GIB.js +175 -0
  99. package/dist/vue3/chunks/index-GVD15GIB.js.map +1 -0
  100. package/dist/vue3/chunks/index-lu2o2f4r.js +169 -0
  101. package/dist/vue3/chunks/index-lu2o2f4r.js.map +1 -0
  102. package/dist/vue3/common/emoji.cjs +40 -163
  103. package/dist/vue3/common/emoji.cjs.map +1 -1
  104. package/dist/vue3/common/emoji.js +3 -146
  105. package/dist/vue3/common/emoji.js.map +1 -1
  106. package/dist/vue3/component-documentation.json +1 -1
  107. package/dist/vue3/dialtone-vue.cjs +2 -2
  108. package/dist/vue3/dialtone-vue.js +2 -2
  109. package/dist/vue3/dialtone-vue.js.map +1 -1
  110. package/dist/vue3/lib/badge.cjs +21 -1
  111. package/dist/vue3/lib/badge.cjs.map +1 -1
  112. package/dist/vue3/lib/badge.js +21 -1
  113. package/dist/vue3/lib/badge.js.map +1 -1
  114. package/dist/vue3/lib/contact-centers-row.cjs +1 -2
  115. package/dist/vue3/lib/contact-centers-row.cjs.map +1 -1
  116. package/dist/vue3/lib/contact-centers-row.js +1 -2
  117. package/dist/vue3/lib/contact-centers-row.js.map +1 -1
  118. package/dist/vue3/lib/contact-row.cjs +1 -2
  119. package/dist/vue3/lib/contact-row.cjs.map +1 -1
  120. package/dist/vue3/lib/contact-row.js +1 -2
  121. package/dist/vue3/lib/contact-row.js.map +1 -1
  122. package/dist/vue3/lib/editor.cjs +1 -2
  123. package/dist/vue3/lib/editor.cjs.map +1 -1
  124. package/dist/vue3/lib/editor.js +1 -2
  125. package/dist/vue3/lib/editor.js.map +1 -1
  126. package/dist/vue3/lib/emoji-row.cjs +1 -2
  127. package/dist/vue3/lib/emoji-row.cjs.map +1 -1
  128. package/dist/vue3/lib/emoji-row.js +1 -2
  129. package/dist/vue3/lib/emoji-row.js.map +1 -1
  130. package/dist/vue3/lib/emoji-text-wrapper.cjs +1 -2
  131. package/dist/vue3/lib/emoji-text-wrapper.cjs.map +1 -1
  132. package/dist/vue3/lib/emoji-text-wrapper.js +1 -2
  133. package/dist/vue3/lib/emoji-text-wrapper.js.map +1 -1
  134. package/dist/vue3/lib/emoji.cjs +1 -2
  135. package/dist/vue3/lib/emoji.cjs.map +1 -1
  136. package/dist/vue3/lib/emoji.js +1 -2
  137. package/dist/vue3/lib/emoji.js.map +1 -1
  138. package/dist/vue3/lib/general-row.cjs +3 -4
  139. package/dist/vue3/lib/general-row.cjs.map +1 -1
  140. package/dist/vue3/lib/general-row.js +3 -4
  141. package/dist/vue3/lib/general-row.js.map +1 -1
  142. package/dist/vue3/lib/group-row.cjs +1 -2
  143. package/dist/vue3/lib/group-row.cjs.map +1 -1
  144. package/dist/vue3/lib/group-row.js +1 -2
  145. package/dist/vue3/lib/group-row.js.map +1 -1
  146. package/dist/vue3/lib/message-input.cjs +1 -2
  147. package/dist/vue3/lib/message-input.cjs.map +1 -1
  148. package/dist/vue3/lib/message-input.js +1 -2
  149. package/dist/vue3/lib/message-input.js.map +1 -1
  150. package/dist/vue3/lib/rich-text-editor.cjs +11 -177
  151. package/dist/vue3/lib/rich-text-editor.cjs.map +1 -1
  152. package/dist/vue3/lib/rich-text-editor.js +11 -177
  153. package/dist/vue3/lib/rich-text-editor.js.map +1 -1
  154. package/dist/vue3/lib/tooltip.cjs +12 -15
  155. package/dist/vue3/lib/tooltip.cjs.map +1 -1
  156. package/dist/vue3/lib/tooltip.js +13 -16
  157. package/dist/vue3/lib/tooltip.js.map +1 -1
  158. package/dist/vue3/types/common/emoji/index.d.ts +1 -0
  159. package/dist/vue3/types/common/emoji/index.d.ts.map +1 -1
  160. package/dist/vue3/types/components/badge/badge.vue.d.ts +32 -0
  161. package/dist/vue3/types/components/badge/badge.vue.d.ts.map +1 -1
  162. package/dist/vue3/types/components/rich_text_editor/extensions/channels/channel.d.ts +0 -1
  163. package/dist/vue3/types/components/rich_text_editor/extensions/channels/channel.d.ts.map +1 -1
  164. package/dist/vue3/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
  165. package/dist/vue3/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts +0 -1
  166. package/dist/vue3/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
  167. package/dist/vue3/types/components/rich_text_editor/extensions/mentions/mention.d.ts +0 -1
  168. package/dist/vue3/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
  169. package/dist/vue3/types/components/rich_text_editor/mention_suggestion.d.ts +2 -2
  170. package/dist/vue3/types/components/rich_text_editor/mention_suggestion.d.ts.map +1 -1
  171. package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts +0 -10
  172. package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
  173. package/dist/vue3/types/components/tooltip/tooltip.vue.d.ts +3 -4
  174. package/dist/vue3/types/components/tooltip/tooltip.vue.d.ts.map +1 -1
  175. package/dist/vue3/types/recipes/leftbar/general_row/general_row_constants.d.ts +1 -1
  176. 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 "../common/emoji.js";
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 { id: item.unicode_character, code: item.shortname };
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 = /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])$/;
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 unicode = codeToEmojiData(attrs[0]).unicode_output;
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: pasteUnicodeRegex,
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: "text",
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.internalValue = newValue;
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
  },