Skip to content

Commit

Permalink
Merge branch 'master' of github.com:yoavst/Graffiti
Browse files Browse the repository at this point in the history
  • Loading branch information
yoavst committed Nov 11, 2024
2 parents cb7fd7a + 5fbffb5 commit 05ea1b7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
5 changes: 5 additions & 0 deletions frontends/web/images/icons/icon_copy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions frontends/web/scripts/TabController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1498,6 +1498,14 @@ config:
this.cachedMermaid = null;
this.draw();
}

copyNodeText() {
if (this._selectedNode == null) {
logEvent("No selected node");
return;
}
navigator.clipboard.writeText(this._selectedNode.overrideLabel ?? this._selectedNode.label);
}
}

const NODE_COMPUTED_PROPERTIES = "computedProperties";
Expand Down
10 changes: 10 additions & 0 deletions frontends/web/scripts/commandPalette.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,16 @@ class CommandPalette {
event_overrideLabel();
},
},
{
id: "CopyNodeText",
title: "Copy the text of the selected node to the clipboard",
hotkey: "Ctrl+c",
icon: iconFor("copy"),
section: "General",
handler: () => {
event_copyNodeText();
}
}
];
}
}
Expand Down
11 changes: 10 additions & 1 deletion frontends/web/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ function event_deleteSubtree() {
});
}

function event_copyNodeText() {
window.tabsController.onCurrent((_, controller) => {
controller.copyNodeText();
});
}

function event_shareGraph() {
Swal.fire({
title: "Share graph",
Expand Down Expand Up @@ -749,7 +755,7 @@ function initiateConnectionUrl() {

function initiateHotkeys() {
hotkeys(
"esc,ctrl+z,ctrl+shift+z,ctrl+y,ctrl+s,ctrl+alt+s,ctrl+o,ctrl+i,ctrl+alt+shift+i,ctrl+q,ctrl+f,ctrl+shift+f,ctrl+k,ctrl+e,ctrl+shift+q,ctrl+shift+p,delete,ctrl+delete,home,ctrl+home,shift+`,/,shift+/,ctrl+shift+/,ctrl+a,1,2,3,4,5,6,7,8,9",
"esc,ctrl+z,ctrl+shift+z,ctrl+y,ctrl+s,ctrl+alt+s,ctrl+o,ctrl+i,ctrl+alt+shift+i,ctrl+q,ctrl+f,ctrl+shift+f,ctrl+k,ctrl+e,ctrl+shift+q,ctrl+shift+p,delete,ctrl+delete,ctrl+c,home,ctrl+home,shift+`,/,shift+/,ctrl+shift+/,ctrl+a,1,2,3,4,5,6,7,8,9",
function (event, handler) {
window.commandPalette.close();
switch (handler.key) {
Expand Down Expand Up @@ -793,6 +799,9 @@ function initiateHotkeys() {
case "ctrl+delete":
event_deleteSubtree();
return false;
case "ctrl+c":
event_copyNodeText();
return false;
case "home":
event_focusOnSelected();
return false;
Expand Down

0 comments on commit 05ea1b7

Please sign in to comment.