/** * SCEditor SVG material icons 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; /** * Material icons by Google (Apache license) * https://github.com/google/material-design-icons/blob/master/LICENSE * * Extra icons by materialdesignicons.com and contributors (MIT license) * https://github.com/Templarian/MaterialDesign-SVG/blob/master/LICENSE */ /* eslint max-len: off*/ var icons = { 'bold': '', 'bulletlist': '', 'center': '', // Cody @XT3000 - https://materialdesignicons.com/ 'code': '', 'color': '', 'copy': '', 'cut': '', 'date': '', 'email': '', 'emoticon': '', // JapanYoshi @japanyoshilol - https://materialdesignicons.com/ 'font': '', 'format': '', // Austin Andrews @Templarian - https://materialdesignicons.com/ 'grip': '', // Sam Clarke @samclarke 'horizontalrule': '', 'image': '', 'indent': '', 'italic': '', 'justify': ' ', 'left': ' ', 'link': '', 'ltr': '', // Austin Andrews @Templarian - https://materialdesignicons.com/ 'maximize': '', 'orderedlist': '', 'outdent': '', 'paste': '', 'pastetext': '', 'print': '', 'quote': '', 'redo': '', 'removeformat': '', 'right': '', 'rtl': '', 'size': '', 'source': '', 'strike': '', // Austin Andrews @Templarian - https://materialdesignicons.com/ 'subscript': '', // Austin Andrews @Templarian - https://materialdesignicons.com/ 'superscript': '', // Austin Andrews @Templarian - https://materialdesignicons.com/ 'table': '', 'time': '', 'underline': '', 'undo': '', // Austin Andrews @Templarian - https://materialdesignicons.com/ 'unlink': '', 'youtube': '' }; sceditor.icons.material = function () { var nodes = {}; var colorPath; return { create: function (command) { if (command in icons) { // Using viewbox="1 1 22 22" to trim off the 1 unit border // around the SVG icons. // Default is viewbox="0 0 24 24" 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.material.icons = icons; })(document, sceditor);