From e50248bde6fbe8ac3f669dacc71f9ed86dea9fdb Mon Sep 17 00:00:00 2001 From: Matthew Welch Date: Mon, 25 Jan 2021 16:39:05 -0800 Subject: [PATCH] Improved usability of the inline editing Fixed bug with using keyboard shortcuts for cut, copy, and paste --- src/css/style.css | 6 +++++ src/js/editor.ts | 58 +++++++++++++++++++++++++++++++---------------- 2 files changed, 45 insertions(+), 19 deletions(-) diff --git a/src/css/style.css b/src/css/style.css index 0229355..3279cd8 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -25,11 +25,17 @@ nav::-webkit-scrollbar { background: white; } +td, th { + white-space: pre-wrap; + min-width: 200px!important; +} + .inline-edit { padding: 0!important; } td.inline-edit > textarea, th.inline-edit > textarea { + white-space: normal; width: 100%; height: 100%; } diff --git a/src/js/editor.ts b/src/js/editor.ts index d5c201d..3be8be8 100644 --- a/src/js/editor.ts +++ b/src/js/editor.ts @@ -67,15 +67,14 @@ function generateTable(table_data) { let table_div = $("
") .attr("id", table_id + "-tab") - .addClass("tab-pane table-responsive text-nowrap") + .addClass("tab-pane table-responsive") .css({"margin-right": "100px"}); let table = $("
") .attr("id", table_id) .addClass("table table-bordered") .append($("") - .append($("") - .addClass("text-nowrap"))) + .append($(""))) .append(""); $.each(table_data["columns"], (i, col) => { @@ -118,7 +117,9 @@ function makeCell(cell_id, cell_text) { cellContextMenu(event, cell_id); }) .on("dblclick", (event) => { - cellInlineEdit(event); + if ($("textarea:focus").length == 0) { + cellInlineEdit(cell_id); + } }); } @@ -132,7 +133,9 @@ function makeHeader(header_id, header_index, col_title) { headerContextMenu(event, header_id); }) .on("dblclick", (event) => { - headerInlineEdit(event); + if ($("textarea:focus").length == 0) { + headerInlineEdit(header_id); + } }); } @@ -631,11 +634,15 @@ function navContextMenu(event, table_id) { menu.css({"top": y_pos, "left": x_pos}); } -function cellInlineEdit(event) { +function cellInlineEdit(cell_id) { if (is_positioning) {return;} let data = getSelectionData() - let target = $(event.target); + let target: JQuery = $("#"+cell_id); + let width = target.outerWidth(); + let height = target.outerHeight(); + console.log(height); let text_area = $("