diff --git a/blocksuite/affine/gfx/brush/src/brush-tool.ts b/blocksuite/affine/gfx/brush/src/brush-tool.ts index 3622b779ec..309c86f00f 100644 --- a/blocksuite/affine/gfx/brush/src/brush-tool.ts +++ b/blocksuite/affine/gfx/brush/src/brush-tool.ts @@ -1,4 +1,7 @@ -import { CanvasElementType } from '@blocksuite/affine-block-surface'; +import { + CanvasElementType, + EdgelessCRUDIdentifier, +} from '@blocksuite/affine-block-surface'; import type { BrushElementModel } from '@blocksuite/affine-model'; import { TelemetryProvider } from '@blocksuite/affine-shared/services'; import type { IVec } from '@blocksuite/global/gfx'; @@ -118,7 +121,7 @@ export class BrushTool extends BaseTool { this._lastPoint = [pointX, pointY]; this._draggingPathPoints = points; - this.gfx.updateElement(this._draggingElement!, { + this.gfx.updateElement(this._draggingElement, { points: this._tryGetPressurePoints(e), }); @@ -167,6 +170,24 @@ export class BrushTool extends BaseTool { this._lastPopLength = 0; } + override click(e: PointerEventState) { + this.doc.captureSync(); + + const [modelX, modelY] = this.gfx.viewport.toModelCoord( + e.point.x, + e.point.y + ); + + const points = this._pressureSupportedPointerIds.has(e.raw.pointerId) + ? [[modelX, modelY, e.pressure]] + : [[modelX, modelY]]; + + const crud = this.std.get(EdgelessCRUDIdentifier); + crud.addElement(CanvasElementType.BRUSH, { + points, + }); + } + override activate() { this.std.getOptional(TelemetryProvider)?.track('EdgelessToolPicked', { page: 'whiteboard editor',