add hotkey to copy contents with line breaks, fixes #349 (#831)

This commit is contained in:
Heniker 2020-01-19 11:16:36 +03:00 committed by zadam
parent 1690248e24
commit 1876664dfb
3 changed files with 17 additions and 2 deletions

View File

@ -241,7 +241,7 @@ function registerEntrypoints() {
d.showDialog(selectedOrActiveNodes);
}));
keyboardActionService.setGlobalActionHandler("CreateNoteIntoDayNote", async () => {
const todayNote = await dateNoteService.getTodayNote();
@ -288,6 +288,9 @@ function registerEntrypoints() {
searchNotesService.searchInSubtree(node.data.noteId);
});
$('document').on('copy', utils.copySelectionToClipboard)
keyboardActionService.setGlobalActionHandler("CopyWithoutFormating", utils.copySelectionToClipboard)
}
export default {

View File

@ -241,6 +241,13 @@ function getUrlForDownload(url) {
}
}
function copySelectionToClipboard() {
const text = window.getSelection().toString()
if (navigator.clipboard) {
navigator.clipboard.writeText(text)
}
}
export default {
reloadApp,
parseDate,
@ -273,5 +280,6 @@ export default {
isHtmlEmpty,
clearBrowserCache,
getUrlForDownload,
normalizeShortcut
normalizeShortcut,
copySelectionToClipboard
};

View File

@ -306,6 +306,10 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "ZoomIn",
defaultShortcuts: ["CommandOrControl+="]
},
{
actionName: "CopyWithoutFormating",
defaultShortcuts: ["Alt+Ctrl+C"]
}
];