Don't add four spaces when tabbing to indent list in note

Fixes #1236
This commit is contained in:
Dan Stillman 2018-10-20 03:35:15 -04:00
parent cbd8fa151d
commit c7915e5bc2
2 changed files with 18 additions and 31 deletions

View file

@ -322,47 +322,26 @@
<parameter name="event"/> <parameter name="event"/>
<body> <body>
<![CDATA[ <![CDATA[
var noteField = this._id('noteField');
switch (event.keyCode) { switch (event.keyCode) {
case 9: case 9:
if (event.ctrlKey || event.altKey) { // On Shift-Tab, if focus was moved out of the note, focus the element
return; // specified in the 'previousfocus' attribute. We check for focus
} // because Shift-Tab doesn't and shouldn't move focus out of the note if
// the cursor is in a list.
event.stopPropagation();
event.preventDefault();
// On shift-tab, focus the element specified in
// the 'previousfocus' attribute
if (event.shiftKey) { if (event.shiftKey) {
let id = this.getAttribute('previousfocus'); let id = this.getAttribute('previousfocus');
if (id) { if (id) {
setTimeout(function () { setTimeout(() => {
document.getElementById(id).focus(); if (!noteField.hasFocus()) {
document.getElementById(id).focus();
}
}, 0); }, 0);
} }
return; return;
} }
// Insert tab manually
//
// From http://kb.mozillazine.org/Inserting_text_at_cursor
try {
var command = "cmd_insertText";
var controller = document.commandDispatcher.getControllerForCommand(command);
if (controller && controller.isCommandEnabled(command)) {
controller = controller.QueryInterface(Components.interfaces.nsICommandController);
var params = Components.classes["@mozilla.org/embedcomp/command-params;1"]
.createInstance(Components.interfaces.nsICommandParams);
params.setStringValue("state_data", "\t");
controller.doCommandWithParams(command, params);
}
}
catch (e) {
Zotero.debug("Can't do cmd_insertText!\n" + e, 1);
}
// DEBUG: is there a better way to prevent blur()?
setTimeout(function() { event.target.focus(); }, 1);
break; break;
} }
]]> ]]>

View file

@ -600,6 +600,14 @@
</body> </body>
</method> </method>
<method name="hasFocus">
<body>
<![CDATA[
return this._editor ? this._editor.hasFocus() : false;
]]>
</body>
</method>
<method name="clearUndo"> <method name="clearUndo">
<body> <body>
<![CDATA[ <![CDATA[