{ "version": 3, "sources": ["../../src/lib/defaultSideEffects.ts"], "sourcesContent": ["import { Editor } from '@tldraw/editor'\n\nexport function registerDefaultSideEffects(editor: Editor) {\n\treturn [\n\t\teditor.sideEffects.registerAfterChangeHandler('instance', (prev, next) => {\n\t\t\tif (prev.isFocused !== next.isFocused) {\n\t\t\t\tif (next.isFocused) {\n\t\t\t\t\teditor.getContainer().focus()\n\t\t\t\t\teditor.updateViewportScreenBounds()\n\t\t\t\t} else {\n\t\t\t\t\teditor.complete() // stop any interaction\n\t\t\t\t\teditor.getContainer().blur() // blur the container\n\t\t\t\t\teditor.updateViewportScreenBounds()\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t\teditor.sideEffects.registerAfterChangeHandler('instance_page_state', (prev, next) => {\n\t\t\tif (prev.croppingShapeId !== next.croppingShapeId) {\n\t\t\t\tconst isInCroppingState = editor.isInAny(\n\t\t\t\t\t'select.crop',\n\t\t\t\t\t'select.pointing_crop_handle',\n\t\t\t\t\t'select.cropping'\n\t\t\t\t)\n\t\t\t\tif (!prev.croppingShapeId && next.croppingShapeId) {\n\t\t\t\t\tif (!isInCroppingState) {\n\t\t\t\t\t\teditor.setCurrentTool('select.crop.idle')\n\t\t\t\t\t}\n\t\t\t\t} else if (prev.croppingShapeId && !next.croppingShapeId) {\n\t\t\t\t\tif (isInCroppingState) {\n\t\t\t\t\t\teditor.setCurrentTool('select.idle')\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (prev.editingShapeId !== next.editingShapeId) {\n\t\t\t\tif (!prev.editingShapeId && next.editingShapeId) {\n\t\t\t\t\tif (!editor.isIn('select.editing_shape')) {\n\t\t\t\t\t\teditor.setCurrentTool('select.editing_shape')\n\t\t\t\t\t}\n\t\t\t\t} else if (prev.editingShapeId && !next.editingShapeId) {\n\t\t\t\t\tif (editor.isIn('select.editing_shape')) {\n\t\t\t\t\t\teditor.setCurrentTool('select.idle')\n\t\t\t\t\t}\n\t\t\t\t}\n\t\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