• findOptimalInsertionRange( selection, model, place ) → Range

    Returns a model range which is optimal (in terms of UX) for inserting a widget block.

    For instance, if a selection is in the middle of a paragraph, the collapsed range before this paragraph will be returned so that it is not split. If the selection is at the end of a paragraph, the collapsed range after this paragraph will be returned.

    Note: If the selection is placed in an empty block, the range in that block will be returned. If that range is then passed to insertContent, the block will be fully replaced by the inserted widget block.

    Note: Use findOptimalInsertionRange instead of this function outside engine. This function is only exposed to be used by findOptimalInsertionRange() in the widget package and inside the engine package.


    selection : Selection | DocumentSelection

    The selection based on which the insertion position should be calculated.

    model : Model

    Model instance.

    place : 'auto' | 'before' | 'after'

    The place where to look for optimal insertion range. The default auto value will determine itself the best position for insertion. The before value will try to find a position before selection. The after value will try to find a position after selection.

    Defaults to 'auto'



    The optimal range.