SCEditor
- auto-gen TOC: {:toc}# Class: SCEditor
SCEditor
new SCEditor(original, userOptions)
SCEditor - A lightweight WYSIWYG editor
Parameters:
Name | Type | Description |
---|---|---|
original |
HTMLTextAreaElement | The textarea to be converted |
userOptions |
object |
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 53
Members
commands
All the commands supported by the editor
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 316
events
All the events supported by the editor
The supported events are:
- keyup
- keydown
- Keypress
- blur
- focus
- nodechanged - When the current node containing the selection changes in WYSIWYG mode
- contextmenu
- selectionchanged
- valuechanged
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 324
opts
Options for this editor instance
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 301
<_inner_> format
Editor format like BBCode or HTML
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 73
<_inner_> isComposing :boolean
If the user is currently composing text via IME
Type:
*boolean*
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 144
<_inner_> valueChangedKeyUpTimer :number
Timer for valueChanged key handler
Type:
*number*
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 151
Methods
_(str, args) → {string}
Translates the string into the locale language.
Replaces any {0}, {1}, {2}, ect. with the params provided.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
str |
string | ||
args |
string | repeatable |
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1921
Returns:
Type string
blur() → {this}
Blurs the editors input area
Since: - 1.3.6|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1935
Returns:
Type this
css() → {string}
Gets the current WYSIWYG editors inline CSS
Since: - 1.4.3|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 2005
Returns:
Type string
css^2(css) → {this}
Sets inline CSS for the WYSIWYG editor
Parameters:
Name | Type | Description |
---|---|---|
css |
string |
Since: - 1.4.3|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 2014
Returns:
Type this
currentBlockNode() → {Node}
Gets the first block level node that contains the selection/caret in WYSIWYG mode.
Will be null in sourceMode or if there is no selection.
Since: - 1.4.4|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1769
Returns:
Type Node
currentNode() → {Node}
Gets the current node that contains the selection/caret in WYSIWYG mode.
Will be null in sourceMode or if there is no selection.
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1756
Returns:
Type Node
destroy()
Destroys the editor, removing all elements and event handlers.
Leaves only the original textarea.
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 963
dimensions() → {object}
Returns an object with the properties width and height which are the width and height of the editor in px.
Since: - 1.4.1|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 770
Returns:
Type object
dimensions^2(width, height) → {this}
Sets the width and/or height of the editor.
If width or height is not numeric it is ignored.
Parameters:
Name | Type | Description |
---|---|---|
width |
number | Width in px |
height |
number | Height in px |
Since: - 1.4.1|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 780
Returns:
Type this
dimensions^3(width, height, save) → {this}
Sets the width and/or height of the editor.
If width or height is not numeric it is ignored.
The save argument specifies if to save the new sizes. The saved sizes can be used for things like restoring from maximized state. This should normally be left as true.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
width |
number | Width in px | ||
height |
number | Height in px | ||
save |
boolean | optional | true | If to store the new sizes |
Since: - 1.4.1|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 793
Returns:
Type this
execCommand(command, param)
Executes a command on the WYSIWYG editor
Parameters:
Name | Type | Argument | Description | |
---|---|---|---|---|
command |
string | |||
param |
string | boolean | optional |
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1630
expandToContent()
Expands or shrinks the editors height to the height of it’s content
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 935
focus() → {this}
Focuses the editors input area
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1954
Returns:
Type this
getBody() → {HTMLElement}
Gets the WYSIWYG editor’s iFrame Body.
Since: - 1.4.3|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1416
Returns:
Type HTMLElement
getContentAreaContainer() → {HTMLElement}
Gets the WYSIWYG editors container area (whole iFrame).
Since: - 1.4.3|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1427
Returns:
Type HTMLElement
getEditorContainer() → {HTMLElement}
Gets the entire editor’s container.
Since: - 3.0.0|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1405
Returns:
Type HTMLElement
getRangeHelper() → {RangeHelper}
Gets the current instance of the rangeHelper class for the editor.
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1271
Returns:
Type RangeHelper
getWysiwygEditorValue(filter) → {string}
Gets the WYSIWYG editors HTML value.
If using a plugin that filters the Ht Ml like the BBCode plugin it will return the result of the filtering (BBCode) unless the filter param is set to false.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
filter |
boolean | optional | true |
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1368
Returns:
Type string
height() → {number}
Gets the height of the editor in px
Since: - 1.3.5|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 839
Returns:
Type number
height^2(height) → {this}
Sets the height of the editor
Parameters:
Name | Type | Description |
---|---|---|
height |
number | Height in px |
Since: - 1.3.5|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 848
Returns:
Type this
height^3(height, saveHeight) → {this}
Sets the height of the editor
The saveHeight specifies if to save the height.
The stored height can be used for things like restoring from maximized state.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
height |
number | Height in px | ||
saveHeight |
boolean | optional | true | If to store the height |
Since: - 1.4.1|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 858
Returns:
Type this
insert(start, end, filter, allowMixed) → {this}
Inserts HTML/BBCode into the editor
If end is supplied any selected text will be placed between start and end. If there is no selected text start and end will be concatenated together.
If the filter param is set to true, the HTML/BBCode will be passed through any plugin filters. If using the BBCode plugin this will convert any BBCode into HTML.
If the allowMixed param is set to true, HTML any will not be escaped
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
start |
string | |||
end |
string | optional | ||
filter |
boolean | optional | true | |
allowMixed |
boolean | optional | false |
Since: - 1.4.3|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1310
Returns:
Type this
insertText(text, endText)
Inserts text into the WYSIWYG or source editor depending on which mode the editor is in.
If endText is specified any selected text will be placed between text and endText. If no text is selected text and endText will just be concatenate together.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
text |
string | |||
endText |
string | optional |
Since: - 1.3.5|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1195
isInSourceMode() → {boolean}
If the editor is in source code mode
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1547
Returns:
Type boolean
isReadOnly() → {boolean}
Gets if the editor is read only
Since: - 3.0.0|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 700
Returns:
Type boolean
maximize() → {boolean}
Gets if the editor is maximised or not
Since: - 1.4.1|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 884
Returns:
Type boolean
maximize^2(maximize) → {this}
Sets if the editor is maximised or not
Parameters:
Name | Type | Description |
---|---|---|
maximize |
boolean | If to maximise the editor |
Since: - 1.4.1|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 893
Returns:
Type this
readOnly(readOnly)
Sets if the editor is read only
Parameters:
Name | Type | Description |
---|---|---|
readOnly |
boolean |
Since: - 1.3.5|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 711
setSourceEditorValue(value)
Sets the text editor value
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1518
setValue(value)
Sets the WYSIWYG HTML editor value. Should only be the HTML contained within the body tags
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1483
setWysiwygEditorValue(value)
Sets the WYSIWYG HTML editor value. Should only be the HTML contained within the body tags
Parameters:
Name | Type | Description |
---|---|---|
value |
string |
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1496
sourceEditorCaret(position) → {this}
Gets or sets the source editor caret position.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
position |
object | optional |
Since: - 1.4.5|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1282
Returns:
Type this
sourceEditorInsertText(text, endText)
Like wysiwygEditorInsertHtml but inserts text into the source mode editor instead.
If endText is specified any selected text will be placed between text and endText. If no text is selected text and endText will just be concatenate together.
The cursor will be placed after the text param. If endText is
specified the cursor will be placed before endText, so passing:
‘[b]’, ‘[/b]’
Would cause the cursor to be placed:
[b]Selected text | [/b] |
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
text |
string | |||
endText |
string | optional |
Since: - 1.4.0|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1220
toggleSourceMode()
Switches between the WYSIWYG and source modes
Since: - 1.4.0|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1560
updateOriginal()
Updates the textarea that the editor is replacing with the value currently inside the editor.
Since: - 1.4.0|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1533
val() → {string}
Gets the value of the editor.
If the editor is in WYSIWYG mode it will return the filtered HTML from it (converted to BBCode if using the BBCode plugin). It it’s in Source Mode it will return the unfiltered contents of the source editor (if using the BBCode plugin this will be BBCode again).
Since: - 1.3.5|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1438
Returns:
Type string
width() → {number}
Gets the width of the editor in pixels
Since: - 1.3.5|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 727
Returns:
Type number
width^2(width) → {this}
Sets the width of the editor
Parameters:
Name | Type | Description |
---|---|---|
width |
number | Width in pixels |
Since: - 1.3.5|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 736
Returns:
Type this
width^3(width, saveWidth) → {this}
Sets the width of the editor
The saveWidth specifies if to save the width. The stored width can be used for things like restoring from maximized state.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
width |
number | Width in pixels | ||
saveWidth |
boolean | optional | true | If to store the width |
Since: - 1.4.1|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 746
Returns:
Type this
wysiwygEditorInsertHtml(html, endHtml, overrideCodeBlocking)
Inserts HTML into WYSIWYG editor.
If endHtml is specified, any selected text will be placed between html and endHtml. If there is no selected text html and endHtml will just be concatenate together.
Parameters:
|Name|Type|Argument|Default|Description|
|—-|—-|——–|——-|———–|
|html
|string| |||
|endHtml
|string|optional |||
|overrideCodeBlocking
|boolean|optional |false|If to insert the html
into code tags, by
default code tags only
support text.|
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1119
wysiwygEditorInsertText(text, endText)
Like wysiwygEditorInsertHtml except it will convert any HTML into text before inserting it.
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
text |
string | |||
endText |
string | optional |
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 1178
<_inner_> currentStyledBlockNode() → {HTMLElement}
Gets the first styled block node that contains the cursor
Source: out/C:/Users/John/repos/SCEditor/src/lib/SCEditor.js, line 2278
Returns:
Type HTMLElement