Skip to content

Commit a245c12

Browse files
committed
Improve editor settings
1 parent 989923c commit a245c12

File tree

6 files changed

+58
-135
lines changed

6 files changed

+58
-135
lines changed

addons/editor/addon-built.js

Lines changed: 33 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

addons/editor/client.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
define([
22
"views/tab",
3-
"ace/ace"
4-
], function(EditorTab, ace) {
3+
"ace/ace",
4+
"ace/ext/modelist",
5+
"ace/ext/themelist"
6+
], function(EditorTab, ace, aceModes, aceThemes) {
57
var $ = codebox.require("jQuery");
68
var commands = codebox.require("core/commands");
79
var tabs = codebox.require("utils/tabs");
@@ -13,30 +15,43 @@ define([
1315
var aceconfig = ace.require("ace/config");
1416
aceconfig.set("basePath", "static/addons/editor/ace");
1517

18+
console.log(aceModes);
19+
console.log(aceThemes);
20+
21+
// Build themes map
22+
var themesMap = {};
23+
_.each(aceThemes.themes, function(theme) {
24+
themesMap[theme.name] = theme.desc;
25+
})
26+
1627
// Add settings
1728
settings.add({
1829
'namespace': "editor",
1930
'title': "Editor",
2031
'defaults': {
21-
'theme': config.editor.default_theme,
32+
'theme': "github",
2233
'fontsize': "12",
2334
'printmargincolumn': 80,
2435
'showprintmargin': false,
2536
'highlightactiveline': false,
2637
'wraplimitrange': 80,
2738
'enablesoftwrap': false,
28-
'keyboard': config.editor.default_keyboard
39+
'keyboard': "textinput"
2940
},
3041
'fields': {
3142
'theme': {
3243
'label': "Theme",
3344
'type': "select",
34-
'options': config.editor.themes
45+
'options': themesMap
3546
},
3647
'keyboard': {
3748
'label': "Keyboard mode",
3849
'type': "select",
39-
'options': config.editor.keyboards
50+
'options': {
51+
"vim": "Vim",
52+
"emacs": "Emacs",
53+
"textinput": "Default"
54+
}
4055
},
4156
'fontsize': {
4257
'label': "Font Size",

addons/editor/templates/file.html

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
<div class="tab-panel-lateralopener"></div>
21
<div class="tab-panel-body editor">
3-
<div class="tab-panel-lateralbar">
4-
<div class="list-group file-participants"></div>
5-
<div class="list-group">
6-
<% _.each(app.config.editor.modes, function(mode, modeid) { %>
7-
<a href="#" class="list-group-item" data-editormode="<%- modeid %>"><%- mode %></a>
8-
<% }); %>
9-
</div>
10-
</div>
112
<div class="tab-panel-inner editor-inner"></div>
123
</div>

addons/editor/views/editor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ define([
1717
className: "editor-ace",
1818
defaults: {
1919
mode: "text",
20-
theme: config.editor.default_theme,
20+
theme: "textmate",
2121
fontsize: "12",
2222
printmargincolumn: 80,
2323
showprintmargin: false,
2424
highlightactiveline: false,
2525
wraplimitrange: 80,
2626
enablesoftwrap: false,
27-
keyboard: config.editor.default_keyboard,
27+
keyboard: "textinput",
2828
readonly: false
2929
},
3030
events: {

addons/editor/views/file.js

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ define([
1313
templateLoader: "addon.editor.templates",
1414
template: "file.html",
1515
events: {
16-
"click .action-file-fullscreen": "toggleFullscreen",
17-
"click a[data-editormode]": "changeEditorMode"
16+
1817
},
1918

2019
// Constructor
@@ -24,18 +23,12 @@ define([
2423
// Build editor
2524
this.editor = new EditorView();
2625

27-
// Bind editor mode changements
28-
this.editor.on("change:mode", this.modeChanged, this);
29-
3026
// Bind editor sync state changements
3127
this.editor.on("sync:state", function(state) {
3228
this.$(".action-editor-state").toggleClass("btn-danger", !state);
3329
this.$(".action-editor-state").toggleClass("btn-success", state);
3430
}, this);
3531

36-
// Bind collaborators changements
37-
this.editor.sync.on("participants:change", this.updateParticipants, this);
38-
3932
// Define file for code editor
4033
this.editor.sync.setFile(this.model, {
4134
'sync': this.options.edition
@@ -59,42 +52,6 @@ define([
5952
this.updateParticipants();
6053

6154
return FileEditorView.__super__.finish.apply(this, arguments);
62-
},
63-
64-
// (action) Toggle fullscreen
65-
toggleFullscreen: function(e) {
66-
e.preventDefault();
67-
this.$el.toggleClass("mode-fullscreen");
68-
},
69-
70-
// (action) change editor mode
71-
changeEditorMode: function(e) {
72-
e.preventDefault();
73-
var mode = $(e.currentTarget).data("editormode");
74-
this.editor.setMode(mode);
75-
},
76-
77-
// (event) Mode changed
78-
modeChanged: function() {
79-
var mode = this.editor.getMode();
80-
this.$("a[data-editormode!='"+mode+"']").removeClass("active");
81-
this.$("a[data-editormode='"+mode+"']").addClass("active");
82-
},
83-
84-
// Update participants list
85-
updateParticipants: function() {
86-
var $participants = this.$(".file-participants").empty();
87-
_.each(this.editor.sync.participants, function(participant) {
88-
$("<a>", {
89-
'text': participant.user.get("name"),
90-
'href': "#",
91-
'class': "list-group-item",
92-
'css': {
93-
'border-left-color': participant.color
94-
},
95-
'click': function(e) { e.preventDefault(); }
96-
}).appendTo($participants);
97-
}, this);
9855
}
9956
});
10057

client/config.js

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,6 @@
11
define([], function() {
22
var configs = {
3-
/* Editor */
4-
editor: {
5-
default_theme: "github",
6-
default_keyboard: "textinput",
7-
themes: {
8-
"clouds": "Clouds",
9-
"monokai": "Monokai",
10-
"chrome": "Chrome",
11-
"clouds_midnight": "Clouds Midnight",
12-
"cobalt": "Cobalt",
13-
"crimson_editor": "Crimson editor",
14-
"tomorrow": "Tomorrow",
15-
"tomorrow_night": "Tomorrow Night",
16-
"tomorrow_night_blue": "Tomorrow Night Blue",
17-
"tomorrow_night_bright": "Tomorrow Night Bright",
18-
"tomorrow_night_eighties": "Tomorrow Night Eighties",
19-
"twilight": "Twilight",
20-
"dawn": "Dawn",
21-
"dreamweaver": "Dreamweaver",
22-
"eclipse": "Eclipse",
23-
"merbivore": "Merbivore",
24-
"merbivore_soft": "Merbivore Soft",
25-
"mono_industrial": "Mono Industrial",
26-
"pastel_on_dark": "Pastel On Dark",
27-
"solarized_dark": "Solarized Dark",
28-
"solarized_light": "Solarized Light",
29-
"textmate": "Textmate",
30-
"github": "GitHub"
31-
},
32-
keyboards: {
33-
"vim": "Vim",
34-
"emacs": "Emacs",
35-
"textinput": "Default"
36-
},
37-
modes: {
38-
"text": "Plain text",
39-
"python": "Python",
40-
"php": "Php",
41-
"ruby": "Ruby",
42-
"perl": "Perl",
43-
"scala": "Scala",
44-
"lua": "Lua",
45-
"java": "Java",
46-
"c_cpp": "C/C++",
47-
"csharp": "C#",
48-
"coffee": "Coffee",
49-
"javascript": "Javascript",
50-
"css": "Css",
51-
"scss": "Scss",
52-
"less": "Less",
53-
"html": "HTML",
54-
"latex": "Latex",
55-
"markdown": "Markdown",
56-
"textile": "Textile",
57-
"json": "Json",
58-
"xml": "XML",
59-
"sh": "Sh",
60-
"sql": "SQL",
61-
"pgsql": "pgSQL",
62-
"clojure": "Clojure",
63-
"coldfusion": "Coldfusion",
64-
"golang": "Go",
65-
"groovy": "Groovy",
66-
"haxe": "Haxe",
67-
"liquid": "Liquid",
68-
"ocaml": "OCaml",
69-
"powershell": "Powershell",
70-
"scad": "Scad",
71-
"svg": "SVG",
72-
"xquery": "XQuery",
73-
"yaml": "YAML"
74-
}
75-
},
3+
764
};
775

786
return configs;

0 commit comments

Comments
 (0)