mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
escape will close the attribute dialog and cancel changes
This commit is contained in:
parent
e8114fcc4f
commit
647863b489
@ -69,7 +69,7 @@ const TPL = `
|
|||||||
<div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
|
<div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
|
||||||
<h5 class="attr-detail-title"></h5>
|
<h5 class="attr-detail-title"></h5>
|
||||||
|
|
||||||
<span class="bx bx-x close-attr-detail-button"></span>
|
<span class="bx bx-x close-attr-detail-button" title="Cancel changes and close"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="attr-is-owned-by"></div>
|
<div class="attr-is-owned-by"></div>
|
||||||
@ -190,7 +190,7 @@ const ATTR_HELP = {
|
|||||||
"disableInclusion": "scripts with this label won't be included into parent script execution.",
|
"disableInclusion": "scripts with this label won't be included into parent script execution.",
|
||||||
"sorted": "keeps child notes sorted by title alphabetically",
|
"sorted": "keeps child notes sorted by title alphabetically",
|
||||||
"hidePromotedAttributes": "Hide promoted attributes on this note",
|
"hidePromotedAttributes": "Hide promoted attributes on this note",
|
||||||
"readOnly": "editor is in read only mode. Works only for text notes.",
|
"readOnly": "editor is in read only mode. Works only for text and code notes.",
|
||||||
"autoReadOnlyDisabled": "text/code notes can be set automatically into read mode when they are too large. You can disable this behavior on per-note basis by adding this label to the note",
|
"autoReadOnlyDisabled": "text/code notes can be set automatically into read mode when they are too large. You can disable this behavior on per-note basis by adding this label to the note",
|
||||||
"appCss": "marks CSS notes which are loaded into the Trilium application and can thus be used to modify Trilium's looks.",
|
"appCss": "marks CSS notes which are loaded into the Trilium application and can thus be used to modify Trilium's looks.",
|
||||||
"appTheme": "marks CSS notes which are full Trilium themes and are thus available in Trilium options.",
|
"appTheme": "marks CSS notes which are full Trilium themes and are thus available in Trilium options.",
|
||||||
@ -224,7 +224,7 @@ export default class AttributeDetailWidget extends TabAwareWidget {
|
|||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
|
|
||||||
utils.bindElShortcut(this.$widget, 'ctrl+return', () => this.saveAndClose());
|
utils.bindElShortcut(this.$widget, 'ctrl+return', () => this.saveAndClose());
|
||||||
utils.bindElShortcut(this.$widget, 'escape', () => alert("H!"));
|
utils.bindElShortcut(this.$widget, 'esc', () => this.cancelAndClose());
|
||||||
|
|
||||||
this.contentSized();
|
this.contentSized();
|
||||||
|
|
||||||
@ -291,6 +291,8 @@ export default class AttributeDetailWidget extends TabAwareWidget {
|
|||||||
this.$inputInheritable.on('change', () => this.userEditedAttribute());
|
this.$inputInheritable.on('change', () => this.userEditedAttribute());
|
||||||
|
|
||||||
this.$closeAttrDetailButton = this.$widget.find('.close-attr-detail-button');
|
this.$closeAttrDetailButton = this.$widget.find('.close-attr-detail-button');
|
||||||
|
this.$closeAttrDetailButton.on('click', () => this.cancelAndClose());
|
||||||
|
|
||||||
this.$attrIsOwnedBy = this.$widget.find('.attr-is-owned-by');
|
this.$attrIsOwnedBy = this.$widget.find('.attr-is-owned-by');
|
||||||
|
|
||||||
this.$attrSaveDeleteButtonContainer = this.$widget.find('.attr-save-delete-button-container');
|
this.$attrSaveDeleteButtonContainer = this.$widget.find('.attr-save-delete-button-container');
|
||||||
@ -316,8 +318,6 @@ export default class AttributeDetailWidget extends TabAwareWidget {
|
|||||||
this.$relatedNotesList = this.$relatedNotesContainer.find('.related-notes-list');
|
this.$relatedNotesList = this.$relatedNotesContainer.find('.related-notes-list');
|
||||||
this.$relatedNotesMoreNotes = this.$relatedNotesContainer.find('.related-notes-more-notes');
|
this.$relatedNotesMoreNotes = this.$relatedNotesContainer.find('.related-notes-more-notes');
|
||||||
|
|
||||||
this.$closeAttrDetailButton.on('click', () => this.hide());
|
|
||||||
|
|
||||||
$(window).on('mouseup', e => {
|
$(window).on('mouseup', e => {
|
||||||
if (!$(e.target).closest(this.$widget[0]).length
|
if (!$(e.target).closest(this.$widget[0]).length
|
||||||
&& !$(e.target).closest(".algolia-autocomplete").length
|
&& !$(e.target).closest(".algolia-autocomplete").length
|
||||||
@ -335,6 +335,14 @@ export default class AttributeDetailWidget extends TabAwareWidget {
|
|||||||
this.triggerCommand('focusOnAttributes', {tabId: this.tabContext.tabId});
|
this.triggerCommand('focusOnAttributes', {tabId: this.tabContext.tabId});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async cancelAndClose() {
|
||||||
|
await this.triggerCommand('reloadAttributes');
|
||||||
|
|
||||||
|
this.hide();
|
||||||
|
|
||||||
|
this.triggerCommand('focusOnAttributes', {tabId: this.tabContext.tabId});
|
||||||
|
}
|
||||||
|
|
||||||
userEditedAttribute() {
|
userEditedAttribute() {
|
||||||
this.updateAttributeInEditor();
|
this.updateAttributeInEditor();
|
||||||
this.updateHelp();
|
this.updateHelp();
|
||||||
|
@ -230,6 +230,10 @@ export default class AttributeListWidget extends TabAwareWidget {
|
|||||||
await this.attributeEditorWidget.save();
|
await this.attributeEditorWidget.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async reloadAttributesCommand() {
|
||||||
|
await this.attributeEditorWidget.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
updateAttributeListCommand({attributes}) {
|
updateAttributeListCommand({attributes}) {
|
||||||
this.attributeEditorWidget.updateAttributeList(attributes);
|
this.attributeEditorWidget.updateAttributeList(attributes);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user