diff --git a/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx b/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx index 32faaf4650..6a8b96495b 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx @@ -182,8 +182,9 @@ export class LogseqPortalShape extends TLBoxShape { const isMoving = useCameraMovingRef() const { Page } = React.useContext(LogseqContext) const isSelected = app.selectedIds.has(this.id) + const isCreating = app.isIn('logseq-portal.creating') && !pageId const tlEventsEnabled = - (isMoving || (isSelected && !isEditing) || app.selectedTool.id !== 'select') && !this.draft + (isMoving || (isSelected && !isEditing) || app.selectedTool.id !== 'select') && !isCreating const stop = React.useCallback( e => { if (!tlEventsEnabled) { @@ -213,16 +214,14 @@ export class LogseqPortalShape extends TLBoxShape { }, [isEditing, this.props.collapsed]) const onPageNameChanged = React.useCallback((id: string) => { - app.history.resume() - app.wrapUpdate(() => { - this.setDraft(false) - this.update({ - pageId: id, - size: [600, 320], - blockType: 'P', - }) - app.selectTool('select') + this.update({ + pageId: id, + size: [600, 320], + blockType: 'P', }) + app.selectTool('select') + app.history.resume() + app.history.persist() }, []) if (!Page) { @@ -247,7 +246,7 @@ export class LogseqPortalShape extends TLBoxShape { pointerEvents: isEditing ? 'all' : 'none', }} > - {this.draft ? ( + {isCreating ? ( ) : (
{ if (!this.creatingShape) return - if (this.creatingShape?.draft) { - this.app.deleteShapes([this.creatingShape.id]) - } else { - this.app.setSelectedShapes([this.creatingShape.id]) - } this.app.clearEditingShape() this.app.history.resume() + + if (this.creatingShape?.props.pageId) { + this.app.setSelectedShapes([this.creatingShape.id]) + } else { + this.app.deleteShapes([this.creatingShape.id]) + } } } diff --git a/tldraw/apps/tldraw-logseq/src/lib/tools/LogseqPortalTool/states/IdleState.tsx b/tldraw/apps/tldraw-logseq/src/lib/tools/LogseqPortalTool/states/IdleState.tsx index a86b2fed28..63f224fe6e 100644 --- a/tldraw/apps/tldraw-logseq/src/lib/tools/LogseqPortalTool/states/IdleState.tsx +++ b/tldraw/apps/tldraw-logseq/src/lib/tools/LogseqPortalTool/states/IdleState.tsx @@ -12,13 +12,13 @@ export class IdleState extends TLToolState< static id = 'idle' cursor = TLCursor.Cross - onEnter = ({ quick }: { quick: boolean } = { quick: false }) => { + onEnter = ({ quick }: { quick?: boolean }) => { if (quick) { this.tool.transition('creating') } } - onPointerDown: TLReactEvents['pointer'] = (e) => { + onPointerDown: TLReactEvents['pointer'] = e => { this.tool.transition('creating') } } diff --git a/tldraw/packages/core/src/lib/TLPage/TLPage.ts b/tldraw/packages/core/src/lib/TLPage/TLPage.ts index cdbc7a131e..63a4f8d4d4 100644 --- a/tldraw/packages/core/src/lib/TLPage/TLPage.ts +++ b/tldraw/packages/core/src/lib/TLPage/TLPage.ts @@ -43,6 +43,7 @@ export class TLPage { + if (this.app.isInAny('creating')) return this.cleanup(curr, prev) } ) @@ -260,16 +261,11 @@ export class TLPage s.draft && this.app.editingShape !== s) - - if (!deepEqual(updated, curr) || shapesToDelete.length) { + if (!deepEqual(updated, curr)) { this.update({ bindings: updated.bindings, }) - this.removeShapes(...shapesToDelete) - updated.shapes.forEach(shape => { this.getShapeById(shape.id)?.update(shape) }) diff --git a/tldraw/packages/core/src/lib/shapes/TLShape/TLShape.tsx b/tldraw/packages/core/src/lib/shapes/TLShape/TLShape.tsx index 92ebe4b84e..d2530bb478 100644 --- a/tldraw/packages/core/src/lib/shapes/TLShape/TLShape.tsx +++ b/tldraw/packages/core/src/lib/shapes/TLShape/TLShape.tsx @@ -105,7 +105,6 @@ export abstract class TLShape

{ bindingDistance = BINDING_DISTANCE - @observable private _draft = false @observable private isDirty = false @observable private lastSerialized: TLShapeModel

| undefined @@ -115,15 +114,6 @@ export abstract class TLShape

{ return this.props.id } - @computed - get draft() { - return this._draft - } - - @action setDraft(draft: boolean) { - this._draft = draft - } - @action setNonce(nonce: number) { this.nonce = nonce } @@ -296,7 +286,7 @@ export abstract class TLShape

{ @computed get serialized(): TLShapeModel

| null { - return this.draft ? null : this.getCachedSerialized() + return this.getCachedSerialized() } validateProps = ( diff --git a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/BrushingState.ts b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/BrushingState.ts index f3359d08a5..76775a6cf8 100644 --- a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/BrushingState.ts +++ b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/BrushingState.ts @@ -48,7 +48,6 @@ export class BrushingState< ? BoundsUtils.boundsContain(brushBounds, shape.rotatedBounds) : shape.hitTestBounds(brushBounds) ) - .filter(s => !s.draft) if (shiftKey) { if (hits.every(hit => this.initialSelectedShapes.includes(hit))) { diff --git a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/IdleState.ts b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/IdleState.ts index 5586602488..45be0e077f 100644 --- a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/IdleState.ts +++ b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/IdleState.ts @@ -83,11 +83,8 @@ export class IdleState< const { selectionBounds, inputs } = this.app if (selectionBounds && PointUtils.pointInBounds(inputs.currentPoint, selectionBounds)) { this.tool.transition('pointingShapeBehindBounds', info) - } else if (!info.shape.draft) { - this.tool.transition('pointingShape', info) } else { - // as if clicking the canvas - this.tool.transition('pointingCanvas') + this.tool.transition('pointingShape', info) } } break diff --git a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ResizingState.ts b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ResizingState.ts index d57bc8b61f..142d72803f 100644 --- a/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ResizingState.ts +++ b/tldraw/packages/core/src/lib/tools/TLSelectTool/states/ResizingState.ts @@ -67,7 +67,6 @@ export class ResizingState< // @ts-expect-error maybe later this.snapshots = Object.fromEntries( selectedShapesArray - .filter(s => !s.draft) .map(shape => { const bounds = { ...shape.bounds } const [cx, cy] = BoundsUtils.getBoundsCenter(bounds) diff --git a/tldraw/packages/react/src/components/Canvas/Canvas.tsx b/tldraw/packages/react/src/components/Canvas/Canvas.tsx index 183901557f..f92d58d01f 100644 --- a/tldraw/packages/react/src/components/Canvas/Canvas.tsx +++ b/tldraw/packages/react/src/components/Canvas/Canvas.tsx @@ -151,7 +151,7 @@ export const Canvas = observer(function Renderer({ isSelected={true} /> ))} - {hoveredShape && !hoveredShape.draft && ( + {hoveredShape && app.isInAny('creating') && ( )} {brush && components.Brush && }