Allow SVG to be treated as an image or XML doc in ImageViewer, with extension to override

This commit is contained in:
David Humphrey (:humph) david.humphrey@senecacollege.ca 2015-07-02 17:42:21 -04:00 коммит произвёл Gideon Thomas
Родитель 614a955e80
Коммит 8e204d52b6
4 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

@ -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