//////////////////////////////////////////////////////////////////////////// // A multiline text editor with "Submit" and "Cancel" buttons. // // Available keybindings: // * Ctrl+Enter Submit // * Escape Cancel // // Events: // * submit-edit(String) Some text should be saved // * cancel-edit The edit has been cancelled // //////////////////////////////////////////////////////////////////////////// // TODO: check that it's okay that editors have been wrapped into
// TODO: I can recall 'section' being removed from item-info, maybe that's important Vue.component('AEditor', { props: { // Text to populate the editor with initContent: {type: String, default: ""}, // Instruction for the user instruction: {type: String, required: true}, // How many rows the editor should have rows: {type: Number, required: true}, // Whether editor content should be reset on cancel resetOnCancel: {type: Boolean, default: true}, }, data: function() { return { content: this.initContent, }}, methods: { onSubmitEdit() { this.$emit('submit-edit', this.content); }, onCancelEdit() { if (this.resetOnCancel) this.content = this.initContent; this.$emit('cancel-edit'); }, }, // TODO: another messy template; also, can use