onmessage = (e) => { const data = JSON.stringify(e.data.editorState, getCircularReplacer(), e.data.spaces); postMessage(data); }; const getCircularReplacer = () => { return (key, value) => { if (key === 'parent') { return; } if (key === 'symbols') { return Array.from(value.entries()); } if (key === 'linkedContainers') { return Array.from(value); } return value; }; };