Commit Graph

29 Commits

Author SHA1 Message Date
Saul-Mirone
9c65c42d64 chore(editor): cleanup dead code (#9904) 2025-01-27 17:06:42 +00:00
Saul-Mirone
17bf75e843 refactor(editor): remove dependency of command global types (#9903)
Closes: [BS-2216](https://linear.app/affine-design/issue/BS-2216/remove-global-types-in-command)
2025-01-27 12:28:46 +00:00
Saul-Mirone
d6bfb761fe fix(editor): typecheck for tests and playground (#9897) 2025-01-27 02:00:09 +00:00
L-Sun
829980bace refactor(editor): toc dragging with std.dnd (#9883)
Close [BS-2458](https://linear.app/affine-design/issue/BS-2458/toc-dnd重构)

### What Changes
- Refactor toc note card dnd with `std.dnd`
- Extract note display mode change to command `changeNoteDisplayMode`
  - It will reorder notes when the display mode changed from `EdgelessOnly` to page mode visible (a.k.a `DocOnly` or `Both`)
2025-01-24 13:27:17 +00:00
zzj3720
95c0f59d96 refactor(editor): remove database-service (#9769)
close: BS-2426
2025-01-18 05:36:15 +00:00
doouding
b350dd1580 fix: legacy e2e test debug (#9746) 2025-01-17 04:26:59 +00:00
doouding
99717196c5 refactor: rewrite blocksuite dnd (#9595)
### Changed

- Refactored BlockSuite drag-and-drop using @atlaskit/pragmatic-drag-and-drop/element/adapter.
- Updated block dragging to use the new drag-and-drop infrastructure.

### BlockSuite DND API

Access the BlockSuite drag-and-drop API via `std.dnd`. This is a lightweight wrapper around pragmatic-drag-and-drop, offering convenient generic types and more intuitive option names.

#### Drag payload structure
There's some constrain about drag payload. The whole drag payload looks like this:

```typescript
type DragPayload = {
  entity: {
    type: string
  },
  from: {
    at: 'blocksuite',
    docId: string
  }
}
```
- The `from` field is auto-generated—no need for manual handling.
- The `entity` field is customizable, but it must include a `type`.

All drag-and-drop methods accept a generic type for entity, ensuring more accurate payloads in event handlers.

```typescript
type BlockEntity = {
  type: 'blocks',
  blockIds: string[]
}

dnd.draggable<BlockEntity>({
  element: someElement,
  setDragData: () => {
    // the return type must satisfy the generic type
    // in this case, it's BlockEntity
    return {
      type: 'blocks',
      blockIds: []
    }
  }
});

dnd.monitor<BlockEntity>({
  // the arguments is same for other event handler
  onDrag({ source }) {
    // the type of this is BlockEntity
    source.data.entity
  }
})
```

#### Drop payload
When hover on droppable target. You can set drop payload as well. All drag-and-drop methods accept a second generic type for drop payload.

The drop payload is customizable. Additionally, the DND system will add an `edge` field to the final payload object, indicating the nearest edge of the drop target relative to the current drag position.

```typescript
type DropPayload = {
  blockId: string;
}

dnd.dropTarget<BlockEntity, DropPayload>({
  getData() {
    // the type should be DropPayload
    return {
      blockId: 'someId'
    }
  }
});

dnd.monitor<BlockEntity, DropPayload>({
  // drag over on drop target
  onDrag({ location }) {
    const target = location.current.dropTargets[0];

    // the type is DropPayload
    target.data;
    // retrieve the nearest edge of the drop target relative to the current drop position.
    target.data.edge;
  }
})
```
2025-01-16 12:36:58 +00:00
Mirone
446b31b621 refactor(editor): rename job to transformer (#9639) 2025-01-11 12:04:07 +08:00
Yifeng Wang
cac0b7fd66 refactor(editor): remove default entry (#9600) 2025-01-09 14:01:48 +08:00
Saul-Mirone
422bac6cbe refactor(editor): remove readonly in awareness (#9597) 2025-01-09 05:15:35 +00:00
Saul-Mirone
3683297ccf feat(editor): add feature flag service (#9592) 2025-01-08 15:46:31 +00:00
Saul-Mirone
5842d45ab1 feat(editor): merge store and blocks (#9591) 2025-01-08 13:01:19 +00:00
Saul-Mirone
fc863e484c refactor(editor): remove selection global types (#9532)
Closes: [BS-2217](https://linear.app/affine-design/issue/BS-2217/remove-global-types-in-selection)
2025-01-06 03:45:11 +00:00
Saul-Mirone
3d168ba2d2 refactor(editor): reorg code structure of store package (#9525) 2025-01-05 12:49:02 +00:00
Saul-Mirone
c773982ced refactor(editor): rename store api (#9518) 2025-01-04 12:51:56 +00:00
Saul-Mirone
dcf4993265 refactor(core): move block collection to affine and implement as doc (#9514) 2025-01-04 06:28:55 +00:00
Saul-Mirone
897c7d4284 refactor(editor): should not rely on doc collection type (#9501) 2025-01-03 06:30:27 +00:00
doouding
cb5d7eaabc feat: add scroll wheel zoom setting (#9476)
### Changed
Add `scroll wheel to zoom` setting option, when the option enables, user can zoom in and out with scroll wheel without pressing the cmd/ctrl key.
2025-01-03 06:09:10 +00:00
doouding
a4e94ab72f feat: add shortcut of zooming to selection (#9447)
### Changed
- change edgeless shortcut `cmd + 0`, `cmd + 1` to `alt + 0`, `alt + 1`
- add new shortcut `alt + 2` to zoom to currently selected elements
2025-01-03 03:57:05 +00:00
Saul-Mirone
53f7480cb8 refactor(editor): merge docCreated and docAdded slot (#9489) 2025-01-02 11:47:14 +00:00
Saul-Mirone
be387a6f33 refactor(editor): set readonly (#9475) 2025-01-02 04:02:15 +00:00
Saul-Mirone
36c1b103df test(editor): remove jsx snapshot (#9463) 2024-12-31 10:27:12 +00:00
Saul-Mirone
e3b6841944 refactor(editor): reorg block specs (#9421) 2024-12-30 05:59:25 +00:00
fundon
b9f2650369 feat(editor): store real color values in edgeless (#9254)
### What's Changed!

* adds theme type: `ThemeSchema`
* adds default theme: `DefaultTheme`
* stores real color values
2024-12-30 03:36:35 +00:00
fundon
a5641ae608 feat(editor): update edgeless color palette (#9243)
Closes: [BS-1475](https://linear.app/affine-design/issue/BS-1475/颜色主题更新) [BS-1803](https://linear.app/affine-design/issue/BS-1803/fill-color色板影响的yuan素) [BS-1804](https://linear.app/affine-design/issue/BS-1804/border-color色板影响的yuan素) [BS-1815](https://linear.app/affine-design/issue/BS-1815/连线文字配色略瞎)

### What's Changed

* refactor `EdgelessLineWidthPanel` component, the previous width is fixed and cannot be used in the new design
* refactor `EdgelessColorPanel` and `EdgelessColorButton` components, make them simple and reusable
* delete redundant `EdgelessOneRowColorPanel` component
* unity and update color palette, if the previously set color is not in the latest color palette, the custom color button will be selected
2024-12-30 03:36:34 +00:00
Saul-Mirone
1e4b1807be refactor(editor): query methods in edgeless api (#9407) 2024-12-28 07:48:41 +00:00
Brooooooklyn
706b614006 style: add sonarjs/no-gratuitous-expressions rule (#9360) 2024-12-27 03:30:20 +00:00
doouding
b246a2d45f fix: drag mind map root node should layout in real time (#9252)
Fixes [BS-2062](https://linear.app/affine-design/issue/BS-2062/拖拽整个-mind-map-还是希望和之前一样,整个思维导图跟手)
2024-12-23 10:33:56 +00:00
Saul-Mirone
bfcc53dc1f chore: migrate blocksuite test (#9222) 2024-12-20 11:08:21 +00:00