Skip to content

Commit e37afce

Browse files
committed
fix: unable to save when saving large content
1 parent f77ec0b commit e37afce

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ The label of a draw.io image block can be configured in the plugin settings.
8181

8282
## Changelog
8383

84+
+ v0.5.3
85+
+ Fix: unable to save when saving large content
8486
+ v0.5.2
8587
+ Optimize: Excalidraw contents of SVG/PNG placeholder image are empty
8688
+ v0.5.1

README_zh_CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070

7171
## 更新日志
7272

73+
+ v0.5.3
74+
+ 修复缺陷:内容过多时无法保存
7375
+ v0.5.2
7476
+ 优化:SVG/PNG占位图像编辑时都为空
7577
+ v0.5.1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "siyuan-embed-drawio",
3-
"version": "0.5.2",
3+
"version": "0.5.3",
44
"type": "module",
55
"description": "This is a plugin for siyuan",
66
"author": "",

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "siyuan-embed-drawio",
33
"author": "Yuxin Zhao",
44
"url": "https://github.com/YuxinZhaozyx/siyuan-embed-drawio",
5-
"version": "0.5.2",
5+
"version": "0.5.3",
66
"minAppVersion": "3.0.0",
77
"disabledInPublish": true,
88
"backends": [

src/utils/index.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ export function unescapeHTML(str: string): string {
2020
export function unicodeToBase64(str: string): string {
2121
const encoder = new TextEncoder();
2222
const bytes = encoder.encode(str);
23-
return btoa(String.fromCharCode(...bytes));
23+
let binary = '';
24+
const len = bytes.length;
25+
for (let i = 0; i < len; i++) {
26+
binary += String.fromCharCode(bytes[i]);
27+
}
28+
return btoa(binary);
2429
}
2530

2631
export function base64ToUnicode(base64: string): string {
@@ -43,7 +48,11 @@ export function base64ToBuffer(base64: string): ArrayBuffer {
4348
}
4449

4550
export function bufferToBase64(buffer: ArrayBuffer): string {
46-
const binary = String.fromCharCode(...new Uint8Array(buffer));
51+
const bytes = new Uint8Array(buffer);
52+
let binary = '';
53+
for (let i = 0; i < bytes.length; i++) {
54+
binary += String.fromCharCode(bytes[i]);
55+
}
4756
return btoa(binary);
4857
}
4958

@@ -99,7 +108,10 @@ export function base64ToArray(base64: string): Uint8Array {
99108
}
100109

101110
export function arrayToBase64(array: Uint8Array): string {
102-
const binary = String.fromCharCode(...array);
111+
let binary = '';
112+
for (let i = 0; i < array.length; i++) {
113+
binary += String.fromCharCode(array[i]);
114+
}
103115
return btoa(binary);
104116
}
105117

0 commit comments

Comments
 (0)