comparison src/sceditor.js @ 16:8bd52902156a

remove "this" from command functions
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 07 Aug 2022 21:41:55 -0600
parents ea930990b601
children a199722647d0
comparison
equal deleted inserted replaced
15:ea930990b601 16:8bd52902156a
1979 }, 1979 },
1980 // END_COMMAND 1980 // END_COMMAND
1981 1981
1982 // START_COMMAND: Left 1982 // START_COMMAND: Left
1983 left: { 1983 left: {
1984 state: function (node) { 1984 state: function (editor, node) {
1985 if (node && node.nodeType === 3) { 1985 if (node && node.nodeType === 3) {
1986 node = node.parentNode; 1986 node = node.parentNode;
1987 } 1987 }
1988 1988
1989 if (node) { 1989 if (node) {
2005 tooltip: 'Center' 2005 tooltip: 'Center'
2006 }, 2006 },
2007 // END_COMMAND 2007 // END_COMMAND
2008 // START_COMMAND: Right 2008 // START_COMMAND: Right
2009 right: { 2009 right: {
2010 state: function (node) { 2010 state: function (editor, node) {
2011 if (node && node.nodeType === 3) { 2011 if (node && node.nodeType === 3) {
2012 node = node.parentNode; 2012 node = node.parentNode;
2013 } 2013 }
2014 2014
2015 if (node) { 2015 if (node) {
2049 }, true)); 2049 }, true));
2050 }); 2050 });
2051 2051
2052 editor.createDropDown(caller, 'font-picker', content); 2052 editor.createDropDown(caller, 'font-picker', content);
2053 }, 2053 },
2054 exec: function (caller) { 2054 exec: function (editor,caller) {
2055 var editor = this;
2056
2057 defaultCmds.font._dropDown(editor, caller, function (fontName) { 2055 defaultCmds.font._dropDown(editor, caller, function (fontName) {
2058 editor.execCommand('fontname', fontName); 2056 editor.execCommand('fontname', fontName);
2059 }); 2057 });
2060 }, 2058 },
2061 tooltip: 'Font Name' 2059 tooltip: 'Font Name'
2078 }, true)); 2076 }, true));
2079 } 2077 }
2080 2078
2081 editor.createDropDown(caller, 'fontsize-picker', content); 2079 editor.createDropDown(caller, 'fontsize-picker', content);
2082 }, 2080 },
2083 exec: function (caller) { 2081 exec: function (editor,caller) {
2084 var editor = this;
2085
2086 defaultCmds.size._dropDown(editor, caller, function (fontSize) { 2082 defaultCmds.size._dropDown(editor, caller, function (fontSize) {
2087 editor.execCommand('fontsize', fontSize); 2083 editor.execCommand('fontsize', fontSize);
2088 }); 2084 });
2089 }, 2085 },
2090 tooltip: 'Font Size' 2086 tooltip: 'Font Size'
2122 e.preventDefault(); 2118 e.preventDefault();
2123 }); 2119 });
2124 2120
2125 editor.createDropDown(caller, 'color-picker', content); 2121 editor.createDropDown(caller, 'color-picker', content);
2126 }, 2122 },
2127 exec: function (caller) { 2123 exec: function (editor,caller) {
2128 var editor = this;
2129
2130 defaultCmds.color._dropDown(editor, caller, function (color) { 2124 defaultCmds.color._dropDown(editor, caller, function (color) {
2131 editor.execCommand('forecolor', color); 2125 editor.execCommand('forecolor', color);
2132 }); 2126 });
2133 }, 2127 },
2134 tooltip: 'Font Color' 2128 tooltip: 'Font Color'
2165 'Please use the keyboard shortcut Ctrl/Cmd-V' 2159 'Please use the keyboard shortcut Ctrl/Cmd-V'
2166 }, 2160 },
2167 // END_COMMAND 2161 // END_COMMAND
2168 // START_COMMAND: Paste Text 2162 // START_COMMAND: Paste Text
2169 pastetext: { 2163 pastetext: {
2170 exec: function (caller) { 2164 exec: function (editor,caller) {
2171 var val, 2165 var val,
2172 content = createElement('div'), 2166 content = createElement('div');
2173 editor = this;
2174 2167
2175 appendChild(content, _tmpl('pastetext', { 2168 appendChild(content, _tmpl('pastetext', {
2176 label: editor._( 2169 label: editor._(
2177 'Paste your text inside the following box:' 2170 'Paste your text inside the following box:'
2178 ), 2171 ),
2195 tooltip: 'Paste Text' 2188 tooltip: 'Paste Text'
2196 }, 2189 },
2197 // END_COMMAND 2190 // END_COMMAND
2198 // START_COMMAND: Bullet List 2191 // START_COMMAND: Bullet List
2199 bulletlist: { 2192 bulletlist: {
2200 exec: function () { 2193 exec: function (editor) {
2201 fixFirefoxListBug(this); 2194 fixFirefoxListBug(editor);
2202 this.execCommand('insertunorderedlist'); 2195 editor.execCommand('insertunorderedlist');
2203 }, 2196 },
2204 tooltip: 'Bullet list' 2197 tooltip: 'Bullet list'
2205 }, 2198 },
2206 // END_COMMAND 2199 // END_COMMAND
2207 // START_COMMAND: Ordered List 2200 // START_COMMAND: Ordered List
2208 orderedlist: { 2201 orderedlist: {
2209 exec: function () { 2202 exec: function (editor) {
2210 fixFirefoxListBug(this); 2203 fixFirefoxListBug(editor);
2211 this.execCommand('insertorderedlist'); 2204 editor.execCommand('insertorderedlist');
2212 }, 2205 },
2213 tooltip: 'Numbered list' 2206 tooltip: 'Numbered list'
2214 }, 2207 },
2215 // END_COMMAND 2208 // END_COMMAND
2216 // START_COMMAND: Indent 2209 // START_COMMAND: Indent
2217 indent: { 2210 indent: {
2218 state: function (parent, firstBlock) { 2211 state: function (editor, parent, firstBlock) {
2219 // Only works with lists, for now 2212 // Only works with lists, for now
2220 var range, startParent, endParent; 2213 var range, startParent, endParent;
2221 2214
2222 if (is(firstBlock, 'li')) { 2215 if (is(firstBlock, 'li')) {
2223 return 0; 2216 return 0;
2247 } 2240 }
2248 } 2241 }
2249 2242
2250 return -1; 2243 return -1;
2251 }, 2244 },
2252 exec: function () { 2245 exec: function (editor) {
2253 var editor = this, 2246 var block = editor.getRangeHelper().getFirstBlockParent();
2254 block = editor.getRangeHelper().getFirstBlockParent();
2255 2247
2256 editor.focus(); 2248 editor.focus();
2257 2249
2258 // An indent system is quite complicated as there are loads 2250 // An indent system is quite complicated as there are loads
2259 // of complications and issues around how to indent text 2251 // of complications and issues around how to indent text
2266 tooltip: 'Add indent' 2258 tooltip: 'Add indent'
2267 }, 2259 },
2268 // END_COMMAND 2260 // END_COMMAND
2269 // START_COMMAND: Outdent 2261 // START_COMMAND: Outdent
2270 outdent: { 2262 outdent: {
2271 state: function (parents, firstBlock) { 2263 state: function (editor, parents, firstBlock) {
2272 return closest(firstBlock, 'ul,ol,menu') ? 0 : -1; 2264 return closest(firstBlock, 'ul,ol,menu') ? 0 : -1;
2273 }, 2265 },
2274 exec: function () { 2266 exec: function (editor) {
2275 var block = this.getRangeHelper().getFirstBlockParent(); 2267 var block = editor.getRangeHelper().getFirstBlockParent();
2276 if (closest(block, 'ul,ol,menu')) { 2268 if (closest(block, 'ul,ol,menu')) {
2277 this.execCommand('outdent'); 2269 editor.execCommand('outdent');
2278 } 2270 }
2279 }, 2271 },
2280 tooltip: 'Remove one indent' 2272 tooltip: 'Remove one indent'
2281 }, 2273 },
2282 // END_COMMAND 2274 // END_COMMAND
2283 2275
2284 // START_COMMAND: Table 2276 // START_COMMAND: Table
2285 table: { 2277 table: {
2286 exec: function (caller) { 2278 exec: function (editor,caller) {
2287 var editor = this, 2279 var content = createElement('div');
2288 content = createElement('div');
2289 2280
2290 appendChild(content, _tmpl('table', { 2281 appendChild(content, _tmpl('table', {
2291 rows: editor._('Rows:'), 2282 rows: editor._('Rows:'),
2292 cols: editor._('Cols:'), 2283 cols: editor._('Cols:'),
2293 insert: editor._('Insert') 2284 insert: editor._('Insert')
2328 }, 2319 },
2329 // END_COMMAND 2320 // END_COMMAND
2330 2321
2331 // START_COMMAND: Code 2322 // START_COMMAND: Code
2332 code: { 2323 code: {
2333 exec: function () { 2324 exec: function (editor) {
2334 this.wysiwygEditorInsertHtml( 2325 editor.wysiwygEditorInsertHtml(
2335 '<code>', 2326 '<code>',
2336 '<br /></code>' 2327 '<br /></code>'
2337 ); 2328 );
2338 }, 2329 },
2339 tooltip: 'Code' 2330 tooltip: 'Code'
2370 e.preventDefault(); 2361 e.preventDefault();
2371 }); 2362 });
2372 2363
2373 editor.createDropDown(caller, 'insertimage', content); 2364 editor.createDropDown(caller, 'insertimage', content);
2374 }, 2365 },
2375 exec: function (caller) { 2366 exec: function (editor,caller) {
2376 var editor = this;
2377
2378 defaultCmds.image._dropDown( 2367 defaultCmds.image._dropDown(
2379 editor, 2368 editor,
2380 caller, 2369 caller,
2381 '', 2370 '',
2382 function (url, width, height) { 2371 function (url, width, height) {
2424 e.preventDefault(); 2413 e.preventDefault();
2425 }); 2414 });
2426 2415
2427 editor.createDropDown(caller, 'insertemail', content); 2416 editor.createDropDown(caller, 'insertemail', content);
2428 }, 2417 },
2429 exec: function (caller) { 2418 exec: function (editor,caller) {
2430 var editor = this;
2431
2432 defaultCmds.email._dropDown( 2419 defaultCmds.email._dropDown(
2433 editor, 2420 editor,
2434 caller, 2421 caller,
2435 function (email, text) { 2422 function (email, text) {
2436 if (!editor.getRangeHelper().selectedHtml() || text) { 2423 if (!editor.getRangeHelper().selectedHtml() || text) {
2480 } 2467 }
2481 }, EVENT_CAPTURE); 2468 }, EVENT_CAPTURE);
2482 2469
2483 editor.createDropDown(caller, 'insertlink', content); 2470 editor.createDropDown(caller, 'insertlink', content);
2484 }, 2471 },
2485 exec: function (caller) { 2472 exec: function (editor,caller) {
2486 var editor = this;
2487
2488 defaultCmds.link._dropDown(editor, caller, function (url, text) { 2473 defaultCmds.link._dropDown(editor, caller, function (url, text) {
2489 if (text || !editor.getRangeHelper().selectedHtml()) { 2474 if (text || !editor.getRangeHelper().selectedHtml()) {
2490 editor.wysiwygEditorInsertHtml( 2475 editor.wysiwygEditorInsertHtml(
2491 '<a href="' + entities(url) + '">' + 2476 '<a href="' + entities(url) + '">' +
2492 entities(text || url) + 2477 entities(text || url) +
2501 }, 2486 },
2502 // END_COMMAND 2487 // END_COMMAND
2503 2488
2504 // START_COMMAND: Unlink 2489 // START_COMMAND: Unlink
2505 unlink: { 2490 unlink: {
2506 state: function () { 2491 state: function (editor) {
2507 return closest(this.currentNode(), 'a') ? 0 : -1; 2492 return closest(editor.currentNode(), 'a') ? 0 : -1;
2508 }, 2493 },
2509 exec: function () { 2494 exec: function (editor) {
2510 var anchor = closest(this.currentNode(), 'a'); 2495 var anchor = closest(editor.currentNode(), 'a');
2511 2496
2512 if (anchor) { 2497 if (anchor) {
2513 while (anchor.firstChild) { 2498 while (anchor.firstChild) {
2514 insertBefore(anchor.firstChild, anchor); 2499 insertBefore(anchor.firstChild, anchor);
2515 } 2500 }
2522 // END_COMMAND 2507 // END_COMMAND
2523 2508
2524 2509
2525 // START_COMMAND: Quote 2510 // START_COMMAND: Quote
2526 quote: { 2511 quote: {
2527 exec: function (caller, html, author) { 2512 exec: function (editor, caller, html, author) {
2528 var before = '<blockquote>', 2513 var before = '<blockquote>',
2529 end = '</blockquote>'; 2514 end = '</blockquote>';
2530 2515
2531 // if there is HTML passed set end to null so any selected 2516 // if there is HTML passed set end to null so any selected
2532 // text is replaced 2517 // text is replaced
2535 entities(author) + 2520 entities(author) +
2536 '</cite>' : ''); 2521 '</cite>' : '');
2537 before = before + author + html + end; 2522 before = before + author + html + end;
2538 end = null; 2523 end = null;
2539 // if not add a newline to the end of the inserted quote 2524 // if not add a newline to the end of the inserted quote
2540 } else if (this.getRangeHelper().selectedHtml() === '') { 2525 } else if (editor.getRangeHelper().selectedHtml() === '') {
2541 end = '<br />' + end; 2526 end = '<br />' + end;
2542 } 2527 }
2543 2528
2544 this.wysiwygEditorInsertHtml(before, end); 2529 editor.wysiwygEditorInsertHtml(before, end);
2545 }, 2530 },
2546 tooltip: 'Insert a Quote' 2531 tooltip: 'Insert a Quote'
2547 }, 2532 },
2548 // END_COMMAND 2533 // END_COMMAND
2549 2534
2550 // START_COMMAND: Emoticons 2535 // START_COMMAND: Emoticons
2551 emoticon: { 2536 emoticon: {
2552 exec: function (caller) { 2537 exec: function (editor, caller) {
2553 var editor = this;
2554
2555 var createContent = function (includeMore) { 2538 var createContent = function (includeMore) {
2556 var moreLink, 2539 var moreLink,
2557 opts = editor.opts, 2540 opts = editor.opts,
2558 emoticonsRoot = opts.emoticonsRoot || '', 2541 emoticonsRoot = opts.emoticonsRoot || '',
2559 emoticonsCompat = opts.emoticonsCompat, 2542 emoticonsCompat = opts.emoticonsCompat,
2617 return content; 2600 return content;
2618 }; 2601 };
2619 2602
2620 editor.createDropDown(caller, 'emoticons', createContent(false)); 2603 editor.createDropDown(caller, 'emoticons', createContent(false));
2621 }, 2604 },
2622 txtExec: function (caller) { 2605 txtExec: function (editor, caller) {
2623 defaultCmds.emoticon.exec.call(this, caller); 2606 defaultCmds.emoticon.exec(editor, caller);
2624 }, 2607 },
2625 tooltip: 'Insert an emoticon' 2608 tooltip: 'Insert an emoticon'
2626 }, 2609 },
2627 // END_COMMAND 2610 // END_COMMAND
2628 2611
2658 e.preventDefault(); 2641 e.preventDefault();
2659 }); 2642 });
2660 2643
2661 editor.createDropDown(caller, 'insertlink', content); 2644 editor.createDropDown(caller, 'insertlink', content);
2662 }, 2645 },
2663 exec: function (btn) { 2646 exec: function (editor, btn) {
2664 var editor = this;
2665
2666 defaultCmds.youtube._dropDown(editor, btn, function (id, time) { 2647 defaultCmds.youtube._dropDown(editor, btn, function (id, time) {
2667 editor.wysiwygEditorInsertHtml(_tmpl('youtube', { 2648 editor.wysiwygEditorInsertHtml(_tmpl('youtube', {
2668 id: id, 2649 id: id,
2669 time: time 2650 time: time
2670 })); 2651 }));
2697 return editor.opts.dateFormat 2678 return editor.opts.dateFormat
2698 .replace(/year/i, year) 2679 .replace(/year/i, year)
2699 .replace(/month/i, month) 2680 .replace(/month/i, month)
2700 .replace(/day/i, day); 2681 .replace(/day/i, day);
2701 }, 2682 },
2702 exec: function () { 2683 exec: function (editor) {
2703 this.insertText(defaultCmds.date._date(this)); 2684 editor.insertText(defaultCmds.date._date(editor));
2704 }, 2685 },
2705 txtExec: function () { 2686 txtExec: function (editor) {
2706 this.insertText(defaultCmds.date._date(this)); 2687 defaultCmds.date.exec(editor);
2707 }, 2688 },
2708 tooltip: 'Insert current date' 2689 tooltip: 'Insert current date'
2709 }, 2690 },
2710 // END_COMMAND 2691 // END_COMMAND
2711 2692
2729 secs = '0' + secs; 2710 secs = '0' + secs;
2730 } 2711 }
2731 2712
2732 return hours + ':' + mins + ':' + secs; 2713 return hours + ':' + mins + ':' + secs;
2733 }, 2714 },
2734 exec: function () { 2715 exec: function (editor) {
2735 this.insertText(defaultCmds.time._time()); 2716 editor.insertText(defaultCmds.time._time());
2736 }, 2717 },
2737 txtExec: function () { 2718 txtExec: function (editor) {
2738 this.insertText(defaultCmds.time._time()); 2719 defaultCmds.time.exec(editor);
2739 }, 2720 },
2740 tooltip: 'Insert current time' 2721 tooltip: 'Insert current time'
2741 }, 2722 },
2742 // END_COMMAND 2723 // END_COMMAND
2743 2724
2744 2725
2745 // START_COMMAND: Ltr 2726 // START_COMMAND: Ltr
2746 ltr: { 2727 ltr: {
2747 state: function (parents, firstBlock) { 2728 state: function (editor, parents, firstBlock) {
2748 return firstBlock && firstBlock.style.direction === 'ltr'; 2729 return firstBlock && firstBlock.style.direction === 'ltr';
2749 }, 2730 },
2750 exec: function () { 2731 exec: function (editor) {
2751 var editor = this, 2732 var rangeHelper = editor.getRangeHelper(),
2752 rangeHelper = editor.getRangeHelper(),
2753 node = rangeHelper.getFirstBlockParent(); 2733 node = rangeHelper.getFirstBlockParent();
2754 2734
2755 editor.focus(); 2735 editor.focus();
2756 2736
2757 if (!node || is(node, 'body')) { 2737 if (!node || is(node, 'body')) {
2771 }, 2751 },
2772 // END_COMMAND 2752 // END_COMMAND
2773 2753
2774 // START_COMMAND: Rtl 2754 // START_COMMAND: Rtl
2775 rtl: { 2755 rtl: {
2776 state: function (parents, firstBlock) { 2756 state: function (editor, parents, firstBlock) {
2777 return firstBlock && firstBlock.style.direction === 'rtl'; 2757 return firstBlock && firstBlock.style.direction === 'rtl';
2778 }, 2758 },
2779 exec: function () { 2759 exec: function (editor) {
2780 var editor = this, 2760 var rangeHelper = editor.getRangeHelper(),
2781 rangeHelper = editor.getRangeHelper(),
2782 node = rangeHelper.getFirstBlockParent(); 2761 node = rangeHelper.getFirstBlockParent();
2783 2762
2784 editor.focus(); 2763 editor.focus();
2785 2764
2786 if (!node || is(node, 'body')) { 2765 if (!node || is(node, 'body')) {
2808 }, 2787 },
2809 // END_COMMAND 2788 // END_COMMAND
2810 2789
2811 // START_COMMAND: Maximize 2790 // START_COMMAND: Maximize
2812 maximize: { 2791 maximize: {
2813 state: function () { 2792 state: function (editor) {
2814 return this.maximize(); 2793 return editor.maximize();
2815 }, 2794 },
2816 exec: function () { 2795 exec: function (editor) {
2817 this.maximize(!this.maximize()); 2796 editor.maximize(!editor.maximize());
2818 this.focus(); 2797 editor.focus();
2819 }, 2798 },
2820 txtExec: function () { 2799 txtExec: function () {
2821 this.maximize(!this.maximize()); 2800 defaultCmds.maximize.exec(editor);
2822 this.focus();
2823 }, 2801 },
2824 tooltip: 'Maximize', 2802 tooltip: 'Maximize',
2825 shortcut: 'Ctrl+Shift+M' 2803 shortcut: 'Ctrl+Shift+M'
2826 }, 2804 },
2827 // END_COMMAND 2805 // END_COMMAND
2828 2806
2829 // START_COMMAND: Source 2807 // START_COMMAND: Source
2830 source: { 2808 source: {
2831 state: function () { 2809 state: function (editor) {
2832 return this.sourceMode(); 2810 return editor.sourceMode();
2833 }, 2811 },
2834 exec: function () { 2812 exec: function (editor) {
2835 this.toggleSourceMode(); 2813 editor.toggleSourceMode();
2836 this.focus(); 2814 editor.focus();
2837 }, 2815 },
2838 txtExec: function () { 2816 txtExec: function (editor) {
2839 this.toggleSourceMode(); 2817 defaultCmds.source.exec(editor);
2840 this.focus();
2841 }, 2818 },
2842 tooltip: 'View source', 2819 tooltip: 'View source',
2843 shortcut: 'Ctrl+Shift+S' 2820 shortcut: 'Ctrl+Shift+S'
2844 }, 2821 },
2845 // END_COMMAND 2822 // END_COMMAND
6158 } 6135 }
6159 6136
6160 let iconName = command.icon || commandName 6137 let iconName = command.icon || commandName
6161 let shortcut = command.shortcut; 6138 let shortcut = command.shortcut;
6162 let button = _tmpl('toolbarButton', { 6139 let button = _tmpl('toolbarButton', {
6140 name: commandName,
6163 iconName: iconName, 6141 iconName: iconName,
6164 name: commandName,
6165 dispName: base._(command.name || 6142 dispName: base._(command.name ||
6166 command.tooltip || commandName) 6143 command.tooltip || commandName)
6167 }, true).firstChild; 6144 }, true).firstChild;
6168 6145
6169 if (icons.create) { 6146 if (icons.create) {
7684 if (base.inSourceMode()) { 7661 if (base.inSourceMode()) {
7685 if (cmd.txtExec) { 7662 if (cmd.txtExec) {
7686 if (Array.isArray(cmd.txtExec)) { 7663 if (Array.isArray(cmd.txtExec)) {
7687 base.sourceEditorInsertText.apply(base, cmd.txtExec); 7664 base.sourceEditorInsertText.apply(base, cmd.txtExec);
7688 } else { 7665 } else {
7689 cmd.txtExec.call(base, caller, sourceEditorSelectedText()); 7666 cmd.txtExec(base, caller, sourceEditorSelectedText());
7690 } 7667 }
7691 } 7668 }
7692 } else if (cmd.exec) { 7669 } else if (cmd.exec) {
7693 if (isFunction(cmd.exec)) { 7670 if (isFunction(cmd.exec)) {
7694 cmd.exec.call(base, caller); 7671 cmd.exec(base, caller);
7695 } else { 7672 } else {
7696 base.execCommand( 7673 base.execCommand(
7697 cmd.exec, 7674 cmd.exec,
7698 cmd.hasOwnProperty('execParam') ? cmd.execParam : null 7675 cmd.hasOwnProperty('execParam') ? cmd.execParam : null
7699 ); 7676 );
7889 state = doc.queryCommandState(stateFn) ? 1 : 0; 7866 state = doc.queryCommandState(stateFn) ? 1 : 0;
7890 } 7867 }
7891 } catch (ex) {} 7868 } catch (ex) {}
7892 } 7869 }
7893 } else if (!isDisabled) { 7870 } else if (!isDisabled) {
7894 state = stateFn.call(base, parent, firstBlock); 7871 state = stateFn(base, parent, firstBlock);
7895 } 7872 }
7896 7873
7897 toggleClass(btn, 'disabled', isDisabled || state < 0); 7874 toggleClass(btn, 'disabled', isDisabled || state < 0);
7898 toggleClass(btn, 'active', state > 0); 7875 toggleClass(btn, 'active', state > 0);
7899 } 7876 }
8971 * } 8948 * }
8972 * }); 8949 * });
8973 * 8950 *
8974 * @param {string} name 8951 * @param {string} name
8975 * @param {Object} cmd 8952 * @param {Object} cmd
8976 * @return {this|false} Returns false if name or cmd is false 8953 * @return {true|false} Returns false if name or cmd is false
8977 * @since v1.3.5 8954 * @since v1.3.5
8978 */ 8955 */
8979 set: function (name, cmd) { 8956 set: function (name, cmd) {
8980 if (!name || !cmd) { 8957 if (!name || !cmd) {
8981 return false; 8958 return false;
8987 cmd.remove = function () { 8964 cmd.remove = function () {
8988 SCEditor.command.remove(name); 8965 SCEditor.command.remove(name);
8989 }; 8966 };
8990 8967
8991 defaultCmds[name] = cmd; 8968 defaultCmds[name] = cmd;
8992 return this; 8969 return true;
8993 }, 8970 },
8994 8971
8995 /** 8972 /**
8996 * Removes a command 8973 * Removes a command
8997 * 8974 *
8998 * @param {string} name 8975 * @param {string} name
8999 * @return {this}
9000 * @since v1.3.5 8976 * @since v1.3.5
9001 */ 8977 */
9002 remove: function (name) { 8978 remove: function (name) {
9003 if (defaultCmds[name]) { 8979 if (defaultCmds[name]) {
9004 delete defaultCmds[name]; 8980 delete defaultCmds[name];
9005 } 8981 }
9006
9007 return this;
9008 } 8982 }
9009 }; 8983 };
9010 8984
9011 /** 8985 /**
9012 * SCEditor 8986 * SCEditor