@dialpad/dialtone 9.139.1 → 9.140.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 (50) hide show
  1. package/dist/tokens/doc.json +59256 -59256
  2. package/dist/vue2/component-documentation.json +1 -1
  3. package/dist/vue2/lib/emoji-picker/emoji-picker.cjs.map +1 -1
  4. package/dist/vue2/lib/emoji-picker/emoji-picker.js.map +1 -1
  5. package/dist/vue2/lib/message-input/message-input.cjs +1 -1
  6. package/dist/vue2/lib/message-input/message-input.cjs.map +1 -1
  7. package/dist/vue2/lib/message-input/message-input.js +26 -18
  8. package/dist/vue2/lib/message-input/message-input.js.map +1 -1
  9. package/dist/vue2/lib/rich-text-editor/channel-suggestion.cjs.map +1 -1
  10. package/dist/vue2/lib/rich-text-editor/channel-suggestion.js.map +1 -1
  11. package/dist/vue2/lib/rich-text-editor/rich-text-editor-constants.cjs +1 -1
  12. package/dist/vue2/lib/rich-text-editor/rich-text-editor-constants.cjs.map +1 -1
  13. package/dist/vue2/lib/rich-text-editor/rich-text-editor-constants.js +2 -1
  14. package/dist/vue2/lib/rich-text-editor/rich-text-editor-constants.js.map +1 -1
  15. package/dist/vue2/lib/rich-text-editor/rich-text-editor.cjs +13 -4
  16. package/dist/vue2/lib/rich-text-editor/rich-text-editor.cjs.map +1 -1
  17. package/dist/vue2/lib/rich-text-editor/rich-text-editor.js +356 -225
  18. package/dist/vue2/lib/rich-text-editor/rich-text-editor.js.map +1 -1
  19. package/dist/vue2/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
  20. package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts +21 -1
  21. package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
  22. package/dist/vue2/types/components/rich_text_editor/rich_text_editor_constants.d.ts.map +1 -1
  23. package/dist/vue2/types/recipes/conversation_view/message_input/message_input.vue.d.ts +2 -1
  24. package/dist/vue2/types/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
  25. package/dist/vue3/component-documentation.json +1 -1
  26. package/dist/vue3/lib/emoji-picker/emoji-picker.cjs.map +1 -1
  27. package/dist/vue3/lib/emoji-picker/emoji-picker.js.map +1 -1
  28. package/dist/vue3/lib/message-input/message-input.cjs +1 -1
  29. package/dist/vue3/lib/message-input/message-input.cjs.map +1 -1
  30. package/dist/vue3/lib/message-input/message-input.js +37 -28
  31. package/dist/vue3/lib/message-input/message-input.js.map +1 -1
  32. package/dist/vue3/lib/rich-text-editor/channel-suggestion.cjs.map +1 -1
  33. package/dist/vue3/lib/rich-text-editor/channel-suggestion.js.map +1 -1
  34. package/dist/vue3/lib/rich-text-editor/rich-text-editor-constants.cjs +1 -1
  35. package/dist/vue3/lib/rich-text-editor/rich-text-editor-constants.cjs.map +1 -1
  36. package/dist/vue3/lib/rich-text-editor/rich-text-editor-constants.js +2 -1
  37. package/dist/vue3/lib/rich-text-editor/rich-text-editor-constants.js.map +1 -1
  38. package/dist/vue3/lib/rich-text-editor/rich-text-editor.cjs +15 -6
  39. package/dist/vue3/lib/rich-text-editor/rich-text-editor.cjs.map +1 -1
  40. package/dist/vue3/lib/rich-text-editor/rich-text-editor.js +421 -278
  41. package/dist/vue3/lib/rich-text-editor/rich-text-editor.js.map +1 -1
  42. package/dist/vue3/types/components/rich_text_editor/extensions/channels/ChannelComponent.vue.d.ts +1 -1
  43. package/dist/vue3/types/components/rich_text_editor/extensions/channels/ChannelComponent.vue.d.ts.map +1 -1
  44. package/dist/vue3/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
  45. package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts +22 -1
  46. package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
  47. package/dist/vue3/types/components/rich_text_editor/rich_text_editor_constants.d.ts.map +1 -1
  48. package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts +3 -1
  49. package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
  50. package/package.json +4 -8
@@ -1,5 +1,5 @@
1
- import { nodeViewProps as _, NodeViewWrapper as y, VueRenderer as w, VueNodeViewRenderer as v, BubbleMenu as H, EditorContent as j, Editor as F } from "../../node_modules/@tiptap/vue-2.js";
2
- import { Node as N, nodePasteRule as E, InputRule as K, mergeAttributes as m, getMarksBetween as U, combineTransactionSteps as W, getChangedRanges as q, findChildrenInRange as V, Mark as z, nodeInputRule as X, Extension as J } from "@tiptap/core";
1
+ import { nodeViewProps as k, NodeViewWrapper as y, VueRenderer as w, VueNodeViewRenderer as C, BubbleMenu as D, EditorContent as j, Editor as H } from "../../node_modules/@tiptap/vue-2.js";
2
+ import { Node as F, nodePasteRule as E, InputRule as K, mergeAttributes as m, getMarksBetween as q, combineTransactionSteps as U, getChangedRanges as W, findChildrenInRange as V, Mark as z, nodeInputRule as X, Extension as J } from "@tiptap/core";
3
3
  import Y from "@tiptap/extension-blockquote";
4
4
  import G from "@tiptap/extension-code-block";
5
5
  import Q from "@tiptap/extension-code";
@@ -10,54 +10,55 @@ import te from "@tiptap/extension-hard-break";
10
10
  import ne from "@tiptap/extension-bold";
11
11
  import re from "@tiptap/extension-bullet-list";
12
12
  import se from "@tiptap/extension-italic";
13
- import ie from "@tiptap/extension-link";
14
- import oe from "@tiptap/extension-list-item";
13
+ import oe from "@tiptap/extension-link";
14
+ import ie from "@tiptap/extension-list-item";
15
15
  import ae from "@tiptap/extension-ordered-list";
16
- import le from "@tiptap/extension-strike";
17
- import ce from "@tiptap/extension-underline";
18
- import de from "@tiptap/extension-text";
16
+ import ce from "@tiptap/extension-strike";
17
+ import de from "@tiptap/extension-underline";
18
+ import le from "@tiptap/extension-text";
19
19
  import ue from "@tiptap/extension-text-align";
20
20
  import me from "@tiptap/extension-history";
21
21
  import he from "@tiptap/extension-text-style";
22
- import fe from "@tiptap/extension-color";
23
- import pe from "@tiptap/extension-font-family";
24
- import { PluginKey as f, Plugin as ge } from "@tiptap/pm/state";
22
+ import pe from "@tiptap/extension-color";
23
+ import fe from "@tiptap/extension-font-family";
24
+ import { PluginKey as p, Plugin as ge } from "@tiptap/pm/state";
25
25
  import _e from "@tiptap/suggestion";
26
- import { emojiPattern as O } from "regex-combined-emojis";
27
- import { n as c } from "../../_plugin-vue2_normalizer-DSLOjnn3.js";
28
- import P from "../emoji/emoji.js";
29
- import { getEmojiData as ye, emojiRegex as we, stringToUnicode as ve, codeToEmojiData as L, emojiShortCodeRegex as xe } from "../../common/emoji/index.js";
26
+ import { emojiPattern as M } from "regex-combined-emojis";
27
+ import { n as d } from "../../_plugin-vue2_normalizer-DSLOjnn3.js";
28
+ import A from "../emoji/emoji.js";
29
+ import { getEmojiData as ke, emojiRegex as ye, stringToUnicode as we, codeToEmojiData as L, emojiShortCodeRegex as Ce } from "../../common/emoji/index.js";
30
30
  import be from "../list-item/list-item.js";
