Add Web Worker for the save to json function
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Siklos 2022-08-15 16:56:32 +02:00
parent 5b20e4f2dc
commit 991683fd7e
3 changed files with 54 additions and 14 deletions

25
src/workers/worker.js Normal file
View file

@ -0,0 +1,25 @@
onmessage = (e) => {
const data = JSON.stringify(e.data.editorState, getCircularReplacer(), e.data.spaces);
postMessage(data);
};
const getCircularReplacer = () => {
const seen = new WeakSet();
return (key, value) => {
if (key === 'parent') {
return;
}
if (key === 'SelectedContainer') {
return;
}
if (typeof value === 'object' && value !== null) {
if (seen.has(value)) {
return;
}
seen.add(value);
}
return value;
};
};