@dialpad/dialtone-vue 2.127.2 → 2.128.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 (35) hide show
  1. package/dist/dialtone-vue.cjs +2 -0
  2. package/dist/dialtone-vue.cjs.map +1 -1
  3. package/dist/dialtone-vue.js +2 -0
  4. package/dist/dialtone-vue.js.map +1 -1
  5. package/dist/lib/editor.cjs +2 -0
  6. package/dist/lib/editor.cjs.map +1 -1
  7. package/dist/lib/editor.js +2 -0
  8. package/dist/lib/editor.js.map +1 -1
  9. package/dist/lib/message-input.cjs +21 -4
  10. package/dist/lib/message-input.cjs.map +1 -1
  11. package/dist/lib/message-input.js +21 -4
  12. package/dist/lib/message-input.js.map +1 -1
  13. package/dist/lib/popover.cjs +2 -1
  14. package/dist/lib/popover.cjs.map +1 -1
  15. package/dist/lib/popover.js +2 -1
  16. package/dist/lib/popover.js.map +1 -1
  17. package/dist/lib/rich-text-editor.cjs +220 -40
  18. package/dist/lib/rich-text-editor.cjs.map +1 -1
  19. package/dist/lib/rich-text-editor.js +220 -40
  20. package/dist/lib/rich-text-editor.js.map +1 -1
  21. package/dist/types/components/rich_text_editor/channel_suggestion.d.ts +15 -0
  22. package/dist/types/components/rich_text_editor/channel_suggestion.d.ts.map +1 -0
  23. package/dist/types/components/rich_text_editor/extensions/channels/ChannelComponent.vue.d.ts +47 -0
  24. package/dist/types/components/rich_text_editor/extensions/channels/ChannelComponent.vue.d.ts.map +1 -0
  25. package/dist/types/components/rich_text_editor/extensions/channels/ChannelSuggestion.vue.d.ts +15 -0
  26. package/dist/types/components/rich_text_editor/extensions/channels/ChannelSuggestion.vue.d.ts.map +1 -0
  27. package/dist/types/components/rich_text_editor/extensions/channels/channel.d.ts +2 -0
  28. package/dist/types/components/rich_text_editor/extensions/channels/channel.d.ts.map +1 -0
  29. package/dist/types/components/rich_text_editor/extensions/channels/suggestion.d.ts +11 -0
  30. package/dist/types/components/rich_text_editor/extensions/channels/suggestion.d.ts.map +1 -0
  31. package/dist/types/components/rich_text_editor/rich_text_editor.vue.d.ts +31 -0
  32. package/dist/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
  33. package/dist/types/recipes/conversation_view/message_input/message_input.vue.d.ts +31 -0
  34. package/dist/types/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
  35. package/package.json +2 -2
@@ -29,6 +29,8 @@ import { linkRegex, getPhoneNumberRegex } from "../common/utils.js";
29
29
  import Mention from "@tiptap/extension-mention";
30
30
  import { DtLink } from "./link.js";
31
31
  import { DtAvatar } from "./avatar.js";
32
+ import DtIconHash from "@dialpad/dialtone-icons/vue2/hash";
33
+ import DtIconLock from "@dialpad/dialtone-icons/vue2/lock";
32
34
  import "./skeleton.js";
33
35
  import "../chunks/icon_constants-Dy4MEUJL.js";
34
36
  import "@dialpad/dialtone-icons/icons.json";
@@ -43,7 +45,7 @@ import "../common/constants.js";
43
45
  import "vue";
44
46
  import "../chunks/link_constants-nWVlXQBs.js";
45
47
  import "./presence.js";
