@dialpad/dialtone 9.91.0 → 9.91.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/tokens/doc.json +23064 -23064
- package/dist/vue2/components/rich_text_editor/rich_text_editor.vue.cjs +2 -2
- 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 +2 -2
- package/dist/vue2/components/rich_text_editor/rich_text_editor.vue.js.map +1 -1
- package/dist/vue3/components/rich_text_editor/rich_text_editor.vue.cjs +2 -2
- 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 +2 -2
- package/dist/vue3/components/rich_text_editor/rich_text_editor.vue.js.map +1 -1
- package/package.json +3 -3
|
@@ -348,7 +348,7 @@ const _sfc_main = {
|
|
|
348
348
|
}
|
|
349
349
|
editor.commands.first(({ commands }) => [
|
|
350
350
|
() => commands.newlineInCode(),
|
|
351
|
-
() => commands.splitListItem("listItem"),
|
|
351
|
+
() => self.allowBulletList && commands.splitListItem("listItem"),
|
|
352
352
|
() => commands.createParagraphNear(),
|
|
353
353
|
() => commands.liftEmptyBlock(),
|
|
354
354
|
() => commands.splitBlock()
|
|
@@ -403,7 +403,7 @@ const _sfc_main = {
|
|
|
403
403
|
}));
|
|
404
404
|
}
|
|
405
405
|
if (this.allowInlineImages) {
|
|
406
|
-
extensions.push(Image);
|
|
406
|
+
extensions.push(Image.configure({ inline: true }));
|
|
407
407
|
}
|
|
408
408
|
if (this.additionalExtensions.length) {
|
|
409
409
|
extensions.push(...this.additionalExtensions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich_text_editor.vue.cjs","sources":["../../../components/rich_text_editor/rich_text_editor.vue"],"sourcesContent":["<!-- eslint-disable vue/no-restricted-class -->\n<template>\n <editor-content\n :editor=\"editor\"\n class=\"d-rich-text-editor\"\n data-qa=\"dt-rich-text-editor\"\n v-on=\"editorListeners\"\n />\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { Editor, EditorContent } from '@tiptap/vue-2';\nimport { Extension } from '@tiptap/core';\nimport Blockquote from '@tiptap/extension-blockquote';\nimport CodeBlock from '@tiptap/extension-code-block';\nimport Document from '@tiptap/extension-document';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Image from '@tiptap/extension-image';\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 value: {\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 * Whether the input allows inline images to be rendered.\n */\n allowInlineImages: {\n type: Boolean,\n default: false,\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:value',\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 editorListeners () {\n return {\n ...this.$listeners,\n input: () => {},\n focus: () => {},\n blur: () => {},\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, HardBreak];\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 const self = this;\n const ShiftEnter = Extension.create({\n addKeyboardShortcuts () {\n return {\n 'Shift-Enter': ({ editor }) => {\n if (self.allowLineBreaks) {\n return false;\n }\n editor.commands.first(({ commands }) => [\n () => commands.newlineInCode(),\n () => commands.splitListItem('listItem'),\n () => commands.createParagraphNear(),\n () => commands.liftEmptyBlock(),\n () => commands.splitBlock(),\n ]);\n return true;\n },\n Enter: () => {\n if (self.allowLineBreaks) {\n return false;\n }\n self.$emit('enter');\n return true;\n },\n };\n },\n });\n extensions.push(ShiftEnter);\n\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\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: 'd-rich-text-editor__code-block',\n },\n }));\n }\n\n if (this.allowInlineImages) {\n extensions.push(Image);\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 value (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.value, 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.value,\n editable: this.editable,\n extensions: this.extensions,\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n },\n\n // Moves the <br /> tags inside the previous closing tag to avoid\n // Prosemirror wrapping them within another </p> tag.\n transformPastedHTML (html) {\n return html.replace(/(<\\/\\w+>)((<br \\/>)+)/g, '$2$3$1');\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\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:value', 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({ blockSeparator: '\\n' });\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({\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n ...attributes,\n },\n },\n });\n },\n\n focusEditor () {\n this.editor.commands.focus();\n },\n },\n};\n</script>\n"],"names":["EditorContent","RICH_TEXT_EDITOR_AUTOFOCUS_TYPES","RICH_TEXT_EDITOR_OUTPUT_FORMATS","Extension","RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS","CustomLink","mentionSuggestion","MentionPlugin","channelSuggestion","ChannelPlugin","slashCommandSuggestion","SlashCommandPlugin","Emoji","warnIfUnmounted","Editor","emojiPattern"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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AACA;AAAA,QACA;AACA,aAAA,MAAA,SAAA,KAAA;AACA,aAAA,MAAA,gBAAA,KAAA;AAAA,MACA,CAAA;AAGA,WAAA,OAAA,GAAA,SAAA,CAAA,EAAA,MAAA,MAAA;AACA,aAAA,MAAA,SAAA,KAAA;AAAA,MACA,CAAA;AAGA,WAAA,OAAA,GAAA,QAAA,CAAA,EAAA,MAAA,MAAA;AACA,aAAA,MAAA,QAAA,KAAA;AAAA,MACA,CAAA;AAAA,IACA;AAAA,IAEA,YAAA;AACA,cAAA,KAAA,cAAA;AAAA,QACA,KAAA;AACA,iBAAA,KAAA,OAAA;QACA,KAAA;AACA,iBAAA,KAAA,OAAA;QACA,KAAA;AAAA,QACA;AACA,iBAAA,KAAA,OAAA,QAAA,EAAA,gBAAA,KAAA,CAAA;AAAA,MACA;AAAA,IACA;AAAA,IAEA,aAAA,WAAA,SAAA;;AACA,UAAA,OAAA,YAAA,WAAA;AACA,eAAA;AAAA,MACA;AACA,cAAA,eAAA,cAAA,mCAAA;AAAA,IACA;AAAA,IAEA,uBAAA,YAAA;AACA,WAAA,OAAA,WAAA;AAAA,QACA,aAAA;AAAA,UACA,YAAA;AAAA,YACA,GAAA,KAAA;AAAA,YACA,OAAA,KAAA;AAAA,YACA,GAAA;AAAA,UACA;AAAA,QACA;AAAA,MACA,CAAA;AAAA,IACA;AAAA,IAEA,cAAA;AACA,WAAA,OAAA,SAAA;IACA;AAAA,EACA;AACA;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"rich_text_editor.vue.cjs","sources":["../../../components/rich_text_editor/rich_text_editor.vue"],"sourcesContent":["<!-- eslint-disable vue/no-restricted-class -->\n<template>\n <editor-content\n :editor=\"editor\"\n class=\"d-rich-text-editor\"\n data-qa=\"dt-rich-text-editor\"\n v-on=\"editorListeners\"\n />\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { Editor, EditorContent } from '@tiptap/vue-2';\nimport { Extension } from '@tiptap/core';\nimport Blockquote from '@tiptap/extension-blockquote';\nimport CodeBlock from '@tiptap/extension-code-block';\nimport Document from '@tiptap/extension-document';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Image from '@tiptap/extension-image';\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 value: {\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 * Whether the input allows inline images to be rendered.\n */\n allowInlineImages: {\n type: Boolean,\n default: false,\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:value',\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 editorListeners () {\n return {\n ...this.$listeners,\n input: () => {},\n focus: () => {},\n blur: () => {},\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, HardBreak];\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 const self = this;\n const ShiftEnter = Extension.create({\n addKeyboardShortcuts () {\n return {\n 'Shift-Enter': ({ editor }) => {\n if (self.allowLineBreaks) {\n return false;\n }\n editor.commands.first(({ commands }) => [\n () => commands.newlineInCode(),\n () => self.allowBulletList && commands.splitListItem('listItem'),\n () => commands.createParagraphNear(),\n () => commands.liftEmptyBlock(),\n () => commands.splitBlock(),\n ]);\n return true;\n },\n Enter: () => {\n if (self.allowLineBreaks) {\n return false;\n }\n self.$emit('enter');\n return true;\n },\n };\n },\n });\n extensions.push(ShiftEnter);\n\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\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: 'd-rich-text-editor__code-block',\n },\n }));\n }\n\n if (this.allowInlineImages) {\n extensions.push(Image.configure({ inline: true }));\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 value (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.value, 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.value,\n editable: this.editable,\n extensions: this.extensions,\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n },\n\n // Moves the <br /> tags inside the previous closing tag to avoid\n // Prosemirror wrapping them within another </p> tag.\n transformPastedHTML (html) {\n return html.replace(/(<\\/\\w+>)((<br \\/>)+)/g, '$2$3$1');\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\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:value', 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({ blockSeparator: '\\n' });\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({\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n ...attributes,\n },\n },\n });\n },\n\n focusEditor () {\n this.editor.commands.focus();\n },\n },\n};\n</script>\n"],"names":["EditorContent","RICH_TEXT_EDITOR_AUTOFOCUS_TYPES","RICH_TEXT_EDITOR_OUTPUT_FORMATS","Extension","RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS","CustomLink","mentionSuggestion","MentionPlugin","channelSuggestion","ChannelPlugin","slashCommandSuggestion","SlashCommandPlugin","Emoji","warnIfUnmounted","Editor","emojiPattern"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAA,YAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA,eAAAA,KAAA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;A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A;AAGA,WAAA,OAAA,GAAA,SAAA,CAAA,EAAA,MAAA,MAAA;AACA,aAAA,MAAA,SAAA,KAAA;AAAA,MACA,CAAA;AAGA,WAAA,OAAA,GAAA,QAAA,CAAA,EAAA,MAAA,MAAA;AACA,aAAA,MAAA,QAAA,KAAA;AAAA,MACA,CAAA;AAAA,IACA;AAAA,IAEA,YAAA;AACA,cAAA,KAAA,cAAA;AAAA,QACA,KAAA;AACA,iBAAA,KAAA,OAAA;QACA,KAAA;AACA,iBAAA,KAAA,OAAA;QACA,KAAA;AAAA,QACA;AACA,iBAAA,KAAA,OAAA,QAAA,EAAA,gBAAA,KAAA,CAAA;AAAA,MACA;AAAA,IACA;AAAA,IAEA,aAAA,WAAA,SAAA;;AACA,UAAA,OAAA,YAAA,WAAA;AACA,eAAA;AAAA,MACA;AACA,cAAA,eAAA,cAAA,mCAAA;AAAA,IACA;AAAA,IAEA,uBAAA,YAAA;AACA,WAAA,OAAA,WAAA;AAAA,QACA,aAAA;AAAA,UACA,YAAA;AAAA,YACA,GAAA,KAAA;AAAA,YACA,OAAA,KAAA;AAAA,YACA,GAAA;AAAA,UACA;AAAA,QACA;AAAA,MACA,CAAA;AAAA,IACA;AAAA,IAEA,cAAA;AACA,WAAA,OAAA,SAAA;IACA;AAAA,EACA;AACA;;;;;;;;;;;;;"}
|
|
@@ -346,7 +346,7 @@ const _sfc_main = {
|
|
|
346
346
|
}
|
|
347
347
|
editor.commands.first(({ commands }) => [
|
|
348
348
|
() => commands.newlineInCode(),
|
|
349
|
-
() => commands.splitListItem("listItem"),
|
|
349
|
+
() => self.allowBulletList && commands.splitListItem("listItem"),
|
|
350
350
|
() => commands.createParagraphNear(),
|
|
351
351
|
() => commands.liftEmptyBlock(),
|
|
352
352
|
() => commands.splitBlock()
|
|
@@ -401,7 +401,7 @@ const _sfc_main = {
|
|
|
401
401
|
}));
|
|
402
402
|
}
|
|
403
403
|
if (this.allowInlineImages) {
|
|
404
|
-
extensions.push(Image);
|
|
404
|
+
extensions.push(Image.configure({ inline: true }));
|
|
405
405
|
}
|
|
406
406
|
if (this.additionalExtensions.length) {
|
|
407
407
|
extensions.push(...this.additionalExtensions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich_text_editor.vue.js","sources":["../../../components/rich_text_editor/rich_text_editor.vue"],"sourcesContent":["<!-- eslint-disable vue/no-restricted-class -->\n<template>\n <editor-content\n :editor=\"editor\"\n class=\"d-rich-text-editor\"\n data-qa=\"dt-rich-text-editor\"\n v-on=\"editorListeners\"\n />\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { Editor, EditorContent } from '@tiptap/vue-2';\nimport { Extension } from '@tiptap/core';\nimport Blockquote from '@tiptap/extension-blockquote';\nimport CodeBlock from '@tiptap/extension-code-block';\nimport Document from '@tiptap/extension-document';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Image from '@tiptap/extension-image';\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 value: {\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 * Whether the input allows inline images to be rendered.\n */\n allowInlineImages: {\n type: Boolean,\n default: false,\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:value',\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 editorListeners () {\n return {\n ...this.$listeners,\n input: () => {},\n focus: () => {},\n blur: () => {},\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, HardBreak];\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 const self = this;\n const ShiftEnter = Extension.create({\n addKeyboardShortcuts () {\n return {\n 'Shift-Enter': ({ editor }) => {\n if (self.allowLineBreaks) {\n return false;\n }\n editor.commands.first(({ commands }) => [\n () => commands.newlineInCode(),\n () => commands.splitListItem('listItem'),\n () => commands.createParagraphNear(),\n () => commands.liftEmptyBlock(),\n () => commands.splitBlock(),\n ]);\n return true;\n },\n Enter: () => {\n if (self.allowLineBreaks) {\n return false;\n }\n self.$emit('enter');\n return true;\n },\n };\n },\n });\n extensions.push(ShiftEnter);\n\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\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: 'd-rich-text-editor__code-block',\n },\n }));\n }\n\n if (this.allowInlineImages) {\n extensions.push(Image);\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 value (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.value, 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.value,\n editable: this.editable,\n extensions: this.extensions,\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n },\n\n // Moves the <br /> tags inside the previous closing tag to avoid\n // Prosemirror wrapping them within another </p> tag.\n transformPastedHTML (html) {\n return html.replace(/(<\\/\\w+>)((<br \\/>)+)/g, '$2$3$1');\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\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:value', 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({ blockSeparator: '\\n' });\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({\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n ...attributes,\n },\n },\n });\n },\n\n focusEditor () {\n this.editor.commands.focus();\n },\n },\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,MAAA,gBAAA,KAAA;AAAA,MACA,CAAA;AAGA,WAAA,OAAA,GAAA,SAAA,CAAA,EAAA,MAAA,MAAA;AACA,aAAA,MAAA,SAAA,KAAA;AAAA,MACA,CAAA;AAGA,WAAA,OAAA,GAAA,QAAA,CAAA,EAAA,MAAA,MAAA;AACA,aAAA,MAAA,QAAA,KAAA;AAAA,MACA,CAAA;AAAA,IACA;AAAA,IAEA,YAAA;AACA,cAAA,KAAA,cAAA;AAAA,QACA,KAAA;AACA,iBAAA,KAAA,OAAA;QACA,KAAA;AACA,iBAAA,KAAA,OAAA;QACA,KAAA;AAAA,QACA;AACA,iBAAA,KAAA,OAAA,QAAA,EAAA,gBAAA,KAAA,CAAA;AAAA,MACA;AAAA,IACA;AAAA,IAEA,aAAA,WAAA,SAAA;;AACA,UAAA,OAAA,YAAA,WAAA;AACA,eAAA;AAAA,MACA;AACA,cAAA,eAAA,cAAA,mCAAA;AAAA,IACA;AAAA,IAEA,uBAAA,YAAA;AACA,WAAA,OAAA,WAAA;AAAA,QACA,aAAA;AAAA,UACA,YAAA;AAAA,YACA,GAAA,KAAA;AAAA,YACA,OAAA,KAAA;AAAA,YACA,GAAA;AAAA,UACA;AAAA,QACA;AAAA,MACA,CAAA;AAAA,IACA;AAAA,IAEA,cAAA;AACA,WAAA,OAAA,SAAA;IACA;AAAA,EACA;AACA;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"rich_text_editor.vue.js","sources":["../../../components/rich_text_editor/rich_text_editor.vue"],"sourcesContent":["<!-- eslint-disable vue/no-restricted-class -->\n<template>\n <editor-content\n :editor=\"editor\"\n class=\"d-rich-text-editor\"\n data-qa=\"dt-rich-text-editor\"\n v-on=\"editorListeners\"\n />\n</template>\n\n<script>\n/* eslint-disable max-lines */\nimport { Editor, EditorContent } from '@tiptap/vue-2';\nimport { Extension } from '@tiptap/core';\nimport Blockquote from '@tiptap/extension-blockquote';\nimport CodeBlock from '@tiptap/extension-code-block';\nimport Document from '@tiptap/extension-document';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Bold from '@tiptap/extension-bold';\nimport BulletList from '@tiptap/extension-bullet-list';\nimport Image from '@tiptap/extension-image';\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 value: {\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 * Whether the input allows inline images to be rendered.\n */\n allowInlineImages: {\n type: Boolean,\n default: false,\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:value',\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 editorListeners () {\n return {\n ...this.$listeners,\n input: () => {},\n focus: () => {},\n blur: () => {},\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, HardBreak];\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 const self = this;\n const ShiftEnter = Extension.create({\n addKeyboardShortcuts () {\n return {\n 'Shift-Enter': ({ editor }) => {\n if (self.allowLineBreaks) {\n return false;\n }\n editor.commands.first(({ commands }) => [\n () => commands.newlineInCode(),\n () => self.allowBulletList && commands.splitListItem('listItem'),\n () => commands.createParagraphNear(),\n () => commands.liftEmptyBlock(),\n () => commands.splitBlock(),\n ]);\n return true;\n },\n Enter: () => {\n if (self.allowLineBreaks) {\n return false;\n }\n self.$emit('enter');\n return true;\n },\n };\n },\n });\n extensions.push(ShiftEnter);\n\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\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: 'd-rich-text-editor__code-block',\n },\n }));\n }\n\n if (this.allowInlineImages) {\n extensions.push(Image.configure({ inline: true }));\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 value (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.value, 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.value,\n editable: this.editable,\n extensions: this.extensions,\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n },\n\n // Moves the <br /> tags inside the previous closing tag to avoid\n // Prosemirror wrapping them within another </p> tag.\n transformPastedHTML (html) {\n return html.replace(/(<\\/\\w+>)((<br \\/>)+)/g, '$2$3$1');\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\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:value', 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({ blockSeparator: '\\n' });\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({\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n ...attributes,\n },\n },\n });\n },\n\n focusEditor () {\n this.editor.commands.focus();\n },\n },\n};\n</script>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAA,YAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAA;AAAA,IACA;AAAA,EACA;AAAA,EAEA,OAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAKA,OAAA;AAAA,MACA,MAAA,CAAA,QAAA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,UAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA,IAKA,eAAA;AAAA,MACA,MAAA;AAAA,MACA,SAAA;AAAA,IACA;AAAA;AAAA;AAAA;AAAA;AAAA,IAMA,iBAAA;AAAA,MACA,MAA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AA,CAAA;AAAA,MACA;AAAA,IACA;AAAA,IAEA,aAAA,WAAA,SAAA;;AACA,UAAA,OAAA,YAAA,WAAA;AACA,eAAA;AAAA,MACA;AACA,cAAA,eAAA,cAAA,mCAAA;AAAA,IACA;AAAA,IAEA,uBAAA,YAAA;AACA,WAAA,OAAA,WAAA;AAAA,QACA,aAAA;AAAA,UACA,YAAA;AAAA,YACA,GAAA,KAAA;AAAA,YACA,OAAA,KAAA;AAAA,YACA,GAAA;AAAA,UACA;AAAA,QACA;AAAA,MACA,CAAA;AAAA,IACA;AAAA,IAEA,cAAA;AACA,WAAA,OAAA,SAAA;IACA;AAAA,EACA;AACA;;;;;;;;;;;;"}
|
|
@@ -349,7 +349,7 @@ const _sfc_main = {
|
|
|
349
349
|
}
|
|
350
350
|
editor.commands.first(({ commands }) => [
|
|
351
351
|
() => commands.newlineInCode(),
|
|
352
|
-
() => commands.splitListItem("listItem"),
|
|
352
|
+
() => self.allowBulletList && commands.splitListItem("listItem"),
|
|
353
353
|
() => commands.createParagraphNear(),
|
|
354
354
|
() => commands.liftEmptyBlock(),
|
|
355
355
|
() => commands.splitBlock()
|
|
@@ -404,7 +404,7 @@ const _sfc_main = {
|
|
|
404
404
|
}));
|
|
405
405
|
}
|
|
406
406
|
if (this.allowInlineImages) {
|
|
407
|
-
extensions.push(Image);
|
|
407
|
+
extensions.push(Image.configure({ inline: true }));
|
|
408
408
|
}
|
|
409
409
|
if (this.additionalExtensions.length) {
|
|
410
410
|
extensions.push(...this.additionalExtensions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich_text_editor.vue.cjs","sources":["../../../components/rich_text_editor/rich_text_editor.vue"],"sourcesContent":["<!-- eslint-disable vue/no-restricted-class -->\n<template>\n <editor-content\n :editor=\"editor\"\n class=\"d-rich-text-editor\"\n data-qa=\"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 { Extension } from '@tiptap/core';\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 Image from '@tiptap/extension-image';\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 * Whether the input allows inline images to be rendered.\n */\n allowInlineImages: {\n type: Boolean,\n default: false,\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, HardBreak];\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 const self = this;\n const ShiftEnter = Extension.create({\n addKeyboardShortcuts () {\n return {\n 'Shift-Enter': ({ editor }) => {\n if (self.allowLineBreaks) {\n return false;\n }\n editor.commands.first(({ commands }) => [\n () => commands.newlineInCode(),\n () => commands.splitListItem('listItem'),\n () => commands.createParagraphNear(),\n () => commands.liftEmptyBlock(),\n () => commands.splitBlock(),\n ]);\n return true;\n },\n Enter: () => {\n if (self.allowLineBreaks) {\n return false;\n }\n self.$emit('enter');\n return true;\n },\n };\n },\n });\n extensions.push(ShiftEnter);\n\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\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: 'd-rich-text-editor__code-block',\n },\n }));\n }\n\n if (this.allowInlineImages) {\n extensions.push(Image);\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 // Moves the <br /> tags inside the previous closing tag to avoid\n // Prosemirror wrapping them within another </p> tag.\n transformPastedHTML (html) {\n return html.replace(/(<\\/\\w+>)((<br \\/>)+)/g, '$2$3$1');\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\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({ blockSeparator: '\\n' });\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({\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n ...attributes,\n },\n },\n });\n },\n\n focusEditor () {\n this.editor.commands.focus();\n },\n },\n};\n</script>\n"],"names":["EditorContent","RICH_TEXT_EDITOR_AUTOFOCUS_TYPES","RICH_TEXT_EDITOR_OUTPUT_FORMATS","Extension","RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS","CustomLink","mentionSuggestion","MentionPlugin","channelSuggestion","ChannelPlugin","slashCommandSuggestion","SlashCommandPlugin","Emoji","warnIfUnmounted","Editor","emojiPattern","_openBlock","_createBlock","_mergeProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,MAAK,YAAU;AAAA,EACb,MAAM;AAAA,EAEN,Y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3,"file":"rich_text_editor.vue.cjs","sources":["../../../components/rich_text_editor/rich_text_editor.vue"],"sourcesContent":["<!-- eslint-disable vue/no-restricted-class -->\n<template>\n <editor-content\n :editor=\"editor\"\n class=\"d-rich-text-editor\"\n data-qa=\"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 { Extension } from '@tiptap/core';\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 Image from '@tiptap/extension-image';\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 * Whether the input allows inline images to be rendered.\n */\n allowInlineImages: {\n type: Boolean,\n default: false,\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, HardBreak];\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 const self = this;\n const ShiftEnter = Extension.create({\n addKeyboardShortcuts () {\n return {\n 'Shift-Enter': ({ editor }) => {\n if (self.allowLineBreaks) {\n return false;\n }\n editor.commands.first(({ commands }) => [\n () => commands.newlineInCode(),\n () => self.allowBulletList && commands.splitListItem('listItem'),\n () => commands.createParagraphNear(),\n () => commands.liftEmptyBlock(),\n () => commands.splitBlock(),\n ]);\n return true;\n },\n Enter: () => {\n if (self.allowLineBreaks) {\n return false;\n }\n self.$emit('enter');\n return true;\n },\n };\n },\n });\n extensions.push(ShiftEnter);\n\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\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: 'd-rich-text-editor__code-block',\n },\n }));\n }\n\n if (this.allowInlineImages) {\n extensions.push(Image.configure({ inline: true }));\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 // Moves the <br /> tags inside the previous closing tag to avoid\n // Prosemirror wrapping them within another </p> tag.\n transformPastedHTML (html) {\n return html.replace(/(<\\/\\w+>)((<br \\/>)+)/g, '$2$3$1');\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\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({ blockSeparator: '\\n' });\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({\n editorProps: {\n attributes: {\n ...this.inputAttrs,\n class: this.inputClass,\n ...attributes,\n },\n },\n });\n },\n\n focusEditor () {\n this.editor.commands.focus();\n },\n },\n};\n</script>\n"],"names":["EditorContent","RICH_TEXT_EDITOR_AUTOFOCUS_TYPES","RICH_TEXT_EDITOR_OUTPUT_FORMATS","Extension","RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS","CustomLink","mentionSuggestion","MentionPlugin","channelSuggestion","ChannelPlugin","slashCommandSuggestion","SlashCommandPlugin","Emoji","warnIfUnmounted","Editor","emojiPattern","_openBlock","_createBlock","_mergeProps"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,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;AAAA;AAAA;AAAA,IAaD,WAAW;AAAA,MACT,MAAM,CAAC,SAAS,QAAQ,MAAM;AAAA,MAC9B,SAAS;AAAA,MACT,UAAW,WAAW;AACpB,YAAI,OAAO,cAAc,UAAU;AACjC,iBAAOC,2BAAgC,iCAAC,SAAS,SAAS;AAAA,QAC5D;AACA,eAAO;AAAA,MACR;AAAA,IACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAQD,cAAc;AAAA,MACZ,MAAM;AAAA,MACN,SAA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,YACZ,GAAG;AAAA,UACJ;AAAA,QACF;AAAA,MACH,CAAC;AAAA,IACF;AAAA,IAED,cAAe;AACb,WAAK,OAAO,SAAS;IACtB;AAAA,EACF;AACH;;;AAvoBE,SAAAC,cAAA,GAAAC,gBAKE,2BALFC,IAAAA,WAKE;AAAA,IAJC,QAAQ,MAAM;AAAA,IACf,OAAM;AAAA,IACN,WAAQ;AAAA,KACA,SAAK,KAAA,GAAA,MAAA,IAAA,CAAA,QAAA,CAAA;;;;"}
|
|
@@ -347,7 +347,7 @@ const _sfc_main = {
|
|
|
347
347
|
}
|
|
348
348
|
editor.commands.first(({ commands }) => [
|
|
349
349
|
() => commands.newlineInCode(),
|
|
350
|
-
() => commands.splitListItem("listItem"),
|
|
350
|
+
() => self.allowBulletList && commands.splitListItem("listItem"),
|
|
351
351
|
() => commands.createParagraphNear(),
|
|
352
352
|
() => commands.liftEmptyBlock(),
|
|
353
353
|
() => commands.splitBlock()
|
|
@@ -402,7 +402,7 @@ const _sfc_main = {
|
|
|
402
402
|
}));
|
|
403
403
|
}
|
|
404
404
|
if (this.allowInlineImages) {
|
|
405
|
-
extensions.push(Image);
|
|
405
|
+
extensions.push(Image.configure({ inline: true }));
|
|
406
406
|
}
|
|
407
407
|
if (this.additionalExtensions.length) {
|
|
408
408
|
extensions.push(...this.additionalExtensions);
|