mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-08 16:07:37 +08:00
f0606b109d
* Improve file select layout on long paths * Automatically back up notebooks without a file * Run formatter * Add margin when there are no sections * Add an informative note about autosave directory * Store autosave path instead of file in the config * Rename autosave dir to autosave path * Fix insert mode escape on section headlines * Show ellipsis on selected file too * Always create the default directory * Apply review comments
28 lines
552 B
JavaScript
28 lines
552 B
JavaScript
import { isEditableElement } from "../lib/utils";
|
|
|
|
/**
|
|
* A hook used to focus an element whenever it receives LV update.
|
|
*/
|
|
const FocusOnUpdate = {
|
|
mounted() {
|
|
this.__focus();
|
|
},
|
|
|
|
updated() {
|
|
if (this.el !== document.activeElement) {
|
|
this.__focus();
|
|
}
|
|
},
|
|
|
|
__focus() {
|
|
if (isEditableElement(document.activeElement)) {
|
|
return;
|
|
}
|
|
|
|
this.el.focus();
|
|
this.el.selectionStart = this.el.selectionEnd = this.el.value.length;
|
|
this.el.scrollLeft = this.el.scrollWidth;
|
|
},
|
|
};
|
|
|
|
export default FocusOnUpdate;
|