46
- const _sfc_main$5 = {
48
+ const _sfc_main$7 = {
47
49
  name: "EmojiComponent",
48
50
  components: {
49
51
  NodeViewWrapper,
@@ -51,23 +53,23 @@ const _sfc_main$5 = {
51
53
  },
52
54
  props: nodeViewProps
53
55
  };
54
- var _sfc_render$5 = function render() {
56
+ var _sfc_render$7 = function render() {
55
57
  var _vm = this, _c = _vm._self._c;
56
58
  return _c("node-view-wrapper", { staticClass: "d-d-inline-block d-va-bottom d-lh0" }, [_c("dt-emoji", { attrs: { "size": "500", "code": _vm.node.attrs.code } })], 1);
57
59
  };
58
- var _sfc_staticRenderFns$5 = [];
59
- var __component__$5 = /* @__PURE__ */ normalizeComponent(
60
- _sfc_main$5,
61
- _sfc_render$5,
62
- _sfc_staticRenderFns$5,
60
+ var _sfc_staticRenderFns$7 = [];
61
+ var __component__$7 = /* @__PURE__ */ normalizeComponent(
62
+ _sfc_main$7,
63
+ _sfc_render$7,
64
+ _sfc_staticRenderFns$7,
63
65
  false,
64
66
  null,
65
67
  null,
66
68
  null,
67
69
  null
68
70
  );
69
- const EmojiComponent = __component__$5.exports;
70
- const _sfc_main$4 = {
71
+ const EmojiComponent = __component__$7.exports;
72
+ const _sfc_main$6 = {
71
73
  name: "SuggestionList",
72
74
  components: {
73
75
  DtListItem
@@ -147,11 +149,14 @@ const _sfc_main$4 = {
147
149
  case "mention":
148
150
  this.command({ name: item.name, id: item.id, avatarSrc: item.avatarSrc });
149
151
  break;
152
+ case "channel":
153
+ this.command({ name: item.name, id: item.id });
154
+ break;
150
155
  }
151
156
  }
152
157
  }
153
158
  };
154
- var _sfc_render$4 = function render2() {
159
+ var _sfc_render$6 = function render2() {
155
160
  var _vm = this, _c = _vm._self._c;
156
161
  return _c("div", { staticClass: "d-popover__dialog" }, [_c("ul", { directives: [{ name: "show", rawName: "v-show", value: _vm.items.length, expression: "items.length" }], ref: "suggestionList", staticClass: "dt-suggestion-list" }, _vm._l(_vm.items, function(item, index) {
157
162
  return _c("dt-list-item", { key: item.id, class: [
@@ -166,19 +171,19 @@ var _sfc_render$4 = function render2() {
166
171
  } } }, [_c(_vm.itemComponent, { tag: "component", attrs: { "item": item } })], 1);
167
172
  }), 1)]);
168
173
  };
169
- var _sfc_staticRenderFns$4 = [];
170
- var __component__$4 = /* @__PURE__ */ normalizeComponent(
171
- _sfc_main$4,
172
- _sfc_render$4,
173
- _sfc_staticRenderFns$4,
174
+ var _sfc_staticRenderFns$6 = [];
175
+ var __component__$6 = /* @__PURE__ */ normalizeComponent(
176
+ _sfc_main$6,
177
+ _sfc_render$6,
178
+ _sfc_staticRenderFns$6,
174
179
  false,
175
180
  null,
176
181
  null,
177
182
  null,
178
183
  null
179
184
  );
180
- const SuggestionList = __component__$4.exports;
181
- const _sfc_main$3 = {
185
+ const SuggestionList = __component__$6.exports;
186
+ const _sfc_main$5 = {
182
187
  name: "EmojiSuggestion",
183
188
  components: {
184
189
  DtEmoji,
@@ -191,22 +196,22 @@ const _sfc_main$3 = {
191
196
  }
192
197
  }
193
198
  };
194
- var _sfc_render$3 = function render3() {
199
+ var _sfc_render$5 = function render3() {
195
200
  var _vm = this, _c = _vm._self._c;
196
201
  return _c("dt-stack", { attrs: { "direction": "row", "gap": "400" } }, [_c("dt-emoji", { attrs: { "size": "200", "code": _vm.item.code } }), _vm._v(" " + _vm._s(_vm.item.code) + " ")], 1);
197
202
  };
198
- var _sfc_staticRenderFns$3 = [];
199
- var __component__$3 = /* @__PURE__ */ normalizeComponent(
200
- _sfc_main$3,
201
- _sfc_render$3,
202
- _sfc_staticRenderFns$3,
203
+ var _sfc_staticRenderFns$5 = [];
204
+ var __component__$5 = /* @__PURE__ */ normalizeComponent(
205
+ _sfc_main$5,
206
+ _sfc_render$5,
207
+ _sfc_staticRenderFns$5,
203
208
  false,
204
209
  null,
205
210
  null,
206
211
  null,
207
212
  null
208
213
  );
209
- const EmojiSuggestion = __component__$3.exports;
214
+ const EmojiSuggestion = __component__$5.exports;
210
215
  const suggestionOptions = {
211
216
  items: ({ query }) => {
212
217
  if (query.length < 2) {
@@ -582,7 +587,7 @@ const Link = Mark.create({
582
587
  ];
583
588
  }
584
589
  });
585
- const _sfc_main$2 = {
590
+ const _sfc_main$4 = {
586
591
  name: "MentionComponent",
587
592
  components: {
588
593
  NodeViewWrapper,
@@ -595,22 +600,22 @@ const _sfc_main$2 = {
595
600
  }
596
601
  }
597
602
  };
598
- var _sfc_render$2 = function render4() {
603
+ var _sfc_render$4 = function render4() {
599
604
  var _vm = this, _c = _vm._self._c;
600
605
  return _c("node-view-wrapper", { staticClass: "d-d-inline-block" }, [_c("dt-link", { attrs: { "kind": "mention" } }, [_vm._v(" " + _vm._s(_vm.text) + " ")])], 1);
601
606
  };
602
- var _sfc_staticRenderFns$2 = [];
603
- var __component__$2 = /* @__PURE__ */ normalizeComponent(
604
- _sfc_main$2,
605
- _sfc_render$2,
606
- _sfc_staticRenderFns$2,
607
+ var _sfc_staticRenderFns$4 = [];
608
+ var __component__$4 = /* @__PURE__ */ normalizeComponent(
609
+ _sfc_main$4,
610
+ _sfc_render$4,
611
+ _sfc_staticRenderFns$4,
607
612
  false,
608
613
  null,
609
614
  null,
610
615
  null,
611
616
  null
612
617
  );
613
- const MentionComponent = __component__$2.exports;
618
+ const MentionComponent = __component__$4.exports;
614
619
  const MentionPlugin = Mention.extend({
615
620
  addNodeView() {
616
621
  return VueNodeViewRenderer(MentionComponent);
@@ -642,6 +647,72 @@ const MentionPlugin = Mention.extend({
642
647
  return ["mention-component", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
643
648
  }
644
649
  });
650
+ const _sfc_main$3 = {
651
+ name: "ChannelComponent",
652
+ components: {
653
+ NodeViewWrapper,
654
+ DtLink
655
+ },
656
+ props: nodeViewProps,
657
+ computed: {
658
+ text() {
659
+ return "#" + this.$props.node.attrs.name;
660
+ }
661
+ }
662
+ };
663
+ var _sfc_render$3 = function render5() {
664
+ var _vm = this, _c = _vm._self._c;
665
+ return _c("node-view-wrapper", { staticClass: "d-d-inline-block" }, [_c("dt-link", { attrs: { "kind": "mention" } }, [_vm._v(" " + _vm._s(_vm.text) + " ")])], 1);
666
+ };
667
+ var _sfc_staticRenderFns$3 = [];
668
+ var __component__$3 = /* @__PURE__ */ normalizeComponent(
669
+ _sfc_main$3,
670
+ _sfc_render$3,
671
+ _sfc_staticRenderFns$3,
672
+ false,
673
+ null,
674
+ null,
675
+ null,
676
+ null
677
+ );
678
+ const ChannelComponent = __component__$3.exports;
679
+ const ChannelPlugin = Mention.extend({
680
+ name: "channel",
681
+ addNodeView() {
682
+ return VueNodeViewRenderer(ChannelComponent);
683
+ },
684
+ parseHTML() {
685
+ return [
686
+ {
687
+ tag: "channel-component"
688
+ }
689
+ ];
690
+ },
691
+ addAttributes() {
692
+ return {
693
+ name: {
694
+ default: ""
695
+ },
696
+ id: {
697
+ default: ""
698
+ },
699
+ locked: {
700
+ default: false
701
+ }
702
+ };
703
+ },
704
+ renderText({ node }) {
705
+ return `#${node.attrs.id}`;
706
+ },
707
+ renderHTML({ HTMLAttributes }) {
708
+ return ["channel-component", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
709
+ }
710
+ }).configure({
711
+ suggestion: {
712
+ char: "#",
713
+ pluginKey: new PluginKey("channelSuggestion")
714
+ }
715
+ });
645
716
  const RICH_TEXT_EDITOR_OUTPUT_FORMATS = [
646
717
  "text",
647
718
  "json",
@@ -660,7 +731,7 @@ const RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS = [
660
731
  "sftp",
661
732
  "mailto"
662
733
  ];
663
- const _sfc_main$1 = {
734
+ const _sfc_main$2 = {
664
735
  name: "MentionSuggestion",
665
736
  components: {
666
737
  DtAvatar,
@@ -681,10 +752,100 @@ const _sfc_main$1 = {
681
752
  }
682
753
  }
683
754
  };
684
- var _sfc_render$1 = function render5() {
755
+ var _sfc_render$2 = function render6() {
685
756
  var _vm = this, _c = _vm._self._c;
686
757
  return _c("dt-stack", { attrs: { "direction": "row", "gap": "400" } }, [_c("dt-avatar", { attrs: { "full-name": _vm.name, "image-src": _vm.avatarSrc, "image-alt": _vm.name, "size": "xs" } }), _vm._v(" " + _vm._s(_vm.name) + " ")], 1);
687
758
  };
759
+ var _sfc_staticRenderFns$2 = [];
760
+ var __component__$2 = /* @__PURE__ */ normalizeComponent(
761
+ _sfc_main$2,
762
+ _sfc_render$2,
763
+ _sfc_staticRenderFns$2,
764
+ false,
765
+ null,
766
+ null,
767
+ null,
768
+ null
769
+ );
770
+ const MentionSuggestion = __component__$2.exports;
771
+ const mentionSuggestion = {
772
+ // This function comes from the user and passed to the editor directly.
773
+ // This will also activate the mention plugin on the editor
774
+ // items: ({ query }) => { return [] },
775
+ allowSpaces: true,
776
+ render: () => {
777
+ let component;
778
+ let popup;
779
+ return {
780
+ onStart: (props) => {
781
+ component = new VueRenderer(SuggestionList, {
782
+ parent: void 0,
783
+ propsData: {
784
+ itemComponent: MentionSuggestion,
785
+ itemType: "mention",
786
+ ...props
787
+ },
788
+ editor: props.editor
789
+ });
790
+ if (!props.clientRect) {
791
+ return;
792
+ }
793
+ popup = tippy("body", {
794
+ getReferenceClientRect: props.clientRect,
795
+ appendTo: () => document.body,
796
+ content: component.element,
797
+ showOnCreate: true,
798
+ interactive: true,
799
+ trigger: "manual",
800
+ placement: "top-start"
801
+ });
802
+ },
803
+ onUpdate(props) {
804
+ component.updateProps(props);
805
+ if (!props.clientRect) {
806
+ return;
807
+ }
808
+ popup[0].setProps({
809
+ getReferenceClientRect: props.clientRect
810
+ });
811
+ },
812
+ onKeyDown(props) {
813
+ if (props.event.key === "Escape") {
814
+ popup[0].hide();
815
+ return true;
816
+ }
817
+ return component == null ? void 0 : component.ref.onKeyDown(props);
818
+ },
819
+ onExit() {
820
+ popup[0].destroy();
821
+ component.destroy();
822
+ }
823
+ };
824
+ }
825
+ };
826
+ const _sfc_main$1 = {
827
+ name: "ChannelSuggestion",
828
+ components: {
829
+ DtStack,
830
+ DtIconHash,
831
+ DtIconLock
832
+ },
833
+ props: {
834
+ item: {
835
+ type: Object,
836
+ required: true
837
+ }
838
+ },
839
+ computed: {
840
+ name() {
841
+ return this.item.name;
842
+ }
843
+ }
844
+ };
845
+ var _sfc_render$1 = function render7() {
846
+ var _vm = this, _c = _vm._self._c;
847
+ return _c("dt-stack", { attrs: { "direction": "row", "gap": "400" } }, [!_vm.item.locked ? _c("dt-icon-hash", { attrs: { "size": "300" } }) : _c("dt-icon-lock", { attrs: { "size": "300" } }), _c("span", [_vm._v(_vm._s(_vm.name))])], 1);
848
+ };
688
849
  var _sfc_staticRenderFns$1 = [];
689
850
  var __component__$1 = /* @__PURE__ */ normalizeComponent(
690
851
  _sfc_main$1,
@@ -696,8 +857,8 @@ var __component__$1 = /* @__PURE__ */ normalizeComponent(
696
857
  null,
697
858
  null
698
859
  );
699
- const MentionSuggestion = __component__$1.exports;
700
- const suggestion = {
860
+ const ChannelSuggestion = __component__$1.exports;
861
+ const channelSuggestion = {
701
862
  // This function comes from the user and passed to the editor directly.
702
863
  // This will also activate the mention plugin on the editor
703
864
  // items: ({ query }) => { return [] },
@@ -710,8 +871,8 @@ const suggestion = {
710
871
  component = new VueRenderer(SuggestionList, {
711
872
  parent: void 0,
712
873
  propsData: {
713
- itemComponent: MentionSuggestion,
714
- itemType: "mention",
874
+ itemComponent: ChannelSuggestion,
875
+ itemType: "channel",
715
876
  ...props
716
877
  },
717
878
  editor: props.editor
@@ -859,6 +1020,21 @@ const _sfc_main = {
859
1020
  type: Object,
860
1021
  default: null
861
1022
  },
1023
+ /**
1024
+ * suggestion object containing the items query function.
1025
+ * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion
1026
+ *
1027
+ * The only required key is the items function which is used to query the channels for suggestion.
1028
+ * items({ query }) => { return [ChannelObject]; }
1029
+ * ChannelObject format:
1030
+ * { name: string, id: string, locked: boolean }
1031
+ *
1032
+ * When null, it does not add the plugin. Setting locked to true will display a lock rather than hash.
1033
+ */
1034
+ channelSuggestion: {
1035
+ type: Object,
1036
+ default: null
1037
+ },
862
1038
  /**
863
1039
  * Whether the input allows for block quote.
864
1040
  */
@@ -988,9 +1164,13 @@ const _sfc_main = {
988
1164
  protocols: RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS
989
1165
  }));
990
1166
  if (this.mentionSuggestion) {
991
- const suggestionObject = { ...this.mentionSuggestion, ...suggestion };
1167
+ const suggestionObject = { ...this.mentionSuggestion, ...mentionSuggestion };
992
1168
  extensions.push(MentionPlugin.configure({ suggestion: suggestionObject }));
993
1169
  }
1170
+ if (this.channelSuggestion) {
1171
+ const suggestionObject = { ...this.channelSuggestion, ...channelSuggestion };
1172
+ extensions.push(ChannelPlugin.configure({ suggestion: suggestionObject }));
1173
+ }
994
1174
  extensions.push(Emoji);
995
1175
  extensions.push(TextAlign.configure({
996
1176
  types: ["paragraph"],
@@ -1115,7 +1295,7 @@ const _sfc_main = {
1115
1295
  }
1116
1296
  }
1117
1297
  };
1118
- var _sfc_render = function render6() {
1298
+ var _sfc_render = function render8() {
1119
1299
  var _vm = this, _c = _vm._self._c;
1120
1300
  return _c("editor-content", { staticClass: "dt-rich-text-editor", attrs: { "editor": _vm.editor, "data-qa": "dt-rich-text-editor" } });
1121
1301
  };