zsviczian / obsidian-excalidraw-plugin

A plugin to edit and view Excalidraw drawings in Obsidian
4.32k stars 234 forks source link

FR: add a quick action to create a task #1328

Open Zorro122 opened 1 year ago

Zorro122 commented 1 year ago

Using excalidraw on an iPad with a pencil it's quite hard while using scribble to get it to recognize the "- [ ]" to create a new task

In "normal" obsidian the Tasks plugin offers the possibilty to add on mobile devices a quick action within the toolbar to create a task, would that be possible to be added to excalidraw as well? The whole toolbar which is available in markdowns is hidden in excalidraw files.

Alternate would most likely be a script to run, but there my knowdlege is not good enough to do such a thing, I found this entry in the Tasks Plugin documentation but simply don't know what to do with it https://publish.obsidian.md/tasks/Advanced/Tasks+Api

Settings in obsidian on iPad: image

Toolbar in markdowns: image

After clicking on Create or edit task button: image

Something in this direction would be a huge game changer to manage tasks in the excalidraw environment on Tablets without an additional keyboard but simply allowing users to draw with a pencil, hit a button create a task, continue drawing without any interference.

Zorro122 commented 1 year ago

I got some help and I think we found a reasonable solution, what you need to do, you need to select an existing element and below script will add a task on the right hand side to the selected element:

` /*


*/
selectedElement = ea.getViewSelectedElement();
ea.setStrokeSharpness(0);
const tasksApi = this.app.plugins.plugins['obsidian-tasks-plugin'].apiV1; 
const taskLine = await tasksApi.createTaskLineModal(); 
id = ea.addText(
selectedElement.x + selectedElement.width+10,
selectedElement.y,
taskLine,
{
  textAlign:"center",
  box:false,
  width:selectedElement.width,
}
);
ea.addElementsToView();
`

If you want, feel free to use (and further tune) it 👍