mirror of
https://github.com/Febbweiss/filebrowser-durandal-widget.git
synced 2026-03-04 22:25:43 +00:00
Add highlightjs editor to view files
This commit is contained in:
31
app/shell.js
31
app/shell.js
@@ -1,7 +1,26 @@
|
||||
define(function (require) {
|
||||
var app = require('durandal/app'),
|
||||
ko = require('knockout');
|
||||
|
||||
return {
|
||||
};
|
||||
define(['durandal/app', 'knockout', 'highlightjs'], function (app, ko) {
|
||||
var type = ko.observable(),
|
||||
content = ko.observable();
|
||||
|
||||
var sub = app.on('filebrowser:open_file').then(function(message) {
|
||||
type(message.type);
|
||||
if( message.type === "json" ) {
|
||||
content(ko.utils.stringifyJson(message.content));
|
||||
} else {
|
||||
content(message.content);
|
||||
}
|
||||
hljs.highlightBlock($('#editor')[0]);
|
||||
}, this);
|
||||
|
||||
|
||||
return {
|
||||
attached: function () {
|
||||
hljs.configure({
|
||||
tabReplace: ' '
|
||||
});
|
||||
hljs.initHighlighting();
|
||||
},
|
||||
type: type,
|
||||
content: content
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user