Commit Graph

59 Commits

Author SHA1 Message Date
doouding
e0e84d302d refactor: moving connector label to connector view (#11738)
### Changed
Moved connector label moving logic from `default-tool` to connector view.

#### Other infrastructure changes:​​
- Gfx element view now can handles drag events
- Added `context.preventDefault()` support to bypass built-in interactions in extension
- Handle the pointer events in element view will bypass the built-in interactions automatically

> The built-in interactions include element dragging, click selection, drag-to-scale operations, etc.
2025-04-22 08:18:24 +00:00
doouding
52953ce8e3 refactor: redesign element transform manager interface (#11679)
### Change
- Rename `ElementTransformManager` -> `InteractivityManager`
- Now you can `event.on` and `action.onXXX` method to extend interactivity behaviour. The old approach of overriding methods directly is deprecated.
2025-04-22 08:18:23 +00:00
doodlewind
1146f4d5a9 fix(editor): prototype polluting in gfx util (#11831)
This fixes the security edge case where the font key happens to be `__proto__` or `constructor`
2025-04-21 04:00:59 +00:00
fundon
67832aab09 chore(editor): update file icons (#11826) 2025-04-21 09:18:29 +08:00
Yifeng Wang
760a689c07 Merge branch 'canary' into 0414/vtr_test_layout 2025-04-15 09:20:25 +08:00
doodlewind
b8967a8a7b test(editor): add tests for turbo renderer state machine (#11659) 2025-04-14 15:54:02 +00:00
Yifeng Wang
e9d04de399 test(editor): add tests for turbo renderer layout cache 2025-04-14 17:06:13 +08:00
doodlewind
6457c979f5 test(editor): add tests for turbo renderer state machine (#11659) 2025-04-14 17:01:27 +08:00
fundon
afdc40b510 feat(editor): add shortcut to highlighter tool (#11604)
Closes: [BS-3092](https://linear.app/affine-design/issue/BS-3092/highlighter-快捷键)

### What's Changed!

* Added shortcut `⇧ P` to highlighter tool

[Screen Recording 2025-04-10 at 16.33.30.mov <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/8ypiIKZXudF5a0tIgIzf/38aadc08-ed18-4b48-9d91-b4876d14a2d3.mov" />](https://app.graphite.dev/media/video/8ypiIKZXudF5a0tIgIzf/38aadc08-ed18-4b48-9d91-b4876d14a2d3.mov)
2025-04-11 13:08:59 +00:00
L-Sun
823bf40a57 fix(editor): fix overlay of tool is not shown or repeated when switching tool (#11575)
Close [BS-3029](https://linear.app/affine-design/issue/BS-3029/frame-里面的-shape-没办法进入文本编辑模式)
Close [BS-3082](https://linear.app/affine-design/issue/BS-3082/按s切换至shape工具,在白板上点击会创建两个shape)
Close [BS-3091](https://linear.app/affine-design/issue/BS-3082/按s切换至shape工具,在白板上点击会创建两个shape)

## Fix Shape Tool Issues

This PR addresses several issues with the shape and mindmap tools functionality in the editor:

1. **Fix text editing after mode switching**: Resolves an issue where users couldn't edit text in shapes after switching editor modes. The fix ensures the edgeless block is properly retrieved when double-clicking on a shape.

2. **Improve tool switching behavior**: Fixes issues with tool overlays not showing or being repeated when switching between tools. This includes:
   - Properly handling tool overlay visibility
   - Ensuring only one tool is active at a time when using keyboard shortcuts
   - Adding proper cleanup when switching tools

3. **Add comprehensive tests**: Adds new test cases to verify:
   - Shape creation with keyboard shortcuts
   - Shape text editing after mode switching
   - Tool switching behavior with keyboard shortcuts
2025-04-10 13:39:22 +00:00
doodlewind
dba8e00fb6 feat(editor): add basic note support in turbo renderer (#11607)
After landing layout tree refactoring, this PR adds basic note support in turbo renderer.

In this demo recording, the code and image block needs to be further supported.

[Screen Recording 2025-04-10 at 5.16.15 PM.mov <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/lEGcysB4lFTEbCwZ8jMv/2e416b41-5609-4e52-a90f-5b7bb77db682.mov" />](https://app.graphite.dev/media/video/lEGcysB4lFTEbCwZ8jMv/2e416b41-5609-4e52-a90f-5b7bb77db682.mov)
2025-04-10 09:52:33 +00:00
doodlewind
69d4620753 refactor(editor): cleanup turbo renderer entry config with doc guide (#11605) 2025-04-10 09:52:32 +00:00
doodlewind
f85b35227b feat(editor): replace flat layout cache with tree in turbo renderer (#11319)
### TL;DR

Refactored the BlockSuite turbo renderer to use a hierarchical tree structure for layouts instead of a flat list, improving rendering accuracy and performance.

### What changed?

- Redesigned the layout system to use a tree structure (`ViewportLayoutTree`) that better represents the document hierarchy
- Added `blockId` to all layout objects for better tracking and debugging
- Updated the layout query mechanism to work with models directly instead of components
- Enhanced error handling with more descriptive warnings and error messages
- Improved the painting process to traverse the layout tree recursively
- Fixed viewport coordinate calculations for more accurate rendering
- Updated the worker communication to support the new tree-based layout structure

### Why make this change?

The previous flat layout structure didn't properly represent the hierarchical nature of documents, leading to rendering issues with nested blocks. This tree-based approach:

1. Better represents the actual document structure
2. Improves rendering accuracy for nested elements
3. Makes debugging easier with more consistent block identification
4. Provides a more robust foundation for future rendering optimizations
5. Reduces the likelihood of rendering artifacts when scrolling or zooming
2025-04-10 08:49:23 +00:00
Saul-Mirone
238ec59dd2 fix(editor): image icon color (#11536)
Closes: BS-2166
2025-04-08 09:18:26 +00:00
Saul-Mirone
1f45cc5dec refactor(editor): unify directories naming (#11516)
**Directory Structure Changes**

- Renamed multiple block-related directories by removing the "block-" prefix:
  - `block-attachment` → `attachment`
  - `block-bookmark` → `bookmark`
  - `block-callout` → `callout`
  - `block-code` → `code`
  - `block-data-view` → `data-view`
  - `block-database` → `database`
  - `block-divider` → `divider`
  - `block-edgeless-text` → `edgeless-text`
  - `block-embed` → `embed`
2025-04-07 12:34:40 +00:00
forehalo
40f218c898 chore: set base version to 0.21 2025-04-07 16:10:32 +08:00
Saul-Mirone
bb1270061a feat(editor): gfx template package (#11480) 2025-04-06 12:24:13 +00:00
Saul-Mirone
aed7f40568 refactor(editor): improve element adapters (#11473) 2025-04-05 09:40:13 +00:00
Saul-Mirone
2a1306c58c refactor(editor): separate the element renders (#11461) 2025-04-04 13:09:46 +00:00
Saul-Mirone
5a1106fb88 refactor(editor): extract brush element renderer (#11460) 2025-04-04 13:09:45 +00:00
CatsJuice
46d8d30e62 feat(editor): disable clickToDrag for edgeless toolbar shape and mindmap (#11310) 2025-04-04 05:10:05 +00:00
JimmFly
7a1d5ab252 feat(core): upgrade icons package (#11435) 2025-04-04 04:52:49 +00:00
doouding
ef76c83184 fix: connector should remain the same when its target or source switch to other
shape type (#11369)

Fixes [BS-1431](https://linear.app/affine-design/issue/BS-1431/改变-shape-形状后,connector-丢失)
2025-04-02 05:10:30 +00:00
fundon
f1882061a2 fix(editor): should exit drawing tools menu when Escape is pressed (#11306)
Closes: [BS-2978](https://linear.app/affine-design/issue/BS-2978/二级菜单的激活状态错误) [BS-2977](https://linear.app/affine-design/issue/BS-2977/pen和highlighter没做esc)
2025-03-31 11:05:01 +00:00
fundon
6a66bf53a8 fix(editor): adjust highlighter color (#11300)
Closes: [BS-2980](https://linear.app/affine-design/issue/BS-2980/highlighter透明度改为30percent) [BS-2979](https://linear.app/affine-design/issue/BS-2979/highlighter默认选择颜色为蓝色)
2025-03-31 09:11:26 +00:00
doodlewind
dffb89c388 feat(editor): add list block turbo renderer scaffold (#11266)
This PR allows placeholder in turbo renderer to cover list block as a basic scaffold.

![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/lEGcysB4lFTEbCwZ8jMv/eda28656-e56e-4845-9fe6-885e70841697.png)
2025-03-29 04:49:25 +00:00
Saul-Mirone
205cd7a86d refactor(editor): rename block-std to std (#11250)
Closes: BS-2946
2025-03-28 07:20:34 +00:00
fundon
c0c0e5ea8f chore(editor): add event tracking to highlighter tool (#11232)
Closes: [BS-2947](https://linear.app/affine-design/issue/BS-2947/埋点相关)
2025-03-28 01:34:44 +00:00
CatsJuice
e855197acf feat(editor): responsive edgeless toolbar pen menu (#11150)
close BS-2855
2025-03-27 08:53:27 +00:00
fundon
2c4278058b feat(editor): add highlighter (#10573)
Closes: [BS-2909](https://linear.app/affine-design/issue/BS-2909/新增highlighter)

### What's Changed!

Currently the highlighter tool is very similar to brush, but for the future, it's a standalone module.

* Added `Highlighter` element model
* Added `Highlighter` tool
* Added `Highlighter` entry to the global toolbar
2025-03-27 08:53:26 +00:00
fundon
6ade2b7084 chore(editor): add event tracking to drawing tool (#11230)
Closes: [BS-2833](https://linear.app/affine-design/issue/BS-2833/考虑屏蔽或者降低brush-行为的采集密度)
2025-03-27 08:17:44 +00:00
doodlewind
bb1bbccd0f refactor(editor): rx state management in turbo renderer (#11200)
# Refactor Turbo Renderer State Management to Use RxJS

### TL;DR

Refactored the TurboRenderer state management to use RxJS observables instead of direct state mutations, improving state transitions and reactivity.

### What changed?

- Replaced the public `state` property with a private `state$` BehaviorSubject in `ViewportTurboRendererExtension`
- Added proper state transition logging using RxJS operators
- Combined multiple event subscriptions using `merge` operator for better organization
- Improved state transition logic in the `refresh()` method
- Updated the `zooming$` and `panning$` signals in the Viewport

### Why make this change?

This refactoring improves the codebase by:
1. Using a more consistent reactive programming model with RxJS
2. Making state transitions more explicit and traceable
3. Reducing potential bugs from manual state management
4. Improving code organization by combining related event streams
5. Ensuring proper cleanup of resources when components are disposed

The change maintains the same functionality while making the code more maintainable and the state management more robust.
2025-03-27 04:50:32 +00:00
doouding
ace5d44a61 refactor: rewrite dblclick and selection logic of default-tool (#11036)
continue #10824

### Changed
- Moved double-click-to-edit behavior from the default tool to individual model views
- Introduced `onSelected` callback interface in gfx view components to allows developers to override default selection logic
2025-03-26 07:32:43 +00:00
fundon
d7eccd10ee chore(editor): add edgeless scribbled style feature flag (#11127)
Closes: [BS-2805](https://linear.app/affine-design/issue/BS-2805/下掉线条样式切换功能,需添加-feature-flag)
2025-03-24 12:55:00 +00:00
Saul-Mirone
4d3eee3bad feat(editor): brush gfx package (#11131) 2025-03-24 09:28:46 +00:00
Saul-Mirone
ef1ed383cb feat(editor): command for ungroup and group (#11116) 2025-03-24 15:34:38 +09:00
Flrande
4bacfbd640 feat(editor): support member node (#11075)
Close [BS-2793](https://linear.app/affine-design/issue/BS-2793/inline-member)
2025-03-24 05:57:03 +00:00
Saul-Mirone
b8df65a2b0 refactor(editor): move mindmap transform to its package (#11115) 2025-03-24 05:19:30 +00:00
Saul-Mirone
5525c2bc8d refactor(editor): move mindmap view to mindmap package (#11102) 2025-03-24 03:14:23 +00:00
Saul-Mirone
8e08b9000d feat(editor): create gfx mindmap package (#11100) 2025-03-24 03:14:22 +00:00
Saul-Mirone
1f0fc9d47a feat(editor): gfx connector package (#11091) 2025-03-22 14:39:05 +00:00
Saul-Mirone
e3735f40b8 feat(editor): gfx note package (#11088) 2025-03-22 14:39:04 +00:00
Saul-Mirone
c1d426d8e9 refactor(editor): move frame toolbar config and components to its package (#11084) 2025-03-21 16:47:40 +00:00
Saul-Mirone
f5fb5c848e refactor(editor): move text toolbar config and components to its package (#11083) 2025-03-21 16:47:40 +00:00
Saul-Mirone
f762797772 refactor(editor): move shape toolbar config and components to its package (#11082) 2025-03-21 16:47:39 +00:00
Saul-Mirone
8109c718c7 feat(editor): gfx shape package (#11060) 2025-03-21 06:13:11 +00:00
Saul-Mirone
92d76ba571 refactor(editor): merge inline to std (#11025) 2025-03-20 05:46:56 +00:00
Saul-Mirone
7e6ff8d9c6 chore(editor): remove unused npm scripts (#10895) 2025-03-16 17:48:49 +00:00
doodlewind
d8dfea6ccf fix(editor): type import in vite worker env (#10856)
The dependencies of `@blocksuite/affine-gfx-turbo-renderer` in work is now all type imports.
2025-03-14 10:22:58 +00:00
doodlewind
d1c10f5401 chore(editor): hide tweakpane for turbo renderer (#10846) 2025-03-14 06:47:15 +00:00