Selection
This module provides several helpful methods working with browser selection.
findParentTag — looks ahead from selection and finds passed tag with class name
expandToTag — expands selection to the passed tag
save – saves selection for later restoring
restore – restores previously saved selection
setFakeBackground – imitates real selection by painting text's background blue
removeFakeBackground – removes blue selection imitation
Finds parent tag with passed class name
String | tag's name that will be found |
String | tag's class name must match this argument |
?HTMLElement
|
found HTML element or null if not found |
Wraps current selection with passed tag
HTMLElement
|
HTML element that will wrap the selection |
Method does not return anything
Allows to save selection to be able to temporally move focus away and restore it later. Might be useful for creating inline tools. To keep the appearance of the selection while it is saved, use with setFakeBackground()
.
None
void
Restores previously saved selection
None
void
Imitates the real selection by creating a blue background behind the text. This can be useful for creating inline tools, as it allows the selection to persist when the focus moves from the text to the tool's controls.
None
void
Removes blue background behind the text that imitates selection
None
void