Show:

SelectionRegion utility class which provides metadata about the selection. The metadata may be the start and end rectangles, caret region, etc. This class is not intended to be used standalone. Its functions will be merged into each editor instance, so the developer may use them directly via the editor, without making an instance of this class.

Constructor

CKEDITOR.plugins.ae_selectionregion

()

Methods

createSelectionFromPoint

(
  • x
  • y
)

Creates selection from two points in page coordinates.

Parameters:

  • x Number

    X point in page coordinates.

  • y Number

    Y point in page coordinates.

createSelectionFromRange

(
  • startX
  • startY
  • endX
  • endY
)

Creates selection from range. A range consists from two points in page coordinates.

Parameters:

  • startX Number

    X coordinate of the first point.

  • startY Number

    Y coordinate of the first point.

  • endX Number

    X coordinate of the second point.

  • endY Number

    Y coordinate of the second point.

getCaretRegion

() Object

Returns the region of the current position of the caret. The points are in page coordinates.

Returns:

Object:

Returns object with the following properties:

  • bottom
  • left
  • right
  • top

getClientRectsRegion

() Object

Returns object with data about the client rectangles of the selection, normalized across browses. All offsets below are in page coordinates.

Returns:

Object:

Returns object with the following data:

  • bottom - bottom offset of all client rectangles
  • left - left offset of all client rectangles
  • right - right offset of all client rectangles
  • top - top offset of all client rectangles
  • startRect - An Object, which contains the following information:
    • bottom - bottom offset
    • height - the height of the rectangle
    • left - left offset of the selection
    • right - right offset of the selection
    • top - top offset of the selection
    • width - the width of the rectangle
  • endRect - An Object, which contains the following information:
    • bottom - bottom offset
    • height - the height of the rectangle
    • left - left offset of the selection
    • right - right offset of the selection
    • top - top offset of the selection
    • width - the width of the rectangle

If there is no native selection, the objects will be filled with 0.

getSelectionData

() Object | Null

Returns data for the current selection.

Returns:

Object | Null:

Returns an object with the following data:

  • element - The currently selected element, if any
  • text - The selected text
  • region - The data, returned from getSelectionRegion

getSelectionDirection

() Number

Retrieves the direction of the selection. The direction is from top to bottom or from bottom to top. For IE < 9 it is not possible, so the direction for these browsers will be always CKEDITOR.SELECTION_TOP_TO_BOTTOM.

Returns:

Number:

Returns a number which represents selection direction. It might be one of these:

  • CKEDITOR.SELECTION_TOP_TO_BOTTOM;
  • CKEDITOR.SELECTION_BOTTOM_TO_TOP;

getSelectionRegion

() Object

Returns the region of the current selection.

Returns:

Object:

Returns object which is being returned from getClientRectsRegion with three more properties:

  • direction - the direction of the selection. Can be one of these:
    1. CKEDITOR.SELECTION_TOP_TO_BOTTOM
    2. CKEDITOR.SELECTION_BOTTOM_TO_TOP
  • height - The height of the selection region
  • width - The width of the selection region

init

(
  • editor
)
protected

Initializer lifecycle implementation for the SelectionRegion plugin.

Parameters:

  • editor Object

    The current CKEditor instance.

isSelectionEmpty

() Boolean

Returns true if the current selection is empty, false otherwise.

Returns:

Boolean:

Returns true if the current selection is empty, false otherwise.

load

(
  • names
  • callback
  • [scope]
)
static

Overrides CKEDITOR.plugins.load method so we can extend the lifecycle methods of the loaded plugins to add some metainformation about the plugin being processed

Parameters:

  • names String/Array

    The name of the resource to load. It may be a string with a single resource name, or an array with several names.

  • callback Function

    A function to be called when all resources are loaded. The callback will receive an array containing all loaded names.

  • [scope] Object optional

    The scope object to be used for the callback call.

wrapPluginLifecycle

(
  • plugin
)
private

Wraps each of the plugin lifecycle methods in a closure that will set up the editor.processingPlugin variable so it can be globally accessed exposing the plugin being processed and the lifecycle phase in which it is happening

Parameters:

  • plugin Object

    The plugin to wrap lifecycle methods