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; }; };