/** * SCEditor SVG monocons plugin * http://www.sceditor.com/ * * Copyright (C) 2017, Sam Clarke (samclarke.com) * * SCEditor is licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * * @author Sam Clarke */ (function (document, sceditor) { 'use strict'; var dom = sceditor.dom; /* eslint max-len: off*/ var icons = { 'bold': 'B', 'bulletlist': '', 'center': '', 'code': '', 'color': 'A', 'copy': '', 'cut': '', 'date': '', 'email': '', 'emoticon': '', 'font': '', 'format': '', 'grip': '', 'horizontalrule': '', 'image': '', 'indent': '', 'italic': 'i', 'justify': '', 'left': '', 'link': '', 'ltr': '', 'maximize': '', 'orderedlist': '', 'outdent': '', 'paste': '', 'pastetext': '', 'print': '', 'quote': '', 'redo': '', 'removeformat': '', 'right': '', 'rtl': '', 'size': '', 'source': '', 'strike': 'S', 'subscript': '', 'superscript': '', 'table': '', 'time': '', 'underline': 'U', 'undo': '', 'unlink': '', 'youtube': '' }; sceditor.icons.monocons = function () { var nodes = {}; var colorPath; return { create: function (command) { if (command in icons) { nodes[command] = sceditor.dom.parseHTML( '' + icons[command] + '' ).firstChild; if (command === 'color') { colorPath = nodes[command].querySelector('.sce-color'); } } return nodes[command]; }, update: function (isSourceMode, currentNode) { if (colorPath) { var color = 'inherit'; if (!isSourceMode && currentNode) { color = currentNode.ownerDocument .queryCommandValue('forecolor'); // Needed for IE if (parseInt(color) === color) { // eslint-disable-next-line color = ((color & 0x0000ff) << 16) | (color & 0x00ff00) | ((color & 0xff0000) >>> 16); color = '#' + ('000000' + color.toString(16)).slice(-6); } } dom.css(colorPath, 'fill', color); } }, rtl: function (isRtl) { var gripNode = nodes.grip; if (gripNode) { var transform = isRtl ? 'scaleX(-1)' : ''; dom.css(gripNode, 'transform', transform); dom.css(gripNode, 'msTransform', transform); dom.css(gripNode, 'webkitTransform', transform); } } }; }; sceditor.icons.monocons.icons = icons; })(document, sceditor);