-
-
Notifications
You must be signed in to change notification settings - Fork 415
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(edgeless): copilot selection widget (#6497)
- Loading branch information
Showing
10 changed files
with
355 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
packages/blocks/src/root-block/edgeless/controllers/tools/copilot-tool.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import type { PointerEventState } from '@blocksuite/block-std'; | ||
import { Slot } from '@blocksuite/store'; | ||
|
||
import type { CopilotSelectionTool } from '../../../../_common/utils/index.js'; | ||
import { EdgelessToolController } from './index.js'; | ||
|
||
export class CopilotSelectionController extends EdgelessToolController<CopilotSelectionTool> { | ||
readonly tool = <CopilotSelectionTool>{ | ||
type: 'copilot', | ||
}; | ||
|
||
private _dragStartPoint: [number, number] = [0, 0]; | ||
private _dragLastPoint: [number, number] = [0, 0]; | ||
private _dragging = false; | ||
|
||
draggingAreaUpdated = new Slot(); | ||
|
||
get area() { | ||
const start = new DOMPoint( | ||
this._dragStartPoint[0], | ||
this._dragStartPoint[1] | ||
); | ||
const end = new DOMPoint(this._dragLastPoint[0], this._dragLastPoint[1]); | ||
|
||
const minX = Math.min(start.x, end.x); | ||
const minY = Math.min(start.y, end.y); | ||
const maxX = Math.max(start.x, end.x); | ||
const maxY = Math.max(start.y, end.y); | ||
|
||
return new DOMRect(minX, minY, maxX - minX, maxY - minY); | ||
} | ||
|
||
private _initDragState(e: PointerEventState) { | ||
this._dragStartPoint = this._service.viewport.toModelCoord(e.x, e.y); | ||
this._dragLastPoint = this._dragStartPoint; | ||
} | ||
|
||
override onContainerDragStart(e: PointerEventState): void { | ||
this._initDragState(e); | ||
this._dragging = true; | ||
this.draggingAreaUpdated.emit(); | ||
} | ||
|
||
override onContainerDragMove(e: PointerEventState): void { | ||
if (!this._dragging) return; | ||
|
||
this._dragLastPoint = this._service.viewport.toModelCoord(e.x, e.y); | ||
this.draggingAreaUpdated.emit(); | ||
} | ||
|
||
override onContainerDragEnd(): void { | ||
this._dragging = false; | ||
} | ||
|
||
onContainerPointerDown(): void {} | ||
|
||
onContainerClick(): void {} | ||
|
||
onContainerContextMenu(): void {} | ||
|
||
onContainerDblClick(): void {} | ||
|
||
onContainerTripleClick(): void {} | ||
|
||
onContainerMouseMove(): void {} | ||
|
||
onContainerMouseOut(): void {} | ||
|
||
onPressShiftKey(): void {} | ||
|
||
onPressSpaceBar(): void {} | ||
|
||
beforeModeSwitch(): void {} | ||
|
||
afterModeSwitch(): void {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
1288de1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Size Report
Bundles
Packages