mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
ensure only active/referenced files are saved
This commit is contained in:
parent
f1c9dda366
commit
cf6b5c3b6e
@ -224,20 +224,28 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
|
|||||||
|
|
||||||
const elements = this.excalidrawRef.current.getSceneElements();
|
const elements = this.excalidrawRef.current.getSceneElements();
|
||||||
const appState = this.excalidrawRef.current.getAppState();
|
const appState = this.excalidrawRef.current.getAppState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FIXME: a file is not deleted, even though removed from canvas
|
* A file is not deleted, even though removed from canvas. therefore we only keep
|
||||||
* maybe cross-reference elements and files before saving?!
|
* files that are referenced by an element. Maybe this will change with new excalidraw version?
|
||||||
*/
|
*/
|
||||||
const files = this.excalidrawRef.current.getFiles();
|
const files = this.excalidrawRef.current.getFiles();
|
||||||
|
|
||||||
|
const activeFiles = {};
|
||||||
|
elements.forEach((element) => {
|
||||||
|
if (element.fileId) {
|
||||||
|
activeFiles[element.fileId] = files[element.fileId];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const content = {
|
const content = {
|
||||||
elements,
|
elements,
|
||||||
appState,
|
appState,
|
||||||
files,
|
files: activeFiles,
|
||||||
time,
|
time,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.log('getContent()', content);
|
this.log('getContent()', content, activeFiles);
|
||||||
|
|
||||||
return JSON.stringify(content);
|
return JSON.stringify(content);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user