Alt-Enter in the editor to toggle&save the style
This commit is contained in:
parent
6df2392132
commit
4559162d45
|
@ -514,6 +514,10 @@
|
||||||
"message": "Enabled",
|
"message": "Enabled",
|
||||||
"description": "Label for the enabled state of styles"
|
"description": "Label for the enabled state of styles"
|
||||||
},
|
},
|
||||||
|
"styleEnabledToggleHint": {
|
||||||
|
"message": "Press Alt-Enter to toggle enabled/disabled state and save the style",
|
||||||
|
"description": "Help text for the '[x] enable' checkbox in the editor"
|
||||||
|
},
|
||||||
"styleInstall": {
|
"styleInstall": {
|
||||||
"message": "Install '$stylename$' into Stylus?",
|
"message": "Install '$stylename$' into Stylus?",
|
||||||
"description": "Confirmation when installing a style",
|
"description": "Confirmation when installing a style",
|
||||||
|
|
|
@ -672,7 +672,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="basic-info-enabled">
|
<div id="basic-info-enabled">
|
||||||
<input type="checkbox" id="enabled" class="style-contributor">
|
<input type="checkbox" id="enabled" class="style-contributor">
|
||||||
<label for="enabled" id="enabled-label" i18n-text="styleEnabledLabel"></label>
|
<label for="enabled" id="enabled-label" i18n-text="styleEnabledLabel"></label><!--
|
||||||
|
--><svg id="toggle-style-help" class="svg-icon info">
|
||||||
|
<use xlink:href="#svg-icon-help"/>
|
||||||
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<section id="actions">
|
<section id="actions">
|
||||||
|
|
15
edit.js
15
edit.js
|
@ -53,7 +53,8 @@ getCodeMirrorThemes();
|
||||||
var hotkeyRerouter = {
|
var hotkeyRerouter = {
|
||||||
commands: {
|
commands: {
|
||||||
save: true, jumpToLine: true, nextEditor: true, prevEditor: true,
|
save: true, jumpToLine: true, nextEditor: true, prevEditor: true,
|
||||||
find: true, findNext: true, findPrev: true, replace: true, replaceAll: true
|
find: true, findNext: true, findPrev: true, replace: true, replaceAll: true,
|
||||||
|
toggleStyle: true,
|
||||||
},
|
},
|
||||||
setState: function(enable) {
|
setState: function(enable) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
|
@ -166,6 +167,7 @@ function initCodeMirror() {
|
||||||
theme: "default",
|
theme: "default",
|
||||||
keyMap: prefs.get("editor.keyMap"),
|
keyMap: prefs.get("editor.keyMap"),
|
||||||
extraKeys: { // independent of current keyMap
|
extraKeys: { // independent of current keyMap
|
||||||
|
"Alt-Enter": "toggleStyle",
|
||||||
"Alt-PageDown": "nextEditor",
|
"Alt-PageDown": "nextEditor",
|
||||||
"Alt-PageUp": "prevEditor"
|
"Alt-PageUp": "prevEditor"
|
||||||
}
|
}
|
||||||
|
@ -179,6 +181,7 @@ function initCodeMirror() {
|
||||||
CM.commands.blockComment = function(cm) {
|
CM.commands.blockComment = function(cm) {
|
||||||
cm.blockComment(cm.getCursor("from"), cm.getCursor("to"), {fullLines: false});
|
cm.blockComment(cm.getCursor("from"), cm.getCursor("to"), {fullLines: false});
|
||||||
};
|
};
|
||||||
|
CM.commands.toggleStyle = toggleStyle;
|
||||||
|
|
||||||
// "basic" keymap only has basic keys by design, so we skip it
|
// "basic" keymap only has basic keys by design, so we skip it
|
||||||
|
|
||||||
|
@ -849,6 +852,11 @@ function jumpToLine(cm) {
|
||||||
}, {value: cur.line+1});
|
}, {value: cur.line+1});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleStyle() {
|
||||||
|
$('#enabled').checked = !$('#enabled').checked;
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
function refocusMinidialog(cm) {
|
function refocusMinidialog(cm) {
|
||||||
var section = cm.getSection();
|
var section = cm.getSection();
|
||||||
if (!section.querySelector(".CodeMirror-dialog")) {
|
if (!section.querySelector(".CodeMirror-dialog")) {
|
||||||
|
@ -1211,6 +1219,7 @@ function initHooks() {
|
||||||
node.addEventListener("change", onChange);
|
node.addEventListener("change", onChange);
|
||||||
node.addEventListener("input", onChange);
|
node.addEventListener("input", onChange);
|
||||||
});
|
});
|
||||||
|
document.getElementById("toggle-style-help").addEventListener("click", showToggleStyleHelp);
|
||||||
document.getElementById("to-mozilla").addEventListener("click", showMozillaFormat, false);
|
document.getElementById("to-mozilla").addEventListener("click", showMozillaFormat, false);
|
||||||
document.getElementById("to-mozilla-help").addEventListener("click", showToMozillaHelp, false);
|
document.getElementById("to-mozilla-help").addEventListener("click", showToMozillaHelp, false);
|
||||||
document.getElementById("from-mozilla").addEventListener("click", fromMozillaFormat);
|
document.getElementById("from-mozilla").addEventListener("click", fromMozillaFormat);
|
||||||
|
@ -1581,6 +1590,10 @@ function showToMozillaHelp() {
|
||||||
showHelp(t("styleMozillaFormatHeading"), t("styleToMozillaFormatHelp"));
|
showHelp(t("styleMozillaFormatHeading"), t("styleToMozillaFormatHelp"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showToggleStyleHelp() {
|
||||||
|
showHelp(t("helpAlt"), t("styleEnabledToggleHint"));
|
||||||
|
}
|
||||||
|
|
||||||
function showKeyMapHelp() {
|
function showKeyMapHelp() {
|
||||||
var keyMap = mergeKeyMaps({}, prefs.get("editor.keyMap"), CodeMirror.defaults.extraKeys);
|
var keyMap = mergeKeyMaps({}, prefs.get("editor.keyMap"), CodeMirror.defaults.extraKeys);
|
||||||
var keyMapSorted = Object.keys(keyMap)
|
var keyMapSorted = Object.keys(keyMap)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user