Compare commits

...

3 Commits

Author SHA1 Message Date
zsviczian
5972f83369 Merge pull request #2083 from dmscode/master
Update zh-cn.ts to 8f14f97
2024-10-30 22:08:28 +01:00
dmscode
0edfd7622c Update zh-cn.ts to 8f14f97 2024-10-29 07:36:30 +08:00
zsviczian
8f14f97007 2.6.2 2024-10-28 22:12:25 +01:00
5 changed files with 49 additions and 4 deletions

View File

@@ -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",

View File

@@ -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",

View File

@@ -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> => {

View File

@@ -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.

View File

@@ -355,6 +355,7 @@ FILENAME_HEAD: "文件名",
DEFAULT_PEN_MODE_DESC:
"打开绘图时,是否自动开启触控笔模式?",
DISABLE_DOUBLE_TAP_ERASER_NAME: "启用手写模式下的双击橡皮擦功能",
DISABLE_SINGLE_FINGER_PANNING_NAME: "启用手写模式下的单指平移功能",
SHOW_PEN_MODE_FREEDRAW_CROSSHAIR_NAME: "在触控笔模式下显示十字准星(+",
SHOW_PEN_MODE_FREEDRAW_CROSSHAIR_DESC:
"在触控笔模式下使用涂鸦功能会显示十字准星 <b><u>打开:</u></b> 显示 <b><u>关闭:</u></b> 隐藏<br>"+