Files
obsidian-excalidraw-plugin/ea-scripts/Scribble Helper.md
Zsolt Viczian a11c195ea4 scribble script
2022-02-06 23:33:30 +01:00

1.1 KiB

/*

iOS scribble helper for better handwriting experience with text elements. If no elements are selected then the creates a text element at pointer position and you can use the edit box to modify the text with scribble. If a text element is selected then opens the input prompt where you can modify this text with scribble.

*/


elements = ea.getViewSelectedElements().filter(el=>el.type==="text");
if(elements.length > 1) {
  new Notice ("Select only 1 or 0 text elements.")
  return;
}

const text = await utils.inputPrompt("Edit text","",(elements.length === 1)?elements[0].rawText:"");
if(!text) return;

if(elements.length === 1) {
	ea.copyViewElementsToEAforEditing(elements);
  ea.getElements()[0].originalText = text;
  ea.getElements()[0].text = text;
  ea.getElements()[0].rawText = text;
  await ea.addElementsToView(false,true);
  return;
}

ea.addText(0,0,text);
await ea.addElementsToView(true, true, true);