Class

MutationHandler (typing/utils)

@ckeditor/ckeditor5-typing/src/utils/injecttypingmutationshandling

class private

Helper class for translating DOM mutations into model changes.

Filtering

Properties

  • editing : EditingController

    readonly

    The editing controller.

  • editor : Editor

    readonly

    Editor instance for which mutations are handled.

Methods

  • constructor( editor )

    Creates an instance of the mutation handler.

    Parameters

    editor : Editor
  • handle( mutations, viewSelection )

    Handles given mutations.

    Parameters

    mutations : Array.<(MutatedText | MutatedChildren)>
    viewSelection : Selection | null
  • _handleContainerChildrenMutations( mutations, viewSelection )

    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()

    private

  • _handleTextNodeInsertion()

    private