Bistard / nota

📕Next-Gen AI-powered markdown note-taking application.
MIT License
59 stars 5 forks source link

Add event listeners and enhance drag-and-drop in editor #244

Closed Bistard closed 2 weeks ago

Bistard commented 2 weeks ago

Summary by Sourcery

Refactor the editor's drag-and-drop functionality by introducing new animation controls and enhancing existing components. Add a drop animation feature and automated scrolling on edge detection to improve user interaction. Update the styling and functionality of the MacWindowBar and integrate it with the zoom service.

New Features:

Enhancements:

sourcery-ai[bot] commented 2 weeks ago

Reviewer's Guide by Sourcery

This PR introduces several significant changes to improve drag-and-drop functionality, animation handling, and event management in the editor. The implementation includes new animation controllers, enhanced drop cursor rendering, and reorganized event handling for better performance and user experience.

Sequence diagram for drag-and-drop event handling

sequenceDiagram
    actor User
    participant EditorWidget
    participant DropCursorRenderer
    participant ScrollOnEdgeController
    participant DropBlinkRenderer
    User->>EditorWidget: Drag event
    EditorWidget->>DropCursorRenderer: render(view, event)
    DropCursorRenderer->>ScrollOnEdgeController: attemptScrollOnEdge(event)
    ScrollOnEdgeController->>DropBlinkRenderer: setNodeBlink(view, position, nodeSize)
    DropBlinkRenderer-->>EditorWidget: Update decorations
    EditorWidget-->>User: Render updated view

File-Level Changes

Change Details Files
Introduced a new RequestAnimateController class for managing animation frame requests
  • Added support for updatable arguments in animation callbacks
  • Implemented request and requestOnEveryFrame methods for different animation scheduling needs
  • Added cancellation and cleanup functionality
src/base/browser/basic/animation.ts
Enhanced drag-and-drop functionality with new features and optimizations
  • Added drop animation with blink effect
  • Implemented automatic scrolling when dragging near viewport edges
  • Refactored drop cursor rendering for better performance
  • Added new dropAnimation configuration option
src/editor/contrib/dragAndDropExtension/dragAndDropExtension.ts
src/editor/contrib/dragAndDropExtension/dropCursorRenderer.ts
src/editor/contrib/dragAndDropExtension/dropBlinkRenderer.ts
src/editor/contrib/dragAndDropExtension/scrollOnEdgeController.ts
Refactored editor event handling system
  • Split onDidFocusChange into separate onDidFocus and onDidBlur events
  • Added new event listeners for rendering and content changes
  • Updated event broadcasting implementation
src/editor/common/editorExtension.ts
src/editor/view/proseEventBroadcaster.ts
src/editor/editorWidget.ts
Improved Mac window bar styling and zoom handling
  • Restructured CSS for better positioning and scaling
  • Added zoom level compensation for window controls
  • Updated layout and container structure
src/workbench/parts/navigationPanel/navigationBar/quickAccessBar/media/macWindowBar.scss
src/workbench/parts/navigationPanel/navigationBar/quickAccessBar/macWindowBar.ts
src/workbench/services/zoom/zoomService.ts

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
Bistard commented 2 weeks ago

@sourcery-ai review