diff --git a/packages/ckeditor5-editor-balloon/src/ballooneditorui.ts b/packages/ckeditor5-editor-balloon/src/ballooneditorui.ts index 03b74c57e9e..f34f456b430 100644 --- a/packages/ckeditor5-editor-balloon/src/ballooneditorui.ts +++ b/packages/ckeditor5-editor-balloon/src/ballooneditorui.ts @@ -117,7 +117,9 @@ export default class BalloonEditorUI extends EditorUI { placeholderText = typeof placeholder === 'string' ? placeholder : placeholder[ editingRoot.rootName ]; } - editingRoot.placeholder = placeholderText; + if ( placeholderText ) { + editingRoot.placeholder = placeholderText; + } enablePlaceholder( { view: editingView, diff --git a/packages/ckeditor5-editor-decoupled/src/decouplededitorui.ts b/packages/ckeditor5-editor-decoupled/src/decouplededitorui.ts index 2fef9903de5..f2ce48219c1 100644 --- a/packages/ckeditor5-editor-decoupled/src/decouplededitorui.ts +++ b/packages/ckeditor5-editor-decoupled/src/decouplededitorui.ts @@ -125,7 +125,9 @@ export default class DecoupledEditorUI extends EditorUI { placeholderText = typeof placeholder === 'string' ? placeholder : placeholder[ editingRoot.rootName ]; } - editingRoot.placeholder = placeholderText; + if ( placeholderText ) { + editingRoot.placeholder = placeholderText; + } enablePlaceholder( { view: editingView, diff --git a/packages/ckeditor5-editor-inline/src/inlineeditorui.ts b/packages/ckeditor5-editor-inline/src/inlineeditorui.ts index b9cf3eb5510..774c8d3c4be 100644 --- a/packages/ckeditor5-editor-inline/src/inlineeditorui.ts +++ b/packages/ckeditor5-editor-inline/src/inlineeditorui.ts @@ -160,7 +160,9 @@ export default class InlineEditorUI extends EditorUI { placeholderText = typeof placeholder === 'string' ? placeholder : placeholder[ editingRoot.rootName ]; } - editingRoot.placeholder = placeholderText; + if ( placeholderText ) { + editingRoot.placeholder = placeholderText; + } if ( placeholderText ) { enablePlaceholder( { diff --git a/packages/ckeditor5-editor-multi-root/src/multirooteditorui.ts b/packages/ckeditor5-editor-multi-root/src/multirooteditorui.ts index c41af0254b5..1cd0e30241d 100644 --- a/packages/ckeditor5-editor-multi-root/src/multirooteditorui.ts +++ b/packages/ckeditor5-editor-multi-root/src/multirooteditorui.ts @@ -207,7 +207,9 @@ export default class MultiRootEditorUI extends EditorUI { const editingView = this.editor.editing.view; const editingRoot = editingView.document.getRoot( editable.name! )!; - editingRoot.placeholder = placeholder; + if ( placeholder ) { + editingRoot.placeholder = placeholder; + } enablePlaceholder( { view: editingView, diff --git a/packages/ckeditor5-engine/src/view/editableelement.ts b/packages/ckeditor5-engine/src/view/editableelement.ts index 7499f35dc5c..282a9be7f10 100644 --- a/packages/ckeditor5-engine/src/view/editableelement.ts +++ b/packages/ckeditor5-engine/src/view/editableelement.ts @@ -43,7 +43,9 @@ export default class EditableElement extends ObservableMixin( ContainerElement ) declare public isFocused: boolean; /** - * Placeholder of current editable element. + * Placeholder of editable element. Could be updated. + * + * editor.editing.view.document.getRoot( 'main' ).placeholder = 'New placeholder'; * * @observable */ diff --git a/packages/ckeditor5-engine/src/view/placeholder.ts b/packages/ckeditor5-engine/src/view/placeholder.ts index ec41487b6df..6f1c657d7e3 100644 --- a/packages/ckeditor5-engine/src/view/placeholder.ts +++ b/packages/ckeditor5-engine/src/view/placeholder.ts @@ -31,7 +31,6 @@ const documentPlaceholders = new WeakMap { - // Store information about the element placeholder under its document. - documentPlaceholders.get( doc )!.set( element, { - text, - isDirectHost, - keepOnFocus, - hostElement: isDirectHost ? element : null - } ); - - // Update the placeholders right away. - view.change( writer => updateDocumentPlaceholders( doc, writer ) ); + setPlaceholder( text ); } ); } if ( element.placeholder ) { + setPlaceholder( element.placeholder ); + } + + function setPlaceholder( text: string ) { + // Store information about the element placeholder under its document. documentPlaceholders.get( doc )!.set( element, { - text: element.placeholder, + text, isDirectHost, keepOnFocus, hostElement: isDirectHost ? element : null