comparison src/sceditor.js @ 13:8d32537e0ca7

icons again
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 07 Aug 2022 14:28:14 -0600
parents 933a459aa182
children ea930990b601
comparison
equal deleted inserted replaced
12:933a459aa182 13:8d32537e0ca7
5722 * Current icon set if any 5722 * Current icon set if any
5723 * 5723 *
5724 * @type {?Object} 5724 * @type {?Object}
5725 * @private 5725 * @private
5726 */ 5726 */
5727 var icons; 5727 let icons = sceditor.icons;
5728 if(!icons) {
5729 let cssUrl = baseUrl + 'icons/famfamfam/famfamfam.css';
5730 let html = '<style>@import "' + cssUrl + '";</style>';
5731 document.head.insertAdjacentHTML('beforeend',html);
5732 sceditor.icons = icons = {};
5733 }
5728 5734
5729 /** 5735 /**
5730 * Private functions 5736 * Private functions
5731 * @private 5737 * @private
5732 */ 5738 */
6136 toolbar = createElement('div', { 6142 toolbar = createElement('div', {
6137 className: 'sceditor-toolbar', 6143 className: 'sceditor-toolbar',
6138 unselectable: 'on' 6144 unselectable: 'on'
6139 }); 6145 });
6140 6146
6141 icons = SCEditor.icons.fn();
6142
6143 each(groups, function (_, menuItems) { 6147 each(groups, function (_, menuItems) {
6144 group = createElement('div', { 6148 group = createElement('div', {
6145 className: 'sceditor-group' 6149 className: 'sceditor-group'
6146 }); 6150 });
6147 6151
6159 name: commandName, 6163 name: commandName,
6160 dispName: base._(command.name || 6164 dispName: base._(command.name ||
6161 command.tooltip || commandName) 6165 command.tooltip || commandName)
6162 }, true).firstChild; 6166 }, true).firstChild;
6163 6167
6164 if (icons && icons.create) { 6168 if (icons.create) {
6165 var icon = icons.create(commandName); 6169 var icon = icons.create(commandName);
6166 if (icon) { 6170 if (icon) {
6167 insertBefore(icons.create(commandName), 6171 insertBefore(icons.create(commandName),
6168 button.firstChild); 6172 button.firstChild);
6169 addClass(button, 'has-icon'); 6173 addClass(button, 'has-icon');
6314 off(globalDoc, endEvents, mouseUpFunc); 6318 off(globalDoc, endEvents, mouseUpFunc);
6315 6319
6316 e.preventDefault(); 6320 e.preventDefault();
6317 }; 6321 };
6318 6322
6319 if (icons && icons.create) { 6323 if (icons.create) {
6320 var icon = icons.create('grip'); 6324 var icon = icons.create('grip');
6321 if (icon) { 6325 if (icon) {
6322 appendChild(grip, icon); 6326 appendChild(grip, icon);
6323 addClass(grip, 'has-icon'); 6327 addClass(grip, 'has-icon');
6324 } 6328 }
6508 6512
6509 removeClass(editorContainer, 'rtl'); 6513 removeClass(editorContainer, 'rtl');
6510 removeClass(editorContainer, 'ltr'); 6514 removeClass(editorContainer, 'ltr');
6511 addClass(editorContainer, dir); 6515 addClass(editorContainer, dir);
6512 6516
6513 if (icons && icons.rtl) { 6517 if (icons.rtl) {
6514 icons.rtl(rtl); 6518 icons.rtl(rtl);
6515 } 6519 }
6516 6520
6517 return base; 6521 return base;
6518 }; 6522 };
7893 7897
7894 toggleClass(btn, 'disabled', isDisabled || state < 0); 7898 toggleClass(btn, 'disabled', isDisabled || state < 0);
7895 toggleClass(btn, activeClass, state > 0); 7899 toggleClass(btn, activeClass, state > 0);
7896 } 7900 }
7897 7901
7898 if (icons && icons.update) { 7902 if (icons.update) {
7899 icons.update(isSource, parent, firstBlock); 7903 icons.update(isSource, parent, firstBlock);
7900 } 7904 }
7901 }; 7905 };
7902 7906
7903 /** 7907 /**
8928 * @memberOf sceditor 8932 * @memberOf sceditor
8929 */ 8933 */
8930 SCEditor.locale = {}; 8934 SCEditor.locale = {};
8931 8935
8932 SCEditor.formats = {}; 8936 SCEditor.formats = {};
8933 SCEditor.icons = {};
8934
8935 // default icons
8936 SCEditor.icons.fn = function() {
8937 let cssUrl = baseUrl + 'icons/famfamfam/famfamfam.css';
8938 let html = '<style>@import "' + cssUrl + '";</style>';
8939 document.head.insertAdjacentHTML('beforeend',html);
8940 return {};
8941 };
8942 8937
8943 8938
8944 /** 8939 /**
8945 * Static command helper class 8940 * Static command helper class
8946 * @class command 8941 * @class command
9070 getOffset: getOffset, 9065 getOffset: getOffset,
9071 getStyle: getStyle, 9066 getStyle: getStyle,
9072 hasStyle: hasStyle 9067 hasStyle: hasStyle
9073 }, 9068 },
9074 locale: SCEditor.locale, 9069 locale: SCEditor.locale,
9075 icons: SCEditor.icons,
9076 utils: { 9070 utils: {
9077 each: each, 9071 each: each,
9078 isEmptyObject: isEmptyObject, 9072 isEmptyObject: isEmptyObject,
9079 extend: extend 9073 extend: extend
9080 }, 9074 },