SCEditor Documentation

RangeHelper

RangeHelper

new RangeHelper(win, d)

Range helper

Parameters:
Name Type Description
win    
d    

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 80


Methods

clear()

Removes any current selection

Since: - 1.4.6|

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 765

cloneSelected() → {Range}

Clones the selected Range

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 240

Returns:

Type Range

compare(rngA, rngB) → {boolean}

Compares two ranges.

If rangeB is undefined it will be set to the current selected range

Parameters:
Name Type Argument Description
rngA Range    
rngB Range optional  

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 740

Returns:

Type boolean

getFirstBlockParent() → {HTMLElement}

Gets the first block level parent of the selected contents of the range.

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 352

Returns:

Type HTMLElement

getFirstBlockParent^2(n, node) → {HTMLElement}

Gets the first block level parent of the selected contents of the range.

Parameters:
Name Type Argument Description
n Node optional The element to get the first block level parent from
node      

Since: - 1.4.1|

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 361

Returns:

Type HTMLElement

getMarker(id) → {Node}

Gets the marker with the specified ID

Parameters:
Name Type Description
id string  

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 462

Returns:

Type Node

hasSelection() → {boolean}

Gets if there is currently a selection

Since: - 1.4.4|

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 295

Returns:

Type boolean

insertHTML(html, endHTML)

Inserts HTML into the current range replacing any selected text.

If endHTML is specified the selected contents will be put between html and endHTML. If there is nothing selected html and endHTML are just concatenate together.

Parameters:
Name Type Argument Description
html string    
endHTML string optional  

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 96

Returns:

False on fail

insertMarkers()

Inserts start/end markers for the current selection which can be used by restoreRange to re-select the range.

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 435

insertNode(node, endNode) → {false|undefined}

The same as insertHTML except with DOM nodes instead

Warning: the nodes must belong to the document they are being inserted into. Some browsers will throw exceptions if they don’t.

Returns boolean false on fail

Parameters:
Name Type Description
node Node  
endNode Node  

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 201

Returns:

Type false|undefined

insertNodeAt(start, node)

Inserts a node at either the start or end of the current selection

Parameters:
Name Type Description
start Bool  
node Node  

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 388

parentNode() → {HTMLElement}

Gets the parent node of the selected contents in the range

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 335

Returns:

Type HTMLElement

removeMarker(id)

Removes the marker with the specified ID

Parameters:
Name Type Description
id string  

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 476

removeMarkers()

Removes the start/end markers

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 493

replaceKeyword(keywords, includeAfter, requireWhitespace, keypressChar) → {boolean}

Replaces keywords with values based on the current caret position

Assumes that the keywords array is sorted shortest to longest

Parameters:

|Name|Type|Description| |—-|—-|———–| |keywords|Array.<string, string, RegExp>|| |includeAfter|boolean|If to include the text after the current caret position or just text before| |requireWhitespace|boolean|If the key must be surrounded by whitespace| |keypressChar|string|If this is being called from a keypress event, this should be set to the pressed character|

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 646

Returns:

Type boolean

restoreRange()

Restores the last range saved by saveRange() or insertMarkers()

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 564

saveRage()

Saves the current range location. Alias of insertMarkers()

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 506

selectedHtml() → {string}

Gets the currently selected HTML

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 311

Returns:

Type string

selectedRange() → {Range}

Gets the selected Range

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 257

Returns:

Type Range

selectOuterText(left, right)

Selects the text left and right of the current selection

Parameters:
Name Type Description
left number  
right number  

Since: - 1.4.3|

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 594

selectOuterText(before, length) → {string}

Gets the text left or right of the current selection

Parameters:
Name Type Description
before boolean  
length number  

Since: - 1.4.3|

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 623

Returns:

Type string

selectRange(range)

Select the specified range

Parameters:
Name Type Description
range Range  

Source: out/C:/Users/John/repos/SCEditor/src/lib/RangeHelper.js, line 518