Mercurial Hosting > sceditor
comparison src/sceditor.js @ 36:21090996a131
clean up TokenizeToken
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 16 Aug 2022 13:50:36 -0600 |
parents | c23475f3f466 |
children | 0c4e4b5ef40d |
comparison
equal
deleted
inserted
replaced
35:cd02cd04bc9d | 36:21090996a131 |
---|---|
2905 * | 2905 * |
2906 * @param {string} signal | 2906 * @param {string} signal |
2907 * @param {...string} args | 2907 * @param {...string} args |
2908 * @function | 2908 * @function |
2909 * @name call | 2909 * @name call |
2910 * @memberOf PluginManager.prototype | |
2911 */ | 2910 */ |
2912 base.call = function () { | 2911 base.call = function () { |
2913 callHandlers(arguments, false); | 2912 callHandlers(arguments, false); |
2914 }; | 2913 }; |
2915 | 2914 |
2919 * @param {string} signal | 2918 * @param {string} signal |
2920 * @param {...string} args | 2919 * @param {...string} args |
2921 * @return {*} The result of calling the handler | 2920 * @return {*} The result of calling the handler |
2922 * @function | 2921 * @function |
2923 * @name callOnlyFirst | 2922 * @name callOnlyFirst |
2924 * @memberOf PluginManager.prototype | |
2925 */ | 2923 */ |
2926 base.callOnlyFirst = function () { | 2924 base.callOnlyFirst = function () { |
2927 return callHandlers(arguments, true); | 2925 return callHandlers(arguments, true); |
2928 }; | 2926 }; |
2929 | 2927 |
2932 * | 2930 * |
2933 * @param {string} signal | 2931 * @param {string} signal |
2934 * @return {boolean} | 2932 * @return {boolean} |
2935 * @function | 2933 * @function |
2936 * @name hasHandler | 2934 * @name hasHandler |
2937 * @memberOf PluginManager.prototype | |
2938 */ | 2935 */ |
2939 base.hasHandler = function (signal) { | 2936 base.hasHandler = function (signal) { |
2940 var i = registeredPlugins.length; | 2937 var i = registeredPlugins.length; |
2941 signal = formatSignalName(signal); | 2938 signal = formatSignalName(signal); |
2942 | 2939 |
2954 * | 2951 * |
2955 * @param {string} plugin | 2952 * @param {string} plugin |
2956 * @return {boolean} | 2953 * @return {boolean} |
2957 * @function | 2954 * @function |
2958 * @name exists | 2955 * @name exists |
2959 * @memberOf PluginManager.prototype | |
2960 */ | 2956 */ |
2961 base.exists = function (plugin) { | 2957 base.exists = function (plugin) { |
2962 if (plugin in plugins) { | 2958 if (plugin in plugins) { |
2963 plugin = plugins[plugin]; | 2959 plugin = plugins[plugin]; |
2964 | 2960 |
2974 * | 2970 * |
2975 * @param {string} plugin | 2971 * @param {string} plugin |
2976 * @return {boolean} | 2972 * @return {boolean} |
2977 * @function | 2973 * @function |
2978 * @name isRegistered | 2974 * @name isRegistered |
2979 * @memberOf PluginManager.prototype | |
2980 */ | 2975 */ |
2981 base.isRegistered = function (plugin) { | 2976 base.isRegistered = function (plugin) { |
2982 if (base.exists(plugin)) { | 2977 if (base.exists(plugin)) { |
2983 var idx = registeredPlugins.length; | 2978 var idx = registeredPlugins.length; |
2984 | 2979 |
2997 * | 2992 * |
2998 * @param {string} plugin | 2993 * @param {string} plugin |
2999 * @return {boolean} | 2994 * @return {boolean} |
3000 * @function | 2995 * @function |
3001 * @name register | 2996 * @name register |
3002 * @memberOf PluginManager.prototype | |
3003 */ | 2997 */ |
3004 base.register = function (pluginName) { | 2998 base.register = function (pluginName) { |
3005 if (!base.exists(pluginName) || base.isRegistered(pluginName)) { | 2999 if (!base.exists(pluginName) || base.isRegistered(pluginName)) { |
3006 return false; | 3000 return false; |
3007 } | 3001 } |
3022 * | 3016 * |
3023 * @param {string} plugin | 3017 * @param {string} plugin |
3024 * @return {boolean} | 3018 * @return {boolean} |
3025 * @function | 3019 * @function |
3026 * @name deregister | 3020 * @name deregister |
3027 * @memberOf PluginManager.prototype | |
3028 */ | 3021 */ |
3029 base.deregister = function (plugin) { | 3022 base.deregister = function (plugin) { |
3030 var removedPlugin, | 3023 var removedPlugin, |
3031 pluginIdx = registeredPlugins.length, | 3024 pluginIdx = registeredPlugins.length, |
3032 removed = false; | 3025 removed = false; |
3054 * | 3047 * |
3055 * Calling any functions on this object after calling | 3048 * Calling any functions on this object after calling |
3056 * destroy will cause a JS error. | 3049 * destroy will cause a JS error. |
3057 * | 3050 * |
3058 * @name destroy | 3051 * @name destroy |
3059 * @memberOf PluginManager.prototype | |
3060 */ | 3052 */ |
3061 base.destroy = function () { | 3053 base.destroy = function () { |
3062 var i = registeredPlugins.length; | 3054 var i = registeredPlugins.length; |
3063 | 3055 |
3064 while (i--) { | 3056 while (i--) { |
3162 * @param {string} html | 3154 * @param {string} html |
3163 * @param {string} [endHTML] | 3155 * @param {string} [endHTML] |
3164 * @return False on fail | 3156 * @return False on fail |
3165 * @function | 3157 * @function |
3166 * @name insertHTML | 3158 * @name insertHTML |
3167 * @memberOf RangeHelper.prototype | |
3168 */ | 3159 */ |
3169 base.insertHTML = function (html, endHTML) { | 3160 base.insertHTML = function (html, endHTML) { |
3170 var node, div, | 3161 var node, div, |
3171 range = base.selectedRange(); | 3162 range = base.selectedRange(); |
3172 | 3163 |
3266 * @param {Node} node | 3257 * @param {Node} node |
3267 * @param {Node} endNode | 3258 * @param {Node} endNode |
3268 * @return {false|undefined} | 3259 * @return {false|undefined} |
3269 * @function | 3260 * @function |
3270 * @name insertNode | 3261 * @name insertNode |
3271 * @memberOf RangeHelper.prototype | |
3272 */ | 3262 */ |
3273 base.insertNode = function (node, endNode) { | 3263 base.insertNode = function (node, endNode) { |
3274 var first, last, | 3264 var first, last, |
3275 input = _prepareInput(node, endNode), | 3265 input = _prepareInput(node, endNode), |
3276 range = base.selectedRange(), | 3266 range = base.selectedRange(), |
3327 * Clones the selected Range | 3317 * Clones the selected Range |
3328 * | 3318 * |
3329 * @return {Range} | 3319 * @return {Range} |
3330 * @function | 3320 * @function |
3331 * @name cloneSelected | 3321 * @name cloneSelected |
3332 * @memberOf RangeHelper.prototype | |
3333 */ | 3322 */ |
3334 base.cloneSelected = function () { | 3323 base.cloneSelected = function () { |
3335 var range = base.selectedRange(); | 3324 var range = base.selectedRange(); |
3336 | 3325 |
3337 if (range) { | 3326 if (range) { |
3343 * Gets the selected Range | 3332 * Gets the selected Range |
3344 * | 3333 * |
3345 * @return {Range} | 3334 * @return {Range} |
3346 * @function | 3335 * @function |
3347 * @name selectedRange | 3336 * @name selectedRange |
3348 * @memberOf RangeHelper.prototype | |
3349 */ | 3337 */ |
3350 base.selectedRange = function () { | 3338 base.selectedRange = function () { |
3351 var range, firstChild, | 3339 var range, firstChild, |
3352 sel = win.getSelection(); | 3340 sel = win.getSelection(); |
3353 | 3341 |
3383 * | 3371 * |
3384 * @return {boolean} | 3372 * @return {boolean} |
3385 * @function | 3373 * @function |
3386 * @name hasSelection | 3374 * @name hasSelection |
3387 * @since 1.4.4 | 3375 * @since 1.4.4 |
3388 * @memberOf RangeHelper.prototype | |
3389 */ | 3376 */ |
3390 base.hasSelection = function () { | 3377 base.hasSelection = function () { |
3391 var sel = win.getSelection(); | 3378 var sel = win.getSelection(); |
3392 | 3379 |
3393 return sel && sel.rangeCount > 0; | 3380 return sel && sel.rangeCount > 0; |
3397 * Gets the currently selected HTML | 3384 * Gets the currently selected HTML |
3398 * | 3385 * |
3399 * @return {string} | 3386 * @return {string} |
3400 * @function | 3387 * @function |
3401 * @name selectedHtml | 3388 * @name selectedHtml |
3402 * @memberOf RangeHelper.prototype | |
3403 */ | 3389 */ |
3404 base.selectedHtml = function () { | 3390 base.selectedHtml = function () { |
3405 var div, | 3391 var div, |
3406 range = base.selectedRange(); | 3392 range = base.selectedRange(); |
3407 | 3393 |
3419 * Gets the parent node of the selected contents in the range | 3405 * Gets the parent node of the selected contents in the range |
3420 * | 3406 * |
3421 * @return {HTMLElement} | 3407 * @return {HTMLElement} |
3422 * @function | 3408 * @function |
3423 * @name parentNode | 3409 * @name parentNode |
3424 * @memberOf RangeHelper.prototype | |
3425 */ | 3410 */ |
3426 base.parentNode = function () { | 3411 base.parentNode = function () { |
3427 var range = base.selectedRange(); | 3412 var range = base.selectedRange(); |
3428 | 3413 |
3429 if (range) { | 3414 if (range) { |
3436 * contents of the range. | 3421 * contents of the range. |
3437 * | 3422 * |
3438 * @return {HTMLElement} | 3423 * @return {HTMLElement} |
3439 * @function | 3424 * @function |
3440 * @name getFirstBlockParent | 3425 * @name getFirstBlockParent |
3441 * @memberOf RangeHelper.prototype | |
3442 */ | 3426 */ |
3443 /** | 3427 /** |
3444 * Gets the first block level parent of the selected | 3428 * Gets the first block level parent of the selected |
3445 * contents of the range. | 3429 * contents of the range. |
3446 * | 3430 * |
3447 * @param {Node} [n] The element to get the first block level parent from | 3431 * @param {Node} [n] The element to get the first block level parent from |
3448 * @return {HTMLElement} | 3432 * @return {HTMLElement} |
3449 * @function | 3433 * @function |
3450 * @name getFirstBlockParent^2 | 3434 * @name getFirstBlockParent^2 |
3451 * @since 1.4.1 | 3435 * @since 1.4.1 |
3452 * @memberOf RangeHelper.prototype | |
3453 */ | 3436 */ |
3454 base.getFirstBlockParent = function (node) { | 3437 base.getFirstBlockParent = function (node) { |
3455 var func = function (elm) { | 3438 var func = function (elm) { |
3456 if (!isInline(elm, true)) { | 3439 if (!isInline(elm, true)) { |
3457 return elm; | 3440 return elm; |
3470 * | 3453 * |
3471 * @param {Bool} start | 3454 * @param {Bool} start |
3472 * @param {Node} node | 3455 * @param {Node} node |
3473 * @function | 3456 * @function |
3474 * @name insertNodeAt | 3457 * @name insertNodeAt |
3475 * @memberOf RangeHelper.prototype | |
3476 */ | 3458 */ |
3477 base.insertNodeAt = function (start, node) { | 3459 base.insertNodeAt = function (start, node) { |
3478 var currentRange = base.selectedRange(), | 3460 var currentRange = base.selectedRange(), |
3479 range = base.cloneSelected(); | 3461 range = base.cloneSelected(); |
3480 | 3462 |
3514 /** | 3496 /** |
3515 * Inserts start/end markers for the current selection | 3497 * Inserts start/end markers for the current selection |
3516 * which can be used by restoreRange to re-select the | 3498 * which can be used by restoreRange to re-select the |
3517 * range. | 3499 * range. |
3518 * | 3500 * |
3519 * @memberOf RangeHelper.prototype | |
3520 * @function | 3501 * @function |
3521 * @name insertMarkers | 3502 * @name insertMarkers |
3522 */ | 3503 */ |
3523 base.insertMarkers = function () { | 3504 base.insertMarkers = function () { |
3524 var currentRange = base.selectedRange(); | 3505 var currentRange = base.selectedRange(); |
3542 * | 3523 * |
3543 * @param {string} id | 3524 * @param {string} id |
3544 * @return {Node} | 3525 * @return {Node} |
3545 * @function | 3526 * @function |
3546 * @name getMarker | 3527 * @name getMarker |
3547 * @memberOf RangeHelper.prototype | |
3548 */ | 3528 */ |
3549 base.getMarker = function (id) { | 3529 base.getMarker = function (id) { |
3550 return doc.getElementById(id); | 3530 return doc.getElementById(id); |
3551 }; | 3531 }; |
3552 | 3532 |
3554 * Removes the marker with the specified ID | 3534 * Removes the marker with the specified ID |
3555 * | 3535 * |
3556 * @param {string} id | 3536 * @param {string} id |
3557 * @function | 3537 * @function |
3558 * @name removeMarker | 3538 * @name removeMarker |
3559 * @memberOf RangeHelper.prototype | |
3560 */ | 3539 */ |
3561 base.removeMarker = function (id) { | 3540 base.removeMarker = function (id) { |
3562 var marker = base.getMarker(id); | 3541 var marker = base.getMarker(id); |
3563 | 3542 |
3564 if (marker) { | 3543 if (marker) { |
3569 /** | 3548 /** |
3570 * Removes the start/end markers | 3549 * Removes the start/end markers |
3571 * | 3550 * |
3572 * @function | 3551 * @function |
3573 * @name removeMarkers | 3552 * @name removeMarkers |
3574 * @memberOf RangeHelper.prototype | |
3575 */ | 3553 */ |
3576 base.removeMarkers = function () { | 3554 base.removeMarkers = function () { |
3577 base.removeMarker(startMarker); | 3555 base.removeMarker(startMarker); |
3578 base.removeMarker(endMarker); | 3556 base.removeMarker(endMarker); |
3579 }; | 3557 }; |
3581 /** | 3559 /** |
3582 * Saves the current range location. Alias of insertMarkers() | 3560 * Saves the current range location. Alias of insertMarkers() |
3583 * | 3561 * |
3584 * @function | 3562 * @function |
3585 * @name saveRage | 3563 * @name saveRage |
3586 * @memberOf RangeHelper.prototype | |
3587 */ | 3564 */ |
3588 base.saveRange = function () { | 3565 base.saveRange = function () { |
3589 base.insertMarkers(); | 3566 base.insertMarkers(); |
3590 }; | 3567 }; |
3591 | 3568 |
3593 * Select the specified range | 3570 * Select the specified range |
3594 * | 3571 * |
3595 * @param {Range} range | 3572 * @param {Range} range |
3596 * @function | 3573 * @function |
3597 * @name selectRange | 3574 * @name selectRange |
3598 * @memberOf RangeHelper.prototype | |
3599 */ | 3575 */ |
3600 base.selectRange = function (range) { | 3576 base.selectRange = function (range) { |
3601 var lastChild; | 3577 var lastChild; |
3602 var sel = win.getSelection(); | 3578 var sel = win.getSelection(); |
3603 var container = range.endContainer; | 3579 var container = range.endContainer; |
3634 /** | 3610 /** |
3635 * Restores the last range saved by saveRange() or insertMarkers() | 3611 * Restores the last range saved by saveRange() or insertMarkers() |
3636 * | 3612 * |
3637 * @function | 3613 * @function |
3638 * @name restoreRange | 3614 * @name restoreRange |
3639 * @memberOf RangeHelper.prototype | |
3640 */ | 3615 */ |
3641 base.restoreRange = function () { | 3616 base.restoreRange = function () { |
3642 var isCollapsed, | 3617 var isCollapsed, |
3643 range = base.selectedRange(), | 3618 range = base.selectedRange(), |
3644 start = base.getMarker(startMarker), | 3619 start = base.getMarker(startMarker), |
3668 * @param {number} left | 3643 * @param {number} left |
3669 * @param {number} right | 3644 * @param {number} right |
3670 * @since 1.4.3 | 3645 * @since 1.4.3 |
3671 * @function | 3646 * @function |
3672 * @name selectOuterText | 3647 * @name selectOuterText |
3673 * @memberOf RangeHelper.prototype | |
3674 */ | 3648 */ |
3675 base.selectOuterText = function (left, right) { | 3649 base.selectOuterText = function (left, right) { |
3676 var start, end, | 3650 var start, end, |
3677 range = base.cloneSelected(); | 3651 range = base.cloneSelected(); |
3678 | 3652 |
3698 * @param {number} length | 3672 * @param {number} length |
3699 * @return {string} | 3673 * @return {string} |
3700 * @since 1.4.3 | 3674 * @since 1.4.3 |
3701 * @function | 3675 * @function |
3702 * @name selectOuterText | 3676 * @name selectOuterText |
3703 * @memberOf RangeHelper.prototype | |
3704 */ | 3677 */ |
3705 base.getOuterText = function (before, length) { | 3678 base.getOuterText = function (before, length) { |
3706 var range = base.cloneSelected(); | 3679 var range = base.cloneSelected(); |
3707 | 3680 |
3708 if (!range) { | 3681 if (!range) { |
3730 * a keypress event, this should be | 3703 * a keypress event, this should be |
3731 * set to the pressed character | 3704 * set to the pressed character |
3732 * @return {boolean} | 3705 * @return {boolean} |
3733 * @function | 3706 * @function |
3734 * @name replaceKeyword | 3707 * @name replaceKeyword |
3735 * @memberOf RangeHelper.prototype | |
3736 */ | 3708 */ |
3737 // eslint-disable-next-line max-params | 3709 // eslint-disable-next-line max-params |
3738 base.replaceKeyword = function ( | 3710 base.replaceKeyword = function ( |
3739 keywords, | 3711 keywords, |
3740 includeAfter, | 3712 includeAfter, |
3825 * @param {Range} rngA | 3797 * @param {Range} rngA |
3826 * @param {Range} [rngB] | 3798 * @param {Range} [rngB] |
3827 * @return {boolean} | 3799 * @return {boolean} |
3828 * @function | 3800 * @function |
3829 * @name compare | 3801 * @name compare |
3830 * @memberOf RangeHelper.prototype | |
3831 */ | 3802 */ |
3832 base.compare = function (rngA, rngB) { | 3803 base.compare = function (rngA, rngB) { |
3833 if (!rngB) { | 3804 if (!rngB) { |
3834 rngB = base.selectedRange(); | 3805 rngB = base.selectedRange(); |
3835 } | 3806 } |
3846 * Removes any current selection | 3817 * Removes any current selection |
3847 * | 3818 * |
3848 * @since 1.4.6 | 3819 * @since 1.4.6 |
3849 * @function | 3820 * @function |
3850 * @name clear | 3821 * @name clear |
3851 * @memberOf RangeHelper.prototype | |
3852 */ | 3822 */ |
3853 base.clear = function () { | 3823 base.clear = function () { |
3854 var sel = win.getSelection(); | 3824 var sel = win.getSelection(); |
3855 | 3825 |
3856 if (sel) { | 3826 if (sel) { |
4438 autoExpand; | 4408 autoExpand; |
4439 | 4409 |
4440 /** | 4410 /** |
4441 * All the commands supported by the editor | 4411 * All the commands supported by the editor |
4442 * @name commands | 4412 * @name commands |
4443 * @memberOf SCEditor.prototype | |
4444 */ | 4413 */ |
4445 base.commands = extendDeep({}, (userOptions.commands || defaultCmds)); | 4414 base.commands = extendDeep({}, (userOptions.commands || defaultCmds)); |
4446 | 4415 |
4447 /** | 4416 /** |
4448 * Options for this editor instance | 4417 * Options for this editor instance |
4449 * @name opts | 4418 * @name opts |
4450 * @memberOf SCEditor.prototype | |
4451 */ | 4419 */ |
4452 var options = base.opts = extendDeep( | 4420 var options = base.opts = extendDeep( |
4453 {}, defaultOptions, userOptions | 4421 {}, defaultOptions, userOptions |
4454 ); | 4422 ); |
4455 | 4423 |
5059 /** | 5027 /** |
5060 * Gets if the editor is read only | 5028 * Gets if the editor is read only |
5061 * | 5029 * |
5062 * @since 1.3.5 | 5030 * @since 1.3.5 |
5063 * @function | 5031 * @function |
5064 * @memberOf SCEditor.prototype | |
5065 * @name readOnly | 5032 * @name readOnly |
5066 * @return {boolean} | 5033 * @return {boolean} |
5067 */ | 5034 */ |
5068 /** | 5035 /** |
5069 * Sets if the editor is read only | 5036 * Sets if the editor is read only |
5070 * | 5037 * |
5071 * @param {boolean} readOnly | 5038 * @param {boolean} readOnly |
5072 * @since 1.3.5 | 5039 * @since 1.3.5 |
5073 * @function | 5040 * @function |
5074 * @memberOf SCEditor.prototype | |
5075 * @name readOnly^2 | 5041 * @name readOnly^2 |
5076 * @return {this} | 5042 * @return {this} |
5077 */ | 5043 */ |
5078 base.readOnly = function (readOnly) { | 5044 base.readOnly = function (readOnly) { |
5079 if (typeof readOnly !== 'boolean') { | 5045 if (typeof readOnly !== 'boolean') { |
5089 /** | 5055 /** |
5090 * Gets if the editor is in RTL mode | 5056 * Gets if the editor is in RTL mode |
5091 * | 5057 * |
5092 * @since 1.4.1 | 5058 * @since 1.4.1 |
5093 * @function | 5059 * @function |
5094 * @memberOf SCEditor.prototype | |
5095 * @name rtl | 5060 * @name rtl |
5096 * @return {boolean} | 5061 * @return {boolean} |
5097 */ | 5062 */ |
5098 /** | 5063 /** |
5099 * Sets if the editor is in RTL mode | 5064 * Sets if the editor is in RTL mode |
5100 * | 5065 * |
5101 * @param {boolean} rtl | 5066 * @param {boolean} rtl |
5102 * @since 1.4.1 | 5067 * @since 1.4.1 |
5103 * @function | 5068 * @function |
5104 * @memberOf SCEditor.prototype | |
5105 * @name rtl^2 | 5069 * @name rtl^2 |
5106 * @return {this} | 5070 * @return {this} |
5107 */ | 5071 */ |
5108 base.rtl = function (rtl) { | 5072 base.rtl = function (rtl) { |
5109 var dir = rtl ? 'rtl' : 'ltr'; | 5073 var dir = rtl ? 'rtl' : 'ltr'; |
5139 /** | 5103 /** |
5140 * Gets the width of the editor in pixels | 5104 * Gets the width of the editor in pixels |
5141 * | 5105 * |
5142 * @since 1.3.5 | 5106 * @since 1.3.5 |
5143 * @function | 5107 * @function |
5144 * @memberOf SCEditor.prototype | |
5145 * @name width | 5108 * @name width |
5146 * @return {number} | 5109 * @return {number} |
5147 */ | 5110 */ |
5148 /** | 5111 /** |
5149 * Sets the width of the editor | 5112 * Sets the width of the editor |
5150 * | 5113 * |
5151 * @param {number} width Width in pixels | 5114 * @param {number} width Width in pixels |
5152 * @since 1.3.5 | 5115 * @since 1.3.5 |
5153 * @function | 5116 * @function |
5154 * @memberOf SCEditor.prototype | |
5155 * @name width^2 | 5117 * @name width^2 |
5156 * @return {this} | 5118 * @return {this} |
5157 */ | 5119 */ |
5158 /** | 5120 /** |
5159 * Sets the width of the editor | 5121 * Sets the width of the editor |
5163 * | 5125 * |
5164 * @param {number} width Width in pixels | 5126 * @param {number} width Width in pixels |
5165 * @param {boolean} [saveWidth=true] If to store the width | 5127 * @param {boolean} [saveWidth=true] If to store the width |
5166 * @since 1.4.1 | 5128 * @since 1.4.1 |
5167 * @function | 5129 * @function |
5168 * @memberOf SCEditor.prototype | |
5169 * @name width^3 | 5130 * @name width^3 |
5170 * @return {this} | 5131 * @return {this} |
5171 */ | 5132 */ |
5172 base.width = function (width$1, saveWidth) { | 5133 base.width = function (width$1, saveWidth) { |
5173 if (!width$1 && width$1 !== 0) { | 5134 if (!width$1 && width$1 !== 0) { |
5181 * Returns an object with the properties width and height | 5142 * Returns an object with the properties width and height |
5182 * which are the width and height of the editor in px. | 5143 * which are the width and height of the editor in px. |
5183 * | 5144 * |
5184 * @since 1.4.1 | 5145 * @since 1.4.1 |
5185 * @function | 5146 * @function |
5186 * @memberOf SCEditor.prototype | |
5187 * @name dimensions | 5147 * @name dimensions |
5188 * @return {object} | 5148 * @return {object} |
5189 */ | 5149 */ |
5190 /** | 5150 /** |
5191 * <p>Sets the width and/or height of the editor.</p> | 5151 * <p>Sets the width and/or height of the editor.</p> |
5194 * | 5154 * |
5195 * @param {number} width Width in px | 5155 * @param {number} width Width in px |
5196 * @param {number} height Height in px | 5156 * @param {number} height Height in px |
5197 * @since 1.4.1 | 5157 * @since 1.4.1 |
5198 * @function | 5158 * @function |
5199 * @memberOf SCEditor.prototype | |
5200 * @name dimensions^2 | 5159 * @name dimensions^2 |
5201 * @return {this} | 5160 * @return {this} |
5202 */ | 5161 */ |
5203 /** | 5162 /** |
5204 * <p>Sets the width and/or height of the editor.</p> | 5163 * <p>Sets the width and/or height of the editor.</p> |
5212 * @param {number} width Width in px | 5171 * @param {number} width Width in px |
5213 * @param {number} height Height in px | 5172 * @param {number} height Height in px |
5214 * @param {boolean} [save=true] If to store the new sizes | 5173 * @param {boolean} [save=true] If to store the new sizes |
5215 * @since 1.4.1 | 5174 * @since 1.4.1 |
5216 * @function | 5175 * @function |
5217 * @memberOf SCEditor.prototype | |
5218 * @name dimensions^3 | 5176 * @name dimensions^3 |
5219 * @return {this} | 5177 * @return {this} |
5220 */ | 5178 */ |
5221 base.dimensions = function (width$1, height$1, save) { | 5179 base.dimensions = function (width$1, height$1, save) { |
5222 // set undefined width/height to boolean false | 5180 // set undefined width/height to boolean false |
5247 /** | 5205 /** |
5248 * Gets the height of the editor in px | 5206 * Gets the height of the editor in px |
5249 * | 5207 * |
5250 * @since 1.3.5 | 5208 * @since 1.3.5 |
5251 * @function | 5209 * @function |
5252 * @memberOf SCEditor.prototype | |
5253 * @name height | 5210 * @name height |
5254 * @return {number} | 5211 * @return {number} |
5255 */ | 5212 */ |
5256 /** | 5213 /** |
5257 * Sets the height of the editor | 5214 * Sets the height of the editor |
5258 * | 5215 * |
5259 * @param {number} height Height in px | 5216 * @param {number} height Height in px |
5260 * @since 1.3.5 | 5217 * @since 1.3.5 |
5261 * @function | 5218 * @function |
5262 * @memberOf SCEditor.prototype | |
5263 * @name height^2 | 5219 * @name height^2 |
5264 * @return {this} | 5220 * @return {this} |
5265 */ | 5221 */ |
5266 /** | 5222 /** |
5267 * Sets the height of the editor | 5223 * Sets the height of the editor |
5273 * | 5229 * |
5274 * @param {number} height Height in px | 5230 * @param {number} height Height in px |
5275 * @param {boolean} [saveHeight=true] If to store the height | 5231 * @param {boolean} [saveHeight=true] If to store the height |
5276 * @since 1.4.1 | 5232 * @since 1.4.1 |
5277 * @function | 5233 * @function |
5278 * @memberOf SCEditor.prototype | |
5279 * @name height^3 | 5234 * @name height^3 |
5280 * @return {this} | 5235 * @return {this} |
5281 */ | 5236 */ |
5282 base.height = function (height$1, saveHeight) { | 5237 base.height = function (height$1, saveHeight) { |
5283 if (!height$1 && height$1 !== 0) { | 5238 if (!height$1 && height$1 !== 0) { |
5290 /** | 5245 /** |
5291 * Gets if the editor is maximised or not | 5246 * Gets if the editor is maximised or not |
5292 * | 5247 * |
5293 * @since 1.4.1 | 5248 * @since 1.4.1 |
5294 * @function | 5249 * @function |
5295 * @memberOf SCEditor.prototype | |
5296 * @name maximize | 5250 * @name maximize |
5297 * @return {boolean} | 5251 * @return {boolean} |
5298 */ | 5252 */ |
5299 /** | 5253 /** |
5300 * Sets if the editor is maximised or not | 5254 * Sets if the editor is maximised or not |
5301 * | 5255 * |
5302 * @param {boolean} maximize If to maximise the editor | 5256 * @param {boolean} maximize If to maximise the editor |
5303 * @since 1.4.1 | 5257 * @since 1.4.1 |
5304 * @function | 5258 * @function |
5305 * @memberOf SCEditor.prototype | |
5306 * @name maximize^2 | 5259 * @name maximize^2 |
5307 * @return {this} | 5260 * @return {this} |
5308 */ | 5261 */ |
5309 base.maximize = function (maximize) { | 5262 base.maximize = function (maximize) { |
5310 var maximizeSize = 'sceditor-maximize'; | 5263 var maximizeSize = 'sceditor-maximize'; |
5346 * | 5299 * |
5347 * @since 1.3.5 | 5300 * @since 1.3.5 |
5348 * @param {boolean} [ignoreMaxHeight=false] | 5301 * @param {boolean} [ignoreMaxHeight=false] |
5349 * @function | 5302 * @function |
5350 * @name expandToContent | 5303 * @name expandToContent |
5351 * @memberOf SCEditor.prototype | |
5352 * @see #resizeToContent | 5304 * @see #resizeToContent |
5353 */ | 5305 */ |
5354 base.expandToContent = function (ignoreMaxHeight) { | 5306 base.expandToContent = function (ignoreMaxHeight) { |
5355 if (base.maximize()) { | 5307 if (base.maximize()) { |
5356 return; | 5308 return; |
5387 * | 5339 * |
5388 * Leaves only the original textarea. | 5340 * Leaves only the original textarea. |
5389 * | 5341 * |
5390 * @function | 5342 * @function |
5391 * @name destroy | 5343 * @name destroy |
5392 * @memberOf SCEditor.prototype | |
5393 */ | 5344 */ |
5394 base.destroy = function () { | 5345 base.destroy = function () { |
5395 // Don't destroy if the editor has already been destroyed | 5346 // Don't destroy if the editor has already been destroyed |
5396 if (!pluginManager) { | 5347 if (!pluginManager) { |
5397 return; | 5348 return; |
5434 * @param {string} name Used for styling the dropdown, will be | 5385 * @param {string} name Used for styling the dropdown, will be |
5435 * a class sceditor-name | 5386 * a class sceditor-name |
5436 * @param {HTMLElement} content The HTML content of the dropdown | 5387 * @param {HTMLElement} content The HTML content of the dropdown |
5437 * @function | 5388 * @function |
5438 * @name createDropDown | 5389 * @name createDropDown |
5439 * @memberOf SCEditor.prototype | |
5440 */ | 5390 */ |
5441 base.createDropDown = function (menuItem, name, content) { | 5391 base.createDropDown = function (menuItem, name, content) { |
5442 // first click for create second click for close | 5392 // first click for create second click for close |
5443 var dropDownCss, | 5393 var dropDownCss, |
5444 dropDownClass = 'sceditor-' + name; | 5394 dropDownClass = 'sceditor-' + name; |
5677 * | 5627 * |
5678 * @param {boolean} [focus=false] If to focus the editor | 5628 * @param {boolean} [focus=false] If to focus the editor |
5679 * after closing the drop down | 5629 * after closing the drop down |
5680 * @function | 5630 * @function |
5681 * @name closeDropDown | 5631 * @name closeDropDown |
5682 * @memberOf SCEditor.prototype | |
5683 */ | 5632 */ |
5684 base.closeDropDown = function (focus) { | 5633 base.closeDropDown = function (focus) { |
5685 if (dropdown) { | 5634 if (dropdown) { |
5686 remove(dropdown); | 5635 remove(dropdown); |
5687 dropdown = null; | 5636 dropdown = null; |
5706 * into code tags, by | 5655 * into code tags, by |
5707 * default code tags only | 5656 * default code tags only |
5708 * support text. | 5657 * support text. |
5709 * @function | 5658 * @function |
5710 * @name wysiwygEditorInsertHtml | 5659 * @name wysiwygEditorInsertHtml |
5711 * @memberOf SCEditor.prototype | |
5712 */ | 5660 */ |
5713 base.wysiwygEditorInsertHtml = function ( | 5661 base.wysiwygEditorInsertHtml = function ( |
5714 html, endHtml, overrideCodeBlocking | 5662 html, endHtml, overrideCodeBlocking |
5715 ) { | 5663 ) { |
5716 var marker, scrollTop, scrollTo, | 5664 var marker, scrollTop, scrollTo, |
5763 * | 5711 * |
5764 * @param {string} text | 5712 * @param {string} text |
5765 * @param {string} [endText=null] | 5713 * @param {string} [endText=null] |
5766 * @function | 5714 * @function |
5767 * @name wysiwygEditorInsertText | 5715 * @name wysiwygEditorInsertText |
5768 * @memberOf SCEditor.prototype | |
5769 */ | 5716 */ |
5770 base.wysiwygEditorInsertText = function (text, endText) { | 5717 base.wysiwygEditorInsertText = function (text, endText) { |
5771 base.wysiwygEditorInsertHtml( | 5718 base.wysiwygEditorInsertHtml( |
5772 entities(text), entities(endText) | 5719 entities(text), entities(endText) |
5773 ); | 5720 ); |
5784 * @param {string} text | 5731 * @param {string} text |
5785 * @param {string} [endText=null] | 5732 * @param {string} [endText=null] |
5786 * @since 1.3.5 | 5733 * @since 1.3.5 |
5787 * @function | 5734 * @function |
5788 * @name insertText | 5735 * @name insertText |
5789 * @memberOf SCEditor.prototype | |
5790 */ | 5736 */ |
5791 base.insertText = function (text, endText) { | 5737 base.insertText = function (text, endText) { |
5792 if (base.inSourceMode()) { | 5738 if (base.inSourceMode()) { |
5793 base.sourceEditorInsertText(text, endText); | 5739 base.sourceEditorInsertText(text, endText); |
5794 } else { | 5740 } else { |
5816 * @param {string} text | 5762 * @param {string} text |
5817 * @param {string} [endText=null] | 5763 * @param {string} [endText=null] |
5818 * @since 1.4.0 | 5764 * @since 1.4.0 |
5819 * @function | 5765 * @function |
5820 * @name sourceEditorInsertText | 5766 * @name sourceEditorInsertText |
5821 * @memberOf SCEditor.prototype | |
5822 */ | 5767 */ |
5823 base.sourceEditorInsertText = function (text, endText) { | 5768 base.sourceEditorInsertText = function (text, endText) { |
5824 var scrollTop, currentValue, | 5769 var scrollTop, currentValue, |
5825 startPos = sourceEditor.selectionStart, | 5770 startPos = sourceEditor.selectionStart, |
5826 endPos = sourceEditor.selectionEnd; | 5771 endPos = sourceEditor.selectionEnd; |
5852 * for the editor. | 5797 * for the editor. |
5853 * | 5798 * |
5854 * @return {RangeHelper} | 5799 * @return {RangeHelper} |
5855 * @function | 5800 * @function |
5856 * @name getRangeHelper | 5801 * @name getRangeHelper |
5857 * @memberOf SCEditor.prototype | |
5858 */ | 5802 */ |
5859 base.getRangeHelper = function () { | 5803 base.getRangeHelper = function () { |
5860 return rangeHelper; | 5804 return rangeHelper; |
5861 }; | 5805 }; |
5862 | 5806 |
5866 * @param {Object} [position] | 5810 * @param {Object} [position] |
5867 * @return {this} | 5811 * @return {this} |
5868 * @function | 5812 * @function |
5869 * @since 1.4.5 | 5813 * @since 1.4.5 |
5870 * @name sourceEditorCaret | 5814 * @name sourceEditorCaret |
5871 * @memberOf SCEditor.prototype | |
5872 */ | 5815 */ |
5873 base.sourceEditorCaret = function (position) { | 5816 base.sourceEditorCaret = function (position) { |
5874 sourceEditor.focus(); | 5817 sourceEditor.focus(); |
5875 | 5818 |
5876 if (position) { | 5819 if (position) { |
5896 * | 5839 * |
5897 * @since 1.3.5 | 5840 * @since 1.3.5 |
5898 * @return {string} | 5841 * @return {string} |
5899 * @function | 5842 * @function |
5900 * @name val | 5843 * @name val |
5901 * @memberOf SCEditor.prototype | |
5902 */ | 5844 */ |
5903 /** | 5845 /** |
5904 * Sets the value of the editor. | 5846 * Sets the value of the editor. |
5905 * | 5847 * |
5906 * If filter set true the val will be passed through the filter | 5848 * If filter set true the val will be passed through the filter |
5911 * @param {boolean} [filter=true] | 5853 * @param {boolean} [filter=true] |
5912 * @return {this} | 5854 * @return {this} |
5913 * @since 1.3.5 | 5855 * @since 1.3.5 |
5914 * @function | 5856 * @function |
5915 * @name val^2 | 5857 * @name val^2 |
5916 * @memberOf SCEditor.prototype | |
5917 */ | 5858 */ |
5918 base.val = function (val, filter) { | 5859 base.val = function (val, filter) { |
5919 if (!isString(val)) { | 5860 if (!isString(val)) { |
5920 return base.inSourceMode() ? | 5861 return base.inSourceMode() ? |
5921 base.getSourceEditorValue(false) : | 5862 base.getSourceEditorValue(false) : |
5950 * @param {boolean} [convertEmoticons=true] If to convert emoticons | 5891 * @param {boolean} [convertEmoticons=true] If to convert emoticons |
5951 * @return {this} | 5892 * @return {this} |
5952 * @since 1.3.5 | 5893 * @since 1.3.5 |
5953 * @function | 5894 * @function |
5954 * @name insert | 5895 * @name insert |
5955 * @memberOf SCEditor.prototype | |
5956 */ | 5896 */ |
5957 /** | 5897 /** |
5958 * Inserts HTML/BBCode into the editor | 5898 * Inserts HTML/BBCode into the editor |
5959 * | 5899 * |
5960 * If end is supplied any selected text will be placed between | 5900 * If end is supplied any selected text will be placed between |
5975 * @param {boolean} [allowMixed=false] | 5915 * @param {boolean} [allowMixed=false] |
5976 * @return {this} | 5916 * @return {this} |
5977 * @since 1.4.3 | 5917 * @since 1.4.3 |
5978 * @function | 5918 * @function |
5979 * @name insert^2 | 5919 * @name insert^2 |
5980 * @memberOf SCEditor.prototype | |
5981 */ | 5920 */ |
5982 // eslint-disable-next-line max-params | 5921 // eslint-disable-next-line max-params |
5983 base.insert = function ( | 5922 base.insert = function ( |
5984 start, end, filter, convertEmoticons, allowMixed | 5923 start, end, filter, convertEmoticons, allowMixed |
5985 ) { | 5924 ) { |
6023 * | 5962 * |
6024 * @param {boolean} [filter=true] | 5963 * @param {boolean} [filter=true] |
6025 * @return {string} | 5964 * @return {string} |
6026 * @function | 5965 * @function |
6027 * @name getWysiwygEditorValue | 5966 * @name getWysiwygEditorValue |
6028 * @memberOf SCEditor.prototype | |
6029 */ | 5967 */ |
6030 base.getWysiwygEditorValue = function (filter) { | 5968 base.getWysiwygEditorValue = function (filter) { |
6031 var html; | 5969 var html; |
6032 // Create a tmp node to store contents so it can be modified | 5970 // Create a tmp node to store contents so it can be modified |
6033 // without affecting anything else. | 5971 // without affecting anything else. |
6057 * | 5995 * |
6058 * @return {HTMLElement} | 5996 * @return {HTMLElement} |
6059 * @function | 5997 * @function |
6060 * @since 1.4.3 | 5998 * @since 1.4.3 |
6061 * @name getBody | 5999 * @name getBody |
6062 * @memberOf SCEditor.prototype | |
6063 */ | 6000 */ |
6064 base.getBody = function () { | 6001 base.getBody = function () { |
6065 return wysiwygBody; | 6002 return wysiwygBody; |
6066 }; | 6003 }; |
6067 | 6004 |
6070 * | 6007 * |
6071 * @return {HTMLElement} | 6008 * @return {HTMLElement} |
6072 * @function | 6009 * @function |
6073 * @since 1.4.3 | 6010 * @since 1.4.3 |
6074 * @name getContentAreaContainer | 6011 * @name getContentAreaContainer |
6075 * @memberOf SCEditor.prototype | |
6076 */ | 6012 */ |
6077 base.getContentAreaContainer = function () { | 6013 base.getContentAreaContainer = function () { |
6078 return wysiwygEditor; | 6014 return wysiwygEditor; |
6079 }; | 6015 }; |
6080 | 6016 |
6089 * @param {boolean} [filter=true] | 6025 * @param {boolean} [filter=true] |
6090 * @return {string} | 6026 * @return {string} |
6091 * @function | 6027 * @function |
6092 * @since 1.4.0 | 6028 * @since 1.4.0 |
6093 * @name getSourceEditorValue | 6029 * @name getSourceEditorValue |
6094 * @memberOf SCEditor.prototype | |
6095 */ | 6030 */ |
6096 base.getSourceEditorValue = function (filter) { | 6031 base.getSourceEditorValue = function (filter) { |
6097 var val = sourceEditor.value; | 6032 var val = sourceEditor.value; |
6098 | 6033 |
6099 if (filter !== false && 'toHtml' in format) { | 6034 if (filter !== false && 'toHtml' in format) { |
6108 * contained within the body tags | 6043 * contained within the body tags |
6109 * | 6044 * |
6110 * @param {string} value | 6045 * @param {string} value |
6111 * @function | 6046 * @function |
6112 * @name setWysiwygEditorValue | 6047 * @name setWysiwygEditorValue |
6113 * @memberOf SCEditor.prototype | |
6114 */ | 6048 */ |
6115 base.setWysiwygEditorValue = function (value) { | 6049 base.setWysiwygEditorValue = function (value) { |
6116 if (!value) { | 6050 if (!value) { |
6117 value = '<p><br /></p>'; | 6051 value = '<p><br /></p>'; |
6118 } | 6052 } |
6129 * Sets the text editor value | 6063 * Sets the text editor value |
6130 * | 6064 * |
6131 * @param {string} value | 6065 * @param {string} value |
6132 * @function | 6066 * @function |
6133 * @name setSourceEditorValue | 6067 * @name setSourceEditorValue |
6134 * @memberOf SCEditor.prototype | |
6135 */ | 6068 */ |
6136 base.setSourceEditorValue = function (value) { | 6069 base.setSourceEditorValue = function (value) { |
6137 sourceEditor.value = value; | 6070 sourceEditor.value = value; |
6138 | 6071 |
6139 triggerValueChanged(); | 6072 triggerValueChanged(); |
6144 * with the value currently inside the editor. | 6077 * with the value currently inside the editor. |
6145 * | 6078 * |
6146 * @function | 6079 * @function |
6147 * @name updateOriginal | 6080 * @name updateOriginal |
6148 * @since 1.4.0 | 6081 * @since 1.4.0 |
6149 * @memberOf SCEditor.prototype | |
6150 */ | 6082 */ |
6151 base.updateOriginal = function () { | 6083 base.updateOriginal = function () { |
6152 original.value = base.val(); | 6084 original.value = base.val(); |
6153 }; | 6085 }; |
6154 | 6086 |
6167 * If the editor is in source code mode | 6099 * If the editor is in source code mode |
6168 * | 6100 * |
6169 * @return {boolean} | 6101 * @return {boolean} |
6170 * @function | 6102 * @function |
6171 * @name inSourceMode | 6103 * @name inSourceMode |
6172 * @memberOf SCEditor.prototype | |
6173 */ | 6104 */ |
6174 base.inSourceMode = function () { | 6105 base.inSourceMode = function () { |
6175 return hasClass(editorContainer, 'sourceMode'); | 6106 return hasClass(editorContainer, 'sourceMode'); |
6176 }; | 6107 }; |
6177 | 6108 |
6179 * Gets if the editor is in sourceMode | 6110 * Gets if the editor is in sourceMode |
6180 * | 6111 * |
6181 * @return boolean | 6112 * @return boolean |
6182 * @function | 6113 * @function |
6183 * @name sourceMode | 6114 * @name sourceMode |
6184 * @memberOf SCEditor.prototype | |
6185 */ | 6115 */ |
6186 /** | 6116 /** |
6187 * Sets if the editor is in sourceMode | 6117 * Sets if the editor is in sourceMode |
6188 * | 6118 * |
6189 * @param {boolean} enable | 6119 * @param {boolean} enable |
6190 * @return {this} | 6120 * @return {this} |
6191 * @function | 6121 * @function |
6192 * @name sourceMode^2 | 6122 * @name sourceMode^2 |
6193 * @memberOf SCEditor.prototype | |
6194 */ | 6123 */ |
6195 base.sourceMode = function (enable) { | 6124 base.sourceMode = function (enable) { |
6196 var inSourceMode = base.inSourceMode(); | 6125 var inSourceMode = base.inSourceMode(); |
6197 | 6126 |
6198 if (typeof enable !== 'boolean') { | 6127 if (typeof enable !== 'boolean') { |
6208 * Switches between the WYSIWYG and source modes | 6137 * Switches between the WYSIWYG and source modes |
6209 * | 6138 * |
6210 * @function | 6139 * @function |
6211 * @name toggleSourceMode | 6140 * @name toggleSourceMode |
6212 * @since 1.4.0 | 6141 * @since 1.4.0 |
6213 * @memberOf SCEditor.prototype | |
6214 */ | 6142 */ |
6215 base.toggleSourceMode = function () { | 6143 base.toggleSourceMode = function () { |
6216 var isInSourceMode = base.inSourceMode(); | 6144 var isInSourceMode = base.inSourceMode(); |
6217 | 6145 |
6218 // don't allow switching to WYSIWYG if doesn't support it | 6146 // don't allow switching to WYSIWYG if doesn't support it |
6290 * | 6218 * |
6291 * @param {string} command | 6219 * @param {string} command |
6292 * @param {String|Boolean} [param] | 6220 * @param {String|Boolean} [param] |
6293 * @function | 6221 * @function |
6294 * @name execCommand | 6222 * @name execCommand |
6295 * @memberOf SCEditor.prototype | |
6296 */ | 6223 */ |
6297 base.execCommand = function (command, param) { | 6224 base.execCommand = function (command, param) { |
6298 var executed = false, | 6225 var executed = false, |
6299 commandObj = base.commands[command]; | 6226 commandObj = base.commands[command]; |
6300 | 6227 |
6410 * Will be null in sourceMode or if there is no selection. | 6337 * Will be null in sourceMode or if there is no selection. |
6411 * | 6338 * |
6412 * @return {?Node} | 6339 * @return {?Node} |
6413 * @function | 6340 * @function |
6414 * @name currentNode | 6341 * @name currentNode |
6415 * @memberOf SCEditor.prototype | |
6416 */ | 6342 */ |
6417 base.currentNode = function () { | 6343 base.currentNode = function () { |
6418 return currentNode; | 6344 return currentNode; |
6419 }; | 6345 }; |
6420 | 6346 |
6425 * Will be null in sourceMode or if there is no selection. | 6351 * Will be null in sourceMode or if there is no selection. |
6426 * | 6352 * |
6427 * @return {?Node} | 6353 * @return {?Node} |
6428 * @function | 6354 * @function |
6429 * @name currentBlockNode | 6355 * @name currentBlockNode |
6430 * @memberOf SCEditor.prototype | |
6431 * @since 1.4.4 | 6356 * @since 1.4.4 |
6432 */ | 6357 */ |
6433 base.currentBlockNode = function () { | 6358 base.currentBlockNode = function () { |
6434 return currentBlockNode; | 6359 return currentBlockNode; |
6435 }; | 6360 }; |
6598 * @param {string} str | 6523 * @param {string} str |
6599 * @param {...String} args | 6524 * @param {...String} args |
6600 * @return {string} | 6525 * @return {string} |
6601 * @function | 6526 * @function |
6602 * @name _ | 6527 * @name _ |
6603 * @memberOf SCEditor.prototype | |
6604 */ | 6528 */ |
6605 base._ = function () { | 6529 base._ = function () { |
6606 var undef, | 6530 var undef, |
6607 args = arguments; | 6531 args = arguments; |
6608 | 6532 |
6670 * @param {boolean} excludeSource if to exclude adding this handler | 6594 * @param {boolean} excludeSource if to exclude adding this handler |
6671 * to the source editor | 6595 * to the source editor |
6672 * @return {this} | 6596 * @return {this} |
6673 * @function | 6597 * @function |
6674 * @name bind | 6598 * @name bind |
6675 * @memberOf SCEditor.prototype | |
6676 * @since 1.4.1 | 6599 * @since 1.4.1 |
6677 */ | 6600 */ |
6678 base.bind = function (events, handler, excludeWysiwyg, excludeSource) { | 6601 base.bind = function (events, handler, excludeWysiwyg, excludeSource) { |
6679 events = events.split(' '); | 6602 events = events.split(' '); |
6680 | 6603 |
6715 * @param {boolean} excludeSource if to exclude unbinding this | 6638 * @param {boolean} excludeSource if to exclude unbinding this |
6716 * handler from the source editor | 6639 * handler from the source editor |
6717 * @return {this} | 6640 * @return {this} |
6718 * @function | 6641 * @function |
6719 * @name unbind | 6642 * @name unbind |
6720 * @memberOf SCEditor.prototype | |
6721 * @since 1.4.1 | 6643 * @since 1.4.1 |
6722 * @see bind | 6644 * @see bind |
6723 */ | 6645 */ |
6724 base.unbind = function (events, handler, excludeWysiwyg, excludeSource) { | 6646 base.unbind = function (events, handler, excludeWysiwyg, excludeSource) { |
6725 events = events.split(' '); | 6647 events = events.split(' '); |
6744 * Blurs the editors input area | 6666 * Blurs the editors input area |
6745 * | 6667 * |
6746 * @return {this} | 6668 * @return {this} |
6747 * @function | 6669 * @function |
6748 * @name blur | 6670 * @name blur |
6749 * @memberOf SCEditor.prototype | |
6750 * @since 1.3.6 | 6671 * @since 1.3.6 |
6751 */ | 6672 */ |
6752 /** | 6673 /** |
6753 * Adds a handler to the editors blur event | 6674 * Adds a handler to the editors blur event |
6754 * | 6675 * |
6758 * @param {boolean} excludeSource if to exclude adding this handler | 6679 * @param {boolean} excludeSource if to exclude adding this handler |
6759 * to the source editor | 6680 * to the source editor |
6760 * @return {this} | 6681 * @return {this} |
6761 * @function | 6682 * @function |
6762 * @name blur^2 | 6683 * @name blur^2 |
6763 * @memberOf SCEditor.prototype | |
6764 * @since 1.4.1 | 6684 * @since 1.4.1 |
6765 */ | 6685 */ |
6766 base.blur = function (handler, excludeWysiwyg, excludeSource) { | 6686 base.blur = function (handler, excludeWysiwyg, excludeSource) { |
6767 if (isFunction(handler)) { | 6687 if (isFunction(handler)) { |
6768 base.bind('blur', handler, excludeWysiwyg, excludeSource); | 6688 base.bind('blur', handler, excludeWysiwyg, excludeSource); |
6777 * Focuses the editors input area | 6697 * Focuses the editors input area |
6778 * | 6698 * |
6779 * @return {this} | 6699 * @return {this} |
6780 * @function | 6700 * @function |
6781 * @name focus | 6701 * @name focus |
6782 * @memberOf SCEditor.prototype | |
6783 */ | 6702 */ |
6784 /** | 6703 /** |
6785 * Adds an event handler to the focus event | 6704 * Adds an event handler to the focus event |
6786 * | 6705 * |
6787 * @param {Function} handler | 6706 * @param {Function} handler |
6790 * @param {boolean} excludeSource if to exclude adding this handler | 6709 * @param {boolean} excludeSource if to exclude adding this handler |
6791 * to the source editor | 6710 * to the source editor |
6792 * @return {this} | 6711 * @return {this} |
6793 * @function | 6712 * @function |
6794 * @name focus^2 | 6713 * @name focus^2 |
6795 * @memberOf SCEditor.prototype | |
6796 * @since 1.4.1 | 6714 * @since 1.4.1 |
6797 */ | 6715 */ |
6798 base.focus = function (handler, excludeWysiwyg, excludeSource) { | 6716 base.focus = function (handler, excludeWysiwyg, excludeSource) { |
6799 if (isFunction(handler)) { | 6717 if (isFunction(handler)) { |
6800 base.bind('focus', handler, excludeWysiwyg, excludeSource); | 6718 base.bind('focus', handler, excludeWysiwyg, excludeSource); |
6845 * @param {boolean} excludeSource If to exclude adding this handler | 6763 * @param {boolean} excludeSource If to exclude adding this handler |
6846 * to the source editor | 6764 * to the source editor |
6847 * @return {this} | 6765 * @return {this} |
6848 * @function | 6766 * @function |
6849 * @name keyDown | 6767 * @name keyDown |
6850 * @memberOf SCEditor.prototype | |
6851 * @since 1.4.1 | 6768 * @since 1.4.1 |
6852 */ | 6769 */ |
6853 base.keyDown = function (handler, excludeWysiwyg, excludeSource) { | 6770 base.keyDown = function (handler, excludeWysiwyg, excludeSource) { |
6854 return base.bind('keydown', handler, excludeWysiwyg, excludeSource); | 6771 return base.bind('keydown', handler, excludeWysiwyg, excludeSource); |
6855 }; | 6772 }; |
6863 * @param {boolean} excludeSource If to exclude adding this handler | 6780 * @param {boolean} excludeSource If to exclude adding this handler |
6864 * to the source editor | 6781 * to the source editor |
6865 * @return {this} | 6782 * @return {this} |
6866 * @function | 6783 * @function |
6867 * @name keyPress | 6784 * @name keyPress |
6868 * @memberOf SCEditor.prototype | |
6869 * @since 1.4.1 | 6785 * @since 1.4.1 |
6870 */ | 6786 */ |
6871 base.keyPress = function (handler, excludeWysiwyg, excludeSource) { | 6787 base.keyPress = function (handler, excludeWysiwyg, excludeSource) { |
6872 return base | 6788 return base |
6873 .bind('keypress', handler, excludeWysiwyg, excludeSource); | 6789 .bind('keypress', handler, excludeWysiwyg, excludeSource); |
6882 * @param {boolean} excludeSource If to exclude adding this handler | 6798 * @param {boolean} excludeSource If to exclude adding this handler |
6883 * to the source editor | 6799 * to the source editor |
6884 * @return {this} | 6800 * @return {this} |
6885 * @function | 6801 * @function |
6886 * @name keyUp | 6802 * @name keyUp |
6887 * @memberOf SCEditor.prototype | |
6888 * @since 1.4.1 | 6803 * @since 1.4.1 |
6889 */ | 6804 */ |
6890 base.keyUp = function (handler, excludeWysiwyg, excludeSource) { | 6805 base.keyUp = function (handler, excludeWysiwyg, excludeSource) { |
6891 return base.bind('keyup', handler, excludeWysiwyg, excludeSource); | 6806 return base.bind('keyup', handler, excludeWysiwyg, excludeSource); |
6892 }; | 6807 }; |
6899 * | 6814 * |
6900 * @param {Function} handler | 6815 * @param {Function} handler |
6901 * @return {this} | 6816 * @return {this} |
6902 * @function | 6817 * @function |
6903 * @name nodeChanged | 6818 * @name nodeChanged |
6904 * @memberOf SCEditor.prototype | |
6905 * @since 1.4.1 | 6819 * @since 1.4.1 |
6906 */ | 6820 */ |
6907 base.nodeChanged = function (handler) { | 6821 base.nodeChanged = function (handler) { |
6908 return base.bind('nodechanged', handler, false, true); | 6822 return base.bind('nodechanged', handler, false, true); |
6909 }; | 6823 }; |
6915 * | 6829 * |
6916 * @param {Function} handler | 6830 * @param {Function} handler |
6917 * @return {this} | 6831 * @return {this} |
6918 * @function | 6832 * @function |
6919 * @name selectionChanged | 6833 * @name selectionChanged |
6920 * @memberOf SCEditor.prototype | |
6921 * @since 1.4.1 | 6834 * @since 1.4.1 |
6922 */ | 6835 */ |
6923 base.selectionChanged = function (handler) { | 6836 base.selectionChanged = function (handler) { |
6924 return base.bind('selectionchanged', handler, false, true); | 6837 return base.bind('selectionchanged', handler, false, true); |
6925 }; | 6838 }; |
6940 * @param {boolean} excludeSource If to exclude adding this handler | 6853 * @param {boolean} excludeSource If to exclude adding this handler |
6941 * to the source editor | 6854 * to the source editor |
6942 * @return {this} | 6855 * @return {this} |
6943 * @function | 6856 * @function |
6944 * @name valueChanged | 6857 * @name valueChanged |
6945 * @memberOf SCEditor.prototype | |
6946 * @since 1.4.5 | 6858 * @since 1.4.5 |
6947 */ | 6859 */ |
6948 base.valueChanged = function (handler, excludeWysiwyg, excludeSource) { | 6860 base.valueChanged = function (handler, excludeWysiwyg, excludeSource) { |
6949 return base | 6861 return base |
6950 .bind('valuechanged', handler, excludeWysiwyg, excludeSource); | 6862 .bind('valuechanged', handler, excludeWysiwyg, excludeSource); |
7008 /** | 6920 /** |
7009 * Gets if emoticons are currently enabled | 6921 * Gets if emoticons are currently enabled |
7010 * @return {boolean} | 6922 * @return {boolean} |
7011 * @function | 6923 * @function |
7012 * @name emoticons | 6924 * @name emoticons |
7013 * @memberOf SCEditor.prototype | |
7014 * @since 1.4.2 | 6925 * @since 1.4.2 |
7015 */ | 6926 */ |
7016 /** | 6927 /** |
7017 * Enables/disables emoticons | 6928 * Enables/disables emoticons |
7018 * | 6929 * |
7019 * @param {boolean} enable | 6930 * @param {boolean} enable |
7020 * @return {this} | 6931 * @return {this} |
7021 * @function | 6932 * @function |
7022 * @name emoticons^2 | 6933 * @name emoticons^2 |
7023 * @memberOf SCEditor.prototype | |
7024 * @since 1.4.2 | 6934 * @since 1.4.2 |
7025 */ | 6935 */ |
7026 base.emoticons = function (enable) { | 6936 base.emoticons = function (enable) { |
7027 if (!enable && enable !== false) { | 6937 if (!enable && enable !== false) { |
7028 return options.emoticonsEnabled; | 6938 return options.emoticonsEnabled; |
7061 * Gets the current WYSIWYG editors inline CSS | 6971 * Gets the current WYSIWYG editors inline CSS |
7062 * | 6972 * |
7063 * @return {string} | 6973 * @return {string} |
7064 * @function | 6974 * @function |
7065 * @name css | 6975 * @name css |
7066 * @memberOf SCEditor.prototype | |
7067 * @since 1.4.3 | 6976 * @since 1.4.3 |
7068 */ | 6977 */ |
7069 /** | 6978 /** |
7070 * Sets inline CSS for the WYSIWYG editor | 6979 * Sets inline CSS for the WYSIWYG editor |
7071 * | 6980 * |
7072 * @param {string} css | 6981 * @param {string} css |
7073 * @return {this} | 6982 * @return {this} |
7074 * @function | 6983 * @function |
7075 * @name css^2 | 6984 * @name css^2 |
7076 * @memberOf SCEditor.prototype | |
7077 * @since 1.4.3 | 6985 * @since 1.4.3 |
7078 */ | 6986 */ |
7079 base.css = function (css) { | 6987 base.css = function (css) { |
7080 if (!inlineCss) { | 6988 if (!inlineCss) { |
7081 inlineCss = createElement('style', { | 6989 inlineCss = createElement('style', { |