зеркало из https://github.com/mozilla/brackets.git
Allow SVG to be treated as an image or XML doc in ImageViewer, with extension to override
This commit is contained in:
Родитель
614a955e80
Коммит
8e204d52b6
|
@ -92,6 +92,7 @@ In addition, you can enable other extra extensions:
|
|||
* ImageUrlCodeHints
|
||||
* HTMLHinter
|
||||
* MdnDocs
|
||||
* SVGasXML
|
||||
|
||||
You could enable JSLint and LESSSupport by loading Bramble with `?enableExtensions=JSLint,LESSSupport`
|
||||
on the URL
|
||||
|
|
|
@ -39,6 +39,10 @@ define(function (require, exports, module) {
|
|||
FileUtils = require("file/FileUtils"),
|
||||
_ = require("thirdparty/lodash");
|
||||
|
||||
// XXXBramble specific bits to allow opening SVG as a regular image vs. XML doc
|
||||
var PreferencesManager = require("preferences/PreferencesManager");
|
||||
PreferencesManager.definePreference("openSVGasXML", "boolean", false);
|
||||
|
||||
var _viewers = {};
|
||||
|
||||
// Get a Blob URL out of the cache
|
||||
|
@ -455,7 +459,12 @@ define(function (require, exports, module) {
|
|||
MainViewFactory.registerViewFactory({
|
||||
canOpenFile: function (fullPath) {
|
||||
var lang = LanguageManager.getLanguageForPath(fullPath);
|
||||
return (lang.getId() === "image");
|
||||
var svgAsXML = PreferencesManager.get("openSVGasXML");
|
||||
var id = lang.getId();
|
||||
|
||||
// Depending on whether or not the user wants to treat SVG files as XML
|
||||
// we default to open as an image.
|
||||
return id === "image" || (!svgAsXML && id === "svg");
|
||||
},
|
||||
openFile: function (file, pane) {
|
||||
return _createImageView(file, pane);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
|
||||
/*global define, brackets, window */
|
||||
|
||||
define(function (require, exports, module) {
|
||||
"use strict";
|
||||
|
||||
// Override SVG ImageViewer in order to display SVG's as XML
|
||||
var PreferencesManager = brackets.getModule("preferences/PreferencesManager");
|
||||
PreferencesManager.set("openSVGasXML", true);
|
||||
});
|
|
@ -62,7 +62,8 @@ define(function (require, exports, module) {
|
|||
"brackets-cdn-suggestions", // https://github.com/szdc/brackets-cdn-suggestions
|
||||
"ImageUrlCodeHints",
|
||||
"HTMLHinter",
|
||||
"MDNDocs"
|
||||
"MDNDocs",
|
||||
"SVGasXML"
|
||||
];
|
||||
|
||||
// Disable any extensions we found on the query string's disableExtensions param
|
||||
|
|
Загрузка…
Ссылка в новой задаче