mirror of https://github.com/logseq/logseq
fix: text origin on create
parent
d277031918
commit
b468f0dc07
|
@ -1,5 +1,6 @@
|
||||||
import type { TLTextTool } from '../TLTextTool'
|
import type { TLTextTool } from '../TLTextTool'
|
||||||
import Vec from '@tldraw/vec'
|
import Vec from '@tldraw/vec'
|
||||||
|
import { GRID_SIZE } from '@tldraw/core'
|
||||||
import type { TLBounds } from '@tldraw/intersect'
|
import type { TLBounds } from '@tldraw/intersect'
|
||||||
import { transaction } from 'mobx'
|
import { transaction } from 'mobx'
|
||||||
import { type TLEventMap, TLCursor, TLTargetType } from '../../../../types'
|
import { type TLEventMap, TLCursor, TLTargetType } from '../../../../types'
|
||||||
|
@ -43,8 +44,10 @@ export class CreatingState<
|
||||||
this.creatingShape.setScaleLevel(this.app.settings.scaleLevel)
|
this.creatingShape.setScaleLevel(this.app.settings.scaleLevel)
|
||||||
transaction(() => {
|
transaction(() => {
|
||||||
this.app.currentPage.addShapes(shape as unknown as S)
|
this.app.currentPage.addShapes(shape as unknown as S)
|
||||||
|
const point = this.app.settings.snapToGrid ? Vec.snap([...originPoint], GRID_SIZE) : originPoint
|
||||||
const { bounds } = shape
|
const { bounds } = shape
|
||||||
shape.update({ point: Vec.sub(originPoint, [bounds.width / 2, bounds.height / 2]) })
|
shape.update({
|
||||||
|
point: Vec.sub(point, [bounds.width / 2, bounds.height / 2]) })
|
||||||
this.app.transition('select')
|
this.app.transition('select')
|
||||||
this.app.setSelectedShapes([shape as unknown as S])
|
this.app.setSelectedShapes([shape as unknown as S])
|
||||||
this.app.currentState.transition('editingShape', {
|
this.app.currentState.transition('editingShape', {
|
||||||
|
|
Loading…
Reference in New Issue