Excalidraw Clothesline Workflow #350
zsviczian
started this conversation in
Templates Showcase
Replies: 1 comment
-
The new script works with Excalidraw 1.3.0. Here's the visually upgraded Empty Clothesline template. And the link to the video that will walk you through the details. The Script<%*
// Initialize ExcalidrawAutomate
const ea = ExcalidrawAutomate;
ea.reset();
ea.style.fontSize = 9;
ea.style.textAlign = "center";
ea.setFontFamily(1);
ea.setFillStyle(2); //solid fill
ea.style.strokeColor = "black";
ea.setView("first");
//get offset
const towelWidth = 76;
const towelHeight = 65;
const selectedElement = ea.getViewSelectedElement();
let [offsetX,offsetY] = [0,0];
if(selectedElement) {
offsetX = selectedElement.x;
offsetY = selectedElement.y+towelHeight+5;
}
//Get card title and card-details file name
const file_name = tp.file.title;
const editor = app.workspace.activeLeaf.view.editor;
const curLineNum = editor.getCursor().line;
const curLine = editor.getLine(curLineNum);
const card_title = curLine.match(/#+\s+(.*)/)[1];
const card_title_wrapped = ea.wrapText(card_title,15);
//Towel
ea.style.backgroundColor = "WhiteSmoke";
const idTowel = ea.addRect(offsetX,offsetY,towelWidth,towelHeight);
//Clip
const colors = ["#40c057","#7950f2","#228be6","#fa5252","#fab005","#868e96"]
const clipcolor = colors[Math.floor(Math.random()*colors.length)];
ea.style.backgroundColor = clipcolor;
const clipWidth = 8;
const idClip = ea.addRect(offsetX+(towelWidth-clipWidth)/2,offsetY-9,clipWidth,14);
const idClipSpring = ea.addLine([[offsetX+(towelWidth-clipWidth)/2,offsetY-2],
[offsetX+(towelWidth+clipWidth)/2,offsetY-2]]);
//Text
const idText = ea.addText(offsetX,offsetY+10,card_title_wrapped);
const textElement = ea.getElement(idText);
textElement.x = offsetX+(towelWidth - textElement.width)/2;
//Details Link
const idDetails = ea.addText(offsetX+towelWidth-11,offsetY+towelHeight-11,`[[${file_name}#${card_title}|»]]`);
const textDetails = ea.getElement(idDetails);
textDetails.width = 10; //In preview mode the text will be much shorter than the markdown supplied
//Add to the view
ea.addToGroup([idTowel,idClip,idClipSpring,idText,idDetails]);
ea.addElementsToView(!selectedElement,true); //recalculate position around pointer if no element is selected, save file after action
%> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is the accompanying templater script to the detailed walkthrough video introducing the Clothesline Method and creating a templater script to help automate the workflow.
Here's the Obsidian Excalidraw template for use with the script: Empty Clothesline.md
The script
Beta Was this translation helpful? Give feedback.
All reactions