From c987a636afa7e02fb3474893705d588aee58986c Mon Sep 17 00:00:00 2001 From: Matthew Welch Date: Mon, 18 Jan 2021 19:35:21 -0800 Subject: [PATCH] Added multiple cell selection Added copy functionality for the table --- src/css/style.css | 6 +- src/editor.html | 17 +- src/index.js | 13 + src/js/editor.js | 321 +++++-- src/js/selectable.js | 1965 ++++++++++++++++++++++++++++++++++++++ src/js/selectable.min.js | 51 + yarn.lock | 12 +- 7 files changed, 2271 insertions(+), 114 deletions(-) create mode 100644 src/js/selectable.js create mode 100644 src/js/selectable.min.js diff --git a/src/css/style.css b/src/css/style.css index e8e4052..0229355 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -12,10 +12,14 @@ nav::-webkit-scrollbar { display: none; } -.selected { +.ui-selected { background-color: #24c278 !important; } +.ui-selecting { + background-color: #aae5d4 !important; +} + .context-menu { position: absolute; background: white; diff --git a/src/editor.html b/src/editor.html index cbcafcb..9738a06 100644 --- a/src/editor.html +++ b/src/editor.html @@ -1,11 +1,11 @@ - - Web Editor - + + Web Editor + - +
@@ -81,12 +81,13 @@
+ diff --git a/src/index.js b/src/index.js index 062555d..1f49d8b 100644 --- a/src/index.js +++ b/src/index.js @@ -58,6 +58,19 @@ let menu_template = [ } } ] + }, + { + label: "Edit", + submenu: [ + { + label: "Copy", + accelerator: "Ctrl+C", + click: function () { + let window = BrowserWindow.getFocusedWindow(); + window.webContents.send("copy-to-clipboard"); + } + }, + ] } ] diff --git a/src/js/editor.js b/src/js/editor.js index 0432884..45f071a 100644 --- a/src/js/editor.js +++ b/src/js/editor.js @@ -1,4 +1,4 @@ -const { ipcRenderer } = require('electron'); +const { ipcRenderer, clipboard } = require('electron'); let json_data; let tables_data; let current_table; @@ -17,25 +17,11 @@ let detail_column_sortable = $("#detail-column-sortable"); let detail_cell_text = $("#detail-cell-text"); let position_edit_btn = $("#position-edit"); -function openFile(file) { - if (typeof file == "object") { - json_data = file; - tables_data = file["tables"]; - current_table = null; - refreshPage(); - } else { - $.ajax({ - dataType: "json", - url: file, - cache: false, - success: (json, textStatus, jqXHR) => { - json_data = json; - tables_data = json["tables"]; - current_table = null; - refreshPage(); - } - }); - } +function openFile(json) { + json_data = json; + tables_data = json["tables"]; + current_table = null; + refreshPage(); } function saveFile(create_new_file) { @@ -63,7 +49,6 @@ function generateTable(table_data, table_index) { let a = $("
") .attr("id", table_id + "-nav") .addClass("btn nav-link table-nav") - // .attr("href", "#" + table_id) .text(table_data["name"]) .on("click", () => { showTab(table_id); @@ -71,7 +56,7 @@ function generateTable(table_data, table_index) { .on("contextmenu", (event) => { navContextMenu(event, table_id); }); - let add_table_btn = nav.find("a[id='add-table']"); + let add_table_btn = nav.find("[id='btn-add-table']"); if (add_table_btn.length !== 0) { add_table_btn.before(a); } else { @@ -124,10 +109,8 @@ function generateTable(table_data, table_index) { function makeCell(cell_id, cell_text) { return $("") .attr("id", cell_id) + .addClass("ui-selectable") .text(cell_text) - .on("click", () => { - selectCell(cell_id); - }) .on("contextmenu" , (event) => { cellContextMenu(event, cell_id); }) @@ -140,10 +123,8 @@ function makeHeader(header_id, header_index, col_title) { return $("") .attr("id", header_id) .css("user-select", "none") + .addClass("ui-selectable") .text(col_title) - .on("click", () => { - selectCell(header_id); - }) .on("contextmenu", (event) => { headerContextMenu(event, header_id); }) @@ -175,8 +156,8 @@ function generateTables() { .on("click", () => { insertRow(current_table, -1) }))) - nav.append($("") - .attr("id", "add-table") + nav.append($("