@dialpad/dialtone 9.77.0 → 9.79.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/dialtone-default-theme.css +795 -810
- package/dist/css/dialtone-default-theme.min.css +1 -1
- package/dist/css/tokens/tokens-base-dark.css +0 -5
- package/dist/css/tokens/tokens-base-light.css +0 -5
- package/dist/css/tokens/tokens-dp-dark.css +795 -805
- package/dist/css/tokens/tokens-dp-light.css +795 -805
- package/dist/css/tokens/tokens-expressive-dark.css +795 -805
- package/dist/css/tokens/tokens-expressive-light.css +795 -805
- package/dist/css/tokens/tokens-expressive-sm-dark.css +795 -805
- package/dist/css/tokens/tokens-expressive-sm-light.css +795 -805
- package/dist/css/tokens/tokens-tmo-dark.css +780 -790
- package/dist/css/tokens/tokens-tmo-light.css +780 -790
- package/dist/tokens/css/tokens-base-dark.css +0 -5
- package/dist/tokens/css/tokens-base-light.css +0 -5
- package/dist/tokens/css/tokens-dp-dark.css +795 -805
- package/dist/tokens/css/tokens-dp-light.css +795 -805
- package/dist/tokens/css/tokens-expressive-dark.css +795 -805
- package/dist/tokens/css/tokens-expressive-light.css +795 -805
- package/dist/tokens/css/tokens-expressive-sm-dark.css +795 -805
- package/dist/tokens/css/tokens-expressive-sm-light.css +795 -805
- package/dist/tokens/css/tokens-tmo-dark.css +780 -790
- package/dist/tokens/css/tokens-tmo-light.css +780 -790
- package/dist/tokens/doc.json +14103 -14103
- package/dist/tokens/themes/chunks/{tokens-base-dark-D9QWQ06G.js → tokens-base-dark-DPDbA0Im.js} +1 -1
- package/dist/tokens/themes/chunks/{tokens-base-dark-BspLyPe6.js → tokens-base-dark-OGkvNn32.js} +1 -1
- package/dist/tokens/themes/chunks/{tokens-base-light-CCF-uj56.js → tokens-base-light-C0l67sjm.js} +1 -1
- package/dist/tokens/themes/chunks/{tokens-base-light-B2jKQq80.js → tokens-base-light-nNZ2WKLp.js} +2 -2
- package/dist/tokens/themes/dp-dark.cjs +1 -1
- package/dist/tokens/themes/dp-dark.js +2 -2
- package/dist/tokens/themes/dp-light.cjs +1 -1
- package/dist/tokens/themes/dp-light.js +2 -2
- package/dist/tokens/themes/expressive-dark.cjs +1 -1
- package/dist/tokens/themes/expressive-dark.js +3 -3
- package/dist/tokens/themes/expressive-light.cjs +1 -1
- package/dist/tokens/themes/expressive-light.js +3 -3
- package/dist/tokens/themes/expressive-sm-dark.cjs +1 -1
- package/dist/tokens/themes/expressive-sm-dark.js +3 -3
- package/dist/tokens/themes/expressive-sm-light.cjs +1 -1
- package/dist/tokens/themes/expressive-sm-light.js +3 -3
- package/dist/tokens/themes/tmo-dark.cjs +1 -1
- package/dist/tokens/themes/tmo-dark.js +3 -3
- package/dist/tokens/themes/tmo-light.cjs +1 -1
- package/dist/tokens/themes/tmo-light.js +3 -3
- package/dist/tokens/types/postcss/constants.d.cts +1 -0
- package/dist/vue2/common/utils.cjs +7 -0
- package/dist/vue2/common/utils.cjs.map +1 -1
- package/dist/vue2/common/utils.js +8 -1
- package/dist/vue2/common/utils.js.map +1 -1
- package/dist/vue2/components/datepicker/datepicker.vue.cjs +4 -0
- package/dist/vue2/components/datepicker/datepicker.vue.cjs.map +1 -1
- package/dist/vue2/components/datepicker/datepicker.vue.js +4 -0
- package/dist/vue2/components/datepicker/datepicker.vue.js.map +1 -1
- package/dist/vue2/components/emoji_picker/modules/emoji_selector.vue.cjs +3 -3
- package/dist/vue2/components/emoji_picker/modules/emoji_selector.vue.cjs.map +1 -1
- package/dist/vue2/components/emoji_picker/modules/emoji_selector.vue.js +3 -3
- package/dist/vue2/components/emoji_picker/modules/emoji_selector.vue.js.map +1 -1
- package/dist/vue2/components/popover/popover.vue.cjs +1 -0
- package/dist/vue2/components/popover/popover.vue.cjs.map +1 -1
- package/dist/vue2/components/popover/popover.vue.js +2 -1
- package/dist/vue2/components/popover/popover.vue.js.map +1 -1
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.cjs +10 -9
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.cjs.map +1 -1
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.js +10 -9
- package/dist/vue2/components/rich_text_editor/extensions/emoji/suggestion.js.map +1 -1
- package/dist/vue2/components/rich_text_editor/rich_text_editor.vue.cjs +20 -9
- package/dist/vue2/components/rich_text_editor/rich_text_editor.vue.cjs.map +1 -1
- package/dist/vue2/components/rich_text_editor/rich_text_editor.vue.js +20 -9
- package/dist/vue2/components/rich_text_editor/rich_text_editor.vue.js.map +1 -1
- package/dist/vue2/components/split_button/split_button.vue.cjs +4 -0
- package/dist/vue2/components/split_button/split_button.vue.cjs.map +1 -1
- package/dist/vue2/components/split_button/split_button.vue.js +4 -0
- package/dist/vue2/components/split_button/split_button.vue.js.map +1 -1
- package/dist/vue2/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.cjs +3 -0
- package/dist/vue2/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.cjs.map +1 -1
- package/dist/vue2/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.js +4 -1
- package/dist/vue2/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.js.map +1 -1
- package/dist/vue2/types/common/utils/index.d.ts +1 -0
- package/dist/vue2/types/common/utils/index.d.ts.map +1 -1
- package/dist/vue2/types/components/dropdown/dropdown.vue.d.ts +4 -4
- package/dist/vue2/types/components/emoji_picker/modules/emoji_selector.vue.d.ts +1 -0
- package/dist/vue2/types/components/modal/modal.vue.d.ts +4 -4
- package/dist/vue2/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts +1 -0
- package/dist/vue2/types/components/tooltip/tooltip.vue.d.ts +4 -4
- package/dist/vue2/types/recipes/comboboxes/combobox_with_popover/combobox_with_popover.vue.d.ts +4 -4
- package/dist/vue3/common/utils.cjs +7 -0
- package/dist/vue3/common/utils.cjs.map +1 -1
- package/dist/vue3/common/utils.js +8 -1
- package/dist/vue3/common/utils.js.map +1 -1
- package/dist/vue3/components/datepicker/datepicker.vue.cjs +5 -0
- package/dist/vue3/components/datepicker/datepicker.vue.cjs.map +1 -1
- package/dist/vue3/components/datepicker/datepicker.vue.js +6 -1
- package/dist/vue3/components/datepicker/datepicker.vue.js.map +1 -1
- package/dist/vue3/components/popover/popover.vue.cjs +1 -0
- package/dist/vue3/components/popover/popover.vue.cjs.map +1 -1
- package/dist/vue3/components/popover/popover.vue.js +2 -1
- package/dist/vue3/components/popover/popover.vue.js.map +1 -1
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.cjs +10 -9
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.cjs.map +1 -1
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.js +10 -9
- package/dist/vue3/components/rich_text_editor/extensions/emoji/suggestion.js.map +1 -1
- package/dist/vue3/components/rich_text_editor/rich_text_editor.vue.cjs +20 -9
- package/dist/vue3/components/rich_text_editor/rich_text_editor.vue.cjs.map +1 -1
- package/dist/vue3/components/rich_text_editor/rich_text_editor.vue.js +20 -9
- package/dist/vue3/components/rich_text_editor/rich_text_editor.vue.js.map +1 -1
- package/dist/vue3/components/split_button/split_button.vue.cjs +3 -0
- package/dist/vue3/components/split_button/split_button.vue.cjs.map +1 -1
- package/dist/vue3/components/split_button/split_button.vue.js +4 -1
- package/dist/vue3/components/split_button/split_button.vue.js.map +1 -1
- package/dist/vue3/components/tooltip/tooltip.vue.cjs +1 -0
- package/dist/vue3/components/tooltip/tooltip.vue.cjs.map +1 -1
- package/dist/vue3/components/tooltip/tooltip.vue.js +2 -1
- package/dist/vue3/components/tooltip/tooltip.vue.js.map +1 -1
- package/dist/vue3/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.cjs +3 -0
- package/dist/vue3/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.cjs.map +1 -1
- package/dist/vue3/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.js +4 -1
- package/dist/vue3/recipes/buttons/callbar_button_with_popover/callbar_button_with_popover.vue.js.map +1 -1
- package/dist/vue3/types/common/utils/index.d.ts +1 -0
- package/dist/vue3/types/common/utils/index.d.ts.map +1 -1
- package/dist/vue3/types/components/dropdown/dropdown.vue.d.ts +5 -5
- package/dist/vue3/types/components/keyboard_shortcut/keyboard_shortcut.vue.d.ts +7 -210
- package/dist/vue3/types/components/lazy_show/lazy_show.vue.d.ts +1 -1
- package/dist/vue3/types/components/modal/modal.vue.d.ts +4 -4
- package/dist/vue3/types/components/notice/notice_icon.vue.d.ts +1 -30
- package/dist/vue3/types/components/notice/notice_icon.vue.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts +1 -0
- package/dist/vue3/types/components/tooltip/tooltip.vue.d.ts +5 -5
- package/dist/vue3/types/components/tooltip/tooltip.vue.d.ts.map +1 -1
- package/dist/vue3/types/recipes/cards/ivr_node/ivr_node.vue.d.ts +1 -30
- package/dist/vue3/types/recipes/comboboxes/combobox_with_popover/combobox_with_popover.vue.d.ts +5 -5
- package/dist/vue3/types/recipes/conversation_view/editor/editor.vue.d.ts +8 -240
- package/dist/vue3/types/recipes/conversation_view/feed_pill/feed_item_pill.vue.d.ts +1 -30
- package/dist/vue3/types/recipes/leftbar/general_row/leftbar_general_row_icon.vue.d.ts +1 -30
- package/package.json +4 -20
|
@@ -5,21 +5,22 @@ import SuggestionList from "../suggestion/SuggestionList.vue.js";
|
|
|
5
5
|
import EmojiSuggestion from "./EmojiSuggestion.vue.js";
|
|
6
6
|
import tippy from "tippy.js";
|
|
7
7
|
import hideOnEsc from "../tippy_plugins/hide_on_esc.js";
|
|
8
|
+
const suggestionLimit = 20;
|
|
8
9
|
const suggestionOptions = {
|
|
9
10
|
items: ({ query }) => {
|
|
10
11
|
if (query.length < 2) {
|
|
11
12
|
return [];
|
|
12
13
|
}
|
|
13
14
|
const emojiList = Object.values(emojisIndexed);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
15
|
+
query = query.toLowerCase();
|
|
16
|
+
const filteredEmoji = emojiList.filter(
|
|
17
|
+
(item) => [
|
|
18
|
+
item.name,
|
|
19
|
+
item.shortname.replaceAll(":", ""),
|
|
20
|
+
...item.keywords
|
|
21
|
+
].some((text) => text.startsWith(query))
|
|
22
|
+
).splice(0, suggestionLimit);
|
|
23
|
+
return filteredEmoji.map((item) => ({ code: item.shortname }));
|
|
23
24
|
},
|
|
24
25
|
command: ({ editor, range, props }) => {
|
|
25
26
|
var _a, _b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestion.js","sources":["../../../../../components/rich_text_editor/extensions/emoji/suggestion.js"],"sourcesContent":["import { markRaw } from 'vue';\nimport { VueRenderer } from '@tiptap/vue-3';\nimport { emojisIndexed } from '@dialpad/dialtone-emojis';\n\nimport SuggestionList from '../suggestion/SuggestionList.vue';\nimport EmojiSuggestion from './EmojiSuggestion.vue';\n\nimport tippy from 'tippy.js';\nimport hideOnEsc from '../tippy_plugins/hide_on_esc';\n\nexport default {\n items: ({ query }) => {\n if (query.length < 2) {\n return [];\n }\n const emojiList = Object.values(emojisIndexed);\n const filteredEmoji = emojiList.filter(
|
|
1
|
+
{"version":3,"file":"suggestion.js","sources":["../../../../../components/rich_text_editor/extensions/emoji/suggestion.js"],"sourcesContent":["import { markRaw } from 'vue';\nimport { VueRenderer } from '@tiptap/vue-3';\nimport { emojisIndexed } from '@dialpad/dialtone-emojis';\n\nimport SuggestionList from '../suggestion/SuggestionList.vue';\nimport EmojiSuggestion from './EmojiSuggestion.vue';\n\nimport tippy from 'tippy.js';\nimport hideOnEsc from '../tippy_plugins/hide_on_esc';\n\nconst suggestionLimit = 20;\n\nexport default {\n items: ({ query }) => {\n if (query.length < 2) {\n return [];\n }\n const emojiList = Object.values(emojisIndexed);\n query = query.toLowerCase();\n\n const filteredEmoji = emojiList\n .filter(\n item => [\n item.name,\n item.shortname.replaceAll(':', ''),\n ...item.keywords,\n ].some(text => text.startsWith(query)),\n ).splice(0, suggestionLimit);\n return filteredEmoji.map(item => ({ code: item.shortname }));\n },\n\n command: ({ editor, range, props }) => {\n // increase range.to by one when the next node is of type \"text\"\n // and starts with a space character\n const nodeAfter = editor.view.state.selection.$to.nodeAfter;\n const overrideSpace = nodeAfter?.text?.startsWith(' ');\n\n if (overrideSpace) {\n range.to += 1;\n }\n\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: 'emoji',\n attrs: props,\n },\n ])\n .run();\n\n window.getSelection()?.collapseToEnd();\n },\n\n render: () => {\n let component;\n let popup;\n let popupIsOpen = false;\n\n return {\n onStart: props => {\n component = new VueRenderer(SuggestionList, {\n props: {\n itemComponent: markRaw(EmojiSuggestion),\n itemType: 'emoji',\n ...props,\n },\n editor: props.editor,\n });\n\n if (!props.clientRect) {\n return;\n }\n\n popup = tippy('body', {\n getReferenceClientRect: props.clientRect,\n appendTo: () => document.body,\n content: component.element,\n showOnCreate: false,\n onShow: () => { popupIsOpen = true; },\n onHidden: () => { popupIsOpen = false; },\n interactive: true,\n trigger: 'manual',\n placement: 'top-start',\n zIndex: 650,\n plugins: [hideOnEsc],\n });\n\n if (props.items.length > 0) {\n popup?.[0].show();\n }\n },\n\n onUpdate (props) {\n component?.updateProps(props);\n\n if (props.items.length > 0) {\n popup?.[0].show();\n } else {\n popup?.[0].hide();\n }\n popup?.[0].setProps({\n getReferenceClientRect: props.clientRect,\n });\n },\n\n onKeyDown (props) {\n if (popupIsOpen) {\n return component?.ref?.onKeyDown(props);\n }\n },\n\n onExit () {\n popup?.[0].destroy();\n popup = null;\n component?.destroy();\n component = null;\n },\n };\n },\n};\n"],"names":[],"mappings":";;;;;;;AAUA,MAAM,kBAAk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SAAS,UAAU;AAAA,UACnB,cAAc;AAAA,UACd,QAAQ,MAAM;AAAE,0BAAc;AAAA,UAAO;AAAA,UACrC,UAAU,MAAM;AAAE,0BAAc;AAAA,UAAQ;AAAA,UACxC,aAAa;AAAA,UACb,SAAS;AAAA,UACT,WAAW;AAAA,UACX,QAAQ;AAAA,UACR,SAAS,CAAC,SAAS;AAAA,QAC7B,CAAS;AAED,YAAI,MAAM,MAAM,SAAS,GAAG;AAC1B,yCAAQ,GAAG;AAAA,QACZ;AAAA,MACF;AAAA,MAED,SAAU,OAAO;AACf,+CAAW,YAAY;AAEvB,YAAI,MAAM,MAAM,SAAS,GAAG;AAC1B,yCAAQ,GAAG;AAAA,QACrB,OAAe;AACL,yCAAQ,GAAG;AAAA,QACZ;AACD,uCAAQ,GAAG,SAAS;AAAA,UAClB,wBAAwB,MAAM;AAAA,QACxC;AAAA,MACO;AAAA,MAED,UAAW,OAAO;;AAChB,YAAI,aAAa;AACf,kBAAO,4CAAW,QAAX,mBAAgB,UAAU;AAAA,QAClC;AAAA,MACF;AAAA,MAED,SAAU;AACR,uCAAQ,GAAG;AACX,gBAAQ;AACR,+CAAW;AACX,oBAAY;AAAA,MACb;AAAA,IACP;AAAA,EACG;AACH;"}
|
|
@@ -24,9 +24,11 @@ const mention = require("./extensions/mentions/mention.cjs");
|
|
|
24
24
|
const channel = require("./extensions/channels/channel.cjs");
|
|
25
25
|
const slash_command = require("./extensions/slash_command/slash_command.cjs");
|
|
26
26
|
const rich_text_editor_constants = require("./rich_text_editor_constants.cjs");
|
|
27
|
+
const regexCombinedEmojis = require("regex-combined-emojis");
|
|
27
28
|
const suggestion = require("./extensions/mentions/suggestion.cjs");
|
|
28
29
|
const suggestion$1 = require("./extensions/channels/suggestion.cjs");
|
|
29
30
|
const suggestion$2 = require("./extensions/slash_command/suggestion.cjs");
|
|
31
|
+
const common_utils = require("../../common/utils.cjs");
|
|
30
32
|
const vue = require("vue");
|
|
31
33
|
;/* empty css */
|
|
32
34
|
const _pluginVue_exportHelper = require("../../_virtual/_plugin-vue_export-helper.cjs");
|
|
@@ -424,15 +426,7 @@ const _sfc_main = {
|
|
|
424
426
|
this.createEditor();
|
|
425
427
|
},
|
|
426
428
|
modelValue(newValue) {
|
|
427
|
-
|
|
428
|
-
if (this.outputFormat === "json") {
|
|
429
|
-
newValue = JSON.stringify(newValue);
|
|
430
|
-
currentValue = JSON.stringify(currentValue);
|
|
431
|
-
}
|
|
432
|
-
if (newValue === currentValue) {
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
this.editor.commands.setContent(newValue, false);
|
|
429
|
+
this.processValue(newValue);
|
|
436
430
|
}
|
|
437
431
|
},
|
|
438
432
|
created() {
|
|
@@ -441,6 +435,10 @@ const _sfc_main = {
|
|
|
441
435
|
beforeUnmount() {
|
|
442
436
|
this.destroyEditor();
|
|
443
437
|
},
|
|
438
|
+
mounted() {
|
|
439
|
+
common_utils.warnIfUnmounted(this.$el, this.$options.name);
|
|
440
|
+
this.processValue(this.modelValue, false);
|
|
441
|
+
},
|
|
444
442
|
methods: {
|
|
445
443
|
createEditor() {
|
|
446
444
|
this.editor = new vue3.Editor({
|
|
@@ -487,6 +485,19 @@ const _sfc_main = {
|
|
|
487
485
|
});
|
|
488
486
|
this.addEditorListeners();
|
|
489
487
|
},
|
|
488
|
+
processValue(newValue, returnIfEqual = true) {
|
|
489
|
+
let currentValue = this.getOutput();
|
|
490
|
+
if (this.outputFormat === "json") {
|
|
491
|
+
newValue = JSON.stringify(newValue);
|
|
492
|
+
currentValue = JSON.stringify(currentValue);
|
|
493
|
+
}
|
|
494
|
+
if (returnIfEqual && newValue === currentValue) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const inputUnicodeRegex = new RegExp(`(${regexCombinedEmojis.emojiPattern})`, "g");
|
|
498
|
+
newValue = newValue.replace(inputUnicodeRegex, '<emoji-component code="$1"></emoji-component>');
|
|
499
|
+
this.editor.commands.setContent(newValue, false);
|
|
500
|
+
},
|
|
490
501
|
destroyEditor() {
|
|
491
502
|
this.editor.destroy();
|
|
492
503
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich_text_editor.vue.cjs","sources":["../../../components/rich_text_editor/rich_text_editor.vue"],"sourcesContent":["<template>\n <editor-content\n :editor=\"editor\"\n data-qa=\"dt-rich-text-editor\"\n class=\"dt-rich-text-editor\"\n v-bind=\"attrs\"\n />\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { Editor, EditorContent } from '@tiptap/vue-3';\nimport { Slice, Fragment } from '@tiptap/pm/model';\nimport Blockquote from '@tiptap/extension-blockquote';\nimport CodeBlock from '@tiptap/extension-code-block';\nimport Document from '@tiptap/extension-document';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Italic from '@tiptap/extension-italic';\nimport TipTapLink from '@tiptap/extension-link';\nimport ListItem from '@tiptap/extension-list-item';\nimport OrderedList from '@tiptap/extension-ordered-list';\nimport Strike from '@tiptap/extension-strike';\nimport Underline from '@tiptap/extension-underline';\nimport Text from '@tiptap/extension-text';\nimport TextAlign from '@tiptap/extension-text-align';\nimport History from '@tiptap/extension-history';\nimport Emoji from './extensions/emoji';\nimport CustomLink from './extensions/custom_link';\nimport { MentionPlugin } from './extensions/mentions/mention';\nimport { ChannelPlugin } from './extensions/channels/channel';\nimport { SlashCommandPlugin } from './extensions/slash_command/slash_command';\nimport {\n RICH_TEXT_EDITOR_OUTPUT_FORMATS,\n RICH_TEXT_EDITOR_AUTOFOCUS_TYPES,\n RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,\n} from './rich_text_editor_constants';\n\nimport mentionSuggestion from './extensions/mentions/suggestion';\nimport channelSuggestion from './extensions/channels/suggestion';\nimport slashCommandSuggestion from './extensions/slash_command/suggestion';\n\nexport default {\n name: 'DtRichTextEditor',\n\n components: {\n EditorContent,\n },\n\n props: {\n /**\n * Value of the input. The object format should match TipTap's JSON\n * document structure: https://tiptap.dev/guide/output#option-1-json\n */\n modelValue: {\n type: [Object, String],\n default: '',\n },\n\n /**\n * Whether the input is editable\n */\n editable: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Prevents the user from typing any further. Deleting text will still work.\n */\n preventTyping: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Whether the input allows for line breaks to be introduced in the text by pressing enter. If this is disabled,\n * line breaks can still be entered by pressing shift+enter.\n */\n allowLineBreaks: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Descriptive label for the input element\n */\n inputAriaLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Additional class name for the input element. Only accepts a String value\n * because this is passed to the editor via options. For multiple classes,\n * join them into one string, e.g. \"d-p8 d-hmx96\"\n */\n inputClass: {\n type: String,\n default: '',\n },\n\n /**\n * Whether the input should receive focus after the component has been\n * mounted. Either one of `start`, `end`, `all` or a Boolean or a Number.\n * - `start` Sets the focus to the beginning of the input\n * - `end` Sets the focus to the end of the input\n * - `all` Selects the whole contents of the input\n * - `Number` Sets the focus to a specific position in the input\n * - `true` Defaults to `start`\n * - `false` Disables autofocus\n * @values true, false, start, end, all, number\n */\n autoFocus: {\n type: [Boolean, String, Number],\n default: false,\n validator (autoFocus) {\n if (typeof autoFocus === 'string') {\n return RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(autoFocus);\n }\n return true;\n },\n },\n\n /**\n * The output format that the editor uses when emitting the \"@input\" event.\n * One of `text`, `json`, `html`. See https://tiptap.dev/guide/output for\n * examples.\n * @values text, json, html\n */\n outputFormat: {\n type: String,\n default: 'html',\n validator (outputFormat) {\n return RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(outputFormat);\n },\n },\n\n /**\n * Placeholder text\n */\n placeholder: {\n type: String,\n default: '',\n },\n\n /**\n * Enables the TipTap Link extension and optionally passes configurations to it\n *\n * It is not recommended to use this and the custom link extension at the same time.\n */\n link: {\n type: [Boolean, Object],\n default: false,\n },\n\n /**\n * Enables the Custom Link extension and optionally passes configurations to it\n *\n * It is not recommended to use this and the built in TipTap link extension at the same time.\n *\n * The custom link does some additional things on top of the built in TipTap link\n * extension such as styling phone numbers and IP adresses as links, and allows you\n * to linkify text without having to type a space after the link. Currently it is missing some\n * functionality such as editing links and will likely require more work to be fully usable,\n * so it is recommended to use the built in TipTap link for now.\n */\n customLink: {\n type: [Boolean, Object],\n default: false,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the contacts for suggestion.\n * items({ query }) => { return [ContactObject]; }\n * ContactObject format:\n * { name: string, avatarSrc: string, id: string }\n *\n * When null, it does not add the plugin.\n */\n mentionSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the channels for suggestion.\n * items({ query }) => { return [ChannelObject]; }\n * ChannelObject format:\n * { name: string, id: string, locked: boolean }\n *\n * When null, it does not add the plugin. Setting locked to true will display a lock rather than hash.\n */\n channelSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the slash commands for suggestion.\n * items({ query }) => { return [SlashCommandObject]; }\n * SlashCommandObject format:\n * { command: string, description: string, parametersExample?: string }\n * The \"parametersExample\" parameter is optional, and describes an example\n * of the parameters that command can take.\n *\n * When null, it does not add the plugin.\n * Note that slash commands only work when they are the first word in the input.\n */\n slashCommandSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * Whether the input allows for block quote.\n */\n allowBlockquote: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for bold to be introduced in the text.\n */\n allowBold: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for bullet list to be introduced in the text.\n */\n allowBulletList: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for italic to be introduced in the text.\n */\n allowItalic: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for strike to be introduced in the text.\n */\n allowStrike: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for underline to be introduced in the text.\n */\n allowUnderline: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows codeblock to be introduced in the text.\n */\n allowCodeblock: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Additional TipTap extensions to be added to the editor.\n */\n additionalExtensions: {\n type: Array,\n default: () => [],\n },\n },\n\n emits: [\n /**\n * Editor input event\n * @event input\n * @type {String|JSON}\n */\n 'input',\n\n /**\n * Event to sync the value with the parent\n * @event update:value\n * @type {String|JSON}\n */\n 'update:modelValue',\n\n /**\n * Editor blur event\n * @event blur\n * @type {FocusEvent}\n */\n 'blur',\n\n /**\n * Editor focus event\n * @event focus\n * @type {FocusEvent}\n */\n 'focus',\n\n /**\n * Enter was pressed. Note that shift enter must be pressed to line break the input.\n * @event enter\n * @type {String}\n */\n 'enter',\n ],\n\n data () {\n return {\n editor: null,\n };\n },\n\n computed: {\n attrs () {\n return {\n ...this.$attrs,\n onInput: () => {},\n onFocus: () => {},\n onBlur: () => {},\n };\n },\n\n // eslint-disable-next-line complexity\n extensions () {\n // These are the default extensions needed just for plain text.\n const extensions = [Document, Paragraph, Text, History];\n if (this.link) {\n extensions.push(TipTapLink.extend({ inclusive: false }).configure({\n HTMLAttributes: {\n class: 'd-link d-wb-break-all',\n },\n autolink: true,\n protocols: RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,\n }));\n }\n if (this.customLink) {\n extensions.push(this.getExtension(CustomLink, this.customLink));\n }\n if (this.allowBlockquote) {\n extensions.push(Blockquote);\n }\n if (this.allowBold) {\n extensions.push(Bold);\n }\n if (this.allowBulletList) {\n extensions.push(BulletList);\n extensions.push(ListItem);\n extensions.push(OrderedList);\n }\n if (this.allowItalic) {\n extensions.push(Italic);\n }\n if (this.allowStrike) {\n extensions.push(Strike);\n }\n if (this.allowUnderline) {\n extensions.push(Underline);\n }\n\n // Enable placeholderText\n if (this.placeholder) {\n extensions.push(\n Placeholder.configure({ placeholder: this.placeholder }),\n );\n }\n\n // make sure that this is defined before any other extensions\n // where Enter and Shift+Enter should have its own interaction. otherwise it will be ignored\n if (!this.allowLineBreaks) {\n const self = this;\n extensions.push(\n HardBreak.extend({\n addKeyboardShortcuts () {\n return {\n Enter: () => {\n self.$emit('enter');\n return true;\n },\n 'Shift-Enter': () => {\n this.editor.commands.setHardBreak();\n return true;\n },\n };\n },\n }),\n );\n } else {\n extensions.push(HardBreak);\n }\n\n if (this.mentionSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.mentionSuggestion, ...mentionSuggestion };\n extensions.push(MentionPlugin.configure({ suggestion: suggestionObject }));\n }\n\n if (this.channelSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.channelSuggestion, ...channelSuggestion };\n extensions.push(ChannelPlugin.configure({ suggestion: suggestionObject }));\n }\n\n if (this.slashCommandSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.slashCommandSuggestion, ...slashCommandSuggestion };\n extensions.push(SlashCommandPlugin.configure({ suggestion: suggestionObject }));\n }\n\n // Emoji has some interactions with Enter key\n // hence this should be done last otherwise the enter wont add a emoji.\n extensions.push(Emoji);\n\n extensions.push(TextAlign.configure({\n types: ['paragraph'],\n defaultAlignment: 'left',\n }));\n\n if (this.allowCodeblock) {\n extensions.push(CodeBlock.configure({\n HTMLAttributes: {\n class: 'dt-rich-text-editor--code-block',\n },\n }));\n }\n\n if (this.additionalExtensions.length) {\n extensions.push(...this.additionalExtensions);\n }\n\n return extensions;\n },\n\n inputAttrs () {\n const attrs = {\n 'aria-label': this.inputAriaLabel,\n 'aria-multiline': true,\n role: 'textbox',\n };\n if (!this.editable) {\n attrs['aria-readonly'] = true;\n }\n return attrs;\n },\n },\n\n /**\n * Because the Editor instance is initialized when mounted it does not get\n * updated props automatically, so the ones that can change after mount have\n * to be hooked up to the Editor's own API.\n */\n watch: {\n editable (isEditable) {\n this.editor.setEditable(isEditable);\n this.updateEditorAttributes({ 'aria-readonly': !isEditable });\n },\n\n inputClass (newClass) {\n this.updateEditorAttributes({ class: newClass });\n },\n\n inputAriaLabel (newLabel) {\n this.updateEditorAttributes({ 'aria-label': newLabel });\n },\n\n extensions () {\n // Extensions can't be registered on the fly, so just recreate the editor.\n // https://github.com/ueberdosis/tiptap/issues/1044\n this.destroyEditor();\n this.createEditor();\n },\n\n modelValue (newValue) {\n let currentValue = this.getOutput();\n if (this.outputFormat === 'json') {\n newValue = JSON.stringify(newValue);\n currentValue = JSON.stringify(currentValue);\n }\n if (newValue === currentValue) {\n // The new value came from this component and was passed back down\n // through the parent, so don't do anything here.\n return;\n }\n // Otherwise replace the content (resets the cursor position).\n this.editor.commands.setContent(newValue, false);\n },\n },\n\n created () {\n this.createEditor();\n },\n\n beforeUnmount () {\n this.destroyEditor();\n },\n\n methods: {\n\n createEditor () {\n // For all available options, see https://tiptap.dev/api/editor#settings\n this.editor = new Editor({\n autofocus: this.autoFocus,\n content: this.modelValue,\n editable: this.editable,\n extensions: this.extensions,\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n },\n\n /* Absolutely crazy that this is what's needed to paste line breaks properly in prosemirror, but it does seem\n to fix our issue of line breaks outputting as paragraphs. Code taken from this thread:\n https://discuss.prosemirror.net/t/how-to-preserve-hard-breaks-when-pasting-html-into-a-plain-text-schema/4202/4\n */\n handlePaste: function (view, event, slice) {\n const { state } = view;\n const { tr } = state;\n\n if (!state.schema.nodes.hardBreak) {\n return false;\n }\n\n const clipboardText = event.clipboardData?.getData('text/plain').trim();\n\n if (!clipboardText) {\n return false;\n }\n\n const textLines = clipboardText.split(/(?:\\r\\n|\\r|\\n)/g);\n\n const nodes = textLines.reduce((nodes, line, index) => {\n if (line.length > 0) {\n nodes.push(state.schema.text(line));\n }\n\n if (index < textLines.length - 1) {\n nodes.push(state.schema.nodes.hardBreak.create());\n }\n\n return nodes;\n }, []);\n\n view.dispatch(\n tr.replaceSelection(Slice.maxOpen(Fragment.fromArray(nodes))).scrollIntoView(),\n );\n\n return true;\n },\n },\n });\n this.addEditorListeners();\n },\n\n destroyEditor () {\n this.editor.destroy();\n },\n\n /**\n * The Editor exposes event hooks that we have to map our emits into. See\n * https://tiptap.dev/api/events for all events.\n */\n addEditorListeners () {\n // The content has changed.\n this.editor.on('update', () => {\n const value = this.getOutput();\n // When preventTyping is true and user wants to type, we revert to last value\n // If Backspace (keyCode = 8) is pressed, we allow updating the text\n if (this.preventTyping && this.editor.view?.input?.lastKeyCode !== 8) {\n this.editor.commands.setContent(this.value, false);\n return;\n }\n this.$emit('input', value);\n this.$emit('update:modelValue', value);\n });\n\n // The editor is focused.\n this.editor.on('focus', ({ event }) => {\n this.$emit('focus', event);\n });\n\n // The editor isn’t focused anymore.\n this.editor.on('blur', ({ event }) => {\n this.$emit('blur', event);\n });\n },\n\n getOutput () {\n switch (this.outputFormat) {\n case 'json':\n return this.editor.getJSON();\n case 'html':\n return this.editor.getHTML();\n case 'text':\n default:\n return this.editor.getText();\n }\n },\n\n getExtension (extension, options) {\n if (typeof options === 'boolean') {\n return extension;\n }\n return extension.configure?.(options);\n },\n\n updateEditorAttributes (attributes) {\n this.editor.setOptions({ editorProps: { attributes } });\n },\n\n focusEditor () {\n this.editor.commands.focus();\n },\n },\n};\n</script>\n\n<style lang=\"less\">\n .dt-rich-text-editor {\n &--code-block {\n background: var(--dt-color-surface-secondary);\n padding: var(--dt-space-400);\n }\n\n > .ProseMirror {\n box-shadow: none;\n\n p.is-editor-empty:first-child::before {\n content: attr(data-placeholder);\n float: left;\n color: var(--dt-color-foreground-placeholder);\n pointer-events: none;\n height: 0;\n }\n\n ul, ol {\n padding-left: var(--dt-space-525);\n }\n\n ul > li {\n list-style-type: disc;\n }\n\n ol > li {\n list-style-type: decimal;\n }\n\n blockquote {\n padding-left: var(--dt-space-400);\n border-left: var(--dt-size-border-300) solid var(--dt-color-foreground-muted-inverted);\n margin-left: 0;\n }\n }\n }\n</style>\n"],"names":["EditorContent","RICH_TEXT_EDITOR_AUTOFOCUS_TYPES","RICH_TEXT_EDITOR_OUTPUT_FORMATS","RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS","CustomLink","mentionSuggestion","MentionPlugin","channelSuggestion","ChannelPlugin","slashCommandSuggestion","SlashCommandPlugin","Emoji","Editor","nodes","Slice","Fragment","_openBlock","_createBlock","_mergeProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAK,YAAU;AAAA,EACb,MAAM;AAAA,EAEN,YAAY;AAAA,mBACVA,KAAa;AAAA,EACd;AAAA,EAED,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,YAAY;AAAA,MACV,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA,IAKD,UAAU;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA,IAKD,eAAe;AAAA,MACb,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA;AAAA,IAMD,iBAAiB;AAAA,MACf,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA,IAKD,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,UAAU;AAAA,IACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOD,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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;AAAA,MACT;AACA,cAAO,eAAU,cAAV,mCAAsB;AAAA,IAC9B;AAAA,IAED,uBAAwB,YAAY;AAClC,WAAK,OAAO,WAAW,EAAE,aAAa,EAAE,WAAa,EAAA,CAAC;AAAA,IACvD;AAAA,IAED,cAAe;AACb,WAAK,OAAO,SAAS;IACtB;AAAA,EACF;AACH;;;AA1nBE,SAAAC,cAAA,GAAAC,gBAKE,2BALFC,IAAAA,WAKE;AAAA,IAJC,QAAQ,MAAM;AAAA,IACf,WAAQ;AAAA,IACR,OAAM;AAAA,KACE,SAAK,KAAA,GAAA,MAAA,IAAA,CAAA,QAAA,CAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"rich_text_editor.vue.cjs","sources":["../../../components/rich_text_editor/rich_text_editor.vue"],"sourcesContent":["<template>\n <editor-content\n :editor=\"editor\"\n data-qa=\"dt-rich-text-editor\"\n class=\"dt-rich-text-editor\"\n v-bind=\"attrs\"\n />\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { Editor, EditorContent } from '@tiptap/vue-3';\nimport { Slice, Fragment } from '@tiptap/pm/model';\nimport Blockquote from '@tiptap/extension-blockquote';\nimport CodeBlock from '@tiptap/extension-code-block';\nimport Document from '@tiptap/extension-document';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Italic from '@tiptap/extension-italic';\nimport TipTapLink from '@tiptap/extension-link';\nimport ListItem from '@tiptap/extension-list-item';\nimport OrderedList from '@tiptap/extension-ordered-list';\nimport Strike from '@tiptap/extension-strike';\nimport Underline from '@tiptap/extension-underline';\nimport Text from '@tiptap/extension-text';\nimport TextAlign from '@tiptap/extension-text-align';\nimport History from '@tiptap/extension-history';\nimport Emoji from './extensions/emoji';\nimport CustomLink from './extensions/custom_link';\nimport { MentionPlugin } from './extensions/mentions/mention';\nimport { ChannelPlugin } from './extensions/channels/channel';\nimport { SlashCommandPlugin } from './extensions/slash_command/slash_command';\nimport {\n RICH_TEXT_EDITOR_OUTPUT_FORMATS,\n RICH_TEXT_EDITOR_AUTOFOCUS_TYPES,\n RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,\n} from './rich_text_editor_constants';\nimport { emojiPattern } from 'regex-combined-emojis';\n\nimport mentionSuggestion from './extensions/mentions/suggestion';\nimport channelSuggestion from './extensions/channels/suggestion';\nimport slashCommandSuggestion from './extensions/slash_command/suggestion';\nimport { warnIfUnmounted } from '@/common/utils';\n\nexport default {\n name: 'DtRichTextEditor',\n\n components: {\n EditorContent,\n },\n\n props: {\n /**\n * Value of the input. The object format should match TipTap's JSON\n * document structure: https://tiptap.dev/guide/output#option-1-json\n */\n modelValue: {\n type: [Object, String],\n default: '',\n },\n\n /**\n * Whether the input is editable\n */\n editable: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Prevents the user from typing any further. Deleting text will still work.\n */\n preventTyping: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Whether the input allows for line breaks to be introduced in the text by pressing enter. If this is disabled,\n * line breaks can still be entered by pressing shift+enter.\n */\n allowLineBreaks: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Descriptive label for the input element\n */\n inputAriaLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Additional class name for the input element. Only accepts a String value\n * because this is passed to the editor via options. For multiple classes,\n * join them into one string, e.g. \"d-p8 d-hmx96\"\n */\n inputClass: {\n type: String,\n default: '',\n },\n\n /**\n * Whether the input should receive focus after the component has been\n * mounted. Either one of `start`, `end`, `all` or a Boolean or a Number.\n * - `start` Sets the focus to the beginning of the input\n * - `end` Sets the focus to the end of the input\n * - `all` Selects the whole contents of the input\n * - `Number` Sets the focus to a specific position in the input\n * - `true` Defaults to `start`\n * - `false` Disables autofocus\n * @values true, false, start, end, all, number\n */\n autoFocus: {\n type: [Boolean, String, Number],\n default: false,\n validator (autoFocus) {\n if (typeof autoFocus === 'string') {\n return RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(autoFocus);\n }\n return true;\n },\n },\n\n /**\n * The output format that the editor uses when emitting the \"@input\" event.\n * One of `text`, `json`, `html`. See https://tiptap.dev/guide/output for\n * examples.\n * @values text, json, html\n */\n outputFormat: {\n type: String,\n default: 'html',\n validator (outputFormat) {\n return RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(outputFormat);\n },\n },\n\n /**\n * Placeholder text\n */\n placeholder: {\n type: String,\n default: '',\n },\n\n /**\n * Enables the TipTap Link extension and optionally passes configurations to it\n *\n * It is not recommended to use this and the custom link extension at the same time.\n */\n link: {\n type: [Boolean, Object],\n default: false,\n },\n\n /**\n * Enables the Custom Link extension and optionally passes configurations to it\n *\n * It is not recommended to use this and the built in TipTap link extension at the same time.\n *\n * The custom link does some additional things on top of the built in TipTap link\n * extension such as styling phone numbers and IP adresses as links, and allows you\n * to linkify text without having to type a space after the link. Currently it is missing some\n * functionality such as editing links and will likely require more work to be fully usable,\n * so it is recommended to use the built in TipTap link for now.\n */\n customLink: {\n type: [Boolean, Object],\n default: false,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the contacts for suggestion.\n * items({ query }) => { return [ContactObject]; }\n * ContactObject format:\n * { name: string, avatarSrc: string, id: string }\n *\n * When null, it does not add the plugin.\n */\n mentionSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the channels for suggestion.\n * items({ query }) => { return [ChannelObject]; }\n * ChannelObject format:\n * { name: string, id: string, locked: boolean }\n *\n * When null, it does not add the plugin. Setting locked to true will display a lock rather than hash.\n */\n channelSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the slash commands for suggestion.\n * items({ query }) => { return [SlashCommandObject]; }\n * SlashCommandObject format:\n * { command: string, description: string, parametersExample?: string }\n * The \"parametersExample\" parameter is optional, and describes an example\n * of the parameters that command can take.\n *\n * When null, it does not add the plugin.\n * Note that slash commands only work when they are the first word in the input.\n */\n slashCommandSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * Whether the input allows for block quote.\n */\n allowBlockquote: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for bold to be introduced in the text.\n */\n allowBold: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for bullet list to be introduced in the text.\n */\n allowBulletList: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for italic to be introduced in the text.\n */\n allowItalic: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for strike to be introduced in the text.\n */\n allowStrike: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for underline to be introduced in the text.\n */\n allowUnderline: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows codeblock to be introduced in the text.\n */\n allowCodeblock: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Additional TipTap extensions to be added to the editor.\n */\n additionalExtensions: {\n type: Array,\n default: () => [],\n },\n },\n\n emits: [\n /**\n * Editor input event\n * @event input\n * @type {String|JSON}\n */\n 'input',\n\n /**\n * Event to sync the value with the parent\n * @event update:value\n * @type {String|JSON}\n */\n 'update:modelValue',\n\n /**\n * Editor blur event\n * @event blur\n * @type {FocusEvent}\n */\n 'blur',\n\n /**\n * Editor focus event\n * @event focus\n * @type {FocusEvent}\n */\n 'focus',\n\n /**\n * Enter was pressed. Note that shift enter must be pressed to line break the input.\n * @event enter\n * @type {String}\n */\n 'enter',\n ],\n\n data () {\n return {\n editor: null,\n };\n },\n\n computed: {\n attrs () {\n return {\n ...this.$attrs,\n onInput: () => {},\n onFocus: () => {},\n onBlur: () => {},\n };\n },\n\n // eslint-disable-next-line complexity\n extensions () {\n // These are the default extensions needed just for plain text.\n const extensions = [Document, Paragraph, Text, History];\n if (this.link) {\n extensions.push(TipTapLink.extend({ inclusive: false }).configure({\n HTMLAttributes: {\n class: 'd-link d-wb-break-all',\n },\n autolink: true,\n protocols: RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,\n }));\n }\n if (this.customLink) {\n extensions.push(this.getExtension(CustomLink, this.customLink));\n }\n if (this.allowBlockquote) {\n extensions.push(Blockquote);\n }\n if (this.allowBold) {\n extensions.push(Bold);\n }\n if (this.allowBulletList) {\n extensions.push(BulletList);\n extensions.push(ListItem);\n extensions.push(OrderedList);\n }\n if (this.allowItalic) {\n extensions.push(Italic);\n }\n if (this.allowStrike) {\n extensions.push(Strike);\n }\n if (this.allowUnderline) {\n extensions.push(Underline);\n }\n\n // Enable placeholderText\n if (this.placeholder) {\n extensions.push(\n Placeholder.configure({ placeholder: this.placeholder }),\n );\n }\n\n // make sure that this is defined before any other extensions\n // where Enter and Shift+Enter should have its own interaction. otherwise it will be ignored\n if (!this.allowLineBreaks) {\n const self = this;\n extensions.push(\n HardBreak.extend({\n addKeyboardShortcuts () {\n return {\n Enter: () => {\n self.$emit('enter');\n return true;\n },\n 'Shift-Enter': () => {\n this.editor.commands.setHardBreak();\n return true;\n },\n };\n },\n }),\n );\n } else {\n extensions.push(HardBreak);\n }\n\n if (this.mentionSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.mentionSuggestion, ...mentionSuggestion };\n extensions.push(MentionPlugin.configure({ suggestion: suggestionObject }));\n }\n\n if (this.channelSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.channelSuggestion, ...channelSuggestion };\n extensions.push(ChannelPlugin.configure({ suggestion: suggestionObject }));\n }\n\n if (this.slashCommandSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.slashCommandSuggestion, ...slashCommandSuggestion };\n extensions.push(SlashCommandPlugin.configure({ suggestion: suggestionObject }));\n }\n\n // Emoji has some interactions with Enter key\n // hence this should be done last otherwise the enter wont add a emoji.\n extensions.push(Emoji);\n\n extensions.push(TextAlign.configure({\n types: ['paragraph'],\n defaultAlignment: 'left',\n }));\n\n if (this.allowCodeblock) {\n extensions.push(CodeBlock.configure({\n HTMLAttributes: {\n class: 'dt-rich-text-editor--code-block',\n },\n }));\n }\n\n if (this.additionalExtensions.length) {\n extensions.push(...this.additionalExtensions);\n }\n\n return extensions;\n },\n\n inputAttrs () {\n const attrs = {\n 'aria-label': this.inputAriaLabel,\n 'aria-multiline': true,\n role: 'textbox',\n };\n if (!this.editable) {\n attrs['aria-readonly'] = true;\n }\n return attrs;\n },\n },\n\n /**\n * Because the Editor instance is initialized when mounted it does not get\n * updated props automatically, so the ones that can change after mount have\n * to be hooked up to the Editor's own API.\n */\n watch: {\n editable (isEditable) {\n this.editor.setEditable(isEditable);\n this.updateEditorAttributes({ 'aria-readonly': !isEditable });\n },\n\n inputClass (newClass) {\n this.updateEditorAttributes({ class: newClass });\n },\n\n inputAriaLabel (newLabel) {\n this.updateEditorAttributes({ 'aria-label': newLabel });\n },\n\n extensions () {\n // Extensions can't be registered on the fly, so just recreate the editor.\n // https://github.com/ueberdosis/tiptap/issues/1044\n this.destroyEditor();\n this.createEditor();\n },\n\n modelValue (newValue) {\n this.processValue(newValue);\n },\n },\n\n created () {\n this.createEditor();\n },\n\n beforeUnmount () {\n this.destroyEditor();\n },\n\n mounted () {\n warnIfUnmounted(this.$el, this.$options.name);\n this.processValue(this.modelValue, false);\n },\n\n methods: {\n\n createEditor () {\n // For all available options, see https://tiptap.dev/api/editor#settings\n this.editor = new Editor({\n autofocus: this.autoFocus,\n content: this.modelValue,\n editable: this.editable,\n extensions: this.extensions,\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n },\n\n /* Absolutely crazy that this is what's needed to paste line breaks properly in prosemirror, but it does seem\n to fix our issue of line breaks outputting as paragraphs. Code taken from this thread:\n https://discuss.prosemirror.net/t/how-to-preserve-hard-breaks-when-pasting-html-into-a-plain-text-schema/4202/4\n */\n handlePaste: function (view, event, slice) {\n const { state } = view;\n const { tr } = state;\n\n if (!state.schema.nodes.hardBreak) {\n return false;\n }\n\n const clipboardText = event.clipboardData?.getData('text/plain').trim();\n\n if (!clipboardText) {\n return false;\n }\n\n const textLines = clipboardText.split(/(?:\\r\\n|\\r|\\n)/g);\n\n const nodes = textLines.reduce((nodes, line, index) => {\n if (line.length > 0) {\n nodes.push(state.schema.text(line));\n }\n\n if (index < textLines.length - 1) {\n nodes.push(state.schema.nodes.hardBreak.create());\n }\n\n return nodes;\n }, []);\n\n view.dispatch(\n tr.replaceSelection(Slice.maxOpen(Fragment.fromArray(nodes))).scrollIntoView(),\n );\n\n return true;\n },\n },\n });\n this.addEditorListeners();\n },\n\n processValue (newValue, returnIfEqual = true) {\n let currentValue = this.getOutput();\n if (this.outputFormat === 'json') {\n newValue = JSON.stringify(newValue);\n currentValue = JSON.stringify(currentValue);\n }\n if (returnIfEqual && newValue === currentValue) {\n // The new value came from this component and was passed back down\n // through the parent, so don't do anything here.\n return;\n }\n\n const inputUnicodeRegex = new RegExp(`(${emojiPattern})`, 'g');\n\n // If the text contains emoji characters convert them to emoji component tags\n newValue = newValue.replace(inputUnicodeRegex, '<emoji-component code=\"$1\"></emoji-component>');\n\n // Otherwise replace the content (resets the cursor position).\n this.editor.commands.setContent(newValue, false);\n },\n\n destroyEditor () {\n this.editor.destroy();\n },\n\n /**\n * The Editor exposes event hooks that we have to map our emits into. See\n * https://tiptap.dev/api/events for all events.\n */\n addEditorListeners () {\n // The content has changed.\n this.editor.on('update', () => {\n const value = this.getOutput();\n // When preventTyping is true and user wants to type, we revert to last value\n // If Backspace (keyCode = 8) is pressed, we allow updating the text\n if (this.preventTyping && this.editor.view?.input?.lastKeyCode !== 8) {\n this.editor.commands.setContent(this.value, false);\n return;\n }\n this.$emit('input', value);\n this.$emit('update:modelValue', value);\n });\n\n // The editor is focused.\n this.editor.on('focus', ({ event }) => {\n this.$emit('focus', event);\n });\n\n // The editor isn’t focused anymore.\n this.editor.on('blur', ({ event }) => {\n this.$emit('blur', event);\n });\n },\n\n getOutput () {\n switch (this.outputFormat) {\n case 'json':\n return this.editor.getJSON();\n case 'html':\n return this.editor.getHTML();\n case 'text':\n default:\n return this.editor.getText();\n }\n },\n\n getExtension (extension, options) {\n if (typeof options === 'boolean') {\n return extension;\n }\n return extension.configure?.(options);\n },\n\n updateEditorAttributes (attributes) {\n this.editor.setOptions({ editorProps: { attributes } });\n },\n\n focusEditor () {\n this.editor.commands.focus();\n },\n },\n};\n</script>\n\n<style lang=\"less\">\n .dt-rich-text-editor {\n &--code-block {\n background: var(--dt-color-surface-secondary);\n padding: var(--dt-space-400);\n }\n\n > .ProseMirror {\n box-shadow: none;\n\n p.is-editor-empty:first-child::before {\n content: attr(data-placeholder);\n float: left;\n color: var(--dt-color-foreground-placeholder);\n pointer-events: none;\n height: 0;\n }\n\n ul, ol {\n padding-left: var(--dt-space-525);\n }\n\n ul > li {\n list-style-type: disc;\n }\n\n ol > li {\n list-style-type: decimal;\n }\n\n blockquote {\n padding-left: var(--dt-space-400);\n border-left: var(--dt-size-border-300) solid var(--dt-color-foreground-muted-inverted);\n margin-left: 0;\n }\n }\n }\n</style>\n"],"names":["EditorContent","RICH_TEXT_EDITOR_AUTOFOCUS_TYPES","RICH_TEXT_EDITOR_OUTPUT_FORMATS","RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS","CustomLink","mentionSuggestion","MentionPlugin","channelSuggestion","ChannelPlugin","slashCommandSuggestion","SlashCommandPlugin","Emoji","warnIfUnmounted","Editor","nodes","Slice","Fragment","emojiPattern","_openBlock","_createBlock","_mergeProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAK,YAAU;AAAA,EACb,MAAM;AAAA,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WAKE;AAAA,IAJC,QAAQ,MAAM;AAAA,IACf,WAAQ;AAAA,IACR,OAAM;AAAA,KACE,SAAK,KAAA,GAAA,MAAA,IAAA,CAAA,QAAA,CAAA;;;;"}
|
|
@@ -23,9 +23,11 @@ import { MentionPlugin } from "./extensions/mentions/mention.js";
|
|
|
23
23
|
import { ChannelPlugin } from "./extensions/channels/channel.js";
|
|
24
24
|
import { SlashCommandPlugin } from "./extensions/slash_command/slash_command.js";
|
|
25
25
|
import { RICH_TEXT_EDITOR_AUTOFOCUS_TYPES, RICH_TEXT_EDITOR_OUTPUT_FORMATS, RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS } from "./rich_text_editor_constants.js";
|
|
26
|
+
import { emojiPattern } from "regex-combined-emojis";
|
|
26
27
|
import mentionSuggestion from "./extensions/mentions/suggestion.js";
|
|
27
28
|
import channelSuggestion from "./extensions/channels/suggestion.js";
|
|
28
29
|
import slashCommandSuggestion from "./extensions/slash_command/suggestion.js";
|
|
30
|
+
import { warnIfUnmounted } from "../../common/utils.js";
|
|
29
31
|
import { resolveComponent, openBlock, createBlock, mergeProps } from "vue";
|
|
30
32
|
/* empty css */
|
|
31
33
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
@@ -423,15 +425,7 @@ const _sfc_main = {
|
|
|
423
425
|
this.createEditor();
|
|
424
426
|
},
|
|
425
427
|
modelValue(newValue) {
|
|
426
|
-
|
|
427
|
-
if (this.outputFormat === "json") {
|
|
428
|
-
newValue = JSON.stringify(newValue);
|
|
429
|
-
currentValue = JSON.stringify(currentValue);
|
|
430
|
-
}
|
|
431
|
-
if (newValue === currentValue) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
this.editor.commands.setContent(newValue, false);
|
|
428
|
+
this.processValue(newValue);
|
|
435
429
|
}
|
|
436
430
|
},
|
|
437
431
|
created() {
|
|
@@ -440,6 +434,10 @@ const _sfc_main = {
|
|
|
440
434
|
beforeUnmount() {
|
|
441
435
|
this.destroyEditor();
|
|
442
436
|
},
|
|
437
|
+
mounted() {
|
|
438
|
+
warnIfUnmounted(this.$el, this.$options.name);
|
|
439
|
+
this.processValue(this.modelValue, false);
|
|
440
|
+
},
|
|
443
441
|
methods: {
|
|
444
442
|
createEditor() {
|
|
445
443
|
this.editor = new Editor({
|
|
@@ -486,6 +484,19 @@ const _sfc_main = {
|
|
|
486
484
|
});
|
|
487
485
|
this.addEditorListeners();
|
|
488
486
|
},
|
|
487
|
+
processValue(newValue, returnIfEqual = true) {
|
|
488
|
+
let currentValue = this.getOutput();
|
|
489
|
+
if (this.outputFormat === "json") {
|
|
490
|
+
newValue = JSON.stringify(newValue);
|
|
491
|
+
currentValue = JSON.stringify(currentValue);
|
|
492
|
+
}
|
|
493
|
+
if (returnIfEqual && newValue === currentValue) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
const inputUnicodeRegex = new RegExp(`(${emojiPattern})`, "g");
|
|
497
|
+
newValue = newValue.replace(inputUnicodeRegex, '<emoji-component code="$1"></emoji-component>');
|
|
498
|
+
this.editor.commands.setContent(newValue, false);
|
|
499
|
+
},
|
|
489
500
|
destroyEditor() {
|
|
490
501
|
this.editor.destroy();
|
|
491
502
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich_text_editor.vue.js","sources":["../../../components/rich_text_editor/rich_text_editor.vue"],"sourcesContent":["<template>\n <editor-content\n :editor=\"editor\"\n data-qa=\"dt-rich-text-editor\"\n class=\"dt-rich-text-editor\"\n v-bind=\"attrs\"\n />\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { Editor, EditorContent } from '@tiptap/vue-3';\nimport { Slice, Fragment } from '@tiptap/pm/model';\nimport Blockquote from '@tiptap/extension-blockquote';\nimport CodeBlock from '@tiptap/extension-code-block';\nimport Document from '@tiptap/extension-document';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Italic from '@tiptap/extension-italic';\nimport TipTapLink from '@tiptap/extension-link';\nimport ListItem from '@tiptap/extension-list-item';\nimport OrderedList from '@tiptap/extension-ordered-list';\nimport Strike from '@tiptap/extension-strike';\nimport Underline from '@tiptap/extension-underline';\nimport Text from '@tiptap/extension-text';\nimport TextAlign from '@tiptap/extension-text-align';\nimport History from '@tiptap/extension-history';\nimport Emoji from './extensions/emoji';\nimport CustomLink from './extensions/custom_link';\nimport { MentionPlugin } from './extensions/mentions/mention';\nimport { ChannelPlugin } from './extensions/channels/channel';\nimport { SlashCommandPlugin } from './extensions/slash_command/slash_command';\nimport {\n RICH_TEXT_EDITOR_OUTPUT_FORMATS,\n RICH_TEXT_EDITOR_AUTOFOCUS_TYPES,\n RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,\n} from './rich_text_editor_constants';\n\nimport mentionSuggestion from './extensions/mentions/suggestion';\nimport channelSuggestion from './extensions/channels/suggestion';\nimport slashCommandSuggestion from './extensions/slash_command/suggestion';\n\nexport default {\n name: 'DtRichTextEditor',\n\n components: {\n EditorContent,\n },\n\n props: {\n /**\n * Value of the input. The object format should match TipTap's JSON\n * document structure: https://tiptap.dev/guide/output#option-1-json\n */\n modelValue: {\n type: [Object, String],\n default: '',\n },\n\n /**\n * Whether the input is editable\n */\n editable: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Prevents the user from typing any further. Deleting text will still work.\n */\n preventTyping: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Whether the input allows for line breaks to be introduced in the text by pressing enter. If this is disabled,\n * line breaks can still be entered by pressing shift+enter.\n */\n allowLineBreaks: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Descriptive label for the input element\n */\n inputAriaLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Additional class name for the input element. Only accepts a String value\n * because this is passed to the editor via options. For multiple classes,\n * join them into one string, e.g. \"d-p8 d-hmx96\"\n */\n inputClass: {\n type: String,\n default: '',\n },\n\n /**\n * Whether the input should receive focus after the component has been\n * mounted. Either one of `start`, `end`, `all` or a Boolean or a Number.\n * - `start` Sets the focus to the beginning of the input\n * - `end` Sets the focus to the end of the input\n * - `all` Selects the whole contents of the input\n * - `Number` Sets the focus to a specific position in the input\n * - `true` Defaults to `start`\n * - `false` Disables autofocus\n * @values true, false, start, end, all, number\n */\n autoFocus: {\n type: [Boolean, String, Number],\n default: false,\n validator (autoFocus) {\n if (typeof autoFocus === 'string') {\n return RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(autoFocus);\n }\n return true;\n },\n },\n\n /**\n * The output format that the editor uses when emitting the \"@input\" event.\n * One of `text`, `json`, `html`. See https://tiptap.dev/guide/output for\n * examples.\n * @values text, json, html\n */\n outputFormat: {\n type: String,\n default: 'html',\n validator (outputFormat) {\n return RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(outputFormat);\n },\n },\n\n /**\n * Placeholder text\n */\n placeholder: {\n type: String,\n default: '',\n },\n\n /**\n * Enables the TipTap Link extension and optionally passes configurations to it\n *\n * It is not recommended to use this and the custom link extension at the same time.\n */\n link: {\n type: [Boolean, Object],\n default: false,\n },\n\n /**\n * Enables the Custom Link extension and optionally passes configurations to it\n *\n * It is not recommended to use this and the built in TipTap link extension at the same time.\n *\n * The custom link does some additional things on top of the built in TipTap link\n * extension such as styling phone numbers and IP adresses as links, and allows you\n * to linkify text without having to type a space after the link. Currently it is missing some\n * functionality such as editing links and will likely require more work to be fully usable,\n * so it is recommended to use the built in TipTap link for now.\n */\n customLink: {\n type: [Boolean, Object],\n default: false,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the contacts for suggestion.\n * items({ query }) => { return [ContactObject]; }\n * ContactObject format:\n * { name: string, avatarSrc: string, id: string }\n *\n * When null, it does not add the plugin.\n */\n mentionSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the channels for suggestion.\n * items({ query }) => { return [ChannelObject]; }\n * ChannelObject format:\n * { name: string, id: string, locked: boolean }\n *\n * When null, it does not add the plugin. Setting locked to true will display a lock rather than hash.\n */\n channelSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the slash commands for suggestion.\n * items({ query }) => { return [SlashCommandObject]; }\n * SlashCommandObject format:\n * { command: string, description: string, parametersExample?: string }\n * The \"parametersExample\" parameter is optional, and describes an example\n * of the parameters that command can take.\n *\n * When null, it does not add the plugin.\n * Note that slash commands only work when they are the first word in the input.\n */\n slashCommandSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * Whether the input allows for block quote.\n */\n allowBlockquote: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for bold to be introduced in the text.\n */\n allowBold: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for bullet list to be introduced in the text.\n */\n allowBulletList: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for italic to be introduced in the text.\n */\n allowItalic: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for strike to be introduced in the text.\n */\n allowStrike: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for underline to be introduced in the text.\n */\n allowUnderline: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows codeblock to be introduced in the text.\n */\n allowCodeblock: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Additional TipTap extensions to be added to the editor.\n */\n additionalExtensions: {\n type: Array,\n default: () => [],\n },\n },\n\n emits: [\n /**\n * Editor input event\n * @event input\n * @type {String|JSON}\n */\n 'input',\n\n /**\n * Event to sync the value with the parent\n * @event update:value\n * @type {String|JSON}\n */\n 'update:modelValue',\n\n /**\n * Editor blur event\n * @event blur\n * @type {FocusEvent}\n */\n 'blur',\n\n /**\n * Editor focus event\n * @event focus\n * @type {FocusEvent}\n */\n 'focus',\n\n /**\n * Enter was pressed. Note that shift enter must be pressed to line break the input.\n * @event enter\n * @type {String}\n */\n 'enter',\n ],\n\n data () {\n return {\n editor: null,\n };\n },\n\n computed: {\n attrs () {\n return {\n ...this.$attrs,\n onInput: () => {},\n onFocus: () => {},\n onBlur: () => {},\n };\n },\n\n // eslint-disable-next-line complexity\n extensions () {\n // These are the default extensions needed just for plain text.\n const extensions = [Document, Paragraph, Text, History];\n if (this.link) {\n extensions.push(TipTapLink.extend({ inclusive: false }).configure({\n HTMLAttributes: {\n class: 'd-link d-wb-break-all',\n },\n autolink: true,\n protocols: RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,\n }));\n }\n if (this.customLink) {\n extensions.push(this.getExtension(CustomLink, this.customLink));\n }\n if (this.allowBlockquote) {\n extensions.push(Blockquote);\n }\n if (this.allowBold) {\n extensions.push(Bold);\n }\n if (this.allowBulletList) {\n extensions.push(BulletList);\n extensions.push(ListItem);\n extensions.push(OrderedList);\n }\n if (this.allowItalic) {\n extensions.push(Italic);\n }\n if (this.allowStrike) {\n extensions.push(Strike);\n }\n if (this.allowUnderline) {\n extensions.push(Underline);\n }\n\n // Enable placeholderText\n if (this.placeholder) {\n extensions.push(\n Placeholder.configure({ placeholder: this.placeholder }),\n );\n }\n\n // make sure that this is defined before any other extensions\n // where Enter and Shift+Enter should have its own interaction. otherwise it will be ignored\n if (!this.allowLineBreaks) {\n const self = this;\n extensions.push(\n HardBreak.extend({\n addKeyboardShortcuts () {\n return {\n Enter: () => {\n self.$emit('enter');\n return true;\n },\n 'Shift-Enter': () => {\n this.editor.commands.setHardBreak();\n return true;\n },\n };\n },\n }),\n );\n } else {\n extensions.push(HardBreak);\n }\n\n if (this.mentionSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.mentionSuggestion, ...mentionSuggestion };\n extensions.push(MentionPlugin.configure({ suggestion: suggestionObject }));\n }\n\n if (this.channelSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.channelSuggestion, ...channelSuggestion };\n extensions.push(ChannelPlugin.configure({ suggestion: suggestionObject }));\n }\n\n if (this.slashCommandSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.slashCommandSuggestion, ...slashCommandSuggestion };\n extensions.push(SlashCommandPlugin.configure({ suggestion: suggestionObject }));\n }\n\n // Emoji has some interactions with Enter key\n // hence this should be done last otherwise the enter wont add a emoji.\n extensions.push(Emoji);\n\n extensions.push(TextAlign.configure({\n types: ['paragraph'],\n defaultAlignment: 'left',\n }));\n\n if (this.allowCodeblock) {\n extensions.push(CodeBlock.configure({\n HTMLAttributes: {\n class: 'dt-rich-text-editor--code-block',\n },\n }));\n }\n\n if (this.additionalExtensions.length) {\n extensions.push(...this.additionalExtensions);\n }\n\n return extensions;\n },\n\n inputAttrs () {\n const attrs = {\n 'aria-label': this.inputAriaLabel,\n 'aria-multiline': true,\n role: 'textbox',\n };\n if (!this.editable) {\n attrs['aria-readonly'] = true;\n }\n return attrs;\n },\n },\n\n /**\n * Because the Editor instance is initialized when mounted it does not get\n * updated props automatically, so the ones that can change after mount have\n * to be hooked up to the Editor's own API.\n */\n watch: {\n editable (isEditable) {\n this.editor.setEditable(isEditable);\n this.updateEditorAttributes({ 'aria-readonly': !isEditable });\n },\n\n inputClass (newClass) {\n this.updateEditorAttributes({ class: newClass });\n },\n\n inputAriaLabel (newLabel) {\n this.updateEditorAttributes({ 'aria-label': newLabel });\n },\n\n extensions () {\n // Extensions can't be registered on the fly, so just recreate the editor.\n // https://github.com/ueberdosis/tiptap/issues/1044\n this.destroyEditor();\n this.createEditor();\n },\n\n modelValue (newValue) {\n let currentValue = this.getOutput();\n if (this.outputFormat === 'json') {\n newValue = JSON.stringify(newValue);\n currentValue = JSON.stringify(currentValue);\n }\n if (newValue === currentValue) {\n // The new value came from this component and was passed back down\n // through the parent, so don't do anything here.\n return;\n }\n // Otherwise replace the content (resets the cursor position).\n this.editor.commands.setContent(newValue, false);\n },\n },\n\n created () {\n this.createEditor();\n },\n\n beforeUnmount () {\n this.destroyEditor();\n },\n\n methods: {\n\n createEditor () {\n // For all available options, see https://tiptap.dev/api/editor#settings\n this.editor = new Editor({\n autofocus: this.autoFocus,\n content: this.modelValue,\n editable: this.editable,\n extensions: this.extensions,\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n },\n\n /* Absolutely crazy that this is what's needed to paste line breaks properly in prosemirror, but it does seem\n to fix our issue of line breaks outputting as paragraphs. Code taken from this thread:\n https://discuss.prosemirror.net/t/how-to-preserve-hard-breaks-when-pasting-html-into-a-plain-text-schema/4202/4\n */\n handlePaste: function (view, event, slice) {\n const { state } = view;\n const { tr } = state;\n\n if (!state.schema.nodes.hardBreak) {\n return false;\n }\n\n const clipboardText = event.clipboardData?.getData('text/plain').trim();\n\n if (!clipboardText) {\n return false;\n }\n\n const textLines = clipboardText.split(/(?:\\r\\n|\\r|\\n)/g);\n\n const nodes = textLines.reduce((nodes, line, index) => {\n if (line.length > 0) {\n nodes.push(state.schema.text(line));\n }\n\n if (index < textLines.length - 1) {\n nodes.push(state.schema.nodes.hardBreak.create());\n }\n\n return nodes;\n }, []);\n\n view.dispatch(\n tr.replaceSelection(Slice.maxOpen(Fragment.fromArray(nodes))).scrollIntoView(),\n );\n\n return true;\n },\n },\n });\n this.addEditorListeners();\n },\n\n destroyEditor () {\n this.editor.destroy();\n },\n\n /**\n * The Editor exposes event hooks that we have to map our emits into. See\n * https://tiptap.dev/api/events for all events.\n */\n addEditorListeners () {\n // The content has changed.\n this.editor.on('update', () => {\n const value = this.getOutput();\n // When preventTyping is true and user wants to type, we revert to last value\n // If Backspace (keyCode = 8) is pressed, we allow updating the text\n if (this.preventTyping && this.editor.view?.input?.lastKeyCode !== 8) {\n this.editor.commands.setContent(this.value, false);\n return;\n }\n this.$emit('input', value);\n this.$emit('update:modelValue', value);\n });\n\n // The editor is focused.\n this.editor.on('focus', ({ event }) => {\n this.$emit('focus', event);\n });\n\n // The editor isn’t focused anymore.\n this.editor.on('blur', ({ event }) => {\n this.$emit('blur', event);\n });\n },\n\n getOutput () {\n switch (this.outputFormat) {\n case 'json':\n return this.editor.getJSON();\n case 'html':\n return this.editor.getHTML();\n case 'text':\n default:\n return this.editor.getText();\n }\n },\n\n getExtension (extension, options) {\n if (typeof options === 'boolean') {\n return extension;\n }\n return extension.configure?.(options);\n },\n\n updateEditorAttributes (attributes) {\n this.editor.setOptions({ editorProps: { attributes } });\n },\n\n focusEditor () {\n this.editor.commands.focus();\n },\n },\n};\n</script>\n\n<style lang=\"less\">\n .dt-rich-text-editor {\n &--code-block {\n background: var(--dt-color-surface-secondary);\n padding: var(--dt-space-400);\n }\n\n > .ProseMirror {\n box-shadow: none;\n\n p.is-editor-empty:first-child::before {\n content: attr(data-placeholder);\n float: left;\n color: var(--dt-color-foreground-placeholder);\n pointer-events: none;\n height: 0;\n }\n\n ul, ol {\n padding-left: var(--dt-space-525);\n }\n\n ul > li {\n list-style-type: disc;\n }\n\n ol > li {\n list-style-type: decimal;\n }\n\n blockquote {\n padding-left: var(--dt-space-400);\n border-left: var(--dt-size-border-300) solid var(--dt-color-foreground-muted-inverted);\n margin-left: 0;\n }\n }\n }\n</style>\n"],"names":["nodes","_openBlock","_createBlock","_mergeProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CA,MAAK,YAAU;AAAA,EACb,MAAM;AAAA,EAEN,YAAY;AAAA,IACV;AAAA,EACD;AAAA,EAED,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,YAAY;AAAA,MACV,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS;AAAA,IACV;AAAA;AAAA;AA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AS,KAAK;AAAA,MAC3B,CAAC;AAGD,WAAK,OAAO,GAAG,QAAQ,CAAC,EAAE,MAAI,MAAQ;AACpC,aAAK,MAAM,QAAQ,KAAK;AAAA,MAC1B,CAAC;AAAA,IACF;AAAA,IAED,YAAa;AACX,cAAQ,KAAK,cAAY;AAAA,QACvB,KAAK;AACH,iBAAO,KAAK,OAAO;QACrB,KAAK;AACH,iBAAO,KAAK,OAAO;QACrB,KAAK;AAAA,QACL;AACE,iBAAO,KAAK,OAAO;MACvB;AAAA,IACD;AAAA,IAED,aAAc,WAAW,SAAS;;AAChC,UAAI,OAAO,YAAY,WAAW;AAChC,eAAO;AAAA,MACT;AACA,cAAO,eAAU,cAAV,mCAAsB;AAAA,IAC9B;AAAA,IAED,uBAAwB,YAAY;AAClC,WAAK,OAAO,WAAW,EAAE,aAAa,EAAE,WAAa,EAAA,CAAC;AAAA,IACvD;AAAA,IAED,cAAe;AACb,WAAK,OAAO,SAAS;IACtB;AAAA,EACF;AACH;;;AA1nBE,SAAAC,UAAA,GAAAC,YAKE,2BALFC,WAKE;AAAA,IAJC,QAAQ,MAAM;AAAA,IACf,WAAQ;AAAA,IACR,OAAM;AAAA,KACE,SAAK,KAAA,GAAA,MAAA,IAAA,CAAA,QAAA,CAAA;;;"}
|
|
1
|
+
{"version":3,"file":"rich_text_editor.vue.js","sources":["../../../components/rich_text_editor/rich_text_editor.vue"],"sourcesContent":["<template>\n <editor-content\n :editor=\"editor\"\n data-qa=\"dt-rich-text-editor\"\n class=\"dt-rich-text-editor\"\n v-bind=\"attrs\"\n />\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { Editor, EditorContent } from '@tiptap/vue-3';\nimport { Slice, Fragment } from '@tiptap/pm/model';\nimport Blockquote from '@tiptap/extension-blockquote';\nimport CodeBlock from '@tiptap/extension-code-block';\nimport Document from '@tiptap/extension-document';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Italic from '@tiptap/extension-italic';\nimport TipTapLink from '@tiptap/extension-link';\nimport ListItem from '@tiptap/extension-list-item';\nimport OrderedList from '@tiptap/extension-ordered-list';\nimport Strike from '@tiptap/extension-strike';\nimport Underline from '@tiptap/extension-underline';\nimport Text from '@tiptap/extension-text';\nimport TextAlign from '@tiptap/extension-text-align';\nimport History from '@tiptap/extension-history';\nimport Emoji from './extensions/emoji';\nimport CustomLink from './extensions/custom_link';\nimport { MentionPlugin } from './extensions/mentions/mention';\nimport { ChannelPlugin } from './extensions/channels/channel';\nimport { SlashCommandPlugin } from './extensions/slash_command/slash_command';\nimport {\n RICH_TEXT_EDITOR_OUTPUT_FORMATS,\n RICH_TEXT_EDITOR_AUTOFOCUS_TYPES,\n RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,\n} from './rich_text_editor_constants';\nimport { emojiPattern } from 'regex-combined-emojis';\n\nimport mentionSuggestion from './extensions/mentions/suggestion';\nimport channelSuggestion from './extensions/channels/suggestion';\nimport slashCommandSuggestion from './extensions/slash_command/suggestion';\nimport { warnIfUnmounted } from '@/common/utils';\n\nexport default {\n name: 'DtRichTextEditor',\n\n components: {\n EditorContent,\n },\n\n props: {\n /**\n * Value of the input. The object format should match TipTap's JSON\n * document structure: https://tiptap.dev/guide/output#option-1-json\n */\n modelValue: {\n type: [Object, String],\n default: '',\n },\n\n /**\n * Whether the input is editable\n */\n editable: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Prevents the user from typing any further. Deleting text will still work.\n */\n preventTyping: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Whether the input allows for line breaks to be introduced in the text by pressing enter. If this is disabled,\n * line breaks can still be entered by pressing shift+enter.\n */\n allowLineBreaks: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Descriptive label for the input element\n */\n inputAriaLabel: {\n type: String,\n required: true,\n },\n\n /**\n * Additional class name for the input element. Only accepts a String value\n * because this is passed to the editor via options. For multiple classes,\n * join them into one string, e.g. \"d-p8 d-hmx96\"\n */\n inputClass: {\n type: String,\n default: '',\n },\n\n /**\n * Whether the input should receive focus after the component has been\n * mounted. Either one of `start`, `end`, `all` or a Boolean or a Number.\n * - `start` Sets the focus to the beginning of the input\n * - `end` Sets the focus to the end of the input\n * - `all` Selects the whole contents of the input\n * - `Number` Sets the focus to a specific position in the input\n * - `true` Defaults to `start`\n * - `false` Disables autofocus\n * @values true, false, start, end, all, number\n */\n autoFocus: {\n type: [Boolean, String, Number],\n default: false,\n validator (autoFocus) {\n if (typeof autoFocus === 'string') {\n return RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(autoFocus);\n }\n return true;\n },\n },\n\n /**\n * The output format that the editor uses when emitting the \"@input\" event.\n * One of `text`, `json`, `html`. See https://tiptap.dev/guide/output for\n * examples.\n * @values text, json, html\n */\n outputFormat: {\n type: String,\n default: 'html',\n validator (outputFormat) {\n return RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(outputFormat);\n },\n },\n\n /**\n * Placeholder text\n */\n placeholder: {\n type: String,\n default: '',\n },\n\n /**\n * Enables the TipTap Link extension and optionally passes configurations to it\n *\n * It is not recommended to use this and the custom link extension at the same time.\n */\n link: {\n type: [Boolean, Object],\n default: false,\n },\n\n /**\n * Enables the Custom Link extension and optionally passes configurations to it\n *\n * It is not recommended to use this and the built in TipTap link extension at the same time.\n *\n * The custom link does some additional things on top of the built in TipTap link\n * extension such as styling phone numbers and IP adresses as links, and allows you\n * to linkify text without having to type a space after the link. Currently it is missing some\n * functionality such as editing links and will likely require more work to be fully usable,\n * so it is recommended to use the built in TipTap link for now.\n */\n customLink: {\n type: [Boolean, Object],\n default: false,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the contacts for suggestion.\n * items({ query }) => { return [ContactObject]; }\n * ContactObject format:\n * { name: string, avatarSrc: string, id: string }\n *\n * When null, it does not add the plugin.\n */\n mentionSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the channels for suggestion.\n * items({ query }) => { return [ChannelObject]; }\n * ChannelObject format:\n * { name: string, id: string, locked: boolean }\n *\n * When null, it does not add the plugin. Setting locked to true will display a lock rather than hash.\n */\n channelSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * suggestion object containing the items query function.\n * The valid keys passed into this object can be found here: https://tiptap.dev/api/utilities/suggestion\n *\n * The only required key is the items function which is used to query the slash commands for suggestion.\n * items({ query }) => { return [SlashCommandObject]; }\n * SlashCommandObject format:\n * { command: string, description: string, parametersExample?: string }\n * The \"parametersExample\" parameter is optional, and describes an example\n * of the parameters that command can take.\n *\n * When null, it does not add the plugin.\n * Note that slash commands only work when they are the first word in the input.\n */\n slashCommandSuggestion: {\n type: Object,\n default: null,\n },\n\n /**\n * Whether the input allows for block quote.\n */\n allowBlockquote: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for bold to be introduced in the text.\n */\n allowBold: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for bullet list to be introduced in the text.\n */\n allowBulletList: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for italic to be introduced in the text.\n */\n allowItalic: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for strike to be introduced in the text.\n */\n allowStrike: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows for underline to be introduced in the text.\n */\n allowUnderline: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Whether the input allows codeblock to be introduced in the text.\n */\n allowCodeblock: {\n type: Boolean,\n default: true,\n },\n\n /**\n * Additional TipTap extensions to be added to the editor.\n */\n additionalExtensions: {\n type: Array,\n default: () => [],\n },\n },\n\n emits: [\n /**\n * Editor input event\n * @event input\n * @type {String|JSON}\n */\n 'input',\n\n /**\n * Event to sync the value with the parent\n * @event update:value\n * @type {String|JSON}\n */\n 'update:modelValue',\n\n /**\n * Editor blur event\n * @event blur\n * @type {FocusEvent}\n */\n 'blur',\n\n /**\n * Editor focus event\n * @event focus\n * @type {FocusEvent}\n */\n 'focus',\n\n /**\n * Enter was pressed. Note that shift enter must be pressed to line break the input.\n * @event enter\n * @type {String}\n */\n 'enter',\n ],\n\n data () {\n return {\n editor: null,\n };\n },\n\n computed: {\n attrs () {\n return {\n ...this.$attrs,\n onInput: () => {},\n onFocus: () => {},\n onBlur: () => {},\n };\n },\n\n // eslint-disable-next-line complexity\n extensions () {\n // These are the default extensions needed just for plain text.\n const extensions = [Document, Paragraph, Text, History];\n if (this.link) {\n extensions.push(TipTapLink.extend({ inclusive: false }).configure({\n HTMLAttributes: {\n class: 'd-link d-wb-break-all',\n },\n autolink: true,\n protocols: RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,\n }));\n }\n if (this.customLink) {\n extensions.push(this.getExtension(CustomLink, this.customLink));\n }\n if (this.allowBlockquote) {\n extensions.push(Blockquote);\n }\n if (this.allowBold) {\n extensions.push(Bold);\n }\n if (this.allowBulletList) {\n extensions.push(BulletList);\n extensions.push(ListItem);\n extensions.push(OrderedList);\n }\n if (this.allowItalic) {\n extensions.push(Italic);\n }\n if (this.allowStrike) {\n extensions.push(Strike);\n }\n if (this.allowUnderline) {\n extensions.push(Underline);\n }\n\n // Enable placeholderText\n if (this.placeholder) {\n extensions.push(\n Placeholder.configure({ placeholder: this.placeholder }),\n );\n }\n\n // make sure that this is defined before any other extensions\n // where Enter and Shift+Enter should have its own interaction. otherwise it will be ignored\n if (!this.allowLineBreaks) {\n const self = this;\n extensions.push(\n HardBreak.extend({\n addKeyboardShortcuts () {\n return {\n Enter: () => {\n self.$emit('enter');\n return true;\n },\n 'Shift-Enter': () => {\n this.editor.commands.setHardBreak();\n return true;\n },\n };\n },\n }),\n );\n } else {\n extensions.push(HardBreak);\n }\n\n if (this.mentionSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.mentionSuggestion, ...mentionSuggestion };\n extensions.push(MentionPlugin.configure({ suggestion: suggestionObject }));\n }\n\n if (this.channelSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.channelSuggestion, ...channelSuggestion };\n extensions.push(ChannelPlugin.configure({ suggestion: suggestionObject }));\n }\n\n if (this.slashCommandSuggestion) {\n // Add both the suggestion plugin as well as means for user to add suggestion items to the plugin\n const suggestionObject = { ...this.slashCommandSuggestion, ...slashCommandSuggestion };\n extensions.push(SlashCommandPlugin.configure({ suggestion: suggestionObject }));\n }\n\n // Emoji has some interactions with Enter key\n // hence this should be done last otherwise the enter wont add a emoji.\n extensions.push(Emoji);\n\n extensions.push(TextAlign.configure({\n types: ['paragraph'],\n defaultAlignment: 'left',\n }));\n\n if (this.allowCodeblock) {\n extensions.push(CodeBlock.configure({\n HTMLAttributes: {\n class: 'dt-rich-text-editor--code-block',\n },\n }));\n }\n\n if (this.additionalExtensions.length) {\n extensions.push(...this.additionalExtensions);\n }\n\n return extensions;\n },\n\n inputAttrs () {\n const attrs = {\n 'aria-label': this.inputAriaLabel,\n 'aria-multiline': true,\n role: 'textbox',\n };\n if (!this.editable) {\n attrs['aria-readonly'] = true;\n }\n return attrs;\n },\n },\n\n /**\n * Because the Editor instance is initialized when mounted it does not get\n * updated props automatically, so the ones that can change after mount have\n * to be hooked up to the Editor's own API.\n */\n watch: {\n editable (isEditable) {\n this.editor.setEditable(isEditable);\n this.updateEditorAttributes({ 'aria-readonly': !isEditable });\n },\n\n inputClass (newClass) {\n this.updateEditorAttributes({ class: newClass });\n },\n\n inputAriaLabel (newLabel) {\n this.updateEditorAttributes({ 'aria-label': newLabel });\n },\n\n extensions () {\n // Extensions can't be registered on the fly, so just recreate the editor.\n // https://github.com/ueberdosis/tiptap/issues/1044\n this.destroyEditor();\n this.createEditor();\n },\n\n modelValue (newValue) {\n this.processValue(newValue);\n },\n },\n\n created () {\n this.createEditor();\n },\n\n beforeUnmount () {\n this.destroyEditor();\n },\n\n mounted () {\n warnIfUnmounted(this.$el, this.$options.name);\n this.processValue(this.modelValue, false);\n },\n\n methods: {\n\n createEditor () {\n // For all available options, see https://tiptap.dev/api/editor#settings\n this.editor = new Editor({\n autofocus: this.autoFocus,\n content: this.modelValue,\n editable: this.editable,\n extensions: this.extensions,\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n },\n\n /* Absolutely crazy that this is what's needed to paste line breaks properly in prosemirror, but it does seem\n to fix our issue of line breaks outputting as paragraphs. Code taken from this thread:\n https://discuss.prosemirror.net/t/how-to-preserve-hard-breaks-when-pasting-html-into-a-plain-text-schema/4202/4\n */\n handlePaste: function (view, event, slice) {\n const { state } = view;\n const { tr } = state;\n\n if (!state.schema.nodes.hardBreak) {\n return false;\n }\n\n const clipboardText = event.clipboardData?.getData('text/plain').trim();\n\n if (!clipboardText) {\n return false;\n }\n\n const textLines = clipboardText.split(/(?:\\r\\n|\\r|\\n)/g);\n\n const nodes = textLines.reduce((nodes, line, index) => {\n if (line.length > 0) {\n nodes.push(state.schema.text(line));\n }\n\n if (index < textLines.length - 1) {\n nodes.push(state.schema.nodes.hardBreak.create());\n }\n\n return nodes;\n }, []);\n\n view.dispatch(\n tr.replaceSelection(Slice.maxOpen(Fragment.fromArray(nodes))).scrollIntoView(),\n );\n\n return true;\n },\n },\n });\n this.addEditorListeners();\n },\n\n processValue (newValue, returnIfEqual = true) {\n let currentValue = this.getOutput();\n if (this.outputFormat === 'json') {\n newValue = JSON.stringify(newValue);\n currentValue = JSON.stringify(currentValue);\n }\n if (returnIfEqual && newValue === currentValue) {\n // The new value came from this component and was passed back down\n // through the parent, so don't do anything here.\n return;\n }\n\n const inputUnicodeRegex = new RegExp(`(${emojiPattern})`, 'g');\n\n // If the text contains emoji characters convert them to emoji component tags\n newValue = newValue.replace(inputUnicodeRegex, '<emoji-component code=\"$1\"></emoji-component>');\n\n // Otherwise replace the content (resets the cursor position).\n this.editor.commands.setContent(newValue, false);\n },\n\n destroyEditor () {\n this.editor.destroy();\n },\n\n /**\n * The Editor exposes event hooks that we have to map our emits into. See\n * https://tiptap.dev/api/events for all events.\n */\n addEditorListeners () {\n // The content has changed.\n this.editor.on('update', () => {\n const value = this.getOutput();\n // When preventTyping is true and user wants to type, we revert to last value\n // If Backspace (keyCode = 8) is pressed, we allow updating the text\n if (this.preventTyping && this.editor.view?.input?.lastKeyCode !== 8) {\n this.editor.commands.setContent(this.value, false);\n return;\n }\n this.$emit('input', value);\n this.$emit('update:modelValue', value);\n });\n\n // The editor is focused.\n this.editor.on('focus', ({ event }) => {\n this.$emit('focus', event);\n });\n\n // The editor isn’t focused anymore.\n this.editor.on('blur', ({ event }) => {\n this.$emit('blur', event);\n });\n },\n\n getOutput () {\n switch (this.outputFormat) {\n case 'json':\n return this.editor.getJSON();\n case 'html':\n return this.editor.getHTML();\n case 'text':\n default:\n return this.editor.getText();\n }\n },\n\n getExtension (extension, options) {\n if (typeof options === 'boolean') {\n return extension;\n }\n return extension.configure?.(options);\n },\n\n updateEditorAttributes (attributes) {\n this.editor.setOptions({ editorProps: { attributes } });\n },\n\n focusEditor () {\n this.editor.commands.focus();\n },\n },\n};\n</script>\n\n<style lang=\"less\">\n .dt-rich-text-editor {\n &--code-block {\n background: var(--dt-color-surface-secondary);\n padding: var(--dt-space-400);\n }\n\n > .ProseMirror {\n box-shadow: none;\n\n p.is-editor-empty:first-child::before {\n content: attr(data-placeholder);\n float: left;\n color: var(--dt-color-foreground-placeholder);\n pointer-events: none;\n height: 0;\n }\n\n ul, ol {\n padding-left: var(--dt-space-525);\n }\n\n ul > li {\n list-style-type: disc;\n }\n\n ol > li {\n list-style-type: decimal;\n }\n\n blockquote {\n padding-left: var(--dt-space-400);\n border-left: var(--dt-size-border-300) solid var(--dt-color-foreground-muted-inverted);\n margin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ACH;;;AA3oBE,SAAAC,UAAA,GAAAC,YAKE,2BALFC,WAKE;AAAA,IAJC,QAAQ,MAAM;AAAA,IACf,WAAQ;AAAA,IACR,OAAM;AAAA,KACE,SAAK,KAAA,GAAA,MAAA,IAAA,CAAA,QAAA,CAAA;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split_button.vue.cjs","sources":["../../../components/split_button/split_button.vue"],"sourcesContent":["<template>\n <span\n data-qa=\"dt-split-button\"\n class=\"d-split-btn\"\n :style=\"{ width }\"\n >\n <split-button-alpha\n v-bind=\"alphaButtonProps\"\n ref=\"alphaButton\"\n @click=\"$emit('alpha-clicked')\"\n >\n <template #icon=\"{ size: iconSize }\">\n <!-- @slot Alpha (left) button icon slot -->\n <slot\n name=\"alphaIcon\"\n :size=\"iconSize\"\n />\n </template>\n <!-- @slot Default content slot -->\n <slot name=\"default\" />\n </split-button-alpha>\n <!-- @slot Omega (right) content slot, overrides omega button styling and functionality completely -->\n <slot name=\"omega\">\n <dt-dropdown\n v-if=\"$slots.dropdownList\"\n :placement=\"dropdownPlacement\"\n @click=\"isDropdownOpen = true\"\n @opened=\"open => isDropdownOpen = open\"\n >\n <template #anchor=\"attrs\">\n <split-button-omega\n v-bind=\"{ ...attrs, ...omegaButtonProps }\"\n :active=\"isDropdownOpen\"\n @click=\"$emit('omega-clicked')\"\n >\n <template #icon=\"{ size: iconSize }\">\n <!-- @slot Omega (right) button icon slot -->\n <slot\n name=\"omegaIcon\"\n :size=\"iconSize\"\n />\n </template>\n </split-button-omega>\n </template>\n <template #list=\"{ close }\">\n <!-- @slot Built-in dropdown content slot, use of dt-list-item is highly recommended here. -->\n <slot\n name=\"dropdownList\"\n :close=\"close\"\n />\n </template>\n </dt-dropdown>\n\n <split-button-omega\n v-else\n v-bind=\"omegaButtonProps\"\n @click=\"$emit('omega-clicked')\"\n >\n <template #icon=\"{ size: iconSize }\">\n <!-- @slot Omega (right) button icon slot -->\n <slot\n name=\"omegaIcon\"\n :size=\"iconSize\"\n />\n </template>\n </split-button-omega>\n </slot>\n </span>\n</template>\n\n<script>\nimport {\n BUTTON_IMPORTANCE_MODIFIERS,\n BUTTON_KIND_MODIFIERS,\n BUTTON_SIZE_MODIFIERS,\n ICON_POSITION_MODIFIERS,\n} from '@/components/button';\nimport SplitButtonAlpha from './split_button-alpha.vue';\nimport SplitButtonOmega from './split_button-omega.vue';\nimport { DtDropdown } from '@/components/dropdown';\nimport { hasSlotContent } from '@/common/utils';\n\nexport default {\n name: 'DtSplitButton',\n\n components: {\n SplitButtonOmega,\n DtDropdown,\n SplitButtonAlpha,\n },\n\n inheritAttrs: false,\n\n props: {\n /**\n * Determines whether the alpha button should have active styling\n * @values true, false\n */\n alphaActive: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Descriptive label for the alpha button\n */\n alphaAriaLabel: {\n type: String,\n default: null,\n },\n\n /**\n * The position of the icon slot within the alpha button.\n * @values left, right, top, bottom\n */\n alphaIconPosition: {\n type: String,\n default: 'left',\n validator: (position) => Object.keys(ICON_POSITION_MODIFIERS).includes(position),\n },\n\n /**\n * Used to customize the alpha label container\n */\n alphaLabelClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Whether the alpha button should display a loading animation or not.\n * @values true, false\n */\n alphaLoading: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Text shown in tooltip when you hover the alpha button,\n * required if no content is passed to default slot\n */\n alphaTooltipText: {\n type: String,\n default: undefined,\n },\n\n /**\n * Determines whether a screenreader reads live updates of\n * the button content to the user while the button\n * is in focus.\n * @values true, false\n */\n assertiveOnFocus: {\n type: Boolean,\n default: false,\n },\n\n /**\n * HTML button disabled attribute\n * <a class=\"d-link\" href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#disabled\" target=\"_blank\">\n * (Reference)\n * </a>\n * @values true, false\n */\n disabled: {\n type: Boolean,\n default: false,\n },\n\n /**\n * The direction the dropdown displays relative to the anchor.\n * @values top, top-start, top-end, right, right-start, right-end, left, left-start, left-end, bottom, bottom-start, bottom-end, auto, auto-start, auto-end\n */\n dropdownPlacement: {\n type: String,\n default: 'bottom-end',\n },\n\n /**\n * The fill and outline of the button associated with its visual importance.\n * @values clear, outlined, primary\n */\n importance: {\n type: String,\n default: 'primary',\n validator: (i) => Object.keys(BUTTON_IMPORTANCE_MODIFIERS).includes(i),\n },\n\n /**\n * The color of the button.\n * @values default, muted, danger, inverted\n */\n kind: {\n type: String,\n default: 'default',\n validator: (k) => Object.keys(BUTTON_KIND_MODIFIERS).includes(k),\n },\n\n /**\n * Determines whether the omega button should have active styling\n * @values true, false\n */\n omegaActive: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Descriptive label for the omega button\n */\n omegaAriaLabel: {\n type: String,\n default: null,\n },\n\n /**\n * Element ID, useful in case you need to reference the button\n * as an external anchor for popover.\n */\n omegaId: {\n type: String,\n default: undefined,\n },\n\n /**\n * Text shown in tooltip when you hover the omega button,\n * required as it is an icon only button\n */\n omegaTooltipText: {\n type: String,\n default: undefined,\n },\n\n /**\n * The size of the button.\n * @values xs, sm, md, lg, xl\n */\n size: {\n type: String,\n default: 'md',\n validator: (s) => Object.keys(BUTTON_SIZE_MODIFIERS).includes(s),\n },\n\n /**\n * Button width, accepts\n * <a class=\"d-link\" href=\"https://developer.mozilla.org/en-US/docs/Web/CSS/width\" target=\"_blank\">\n * CSS width attribute\n * </a>\n * values\n */\n width: {\n type: String,\n default: null,\n },\n },\n\n emits: [\n /**\n * Native alpha button click event\n *\n * @event click\n * @type {PointerEvent | KeyboardEvent}\n */\n 'alpha-clicked',\n\n /**\n * Native omega button click event\n *\n * @event click\n * @type {PointerEvent | KeyboardEvent}\n */\n 'omega-clicked',\n ],\n\n data () {\n return {\n isDropdownOpen: false,\n };\n },\n\n computed: {\n alphaButtonProps () {\n return {\n active: this.alphaActive,\n ariaLabel: this.alphaAriaLabel,\n assertiveOnFocus: this.assertiveOnFocus,\n disabled: this.disabled,\n iconPosition: this.alphaIconPosition,\n labelClass: this.alphaLabelClass,\n loading: this.alphaLoading,\n importance: this.importance,\n kind: this.kind,\n size: this.size,\n tooltipText: this.alphaTooltipText,\n class: this.$attrs.class,\n };\n },\n\n omegaButtonProps () {\n return {\n id: this.omegaId,\n active: this.omegaActive,\n ariaLabel: this.omegaAriaLabel,\n disabled: this.disabled,\n importance: this.importance,\n kind: this.kind,\n size: this.size,\n tooltipText: this.omegaTooltipText,\n class: this.$attrs.class,\n };\n },\n },\n\n created () {\n this.validateProps();\n },\n\n updated () {\n this.validateProps();\n },\n\n methods: {\n validateProps () {\n this.validateAlphaButtonProps();\n this.validateOmegaButtonProps();\n },\n\n validateAlphaButtonProps () {\n if (hasSlotContent(this.$slots.default)) return;\n\n if (hasSlotContent(this.$slots.alphaIcon) && !this.alphaTooltipText) {\n console.warn('alpha-tooltip-text prop must be set if alpha button has an icon only');\n }\n },\n\n validateOmegaButtonProps () {\n if (hasSlotContent(this.$slots.omega)) return;\n\n if (!this.omegaTooltipText) {\n console.warn('omega-tooltip-text prop is required as it is an icon-only button');\n }\n },\n },\n};\n</script>\n"],"names":["SplitButtonOmega","DtDropdown","SplitButtonAlpha","ICON_POSITION_MODIFIERS","BUTTON_IMPORTANCE_MODIFIERS","BUTTON_KIND_MODIFIERS","BUTTON_SIZE_MODIFIERS","hasSlotContent","_createElementBlock","_normalizeStyle","_createVNode","_mergeProps","_withCtx","_renderSlot","_createBlock","_openBlock"],"mappings":";;;;;;;;AAkFA,MAAK,YAAU;AAAA,EACb,MAAM;AAAA,EAEN,YAAY;AAAA,IACV,kBAAAA;AAAAA,gBACAC;AAAAA,IACA,kBAAAC;AAAAA,EACD;AAAA,EAED,cAAc;AAAA,EAEd,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA,IAKD,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;A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AA,MAAA,OAAA,CAAA,IAAA,UAAQ,MAAA,iBAAiB;AAAA;QAEvB,QAAMF,IAAAA,QACf,CADiB,UAAK;AAAA,UACtBF,IAAA,YAYqB,+BAZrBC,eAYqB,EAXN,GAAA,UAAU,SAAgB,oBAAA;AAAA,YACtC,QAAQ,MAAc;AAAA,YACtB,+CAAO,KAAK,MAAA,eAAA;AAAA;YAEF,MAAIC,IAAAA,QAEb,CAGE,EAAA,MALqB,SAAQ,MAAA;AAAA,cAE/BC,IAGE,WAAA,KAAA,QAAA,aAAA,EADC,MAAM,UAAQ;AAAA;YAvC/B,GAAA;AAAA;;QA4CmB,MAAID,IAAA,QAEb,CAGE,EALe,YAAK;AAAA,UAEtBC,IAGE,WAAA,KAAA,QAAA,gBAAA,EADC,OAAY;AAAA;QAhDzB,GAAA;AAAA,+BAqDME,cAAA,GAAAD,gBAYqB,+BAZrBH,IAAA,WAYqB,EAjE3B,KAAA,KAuDgB,SAAgB,kBAAA;AAAA,QACvB,+CAAO,KAAK,MAAA,eAAA;AAAA;QAEF,MAAIC,IAAAA,QAEb,CAGE,EAAA,MALqB,SAAQ,MAAA;AAAA,UAE/BC,IAGE,WAAA,KAAA,QAAA,aAAA,EADC,MAAM,UAAQ;AAAA;QA9D3B,GAAA;AAAA;;;;;;"}
|
|
1
|
+
{"version":3,"file":"split_button.vue.cjs","sources":["../../../components/split_button/split_button.vue"],"sourcesContent":["<template>\n <span\n data-qa=\"dt-split-button\"\n class=\"d-split-btn\"\n :style=\"{ width }\"\n >\n <split-button-alpha\n v-bind=\"alphaButtonProps\"\n ref=\"alphaButton\"\n @click=\"$emit('alpha-clicked')\"\n >\n <template #icon=\"{ size: iconSize }\">\n <!-- @slot Alpha (left) button icon slot -->\n <slot\n name=\"alphaIcon\"\n :size=\"iconSize\"\n />\n </template>\n <!-- @slot Default content slot -->\n <slot name=\"default\" />\n </split-button-alpha>\n <!-- @slot Omega (right) content slot, overrides omega button styling and functionality completely -->\n <slot name=\"omega\">\n <dt-dropdown\n v-if=\"$slots.dropdownList\"\n :placement=\"dropdownPlacement\"\n @click=\"isDropdownOpen = true\"\n @opened=\"open => isDropdownOpen = open\"\n >\n <template #anchor=\"attrs\">\n <split-button-omega\n v-bind=\"{ ...attrs, ...omegaButtonProps }\"\n :active=\"isDropdownOpen\"\n @click=\"$emit('omega-clicked')\"\n >\n <template #icon=\"{ size: iconSize }\">\n <!-- @slot Omega (right) button icon slot -->\n <slot\n name=\"omegaIcon\"\n :size=\"iconSize\"\n />\n </template>\n </split-button-omega>\n </template>\n <template #list=\"{ close }\">\n <!-- @slot Built-in dropdown content slot, use of dt-list-item is highly recommended here. -->\n <slot\n name=\"dropdownList\"\n :close=\"close\"\n />\n </template>\n </dt-dropdown>\n\n <split-button-omega\n v-else\n v-bind=\"omegaButtonProps\"\n @click=\"$emit('omega-clicked')\"\n >\n <template #icon=\"{ size: iconSize }\">\n <!-- @slot Omega (right) button icon slot -->\n <slot\n name=\"omegaIcon\"\n :size=\"iconSize\"\n />\n </template>\n </split-button-omega>\n </slot>\n </span>\n</template>\n\n<script>\nimport {\n BUTTON_IMPORTANCE_MODIFIERS,\n BUTTON_KIND_MODIFIERS,\n BUTTON_SIZE_MODIFIERS,\n ICON_POSITION_MODIFIERS,\n} from '@/components/button';\nimport SplitButtonAlpha from './split_button-alpha.vue';\nimport SplitButtonOmega from './split_button-omega.vue';\nimport { DtDropdown } from '@/components/dropdown';\nimport { hasSlotContent, warnIfUnmounted } from '@/common/utils';\n\nexport default {\n name: 'DtSplitButton',\n\n components: {\n SplitButtonOmega,\n DtDropdown,\n SplitButtonAlpha,\n },\n\n inheritAttrs: false,\n\n props: {\n /**\n * Determines whether the alpha button should have active styling\n * @values true, false\n */\n alphaActive: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Descriptive label for the alpha button\n */\n alphaAriaLabel: {\n type: String,\n default: null,\n },\n\n /**\n * The position of the icon slot within the alpha button.\n * @values left, right, top, bottom\n */\n alphaIconPosition: {\n type: String,\n default: 'left',\n validator: (position) => Object.keys(ICON_POSITION_MODIFIERS).includes(position),\n },\n\n /**\n * Used to customize the alpha label container\n */\n alphaLabelClass: {\n type: [String, Array, Object],\n default: '',\n },\n\n /**\n * Whether the alpha button should display a loading animation or not.\n * @values true, false\n */\n alphaLoading: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Text shown in tooltip when you hover the alpha button,\n * required if no content is passed to default slot\n */\n alphaTooltipText: {\n type: String,\n default: undefined,\n },\n\n /**\n * Determines whether a screenreader reads live updates of\n * the button content to the user while the button\n * is in focus.\n * @values true, false\n */\n assertiveOnFocus: {\n type: Boolean,\n default: false,\n },\n\n /**\n * HTML button disabled attribute\n * <a class=\"d-link\" href=\"https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#disabled\" target=\"_blank\">\n * (Reference)\n * </a>\n * @values true, false\n */\n disabled: {\n type: Boolean,\n default: false,\n },\n\n /**\n * The direction the dropdown displays relative to the anchor.\n * @values top, top-start, top-end, right, right-start, right-end, left, left-start, left-end, bottom, bottom-start, bottom-end, auto, auto-start, auto-end\n */\n dropdownPlacement: {\n type: String,\n default: 'bottom-end',\n },\n\n /**\n * The fill and outline of the button associated with its visual importance.\n * @values clear, outlined, primary\n */\n importance: {\n type: String,\n default: 'primary',\n validator: (i) => Object.keys(BUTTON_IMPORTANCE_MODIFIERS).includes(i),\n },\n\n /**\n * The color of the button.\n * @values default, muted, danger, inverted\n */\n kind: {\n type: String,\n default: 'default',\n validator: (k) => Object.keys(BUTTON_KIND_MODIFIERS).includes(k),\n },\n\n /**\n * Determines whether the omega button should have active styling\n * @values true, false\n */\n omegaActive: {\n type: Boolean,\n default: false,\n },\n\n /**\n * Descriptive label for the omega button\n */\n omegaAriaLabel: {\n type: String,\n default: null,\n },\n\n /**\n * Element ID, useful in case you need to reference the button\n * as an external anchor for popover.\n */\n omegaId: {\n type: String,\n default: undefined,\n },\n\n /**\n * Text shown in tooltip when you hover the omega button,\n * required as it is an icon only button\n */\n omegaTooltipText: {\n type: String,\n default: undefined,\n },\n\n /**\n * The size of the button.\n * @values xs, sm, md, lg, xl\n */\n size: {\n type: String,\n default: 'md',\n validator: (s) => Object.keys(BUTTON_SIZE_MODIFIERS).includes(s),\n },\n\n /**\n * Button width, accepts\n * <a class=\"d-link\" href=\"https://developer.mozilla.org/en-US/docs/Web/CSS/width\" target=\"_blank\">\n * CSS width attribute\n * </a>\n * values\n */\n width: {\n type: String,\n default: null,\n },\n },\n\n emits: [\n /**\n * Native alpha button click event\n *\n * @event click\n * @type {PointerEvent | KeyboardEvent}\n */\n 'alpha-clicked',\n\n /**\n * Native omega button click event\n *\n * @event click\n * @type {PointerEvent | KeyboardEvent}\n */\n 'omega-clicked',\n ],\n\n data () {\n return {\n isDropdownOpen: false,\n };\n },\n\n computed: {\n alphaButtonProps () {\n return {\n active: this.alphaActive,\n ariaLabel: this.alphaAriaLabel,\n assertiveOnFocus: this.assertiveOnFocus,\n disabled: this.disabled,\n iconPosition: this.alphaIconPosition,\n labelClass: this.alphaLabelClass,\n loading: this.alphaLoading,\n importance: this.importance,\n kind: this.kind,\n size: this.size,\n tooltipText: this.alphaTooltipText,\n class: this.$attrs.class,\n };\n },\n\n omegaButtonProps () {\n return {\n id: this.omegaId,\n active: this.omegaActive,\n ariaLabel: this.omegaAriaLabel,\n disabled: this.disabled,\n importance: this.importance,\n kind: this.kind,\n size: this.size,\n tooltipText: this.omegaTooltipText,\n class: this.$attrs.class,\n };\n },\n },\n\n created () {\n this.validateProps();\n },\n\n updated () {\n this.validateProps();\n },\n\n mounted () {\n warnIfUnmounted(this.$el, this.$options.name);\n },\n\n methods: {\n validateProps () {\n this.validateAlphaButtonProps();\n this.validateOmegaButtonProps();\n },\n\n validateAlphaButtonProps () {\n if (hasSlotContent(this.$slots.default)) return;\n\n if (hasSlotContent(this.$slots.alphaIcon) && !this.alphaTooltipText) {\n console.warn('alpha-tooltip-text prop must be set if alpha button has an icon only');\n }\n },\n\n validateOmegaButtonProps () {\n if (hasSlotContent(this.$slots.omega)) return;\n\n if (!this.omegaTooltipText) {\n console.warn('omega-tooltip-text prop is required as it is an icon-only button');\n }\n },\n },\n};\n</script>\n"],"names":["SplitButtonOmega","DtDropdown","SplitButtonAlpha","ICON_POSITION_MODIFIERS","BUTTON_IMPORTANCE_MODIFIERS","BUTTON_KIND_MODIFIERS","BUTTON_SIZE_MODIFIERS","warnIfUnmounted","hasSlotContent","_createElementBlock","_normalizeStyle","_createVNode","_mergeProps","_withCtx","_renderSlot","_createBlock","_openBlock"],"mappings":";;;;;;;;AAkFA,MAAK,YAAU;AAAA,EACb,MAAM;AAAA,EAEN,YAAY;AAAA,IACV,kBAAAA;AAAAA,gBACAC;AAAAA,IACA,kBAAAC;AAAAA,EACD;AAAA,EAED,cAAc;AAAA,EAEd,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA,IAKD,gBAAgB;AAAA,MACd,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA;AAAA,IAMD,mBAAmB;AAAA,MACjB,MAAM;AAAA,MACN,SAAS;AAAA,MACT,WAAW,CAAC,aAAa,OAAO,KAAKC,wCAAuB,EAAE,SAAS,QAAQ;AAAA,IAChF;AAAA;AAAA;AAAA;AAAA,IAKD,iBAAiB;AAAA,MACf,MAAM,CAAC,QAAQ,OAAO,MAAM;AAAA,MAC5B,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA;AAAA,IAMD,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA;AAAA,IAMD,kBAAkB;AAAA,MAChB,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQD,kBAAkB;AAAA,MAChB,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA;AAAA;AAAA;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AY;AAAA;QAhDzB,GAAA;AAAA,+BAqDME,cAAA,GAAAD,gBAYqB,+BAZrBH,IAAA,WAYqB,EAjE3B,KAAA,KAuDgB,SAAgB,kBAAA;AAAA,QACvB,+CAAO,KAAK,MAAA,eAAA;AAAA;QAEF,MAAIC,IAAAA,QAEb,CAGE,EAAA,MALqB,SAAQ,MAAA;AAAA,UAE/BC,IAGE,WAAA,KAAA,QAAA,aAAA,EADC,MAAM,UAAQ;AAAA;QA9D3B,GAAA;AAAA;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import SplitButtonAlpha from "./split_button-alpha.vue.js";
|
|
2
2
|
import SplitButtonOmega from "./split_button-omega.vue.js";
|
|
3
|
-
import { hasSlotContent } from "../../common/utils.js";
|
|
3
|
+
import { warnIfUnmounted, hasSlotContent } from "../../common/utils.js";
|
|
4
4
|
import { resolveComponent, openBlock, createElementBlock, normalizeStyle, createVNode, mergeProps, withCtx, renderSlot, createBlock } from "vue";
|
|
5
5
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
6
6
|
import DtDropdown from "../dropdown/dropdown.vue.js";
|
|
@@ -218,6 +218,9 @@ const _sfc_main = {
|
|
|
218
218
|
updated() {
|
|
219
219
|
this.validateProps();
|
|
220
220
|
},
|
|
221
|
+
mounted() {
|
|
222
|
+
warnIfUnmounted(this.$el, this.$options.name);
|
|
223
|
+
},
|
|
221
224
|
methods: {
|
|
222
225
|
validateProps() {
|
|
223
226
|
this.validateAlphaButtonProps();
|