SmartBlocks icon indicating copy to clipboard operation
SmartBlocks copied to clipboard

Open a Block in the Sidebar from within a Workflow

Open eatondpe opened this issue 4 years ago • 5 comments

✂️ Copy of your #42SmartBlock from Roam

  • Open Block in Sidebar #42SmartBlock
    
    • <%J:```javascript
      setTimeout(()=>{
         roam42KeyboardLib.simulateKey(79,100,{ctrlKey:true,shiftKey:true});  
      }, 200);
      return '';```%>
      

📋 Describe the SmartBlock

This SmartBlock opens the current block in the sidebar by simulating a CTRL+SHIFT+O keyboard entry. This could be useful in workflows in which a certain block is desired to be pinned.

✅ Describe any prerequisites or dependencies that are required for this SmartBlock

None.

📷 Screenshot of your #42SmartBlock workflow/template from Roam

image

💡 Additional Info

eatondpe avatar Jan 22 '21 14:01 eatondpe

Nice work @eatondpe.

I have been trying to find documentation of the roam42 keyboardlib and even had a look at source code. I couldn't find it.

Can you point me in the right direction? Cheers!

mlava avatar Jan 23 '21 00:01 mlava

@mlava I wish I could. I still have not found any such documentation. I just found what I needed in someone else's code.

@roamhacker Do you know where we can find documentation on the keyboardlib you use?

eatondpe avatar Jan 23 '21 01:01 eatondpe

@mlava Or I should say, I saw an example of including shiftKey=true and guessed that ctrlKey must also exist. The rest was just experimentation.

eatondpe avatar Jan 23 '21 01:01 eatondpe

If you search the whole roam42 code base you will see examples of its use. It is basically using some standard JS stuff for key events. It can't emulate everything in every scenario. So you have to test thoroughly. But it can emulate letters, numbers and combinations of holding CTRL, SHIFT, ALT

Also useful is the mouse click commands in 42. you can simulate left and right mouse clicks.

TfTHacker avatar Jan 23 '21 06:01 TfTHacker

Thanks @eatondpe and @roamhacker

I will search the code. Cheers!

mlava avatar Jan 24 '21 00:01 mlava