Open utterances-bot opened 6 months ago
Is there a command to insert around editing cursor? Eg. I want smth like
insertAroundEditingCursor('[[', ']]')
so that I can create a shortcut for "insert a page reference"
@neongreen
Is there a command to insert around editing cursor? Eg. I want smth like
insertAroundEditingCursor('[[', ']]')
so that I can create a shortcut for "insert a page reference"
Several steps are required. The "pos" accept the position of the letter. https://logseq.github.io/plugins/types/BlockCursorPosition.html Thus, the following process is possible.
const blockEntity = await logseq.Editor.getCurrentBlock()
if(blockEntity){
const blockPos = await logseq.Editor.getEditingCursorPosition()
if(blockPos){
await logseq.Editor.insertAtEditingCursor("[[]]")
setTimeout(() => {
await logseq.Editor.editBlock(blockEntity.uuid, { pos: blockPos.pos+2 })
}, 200)
}
}
I have never done anything similar so I am guessing. This is a TypeScript expression. (Sorry, I forgot how to write JavaScript)
https://plugins-doc.logseq.com/logseq/Editor/insertAtEditingCursor