comparison src/icons/monocons.js @ 13:8d32537e0ca7

icons again
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 07 Aug 2022 14:28:14 -0600
parents 73d62b7a0713
children
comparison
equal deleted inserted replaced
12:933a459aa182 13:8d32537e0ca7
59 'undo': '<path d="M2 7h5L2 2z"/><path d="M6.447 2.205c-1 .268-1.932.796-2.69 1.553l-.706.707 1.414 1.414.707-.707a3.995 3.995 0 0 1 3.863-1.035 3.995 3.995 0 0 1 2.828 2.828 3.995 3.995 0 0 1-1.035 3.863l-.707.707 1.414 1.414.707-.707a6.003 6.003 0 0 0 1.553-5.795 6.003 6.003 0 0 0-7.348-4.242z"/>', 59 'undo': '<path d="M2 7h5L2 2z"/><path d="M6.447 2.205c-1 .268-1.932.796-2.69 1.553l-.706.707 1.414 1.414.707-.707a3.995 3.995 0 0 1 3.863-1.035 3.995 3.995 0 0 1 2.828 2.828 3.995 3.995 0 0 1-1.035 3.863l-.707.707 1.414 1.414.707-.707a6.003 6.003 0 0 0 1.553-5.795 6.003 6.003 0 0 0-7.348-4.242z"/>',
60 'unlink': '<path d="M2 4c-.625 0-1.009.438-1.188.75s-.269.63-.344.969c-.15.677-.219 1.476-.219 2.28s.068 1.605.219 2.282c.075.339.165.625.344.938s.563.78 1.188.78h4v-2H2.469c-.022-.065-.042-.06-.063-.155-.1-.447-.156-1.15-.156-1.844s.057-1.396.156-1.844c.02-.088.042-.092.063-.156H6V4H2zm8 0v2h3.531c.021.064.043.068.063.156.1.448.156 1.149.156 1.844s-.057 1.396-.156 1.844c-.021.095-.041.09-.063.156H10v2h4c.625 0 1.009-.47 1.188-.781s.269-.6.344-.938c.15-.678.219-1.476.219-2.281s-.068-1.604-.219-2.281c-.075-.34-.165-.656-.344-.97S14.625 4 14 4h-4z"/>', 60 'unlink': '<path d="M2 4c-.625 0-1.009.438-1.188.75s-.269.63-.344.969c-.15.677-.219 1.476-.219 2.28s.068 1.605.219 2.282c.075.339.165.625.344.938s.563.78 1.188.78h4v-2H2.469c-.022-.065-.042-.06-.063-.155-.1-.447-.156-1.15-.156-1.844s.057-1.396.156-1.844c.02-.088.042-.092.063-.156H6V4H2zm8 0v2h3.531c.021.064.043.068.063.156.1.448.156 1.149.156 1.844s-.057 1.396-.156 1.844c-.021.095-.041.09-.063.156H10v2h4c.625 0 1.009-.47 1.188-.781s.269-.6.344-.938c.15-.678.219-1.476.219-2.281s-.068-1.604-.219-2.281c-.075-.34-.165-.656-.344-.97S14.625 4 14 4h-4z"/>',
61 'youtube': '<path d="M2 2C1 2 0 3 0 4v8c0 1 1 2 2 2h12c1 0 2-1 2-2V4c0-1-1-2-2-2H2zm4 3l6 3-6 3V5z"/>' 61 'youtube': '<path d="M2 2C1 2 0 3 0 4v8c0 1 1 2 2 2h12c1 0 2-1 2-2V4c0-1-1-2-2-2H2zm4 3l6 3-6 3V5z"/>'
62 }; 62 };
63 63
64 sceditor.icons.fn = function () { 64 var nodes = {};
65 var nodes = {}; 65 var colorPath;
66 var colorPath;
67 66
68 return { 67 sceditor.icons = {
69 create: function (command) { 68 create: function (command) {
70 if (command in icons) { 69 if (command in icons) {
71 nodes[command] = sceditor.dom.parseHTML( 70 nodes[command] = sceditor.dom.parseHTML(
72 '<svg xmlns="http://www.w3.org/2000/svg" ' + 71 '<svg xmlns="http://www.w3.org/2000/svg" ' +
73 'viewbox="0 0 16 16" unselectable="on">' + 72 'viewbox="0 0 16 16" unselectable="on">' +
74 icons[command] + 73 icons[command] +
75 '</svg>' 74 '</svg>'
76 ).firstChild; 75 ).firstChild;
77 76
78 if (command === 'color') { 77 if (command === 'color') {
79 colorPath = nodes[command].querySelector('.sce-color'); 78 colorPath = nodes[command].querySelector('.sce-color');
80 } 79 }
80 }
81
82 return nodes[command];
83 },
84 update: function (isSourceMode, currentNode) {
85 if (colorPath) {
86 var color = 'inherit';
87
88 if (!isSourceMode && currentNode) {
89 color = currentNode.ownerDocument
90 .queryCommandValue('forecolor');
81 } 91 }
82 92
83 return nodes[command]; 93 dom.css(colorPath, 'fill', color);
84 }, 94 }
85 update: function (isSourceMode, currentNode) { 95 },
86 if (colorPath) { 96 rtl: function (isRtl) {
87 var color = 'inherit'; 97 var gripNode = nodes.grip;
88 98
89 if (!isSourceMode && currentNode) { 99 if (gripNode) {
90 color = currentNode.ownerDocument 100 var transform = isRtl ? 'scaleX(-1)' : '';
91 .queryCommandValue('forecolor');
92 }
93 101
94 dom.css(colorPath, 'fill', color); 102 dom.css(gripNode, 'transform', transform);
95 } 103 dom.css(gripNode, 'msTransform', transform);
96 }, 104 dom.css(gripNode, 'webkitTransform', transform);
97 rtl: function (isRtl) {
98 var gripNode = nodes.grip;
99
100 if (gripNode) {
101 var transform = isRtl ? 'scaleX(-1)' : '';
102
103 dom.css(gripNode, 'transform', transform);
104 dom.css(gripNode, 'msTransform', transform);
105 dom.css(gripNode, 'webkitTransform', transform);
106 }
107 } 105 }
108 }; 106 },
107 icons: icons
109 }; 108 };
110
111 sceditor.icons.icons = icons;
112 })(document, sceditor); 109 })(document, sceditor);