autoformat/inlineautoformatediting
@ckeditor/ckeditor5-autoformat/src/inlineautoformatediting
The inline autoformatting engine. It allows to format various inline patterns. For example,
it can be configured to make "foo" bold when typed **foo**
(the **
markers will be removed).
The autoformatting operation is integrated with the undo manager, so the autoformatting step can be undone if the user's intention was not to format the text.
See the inlineAutoformatEditing
documentation
to learn how to create custom inline autoformatters. You can also use
the Autoformat
feature which enables a set of default autoformatters
(lists, headings, bold and italic).
Filtering
Functions
-
inlineAutoformatEditing( editor, plugin, testRegexpOrCallback, formatCallback )
Enables autoformatting mechanism for a given
Editor
.It formats the matched text by applying the given model attribute or by running the provided formatting callback. On every data change in the model document the autoformatting engine checks the text on the left of the selection and executes the provided action if the text matches given criteria (regular expression or callback).
Parameters
editor : Editor
The editor instance.
plugin : Autoformat
The autoformat plugin instance.
testRegexpOrCallback : function | RegExp
The regular expression or callback to execute on text. Provided regular expression must have three capture groups. The first and the third capture group should match opening and closing delimiters. The second capture group should match the text to format.
When a function is provided instead of the regular expression, it will be executed with the text to match as a parameter. The function should return proper "ranges" to delete and format.
formatCallback : function
A callback to apply actual formatting. It should return
false
if changes should not be applied (e.g. if a command is disabled).
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.