Skip to content

Commit e9811e9

Browse files
committed
誤ったBLOBが保存される問題を修正
1 parent 7c2f015 commit e9811e9

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

js/core/compression/project-compression.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
async function generateProjectFileBufferList() {
33
saveState();
4+
await convertImageMapBlobUrls();
45
const fileBufferList=[];
56

67
const promises=[

js/layer/image-history-management.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,33 @@ function generateHash(imageData) {
107107
return CryptoJS.SHA256(imageData).toString(CryptoJS.enc.Hex);
108108
}
109109

110+
async function blobUrlToDataUrl(blobUrl){
111+
try{
112+
const response=await fetch(blobUrl);
113+
const blob=await response.blob();
114+
return new Promise((resolve,reject)=>{
115+
const reader=new FileReader();
116+
reader.onloadend=()=>resolve(reader.result);
117+
reader.onerror=reject;
118+
reader.readAsDataURL(blob);
119+
});
120+
}catch(e){
121+
console.error("Failed to convert blob URL:",blobUrl,e);
122+
return null;
123+
}
124+
}
125+
126+
async function convertImageMapBlobUrls(){
127+
const entries=Array.from(imageMap.entries());
128+
for(const [hash,value] of entries){
129+
if(typeof value==='string'&&value.startsWith('blob:')){
130+
const dataUrl=await blobUrlToDataUrl(value);
131+
if(dataUrl){
132+
imageMap.set(hash,dataUrl);
133+
}
134+
}
135+
}
136+
}
110137

111138
function customToJSON() {
112139
const json=canvas.toJSON(commonProperties);
@@ -149,6 +176,9 @@ if (obj.speechBubbleGrid) {
149176
obj.speechBubbleGrid=obj.speechBubbleGrid.replace('GUID:','');
150177
obj.speechBubbleGrid=imageMap.get(obj.speechBubbleGrid);
151178
}
179+
if (obj.textBaseline==='alphabetical') {
180+
obj.textBaseline='alphabetic';
181+
}
152182
commonProperties.forEach(prop=>{
153183
if (obj[prop]!==undefined) {
154184
obj[prop]=obj[prop];

0 commit comments

Comments
 (0)