diff --git a/components/rich_text_editor/rich_text_editor.stories.js b/components/rich_text_editor/rich_text_editor.stories.js index 6aa60ae6a0..a6009d97a6 100644 --- a/components/rich_text_editor/rich_text_editor.stories.js +++ b/components/rich_text_editor/rich_text_editor.stories.js @@ -15,6 +15,7 @@ export const argsData = { outputFormat: 'text', autoFocus: false, link: true, + placeholder: 'Type here...', onBlur: action('blur'), onInput: action('input'), onFocus: action('focus'), diff --git a/components/rich_text_editor/rich_text_editor.vue b/components/rich_text_editor/rich_text_editor.vue index cdb7e02018..ed2cb29dac 100644 --- a/components/rich_text_editor/rich_text_editor.vue +++ b/components/rich_text_editor/rich_text_editor.vue @@ -9,6 +9,7 @@ import { Editor, EditorContent } from '@tiptap/vue-2'; import Document from '@tiptap/extension-document'; import Paragraph from '@tiptap/extension-paragraph'; +import Placeholder from '@tiptap/extension-placeholder'; import Text from '@tiptap/extension-text'; import Link from './extensions/link'; import { @@ -102,6 +103,14 @@ export default { type: [Boolean, Object], default: false, }, + + /** + * Placeholder text + */ + placeholder: { + type: String, + default: '', + }, }, emits: [ @@ -147,6 +156,10 @@ export default { if (this.link) { extensions.push(this.getExtension(Link, this.link)); } + // Enable placeholder text + extensions.push( + Placeholder.configure({ placeholder: this.placeholder }), + ); return extensions; }, @@ -283,3 +296,13 @@ export default { }, }; + + diff --git a/components/rich_text_editor/rich_text_editor_default.story.vue b/components/rich_text_editor/rich_text_editor_default.story.vue index 440a9ce1b2..59498e30b7 100644 --- a/components/rich_text_editor/rich_text_editor_default.story.vue +++ b/components/rich_text_editor/rich_text_editor_default.story.vue @@ -7,6 +7,7 @@ :output-format="outputFormat" :auto-focus="autoFocus" :link="link" + :placeholder="placeholder" @blur="onBlur" @input="onInput" @focus="onFocus" diff --git a/package-lock.json b/package-lock.json index a5a4891ebc..078f7462f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@linusborg/vue-simple-portal": "^0.1.5", "@tiptap/extension-document": "^2.0.2", "@tiptap/extension-paragraph": "^2.0.2", + "@tiptap/extension-placeholder": "^2.0.3", "@tiptap/extension-text": "^2.0.2", "@tiptap/pm": "^2.0.2", "@tiptap/vue-2": "^2.0.2", @@ -7438,6 +7439,19 @@ "@tiptap/core": "^2.0.0" } }, + "node_modules/@tiptap/extension-placeholder": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@tiptap/extension-placeholder/-/extension-placeholder-2.0.3.tgz", + "integrity": "sha512-Z42jo0termRAf0S0L8oxrts94IWX5waU4isS2CUw8xCUigYyCFslkhQXkWATO1qRbjNFLKN2C9qvCgGf4UeBrw==", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/ueberdosis" + }, + "peerDependencies": { + "@tiptap/core": "^2.0.0", + "@tiptap/pm": "^2.0.0" + } + }, "node_modules/@tiptap/extension-text": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-2.0.3.tgz", @@ -42940,6 +42954,12 @@ "integrity": "sha512-a+tKtmj4bU3GVCH1NE8VHWnhVexxX5boTVxsHIr4yGG3UoKo1c5AO7YMaeX2W5xB5iIA+BQqOPCDPEAx34dd2A==", "requires": {} }, + "@tiptap/extension-placeholder": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@tiptap/extension-placeholder/-/extension-placeholder-2.0.3.tgz", + "integrity": "sha512-Z42jo0termRAf0S0L8oxrts94IWX5waU4isS2CUw8xCUigYyCFslkhQXkWATO1qRbjNFLKN2C9qvCgGf4UeBrw==", + "requires": {} + }, "@tiptap/extension-text": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@tiptap/extension-text/-/extension-text-2.0.3.tgz", diff --git a/package.json b/package.json index c4887a7256..b5f1f4c773 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@linusborg/vue-simple-portal": "^0.1.5", "@tiptap/extension-document": "^2.0.2", "@tiptap/extension-paragraph": "^2.0.2", + "@tiptap/extension-placeholder": "^2.0.3", "@tiptap/extension-text": "^2.0.2", "@tiptap/pm": "^2.0.2", "@tiptap/vue-2": "^2.0.2",