⚠️⚠️ BREAKING CHANGE ⚠️⚠️
I migrated the element type "iframe" to "embeddable". This is because iframe support on excalidraw.com will use the "embeddable" type. Migration is necessary for continued compatibility. You need to update Excalidraw to the latest version on all your devices otherwise if you open an already converted file with an older version, the embedded elements will be deleted from your drawing.
Fixed:
- PNG image caching resulting in broken images after Obsidian restarts
- SVG export now displays embedded iframes with the correct embed link (note this feature only works when you open the SVGs in a browser outside Obsidian).
Updated / fixed in Excalidraw Automate
- I updated
lib/ExcalidrawAutomate.d.ts
and published a new version of obsidian-excalidraw-plugin type library to npmjs. - Added new ExcalidrawAutomate functions:
addEmbeddable()
,DEVICE
,newFilePrompt()
, andgetLeaf()
addImage
andaddElementsToView
were extended with 1-1 additional optional parameter. As a result ofshouldRestoreElements
defaulting to false, all elements in the scene will no longer be updated (iframes will not blink) when you add elements via script.- There is a new event hook:
onPasteHook
. This will be called whenever the user pastes something to the canvas. You can use this callback if you want to do something additional during the onPaste event. In case you want to prevent the Excalidraw default onPaste action you must return false
async addImage(
topX: number,
topY: number,
imageFile: TFile | string,
scale: boolean = true, //default is true which will scale the image to MAX_IMAGE_SIZE, false will insert image at 100% of its size
anchor: boolean = true, //only has an effect if "scale" is false. If "anchor" is true the image path will include |100%, if false the image will be inserted at 100%, but if resized by the user it won't pop back to 100% the next time Excalidraw is opened.
): Promise<string>;
async addElementsToView(
repositionToCursor: boolean = false,
save: boolean = true,
newElementsOnTop: boolean = false,
shouldRestoreElements: boolean = false, //restore elements - auto-corrects broken, incomplete or old elements included in the update
): Promise<boolean>;
onPasteHook: (data: {
ea: ExcalidrawAutomate;
payload: ClipboardData;
event: ClipboardEvent;
excalidrawFile: TFile; //the file receiving the paste event
view: ExcalidrawView; //the excalidraw view receiving the paste
pointerPosition: { x: number; y: number }; //the pointer position on canvas
}) => boolean = null;
addEmbeddable(
topX: number,
topY: number,
width: number,
height: number,
url?: string,
file?: TFile
): string;
get DEVICE(): DeviceType;
/**
* Prompts the user with a dialog to select new file action.
* - create markdown file
* - create excalidraw file
* - cancel action
* The new file will be relative to this.targetView.file.path, unless the parent file is provided.
* If shouldOpenNewFile is true, the new file will be opened in a workspace leaf.
* targetPane control which leaf will be used for the new file.
* Returns the TFile for the new file or null if the user cancels the action.
* @param newFileNameOrPath
* @param shouldOpenNewFile
* @param targetPane //type PaneTarget = "active-pane"|"new-pane"|"popout-window"|"new-tab"|"md-properties";
* @param parentFile
* @returns
*/
newFilePrompt(
newFileNameOrPath: string,
shouldOpenNewFile: boolean,
targetPane?: PaneTarget,
parentFile?: TFile
): Promise<TFile | null>;
/**
* Generates a new Obsidian Leaf following Excalidraw plugin settings such as open in Main Workspace or not, open in adjacent pane if available, etc.
* @param origo // the currently active leaf, the origin of the new leaf
* @param targetPane //type PaneTarget = "active-pane"|"new-pane"|"popout-window"|"new-tab"|"md-properties";
* @returns
*/
getLeaf(
origo: WorkspaceLeaf,
targetPane?: PaneTarget
): WorkspaceLeaf;