-
-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(edgeless): copilot selection widget #6497
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d617ae9
feat: add ai selection
doouding db9d771
fix: circular
doouding 082f2b1
Merge branch 'master' into feat/edgeless-ai
doouding 57c5114
Merge remote-tracking branch 'origin/master' into feat/edgeless-ai
doouding 3d48d6b
fix: metakey pressed
doouding b2f2c9b
fix: click outside to cancel the ai selection
doouding 9a2fa78
fix: metakey pressed
doouding 1d90ca4
test: add test
doouding 85b576d
fix: test
doouding 8f7d5ef
fix: review
doouding e383093
fix: naming
doouding 4f228a6
fix: naming
doouding a5de43a
fix: naming
doouding 93b7335
fix: test
doouding c78f243
fix: build
doouding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/ai-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 { AITool } from '../../../../_common/utils/index.js'; | ||
import { EdgelessToolController } from './index.js'; | ||
|
||
export class AIToolController extends EdgelessToolController<AITool> { | ||
readonly tool = <AITool>{ | ||
type: 'ai', | ||
}; | ||
|
||
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
CopilotSelectionTool