trilium icon indicating copy to clipboard operation
trilium copied to clipboard

[Feature request] shortcut for ckeditor's edit block menu

Open leeyaunlong opened this issue 4 years ago • 8 comments

can you add the shortcut to popup the ckeditor's edit block menu? because some funcitons in block menu have the shortcut , but I want to quick access others(inline note , etc).

leeyaunlong avatar Jun 30 '20 02:06 leeyaunlong

would indeed be great to have shortcuts/hotkeys for some formatting like "inline code", "block code" and so on. I think it is dependent of Ckeditor, and maybe there is a plugin for that

koutto avatar Nov 03 '20 12:11 koutto

Checkout https://ckeditor.com/docs/ckeditor5/latest/features/autoformat.html

Things like inline/block code can be triggered in markdown fashion via typing `something` and ```

zadam avatar Nov 03 '20 20:11 zadam

It's not complete though. The checkbox (to-do list) does not work when doing [ ] or [x].

psybustermk2 avatar Mar 31 '21 14:03 psybustermk2

@psybustermk2 these will work in (not yet released) 0.47

zadam avatar Mar 31 '21 20:03 zadam

There is already 0.47.5 available. How can we trigger "edit block" menu from keyboard?

stgolem avatar Jul 24 '21 12:07 stgolem

@zadam was referring to the check box list, not the keyboard shortcuts

abitofevrything avatar Jul 24 '21 17:07 abitofevrything

I have been searching through the issues here asking about the keyboard shortcut (earliest I found was #764) and didn't find any solution. I needed this functionality badly so I came up with this JS backend code to trigger the ckeditor toolbar.

api.bindGlobalShortcut("ctrl+shift+p", function(){
    let button_off = document.querySelector('.ck.ck-button.ck-off.ck-block-toolbar-button');
    if (button_off)
        button_off.click();
    else
        document.querySelector('.ck.ck-button.ck-on.ck-block-toolbar-button').click();
});

I added a shortcut too for blockQuote which I use a lot. I don't know if this is the right way of doing it but it works for me. I love Trilium for being this customizable. Thanks @zadam !

api.bindGlobalShortcut("ctrl+shift+q", function(){
    api.getActiveTabTextEditor(function(editor){
        editor.execute('blockQuote');
    });
});

code-ink-space avatar Feb 16 '22 12:02 code-ink-space

@code-ink-space This is a good idea! However, in version 0.59.1, the multi-tag function will cause the shortcut key to not work. I made some changes:

api.bindGlobalShortcut("alt+q", function(){
    console.log("alt+q");
    let edit_block_buttons = document.querySelectorAll(".ck.ck-button.ck-block-toolbar-button");
        for (let item of edit_block_buttons) {
            console.log(item);
            if(!item.getAttribute("class").includes("ck-hidden")){
                item.click();
                continue;
            }
        }
});

WACrown avatar Mar 16 '23 02:03 WACrown

Trilium has entered maintenance mode. Future enhancements will be addressed in TrilumNext: https://github.com/TriliumNext/Notes/issues/100

meichthys avatar May 09 '24 03:05 meichthys