@dialpad/dialtone-vue 2.133.0 → 2.135.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 (195) hide show
  1. package/dist/chunks/index-ODod4Oj_.js +175 -0
  2. package/dist/chunks/index-ODod4Oj_.js.map +1 -0
  3. package/dist/chunks/index-anN_sx1F.js +169 -0
  4. package/dist/chunks/index-anN_sx1F.js.map +1 -0
  5. package/dist/chunks/link_constants-AfTWrr-n.js +35 -0
  6. package/dist/chunks/link_constants-AfTWrr-n.js.map +1 -0
  7. package/dist/chunks/link_constants-x8NwdqmA.js +34 -0
  8. package/dist/chunks/link_constants-x8NwdqmA.js.map +1 -0
  9. package/dist/common/emoji.cjs +40 -163
  10. package/dist/common/emoji.cjs.map +1 -1
  11. package/dist/common/emoji.js +3 -146
  12. package/dist/common/emoji.js.map +1 -1
  13. package/dist/component-documentation.json +1 -1
  14. package/dist/dialtone-vue.cjs +10 -3
  15. package/dist/dialtone-vue.cjs.map +1 -1
  16. package/dist/dialtone-vue.js +10 -3
  17. package/dist/dialtone-vue.js.map +1 -1
  18. package/dist/lib/attachment-carousel.cjs +1 -1
  19. package/dist/lib/attachment-carousel.js +1 -1
  20. package/dist/lib/avatar.cjs.map +1 -1
  21. package/dist/lib/avatar.js.map +1 -1
  22. package/dist/lib/badge.cjs +21 -1
  23. package/dist/lib/badge.cjs.map +1 -1
  24. package/dist/lib/badge.js +21 -1
  25. package/dist/lib/badge.js.map +1 -1
  26. package/dist/lib/banner.cjs +1 -1
  27. package/dist/lib/banner.js +1 -1
  28. package/dist/lib/breadcrumbs.cjs +6 -3
  29. package/dist/lib/breadcrumbs.cjs.map +1 -1
  30. package/dist/lib/breadcrumbs.js +6 -3
  31. package/dist/lib/breadcrumbs.js.map +1 -1
  32. package/dist/lib/button.cjs +1 -1
  33. package/dist/lib/button.js +1 -1
  34. package/dist/lib/callbar-button-with-popover.cjs +1 -1
  35. package/dist/lib/callbar-button-with-popover.js +1 -1
  36. package/dist/lib/callbar-button.cjs +2 -2
  37. package/dist/lib/callbar-button.cjs.map +1 -1
  38. package/dist/lib/callbar-button.js +2 -2
  39. package/dist/lib/callbar-button.js.map +1 -1
  40. package/dist/lib/chip.cjs +1 -1
  41. package/dist/lib/chip.js +1 -1
  42. package/dist/lib/collapsible.cjs +1 -1
  43. package/dist/lib/collapsible.js +1 -1
  44. package/dist/lib/combobox-multi-select.cjs +1 -1
  45. package/dist/lib/combobox-multi-select.js +1 -1
  46. package/dist/lib/combobox-with-popover.cjs +1 -1
  47. package/dist/lib/combobox-with-popover.js +1 -1
  48. package/dist/lib/contact-centers-row.cjs +2 -3
  49. package/dist/lib/contact-centers-row.cjs.map +1 -1
  50. package/dist/lib/contact-centers-row.js +2 -3
  51. package/dist/lib/contact-centers-row.js.map +1 -1
  52. package/dist/lib/contact-row.cjs +2 -3
  53. package/dist/lib/contact-row.cjs.map +1 -1
  54. package/dist/lib/contact-row.js +2 -3
  55. package/dist/lib/contact-row.js.map +1 -1
  56. package/dist/lib/datepicker.cjs +1 -1
  57. package/dist/lib/datepicker.js +1 -1
  58. package/dist/lib/dropdown.cjs +1 -1
  59. package/dist/lib/dropdown.js +1 -1
  60. package/dist/lib/editor.cjs +3 -4
  61. package/dist/lib/editor.cjs.map +1 -1
  62. package/dist/lib/editor.js +3 -4
  63. package/dist/lib/editor.js.map +1 -1
  64. package/dist/lib/emoji-picker.cjs +1 -1
  65. package/dist/lib/emoji-picker.js +1 -1
  66. package/dist/lib/emoji-row.cjs +2 -3
  67. package/dist/lib/emoji-row.cjs.map +1 -1
  68. package/dist/lib/emoji-row.js +2 -3
  69. package/dist/lib/emoji-row.js.map +1 -1
  70. package/dist/lib/emoji-text-wrapper.cjs +1 -2
  71. package/dist/lib/emoji-text-wrapper.cjs.map +1 -1
  72. package/dist/lib/emoji-text-wrapper.js +1 -2
  73. package/dist/lib/emoji-text-wrapper.js.map +1 -1
  74. package/dist/lib/emoji.cjs +1 -2
  75. package/dist/lib/emoji.cjs.map +1 -1
  76. package/dist/lib/emoji.js +1 -2
  77. package/dist/lib/emoji.js.map +1 -1
  78. package/dist/lib/empty-state.cjs +142 -0
  79. package/dist/lib/empty-state.cjs.map +1 -0
  80. package/dist/lib/empty-state.js +142 -0
  81. package/dist/lib/empty-state.js.map +1 -0
  82. package/dist/lib/feed-pill.cjs +1 -1
  83. package/dist/lib/feed-pill.js +1 -1
  84. package/dist/lib/general-row.cjs +4 -5
  85. package/dist/lib/general-row.cjs.map +1 -1
  86. package/dist/lib/general-row.js +4 -5
  87. package/dist/lib/general-row.js.map +1 -1
  88. package/dist/lib/group-row.cjs +2 -3
  89. package/dist/lib/group-row.cjs.map +1 -1
  90. package/dist/lib/group-row.js +2 -3
  91. package/dist/lib/group-row.js.map +1 -1
  92. package/dist/lib/grouped-chip.cjs +1 -1
  93. package/dist/lib/grouped-chip.js +1 -1
  94. package/dist/lib/hovercard.cjs +1 -1
  95. package/dist/lib/hovercard.js +1 -1
  96. package/dist/lib/illustration.cjs +43 -0
  97. package/dist/lib/illustration.cjs.map +1 -0
  98. package/dist/lib/illustration.js +43 -0
  99. package/dist/lib/illustration.js.map +1 -0
  100. package/dist/lib/image-viewer.cjs +1 -1
  101. package/dist/lib/image-viewer.js +1 -1
  102. package/dist/lib/ivr-node.cjs +1 -1
  103. package/dist/lib/ivr-node.js +1 -1
  104. package/dist/lib/link.cjs +20 -6
  105. package/dist/lib/link.cjs.map +1 -1
  106. package/dist/lib/link.js +20 -6
  107. package/dist/lib/link.js.map +1 -1
  108. package/dist/lib/message-input.cjs +14 -8
  109. package/dist/lib/message-input.cjs.map +1 -1
  110. package/dist/lib/message-input.js +14 -8
  111. package/dist/lib/message-input.js.map +1 -1
  112. package/dist/lib/modal.cjs +1 -1
  113. package/dist/lib/modal.js +1 -1
  114. package/dist/lib/notice.cjs +1 -1
  115. package/dist/lib/notice.js +1 -1
  116. package/dist/lib/pagination.cjs +1 -1
  117. package/dist/lib/pagination.js +1 -1
  118. package/dist/lib/popover.cjs +1 -1
  119. package/dist/lib/popover.js +1 -1
  120. package/dist/lib/rich-text-editor.cjs +64 -200
  121. package/dist/lib/rich-text-editor.cjs.map +1 -1
  122. package/dist/lib/rich-text-editor.js +64 -200
  123. package/dist/lib/rich-text-editor.js.map +1 -1
  124. package/dist/lib/settings-menu-button.cjs +1 -1
  125. package/dist/lib/settings-menu-button.js +1 -1
  126. package/dist/lib/tabs.cjs +1 -1
  127. package/dist/lib/tabs.js +1 -1
  128. package/dist/lib/toast.cjs +1 -1
  129. package/dist/lib/toast.js +1 -1
  130. package/dist/lib/tooltip.cjs +9 -8
  131. package/dist/lib/tooltip.cjs.map +1 -1
  132. package/dist/lib/tooltip.js +9 -8
  133. package/dist/lib/tooltip.js.map +1 -1
  134. package/dist/style.css +15 -11
  135. package/dist/types/common/emoji/index.d.ts +3 -10
  136. package/dist/types/common/emoji/index.d.ts.map +1 -1
  137. package/dist/types/common/storybook_utils.d.ts +6 -0
  138. package/dist/types/common/storybook_utils.d.ts.map +1 -1
  139. package/dist/types/components/badge/badge.vue.d.ts +32 -0
  140. package/dist/types/components/badge/badge.vue.d.ts.map +1 -1
  141. package/dist/types/components/breadcrumbs/breadcrumb_item.vue.d.ts +2 -1
  142. package/dist/types/components/breadcrumbs/breadcrumb_item.vue.d.ts.map +1 -1
  143. package/dist/types/components/empty_state/empty_state.vue.d.ts +3 -0
  144. package/dist/types/components/empty_state/empty_state.vue.d.ts.map +1 -0
  145. package/dist/types/components/empty_state/empty_state_constants.d.ts +10 -0
  146. package/dist/types/components/empty_state/empty_state_constants.d.ts.map +1 -0
  147. package/dist/types/components/empty_state/index.d.ts +3 -0
  148. package/dist/types/components/empty_state/index.d.ts.map +1 -0
  149. package/dist/types/components/illustration/illustration.vue.d.ts +23 -0
  150. package/dist/types/components/illustration/illustration.vue.d.ts.map +1 -0
  151. package/dist/types/components/illustration/illustration_constants.d.ts +6 -0
  152. package/dist/types/components/illustration/illustration_constants.d.ts.map +1 -0
  153. package/dist/types/components/illustration/index.d.ts +3 -0
  154. package/dist/types/components/illustration/index.d.ts.map +1 -0
  155. package/dist/types/components/link/link.vue.d.ts +24 -4
  156. package/dist/types/components/link/link.vue.d.ts.map +1 -1
  157. package/dist/types/components/link/link_constants.d.ts +2 -2
  158. package/dist/types/components/link/link_constants.d.ts.map +1 -1
  159. package/dist/types/components/rich_text_editor/extensions/channels/channel.d.ts +0 -1
  160. package/dist/types/components/rich_text_editor/extensions/channels/channel.d.ts.map +1 -1
  161. package/dist/types/components/rich_text_editor/extensions/custom_link/autolink.d.ts.map +1 -0
  162. package/dist/types/components/rich_text_editor/extensions/custom_link/custom_link.d.ts +3 -0
  163. package/dist/types/components/rich_text_editor/extensions/custom_link/custom_link.d.ts.map +1 -0
  164. package/dist/types/components/rich_text_editor/extensions/custom_link/index.d.ts +3 -0
  165. package/dist/types/components/rich_text_editor/extensions/custom_link/index.d.ts.map +1 -0
  166. package/dist/types/components/rich_text_editor/extensions/custom_link/utils.d.ts.map +1 -0
  167. package/dist/types/components/rich_text_editor/extensions/emoji/emoji.d.ts.map +1 -1
  168. package/dist/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts +0 -1
  169. package/dist/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
  170. package/dist/types/components/rich_text_editor/extensions/mentions/mention.d.ts +0 -1
  171. package/dist/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
  172. package/dist/types/components/rich_text_editor/mention_suggestion.d.ts +2 -2
  173. package/dist/types/components/rich_text_editor/mention_suggestion.d.ts.map +1 -1
  174. package/dist/types/components/rich_text_editor/rich_text_editor.vue.d.ts +52 -12
  175. package/dist/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
  176. package/dist/types/components/toggle/toggle.vue.d.ts +1 -1
  177. package/dist/types/components/tooltip/tooltip.vue.d.ts +4 -2
  178. package/dist/types/components/tooltip/tooltip.vue.d.ts.map +1 -1
  179. package/dist/types/index.d.ts +2 -0
  180. package/dist/types/recipes/conversation_view/message_input/message_input.vue.d.ts +15 -0
  181. package/dist/types/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
  182. package/dist/types/recipes/leftbar/general_row/general_row_constants.d.ts +1 -1
  183. package/package.json +6 -6
  184. package/dist/chunks/link_constants-Huj7D_hm.js +0 -22
  185. package/dist/chunks/link_constants-Huj7D_hm.js.map +0 -1
  186. package/dist/chunks/link_constants-nWVlXQBs.js +0 -23
  187. package/dist/chunks/link_constants-nWVlXQBs.js.map +0 -1
  188. package/dist/types/components/rich_text_editor/extensions/link/autolink.d.ts.map +0 -1
  189. package/dist/types/components/rich_text_editor/extensions/link/index.d.ts +0 -4
  190. package/dist/types/components/rich_text_editor/extensions/link/index.d.ts.map +0 -1
  191. package/dist/types/components/rich_text_editor/extensions/link/link.d.ts +0 -3
  192. package/dist/types/components/rich_text_editor/extensions/link/link.d.ts.map +0 -1
  193. package/dist/types/components/rich_text_editor/extensions/link/utils.d.ts.map +0 -1
  194. /package/dist/types/components/rich_text_editor/extensions/{link → custom_link}/autolink.d.ts +0 -0
  195. /package/dist/types/components/rich_text_editor/extensions/{link → custom_link}/utils.d.ts +0 -0
