Commit Graph
22 Commits
Author SHA1 Message Date
doouding 02122098c7 fix: drag block issue (#9902)
### Changed
- Added support for changing the preview offset during dragging.
- Fixed the preview rendering for embed block and surface-ref block
- Resolved an issue where the host element might be reused in certain cases, which could cause unexpected behavior
- Moved viewport-related constants and methods to a more appropriate location
2025-02-05 07:25:53 +00:00
doouding 73b4437081 chore: dnd cleanup (#9899) 2025-01-27 04:29:14 +00:00
doouding 1560880abd fix: drag embed block preview (#9791)
Fixes [BS-1518](https://linear.app/affine-design/issue/BS-1518/拖拽一个-embed-view-的-linked-doc,其-indicator-是错误的)
2025-01-20 09:25:05 +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
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
doouding 7dbb85c8c2 fix: sentry AFFINE-84T (#9368)
Fixes [BS-2243](https://linear.app/affine-design/issue/BS-2243/typeerror-cannot-read-properties-of-undefined-reading-length)
2024-12-27 07:07:53 +00:00
doouding 71272203b0 fix: beginPath before drawing drag indicator (#9364)
Fixes [BS-2238](https://linear.app/affine-design/issue/BS-2238/frame-套一个-mindmap-,拖动行为不可用)
2024-12-27 04:02:57 +00:00
doouding 0de4f7abbb test: add mindmap collapse test (#9336) 2024-12-26 08:23:09 +00:00
doouding 4ead165dd5 fix: mini mindmap layout (#9276)
Fixes [BS-2197](https://linear.app/affine-design/issue/BS-2197/ai-生成-mindmap-预览异常)
2024-12-24 06:55:26 +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
doouding 393dcfec78 feat: bump bs (#8212)
https://github.com/toeverything/blocksuite/pull/8311
2024-09-12 04:28:14 +00:00
doouding 52d9569f47 feat: add mind map import feature flag (#8196) 2024-09-11 06:27:47 +00:00
doouding 05ac3dbdcb feat: bump bs (#7866) 2024-08-14 04:42:20 +00:00
doouding cf7b026832 feat: bump bs (#7430)
## Features

## Bugfix
- https://github.com/toeverything/BlockSuite/pull/7499 @doouding
- https://github.com/toeverything/BlockSuite/pull/7491 @golok727

## Refactor

## Misc
- https://github.com/toeverything/BlockSuite/pull/7454 @CatsJuice
2024-07-09 07:56:16 +00:00
doouding b379aa0a91 feat: bump bs (#7266)
## Features
- https://github.com/toeverything/BlockSuite/pull/7366 @donteatfriedrice
- https://github.com/toeverything/BlockSuite/pull/7360 @Flrande
- https://github.com/toeverything/BlockSuite/pull/7350 @Flrande

## Bugfix
- https://github.com/toeverything/BlockSuite/pull/7372 @Saul-Mirone
- https://github.com/toeverything/BlockSuite/pull/7365 @CatsJuice
- https://github.com/toeverything/BlockSuite/pull/7369 @doouding
- https://github.com/toeverything/BlockSuite/pull/7367 @akumatus
- https://github.com/toeverything/BlockSuite/pull/7364 @CatsJuice
- https://github.com/toeverything/BlockSuite/pull/7356 @akumatus
- https://github.com/toeverything/BlockSuite/pull/7335 @doouding
- https://github.com/toeverything/BlockSuite/pull/7362 @Flrande
- https://github.com/toeverything/BlockSuite/pull/7361 @Flrande
- https://github.com/toeverything/BlockSuite/pull/7359 @donteatfriedrice
- https://github.com/toeverything/BlockSuite/pull/7358 @zzj3720
- https://github.com/toeverything/BlockSuite/pull/7344 @fundon

## Refactor

## Misc
- https://github.com/toeverything/BlockSuite/pull/7370 @Saul-Mirone
- https://github.com/toeverything/BlockSuite/pull/7368 @Saul-Mirone
2024-06-19 06:56:25 +00:00
doouding 314fa064ab fix: peek view on synced doc (#7265) 2024-06-19 06:41:08 +00:00
doouding a3ca41fd6a fix: surface-ref peek view (#7208)
### Change
Add ref to `SurfaceRefPeekView`. It provide `fitViewportToTarget` method to fit the `surface-ref` content.

Related to [AFF-1200](https://linear.app/affine-design/issue/AFF-1200/center-peek-frame-rendering-issue).
2024-06-13 07:05:14 +00:00
doouding ec8b2cc32a feat: bump bs (#7198)
## Features
- https://github.com/toeverything/BlockSuite/pull/7264 @CatsJuice
- https://github.com/toeverything/BlockSuite/pull/7182 @CatsJuice
- https://github.com/toeverything/BlockSuite/pull/7181 @CatsJuice

## Bugfix
- https://github.com/toeverything/BlockSuite/pull/7273 @L-Sun
- https://github.com/toeverything/BlockSuite/pull/7272 @doouding
- https://github.com/toeverything/BlockSuite/pull/7263 @doouding
- https://github.com/toeverything/BlockSuite/pull/7252 @fourdim
- https://github.com/toeverything/BlockSuite/pull/7261 @fundon

## Refactor
- https://github.com/toeverything/BlockSuite/pull/7271 @golok727

## Misc
- https://github.com/toeverything/BlockSuite/pull/7274 @Saul-Mirone
- https://github.com/toeverything/BlockSuite/pull/7266 @Saul-Mirone
2024-06-12 05:50:58 +00:00
doouding 0dd0432531 fix(server): update mind map prompt (#7079) 2024-05-27 12:01:45 +00:00
doouding 6525c99631 feat(server): new prompt for expand mind map (#6678)
feat(server): new prompt for expand mind map

feat: add migration file
2024-04-24 07:10:11 +00:00