Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 8166f1c

Browse files
committed
SVG code hints cleanup
Added color names support. SVG code hint refactor Added transparent, currentColor SVG code hints refactoring
1 parent f9cd4f7 commit 8166f1c

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

src/extensions/default/SVGCodeHints/SVGAttributes.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@
1111
"animate/fill": {
1212
"attribOptions": ["freeze", "remove"]
1313
},
14+
"animateColor/fill": {
15+
"attribOptions": ["freeze", "remove"]
16+
},
17+
"animateMotion/fill": {
18+
"attribOptions": ["freeze", "remove"]
19+
},
20+
"animateTransform/fill": {
21+
"attribOptions": ["freeze", "remove"]
22+
},
1423
"animateTransform/type": {
1524
"attribOptions": ["rotate", "scale", "skewX", "skewY", "translate"]
1625
},
@@ -38,6 +47,9 @@
3847
"clipPathUnits": {
3948
"attribOptions": ["objectBoundingBox", "userSpaceOnUse"]
4049
},
50+
"color": {
51+
"type": "color"
52+
},
4153
"color-interpolation": {
4254
"attribOptions": ["auto", "inherit", "linearRGB", "sRGB"]
4355
},
@@ -104,6 +116,9 @@
104116
"feTurbulence/type": {
105117
"attribOptions": ["fractalNoise", "turbulence"]
106118
},
119+
"fill": {
120+
"type": "color"
121+
},
107122
"fill-opacity": {
108123
"attribOptions": ["inherit"]
109124
},
@@ -116,6 +131,9 @@
116131
"filterUnits": {
117132
"attribOptions": ["objectBoundingBox", "userSpaceOnUse"]
118133
},
134+
"flood-color": {
135+
"type": "color"
136+
},
119137
"flood-opacity": {
120138
"attribOptions": ["inherit"]
121139
},
@@ -170,6 +188,9 @@
170188
"letter-spacing": {
171189
"attribOptions": ["inherit", "normal"]
172190
},
191+
"lighting-color": {
192+
"type": "color"
193+
},
173194
"marker-end": {
174195
"attribOptions": ["inherit", "none"]
175196
},
@@ -262,6 +283,9 @@
262283
"script/type": {
263284
"attribOptions": ["application/ecmascript", "application/javascript", "application/x-ecmascript", "application/x-javascript", "text/ecmascript", "text/javascript", "text/jscript", "text/livescript", "text/tcl", "text/x-ecmascript", "text/x-javascript"]
264285
},
286+
"set/fill": {
287+
"attribOptions": ["freeze", "remove"]
288+
},
265289
"shape-rendering": {
266290
"attribOptions": ["auto", "crispEdges", "geometricPrecision", "inherit", "optimizeSpeed"]
267291
},
@@ -274,9 +298,15 @@
274298
"stitchTiles": {
275299
"attribOptions": ["noStitch", "stitch"]
276300
},
301+
"stop-color": {
302+
"type": "color"
303+
},
277304
"stop-opacity": {
278305
"attribOptions": ["inherit"]
279306
},
307+
"stroke": {
308+
"type": "color"
309+
},
280310
"stroke-dasharray": {
281311
"attribOptions": ["inherit", "none"]
282312
},

src/extensions/default/SVGCodeHints/main.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ define(function (require, exports, module) {
3434
XMLUtils = brackets.getModule("language/XMLUtils"),
3535
StringMatch = brackets.getModule("utils/StringMatch"),
3636
ExtensionUtils = brackets.getModule("utils/ExtensionUtils"),
37+
ColorUtils = brackets.getModule("utils/ColorUtils"),
38+
_ = brackets.getModule("thirdparty/lodash"),
3739
SVGTags = require("text!SVGTags.json"),
3840
SVGAttributes = require("text!SVGAttributes.json"),
3941
cachedAttributes = {},
@@ -85,7 +87,7 @@ define(function (require, exports, module) {
8587
cachedAttributes[tagName] = cachedAttributes[tagName].concat(tagData.attributeGroups[group]);
8688
}
8789
});
88-
cachedAttributes[tagName].sort();
90+
cachedAttributes[tagName] = _.uniq(cachedAttributes[tagName].sort(), true);
8991
}
9092
return cachedAttributes[tagName];
9193
}
@@ -96,7 +98,7 @@ define(function (require, exports, module) {
9698
*
9799
* @param {Array.<Object>} hints - the list of hints to format
98100
* @param {string} query - querystring used for highlighting matched
99-
* poritions of each hint
101+
* portions of each hint
100102
* @return {Array.jQuery} sorted Array of jQuery DOM elements to insert
101103
*/
102104
function formatHints(hints, query) {
@@ -206,6 +208,11 @@ define(function (require, exports, module) {
206208
} else if (attributeData[tagInfo.attrName]) {
207209
options = attributeData[tagInfo.attrName].attribOptions;
208210
isMultiple = attributeData[tagInfo.attrName].multiple;
211+
212+
if (attributeData[tagInfo.attrName].type === "color") {
213+
options = ColorUtils.COLOR_NAMES;
214+
options = options.concat(["currentColor", "transparent"]);
215+
}
209216
}
210217

211218
// Stop if the attribute doesn't support multiple options.

src/extensions/default/SVGCodeHints/styles/brackets-svg-hints.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
.brackets-svg-hints .matched-hint {
2525
font-weight: 500;
26-
color: #000;
2726
}
2827
.dark .brackets-svg-hints .matched-hint {
2928
color: #ccc;

0 commit comments

Comments
 (0)