CKEDITOR.plugins.lineutils.finder
A utility that traverses the DOM tree and discovers elements (relations) matching user-defined lookups.
Filtering
Properties
lookups : ObjectCKEDITOR.plugins.lineutils.finder#lookupsA 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_AFTERorCKEDITOR.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
typethat 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 : editorEditor instance that the Finder belongs to.
def : ObjectFinder's definition.
Returns
finder
getRange( location ) → rangeCKEDITOR.plugins.lineutils.finder#getRangeReturns a range representing the relation, according to its element and type.
Parameters
location : ObjectLocation containing a unique identifier and type.
Returns
rangeRange representing the relation.
greedySearch() → ObjectCKEDITOR.plugins.lineutils.finder#greedySearchUnlike 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#pixelSearchIterates 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 : elementElement which is the starting point.
[ x ] : NumberHorizontal mouse coordinate relative to the viewport.
[ y ] : NumberVertical mouse coordinate relative to the viewport.
start( [ callback ] )CKEDITOR.plugins.lineutils.finder#startInitializes searching for elements with every mousemove event fired. To stop searching use stop.
Parameters
[ callback ] : FunctionFunction executed on every iteration.
stop()CKEDITOR.plugins.lineutils.finder#stopStops observing mouse events attached by start.
store( el, type )CKEDITOR.plugins.lineutils.finder#storeStores given relation in a relations object. Processes the relation to normalize and avoid duplicates.
Parameters
el : elementElement of the relation.
type : NumberRelation, one of
CKEDITOR.LINEUTILS_AFTER,CKEDITOR.LINEUTILS_BEFORE,CKEDITOR.LINEUTILS_INSIDE.
traverseSearch( el )CKEDITOR.plugins.lineutils.finder#traverseSearchTraverses the DOM tree towards root, checking all ancestors with lookup rules, avoiding duplicates. Stores positive relations in the relations object.
Parameters
el : elementElement which is the starting point.