Add Web Worker for the save to json function
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5b20e4f2dc
commit
991683fd7e
3 changed files with 54 additions and 14 deletions
25
src/workers/worker.js
Normal file
25
src/workers/worker.js
Normal 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;
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue