diff --git a/manifest.json b/manifest.json index a59b598..e6c526e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "1.8.6", + "version": "1.8.7", "minAppVersion": "1.0.0", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/MarkdownPostProcessor.ts b/src/MarkdownPostProcessor.ts index d768c76..144cb45 100644 --- a/src/MarkdownPostProcessor.ts +++ b/src/MarkdownPostProcessor.ts @@ -55,6 +55,7 @@ export const initializeMarkdownPostProcessor = (p: ExcalidrawPlugin) => { */ const getIMG = async ( imgAttributes: imgElementAttributes, + onCanvas: boolean = false, ): Promise => { let file = imgAttributes.file; if (!imgAttributes.file) { @@ -83,7 +84,7 @@ const getIMG = async ( if (imgAttributes.fheight) { style += `height:${imgAttributes.fheight}px;`; } - img.setAttribute("style", style); + if(!onCanvas) img.setAttribute("style", style); img.addClass(imgAttributes.style); const theme = @@ -187,8 +188,9 @@ const getIMG = async ( const createImgElement = async ( attr: imgElementAttributes, + onCanvas: boolean = false, ) :Promise => { - const img = await getIMG(attr); + const img = await getIMG(attr,onCanvas); img.setAttribute("fileSource", attr.fname); if (attr.fwidth) { img.setAttribute("w", attr.fwidth); @@ -196,6 +198,8 @@ const createImgElement = async ( if (attr.fheight) { img.setAttribute("h", attr.fheight); } + img.setAttribute("draggable","false"); + img.setAttribute("onCanvas",onCanvas?"true":"false"); let timer:NodeJS.Timeout; const clickEvent = (ev:PointerEvent) => { @@ -236,15 +240,18 @@ const createImgElement = async ( const imgMaxWidth = img.style.maxWidth; const imgMaxHeigth = img.style.maxHeight; const fileSource = img.getAttribute("fileSource"); + const onCanvas = img.getAttribute("onCanvas") === "true"; const newImg = await createImgElement({ fname: fileSource, fwidth: img.getAttribute("w"), fheight: img.getAttribute("h"), style: img.getAttribute("class"), - }); + }, onCanvas); parent.empty(); - newImg.style.maxHeight = imgMaxHeigth; - newImg.style.maxWidth = imgMaxWidth; + if(!onCanvas) { + newImg.style.maxHeight = imgMaxHeigth; + newImg.style.maxWidth = imgMaxWidth; + } newImg.setAttribute("fileSource",fileSource); parent.append(newImg); }); @@ -253,8 +260,9 @@ const createImgElement = async ( const createImageDiv = async ( attr: imgElementAttributes, + onCanvas: boolean = false ): Promise => { - const img = await createImgElement(attr); + const img = await createImgElement(attr, onCanvas); return createDiv(attr.style, (el) => el.append(img)); }; @@ -408,15 +416,20 @@ const tmpObsidianWYSIWYG = async ( return; } internalEmbedDiv.empty(); - const imgDiv = await createImageDiv(attr); + const onCanvas = internalEmbedDiv.hasClass("canvas-node-content"); + const imgDiv = await createImageDiv(attr, onCanvas); if(markdownEmbed) { - internalEmbedDiv.addClass("markdown-embed"); - if(imgDiv.firstChild instanceof HTMLElement) { + if(onCanvas) { + internalEmbedDiv.removeClass("markdown-embed"); + internalEmbedDiv.addClass("media-embed"); + internalEmbedDiv.addClass("image-embed"); + } + if(!onCanvas && imgDiv.firstChild instanceof HTMLElement) { imgDiv.firstChild.style.maxHeight = "100%"; imgDiv.firstChild.style.maxWidth = null; - internalEmbedDiv.appendChild(imgDiv.firstChild); - return; } + internalEmbedDiv.appendChild(imgDiv.firstChild); + return; } internalEmbedDiv.appendChild(imgDiv); return; diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index 051b9c4..192521a 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,22 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
`, +"1.8.7":` +## New from Excalidraw.com +- Support shrinking text containers to their original height when text is removed [#6025](https://github.com/excalidraw/excalidraw/pull/6025) +
+ +
+ +## Fixed +- removed the white background when editing arrow-label [#6033](https://github.com/excalidraw/excalidraw/pull/6033) +- Minor style tweaks + - for embedding Excalidraw into Obsidian Canvas. e.g. dragging no longer accidentally creates an image copy of the drawing, and + - style tweaks on the Excalidraw canvas + +## New +- If you set a different text color and sticky note border color, now if you change the border color, the text color will not be changed. +`, "1.8.6":` ## New from Excalidraw.com: - Better default radius for rectangles [#5553](https://github.com/excalidraw/excalidraw/pull/5553). Existing drawings will look unchanged, this applies only to new rectangles.