31
- import x from "../stack/stack.js";
31
+ import f from "../stack/stack.js";
32
32
  import b from "tippy.js";
33
- import { getPhoneNumberRegex as ke, linkRegex as Ce, warnIfUnmounted as Te } from "../../common/utils/index.js";
33
+ import { getPhoneNumberRegex as ve, linkRegex as xe, warnIfUnmounted as Te } from "../../common/utils/index.js";
34
34
  import Ee from "@tiptap/extension-image";
35
- import R from "@tiptap/extension-mention";
36
- import D from "../link/link.js";
37
- import { RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS as $, RICH_TEXT_EDITOR_OUTPUT_FORMATS as Se, RICH_TEXT_EDITOR_AUTOFOCUS_TYPES as Le } from "./rich-text-editor-constants.js";
35
+ import S from "@tiptap/extension-mention";
36
+ import O from "../link/link.js";
37
+ import { DtIconLock as $e } from "@dialpad/dialtone-icons/vue2";
38
+ import { RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS as R, RICH_TEXT_EDITOR_OUTPUT_FORMATS as Le, RICH_TEXT_EDITOR_AUTOFOCUS_TYPES as Se } from "./rich-text-editor-constants.js";
38
39
  import Re from "../avatar/avatar.js";
39
- import $e from "@dialpad/dialtone-icons/vue2/hash";
40
- import Ie from "@dialpad/dialtone-icons/vue2/lock";
41
- import Ae from "deep-equal";
42
- import { DialtoneLocalization as Be } from "../../localization/index.js";
43
- import Oe from "../button/button.js";
44
- const Pe = {
40
+ import Ie from "@dialpad/dialtone-icons/vue2/hash";
41
+ import Ne from "@dialpad/dialtone-icons/vue2/lock";
42
+ import Be from "deep-equal";
43
+ import { DialtoneLocalization as Me } from "../../localization/index.js";
44
+ import Ae from "../button/button.js";
45
+ const Oe = {
45
46
  name: "EmojiComponent",
46
47
  components: {
47
48
  NodeViewWrapper: y,
48
- DtEmoji: P
49
+ DtEmoji: A
49
50
  },
50
- props: _
51
+ props: k
51
52
  };
52
- var De = function() {
53
+ var Pe = function() {
53
54
  var t = this, n = t._self._c;
54
55
  return n("node-view-wrapper", { staticClass: "d-d-inline-block d-va-bottom d-lh0" }, [n("dt-emoji", { attrs: { size: "500", code: t.node.attrs.code } })], 1);
55
- }, Me = [], He = /* @__PURE__ */ c(
56
+ }, De = [], je = /* @__PURE__ */ d(
57
+ Oe,
56
58
  Pe,
57
- De,
58
- Me
59
+ De
59
60
  );
60
- const je = He.exports, Fe = {
61
+ const He = je.exports, Fe = {
61
62
  name: "SuggestionList",
62
63
  components: {
63
64
  DtListItem: be
@@ -121,7 +122,7 @@ const je = He.exports, Fe = {
121
122
  this.command({ name: t.name, id: t.id, avatarSrc: t.avatarSrc });
122
123
  break;
123
124
  case "channel":
124
- this.command({ name: t.name, id: t.id });
125
+ this.command({ name: t.name, id: t.id, locked: t.locked });
125
126
  break;
126
127
  case "slash-command":
127
128
  this.command({ command: t.command });
@@ -130,28 +131,28 @@ const je = He.exports, Fe = {
130
131
  }
131
132
  }
132
133
  };
133
- var Ne = function() {
134
+ var Ke = function() {
134
135
  var t = this, n = t._self._c;
135
136
  return n("div", { staticClass: "d-popover__dialog d-suggestion-list__container" }, [n("ul", { directives: [{ name: "show", rawName: "v-show", value: t.items.length, expression: "items.length" }], ref: "suggestionList", staticClass: "d-suggestion-list" }, t._l(t.items, function(r, s) {
136
137
  return n("dt-list-item", { key: r.id, class: [
137
138
  "d-suggestion-list__item",
138
139
  { "d-list-item--highlighted": s === t.selectedIndex }
139
- ], attrs: { "navigation-type": "arrow-keys" }, on: { click: function(i) {
140
+ ], attrs: { "navigation-type": "arrow-keys" }, on: { click: function(o) {
140
141
  return t.selectItem(s);
141
- }, keydown: function(i) {
142
- return i.preventDefault(), t.onKeyDown.apply(null, arguments);
142
+ }, keydown: function(o) {
143
+ return o.preventDefault(), t.onKeyDown.apply(null, arguments);
143
144
  } } }, [n(t.itemComponent, { tag: "component", attrs: { item: r } })], 1);
144
145
  }), 1)]);
145
- }, Ke = [], Ue = /* @__PURE__ */ c(
146
+ }, qe = [], Ue = /* @__PURE__ */ d(
146
147
  Fe,
147
- Ne,
148
- Ke
148
+ Ke,
149
+ qe
149
150
  );
150
- const k = Ue.exports, We = {
151
+ const v = Ue.exports, We = {
151
152
  name: "EmojiSuggestion",
152
153
  components: {
153
- DtEmoji: P,
154
- DtStack: x
154
+ DtEmoji: A,
155
+ DtStack: f
155
156
  },
156
157
  props: {
157
158
  item: {
@@ -160,15 +161,15 @@ const k = Ue.exports, We = {
160
161
  }
161
162
  }
162
163
  };
163
- var qe = function() {
164
+ var Ve = function() {
164
165
  var t = this, n = t._self._c;
165
166
  return n("dt-stack", { attrs: { direction: "row", gap: "400" } }, [n("dt-emoji", { attrs: { size: "200", code: t.item.code } }), t._v(" " + t._s(t.item.code) + " ")], 1);
166
- }, Ve = [], ze = /* @__PURE__ */ c(
167
+ }, ze = [], Xe = /* @__PURE__ */ d(
167
168
  We,
168
- qe,
169
- Ve
169
+ Ve,
170
+ ze
170
171
  );
171
- const Xe = ze.exports, C = {
172
+ const Je = Xe.exports, x = {
172
173
  name: "hideOnEsc",
173
174
  defaultValue: !0,
174
175
  fn({ hide: e }) {
@@ -184,15 +185,15 @@ const Xe = ze.exports, C = {
184
185
  }
185
186
  };
186
187
  }
187
- }, Je = 20, Ye = (e, t, n) => {
188
- var a, l;
189
- const r = (a = e.shortname) == null ? void 0 : a.replaceAll(":", ""), s = (l = t.shortname) == null ? void 0 : l.replaceAll(":", ""), i = r.startsWith(n), o = s.startsWith(n);
190
- return i && !o ? -1 : !i && o ? 1 : r.localeCompare(s);
191
- }, Ge = {
188
+ }, Ye = 20, Ge = (e, t, n) => {
189
+ var a, c;
190
+ const r = (a = e.shortname) == null ? void 0 : a.replaceAll(":", ""), s = (c = t.shortname) == null ? void 0 : c.replaceAll(":", ""), o = r.startsWith(n), i = s.startsWith(n);
191
+ return o && !i ? -1 : !o && i ? 1 : r.localeCompare(s);
192
+ }, Qe = {
192
193
  items: ({ query: e }) => {
193
194
  if (e.length < 2)
194
195
  return [];
195
- const t = Object.values(ye());
196
+ const t = Object.values(ke());
196
197
  return e = e.toLowerCase(), t.filter(
197
198
  (r) => {
198
199
  var s;
@@ -200,28 +201,28 @@ const Xe = ze.exports, C = {
200
201
  r.name,
201
202
  (s = r.shortname) == null ? void 0 : s.replaceAll(":", ""),
202
203
  ...r.keywords || []
203
- ].some((i) => i && i.startsWith(e));
204
+ ].some((o) => o && o.startsWith(e));
204
205
  }
205
- ).splice(0, Je).sort((r, s) => Ye(r, s, e)).map((r) => ({ code: r.shortname }));
206
+ ).splice(0, Ye).sort((r, s) => Ge(r, s, e)).map((r) => ({ code: r.shortname }));
206
207
  },
207
208
  command: ({ editor: e, range: t, props: n }) => {
208
- var i, o;
209
+ var o, i;
209
210
  const r = e.view.state.selection.$to.nodeAfter;
210
- ((i = r == null ? void 0 : r.text) == null ? void 0 : i.startsWith(" ")) && (t.to += 1), e.chain().focus().insertContentAt(t, [
211
+ ((o = r == null ? void 0 : r.text) == null ? void 0 : o.startsWith(" ")) && (t.to += 1), e.chain().focus().insertContentAt(t, [
211
212
  {
212
213
  type: "emoji",
213
214
  attrs: n
214
215
  }
215
- ]).run(), (o = window.getSelection()) == null || o.collapseToEnd();
216
+ ]).run(), (i = window.getSelection()) == null || i.collapseToEnd();
216
217
  },
217
218
  render: () => {
218
219
  let e, t, n = !1;
219
220
  return {
220
221
  onStart: (r) => {
221
- e = new w(k, {
222
+ e = new w(v, {
222
223
  parent: void 0,
223
224
  propsData: {
224
- itemComponent: Xe,
225
+ itemComponent: Je,
225
226
  itemType: "emoji",
226
227
  ...r
227
228
  },
@@ -241,7 +242,7 @@ const Xe = ze.exports, C = {
241
242
  trigger: "manual",
242
243
  placement: "top-start",
243
244
  zIndex: 650,
244
- plugins: [C]
245
+ plugins: [x]
245
246
  }), r.items.length > 0 && (t == null || t[0].show()));
246
247
  },
247
248
  onUpdate(r) {
@@ -259,14 +260,14 @@ const Xe = ze.exports, C = {
259
260
  }
260
261
  };
261
262
  }
262
- }, Qe = /(:\w+:)$/, Ze = new RegExp(O + "$"), et = (e) => {
263
+ }, Ze = /(:\w+:)$/, et = new RegExp(M + "$"), tt = (e) => {
263
264
  if (e && L(e[0]))
264
265
  return { text: e[2] || e[0] };
265
- }, tt = (e) => [...e.matchAll(xe)].filter((n) => L(n[0])).map((n) => ({
266
+ }, nt = (e) => [...e.matchAll(Ce)].filter((n) => L(n[0])).map((n) => ({
266
267
  index: n.index,
267
268
  text: n[0],
268
269
  match: n
269
- })), nt = N.create({
270
+ })), rt = F.create({
270
271
  name: "emoji",
271
272
  addOptions() {
272
273
  return {
@@ -278,7 +279,7 @@ const Xe = ze.exports, C = {
278
279
  selectable: !1,
279
280
  atom: !0,
280
281
  addNodeView() {
281
- return v(je);
282
+ return C(He);
282
283
  },
283
284
  addAttributes() {
284
285
  return {
@@ -301,7 +302,7 @@ const Xe = ze.exports, C = {
301
302
  ];
302
303
  },
303
304
  renderText({ node: e }) {
304
- return ve(L(e.attrs.code).unicode_output);
305
+ return we(L(e.attrs.code).unicode_output);
305
306
  },
306
307
  renderHTML({ HTMLAttributes: e }) {
307
308
  return ["emoji-component", m(this.options.HTMLAttributes, e)];
@@ -310,13 +311,13 @@ const Xe = ze.exports, C = {
310
311
  return [
311
312
  new K({
312
313
  find: (e) => {
313
- const t = e.match(Qe) || e.match(Ze);
314
+ const t = e.match(Ze) || e.match(et);
314
315
  if (t)
315
- return et(t);
316
+ return tt(t);
316
317
  },
317
318
  handler: ({ state: e, range: t, match: n }) => {
318
- const { tr: r } = e, s = t.from, i = t.to;
319
- r.replaceWith(s, i, this.type.create({ code: n[0] }));
319
+ const { tr: r } = e, s = t.from, o = t.to;
320
+ r.replaceWith(s, o, this.type.create({ code: n[0] }));
320
321
  }
321
322
  })
322
323
  ];
@@ -324,7 +325,7 @@ const Xe = ze.exports, C = {
324
325
  addPasteRules() {
325
326
  return [
326
327
  E({
327
- find: tt,
328
+ find: nt,
328
329
  type: this.type,
329
330
  getAttributes(e) {
330
331
  return {
@@ -335,7 +336,7 @@ const Xe = ze.exports, C = {
335
336
  }
336
337
  }),
337
338
  E({
338
- find: we,
339
+ find: ye,
339
340
  type: this.type,
340
341
  getAttributes(e) {
341
342
  return {
@@ -351,10 +352,10 @@ const Xe = ze.exports, C = {
351
352
  return [
352
353
  _e({
353
354
  char: ":",
354
- pluginKey: new f("emoji"),
355
+ pluginKey: new p("emoji"),
355
356
  editor: this.editor,
356
357
  ...this.options.suggestion,
357
- ...Ge
358
+ ...Qe
358
359
  })
359
360
  ];
360
361
  },
@@ -362,16 +363,16 @@ const Xe = ze.exports, C = {
362
363
  return {
363
364
  Backspace: () => this.editor.commands.command(({ tr: e, state: t }) => {
364
365
  let n = !1;
365
- const { selection: r } = t, { empty: s, anchor: i } = r;
366
- return s ? (t.doc.nodesBetween(i - 1, i, (o, a) => {
367
- if (o.type.name === this.name)
368
- return n = !0, e.insertText("", a, a + o.nodeSize), !1;
366
+ const { selection: r } = t, { empty: s, anchor: o } = r;
367
+ return s ? (t.doc.nodesBetween(o - 1, o, (i, a) => {
368
+ if (i.type.name === this.name)
369
+ return n = !0, e.insertText("", a, a + i.nodeSize), !1;
369
370
  }), n) : !1;
370
371
  })
371
372
  };
372
373
  }
373
374
  });
374
- function rt(e, t, n = () => !0) {
375
+ function st(e, t, n = () => !0) {
375
376
  const r = [];
376
377
  t.lastIndex = 0;
377
378
  let s;
@@ -379,7 +380,7 @@ function rt(e, t, n = () => !0) {
379
380
  n(e, s) && r.push(s);
380
381
  return r;
381
382
  }
382
- function st(e, t) {
383
+ function ot(e, t) {
383
384
  return !["#", "@"].includes(e.charAt(t.index)) && !["#", "@"].includes(e.charAt(t.index - 1));
384
385
  }
385
386
  function it(e) {
@@ -392,7 +393,7 @@ function it(e) {
392
393
  );
393
394
  return e.replace(t, "");
394
395
  }
395
- function ot(e, t) {
396
+ function at(e, t) {
396
397
  const n = e.slice(0, t + 1).search(/\S+\s*$/), r = e.slice(t).search(/\s/);
397
398
  if (r < 0) {
398
399
  const s = e.slice(n);
@@ -408,77 +409,77 @@ function ot(e, t) {
408
409
  to: r + t
409
410
  };
410
411
  }
411
- function S(e, t, n, r) {
412
- const s = ot(e, t);
412
+ function $(e, t, n, r) {
413
+ const s = at(e, t);
413
414
  if (r.lastIndex = 0, !r.test(s.text))
414
415
  return s;
415
- const i = n === "left" ? s.from - 1 : s.to + 1;
416
- return i <= 0 || i >= e.length || i === t ? s : S(e, i, n, r);
416
+ const o = n === "left" ? s.from - 1 : s.to + 1;
417
+ return o <= 0 || o >= e.length || o === t ? s : $(e, o, n, r);
417
418
  }
418
- function at(e, t, n, r) {
419
- const s = Math.max(e.from - 1, 0), i = Math.min(e.to + 1, t.content.size), o = U(s, i, t);
420
- for (const a of o)
419
+ function ct(e, t, n, r) {
420
+ const s = Math.max(e.from - 1, 0), o = Math.min(e.to + 1, t.content.size), i = q(s, o, t);
421
+ for (const a of i)
421
422
  a.mark.type === r && n.removeMark(a.from, a.to, r);
422
423
  }
423
- const I = ke(1, 15);
424
- function A(e, t, n, r, s, i) {
424
+ const I = ve(1, 15);
425
+ function N(e, t, n, r, s, o) {
425
426
  if (!e)
426
427
  return;
427
- let o = n - t - 1;
428
- o = o < 0 ? 0 : o;
429
- const a = r - t, l = S(
428
+ let i = n - t - 1;
429
+ i = i < 0 ? 0 : i;
430
+ const a = r - t, c = $(
430
431
  e,
431
- o,
432
+ i,
432
433
  "left",
433
434
  I
434
- ), d = S(
435
+ ), l = $(
435
436
  e,
436
437
  a,
437
438
  "right",
438
439
  I
439
- ), u = e.slice(l.from, d.to);
440
- rt(u, Ce, st).forEach((T) => {
441
- const h = it(T[0]), g = t + l.from + T.index + 1, M = g + h.length;
442
- s.addMark(g, M, i.create());
440
+ ), u = e.slice(c.from, l.to);
441
+ st(u, xe, ot).forEach((T) => {
442
+ const h = it(T[0]), _ = t + c.from + T.index + 1, P = _ + h.length;
443
+ s.addMark(_, P, o.create());
443
444
  });
444
445
  }
445
- function lt(e) {
446
+ function dt(e) {
446
447
  let t = !1;
447
448
  return new ge({
448
- key: new f("autolink"),
449
+ key: new p("autolink"),
449
450
  appendTransaction: (n, r, s) => {
450
- const i = n.some((u) => u.docChanged) && !r.doc.eq(s.doc);
451
- if (t && !i)
451
+ const o = n.some((u) => u.docChanged) && !r.doc.eq(s.doc);
452
+ if (t && !o)
452
453
  return;
453
- const { tr: o } = s, { textContent: a } = s.doc;
454
- t || A(a, 0, 0, a.length, o, e.type), t = !0;
455
- const l = W(
454
+ const { tr: i } = s, { textContent: a } = s.doc;
455
+ t || N(a, 0, 0, a.length, i, e.type), t = !0;
456
+ const c = U(
456
457
  r.doc,
457
458
  [...n]
458
459
  );
459
- return q(l).forEach(({ oldRange: u, newRange: p }) => {
460
- at(p, s.doc, o, e.type), V(
460
+ return W(c).forEach(({ oldRange: u, newRange: g }) => {
461
+ ct(g, s.doc, i, e.type), V(
461
462
  s.doc,
462
- p,
463
+ g,
463
464
  (h) => h.isTextblock
464
- ).forEach(({ node: h, pos: g }) => {
465
- A(
465
+ ).forEach(({ node: h, pos: _ }) => {
466
+ N(
466
467
  h.textContent,
467
- g,
468
+ _,
468
469
  u.from,
469
- p.to,
470
- o,
470
+ g.to,
471
+ i,
471
472
  e.type
472
473
  );
473
474
  });
474
- }), o;
475
+ }), i;
475
476
  }
476
477
  });
477
478
  }
478
- const ct = {
479
+ const lt = {
479
480
  class: "d-link d-c-text d-d-inline-block d-wb-break-all",
480
481
  rel: "noopener noreferrer nofollow"
481
- }, dt = z.create({
482
+ }, ut = z.create({
482
483
  name: "CustomLink",
483
484
  renderHTML({ HTMLAttributes: e }) {
484
485
  return [
@@ -486,7 +487,7 @@ const ct = {
486
487
  m(
487
488
  this.options.HTMLAttributes,
488
489
  e,
489
- ct
490
+ lt
490
491
  )
491
492
  ];
492
493
  },
@@ -495,10 +496,10 @@ const ct = {
495
496
  },
496
497
  addProseMirrorPlugins() {
497
498
  return [
498
- lt({ type: this.type })
499
+ dt({ type: this.type })
499
500
  ];
500
501
  }
501
- }), ut = Ee.extend({
502
+ }), mt = Ee.extend({
502
503
  name: "ConfigurableImage",
503
504
  addAttributes() {
504
505
  return {
@@ -522,20 +523,20 @@ const ct = {
522
523
  }
523
524
  };
524
525
  }
525
- }).configure({ inline: !0, allowBase64: !0 }), mt = B.extend({
526
+ }).configure({ inline: !0, allowBase64: !0 }), ht = B.extend({
526
527
  parseHTML() {
527
528
  return [{ tag: "div" }];
528
529
  },
529
530
  renderHTML({ HTMLAttributes: e }) {
530
531
  return ["div", m(this.options.HTMLAttributes, e), 0];
531
532
  }
532
- }), ht = {
533
+ }), pt = {
533
534
  name: "MentionComponent",
534
535
  components: {
535
536
  NodeViewWrapper: y,
536
- DtLink: D
537
+ DtLink: O
537
538
  },
538
- props: _,
539
+ props: k,
539
540
  computed: {
540
541
  text() {
541
542
  return "@" + this.$props.node.attrs.name;
@@ -545,14 +546,14 @@ const ct = {
545
546
  var ft = function() {
546
547
  var t = this, n = t._self._c;
547
548
  return n("node-view-wrapper", { staticClass: "d-d-inline-block" }, [n("dt-link", { attrs: { kind: "mention" } }, [t._v(" " + t._s(t.text) + " ")])], 1);
548
- }, pt = [], gt = /* @__PURE__ */ c(
549
- ht,
549
+ }, gt = [], _t = /* @__PURE__ */ d(
550
+ pt,
550
551
  ft,
551
- pt
552
+ gt
552
553
  );
553
- const _t = gt.exports, yt = R.extend({
554
+ const kt = _t.exports, yt = S.extend({
554
555
  addNodeView() {
555
- return v(_t);
556
+ return C(kt);
556
557
  },
557
558
  parseHTML() {
558
559
  return [
@@ -571,6 +572,9 @@ const _t = gt.exports, yt = R.extend({
571
572
  },
572
573
  id: {
573
574
  default: ""
575
+ },
576
+ contactKey: {
577
+ default: ""
574
578
  }
575
579
  };
576
580
  },
@@ -583,33 +587,35 @@ const _t = gt.exports, yt = R.extend({
583
587
  }).configure({
584
588
  suggestion: {
585
589
  char: "@",
586
- pluginKey: new f("mentionSuggestion")
590
+ pluginKey: new p("mentionSuggestion")
587
591
  }
588
592
  }), wt = {
589
593
  name: "ChannelComponent",
590
594
  components: {
591
595
  NodeViewWrapper: y,
592
- DtLink: D
596
+ DtLink: O,
597
+ DtIconLock: $e,
598
+ DtStack: f
593
599
  },
594
- props: _,
600
+ props: k,
595
601
  computed: {
596
602
  text() {
597
- return "#" + this.$props.node.attrs.name;
603
+ return this.$props.node.attrs.locked ? this.$props.node.attrs.name : "#" + this.$props.node.attrs.name;
598
604
  }
599
605
  }
600
606
  };
601
- var vt = function() {
607
+ var Ct = function() {
602
608
  var t = this, n = t._self._c;
603
- return n("node-view-wrapper", { staticClass: "d-d-inline-block" }, [n("dt-link", { attrs: { kind: "mention" } }, [t._v(" " + t._s(t.text) + " ")])], 1);
604
- }, xt = [], bt = /* @__PURE__ */ c(
609
+ return n("node-view-wrapper", { staticClass: "d-d-inline-block" }, [n("dt-link", { attrs: { kind: "mention" } }, [n("dt-stack", { attrs: { direction: "row", gap: "0" } }, [t.$props.node.attrs.locked ? n("dt-icon-lock", { attrs: { size: "200" } }) : t._e(), n("span", [t._v(t._s(t.text))])], 1)], 1)], 1);
610
+ }, bt = [], vt = /* @__PURE__ */ d(
605
611
  wt,
606
- vt,
607
- xt
612
+ Ct,
613
+ bt
608
614
  );
609
- const kt = bt.exports, Ct = R.extend({
615
+ const xt = vt.exports, Tt = S.extend({
610
616
  name: "channel",
611
617
  addNodeView() {
612
- return v(kt);
618
+ return C(xt);
613
619
  },
614
620
  parseHTML() {
615
621
  return [
@@ -640,15 +646,15 @@ const kt = bt.exports, Ct = R.extend({
640
646
  }).configure({
641
647
  suggestion: {
642
648
  char: "#",
643
- pluginKey: new f("channelSuggestion")
649
+ pluginKey: new p("channelSuggestion")
644
650
  }
645
- }), Tt = {
651
+ }), Et = {
646
652
  name: "SlashCommandsComponent",
647
653
  components: {
648
654
  NodeViewWrapper: y
649
655
  },
650
656
  props: {
651
- ..._
657
+ ...k
652
658
  },
653
659
  emits: ["selected-command"],
654
660
  computed: {
@@ -664,22 +670,22 @@ const kt = bt.exports, Ct = R.extend({
664
670
  t && typeof t == "function" && t(e);
665
671
  }
666
672
  };
667
- var Et = function() {
673
+ var $t = function() {
668
674
  var t = this, n = t._self._c;
669
675
  return n("node-view-wrapper", { staticClass: "d-d-inline-block" }, [t._v(" " + t._s(t.text) + " ")]);
670
- }, St = [], Lt = /* @__PURE__ */ c(
671
- Tt,
676
+ }, Lt = [], St = /* @__PURE__ */ d(
672
677
  Et,
673
- St
678
+ $t,
679
+ Lt
674
680
  );
675
- const Rt = Lt.exports, $t = (e, t) => [...e.matchAll(t)].map((r) => {
681
+ const Rt = St.exports, It = (e, t) => [...e.matchAll(t)].map((r) => {
676
682
  let s = r[2];
677
683
  return s.endsWith(" ") || (s += " "), {
678
684
  index: r.index,
679
685
  text: s,
680
686
  match: r
681
687
  };
682
- }), It = R.extend({
688
+ }), Nt = S.extend({
683
689
  name: "slash-commands",
684
690
  group: "inline",
685
691
  inline: !0,
@@ -696,7 +702,7 @@ const Rt = Lt.exports, $t = (e, t) => [...e.matchAll(t)].map((r) => {
696
702
  };
697
703
  },
698
704
  addNodeView() {
699
- return v(Rt);
705
+ return C(Rt);
700
706
  },
701
707
  parseHTML() {
702
708
  return [
@@ -742,7 +748,7 @@ const Rt = Lt.exports, $t = (e, t) => [...e.matchAll(t)].map((r) => {
742
748
  const e = (n = this.options.suggestion) == null ? void 0 : n.items({ query: "" }).map((r) => r.command), t = new RegExp(`^((?:\\/)(${e.join("|")})) ?$`, "g");
743
749
  return [
744
750
  E({
745
- find: (r) => $t(r, t),
751
+ find: (r) => It(r, t),
746
752
  type: this.type,
747
753
  getAttributes(r) {
748
754
  return { command: r[0].trim() };
@@ -753,13 +759,13 @@ const Rt = Lt.exports, $t = (e, t) => [...e.matchAll(t)].map((r) => {
753
759
  }).configure({
754
760
  suggestion: {
755
761
  char: "/",
756
- pluginKey: new f("slashCommandSuggestion")
762
+ pluginKey: new p("slashCommandSuggestion")
757
763
  }
758
- }), At = {
764
+ }), Bt = {
759
765
  name: "MentionSuggestion",
760
766
  components: {
761
767
  DtAvatar: Re,
762
- DtStack: x
768
+ DtStack: f
763
769
  },
764
770
  props: {
765
771
  item: {
@@ -796,15 +802,15 @@ const Rt = Lt.exports, $t = (e, t) => [...e.matchAll(t)].map((r) => {
796
802
  }
797
803
  }
798
804
  };
799
- var Bt = function() {
805
+ var Mt = function() {
800
806
  var t = this, n = t._self._c;
801
807
  return n("dt-stack", { staticClass: "d-mention-suggestion__container", attrs: { direction: "row", gap: "400" } }, [n("dt-avatar", { attrs: { "full-name": t.name, "image-src": t.avatarSrc, "image-alt": t.name, "show-presence": t.showDetails, presence: t.presence, size: "sm" } }), n("dt-stack", { staticClass: "d-mention-suggestion__details-container", attrs: { gap: "100" } }, [n("span", { staticClass: "d-mention-suggestion__name" }, [t._v(" " + t._s(t.name) + " ")]), t.showDetails ? n("dt-stack", { staticClass: "d-label--sm-plain", attrs: { direction: "row", gap: "300" } }, [t.presenceText ? n("span", { staticClass: "d-mention-suggestion__presence", class: [t.presenceFontColorClass] }, [t._v(" " + t._s(t.presenceText) + " ")]) : t._e(), t.status && t.presenceText ? n("div", { staticClass: "d-mention-suggestion__divider" }, [t._v(" • ")]) : t._e(), t.status ? n("div", { staticClass: "d-mention-suggestion__status" }, [t._v(" " + t._s(t.status) + " ")]) : t._e()]) : t._e()], 1)], 1);
802
- }, Ot = [], Pt = /* @__PURE__ */ c(
803
- At,
808
+ }, At = [], Ot = /* @__PURE__ */ d(
804
809
  Bt,
805
- Ot
810
+ Mt,
811
+ At
806
812
  );
807
- const Dt = Pt.exports, Mt = {
813
+ const Pt = Ot.exports, Dt = {
808
814
  // This function comes from the user and passed to the editor directly.
809
815
  // This will also activate the mention plugin on the editor
810
816
  // items: ({ query }) => { return [] },
@@ -813,10 +819,10 @@ const Dt = Pt.exports, Mt = {
813
819
  let e, t, n = !1;
814
820
  return {
815
821
  onStart: (r) => {
816
- e = new w(k, {
822
+ e = new w(v, {
817
823
  parent: void 0,
818
824
  propsData: {
819
- itemComponent: Dt,
825
+ itemComponent: Pt,
820
826
  itemType: "mention",
821
827
  ...r
822
828
  },
@@ -836,7 +842,7 @@ const Dt = Pt.exports, Mt = {
836
842
  trigger: "manual",
837
843
  placement: "top-start",
838
844
  zIndex: 650,
839
- plugins: [C]
845
+ plugins: [x]
840
846
  }), r.items.length > 0 && (t == null || t[0].show()));
841
847
  },
842
848
  onUpdate(r) {
@@ -854,12 +860,12 @@ const Dt = Pt.exports, Mt = {
854
860
  }
855
861
  };
856
862
  }
857
- }, Ht = {
863
+ }, jt = {
858
864
  name: "ChannelSuggestion",
859
865
  components: {
860
- DtStack: x,
861
- DtIconHash: $e,
862
- DtIconLock: Ie
866
+ DtStack: f,
867
+ DtIconHash: Ie,
868
+ DtIconLock: Ne
863
869
  },
864
870
  props: {
865
871
  item: {
@@ -873,15 +879,15 @@ const Dt = Pt.exports, Mt = {
873
879
  }
874
880
  }
875
881
  };
876
- var jt = function() {
882
+ var Ht = function() {
877
883
  var t = this, n = t._self._c;
878
884
  return n("dt-stack", { attrs: { direction: "row", gap: "400" } }, [t.item.locked ? n("dt-icon-lock", { attrs: { size: "300" } }) : n("dt-icon-hash", { attrs: { size: "300" } }), n("span", [t._v(t._s(t.name))])], 1);
879
- }, Ft = [], Nt = /* @__PURE__ */ c(
880
- Ht,
885
+ }, Ft = [], Kt = /* @__PURE__ */ d(
881
886
  jt,
887
+ Ht,
882
888
  Ft
883
889
  );
884
- const Kt = Nt.exports, Ut = {
890
+ const qt = Kt.exports, Ut = {
885
891
  // This function comes from the user and passed to the editor directly.
886
892
  // This will also activate the mention plugin on the editor
887
893
  // items: ({ query }) => { return [] },
@@ -890,10 +896,10 @@ const Kt = Nt.exports, Ut = {
890
896
  let e, t, n = !1;
891
897
  return {
892
898
  onStart: (r) => {
893
- e = new w(k, {
899
+ e = new w(v, {
894
900
  parent: void 0,
895
901
  propsData: {
896
- itemComponent: Kt,
902
+ itemComponent: qt,
897
903
  itemType: "channel",
898
904
  ...r
899
905
  },
@@ -913,7 +919,7 @@ const Kt = Nt.exports, Ut = {
913
919
  trigger: "manual",
914
920
  placement: "top-start",
915
921
  zIndex: 650,
916
- plugins: [C]
922
+ plugins: [x]
917
923
  }), r.items.length > 0 && (t == null || t[0].show()));
918
924
  },
919
925
  onUpdate(r) {
@@ -951,15 +957,15 @@ const Kt = Nt.exports, Ut = {
951
957
  }
952
958
  }
953
959
  };
954
- var qt = function() {
960
+ var Vt = function() {
955
961
  var t = this, n = t._self._c;
956
962
  return n("div", [n("div", { staticClass: "d-body--md-compact" }, [n("span", [t._v("/" + t._s(t.command))]), t.parametersExample ? n("span", [t._v(" " + t._s(t.parametersExample))]) : t._e()]), n("div", { staticClass: "d-body--sm d-fc-tertiary" }, [t._v(" " + t._s(t.description) + " ")])]);
957
- }, Vt = [], zt = /* @__PURE__ */ c(
963
+ }, zt = [], Xt = /* @__PURE__ */ d(
958
964
  Wt,
959
- qt,
960
- Vt
965
+ Vt,
966
+ zt
961
967
  );
962
- const Xt = zt.exports, Jt = {
968
+ const Jt = Xt.exports, Yt = {
963
969
  // This function comes from the user and passed to the editor directly.
964
970
  // This will also activate the mention plugin on the editor
965
971
  // items: ({ query }) => { return [] },
@@ -969,10 +975,10 @@ const Xt = zt.exports, Jt = {
969
975
  let e, t, n = !1;
970
976
  return {
971
977
  onStart: (r) => {
972
- e = new w(k, {
978
+ e = new w(v, {
973
979
  parent: void 0,
974
980
  propsData: {
975
- itemComponent: Xt,
981
+ itemComponent: Jt,
976
982
  itemType: "slash-command",
977
983
  ...r
978
984
  },
@@ -992,7 +998,7 @@ const Xt = zt.exports, Jt = {
992
998
  trigger: "manual",
993
999
  placement: "top-start",
994
1000
  zIndex: 650,
995
- plugins: [C]
1001
+ plugins: [x]
996
1002
  }), r.items.length > 0 && (t == null || t[0].show()));
997
1003
  },
998
1004
  onUpdate(r) {
@@ -1010,13 +1016,13 @@ const Xt = zt.exports, Jt = {
1010
1016
  }
1011
1017
  };
1012
1018
  }
1013
- }, Yt = {
1019
+ }, Gt = {
1014
1020
  name: "DtRichTextEditor",
1015
1021
  components: {
1016
1022
  EditorContent: j,
1017
- BubbleMenu: H,
1018
- DtButton: Oe,
1019
- DtStack: x
1023
+ BubbleMenu: D,
1024
+ DtButton: Ae,
1025
+ DtStack: f
1020
1026
  },
1021
1027
  props: {
1022
1028
  /**
@@ -1088,20 +1094,20 @@ const Xt = zt.exports, Jt = {
1088
1094
  type: [Boolean, String, Number],
1089
1095
  default: !1,
1090
1096
  validator(e) {
1091
- return typeof e == "string" ? Le.includes(e) : !0;
1097
+ return typeof e == "string" ? Se.includes(e) : !0;
1092
1098
  }
1093
1099
  },
1094
1100
  /**
1095
1101
  * The output format that the editor uses when emitting the "@input" event.
1096
- * One of `text`, `json`, `html`. See https://tiptap.dev/guide/output for
1102
+ * One of `text`, `json`, `html`, `markdown`. See https://tiptap.dev/guide/output for
1097
1103
  * examples.
1098
- * @values text, json, html
1104
+ * @values text, json, html, markdown
1099
1105
  */
1100
1106
  outputFormat: {
1101
1107
  type: String,
1102
1108
  default: "html",
1103
1109
  validator(e) {
1104
- return Se.includes(e);
1110
+ return Le.includes(e);
1105
1111
  }
1106
1112
  },
1107
1113
  /**
@@ -1309,6 +1315,12 @@ const Xt = zt.exports, Jt = {
1309
1315
  * @type {String}
1310
1316
  */
1311
1317
  "text-input",
1318
+ /**
1319
+ * Input event always in markdown format.
1320
+ * @event input
1321
+ * @type {String}
1322
+ */
1323
+ "markdown-input",
1312
1324
  /**
1313
1325
  * Event to sync the value with the parent
1314
1326
  * @event update:value
@@ -1364,7 +1376,124 @@ const Xt = zt.exports, Jt = {
1364
1376
  },
1365
1377
  placement: "top-start"
1366
1378
  },
1367
- i18n: new Be()
1379
+ i18n: new Me(),
1380
+ // JSON-to-markdown converter
1381
+ jsonToMarkdownConverter: {
1382
+ convertToMarkdown(e) {
1383
+ return this.processNode(e);
1384
+ },
1385
+ processNodeContent(e) {
1386
+ return e.content ? e.content.map((t) => this.processNode(t)).join("") : "";
1387
+ },
1388
+ processNode(e) {
1389
+ if (!e) return "";
1390
+ const n = {
1391
+ doc: (r) => this.processDocNode(r),
1392
+ paragraph: (r) => this.processParagraphNode(r),
1393
+ text: (r) => this.processTextNode(r),
1394
+ hardBreak: () => this.processHardBreakNode(),
1395
+ blockquote: (r) => this.processBlockquoteNode(r),
1396
+ bulletList: (r) => this.processBulletListNode(r),
1397
+ orderedList: (r) => this.processOrderedListNode(r),
1398
+ listItem: (r) => this.processListItemNode(r),
1399
+ codeBlock: (r) => this.processCodeBlockNode(r),
1400
+ mention: (r) => this.processMentionNode(r),
1401
+ channel: (r) => this.processChannelNode(r),
1402
+ "slash-commands": (r) => this.processSlashCommandsNode(r),
1403
+ emoji: (r) => this.processEmojiNode(r)
1404
+ }[e.type];
1405
+ return n ? n(e) : this.processUnknownNode(e);
1406
+ },
1407
+ processDocNode(e) {
1408
+ return this.processNodeContent(e);
1409
+ },
1410
+ processParagraphNode(e) {
1411
+ const t = this.processNodeContent(e);
1412
+ return t ? t + `
1413
+ ` : `
1414
+ `;
1415
+ },
1416
+ processTextNode(e) {
1417
+ let t = e.text || "";
1418
+ return e.marks && (t = this.applyMarks(t, e.marks)), t;
1419
+ },
1420
+ processHardBreakNode() {
1421
+ return `
1422
+ `;
1423
+ },
1424
+ processBlockquoteNode(e) {
1425
+ return this.processNodeContent(e).split(`
1426
+ `).map((n) => n ? `> ${n}` : ">").join(`
1427
+ `) + `
1428
+ `;
1429
+ },
1430
+ processBulletListNode(e) {
1431
+ return this.processNodeContent(e);
1432
+ },
1433
+ processOrderedListNode(e) {
1434
+ return e.content ? e.content.map((t, n) => this.processNode(t).replace(/^- /, `${n + 1}. `)).join("") : "";
1435
+ },
1436
+ processListItemNode(e) {
1437
+ const t = this.processNodeContent(e);
1438
+ return t ? `- ${t.replace(/\n$/, "")}
1439
+ ` : "";
1440
+ },
1441
+ processCodeBlockNode(e) {
1442
+ return `\`\`\`
1443
+ ${this.processNodeContent(e)}
1444
+ \`\`\``;
1445
+ },
1446
+ processMentionNode(e) {
1447
+ var s, o, i;
1448
+ const t = ((s = e.attrs) == null ? void 0 : s.name) || "", n = ((o = e.attrs) == null ? void 0 : o.id) || "", r = ((i = e.attrs) == null ? void 0 : i.contactKey) || "";
1449
+ return `<!-- @mention: {"id": "${n}", "contactKey": "${r}", "name": "${t}"} -->`;
1450
+ },
1451
+ processChannelNode(e) {
1452
+ var s, o, i;
1453
+ const t = ((s = e.attrs) == null ? void 0 : s.name) || "", n = ((o = e.attrs) == null ? void 0 : o.id) || "", r = ((i = e.attrs) == null ? void 0 : i.locked.toString()) || "";
1454
+ return `<!-- @channel: {"id": "${n}", "name": "${t}", "locked": "${r}"} -->`;
1455
+ },
1456
+ processSlashCommandsNode(e) {
1457
+ var r, s;
1458
+ const t = ((r = e.attrs) == null ? void 0 : r.command) || "", n = ((s = e.attrs) == null ? void 0 : s.parameters) || "";
1459
+ return `/${t}${n ? ` ${n}` : ""}`;
1460
+ },
1461
+ processEmojiNode(e) {
1462
+ var t;
1463
+ return ((t = e.attrs) == null ? void 0 : t.code) || "";
1464
+ },
1465
+ processUnknownNode(e) {
1466
+ return this.processNodeContent(e);
1467
+ },
1468
+ applyMarks(e, t) {
1469
+ let n = e;
1470
+ return [...t].sort((s, o) => {
1471
+ const i = { link: 0, bold: 1, italic: 2, strike: 3, code: 4 };
1472
+ return (i[s.type] || 5) - (i[o.type] || 5);
1473
+ }).forEach((s) => {
1474
+ var o;
1475
+ switch (s.type) {
1476
+ case "bold":
1477
+ n = `**${n}**`;
1478
+ break;
1479
+ case "italic":
1480
+ n = `*${n}*`;
1481
+ break;
1482
+ case "strike":
1483
+ n = `~~${n}~~`;
1484
+ break;
1485
+ case "code":
1486
+ n = `\`${n}\``;
1487
+ break;
1488
+ case "link": {
1489
+ const i = ((o = s.attrs) == null ? void 0 : o.href) || "";
1490
+ n = `[${n}](${i})`;
1491
+ break;
1492
+ }
1493
+ }
1494
+ }), n;
1495
+ }
1496
+ }
1368
1497
  };
1369
1498
  },
1370
1499
  computed: {
@@ -1381,12 +1510,12 @@ const Xt = zt.exports, Jt = {
1381
1510
  },
1382
1511
  // eslint-disable-next-line complexity
1383
1512
  extensions() {
1384
- const e = [Z, de, me, te];
1385
- e.push(this.useDivTags ? mt : B), this.allowBold && e.push(ne), this.allowBlockquote && e.push(Y), this.allowBulletList && (e.push(re), e.push(oe.extend({
1513
+ const e = [Z, le, me, te];
1514
+ e.push(this.useDivTags ? ht : B), this.allowBold && e.push(ne), this.allowBlockquote && e.push(Y), this.allowBulletList && (e.push(re), e.push(ie.extend({
1386
1515
  renderText({ node: r }) {
1387
1516
  return r.textContent;
1388
1517
  }
1389
- })), e.push(ae)), this.allowItalic && e.push(se), this.allowStrike && e.push(le), this.allowUnderline && e.push(ce), this.placeholder && e.push(
1518
+ })), e.push(ae)), this.allowItalic && e.push(se), this.allowStrike && e.push(ce), this.allowUnderline && e.push(de), this.placeholder && e.push(
1390
1519
  ee.configure({ placeholder: this.placeholder })
1391
1520
  );
1392
1521
  const t = this, n = J.create({
@@ -1403,7 +1532,7 @@ const Xt = zt.exports, Jt = {
1403
1532
  };
1404
1533
  }
1405
1534
  });
1406
- if (e.push(n), this.link && e.push(ie.extend({
1535
+ if (e.push(n), this.link && e.push(oe.extend({
1407
1536
  inclusive: !1,
1408
1537
  addKeyboardShortcuts() {
1409
1538
  return {
@@ -1416,25 +1545,25 @@ const Xt = zt.exports, Jt = {
1416
1545
  },
1417
1546
  openOnClick: !1,
1418
1547
  autolink: !0,
1419
- protocols: $
1420
- })), this.customLink && e.push(this.getExtension(dt, this.customLink)), this.mentionSuggestion) {
1421
- const r = { ...this.mentionSuggestion, ...Mt };
1548
+ protocols: R
1549
+ })), this.customLink && e.push(this.getExtension(ut, this.customLink)), this.mentionSuggestion) {
1550
+ const r = { ...this.mentionSuggestion, ...Dt };
1422
1551
  e.push(yt.configure({ suggestion: r }));
1423
1552
  }
1424
1553
  if (this.channelSuggestion) {
1425
1554
  const r = { ...this.channelSuggestion, ...Ut };
1426
- e.push(Ct.configure({ suggestion: r }));
1555
+ e.push(Tt.configure({ suggestion: r }));
1427
1556
  }
1428
1557
  if (this.slashCommandSuggestion) {
1429
- const r = { ...this.slashCommandSuggestion, ...Jt };
1430
- e.push(It.configure({
1558
+ const r = { ...this.slashCommandSuggestion, ...Yt };
1559
+ e.push(Nt.configure({
1431
1560
  suggestion: r,
1432
1561
  onSelectedCommand: (s) => {
1433
1562
  this.$emit("selected-command", s);
1434
1563
  }
1435
1564
  }));
1436
1565
  }
1437
- return e.push(nt), e.push(ue.configure({
1566
+ return e.push(rt), e.push(ue.configure({
1438
1567
  types: ["paragraph"]
1439
1568
  })), this.allowCode && e.push(Q), this.allowCodeblock && e.push(G.extend({
1440
1569
  renderText({ node: r }) {
@@ -1446,7 +1575,7 @@ ${r.textContent}
1446
1575
  HTMLAttributes: {
1447
1576
  class: "d-rich-text-editor__code-block"
1448
1577
  }
1449
- })), this.allowInlineImages && e.push(ut), (this.allowFontFamily || this.allowFontColor) && (e.push(he), this.allowFontColor && e.push(fe), this.allowFontFamily && e.push(pe)), this.additionalExtensions.length && e.push(...this.additionalExtensions), e;
1578
+ })), this.allowInlineImages && e.push(mt), (this.allowFontFamily || this.allowFontColor) && (e.push(he), this.allowFontColor && e.push(pe), this.allowFontFamily && e.push(fe)), this.additionalExtensions.length && e.push(...this.additionalExtensions), e;
1450
1579
  },
1451
1580
  inputAttrs() {
1452
1581
  const e = {
@@ -1490,7 +1619,7 @@ ${r.textContent}
1490
1619
  },
1491
1620
  methods: {
1492
1621
  createEditor() {
1493
- this.editor = new F({
1622
+ this.editor = new H({
1494
1623
  autofocus: this.autoFocus,
1495
1624
  content: this.value,
1496
1625
  editable: this.editable,
@@ -1529,9 +1658,9 @@ ${r.textContent}
1529
1658
  * @param editor the editor instance.
1530
1659
  */
1531
1660
  getSelectedLinkText(e) {
1532
- var a, l, d;
1533
- const { view: t, state: n } = e, { from: r, to: s } = t.state.selection, i = n.doc.textBetween(r, s, ""), o = this.editor.state.doc.nodeAt(r);
1534
- return o && ((d = (l = (a = o.marks) == null ? void 0 : a.at(0)) == null ? void 0 : l.type) == null ? void 0 : d.name) === "link" ? o.textContent : i;
1661
+ var a, c, l;
1662
+ const { view: t, state: n } = e, { from: r, to: s } = t.state.selection, o = n.doc.textBetween(r, s, ""), i = this.editor.state.doc.nodeAt(r);
1663
+ return i && ((l = (c = (a = i.marks) == null ? void 0 : a.at(0)) == null ? void 0 : c.type) == null ? void 0 : l.name) === "link" ? i.textContent : o;
1535
1664
  },
1536
1665
  editLink() {
1537
1666
  const e = this.getSelectedLinkText(this.editor), t = {
@@ -1550,23 +1679,21 @@ ${r.textContent}
1550
1679
  const e = this.editor.getAttributes("link").href;
1551
1680
  window.open(e, "_blank");
1552
1681
  },
1553
- // eslint-disable-next-line complexity
1554
- setLink(e, t, n, r = $, s) {
1555
- var a, l, d;
1682
+ setLink(e, t, n, r = R, s) {
1683
+ var a, c, l;
1556
1684
  if (!e) {
1557
1685
  this.removeLink();
1558
1686
  return;
1559
1687
  }
1560
1688
  r.find((u) => u.test(e)) || (e = `${s}${e}`), this.editor.chain().focus().extendMarkRange("link").run();
1561
- const o = (d = (l = (a = this.editor) == null ? void 0 : a.view) == null ? void 0 : l.state) == null ? void 0 : d.selection;
1562
- this.editor.chain().focus().insertContent(t).setTextSelection({ from: o.from, to: o.from + t.length }).setLink({ href: e, class: n.class }).run();
1689
+ const i = (l = (c = (a = this.editor) == null ? void 0 : a.view) == null ? void 0 : c.state) == null ? void 0 : l.selection;
1690
+ this.editor.chain().focus().insertContent(t).setTextSelection({ from: i.from, to: i.from + t.length }).setLink({ href: e, class: n.class }).run();
1563
1691
  },
1564
- // eslint-disable-next-line complexity
1565
1692
  processValue(e, t = !0) {
1566
1693
  const n = this.getOutput();
1567
- if (!(t && Ae(e, n))) {
1694
+ if (!(t && Be(e, n))) {
1568
1695
  if (typeof e == "string" && this.outputFormat === "text") {
1569
- const r = new RegExp(`(${O})`, "g");
1696
+ const r = new RegExp(`(${M})`, "g");
1570
1697
  e = e == null ? void 0 : e.replace(r, '<emoji-component code="$1"></emoji-component>');
1571
1698
  }
1572
1699
  this.editor.commands.setContent(e, !1, { preserveWhitespace: "full" });
@@ -1578,10 +1705,10 @@ ${r.textContent}
1578
1705
  insertPlainTextWithHardBreaks(e, t) {
1579
1706
  const { tr: n } = e.state, { from: r, to: s } = e.state.selection;
1580
1707
  n.deleteRange(r, s);
1581
- const i = t.split(/\r?\n/);
1582
- let o = r;
1583
- for (let a = 0; a < i.length; a++)
1584
- a > 0 && (n.insert(o, e.state.schema.nodes.hardBreak.create()), o++), n.insertText(i[a], o), o += i[a].length;
1708
+ const o = t.split(/\r?\n/);
1709
+ let i = r;
1710
+ for (let a = 0; a < o.length; a++)
1711
+ a > 0 && (n.insert(i, e.state.schema.nodes.hardBreak.create()), i++), n.insertText(o[a], i), i += o[a].length;
1585
1712
  e.dispatch(n);
1586
1713
  },
1587
1714
  shouldPreserveLineBreaks(e, t) {
@@ -1649,6 +1776,8 @@ ${r.textContent}
1649
1776
  const r = this.editor.getText({ blockSeparator: `
1650
1777
  ` });
1651
1778
  this.$emit("text-input", r);
1779
+ const s = this.jsonToMarkdownConverter.convertToMarkdown(t);
1780
+ this.$emit("markdown-input", s);
1652
1781
  },
1653
1782
  /**
1654
1783
  * The Editor exposes event hooks that we have to map our emits into. See
@@ -1673,6 +1802,8 @@ ${r.textContent}
1673
1802
  return this.editor.getJSON();
1674
1803
  case "html":
1675
1804
  return this.editor.getHTML();
1805
+ case "markdown":
1806
+ return this.jsonToMarkdownConverter.convertToMarkdown(this.editor.getJSON());
1676
1807
  case "text":
1677
1808
  default:
1678
1809
  return this.editor.getText({ blockSeparator: `
@@ -1699,16 +1830,16 @@ ${r.textContent}
1699
1830
  }
1700
1831
  }
1701
1832
  };
1702
- var Gt = function() {
1833
+ var Qt = function() {
1703
1834
  var t = this, n = t._self._c;
1704
1835
  return n("div", [t.editor && t.link && !t.hideLinkBubbleMenu ? n("bubble-menu", { staticStyle: { visibility: "visible" }, attrs: { editor: t.editor, "should-show": t.bubbleMenuShouldShow, "tippy-options": t.tippyOptions } }, [n("div", { staticClass: "d-popover__dialog" }, [n("dt-stack", { staticClass: "d-rich-text-editor-bubble-menu__button-stack", attrs: { direction: "row", gap: "0" } }, [n("dt-button", { attrs: { kind: "muted", importance: "clear" }, on: { click: t.editLink } }, [t._v(" " + t._s(t.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL")) + " ")]), n("dt-button", { attrs: { kind: "muted", importance: "clear" }, on: { click: t.openLink } }, [t._v(" " + t._s(t.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL")) + " ")]), n("dt-button", { attrs: { kind: "danger", importance: "clear" }, on: { click: t.removeLink } }, [t._v(" " + t._s(t.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL")) + " ")])], 1)], 1)]) : t._e(), n("editor-content", t._g({ ref: "editor", staticClass: "d-rich-text-editor", attrs: { editor: t.editor, "data-qa": "dt-rich-text-editor" } }, t.editorListeners))], 1);
1705
- }, Qt = [], Zt = /* @__PURE__ */ c(
1706
- Yt,
1836
+ }, Zt = [], en = /* @__PURE__ */ d(
1707
1837
  Gt,
1708
- Qt
1838
+ Qt,
1839
+ Zt
1709
1840
  );
1710
- const Wn = Zt.exports;
1841
+ const Vn = en.exports;
1711
1842
  export {
1712
- Wn as default
1843
+ Vn as default
1713
1844
  };
1714
1845
  //# sourceMappingURL=rich-text-editor.js.map