Commit Graph

1146 Commits

Author SHA1 Message Date
akumatus
3d2f0e7b5b feat(core): chat-panel buttons ui (#11942)
Close [AI-7](https://linear.app/affine-design/issue/AI-7).

![截屏2025-04-23 23.29.32.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/a984a28f-0ccf-4e8d-ba2d-239ad03f2998.png)
2025-04-24 14:32:55 +00:00
akumatus
a603c06fab feat(core): add web search tool and reasoning params (#11912)
Close [AI-60](https://linear.app/affine-design/issue/AI-60).

### What changed?
- Add Exa web search tool
- Add reasoning params
2025-04-24 12:23:06 +00:00
Peng Xiao
13b28e2ad8 fix(core): remove image proxy in onboarding snapshots (#11954) 2025-04-24 17:03:36 +08:00
L-Sun
a9ad01491c test(core): enable no-floating-promises rule for tests (#11915)
Sometimes, missing `await` in the test code can cause timing issues, leading to test failures. This PR enables the `no-floating-promises` rule for the test code to ensure that such errors do not occur.
2025-04-23 08:17:41 +00:00
L-Sun
9dbdd4b7ba refactor(editor): add helper function for undo notification (#11903)
### What Changes
- Refactors the `notify` function call with undo button. It is called `notifyWithUndo`, which can  associate the visibility of the `NotificationCard` with the top undo item in history stack, such as undo by shortcut `Cmd+Z`.
- change icon of the "Insert into page" button. Close [BS-3267](https://linear.app/affine-design/issue/BS-3267/frame和group的insert-into-page图标也更换一下)
2025-04-23 05:56:23 +00:00
L-Sun
27ff9ab9f4 refactor(core): move actions to footer of notification card (#11894)
This PR move all actions button to the footer of `NotificationCard`. There are some example as following:

### No Changes
![CleanShot 2025-04-22 at 20.02.58@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyRfgiN4RuBxJfrza3SG/1207cbfb-6033-48f4-8a7b-b7b024f16881.png)

![CleanShot 2025-04-22 at 20.03.42@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyRfgiN4RuBxJfrza3SG/6da27303-06c3-4f40-b3f9-3cf88759f685.png)

![CleanShot 2025-04-22 at 20.03.57@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyRfgiN4RuBxJfrza3SG/a53d2bdf-a103-4275-9833-a55387af6f09.png)

### Changes
### Before
![CleanShot 2025-04-22 at 20.07.40@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyRfgiN4RuBxJfrza3SG/d785b12b-480c-4b9d-bb0b-d93dd18939a2.png)

#### After
![CleanShot 2025-04-22 at 20.05.51@2x.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyRfgiN4RuBxJfrza3SG/242a9956-6a68-46a7-865a-454117ee997c.png)
2025-04-23 05:41:14 +00:00
L-Sun
9baef237f2 test(core): add missing await for expect (#11900) 2025-04-23 04:55:18 +00:00
doodlewind
1b2030b36a fix(editor): should not paste in readonly page mode (#11913)
### TL;DR

Prevent pasting content when a document is in readonly mode.

### What changed?

Added a check in the `PageClipboard` class to prevent pasting operations when the document is in readonly mode. The function now returns early if `this.std.store.readonly` is true, preventing any clipboard operations from being executed.

### How to test?

1. Open a document and add some content
2. Set the document to readonly mode: `document.querySelector('affine-page-root')!.doc.readonly = true`
3. Try to paste content into the document using:
   - Regular paste operation
   - Keyboard shortcut (Ctrl+V/Cmd+V)
4. Verify that no content is pasted and the document remains unchanged
5. Set the document back to editable mode and confirm pasting works again

### Why make this change?

This change ensures that documents in readonly mode maintain their integrity by preventing unintended modifications through clipboard operations. This is consistent with the expected behavior of readonly documents, where users should not be able to modify content through any means.
2025-04-23 04:30:26 +00:00
darkskygit
597b27c22f feat(server): enable web search for 4.1 (#11825) 2025-04-22 14:49:46 +00:00
Brooooooklyn
bfd3c64615 test: add mutex to clipboard copy & paste operation to reduce flaky (#11884) 2025-04-22 11:02:30 +00:00
doouding
b59f6ebde0 refactor: default-tool box selection (#11800)
### Changed
- Rewrite box selection in `default-tool`, the view can decide whether to be selected in box selection by return a boolean value in `onBoxSelected` method
- Cleanup unnecessary states in `default-tool` and some naming problem
2025-04-22 08:18:26 +00:00
L-Sun
e457e2f8a8 fix(editor): add reference after duplicate edgeless embed doc as note (#11877)
- fix(editor): add reference in the copied note of embed doc
- refactor(editor): add generics parameter `TextAttributes` into `Text`
2025-04-22 08:03:52 +00:00
yoyoyohamapi
19c06a2821 fix(core): falky ai save as block test (#11878) 2025-04-22 06:58:26 +00:00
EYHN
e4d6833296 refactor(core): rename explorer to navigation-panel (#11876) 2025-04-22 12:47:35 +08:00
fundon
fd67bdf88b fix(editor): should update color of edgeless text when switching theme (#11853)
Closes: [BS-3258](https://linear.app/affine-design/issue/BS-3258/edgeless-text-颜色不符合预期)
2025-04-21 13:54:12 +00:00
Brooooooklyn
864dd0e74d test: fix flaky create template doc e2e (#11863) 2025-04-21 13:04:49 +00:00
L-Sun
a2b40fea20 feat(editor): insertion and duplication actions for embed synced doc (#11852)
Close [BS-3068](https://linear.app/affine-design/issue/BS-3068/在edgeless-的embed-doc-block上,增加-insert-into-page的选项,类似frame)
Close [BS-3069](https://linear.app/affine-design/issue/BS-3069/edgeless下的-embed,覆盖现在的edit行为-,暂定叫做duplicate-into-a-note,复制一个-note)
2025-04-21 11:01:04 +00:00
L-Sun
61ce1123ae refactor(editor): split synced-doc-block tests to serveral files (#11845)
This PR splits `synced-doc-block.spec.ts` into multiple files for better organization.
2025-04-21 08:54:04 +00:00
yoyoyohamapi
f65c8f8fa6 fix(core): disable space ai guidance for non-paragraph block (#11847)
### TL;DR

Disable space ai guidance for non-paragraph block

> CLOSE AI-67
2025-04-21 08:04:51 +00:00
pengx17
535b5ff7c2 fix(core): flaky quick search test (#11833) 2025-04-21 04:14:29 +00:00
L-Sun
6d7cd6dd99 fix(editor): banner of blookmark not shown in edgeless (#11796)
Close [BS-2651](https://app.graphite.dev/github/pr/toeverything/AFFiNE/11797/chore(editor)-add-feature-flag-to-embed-doc-with-alias)
### What Changes:
- Fixed banner of edgeless embed bookmark is not shown
- Add fallback bookmark creation with embed creation modal when there is not a `QuickSearchProvider` in blocksuite playground
- Add tests for embed blookmark and embed github block in edgeless
2025-04-21 03:33:18 +00:00
Saul-Mirone
c74b5dc214 fix(editor): convert note to linked doc from edgeless (#11828)
Closes: BS-3244
2025-04-21 03:18:14 +00:00
fundon
c0ff567a2a fix(editor): get block props (#11807)
Closes: [BS-3184](https://linear.app/affine-design/issue/BS-3184/duplicate-图片,一直在loading)
2025-04-18 10:59:31 +00:00
yoyoyohamapi
dcfc92347f fix(core): unable to copy the selected ai answer content across multiple lines (#11806)
> CLOSE AI-76
2025-04-18 10:33:14 +00:00
fundon
1ae36d4b3e fix(editor): remove redundant subtraction (#11781) 2025-04-18 03:53:51 +00:00
EYHN
dd51180acb feat(core): replace onboarding template (#11768) 2025-04-18 02:31:13 +00:00
fundon
a46bb446e2 fix(editor): should keep color on custom color button (#11773)
Closes: [BS-3167](https://linear.app/affine-design/issue/BS-3167/自定义按钮显示错误)
2025-04-17 12:21:39 +00:00
akumatus
e577bb7aa9 fix(core): ask ai loses user selected context (#11767)
Close [AI-72](https://linear.app/affine-design/issue/AI-72)
2025-04-17 09:05:44 +00:00
L-Sun
98899b4eea feat(editor): affine to blocksuite doc dnd with prefered card view (#11748)
Close [BS-3070](https://linear.app/affine-design/issue/BS-3070/文档拖动进入edgeless,形成引用时,默认形成embeded的引用,但是记录上次选择)
2025-04-17 04:06:50 +00:00
akumatus
50b3f5f7df fix(core): ai history of new users is always loading, enable online search by default (#11741)
Close [AI-69](https://linear.app/affine-design/issue/AI-69).
2025-04-17 02:53:41 +00:00
donteatfriedrice
212c13f843 fix(editor): add code block clipboard extension (#11731)
Close [BS-3109](https://linear.app/affine-design/issue/BS-3109/code-block-不支援-markdown-語法)
2025-04-16 08:32:00 +00:00
fundon
8ca675b2ec fix(editor): improve pdf embed viewer UX (#11641)
Closes: [BS-3101](https://linear.app/affine-design/issue/BS-3101/pdf-embed-模式的选中框选-和点开看详情有比较大的问题)

### What's Changed!

* Fixed disable pointer event in native pdf viewer by dragging
* Disable opening peek view with pdf viewer in readonly and sharing modes
2025-04-15 08:51:02 +00:00
yoyoyohamapi
0df584bd5e refactor(core): add keyPress event to fix IME space detection (#11700)
### TL;DR
Refactor space-triggered AI Widget activation logic from `keydown` to `keypress` event listeners

### Background

The `keydown` event triggered by a space may originate from:
1. Normal space insertion
2. Space triggered by input method confirming candidate words

In scenarios like (2), some browsers (see [ISSUE](https://github.com/toeverything/AFFiNE/issues/11541)) and input method callbacks produce events identical to scenario (1),making it impossible to distinguish between the two.

To fix this, the space-activated AI listener uses the `keypress` event:
In scenario 2, `event.which !== 32` (may be `30430` or other values) can be used to differentiate from scenario 1.

> CLOSE BS-3081
2025-04-15 08:37:27 +00:00
donteatfriedrice
7aa87de5f7 fix(editor): markdown code preprocessor should handle link correctly (#11671)
Close [BS-3117](https://linear.app/affine-design/issue/BS-3117/代码粘贴后出现多余的-和-符号)
2025-04-14 08:28:43 +00:00
Saul-Mirone
efecce9bf2 test(editor): enable basic test for cross platform (#11667) 2025-04-14 07:36:56 +00:00
yoyoyohamapi
d494394c8d test(core): common setup for ai tests (#11644)
### TL:DR

By sharing initialization logic, accelerate test case execution.

### What Changed

* Global setup for copilot e2e
  * Login
  * Create Workspace
* Enable fully parallel for ci

### Optimization Comparison​

Comparing with PR [fix(core): ask AI input box in the whiteboard is blocked by the menu …](https://github.com/toeverything/AFFiNE/pull/11634):

|           |    Shard 1   |2|3|4|5|6|7|8|
| ------|----|----|----|----|----|---|---|--|
|Before|15min|14min|14min|14min|14min|13min|15min|10min|
|After|8min|11min|8min|8min|8min|8min|8min|7min|

### Trade-Off

Since all copilot use cases currently share a single user and workspace, some test cases need to focus on **isolation** and **independence**.
For example, when testing Embedding-related workflows:
* Different document contents should be used to avoid interference.
* After each test case execution, **cleanup** operations are also required.
* Some tests should be configured to **serial** mode.

```ts
test.describe.configure({ mode: 'serial' });

test.describe('AIChatWith/Collections', () => {
  test.beforeEach(async ({ loggedInPage: page, utils }) => {
    await utils.testUtils.setupTestEnvironment(page);
    await utils.chatPanel.openChatPanel(page);
    await utils.editor.clearAllCollections(page);

    await utils.testUtils.createNewPage(page);
  });

  test.afterEach(async ({ loggedInPage: page, utils }) => {
    // clear all collections
    await utils.editor.clearAllCollections(page);
  });

  test('should support chat with collection', async ({
    loggedInPage: page,
    utils,
  }) => {
    // Create two collections
    await utils.editor.createCollectionAndDoc(
      page,
      'Collection 1',
      'CollectionAAaa is a cute dog'
    );

    await utils.chatPanel.chatWithCollections(page, ['Collection 1']);
    await utils.chatPanel.makeChat(page, 'What is CollectionAAaa(Use English)');
    // ...
  });

  test('should support chat with multiple collections', async ({
    loggedInPage: page,
    utils,
  }) => {
    // Create two collections
    await utils.editor.createCollectionAndDoc(
      page,
      'Collection 2',
      'CollectionEEee is a cute cat'
    );

    await utils.editor.createCollectionAndDoc(
      page,
      'Collection 3',
      'CollectionFFff is a cute dog'
    );

    await utils.chatPanel.chatWithCollections(page, [
      'Collection 2',
      'Collection 3',
    ]);
    await utils.chatPanel.makeChat(
      page,
      'What is CollectionEEee? What is CollectionFFff?(Use English)'
    );
    // ...
  });
});

```

> CLOSE AI-51
2025-04-14 02:42:06 +00:00
L-Sun
076c5ba044 fix(editor): repeat trigger keys of at-menu was added (#11631)
Close [BS-2716](https://linear.app/affine-design/issue/BS-2716/移动端通过toolpanel唤起的at-menu,出现两个)
2025-04-13 06:46:37 +00:00
donteatfriedrice
4da00eba0d fix(editor): cut and paste surface-ref to same doc should remain surface-ref (#11639)
Close [BS-3107](https://linear.app/affine-design/issue/BS-3107/剪切-surface-ref-block-会变成指向当前文档的link-card)
2025-04-12 01:56:24 +00: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
aabb09b31f fix(editor): ime input error at empty line (#11636)
Close [BS-3106](https://linear.app/affine-design/issue/BS-3106/mac-chrom在空行使用ime输入,文档卡住)
2025-04-11 10:39:16 +00:00
yoyoyohamapi
149433b8d0 fix(core): cannot focus inside shape in test (#11630) 2025-04-11 05:26:27 +00:00
doouding
714f2e79dc fix: cannot exit editing mode when click frame body (#11603) 2025-04-11 03:23:27 +00:00
Saul-Mirone
a2f879066f ci(editor): enable cross platform test (#11566) 2025-04-10 16:52:15 +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
yoyoyohamapi
25418b402a fix(core): replace zero-width non-ioiner for editor content​ (#11591) 2025-04-10 11:55:31 +00:00
donteatfriedrice
dbb8451adb test(core): add e2e test for share page copy function (#11555)
related pr https://github.com/toeverything/AFFiNE/pull/11538
To close [BS-1915](https://linear.app/affine-design/issue/BS-1915/public-page-页面应该允许选中和复制内容)
2025-04-10 06:34:15 +00:00
donteatfriedrice
0302bd43cb fix(editor): should preserve indentation when pasting code with spaces into code block (#11587)
Close [BS-3087](https://linear.app/affine-design/issue/BS-3087/粘贴内容到-code-block-缩进会丢)
2025-04-10 04:48:08 +00:00
fundon
bb79781dd8 fix(editor): should clear selection when switching doc mode (#11545)
Closes: [BS-3050](https://linear.app/affine-design/issue/BS-3050/切换模式时,清除选区)
2025-04-10 03:10:50 +00:00
L-Sun
06497773a7 fix(editor): can not move carte at the end of inline element (#11558)
Close [BS-2922](https://linear.app/affine-design/issue/BS-2922/【移动端-ios】文档添加linked-page后,无法删除)
2025-04-09 08:07:02 +00:00
fundon
c57f41805f fix(editor): should auto close dropdown menus on toolbar (#11522)
Closes: [BS-2524](https://linear.app/affine-design/issue/BS-2524/切换-block-后,刷新-toolbar-时,应该自动关闭已经打开的-dropdown)
2025-04-09 01:29:44 +00:00