zsviczian / obsidian-excalidraw-plugin

A plugin to edit and view Excalidraw drawings in Obsidian
4.16k stars 230 forks source link

FR: Allow (individual) PDF pages to be selected, moved, and deleted. #1278

Open Captain-Pumpkinhead opened 1 year ago

Captain-Pumpkinhead commented 1 year ago

Is your feature request related to a problem? Please describe. I'm filling out my college course's lecture notes on Obsidian-Excalidraw, and not every page is used. I could select specific pages when importing, but I don't know which pages will be skipped until my professor gets to that point in the lesson.

Describe the solution you'd like I'd like to be able to select individual PDF pages and delete or move them. This may lead to conflicts like #1277, where an eraser erases the page in addition to the pen strokes. To avoid this, I propose the eraser not work on PDF pages. If the user wants to erase a page, it must be selected via the select tool and deleted that way.

Describe alternatives you've considered To workaround this, I've been importing the PDF as images, so I can delete or move the pages as needed. This lead to the conflict described in #1277.

zsviczian commented 1 year ago

1

3 simple steps will give you flexibility: 1) Import PDF pages without locking them. 2) before doing anything else, select the imported pages and group them 3) then select the group and lock.

Next time you need to move, edit, or delete, you can right-click any of the pages to unlock. Then double-click the PDF page you want to move or delete... and do that. Once done, click any of the pages on the canvas within the group and lock the group.

2

It is super easy to automate this also with an Excalidraw Script.

1) Create an empty file under Excalidraw/Scripts 2) Copy this code to the file

pdfs = ea.getViewElements().filter(el=>el.type==="image" && ea.getViewFileForImageElement(el)?.extension === "pdf");
if(pdfs.length === 0) return;
ea.copyViewElementsToEAforEditing(pdfs);
ea.getElements().forEach(el=>{
  el.locked = !el.locked;
});
ea.addElementsToView();
image

3) Create a hotkey

image

This script will toggle all PDF images locked/unlocked