mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
2.6.2
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.6.1",
|
||||
"version": "2.6.2",
|
||||
"minAppVersion": "1.1.6",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.6.1",
|
||||
"version": "2.6.2",
|
||||
"minAppVersion": "1.1.6",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
@@ -1106,8 +1106,48 @@ export class EmbeddedFilesLoader {
|
||||
}
|
||||
|
||||
const getSVGData = async (app: App, file: TFile, colorMap: ColorMap | null): Promise<DataURL> => {
|
||||
const svg = replaceSVGColors(await app.vault.read(file), colorMap) as string;
|
||||
return svgToBase64(svg) as DataURL;
|
||||
const svgString = replaceSVGColors(await app.vault.read(file), colorMap) as string;
|
||||
|
||||
try {
|
||||
const container = document.createElement('div');
|
||||
container.innerHTML = svgString;
|
||||
|
||||
const svgElement = container.querySelector('svg');
|
||||
|
||||
if (!svgElement) {
|
||||
throw new Error('Invalid SVG content'); // Ensure there's an SVG element
|
||||
}
|
||||
|
||||
// Check for width and height attributes
|
||||
const hasWidth = svgElement.hasAttribute('width');
|
||||
const hasHeight = svgElement.hasAttribute('height');
|
||||
|
||||
// If width or height is missing, calculate based on viewBox
|
||||
if (!hasWidth || !hasHeight) {
|
||||
const viewBox = svgElement.getAttribute('viewBox');
|
||||
|
||||
if (viewBox) {
|
||||
const [ , , viewBoxWidth, viewBoxHeight] = viewBox.split(/\s+/).map(Number);
|
||||
|
||||
// Set width and height based on viewBox if they are missing
|
||||
if (!hasWidth) {
|
||||
svgElement.setAttribute('width', `${viewBoxWidth}px`);
|
||||
}
|
||||
if (!hasHeight) {
|
||||
svgElement.setAttribute('height', `${viewBoxHeight}px`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the updated SVG string from outerHTML
|
||||
const updatedSVGString = svgElement.outerHTML;
|
||||
|
||||
// Convert the updated SVG string to a base64 Data URL
|
||||
return svgToBase64(updatedSVGString) as DataURL;
|
||||
} catch (error) {
|
||||
errorlog({ where: "EmbeddedFileLoader.getSVGData", error });
|
||||
return svgToBase64(svgString) as DataURL;
|
||||
}
|
||||
};
|
||||
|
||||
/*export const generateIdFromFile = async (file: ArrayBuffer): Promise<FileId> => {
|
||||
|
||||
@@ -17,6 +17,10 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
|
||||
|
||||
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://storage.ko-fi.com/cdn/kofi6.png?v=6" border="0" alt="Buy Me a Coffee at ko-fi.com" height=45></a></div>
|
||||
`,
|
||||
"2.6.2":`
|
||||
## Fixed
|
||||
- Image scaling issue with SVGs that miss the width and height property. [#8729](https://github.com/excalidraw/excalidraw/issues/8729)
|
||||
`,
|
||||
"2.6.1":`
|
||||
## New
|
||||
- Pen-mode single-finger panning enabled also for the "Selection" tool.
|
||||
|
||||
Reference in New Issue
Block a user