Skip to content

Build your personal knowledge base with Trilium Notes

copy paste, undo, redo, select all shortcuts supported on mac build

azivnerb8a74c727e5e
diff --git a/src/public/javascripts/services/bootstrap.js b/src/public/javascripts/services/bootstrap.js
index 8e3d4f93e3..b1622538d4 100644
--- a/src/public/javascripts/services/bootstrap.js
+++ b/src/public/javascripts/services/bootstrap.js
@@ -104,6 +104,21 @@ if (utils.isElectron()) {
});
}
+function exec(cmd) {
+ document.execCommand(cmd);
+
+ return false;
+}
+
+if (utils.isElectron() && utils.isMac()) {
+ utils.bindShortcut('ctrl+c', () => exec("copy"));
+ utils.bindShortcut('ctrl+v', () => exec('paste'));
+ utils.bindShortcut('ctrl+x', () => exec('cut'));
+ utils.bindShortcut('ctrl+a', () => exec('selectAll'));
+ utils.bindShortcut('ctrl+z', () => exec('undo'));
+ utils.bindShortcut('ctrl+y', () => exec('redo'));
+}
+
$("#export-note-button").click(function () {
if ($(this).hasClass("disabled")) {
return;
@@ -118,4 +133,4 @@ entrypoints.registerEntrypoints();
tooltip.setupTooltip();
-bundle.executeStartupBundles();
\ No newline at end of file
+bundle.executeStartupBundles();
diff --git a/src/public/javascripts/services/utils.js b/src/public/javascripts/services/utils.js
index ea1f8edd1b..d88a8e574a 100644
--- a/src/public/javascripts/services/utils.js
+++ b/src/public/javascripts/services/utils.js
@@ -46,6 +46,10 @@ function isElectron() {
return window && window.process && window.process.type;
}
+function isMac() {
+ return navigator.platform.indexOf('Mac') > -1;
+}
+
function assertArguments() {
for (const i in arguments) {
if (!arguments[i]) {
@@ -150,6 +154,7 @@ export default {
formatDateTime,
now,
isElectron,
+ isMac,
assertArguments,
isTopLevelNode,
isRootNode,