@@ -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";
@@ -43,7 +42,7 @@ import "@dialpad/dialtone-icons/vue2";
43
42
  import "../chunks/stack_constants-HraCekPm.js";
44
43
  import "../common/constants.js";
45
44
  import "vue";
46
- import "../chunks/link_constants-nWVlXQBs.js";
45
+ import "../chunks/link_constants-AfTWrr-n.js";
47
46
  import "./presence.js";
48
47
  const _sfc_main$9 = {
49
48
  name: "EmojiComponent",
@@ -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 {
@@ -572,8 +564,8 @@ const defaultAttributes = {
572
564
  class: "d-link d-c-text d-d-inline-block d-wb-break-all",
573
565
  rel: "noopener noreferrer nofollow"
574
566
  };
575
- const Link = Mark.create({
576
- name: "Link",
567
+ const CustomLink = Mark.create({
568
+ name: "CustomLink",
577
569
  renderHTML({ HTMLAttributes }) {
578
570
  return [
579
571
  "a",
@@ -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
  }
@@ -1320,12 +1207,29 @@ const _sfc_main = {
1320
1207
  default: ""
1321
1208
  },
1322
1209
  /**
1323
- * Enables the Link extension and optionally passes configurations to it
1210
+ * Enables the TipTap Link extension and optionally passes configurations to it
1211
+ *
1212
+ * It is not recommended to use this and the custom link extension at the same time.
1324
1213
  */
1325
1214
  link: {
1326
1215
  type: [Boolean, Object],
1327
1216
  default: false
1328
1217
  },
1218
+ /**
1219
+ * Enables the Custom Link extension and optionally passes configurations to it
1220
+ *
1221
+ * It is not recommended to use this and the built in TipTap link extension at the same time.
1222
+ *
1223
+ * The custom link does some additional things on top of the built in TipTap link
1224
+ * extension such as styling phone numbers and IP adresses as links, and allows you
1225
+ * to linkify text without having to type a space after the link. Currently it is missing some
1226
+ * functionality such as editing links and will likely require more work to be fully usable,
1227
+ * so it is recommended to use the built in TipTap link for now.
1228
+ */
1229
+ customLink: {
1230
+ type: [Boolean, Object],
1231
+ default: false
1232
+ },
1329
1233
  /**
1330
1234
  * suggestion object containing the items query function.
1331
1235
  * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion
@@ -1414,6 +1318,13 @@ const _sfc_main = {
1414
1318
  allowUnderline: {
1415
1319
  type: Boolean,
1416
1320
  default: true
1321
+ },
1322
+ /**
1323
+ * Whether the input allows codeblock to be introduced in the text.
1324
+ */
1325
+ allowCodeblock: {
1326
+ type: Boolean,
1327
+ default: true
1417
1328
  }
1418
1329
  },
1419
1330
  emits: [
@@ -1461,7 +1372,16 @@ const _sfc_main = {
1461
1372
  extensions() {
1462
1373
  const extensions = [Document, Paragraph, Text];
1463
1374
  if (this.link) {
1464
- extensions.push(this.getExtension(Link, this.link));
1375
+ extensions.push(TipTapLink.extend({ inclusive: false }).configure({
1376
+ HTMLAttributes: {
1377
+ class: "d-link d-wb-break-all"
1378
+ },
1379
+ autolink: true,
1380
+ protocols: RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS
1381
+ }));
1382
+ }
1383
+ if (this.customLink) {
1384
+ extensions.push(this.getExtension(CustomLink, this.customLink));
1465
1385
  }
1466
1386
  if (this.allowBlockquote) {
1467
1387
  extensions.push(Blockquote);
@@ -1472,9 +1392,7 @@ const _sfc_main = {
1472
1392
  if (this.allowBulletList) {
1473
1393
  extensions.push(BulletList);
1474
1394
  extensions.push(ListItem);
1475
- extensions.push(OrderedList.configure({
1476
- itemTypeName: "listItem"
1477
- }));
1395
+ extensions.push(OrderedList);
1478
1396
  }
1479
1397
  if (this.allowItalic) {
1480
1398
  extensions.push(Italic);
@@ -1485,10 +1403,13 @@ const _sfc_main = {
1485
1403
  if (this.allowUnderline) {
1486
1404
  extensions.push(Underline);
1487
1405
  }
1488
- extensions.push(
1489
- Placeholder.configure({ placeholder: this.placeholder })
1490
- );
1406
+ if (this.placeholder) {
1407
+ extensions.push(
1408
+ Placeholder.configure({ placeholder: this.placeholder })
1409
+ );
1410
+ }
1491
1411
  if (!this.allowLineBreaks) {
1412
+ const self = this;
1492
1413
  extensions.push(
1493
1414
  HardBreak.extend({
1494
1415
  addKeyboardShortcuts() {
@@ -1496,6 +1417,7 @@ const _sfc_main = {
1496
1417
  Enter: () => true,
1497
1418
  "Shift-Enter": () => this.editor.commands.first(({ commands }) => [
1498
1419
  () => commands.newlineInCode(),
1420
+ () => self.allowBulletList && commands.splitListItem("listItem"),
1499
1421
  () => commands.createParagraphNear(),
1500
1422
  () => commands.liftEmptyBlock(),
1501
1423
  () => commands.splitBlock()
@@ -1505,10 +1427,6 @@ const _sfc_main = {
1505
1427
  })
1506
1428
  );
1507
1429
  }
1508
- extensions.push(TipTapLink.extend({ inclusive: false }).configure({
1509
- autolink: true,
1510
- protocols: RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS
1511
- }));
1512
1430
  if (this.mentionSuggestion) {
1513
1431
  const suggestionObject = { ...this.mentionSuggestion, ...mentionSuggestion };
1514
1432
  extensions.push(MentionPlugin.configure({ suggestion: suggestionObject }));
@@ -1526,11 +1444,13 @@ const _sfc_main = {
1526
1444
  types: ["paragraph"],
1527
1445
  defaultAlignment: "left"
1528
1446
  }));
1529
- extensions.push(CodeBlock.configure({
1530
- HTMLAttributes: {
1531
- class: "dt-rich-text-editor--code-block"
1532
- }
1533
- }));
1447
+ if (this.allowCodeblock) {
1448
+ extensions.push(CodeBlock.configure({
1449
+ HTMLAttributes: {
1450
+ class: "dt-rich-text-editor--code-block"
1451
+ }
1452
+ }));
1453
+ }
1534
1454
  return extensions;
1535
1455
  },
1536
1456
  inputAttrs() {
@@ -1574,8 +1494,7 @@ const _sfc_main = {
1574
1494
  if (newValue === currentValue) {
1575
1495
  return;
1576
1496
  }
1577
- this.internalValue = newValue;
1578
- this.insertContent();
1497
+ this.editor.commands.setContent(newValue, false);
1579
1498
  }
1580
1499
  },
1581
1500
  created() {
@@ -1591,6 +1510,7 @@ const _sfc_main = {
1591
1510
  createEditor() {
1592
1511
  this.editor = new Editor({
1593
1512
  autofocus: this.autoFocus,
1513
+ content: this.value,
1594
1514
  editable: this.editable,
1595
1515
  extensions: this.extensions,
1596
1516
  editorProps: {
@@ -1600,64 +1520,8 @@ const _sfc_main = {
1600
1520
  }
1601
1521
  }
1602
1522
  });
1603
- this.insertContent();
1604
1523
  this.addEditorListeners();
1605
1524
  },
1606
- /**
1607
- * This function is necessary as tiptap doesn't render the content passed
1608
- * directly through `editor.commands.setContent` the content passed down to it
1609
- * should be already parsed. So We're parsing the elements into it's corresponding
1610
- * HTML version before setting it.
1611
- */
1612
- insertContent() {
1613
- this.parseMentions();
1614
- this.parseChannels();
1615
- this.parseEmojis();
1616
- this.editor.commands.setContent(this.internalValue, true);
1617
- },
1618
- parseEmojis() {
1619
- const matches = new Set(
1620
- [...this.value.matchAll(emojiRegex()), ...this.value.matchAll(emojiShortCodeRegex)].map((match) => match[0].trim())
1621
- );
1622
- if (!matches)
1623
- return;
1624
- matches.forEach((match) => {
1625
- const emoji = codeToEmojiData(match);
1626
- if (!emoji)
1627
- return;
1628
- this.internalValue = this.internalValue.replace(new RegExp(`${match}`, "g"), `<emoji-component code="${emoji.shortname}"></emoji-component>`);
1629
- });
1630
- },
1631
- parseChannels() {
1632
- if (!this.channelSuggestion)
1633
- return;
1634
- const suggestions = this.channelSuggestion.items({ query: "" });
1635
- const matches = [...this.value.matchAll(channelRegex)].filter((match) => suggestions.some(({ id }) => id === match[1]));
1636
- if (!matches)
1637
- return;
1638
- matches.forEach((match) => {
1639
- const channel = suggestions.find(({ id }) => id === match[1]);
1640
- this.internalValue = this.internalValue.replace(
1641
- `#${match[1]}`,
1642
- /** The space at the beginning is important as tiptap removes that while rendering.
1643
- * So if multiple mentions, channels or emojis are next to each other it will fail
1644
- */
1645
- ` <channel-component name="${channel.name}" id="${channel.id}"></channel-component>`
1646
- );
1647
- });
1648
- },
1649
- parseMentions() {
1650
- if (!this.mentionSuggestion)
1651
- return;
1652
- const suggestions = this.mentionSuggestion.items({ query: "" });
1653
- const matches = [...this.value.matchAll(mentionRegex)].filter((match) => suggestions.some(({ id }) => id === match[1]));
1654
- if (!matches)
1655
- return;
1656
- matches.forEach((match) => {
1657
- const mention = suggestions.find(({ id }) => id === match[1]);
1658
- this.internalValue = this.internalValue.replace(`@${match[1]}`, ` <mention-component name="${mention.name}" id="${mention.id}"></mention-component>`);
1659
- });
1660
- },
1661
1525
  destroyEditor() {
1662
1526
  this.editor.destroy();
1663
1527
  },