MutationHandler (typing/utils)
@ckeditor/ckeditor5-typing/src/utils/injecttypingmutationshandling
Helper class for translating DOM mutations into model changes.
Filtering
Properties
-
editing : EditingController
module:typing/utils/injecttypingmutationshandling~MutationHandler#editing
readonly
The editing controller.
-
Editor instance for which mutations are handled.
Methods
-
constructor( editor )
module:typing/utils/injecttypingmutationshandling~MutationHandler#constructor
-
handle( mutations, viewSelection )
module:typing/utils/injecttypingmutationshandling~MutationHandler#handle
Handles given mutations.
Parameters
mutations : Array.<(MutatedText | MutatedChildren)>
viewSelection : Selection | null
-
_handleContainerChildrenMutations( mutations, viewSelection )
module:typing/utils/injecttypingmutationshandling~MutationHandler#_handleContainerChildrenMutations
private
Handles situations when container's children mutated during input. This can happen when the browser is trying to "fix" DOM in certain situations. For example, when the user starts to type in
<p><a href=""><i>Link{}</i></a></p>
, the browser might change the order of elements to<p><i><a href="">Link</a>x{}</i></p>
. A similar situation happens when the spell checker replaces a word wrapped with<strong>
with a word wrapped with a<b>
element.To handle such situations, the common DOM ancestor of all mutations is converted to the model representation and then compared with the current model to calculate the proper text change.
Note: Single text node insertion is handled in
_handleTextNodeInsertion
and text node mutation is handled in_handleTextMutation
).Parameters
mutations : Array.<(MutatedText | MutatedChildren)>
viewSelection : Selection | null
-
_handleTextMutation()
module:typing/utils/injecttypingmutationshandling~MutationHandler#_handleTextMutation
private
-
_handleTextNodeInsertion()
module:typing/utils/injecttypingmutationshandling~MutationHandler#_handleTextNodeInsertion
private
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.