placeholder function
Extension that enables a placeholder—a piece of example content to show when the editor is empty.
Example
EditorState.create(EditorStateConfig(
extensions: placeholder('Enter some text...'),
))
The content can be:
Implementation
Extension placeholder(Object content) {
final plugin = ViewPlugin.define<_PlaceholderPluginValue>(
(view) => _PlaceholderPluginValue(view, content),
ViewPluginSpec(
decorations: (v) => v.decorations,
),
);
// For string content, also add aria-placeholder attribute
if (content is String) {
return ExtensionList([
plugin.extension,
contentAttributes.of({'aria-placeholder': content}),
]);
}
return plugin.extension;
}