CKEDITOR.plugins.lineutils.finder
A utility that traverses the DOM tree and discovers elements (relations) matching user-defined lookups.
Filtering
Properties
-
lookups : Object
CKEDITOR.plugins.lineutils.finder#lookups
A set of user-defined functions used by Finder to check if an element is a valid relation, belonging to relations. When the criterion is met, lookup returns a logical conjunction of
CKEDITOR.LINEUTILS_BEFORE
,CKEDITOR.LINEUTILS_AFTER
orCKEDITOR.LINEUTILS_INSIDE
.Lookups are passed along with Finder's definition.
lookups: { 'some lookup': function( el ) { if ( someCondition ) return CKEDITOR.LINEUTILS_BEFORE; }, ... }
-
Relations express elements in DOM that match user-defined lookups. Every relation has its own
type
that determines whether it refers to the space before, after or inside theelement
. This object stores relations found by traverseSearch or greedySearch, structured in the following way:relations: { // Unique identifier of the element. Number: { // Element of this relation. element: CKEDITOR.dom.element // Conjunction of CKEDITOR.LINEUTILS_BEFORE, CKEDITOR.LINEUTILS_AFTER and CKEDITOR.LINEUTILS_INSIDE. type: Number }, ... }
Methods
-
Creates a Finder class instance.
Parameters
editor : editor
Editor instance that the Finder belongs to.
def : Object
Finder's definition.
Returns
finder
-
getRange( location ) → range
CKEDITOR.plugins.lineutils.finder#getRange
Returns a range representing the relation, according to its element and type.
Parameters
location : Object
Location containing a unique identifier and type.
Returns
range
Range representing the relation.
-
greedySearch() → Object
CKEDITOR.plugins.lineutils.finder#greedySearch
Unlike traverseSearch, it collects all elements from editable's DOM tree and runs lookups for every one of them, collecting relations.
Returns
Object
-
pixelSearch( el, [ x ], [ y ] )
CKEDITOR.plugins.lineutils.finder#pixelSearch
Iterates vertically pixel-by-pixel within a given element starting from given coordinates, searching for elements in the neighborhood. Once an element is found it is processed by traverseSearch.
Parameters
el : element
Element which is the starting point.
[ x ] : Number
Horizontal mouse coordinate relative to the viewport.
[ y ] : Number
Vertical mouse coordinate relative to the viewport.
-
start( [ callback ] )
CKEDITOR.plugins.lineutils.finder#start
Initializes searching for elements with every mousemove event fired. To stop searching use stop.
Parameters
[ callback ] : Function
Function executed on every iteration.
-
stop()
CKEDITOR.plugins.lineutils.finder#stop
Stops observing mouse events attached by start.
-
store( el, type )
CKEDITOR.plugins.lineutils.finder#store
Stores given relation in a relations object. Processes the relation to normalize and avoid duplicates.
Parameters
el : element
Element of the relation.
type : Number
Relation, one of
CKEDITOR.LINEUTILS_AFTER
,CKEDITOR.LINEUTILS_BEFORE
,CKEDITOR.LINEUTILS_INSIDE
.
-
traverseSearch( el )
CKEDITOR.plugins.lineutils.finder#traverseSearch
Traverses the DOM tree towards root, checking all ancestors with lookup rules, avoiding duplicates. Stores positive relations in the relations object.
Parameters
el : element
Element which is the starting point.