diff --git a/app/assets/stylesheets/shared/inline_edit.scss b/app/assets/stylesheets/shared/inline_edit.scss index cf7a408e9..145f5993c 100644 --- a/app/assets/stylesheets/shared/inline_edit.scss +++ b/app/assets/stylesheets/shared/inline_edit.scss @@ -28,6 +28,7 @@ .sci-inline-edit__view { cursor: pointer; + white-space: pre-wrap; width: 100%; &.blank { diff --git a/app/javascript/vue/protocol/step_elements/checklistItem.vue b/app/javascript/vue/protocol/step_elements/checklistItem.vue index 8e4b7cfd4..e6e74b090 100644 --- a/app/javascript/vue/protocol/step_elements/checklistItem.vue +++ b/app/javascript/vue/protocol/step_elements/checklistItem.vue @@ -26,6 +26,8 @@ :multilinePaste="true" :editOnload="checklistItem.attributes.isNew" :smartAnnotation="true" + :saveOnEnter="false" + :allowNewLine="true" @editingEnabled="enableTextEdit" @editingDisabled="disableTextEdit" @update="updateText" diff --git a/app/javascript/vue/shared/inline_edit.vue b/app/javascript/vue/shared/inline_edit.vue index 057e1c2d4..d280bf604 100644 --- a/app/javascript/vue/shared/inline_edit.vue +++ b/app/javascript/vue/shared/inline_edit.vue @@ -40,6 +40,8 @@ characterLimit: { type: Number }, placeholder: { type: String }, autofocus: { type: Boolean, default: false }, + saveOnEnter: { type: Boolean, default: true }, + allowNewLine: { type: Boolean, default: false }, multilinePaste: { type: Boolean, default: false }, smartAnnotation: { type: Boolean, default: false }, editOnload: { type: Boolean, default: false } @@ -134,17 +136,16 @@ } }, handleInput() { - this.newValue = this.newValue.replace(/^[\n\r]+|[\n\r]+$/g, ''); + if (!this.allowNewLine) { + this.newValue = this.newValue.replace(/^[\n\r]+|[\n\r]+$/g, ''); + } this.$nextTick(this.resize); }, handleKeypress(e) { - switch(e.key) { - case 'Escape': - this.cancelEdit(); - break; - case 'Enter': - this.update(); - break; + if (e.key == 'Escape') { + this.cancelEdit(); + } else if (e.key == 'Enter' && this.saveOnEnter) { + this.update(); } }, resize() {