Files
labelmaker/assets/js/hooks.js
2025-05-12 16:22:10 -04:00

20 lines
440 B
JavaScript

const Hooks = {};
Hooks.EnterToNewline = {
mounted() {
this.el.addEventListener('keydown', (e) => {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
const cursorPos = this.el.selectionStart;
const value = this.el.value;
this.el.value = value.slice(0, cursorPos) + '\\n' + value.slice(cursorPos);
this.el.selectionStart = this.el.selectionEnd = cursorPos + 2;
}
});
},
};
export default Hooks;