Commit Graph

629 Commits

Author SHA1 Message Date
fundon
07a64eb004 refactor(editor): edgeless toolbar lock and unlock actions (#10878) 2025-03-20 02:08:16 +00:00
fundon
bd9b78f7d2 refactor(editor): edgeless toolbar quick connect action (#10876) 2025-03-20 02:08:16 +00:00
fundon
54bc60aa4d refactor(editor): edgeless shape toolbar config extension (#10821) 2025-03-20 02:08:16 +00:00
fundon
1acc7e5a9e refactor(editor): edgeless text toolbar config extension (#10811) 2025-03-20 02:08:15 +00:00
Saul-Mirone
cdd405bbe5 refactor(editor): improve edgeless editors (#11019) 2025-03-20 01:49:56 +00:00
Saul-Mirone
258c70cf07 refactor(editor): store should not rely on inline (#11017) 2025-03-20 01:33:29 +00:00
Saul-Mirone
b3c6333694 refactor(editor): remove note block service (#11015) 2025-03-20 01:04:20 +09:00
Saul-Mirone
2701be8d08 refactor(editor): remove empty block services (#11014) 2025-03-20 01:04:20 +09:00
Saul-Mirone
76dc55f328 refactor(editor): remove legacy block service spec slots (#11013) 2025-03-20 01:04:18 +09:00
doouding
1c8d25bc29 feat: add ElementTransformManager for edgeless element basic manipulation (#10824)
### Overview:
We've been working with some legacy code in the default-tool and edgeless-selected-rect modules, which are responsible for fundamental operations like moving, resizing, and rotating elements. Currently, these operations are hardcoded, making it challenging to extend functionalities without diving deep into the code.

### What's Changing:
Introducing `ElementTransformManager` to streamline the handling of basic transformations (move, resize, rotate) while allowing the business logic to dictate when these actions occur.

Providing two ways to extend the transformations behaviour:
- Extends inside element view definition: Elements can decide how to handle move/resize events, such as enforcing size constraints.
- Extension mechanism provided by this manager: Adjust or completely override default drag behaviors, like snapping elements into alignment.

### Code Examples:
Delegate element movement to TransformManager:
```typescript
class DefaultTool {
  override dragStart(event) {
    if(this.dragType === DragType.ContentMoving) {
      const transformManager = this.std.get(TransformManagerIdentifier);
      transformManager.startDrag({ selectedElements, event });
    }
  }
}
```

 Enforce minimum width inside view definition:
```typescript
class EdgelessNoteBlock extends GfxBlockComponent {
  onResizeDelta({ dw, dh }) {
    const bound = this.model.elementBound;
    bound.w = Math.min(MAX_WIDTH, bound.w + dw);
    bound.h = Math.min(MAX_HEIGHT, bound.h + dh);
    this.model.xywh = bound.serialize();
  }
}
```

Use extension to implement element snapping:
```typescript
import { TransformerExtension } from '@blocksuite/std/gfx';

// Just extends the TransformerExtension
class SnapManager extends TransformerExtension {
  static override key = 'snap-manager';
  onDragInitialize() {
    return {
      onDragMove(context) {
        const { dx, dy } = this.getAlignmentMoveDistance(context.elements);
        context.dx = dx;
        context.dy = dy;
      }
    }
  }
}
```

### Others

The migration will be divided into several PRs. This PR mostly focus on refactoring elements movement part of `default-tool`.
- Delegate elements movement to `TransformManager`
- Rewrite the default tool extension into `TransformManager` extension
- Add drag handler interface to gfx view (both `GfxBlockComponent` and `GfxElementModelView`) to allow element to define how it gonna react on drag
2025-03-19 15:30:06 +00:00
fundon
c98f0900cc refactor(editor): edgeless mindmap toolbar config extension (#10803) 2025-03-19 14:50:55 +00:00
fundon
7f34667b78 refactor(editor): edgeless connector toolbar config extension (#10798) 2025-03-19 14:50:55 +00:00
donteatfriedrice
f6e32d8894 feat(editor): add embed iframe provider miro (#10996) 2025-03-19 13:57:30 +00:00
Saul-Mirone
ee65d66d67 refactor(editor): remove code block service (#11010) 2025-03-19 13:38:10 +00:00
Saul-Mirone
1c6a876e6a refactor(editor): improve config extension (#11006) 2025-03-19 13:38:10 +00:00
Saul-Mirone
c1e16aeaa7 refactor(editor): remove paragraph service (#11003) 2025-03-19 13:38:09 +00:00
fundon
03ffc688c3 refactor(editor): edgeless brush toolbar config extension (#10796) 2025-03-19 12:34:19 +00:00
fundon
c44a339bd9 refactor(editor): edgeless group toolbar config extension (#10787) 2025-03-19 12:34:19 +00:00
fundon
f87cc0f599 refactor(editor): edgeless frame toolbar config extension (#10769) 2025-03-19 12:34:18 +00:00
fundon
e320552594 refactor(editor): edgeless note toolbar config extension (#10719) 2025-03-19 12:34:18 +00:00
fundon
b5406fa57a refactor(editor): edgeless image toolbar config extension (#10718) 2025-03-19 12:34:18 +00:00
fundon
e686a6aecc refactor(editor): edgeless internal embed card toolbar config extension (#10717) 2025-03-19 12:34:17 +00:00
Saul-Mirone
a9b53839a6 refactor(editor): improve std structure (#10993) 2025-03-19 11:37:55 +00:00
L-Sun
9211fbf68c refactor(editor): move surface-ref toolbar to its block folder (#10938) 2025-03-19 10:54:22 +00:00
Saul-Mirone
ae3cb61943 chore: align vitest versions (#10990) 2025-03-19 08:57:24 +00:00
fundon
0442430971 refactor(editor): edgeless html embed card toolbar config extension (#10716) 2025-03-19 05:03:00 +00:00
doodlewind
80f62a995b perf(editor): improve resize frame rate (#10967)
This PR improves panel toggling FPS by minimizing DOM and canvas updates during resizing.

[Screen Recording 2025-03-18 at 11.57.45 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/d36beeab-a2e4-4fd6-923a-705ce7fbcdf7.mov" />](https://app.graphite.dev/media/video/lEGcysB4lFTEbCwZ8jMv/d36beeab-a2e4-4fd6-923a-705ce7fbcdf7.mov)

### What changed?

- Added a debounced resize handling mechanism using RxJS's `debounceTime` operator
- Implemented a new resize strategy that preserves the top-left corner position during resizing
- Added state tracking for resize operations with `_isResizing` flag and `_initialTopLeft` coordinates
2025-03-19 04:42:23 +00:00
fundon
7f4b56e05c refactor(editor): edgeless external embed card toolbar config extension (#10712) 2025-03-19 04:05:36 +00:00
L-Sun
68bc2db560 fix(editor): descendant elements are missing in edgelessToCanvas (#10933)
### Before

![CleanShot 2025-03-17 at 20.24.39@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyRfgiN4RuBxJfrza3SG/c097d8b2-69df-4965-8e49-3798e930e779.png)

### After

![CleanShot 2025-03-17 at 20.24.17@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyRfgiN4RuBxJfrza3SG/6af03a7d-1e64-4ced-ac4d-e7cbc5648da6.png)
2025-03-19 03:35:06 +00:00
pengx17
a118cbd036 fix(editor): chat panel text render link preview base url (#10791)
fix AF-2322
2025-03-19 03:19:09 +00:00
donteatfriedrice
3a2d386275 feat(editor): support add embed iframe block in mobile (#10955)
To close [BS-2664](https://linear.app/affine-design/issue/BS-2664/iframe-embed-block-移动端支持)
2025-03-19 02:58:51 +00:00
fundon
d8567e669a refactor(editor): edgeless bookmark toolbar config extension (#10711) 2025-03-19 02:24:26 +00:00
fundon
251d1d8782 refactor(editor): edgeless attacment toolbar config extension (#10710) 2025-03-19 00:52:22 +00:00
fundon
3cce147c60 refactor(editor): improve query methods in toolbar context (#10714) 2025-03-19 00:52:22 +00:00
doodlewind
02d707feab fix(editor): adapt font size in turbo renderer (#10858) 2025-03-18 19:01:48 +00:00
fundon
cb37d25d7b refactor(editor): edgeless element toolbar with new pattern (#10511) 2025-03-18 15:36:25 +00:00
zzj3720
3939cc1c52 feat(editor): support file column and member column for database block (#10932)
close: BS-2630, BS-2631, BS-2629, BS-2632, BS-2635
2025-03-18 14:51:45 +00:00
Saul-Mirone
321e3449ec fix(editor): block can be null in widget (#10959)
Closes: [BS-2826](https://linear.app/affine-design/issue/BS-2826/typeerror-thisblock-is-null)
2025-03-18 10:58:19 +00:00
Saul-Mirone
5cb2abab76 docs(editor): add doc for reactive types in store (#10958) 2025-03-18 09:07:42 +00:00
Saul-Mirone
ef00a158fc docs(editor): improve documentation for store class (#10949) 2025-03-18 07:57:58 +00:00
L-Sun
83af78d9ee chore(editor): update icon color of link doc card (#10943)
Close [BS-2679](https://linear.app/affine-design/issue/BS-2679/card-view-icon-color-incorrect)
2025-03-18 05:00:26 +00:00
Saul-Mirone
9f3cf271e3 feat(editor): support user provided role and role schema (#10939)
Let me analyze the key changes in this diff:

1. **Role System Changes**:
- Changed from a fixed enum of roles (`root`, `hub`, `content`) to a more flexible string-based system
- Removed strict role hierarchy validation rules (hub/content/root relationships)
- Added support for role-based matching using `@` prefix (e.g., `@root`, `@content`)

2. **Schema Validation Updates**:
- Added new `_matchFlavourOrRole` method to handle both flavour and role-based matching
- Updated `_validateParent` to consider both roles and flavours when validating parent-child relationships
- Simplified `_validateRole` by removing specific role hierarchy constraints

3. **Block Schema Changes**:
- Updated parent/children references in various block schemas to use the new `@` prefix notation
- Changed parent definitions from `['affine:page']` to `['@root']` in several blocks
- Updated children definitions to use role-based references (e.g., `['@content']`)

4. **Test Updates**:
- Added new test cases for role-based schema validation
- Introduced new test block schemas (`TestRoleBlockSchema`, `TestParagraphBlockSchema`) to verify role-based functionality

This appears to be a significant architectural change that makes the block schema system more flexible by:
1. Moving away from hardcoded role hierarchies
2. Introducing a more dynamic role-based relationship system
3. Supporting both flavour-based and role-based parent-child relationships
4. Using the `@` prefix convention to distinguish role references from flavour references

The changes make the system more extensible while maintaining backward compatibility with existing flavour-based relationships.
2025-03-18 01:58:59 +00:00
Saul-Mirone
3de7d85eea feat(editor): improve api for store, and add docs (#10941) 2025-03-17 16:30:59 +00:00
L-Sun
3dbeebd6ba fix(editor): background of surface-ref disappeared when it was re-rendered (#10931)
This PR fixed the background of surface-ref dis
2025-03-17 14:00:17 +00:00
L-Sun
cc8ec72f2c feat(editor): insert a mindmap slash menu action (#10930)
Close [BS-2516](https://linear.app/affine-design/issue/BS-2516/添加mind-map入口)
2025-03-17 13:19:56 +00:00
Saul-Mirone
1d04438049 docs(editor): scaffolding docs generator (#10925) 2025-03-17 12:51:08 +00:00
L-Sun
d80f1e8067 feat(editor): insert a blank frame slash menu action (#10899)
Close [BS-2517](https://linear.app/affine-design/issue/BS-2517/%E6%B7%BB%E5%8A%A0frame%E5%85%A5%E5%8F%A3)

### What changes:
- add a insert blank frame action to slash menu
- move `EdgelessFrameManager` and `FrameOverlay` extensions to `FrameBlockSpec`
- make `FrameBlockSpec` as a part of `CommonBlockSpecs` such that we can use `EdgelessFrameManager` to create a frame more easily

https://github.com/user-attachments/assets/ddff5866-8933-4ce5-aaf4-873661407ee4
2025-03-17 10:32:55 +00:00
EYHN
b401012d85 feat(core): user service loading state (#10922) 2025-03-17 09:28:25 +00:00
Saul-Mirone
d5a5df5e49 test(editor): move blocksuite test to tests folder (#10917) 2025-03-17 06:40:25 +00:00
doodlewind
81af7a0571 docs(editor): add guide for extension usage (#10911)
The guide is baed on #10847 to improve the code quality for migrating extensions using LLM.
2025-03-17 05:38:10 +00:00