Add Plugin Key to placeholder component. (#3652)

* Add Plugin Key to placeholder component.

Key added to fix error duplicate plugin when using `Placeholder` component.

* Add PluginKey import

---------

Co-authored-by: Dominik <6538827+bdbch@users.noreply.github.com>
This commit is contained in:
Ta'zirah Marwan 2023-02-19 03:33:33 +07:00 committed by GitHub
parent c8f8295146
commit 125caf4965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import { Editor, Extension } from '@tiptap/core' import { Editor, Extension } from '@tiptap/core'
import { Node as ProsemirrorNode } from '@tiptap/pm/model' import { Node as ProsemirrorNode } from '@tiptap/pm/model'
import { Plugin } from '@tiptap/pm/state' import { Plugin, PluginKey } from '@tiptap/pm/state'
import { Decoration, DecorationSet } from '@tiptap/pm/view' import { Decoration, DecorationSet } from '@tiptap/pm/view'
export interface PlaceholderOptions { export interface PlaceholderOptions {
@ -36,6 +36,7 @@ export const Placeholder = Extension.create<PlaceholderOptions>({
addProseMirrorPlugins() { addProseMirrorPlugins() {
return [ return [
new Plugin({ new Plugin({
key: new PluginKey('placeholder'),
props: { props: {
decorations: ({ doc, selection }) => { decorations: ({ doc, selection }) => {
const active = this.editor.isEditable || !this.options.showOnlyWhenEditable const active = this.editor.isEditable || !this.options.showOnlyWhenEditable