engine/view/placeholder
@ckeditor/ckeditor5-engine/src/view/placeholder
Filtering
Functions
-
disablePlaceholder( view, element )
module:engine/view/placeholder~disablePlaceholder
Disables the placeholder functionality from a given element.
-
enablePlaceholder( [ options ] = { options.view, options.element, options.text, [options.isDirectHost], [options.keepOnFocus] } )
module:engine/view/placeholder~enablePlaceholder
A helper that enables a placeholder on the provided view element (also updates its visibility). The placeholder is a CSS pseudo–element (with a text content) attached to the element.
To change the placeholder text, simply call this method again with new options.
To disable the placeholder, use
disablePlaceholder()
helper.Parameters
[ options ] : Object
Configuration options of the placeholder.
Propertiesoptions.view : View
Editing view instance.
options.element : Element
Element that will gain a placeholder. See
options.isDirectHost
to learn more.options.text : String
Placeholder text.
[ options.isDirectHost ] : Boolean
If set
false
, the placeholder will not be enabled directly in the passedelement
but in one of its children (selected automatically, i.e. a first empty child element). Useful when attaching placeholders to elements that can host other elements (not just text), for instance, editable root elements.Defaults to
true
[ options.keepOnFocus ] : Boolean
If set
true
, the placeholder stay visible when the host element is focused.Defaults to
false
-
hidePlaceholder( writer, element ) → Boolean
module:engine/view/placeholder~hidePlaceholder
Hides a placeholder in the element by changing related attributes and CSS classes.
Note: This helper will not update the placeholder visibility nor manage the it in any way in the future. What it does is a one–time state change of an element. Use
enablePlaceholder()
anddisablePlaceholder()
for full placeholder functionality.Parameters
writer : DowncastWriter
element : Element
Returns
Boolean
true
, if any changes were made to theelement
.
-
needsPlaceholder( element, keepOnFocus ) → Boolean
module:engine/view/placeholder~needsPlaceholder
Checks if a placeholder should be displayed in the element.
Note: This helper will blindly check the possibility of showing a placeholder directly in the root editable element if one is passed, which may not be the expected result. If an element can host other elements (not just text), most likely one of its children should be checked instead because it will be the final host for the placeholder. Use
enablePlaceholder()
in that case or make sure the correct element is passed to the helper.Parameters
element : Element
Element that holds the placeholder.
keepOnFocus : Boolean
Focusing the element will keep the placeholder visible.
Returns
Boolean
-
showPlaceholder( writer, element ) → Boolean
module:engine/view/placeholder~showPlaceholder
Shows a placeholder in the provided element by changing related attributes and CSS classes.
Note: This helper will not update the placeholder visibility nor manage the it in any way in the future. What it does is a one–time state change of an element. Use
enablePlaceholder()
anddisablePlaceholder()
for full placeholder functionality.Note: This helper will blindly show the placeholder directly in the root editable element if one is passed, which could result in a visual clash if the editable element has some children (for instance, an empty paragraph). Use
enablePlaceholder()
in that case or make sure the correct element is passed to the helper.Parameters
writer : DowncastWriter
element : Element
Returns
Boolean
true
, if any changes were made to theelement
.
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.