comparison src/sceditor.js @ 38:2dfdaaac9482

simplify icons
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 18 Aug 2022 21:36:34 -0600
parents 0c4e4b5ef40d
children 9f63c8f506d1
comparison
equal deleted inserted replaced
37:0c4e4b5ef40d 38:2dfdaaac9482
1805 '<link rel="stylesheet" type="text/css" href="{style}" />' + 1805 '<link rel="stylesheet" type="text/css" href="{style}" />' +
1806 '</head>' + 1806 '</head>' +
1807 '<body contenteditable="true" {spellcheck}><p></p></body>' + 1807 '<body contenteditable="true" {spellcheck}><p></p></body>' +
1808 '</html>', 1808 '</html>',
1809 1809
1810 toolbarButton: '<a class="sceditor-button sceditor-button-{iconName}" ' + 1810
1811 toolbarButton: '<a class="sceditor-button" ' +
1811 'data-sceditor-command="{name}" unselectable="on">' + 1812 'data-sceditor-command="{name}" unselectable="on">' +
1812 '<div unselectable="on">{dispName}</div></a>', 1813 '{icon}</a>',
1813 1814
1814 emoticon: '<img src="{url}" data-sceditor-emoticon="{key}" ' + 1815 emoticon: '<img src="{url}" data-sceditor-emoticon="{key}" ' +
1815 'alt="{key}" title="{tooltip}" />', 1816 'alt="{key}" title="{tooltip}" />',
1816 1817
1817 fontOpt: '<a class="sceditor-font-option" href="#" ' + 1818 fontOpt: '<a class="sceditor-font-option" href="#" ' +
1937 } 1938 }
1938 } 1939 }
1939 } 1940 }
1940 1941
1941 1942
1943 function material(png) {
1944 return '<img src="' + baseUrl + 'icons/material/' + png + '" width=18 height=18>';
1945 }
1946
1942 /** 1947 /**
1943 * Map of all the commands for SCEditor 1948 * Map of all the commands for SCEditor
1944 * @type {Object} 1949 * @type {Object}
1945 * @name commands 1950 * @name commands
1946 * @memberOf jQuery.sceditor
1947 */ 1951 */
1948 var defaultCmds = { 1952 var defaultCmds = {
1949 // START_COMMAND: Bold 1953 // START_COMMAND: Bold
1950 bold: { 1954 bold: {
1951 exec: 'bold', 1955 exec: 'bold',
1952 tooltip: 'Bold', 1956 tooltip: 'Bold',
1953 shortcut: 'Ctrl+B' 1957 shortcut: 'Ctrl+B',
1958 icon: material('format-bold.png'),
1954 }, 1959 },
1955 // END_COMMAND 1960 // END_COMMAND
1956 // START_COMMAND: Italic 1961 // START_COMMAND: Italic
1957 italic: { 1962 italic: {
1958 exec: 'italic', 1963 exec: 'italic',
1959 tooltip: 'Italic', 1964 tooltip: 'Italic',
1960 shortcut: 'Ctrl+I' 1965 shortcut: 'Ctrl+I',
1966 icon: material('format-italic.png'),
1961 }, 1967 },
1962 // END_COMMAND 1968 // END_COMMAND
1963 // START_COMMAND: Underline 1969 // START_COMMAND: Underline
1964 underline: { 1970 underline: {
1965 exec: 'underline', 1971 exec: 'underline',
1966 tooltip: 'Underline', 1972 tooltip: 'Underline',
1967 shortcut: 'Ctrl+U' 1973 shortcut: 'Ctrl+U',
1974 icon: material('format-underline.png'),
1968 }, 1975 },
1969 // END_COMMAND 1976 // END_COMMAND
1970 // START_COMMAND: Strikethrough 1977 // START_COMMAND: Strikethrough
1971 strike: { 1978 strike: {
1972 exec: 'strikethrough', 1979 exec: 'strikethrough',
1973 tooltip: 'Strikethrough' 1980 tooltip: 'Strikethrough',
1981 icon: material('format-strikethrough.png'),
1974 }, 1982 },
1975 // END_COMMAND 1983 // END_COMMAND
1976 // START_COMMAND: Subscript 1984 // START_COMMAND: Subscript
1977 subscript: { 1985 subscript: {
1978 exec: 'subscript', 1986 exec: 'subscript',
1979 tooltip: 'Subscript' 1987 tooltip: 'Subscript',
1988 icon: material('format-subscript.png'),
1980 }, 1989 },
1981 // END_COMMAND 1990 // END_COMMAND
1982 // START_COMMAND: Superscript 1991 // START_COMMAND: Superscript
1983 superscript: { 1992 superscript: {
1984 exec: 'superscript', 1993 exec: 'superscript',
1985 tooltip: 'Superscript' 1994 tooltip: 'Superscript',
1995 icon: material('format-superscript.png'),
1986 }, 1996 },
1987 // END_COMMAND 1997 // END_COMMAND
1988 1998
1989 // START_COMMAND: Left 1999 // START_COMMAND: Left
1990 left: { 2000 left: {
2001 return /left/.test(align) || 2011 return /left/.test(align) ||
2002 align === (isLtr ? 'start' : 'end'); 2012 align === (isLtr ? 'start' : 'end');
2003 } 2013 }
2004 }, 2014 },
2005 exec: 'justifyleft', 2015 exec: 'justifyleft',
2006 tooltip: 'Align left' 2016 tooltip: 'Align left',
2017 icon: material('format-align-left.png'),
2007 }, 2018 },
2008 // END_COMMAND 2019 // END_COMMAND
2009 // START_COMMAND: Centre 2020 // START_COMMAND: Centre
2010 center: { 2021 center: {
2011 exec: 'justifycenter', 2022 exec: 'justifycenter',
2012 tooltip: 'Center' 2023 tooltip: 'Center',
2024 icon: material('format-align-center.png'),
2013 }, 2025 },
2014 // END_COMMAND 2026 // END_COMMAND
2015 // START_COMMAND: Right 2027 // START_COMMAND: Right
2016 right: { 2028 right: {
2017 state: function (editor, node) { 2029 state: function (editor, node) {
2027 return /right/.test(align) || 2039 return /right/.test(align) ||
2028 align === (isLtr ? 'end' : 'start'); 2040 align === (isLtr ? 'end' : 'start');
2029 } 2041 }
2030 }, 2042 },
2031 exec: 'justifyright', 2043 exec: 'justifyright',
2032 tooltip: 'Align right' 2044 tooltip: 'Align right',
2045 icon: material('format-align-right.png'),
2033 }, 2046 },
2034 // END_COMMAND 2047 // END_COMMAND
2035 // START_COMMAND: Justify 2048 // START_COMMAND: Justify
2036 justify: { 2049 justify: {
2037 exec: 'justifyfull', 2050 exec: 'justifyfull',
2038 tooltip: 'Justify' 2051 tooltip: 'Justify',
2052 icon: material('format-align-justify.png'),
2039 }, 2053 },
2040 // END_COMMAND 2054 // END_COMMAND
2041 2055
2042 // START_COMMAND: Font 2056 // START_COMMAND: Font
2043 font: { 2057 font: {
2061 exec: function (editor, caller) { 2075 exec: function (editor, caller) {
2062 defaultCmds.font._dropDown(editor, caller, function (fontName) { 2076 defaultCmds.font._dropDown(editor, caller, function (fontName) {
2063 editor.execCommand('fontname', fontName); 2077 editor.execCommand('fontname', fontName);
2064 }); 2078 });
2065 }, 2079 },
2066 tooltip: 'Font Name' 2080 tooltip: 'Font Name',
2081 icon: material('format-font.png'),
2067 }, 2082 },
2068 // END_COMMAND 2083 // END_COMMAND
2069 // START_COMMAND: Size 2084 // START_COMMAND: Size
2070 size: { 2085 size: {
2071 _dropDown: function (editor, caller, callback) { 2086 _dropDown: function (editor, caller, callback) {
2088 exec: function (editor, caller) { 2103 exec: function (editor, caller) {
2089 defaultCmds.size._dropDown(editor, caller, function (fontSize) { 2104 defaultCmds.size._dropDown(editor, caller, function (fontSize) {
2090 editor.execCommand('fontsize', fontSize); 2105 editor.execCommand('fontsize', fontSize);
2091 }); 2106 });
2092 }, 2107 },
2093 tooltip: 'Font Size' 2108 tooltip: 'Font Size',
2109 icon: material('format-size.png'),
2094 }, 2110 },
2095 // END_COMMAND 2111 // END_COMMAND
2096 // START_COMMAND: Colour 2112 // START_COMMAND: Colour
2097 color: { 2113 color: {
2098 _dropDown: function (editor, caller, callback) { 2114 _dropDown: function (editor, caller, callback) {
2130 exec: function (editor, caller) { 2146 exec: function (editor, caller) {
2131 defaultCmds.color._dropDown(editor, caller, function (color) { 2147 defaultCmds.color._dropDown(editor, caller, function (color) {
2132 editor.execCommand('forecolor', color); 2148 editor.execCommand('forecolor', color);
2133 }); 2149 });
2134 }, 2150 },
2135 tooltip: 'Font Color' 2151 tooltip: 'Font Color',
2152 icon: material('palette.png'),
2136 }, 2153 },
2137 // END_COMMAND 2154 // END_COMMAND
2138 // START_COMMAND: Remove Format 2155 // START_COMMAND: Remove Format
2139 removeformat: { 2156 removeformat: {
2140 exec: 'removeformat', 2157 exec: 'removeformat',
2141 tooltip: 'Remove Formatting' 2158 tooltip: 'Remove Formatting',
2159 icon: material('format-clear.png'),
2142 }, 2160 },
2143 // END_COMMAND 2161 // END_COMMAND
2144 2162
2145 // START_COMMAND: Cut 2163 // START_COMMAND: Cut
2146 cut: { 2164 cut: {
2147 exec: 'cut', 2165 exec: 'cut',
2148 tooltip: 'Cut', 2166 tooltip: 'Cut',
2149 errorMessage: 'Your browser does not allow the cut command. ' + 2167 errorMessage: 'Your browser does not allow the cut command. ' +
2150 'Please use the keyboard shortcut Ctrl/Cmd-X' 2168 'Please use the keyboard shortcut Ctrl/Cmd-X',
2169 icon: material('content-cut.png'),
2151 }, 2170 },
2152 // END_COMMAND 2171 // END_COMMAND
2153 // START_COMMAND: Copy 2172 // START_COMMAND: Copy
2154 copy: { 2173 copy: {
2155 exec: 'copy', 2174 exec: 'copy',
2156 tooltip: 'Copy', 2175 tooltip: 'Copy',
2157 errorMessage: 'Your browser does not allow the copy command. ' + 2176 errorMessage: 'Your browser does not allow the copy command. ' +
2158 'Please use the keyboard shortcut Ctrl/Cmd-C' 2177 'Please use the keyboard shortcut Ctrl/Cmd-C',
2178 icon: material('content-copy.png'),
2159 }, 2179 },
2160 // END_COMMAND 2180 // END_COMMAND
2161 // START_COMMAND: Paste 2181 // START_COMMAND: Paste
2162 paste: { 2182 paste: {
2163 exec: 'paste', 2183 exec: 'paste',
2164 tooltip: 'Paste', 2184 tooltip: 'Paste',
2165 errorMessage: 'Your browser does not allow the paste command. ' + 2185 errorMessage: 'Your browser does not allow the paste command. ' +
2166 'Please use the keyboard shortcut Ctrl/Cmd-V' 2186 'Please use the keyboard shortcut Ctrl/Cmd-V',
2187 icon: material('content-paste.png'),
2167 }, 2188 },
2168 // END_COMMAND 2189 // END_COMMAND
2169 // START_COMMAND: Paste Text 2190 // START_COMMAND: Paste Text
2170 pastetext: { 2191 pastetext: {
2171 exec: function (editor, caller) { 2192 exec: function (editor, caller) {
2190 e.preventDefault(); 2211 e.preventDefault();
2191 }); 2212 });
2192 2213
2193 editor.createDropDown(caller, 'pastetext', content); 2214 editor.createDropDown(caller, 'pastetext', content);
2194 }, 2215 },
2195 tooltip: 'Paste Text' 2216 tooltip: 'Paste Text',
2217 icon: material('content-paste.png'),
2196 }, 2218 },
2197 // END_COMMAND 2219 // END_COMMAND
2198 // START_COMMAND: Bullet List 2220 // START_COMMAND: Bullet List
2199 bulletlist: { 2221 bulletlist: {
2200 exec: function (editor) { 2222 exec: function (editor) {
2201 fixFirefoxListBug(editor); 2223 fixFirefoxListBug(editor);
2202 editor.execCommand('insertunorderedlist'); 2224 editor.execCommand('insertunorderedlist');
2203 }, 2225 },
2204 tooltip: 'Bullet list' 2226 tooltip: 'Bullet list',
2227 icon: material('format-list-bulleted.png'),
2205 }, 2228 },
2206 // END_COMMAND 2229 // END_COMMAND
2207 // START_COMMAND: Ordered List 2230 // START_COMMAND: Ordered List
2208 orderedlist: { 2231 orderedlist: {
2209 exec: function (editor) { 2232 exec: function (editor) {
2210 fixFirefoxListBug(editor); 2233 fixFirefoxListBug(editor);
2211 editor.execCommand('insertorderedlist'); 2234 editor.execCommand('insertorderedlist');
2212 }, 2235 },
2213 tooltip: 'Numbered list' 2236 tooltip: 'Numbered list',
2237 icon: material('format-list-numbered.png'),
2214 }, 2238 },
2215 // END_COMMAND 2239 // END_COMMAND
2216 // START_COMMAND: Indent 2240 // START_COMMAND: Indent
2217 indent: { 2241 indent: {
2218 state: function (editor, parent, firstBlock) { 2242 state: function (editor, parent, firstBlock) {
2260 // at least, for now. 2284 // at least, for now.
2261 if (closest(block, 'ul,ol,menu')) { 2285 if (closest(block, 'ul,ol,menu')) {
2262 editor.execCommand('indent'); 2286 editor.execCommand('indent');
2263 } 2287 }
2264 }, 2288 },
2265 tooltip: 'Add indent' 2289 tooltip: 'Add indent',
2290 icon: material('format-indent-increase.png'),
2266 }, 2291 },
2267 // END_COMMAND 2292 // END_COMMAND
2268 // START_COMMAND: Outdent 2293 // START_COMMAND: Outdent
2269 outdent: { 2294 outdent: {
2270 state: function (editor, parents, firstBlock) { 2295 state: function (editor, parents, firstBlock) {
2274 var block = editor.getRangeHelper().getFirstBlockParent(); 2299 var block = editor.getRangeHelper().getFirstBlockParent();
2275 if (closest(block, 'ul,ol,menu')) { 2300 if (closest(block, 'ul,ol,menu')) {
2276 editor.execCommand('outdent'); 2301 editor.execCommand('outdent');
2277 } 2302 }
2278 }, 2303 },
2279 tooltip: 'Remove one indent' 2304 tooltip: 'Remove one indent',
2305 icon: material('format-indent-decrease.png'),
2280 }, 2306 },
2281 // END_COMMAND 2307 // END_COMMAND
2282 2308
2283 // START_COMMAND: Table 2309 // START_COMMAND: Table
2284 table: { 2310 table: {
2313 } 2339 }
2314 }); 2340 });
2315 2341
2316 editor.createDropDown(caller, 'inserttable', content); 2342 editor.createDropDown(caller, 'inserttable', content);
2317 }, 2343 },
2318 tooltip: 'Insert a table' 2344 tooltip: 'Insert a table',
2345 icon: material('table.png'),
2319 }, 2346 },
2320 // END_COMMAND 2347 // END_COMMAND
2321 2348
2322 // START_COMMAND: Horizontal Rule 2349 // START_COMMAND: Horizontal Rule
2323 horizontalrule: { 2350 horizontalrule: {
2324 exec: 'inserthorizontalrule', 2351 exec: 'inserthorizontalrule',
2325 tooltip: 'Insert a horizontal rule' 2352 tooltip: 'Insert a horizontal rule',
2353 icon: material('minus.png'),
2326 }, 2354 },
2327 // END_COMMAND 2355 // END_COMMAND
2328 2356
2329 // START_COMMAND: Code 2357 // START_COMMAND: Code
2330 code: { 2358 code: {
2332 editor.wysiwygEditorInsertHtml( 2360 editor.wysiwygEditorInsertHtml(
2333 '<code>', 2361 '<code>',
2334 '<br /></code>' 2362 '<br /></code>'
2335 ); 2363 );
2336 }, 2364 },
2337 tooltip: 'Code' 2365 tooltip: 'Code',
2366 icon: material('code-braces.png'),
2338 }, 2367 },
2339 // END_COMMAND 2368 // END_COMMAND
2340 2369
2341 // START_COMMAND: Image 2370 // START_COMMAND: Image
2342 image: { 2371 image: {
2392 '<img' + attrs + ' />' 2421 '<img' + attrs + ' />'
2393 ); 2422 );
2394 } 2423 }
2395 ); 2424 );
2396 }, 2425 },
2397 tooltip: 'Insert an image' 2426 tooltip: 'Insert an image',
2427 icon: material('image.png'),
2398 }, 2428 },
2399 // END_COMMAND 2429 // END_COMMAND
2400 2430
2401 // START_COMMAND: E-mail 2431 // START_COMMAND: E-mail
2402 email: { 2432 email: {
2438 editor.execCommand('createlink', 'mailto:' + email); 2468 editor.execCommand('createlink', 'mailto:' + email);
2439 } 2469 }
2440 } 2470 }
2441 ); 2471 );
2442 }, 2472 },
2443 tooltip: 'Insert an email' 2473 tooltip: 'Insert an email',
2474 icon: material('email.png'),
2444 }, 2475 },
2445 // END_COMMAND 2476 // END_COMMAND
2446 2477
2447 // START_COMMAND: Link 2478 // START_COMMAND: Link
2448 link: { 2479 link: {
2487 } else { 2518 } else {
2488 editor.execCommand('createlink', url); 2519 editor.execCommand('createlink', url);
2489 } 2520 }
2490 }); 2521 });
2491 }, 2522 },
2492 tooltip: 'Insert a link' 2523 tooltip: 'Insert a link',
2524 icon: material('link.png'),
2493 }, 2525 },
2494 // END_COMMAND 2526 // END_COMMAND
2495 2527
2496 // START_COMMAND: Unlink 2528 // START_COMMAND: Unlink
2497 unlink: { 2529 unlink: {
2507 } 2539 }
2508 2540
2509 remove(anchor); 2541 remove(anchor);
2510 } 2542 }
2511 }, 2543 },
2512 tooltip: 'Unlink' 2544 tooltip: 'Unlink',
2545 icon: material('link-off.png'),
2513 }, 2546 },
2514 // END_COMMAND 2547 // END_COMMAND
2515 2548
2516 2549
2517 // START_COMMAND: Quote 2550 // START_COMMAND: Quote
2533 end = '<br />' + end; 2566 end = '<br />' + end;
2534 } 2567 }
2535 2568
2536 editor.wysiwygEditorInsertHtml(before, end); 2569 editor.wysiwygEditorInsertHtml(before, end);
2537 }, 2570 },
2538 tooltip: 'Insert a Quote' 2571 tooltip: 'Insert a Quote',
2572 icon: material('format-quote-close.png'),
2539 }, 2573 },
2540 // END_COMMAND 2574 // END_COMMAND
2541 2575
2542 // START_COMMAND: Emoticons 2576 // START_COMMAND: Emoticons
2543 emoticon: { 2577 emoticon: {
2611 ); 2645 );
2612 }, 2646 },
2613 txtExec: function (editor, caller) { 2647 txtExec: function (editor, caller) {
2614 editor.commands.emoticon.exec(editor, caller); 2648 editor.commands.emoticon.exec(editor, caller);
2615 }, 2649 },
2616 tooltip: 'Insert an emoticon' 2650 tooltip: 'Insert an emoticon',
2651 icon: material('emoticon-outline.png'),
2617 }, 2652 },
2618 // END_COMMAND 2653 // END_COMMAND
2619 2654
2620 // START_COMMAND: YouTube 2655 // START_COMMAND: YouTube
2621 youtube: { 2656 youtube: {
2657 id: id, 2692 id: id,
2658 time: time 2693 time: time
2659 })); 2694 }));
2660 }); 2695 });
2661 }, 2696 },
2662 tooltip: 'Insert a YouTube video' 2697 tooltip: 'Insert a YouTube video',
2698 icon: material('youtube.png'),
2663 }, 2699 },
2664 // END_COMMAND 2700 // END_COMMAND
2665 2701
2666 // START_COMMAND: Date 2702 // START_COMMAND: Date
2667 date: { 2703 date: {
2692 editor.insertText(defaultCmds.date._date(editor)); 2728 editor.insertText(defaultCmds.date._date(editor));
2693 }, 2729 },
2694 txtExec: function (editor) { 2730 txtExec: function (editor) {
2695 defaultCmds.date.exec(editor); 2731 defaultCmds.date.exec(editor);
2696 }, 2732 },
2697 tooltip: 'Insert current date' 2733 tooltip: 'Insert current date',
2734 icon: material('calendar-today.png'),
2698 }, 2735 },
2699 // END_COMMAND 2736 // END_COMMAND
2700 2737
2701 // START_COMMAND: Time 2738 // START_COMMAND: Time
2702 time: { 2739 time: {
2724 editor.insertText(defaultCmds.time._time()); 2761 editor.insertText(defaultCmds.time._time());
2725 }, 2762 },
2726 txtExec: function (editor) { 2763 txtExec: function (editor) {
2727 defaultCmds.time.exec(editor); 2764 defaultCmds.time.exec(editor);
2728 }, 2765 },
2729 tooltip: 'Insert current time' 2766 tooltip: 'Insert current time',
2767 icon: material('clock-outline.png'),
2730 }, 2768 },
2731 // END_COMMAND 2769 // END_COMMAND
2732 2770
2733 2771
2734 // START_COMMAND: Ltr 2772 // START_COMMAND: Ltr
2754 } 2792 }
2755 2793
2756 var toggleValue = css(node, 'direction') === 'ltr' ? '' : 'ltr'; 2794 var toggleValue = css(node, 'direction') === 'ltr' ? '' : 'ltr';
2757 css(node, 'direction', toggleValue); 2795 css(node, 'direction', toggleValue);
2758 }, 2796 },
2759 tooltip: 'Left-to-Right' 2797 tooltip: 'Left-to-Right',
2798 icon: material('format-pilcrow-arrow-right.png'),
2760 }, 2799 },
2761 // END_COMMAND 2800 // END_COMMAND
2762 2801
2763 // START_COMMAND: Rtl 2802 // START_COMMAND: Rtl
2764 rtl: { 2803 rtl: {
2783 } 2822 }
2784 2823
2785 var toggleValue = css(node, 'direction') === 'rtl' ? '' : 'rtl'; 2824 var toggleValue = css(node, 'direction') === 'rtl' ? '' : 'rtl';
2786 css(node, 'direction', toggleValue); 2825 css(node, 'direction', toggleValue);
2787 }, 2826 },
2788 tooltip: 'Right-to-Left' 2827 tooltip: 'Right-to-Left',
2828 icon: material('format-pilcrow-arrow-left.png'),
2789 }, 2829 },
2790 // END_COMMAND 2830 // END_COMMAND
2791 2831
2792 2832
2793 // START_COMMAND: Print 2833 // START_COMMAND: Print
2794 print: { 2834 print: {
2795 exec: 'print', 2835 exec: 'print',
2796 tooltip: 'Print' 2836 tooltip: 'Print',
2837 icon: material('printer.png'),
2797 }, 2838 },
2798 // END_COMMAND 2839 // END_COMMAND
2799 2840
2800 // START_COMMAND: Maximize 2841 // START_COMMAND: Maximize
2801 maximize: { 2842 maximize: {
2808 }, 2849 },
2809 txtExec: function () { 2850 txtExec: function () {
2810 defaultCmds.maximize.exec(editor); 2851 defaultCmds.maximize.exec(editor);
2811 }, 2852 },
2812 tooltip: 'Maximize', 2853 tooltip: 'Maximize',
2813 shortcut: 'Ctrl+Shift+M' 2854 shortcut: 'Ctrl+Shift+M',
2855 icon: material('arrow-expand-all.png'),
2814 }, 2856 },
2815 // END_COMMAND 2857 // END_COMMAND
2816 2858
2817 // START_COMMAND: Source 2859 // START_COMMAND: Source
2818 source: { 2860 source: {
2825 }, 2867 },
2826 txtExec: function (editor) { 2868 txtExec: function (editor) {
2827 defaultCmds.source.exec(editor); 2869 defaultCmds.source.exec(editor);
2828 }, 2870 },
2829 tooltip: 'View source', 2871 tooltip: 'View source',
2830 shortcut: 'Ctrl+Shift+S' 2872 shortcut: 'Ctrl+Shift+S',
2873 icon: material('code-tags.png'),
2831 }, 2874 },
2832 // END_COMMAND 2875 // END_COMMAND
2833
2834 // this is here so that commands above can be removed
2835 // without having to remove the , after the last one.
2836 // Needed for IE.
2837 ignore: {}
2838 }; 2876 };
2839 2877
2840 var plugins = {}; 2878 var plugins = {};
2841 2879
2842 /** 2880 /**
4349 * 4387 *
4350 * @type {!Object<string, string>} 4388 * @type {!Object<string, string>}
4351 * @private 4389 * @private
4352 */ 4390 */
4353 var allEmoticons = {}; 4391 var allEmoticons = {};
4354
4355 /**
4356 * Current icon set if any
4357 *
4358 * @type {?Object}
4359 * @private
4360 */
4361 let icons = sceditor.icons;
4362 if(!icons) {
4363 let cssUrl = baseUrl + 'icons/famfamfam/famfamfam.css';
4364 let html = '<style>@import "' + cssUrl + '";</style>';
4365 document.head.insertAdjacentHTML('beforeend',html);
4366 sceditor.icons = icons = {};
4367 }
4368 4392
4369 /** 4393 /**
4370 * Private functions 4394 * Private functions
4371 * @private 4395 * @private
4372 */ 4396 */
4737 // The commandName must be a valid command and not excluded 4761 // The commandName must be a valid command and not excluded
4738 if (!command || exclude.indexOf(commandName) > -1) { 4762 if (!command || exclude.indexOf(commandName) > -1) {
4739 return; 4763 return;
4740 } 4764 }
4741 4765
4742 let iconName = command.icon || commandName
4743 let shortcut = command.shortcut; 4766 let shortcut = command.shortcut;
4767 let icon = command.icon;
4744 let button = _tmpl('toolbarButton', { 4768 let button = _tmpl('toolbarButton', {
4745 name: commandName, 4769 name: commandName,
4746 iconName: iconName, 4770 icon: icon || '',
4747 dispName: base._(command.name ||
4748 command.tooltip || commandName)
4749 }, true).firstChild; 4771 }, true).firstChild;
4750
4751 if (icons.create) {
4752 let icon = icons.create(iconName);
4753 if (icon) {
4754 insertBefore( icon, button.firstChild );
4755 addClass(button, 'has-icon');
4756 }
4757 }
4758
4759 button._sceTxtMode = !!command.txtExec; 4772 button._sceTxtMode = !!command.txtExec;
4760 button._sceWysiwygMode = !!command.exec; 4773 button._sceWysiwygMode = !!command.exec;
4761 toggleClass(button, 'disabled', !command.exec); 4774 toggleClass(button, 'disabled', !command.exec);
4762 onEvent2(button, 'click', function (e) { 4775 onEvent2(button, 'click', function (e) {
4763 if (!hasClass(button, 'disabled')) { 4776 if (!hasClass(button, 'disabled')) {
4900 offEvent(globalDoc, endEvents, mouseUpFunc); 4913 offEvent(globalDoc, endEvents, mouseUpFunc);
4901 4914
4902 e.preventDefault(); 4915 e.preventDefault();
4903 }; 4916 };
4904 4917
4905 if (icons.create) {
4906 var icon = icons.create('grip');
4907 if (icon) {
4908 appendChild(grip, icon);
4909 addClass(grip, 'has-icon');
4910 }
4911 }
4912
4913 appendChild(editorContainer, grip); 4918 appendChild(editorContainer, grip);
4914 appendChild(editorContainer, cover); 4919 appendChild(editorContainer, cover);
4915 hide(cover); 4920 hide(cover);
4916 4921
4917 onEvent2(grip, 'touchstart mousedown', function (e) { 4922 onEvent2(grip, 'touchstart mousedown', function (e) {
5080 attr(sourceEditor, 'dir', dir); 5085 attr(sourceEditor, 'dir', dir);
5081 5086
5082 removeClass(editorContainer, 'rtl'); 5087 removeClass(editorContainer, 'rtl');
5083 removeClass(editorContainer, 'ltr'); 5088 removeClass(editorContainer, 'ltr');
5084 addClass(editorContainer, dir); 5089 addClass(editorContainer, dir);
5085
5086 if (icons.rtl) {
5087 icons.rtl(rtl);
5088 }
5089 }; 5090 };
5090 5091
5091 /** 5092 /**
5092 * Updates the toolbar to disable/enable the appropriate buttons 5093 * Updates the toolbar to disable/enable the appropriate buttons
5093 * @private 5094 * @private
6391 state = stateFn(base, parent, firstBlock); 6392 state = stateFn(base, parent, firstBlock);
6392 } 6393 }
6393 6394
6394 toggleClass(btn, 'disabled', isDisabled || state < 0); 6395 toggleClass(btn, 'disabled', isDisabled || state < 0);
6395 toggleClass(btn, 'active', state > 0); 6396 toggleClass(btn, 'active', state > 0);
6396 }
6397
6398 if (icons.update) {
6399 icons.update(isSource, parent, firstBlock);
6400 } 6397 }
6401 }; 6398 };
6402 6399
6403 /** 6400 /**
6404 * Handles any key press in the WYSIWYG editor 6401 * Handles any key press in the WYSIWYG editor