Compare commits

...

67 Commits

Author SHA1 Message Date
Yifeng Wang 9c696d278b Add lint-staged script 2025-05-29 16:23:30 +08:00
Yifeng Wang 372fc126b5 test: add test 2025-05-29 16:13:48 +08:00
Yifeng Wang 6d57c01dd4 feat(editor): support brush dom renderer 2025-05-29 16:13:48 +08:00
Yifeng Wang 3d2d399796 refactor: extract common builder 2025-05-29 16:13:48 +08:00
Yifeng Wang 6483f36723 refactor: use path builder 2025-05-29 16:13:48 +08:00
Yifeng Wang df2ecf2bec feat(editor): support connector dom renderer 2025-05-29 16:13:48 +08:00
Yifeng Wang 148c718a12 fix: review 2025-05-29 16:13:48 +08:00
Yifeng Wang c4af1e77d0 fix: test 2025-05-29 16:13:48 +08:00
Yifeng Wang 6a0eb80903 feat(editor): support triangle and diamond shape in shape dom renderer 2025-05-29 16:13:48 +08:00
L-Sun 77392efaa2 chore(editor): remove feature flag of embed doc with alias (#12620)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Toolbar actions related to embedding and duplicating documents are now always available without restrictions.

- **Chores**
  - Removed the feature flag controlling embed document alias features for a simpler user experience.

- **Tests**
  - Updated test setup to remove reliance on the deprecated feature flag.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 07:55:52 +00:00
L-Sun 927b4f4430 chore(editor): adjust format of date time in slash menu (#12631)
Closes: #12624

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Updated the time formatting to display dates as "yyyy-mm-dd hh:mm" instead of "mm-dd hh:mm".

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 07:32:35 +00:00
renovate 9ec1d08d98 chore: bump up @chromatic-com/storybook version to v4 (#12618)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@chromatic-com/storybook](https://redirect.github.com/chromaui/addon-visual-tests) | [`^3.2.2` -> `^4.0.0`](https://renovatebot.com/diffs/npm/@chromatic-com%2fstorybook/3.2.6/4.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@chromatic-com%2fstorybook/4.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@chromatic-com%2fstorybook/4.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@chromatic-com%2fstorybook/3.2.6/4.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@chromatic-com%2fstorybook/3.2.6/4.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>chromaui/addon-visual-tests (@&#8203;chromatic-com/storybook)</summary>

### [`v4.0.0`](https://redirect.github.com/chromaui/addon-visual-tests/compare/v3.2.6...814ef25cc6d4fd763d089f67b21f8b56429d6512)

[Compare Source](https://redirect.github.com/chromaui/addon-visual-tests/compare/v3.2.6...v4.0.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4zMy42IiwidXBkYXRlZEluVmVyIjoiNDAuMzMuNiIsInRhcmdldEJyYW5jaCI6ImNhbmFyeSIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->
2025-05-29 07:17:38 +00:00
JimmFly 86cd92a878 fix(core): add loading status to share page button (#12288)
close AF-2615

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Enhancements**
  - Improved the share menu's user experience by showing a loading indicator and disabling the public page button during revalidation. This prevents user interaction while the share info is updating.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 07:02:43 +00:00
akumatus ab28213df2 feat(core): support synchronization of ai playground input value and send button (#12607)
Close [AI-86](https://linear.app/affine-design/issue/AI-86)

[123.mov <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/sJGviKxfE3Ap685cl5bj/01ca98ef-60a3-4a42-9bef-62993f6a657b.mov" />](https://app.graphite.dev/media/video/sJGviKxfE3Ap685cl5bj/01ca98ef-60a3-4a42-9bef-62993f6a657b.mov)
2025-05-29 06:26:32 +00:00
fengmk2 39cb1afedb fix(server): limit rootDoc snapshot size (#12625)
close CLOUD-225

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Added support for reading document blocks without requiring a workspace or root document snapshot.
- **Bug Fixes**
  - Improved handling of large workspace snapshots by skipping them when they exceed 10MB.
- **Tests**
  - Introduced new test cases to cover scenarios where root or workspace snapshots are absent.
  - Expanded snapshot tests for document block reading.
- **Refactor**
  - Updated several function signatures to make root and workspace snapshot parameters optional for greater flexibility.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 05:32:31 +00:00
JimmFly 1eb9e62075 fix(core): adjust sign in page z-index (#12476)
![CleanShot 2025-05-23 at 14 13 11@2x](https://github.com/user-attachments/assets/b5a26ece-1a37-4c89-be88-b3026331999d)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Style**
  - Improved layering of the sign-in page container to ensure it displays above other elements when necessary.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 05:18:14 +00:00
JimmFly ef5f96bfb6 fix(core): loadDoc tracking events not tracking correctly (#11960)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Refactor**
  - Improved the reliability and clarity of loading state and error tracking in the editor, resulting in more accurate feedback during document loading.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 05:03:27 +00:00
yoyoyohamapi b9c70985a1 fix(core): workspace embedding settings icon (#12622)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Style**
  - Updated the icon for the embedding workspace setting to a new design for improved visual clarity.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 04:48:56 +00:00
yoyoyohamapi 66db63c845 feat(core): no-access & local for workspace embedding (#12598)
## TL;DR

Workspace embedding settings opt:

* **local workspace**: show enable cloud panel
* **no-access workspace**: disable settings panel

![截屏2025-05-28 14.59.36.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyktQ6Qwc7H6TiRCFoYN/58e1f511-9bde-487e-a4cd-f0818c582fcb.png)

![截屏2025-05-28 15.00.19.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/MyktQ6Qwc7H6TiRCFoYN/25c3db30-bf31-4c92-a771-55ce871c9a7a.png)

> CLOSE AI-155

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Embedding settings UI now displays a tooltip indicating that only workspace owners can enable Workspace Embedding.
  - Embedding settings are modularized for local and cloud workspaces, with clear separation and appropriate enablement controls.
  - Attachments in embedding settings cannot be deleted when the settings are disabled.

- **Accessibility**
  - Settings wrapper now includes an aria-disabled attribute for improved assistive technology support.

- **Localization**
  - Added a new tooltip message: "Only the workspace owner can enable Workspace Embedding."

- **Tests**
  - Added end-to-end tests for local workspace UI and disabled state when not the workspace owner.

- **UI Improvements**
  - Updated settings panel to better reflect disabled states with tooltips and conditional controls.
  - Improved synchronization when opening the embedding settings panel for a smoother user experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 04:33:07 +00:00
L-Sun 32a29657e4 fix(editor): incorrect position of toolbar in android (#12614)
### Before
Extra padding between toolbaar and keyboard
![CleanShot 2025-05-28 at 18 56 02](https://github.com/user-attachments/assets/9c865f7c-3acf-41b6-9436-d8d2d4c89c83)

### After
![CleanShot 2025-05-28 at 18 55 19](https://github.com/user-attachments/assets/0a4aeb01-32af-4420-b204-feca3981641b)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Bug Fixes**
  - Improved accuracy of keyboard height calculations by properly accounting for the navigation bar height on Android devices.

- **Refactor**
  - Standardized naming conventions for navigation bar height methods and unit conversion utilities to enhance consistency across the app.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 04:19:01 +00:00
renovate 1aa0cd27d5 chore: bump up storybook monorepo to v9 (major) (#12616)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@storybook/addon-links](https://redirect.github.com/storybookjs/storybook/tree/next/code/addons/links) ([source](https://redirect.github.com/storybookjs/storybook/tree/HEAD/code/addons/links)) | [`^8.4.7` -> `^9.0.0`](https://renovatebot.com/diffs/npm/@storybook%2faddon-links/8.6.14/9.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@storybook%2faddon-links/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@storybook%2faddon-links/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@storybook%2faddon-links/8.6.14/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@storybook%2faddon-links/8.6.14/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@storybook/react](https://redirect.github.com/storybookjs/storybook/tree/next/code/renderers/react) ([source](https://redirect.github.com/storybookjs/storybook/tree/HEAD/code/renderers/react)) | [`^8.4.7` -> `^9.0.0`](https://renovatebot.com/diffs/npm/@storybook%2freact/8.6.14/9.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@storybook%2freact/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@storybook%2freact/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@storybook%2freact/8.6.14/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@storybook%2freact/8.6.14/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@storybook/react-vite](https://redirect.github.com/storybookjs/storybook/tree/next/code/frameworks/react-vite) ([source](https://redirect.github.com/storybookjs/storybook/tree/HEAD/code/frameworks/react-vite)) | [`^8.4.7` -> `^9.0.0`](https://renovatebot.com/diffs/npm/@storybook%2freact-vite/8.6.14/9.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@storybook%2freact-vite/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@storybook%2freact-vite/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@storybook%2freact-vite/8.6.14/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@storybook%2freact-vite/8.6.14/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [storybook](https://storybook.js.org) ([source](https://redirect.github.com/storybookjs/storybook/tree/HEAD/code/core)) | [`^8.4.7` -> `^9.0.0`](https://renovatebot.com/diffs/npm/storybook/8.6.14/9.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/storybook/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/storybook/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/storybook/8.6.14/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/storybook/8.6.14/9.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>storybookjs/storybook (@&#8203;storybook/addon-links)</summary>

### [`v9.0.0`](https://redirect.github.com/storybookjs/storybook/blob/HEAD/CHANGELOG.md#900)

[Compare Source](https://redirect.github.com/storybookjs/storybook/compare/v8.6.14...v9.0.0)

##### Storybook 9.0 is here

This is a huge release focused on testing and bundle size.

-   Component testing
    -   👆 Interactions
    -   ️ Accessibility
    -   👁️ Visual changes
    -   🛡️ Coverage
-   🪶 48% lighter bundle
-   🏷️ Tags-based organization
-   🌐 Story globals
-   🏗️ Major upgrades: Svelte, Next, React Native, Angular

Please checkout our [Migration guide](https://storybook.js.org/docs/9/migration-guide) to upgrade from earlier versions of Storybook. To see a comprehensive list of changes that went into 9.0, you can refer to the [9.0 prerelease changelogs](./CHANGELOG.prerelease.md)

<details>
<summary>List of all updates</summary>

-   Addon A11y: Add `linkPath` to Axe results and use it in copy link action - [#&#8203;31009](https://redirect.github.com/storybookjs/storybook/pull/31009), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Addon A11y: Fix setup as part of storybook create - [#&#8203;31403](https://redirect.github.com/storybookjs/storybook/pull/31403), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Addon A11y: Fix usage of axe-core in pnpm projects - [#&#8203;31422](https://redirect.github.com/storybookjs/storybook/pull/31422), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Addon A11y: Fix various issues and inconsistencies - [#&#8203;31432](https://redirect.github.com/storybookjs/storybook/pull/31432), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Addon A11y: Improve selector automigration detection - [#&#8203;31392](https://redirect.github.com/storybookjs/storybook/pull/31392), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Addon A11y: Only run checks in story mode - [#&#8203;30976](https://redirect.github.com/storybookjs/storybook/pull/30976), thanks [@&#8203;kroeder](https://redirect.github.com/kroeder)!
-   Addon A11y: Provide full report in a11y manual runs - [#&#8203;31325](https://redirect.github.com/storybookjs/storybook/pull/31325), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Addon A11y: Use short titles and friendly summary messages in A11y report - [#&#8203;31185](https://redirect.github.com/storybookjs/storybook/pull/31185), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Addon Controls: Fix loading state UI in addon panel - [#&#8203;31168](https://redirect.github.com/storybookjs/storybook/pull/31168), thanks [@&#8203;iineineno03k](https://redirect.github.com/iineineno03k)!
-   Addon Docs: Fix `layout: centered` in conjunction with `inline: false` - [#&#8203;31430](https://redirect.github.com/storybookjs/storybook/pull/31430), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Addon Docs: Fix docs-content overflow with TOC - [#&#8203;27167](https://redirect.github.com/storybookjs/storybook/pull/27167), thanks [@&#8203;njsokol](https://redirect.github.com/njsokol)!
-   Addon Docs: Fix iframe content width in centered layout - [#&#8203;31320](https://redirect.github.com/storybookjs/storybook/pull/31320), thanks [@&#8203;Audie80](https://redirect.github.com/Audie80)!
-   Addon Docs: Improve TableOfContents HTML structure and a11y - [#&#8203;31327](https://redirect.github.com/storybookjs/storybook/pull/31327), thanks [@&#8203;Sidnioulz](https://redirect.github.com/Sidnioulz)!
-   Addon Docs: Reset error boundary when story changes to recover from erros - [#&#8203;31242](https://redirect.github.com/storybookjs/storybook/pull/31242), thanks [@&#8203;yatishgoel](https://redirect.github.com/yatishgoel)!
-   Addon Docs: Simplify color parsing and color cycling logic - [#&#8203;29840](https://redirect.github.com/storybookjs/storybook/pull/29840), thanks [@&#8203;leyvae](https://redirect.github.com/leyvae)!
-   Addon Docs: Update telejson - [#&#8203;31115](https://redirect.github.com/storybookjs/storybook/pull/31115), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Addon Pseudo States: Move package into monorepo - [#&#8203;31123](https://redirect.github.com/storybookjs/storybook/pull/31123), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Addon Test: Improve unhandled error messages - [#&#8203;30755](https://redirect.github.com/storybookjs/storybook/pull/30755), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Addon Test: Rename `@storybook/experimental-addon-test` to `@storybook/addon-vitest` - [#&#8203;31014](https://redirect.github.com/storybookjs/storybook/pull/31014), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Addon Vitest: Ensure vitest exclusions are relative to the project root, not cwd - [#&#8203;31514](https://redirect.github.com/storybookjs/storybook/pull/31514), thanks [@&#8203;mrginglymus](https://redirect.github.com/mrginglymus)!
-   Addon Vitest: Fix broken docs links - [#&#8203;31445](https://redirect.github.com/storybookjs/storybook/pull/31445), thanks [@&#8203;kylegach](https://redirect.github.com/kylegach)!
-   Addon Vitest: Fix watch mode for new files - [#&#8203;31156](https://redirect.github.com/storybookjs/storybook/pull/31156), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Addon Vitest: Ignore mdx files as part of tests - [#&#8203;31457](https://redirect.github.com/storybookjs/storybook/pull/31457), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Addon Vitest: Improve handling multiple browser mode projects - [#&#8203;31508](https://redirect.github.com/storybookjs/storybook/pull/31508), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Addon Vitest: Support `vitest.projects.ts` file as workspace file during postinstall - [#&#8203;31565](https://redirect.github.com/storybookjs/storybook/pull/31565), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Addon Vitest: Transform [@&#8203;storybook/nextjs](https://redirect.github.com/storybook/nextjs) imports to [@&#8203;storybook/nextjs-vite](https://redirect.github.com/storybook/nextjs-vite) during init - [#&#8203;31180](https://redirect.github.com/storybookjs/storybook/pull/31180), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Addon Vitest: Use its own cache directory - [#&#8203;31439](https://redirect.github.com/storybookjs/storybook/pull/31439), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Addon-a11y: Replace `element` parameter with `context` - [#&#8203;31036](https://redirect.github.com/storybookjs/storybook/pull/31036), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Addon-A11y: Various improvements - [#&#8203;30774](https://redirect.github.com/storybookjs/storybook/pull/30774), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Addon-Essentials: Remove addon-docs - [#&#8203;30856](https://redirect.github.com/storybookjs/storybook/pull/30856), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Addon-Test: Automatically load before all - [#&#8203;30584](https://redirect.github.com/storybookjs/storybook/pull/30584), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Addon-test: Exclude `storybook-static` from coverage reports - [#&#8203;31005](https://redirect.github.com/storybookjs/storybook/pull/31005), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Addon-test: Fix watching non-story files, run all tests on preview change - [#&#8203;31045](https://redirect.github.com/storybookjs/storybook/pull/31045), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Addon-Test: Migrate to new test provider API, drop Vitest 2 support - [#&#8203;30875](https://redirect.github.com/storybookjs/storybook/pull/30875), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Addon-Vitest: Always clean coverage before (re)running - [#&#8203;31540](https://redirect.github.com/storybookjs/storybook/pull/31540), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Addon-vitest: Fix coverage being disabled with Run All button - [#&#8203;31074](https://redirect.github.com/storybookjs/storybook/pull/31074), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Addon-vitest: Fix coverage when restarting Vitest due to config change - [#&#8203;31069](https://redirect.github.com/storybookjs/storybook/pull/31069), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Addon-vitest: Fix wrong test count in telemetry - [#&#8203;31504](https://redirect.github.com/storybookjs/storybook/pull/31504), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Addon-vitest: Remove internal log for `staticDir` - [#&#8203;31340](https://redirect.github.com/storybookjs/storybook/pull/31340), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Addon-vitest: Support paths with spaces - [#&#8203;31437](https://redirect.github.com/storybookjs/storybook/pull/31437), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Addons: Add shim Storybook addons for previously removed addons - [#&#8203;31520](https://redirect.github.com/storybookjs/storybook/pull/31520), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Addons: Move [@&#8203;storybook/addon-interactions](https://redirect.github.com/storybook/addon-interactions) into core - [#&#8203;30916](https://redirect.github.com/storybookjs/storybook/pull/30916), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Addons: Remove [@&#8203;storybook/addon-storysource](https://redirect.github.com/storybook/addon-storysource) - [#&#8203;31007](https://redirect.github.com/storybookjs/storybook/pull/31007), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Addons: Update the Viewport and Background Addon - [#&#8203;30841](https://redirect.github.com/storybookjs/storybook/pull/30841), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   AddonVitest: Use framework package, not renderer - [#&#8203;31133](https://redirect.github.com/storybookjs/storybook/pull/31133), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   All packages: Remove unused dependencies - [#&#8203;31227](https://redirect.github.com/storybookjs/storybook/pull/31227), thanks [@&#8203;webpro](https://redirect.github.com/webpro)!
-   Angular: Add [@&#8203;angular-devkit/build-angular](https://redirect.github.com/angular-devkit/build-angular) to default installed pacakages in angular - [#&#8203;30790](https://redirect.github.com/storybookjs/storybook/pull/30790), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Angular: Filter non-inputs from controls - [#&#8203;30550](https://redirect.github.com/storybookjs/storybook/pull/30550), thanks [@&#8203;robertIsaac](https://redirect.github.com/robertIsaac)!
-   Angular: remove invalid defaults for start-storybook - [#&#8203;31337](https://redirect.github.com/storybookjs/storybook/pull/31337), thanks [@&#8203;AgentEnder](https://redirect.github.com/AgentEnder)!
-   ArgTypes: Always extract argTypes, even without `addon-docs` - [#&#8203;31488](https://redirect.github.com/storybookjs/storybook/pull/31488), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Autoblock: Add autoblocker for addon-test - [#&#8203;31068](https://redirect.github.com/storybookjs/storybook/pull/31068), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Autoblock: Fix link - [#&#8203;31236](https://redirect.github.com/storybookjs/storybook/pull/31236), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   AutoBlocker: Add major version upgrade blocker - [#&#8203;30714](https://redirect.github.com/storybookjs/storybook/pull/30714), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Automigrate: Disable `missingStorybookDependencies` for 9.0 - [#&#8203;30769](https://redirect.github.com/storybookjs/storybook/pull/30769), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Automigrate: Prefer framework import - [#&#8203;30785](https://redirect.github.com/storybookjs/storybook/pull/30785), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Automigration: Add new Storybook addons to consolidated packages mapping - [#&#8203;30993](https://redirect.github.com/storybookjs/storybook/pull/30993), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Adjust addon-docs install condition - [#&#8203;31343](https://redirect.github.com/storybookjs/storybook/pull/31343), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Always scan file system to substitute essential addons - [#&#8203;31176](https://redirect.github.com/storybookjs/storybook/pull/31176), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Correctly apply the wrap-require automigration in ESM modules - [#&#8203;31420](https://redirect.github.com/storybookjs/storybook/pull/31420), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Enhance import transformation to handle partial package matches - [#&#8203;31033](https://redirect.github.com/storybookjs/storybook/pull/31033), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Ensure correct addition of missing dependencies - [#&#8203;31023](https://redirect.github.com/storybookjs/storybook/pull/31023), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Fix an issue when main.js addons have dynamic values - [#&#8203;31273](https://redirect.github.com/storybookjs/storybook/pull/31273), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Fix consolidated-imports with sub-paths - [#&#8203;31135](https://redirect.github.com/storybookjs/storybook/pull/31135), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Automigration: Fix wrap require wrapper - [#&#8203;31569](https://redirect.github.com/storybookjs/storybook/pull/31569), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Improve renderer to framework automigration - [#&#8203;31397](https://redirect.github.com/storybookjs/storybook/pull/31397), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Migrate users to codePanel - [#&#8203;31313](https://redirect.github.com/storybookjs/storybook/pull/31313), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Misc addon-essentials migration fixes - [#&#8203;31072](https://redirect.github.com/storybookjs/storybook/pull/31072), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Pass over flags when calling automigrations - [#&#8203;31342](https://redirect.github.com/storybookjs/storybook/pull/31342), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Remove `@storybook/addon-essentials` proper - [#&#8203;31015](https://redirect.github.com/storybookjs/storybook/pull/31015), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Automigration: Remove `docs.autodocs` field - [#&#8203;31203](https://redirect.github.com/storybookjs/storybook/pull/31203), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Automigration: Respect config-dir option - [#&#8203;31233](https://redirect.github.com/storybookjs/storybook/pull/31233), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigration: Update mapping for '[@&#8203;storybook/experimental-nextjs-vite](https://redirect.github.com/storybook/experimental-nextjs-vite)' - [#&#8203;30991](https://redirect.github.com/storybookjs/storybook/pull/30991), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigrations: Add logging - [#&#8203;31066](https://redirect.github.com/storybookjs/storybook/pull/31066), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigrations: Fix installation of addon-docs - [#&#8203;31399](https://redirect.github.com/storybookjs/storybook/pull/31399), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Automigrations: Re-add renderer-to-framework and fix issue in monorepositories - [#&#8203;31011](https://redirect.github.com/storybookjs/storybook/pull/31011), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Backgrounds/Viewport: Fix resetting - [#&#8203;31386](https://redirect.github.com/storybookjs/storybook/pull/31386), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Blocks: IconGallery improvement - [#&#8203;30743](https://redirect.github.com/storybookjs/storybook/pull/30743), thanks [@&#8203;leeovictor](https://redirect.github.com/leeovictor)!
-   Build: Update import paths and enable syntax minification - [#&#8203;31390](https://redirect.github.com/storybookjs/storybook/pull/31390), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Cleanup: Remove obsolete dependency - [#&#8203;31177](https://redirect.github.com/storybookjs/storybook/pull/31177), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   CLI: Add `storybook-static` to `.gitignore` on init - [#&#8203;31201](https://redirect.github.com/storybookjs/storybook/pull/31201), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   CLI: Add detection for the storybook package being behind any other core packages - [#&#8203;30861](https://redirect.github.com/storybookjs/storybook/pull/30861), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   CLI: Add index command / API - [#&#8203;30071](https://redirect.github.com/storybookjs/storybook/pull/30071), thanks [@&#8203;shilman](https://redirect.github.com/shilman)!
-   CLI: Add React Native `.rnstorybook` CLI automigration - [#&#8203;30882](https://redirect.github.com/storybookjs/storybook/pull/30882), thanks [@&#8203;shilman](https://redirect.github.com/shilman)!
-   CLI: Detect correct storybook version on upgrade - [#&#8203;31393](https://redirect.github.com/storybookjs/storybook/pull/31393), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   CLI: Do not install renderer package on `init` - [#&#8203;30799](https://redirect.github.com/storybookjs/storybook/pull/30799), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   CLI: Enhance compatibility check: deprecated detection - [#&#8203;31317](https://redirect.github.com/storybookjs/storybook/pull/31317), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   CLI: Fix framework for preview imports - [#&#8203;31101](https://redirect.github.com/storybookjs/storybook/pull/31101), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   CLI: Fix get versions utility for NPM - [#&#8203;29577](https://redirect.github.com/storybookjs/storybook/pull/29577), thanks [@&#8203;johnrcui](https://redirect.github.com/johnrcui)!
-   CLI: Improve CLI upgrade process for [@&#8203;latest](https://redirect.github.com/latest) and [@&#8203;next](https://redirect.github.com/next) - [#&#8203;31356](https://redirect.github.com/storybookjs/storybook/pull/31356), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   CLI: Improve package upgrade logic - [#&#8203;31406](https://redirect.github.com/storybookjs/storybook/pull/31406), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   CLI: Install prereleases of `@chromatic-com/storybook` - [#&#8203;30662](https://redirect.github.com/storybookjs/storybook/pull/30662), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   CLI: Make sure that the add commands logs all output to the console - [#&#8203;30865](https://redirect.github.com/storybookjs/storybook/pull/30865), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   CLI: Remove `@latest` from `yarn create` commands - [#&#8203;31458](https://redirect.github.com/storybookjs/storybook/pull/31458), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   CLI: Supress npm notice update log messages - [#&#8203;31334](https://redirect.github.com/storybookjs/storybook/pull/31334), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   CLI: Tweak init prompt - [#&#8203;31376](https://redirect.github.com/storybookjs/storybook/pull/31376), thanks [@&#8203;shilman](https://redirect.github.com/shilman)!
-   CLI: Update nx docs in Storybook detection error - [#&#8203;31266](https://redirect.github.com/storybookjs/storybook/pull/31266), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   CLI: Wrap object addon names in wrap-require migration - [#&#8203;31285](https://redirect.github.com/storybookjs/storybook/pull/31285), thanks [@&#8203;yatishgoel](https://redirect.github.com/yatishgoel)!
-   CodePanel: Show originalSource code - [#&#8203;31456](https://redirect.github.com/storybookjs/storybook/pull/31456), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Controls: Embed addon-controls into the core - [#&#8203;30864](https://redirect.github.com/storybookjs/storybook/pull/30864), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Controls: Remove empty state video link - [#&#8203;31539](https://redirect.github.com/storybookjs/storybook/pull/31539), thanks [@&#8203;kylegach](https://redirect.github.com/kylegach)!
-   Core / Addon A11y: Emit `STORY_HOT_UPDATED` and rerun A11y tests on HMR - [#&#8203;31423](https://redirect.github.com/storybookjs/storybook/pull/31423), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Add error boundary to tabs to prevent addon errors breaking Storybook - [#&#8203;30952](https://redirect.github.com/storybookjs/storybook/pull/30952), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Core: Add highlight as public API - [#&#8203;31134](https://redirect.github.com/storybookjs/storybook/pull/31134), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Core: Add preview navigator and `--preview-only` CLI flag - [#&#8203;31102](https://redirect.github.com/storybookjs/storybook/pull/31102), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Core: Automatically expand testing module on unhandled error - [#&#8203;31028](https://redirect.github.com/storybookjs/storybook/pull/31028), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Avoid pre-bundling of preview-api in manager entries - [#&#8203;31385](https://redirect.github.com/storybookjs/storybook/pull/31385), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Core: Bring back loading globals from global types in portable stories - [#&#8203;31328](https://redirect.github.com/storybookjs/storybook/pull/31328), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Core: Builder-manager disable metafile - [#&#8203;31467](https://redirect.github.com/storybookjs/storybook/pull/31467), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Core: Change require.resolve path for storybook/package.json - [#&#8203;31230](https://redirect.github.com/storybookjs/storybook/pull/31230), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Core: Cleanup dependencies - [#&#8203;31222](https://redirect.github.com/storybookjs/storybook/pull/31222), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Core: Create `features` for addons moved into core - [#&#8203;31146](https://redirect.github.com/storybookjs/storybook/pull/31146), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Core: Do not show 'Render story' step in interactions - [#&#8203;31452](https://redirect.github.com/storybookjs/storybook/pull/31452), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Draw highlights on top of canvas and add various new features - [#&#8203;30894](https://redirect.github.com/storybookjs/storybook/pull/30894), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Fix core annotations applied twice - [#&#8203;31361](https://redirect.github.com/storybookjs/storybook/pull/31361), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Core: Fix favicon issue on dev server - [#&#8203;30818](https://redirect.github.com/storybookjs/storybook/pull/30818), thanks [@&#8203;MuhdHishamP](https://redirect.github.com/MuhdHishamP)!
-   Core: Fix flaky unit tests related to stores - [#&#8203;30963](https://redirect.github.com/storybookjs/storybook/pull/30963), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Core: Fix highlight `clickEvent` serialization and export public types - [#&#8203;31179](https://redirect.github.com/storybookjs/storybook/pull/31179), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Fix highlight conflicts - [#&#8203;31204](https://redirect.github.com/storybookjs/storybook/pull/31204), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Fix highlighting zero-pixel elements and focus on single element - [#&#8203;31183](https://redirect.github.com/storybookjs/storybook/pull/31183), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Fix sidebar accessibility order for screen readers - [#&#8203;31250](https://redirect.github.com/storybookjs/storybook/pull/31250), thanks [@&#8203;yatishgoel](https://redirect.github.com/yatishgoel)!
-   Core: Improve unhandled error detection - [#&#8203;31440](https://redirect.github.com/storybookjs/storybook/pull/31440), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Core: Increase compile targets for node & browsers - [#&#8203;31139](https://redirect.github.com/storybookjs/storybook/pull/31139), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Core: Make sure to only mutate writable arrays - [#&#8203;31578](https://redirect.github.com/storybookjs/storybook/pull/31578), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Core: Move [@&#8203;storybook/addon-actions](https://redirect.github.com/storybook/addon-actions) into storybook - [#&#8203;30765](https://redirect.github.com/storybookjs/storybook/pull/30765), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Core: Move [@&#8203;storybook/instrumenter](https://redirect.github.com/storybook/instrumenter) into core - [#&#8203;30740](https://redirect.github.com/storybookjs/storybook/pull/30740), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Core: New Status Store - [#&#8203;30764](https://redirect.github.com/storybookjs/storybook/pull/30764), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Core: New Test Provider Store - [#&#8203;30828](https://redirect.github.com/storybookjs/storybook/pull/30828), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Core: Prebundle jsdoc-type-pratt-parser again - [#&#8203;30923](https://redirect.github.com/storybookjs/storybook/pull/30923), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Core: Re-Export renderers from frameworks - [#&#8203;30771](https://redirect.github.com/storybookjs/storybook/pull/30771), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Core: Remove `util`, `browser-assert`, `process` deps - [#&#8203;30805](https://redirect.github.com/storybookjs/storybook/pull/30805), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Core: Remove `uuid` package from core - [#&#8203;31219](https://redirect.github.com/storybookjs/storybook/pull/31219), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Core: Remove deprecated parts of test provider API - [#&#8203;30962](https://redirect.github.com/storybookjs/storybook/pull/30962), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Core: Remove duplicate notification dot on sidebar buttons on mobile - [#&#8203;31485](https://redirect.github.com/storybookjs/storybook/pull/31485), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Remove maximum-scale=1 from viewport meta tag - [#&#8203;31283](https://redirect.github.com/storybookjs/storybook/pull/31283), thanks [@&#8203;yatishgoel](https://redirect.github.com/yatishgoel)!
-   Core: Rename local tests to interactions - [#&#8203;31141](https://redirect.github.com/storybookjs/storybook/pull/31141), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Core: Set a minimum height/width for the targetable area of highlights - [#&#8203;31486](https://redirect.github.com/storybookjs/storybook/pull/31486), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Show "Render story" event explicitly in Component Tests event trace - [#&#8203;31027](https://redirect.github.com/storybookjs/storybook/pull/31027), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Support groups and info icon in highlight popover menu - [#&#8203;31475](https://redirect.github.com/storybookjs/storybook/pull/31475), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Support React Native environment without static class blocks - [#&#8203;31282](https://redirect.github.com/storybookjs/storybook/pull/31282), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Core: Testing Module UI improvements - [#&#8203;30773](https://redirect.github.com/storybookjs/storybook/pull/30773), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Core: Wait for animations before completing render cycle - [#&#8203;31287](https://redirect.github.com/storybookjs/storybook/pull/31287), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   CSF-Tools: Add support for existing node imports and improve import handling - [#&#8203;31497](https://redirect.github.com/storybookjs/storybook/pull/31497), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Csf-Tools: Enhance setFieldNode logic to handle variable declarations - [#&#8203;31056](https://redirect.github.com/storybookjs/storybook/pull/31056), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   CSF: Fix handling of renamed story exports - [#&#8203;31519](https://redirect.github.com/storybookjs/storybook/pull/31519), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Dependencies: Update dependencies - [#&#8203;31143](https://redirect.github.com/storybookjs/storybook/pull/31143), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Dependencies: Update docgen - [#&#8203;31465](https://redirect.github.com/storybookjs/storybook/pull/31465), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Dependencies: Upgrade [@&#8203;types/estree](https://redirect.github.com/types/estree) package to version v1.0.6 - [#&#8203;29477](https://redirect.github.com/storybookjs/storybook/pull/29477), thanks [@&#8203;hakshu25](https://redirect.github.com/hakshu25)!
-   Dependencies: Upgrade `telejson` - [#&#8203;30998](https://redirect.github.com/storybookjs/storybook/pull/30998), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Dependencies: Upgrades - [#&#8203;30515](https://redirect.github.com/storybookjs/storybook/pull/30515), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Dependencies: Upgrades for security - [#&#8203;31235](https://redirect.github.com/storybookjs/storybook/pull/31235), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Dependencies: Upgrades for security - [#&#8203;31276](https://redirect.github.com/storybookjs/storybook/pull/31276), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Dependencies: Upgrades for security - [#&#8203;31291](https://redirect.github.com/storybookjs/storybook/pull/31291), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Docs: Consolidate blocks into addon-docs - [#&#8203;31097](https://redirect.github.com/storybookjs/storybook/pull/31097), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Docs: Fix source code panel - [#&#8203;31245](https://redirect.github.com/storybookjs/storybook/pull/31245), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Eslint-plugin: Handle JSON5 format - [#&#8203;31336](https://redirect.github.com/storybookjs/storybook/pull/31336), thanks [@&#8203;yatishgoel](https://redirect.github.com/yatishgoel)!
-   ESLint: Fix flat config setup - [#&#8203;31192](https://redirect.github.com/storybookjs/storybook/pull/31192), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Essentials: Move remaining addons into core - [#&#8203;30924](https://redirect.github.com/storybookjs/storybook/pull/30924), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Highlights: Dont run highlights when the feature is disabled - [#&#8203;31239](https://redirect.github.com/storybookjs/storybook/pull/31239), thanks [@&#8203;dannyhw](https://redirect.github.com/dannyhw)!
-   Hooks: Stabilize experimental afterEach hook - [#&#8203;31438](https://redirect.github.com/storybookjs/storybook/pull/31438), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   HTML Framework: Remove support for HTML Webpack 5 - [#&#8203;30990](https://redirect.github.com/storybookjs/storybook/pull/30990), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Indexer: Do not create autodocs entries unless addon-docs installed - [#&#8203;31331](https://redirect.github.com/storybookjs/storybook/pull/31331), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Init: Install framework stories instead of renderer stories - [#&#8203;31160](https://redirect.github.com/storybookjs/storybook/pull/31160), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Instrumenter: Fix `preview-api` import for react-native - [#&#8203;31057](https://redirect.github.com/storybookjs/storybook/pull/31057), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Interactions: Rename component test panel - [#&#8203;31130](https://redirect.github.com/storybookjs/storybook/pull/31130), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Maintenance: Drop tooling support - [#&#8203;30940](https://redirect.github.com/storybookjs/storybook/pull/30940), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Maintenance: Merge `@storybook/core` with `storybook` - [#&#8203;30168](https://redirect.github.com/storybookjs/storybook/pull/30168), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Maintenance: Migrate eslint-storybook-plugin into the monorepo - [#&#8203;31151](https://redirect.github.com/storybookjs/storybook/pull/31151), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Maintenance: Remove aliasses in builder configurations & scripts - [#&#8203;31344](https://redirect.github.com/storybookjs/storybook/pull/31344), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Maintenance: Remove deprecated APIs - [#&#8203;30926](https://redirect.github.com/storybookjs/storybook/pull/30926), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Maintenance: Remove deprecated packages - [#&#8203;30690](https://redirect.github.com/storybookjs/storybook/pull/30690), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Maintenance: Remove obsolete automigrations - [#&#8203;30945](https://redirect.github.com/storybookjs/storybook/pull/30945), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Maintenance: Specify that Addon Test now requires Vitest 3.0 - [#&#8203;30948](https://redirect.github.com/storybookjs/storybook/pull/30948), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Manager: Add reactivity to useParameter - [#&#8203;31579](https://redirect.github.com/storybookjs/storybook/pull/31579), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Manager: Fix `Uncaught ReferenceError: global is not defined` - [#&#8203;30970](https://redirect.github.com/storybookjs/storybook/pull/30970), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Migration: Add auto-automigration for merged packages - [#&#8203;30753](https://redirect.github.com/storybookjs/storybook/pull/30753), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Migration: Improve glob question text - [#&#8203;31118](https://redirect.github.com/storybookjs/storybook/pull/31118), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Next.js-Vite: Stabilize [@&#8203;storybook/experimental-nextjs-vite](https://redirect.github.com/storybook/experimental-nextjs-vite) - [#&#8203;30956](https://redirect.github.com/storybookjs/storybook/pull/30956), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Next.js: Remove deprecated compatibility files - [#&#8203;31295](https://redirect.github.com/storybookjs/storybook/pull/31295), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Next.js: Upgrade image-size to 2.0 - [#&#8203;30741](https://redirect.github.com/storybookjs/storybook/pull/30741), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Nextjs Vite: Add runtime check for malformed postcss config - [#&#8203;31184](https://redirect.github.com/storybookjs/storybook/pull/31184), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Nextjs-Vite: Update vite-plugin-storybook-nextjs version and add optimizeDeps - [#&#8203;31037](https://redirect.github.com/storybookjs/storybook/pull/31037), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Node.js: Align Node.js version support - [#&#8203;31041](https://redirect.github.com/storybookjs/storybook/pull/31041), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Preact: Remove support for Preact Webpack 5 - [#&#8203;30957](https://redirect.github.com/storybookjs/storybook/pull/30957), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Presets: Use `.js` files when `.cjs` files are passed for entries that should be ESM - [#&#8203;31556](https://redirect.github.com/storybookjs/storybook/pull/31556), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Pseudo States: Ignore escaped pseudo-class names - [#&#8203;31515](https://redirect.github.com/storybookjs/storybook/pull/31515), thanks [@&#8203;sentience](https://redirect.github.com/sentience)!
-   React Native Web: Add RNW to vitest supported frameworks - [#&#8203;31253](https://redirect.github.com/storybookjs/storybook/pull/31253), thanks [@&#8203;dannyhw](https://redirect.github.com/dannyhw)!
-   React Native: Fix support for 9.0 - [#&#8203;31518](https://redirect.github.com/storybookjs/storybook/pull/31518), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   React-Native: Fix `__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__` access - [#&#8203;30820](https://redirect.github.com/storybookjs/storybook/pull/30820), thanks [@&#8203;dannyhw](https://redirect.github.com/dannyhw)!
-   React-Native: Fix `userEvent.setup()` errors in jest - [#&#8203;30833](https://redirect.github.com/storybookjs/storybook/pull/30833), thanks [@&#8203;dannyhw](https://redirect.github.com/dannyhw)!
-   React-Native: Fix `userEvent.setup()` errors outside browser context - [#&#8203;30831](https://redirect.github.com/storybookjs/storybook/pull/30831), thanks [@&#8203;dannyhw](https://redirect.github.com/dannyhw)!
-   React-Native: Update config directory to .rnstorybook - [#&#8203;30819](https://redirect.github.com/storybookjs/storybook/pull/30819), thanks [@&#8203;dannyhw](https://redirect.github.com/dannyhw)!
-   React: Don't use Act wrapper in Storybook when rendering in docs - [#&#8203;31483](https://redirect.github.com/storybookjs/storybook/pull/31483), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   React: Ensure render functions and decorators are react components - [#&#8203;30869](https://redirect.github.com/storybookjs/storybook/pull/30869), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   React: Export returntype of ReactMeta#story - [#&#8203;30580](https://redirect.github.com/storybookjs/storybook/pull/30580), thanks [@&#8203;mrginglymus](https://redirect.github.com/mrginglymus)!
-   React: Remove react import in template files - [#&#8203;30757](https://redirect.github.com/storybookjs/storybook/pull/30757), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Refactor: Update panel IDs in vitest addon to use new constants - [#&#8203;31132](https://redirect.github.com/storybookjs/storybook/pull/31132), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Remove: Addon mdx-gfm (`@storybook/addon-mdx-gfm`) - [#&#8203;30996](https://redirect.github.com/storybookjs/storybook/pull/30996), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Revert "Svelte: Adjust Svelte typings to include Svelte 5 function components" - [#&#8203;30851](https://redirect.github.com/storybookjs/storybook/pull/30851), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Save from Controls: Replace rendererPackage with frameworkPackage - [#&#8203;31114](https://redirect.github.com/storybookjs/storybook/pull/31114), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Source Loader: Remove package - [#&#8203;31466](https://redirect.github.com/storybookjs/storybook/pull/31466), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Source: Support async parameters.docs.source.transform - [#&#8203;30426](https://redirect.github.com/storybookjs/storybook/pull/30426), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Svelte-vite: Improve SvelteKit detection error - [#&#8203;31038](https://redirect.github.com/storybookjs/storybook/pull/31038), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Svelte: Adjust Svelte typings to include Svelte 5 function components - [#&#8203;30812](https://redirect.github.com/storybookjs/storybook/pull/30812), thanks [@&#8203;dummdidumm](https://redirect.github.com/dummdidumm)!
-   Svelte: Drop Support for Svelte < 5 - [#&#8203;30703](https://redirect.github.com/storybookjs/storybook/pull/30703), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Svelte: Fix missing `ts-dedent` dependency - [#&#8203;31289](https://redirect.github.com/storybookjs/storybook/pull/31289), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Svelte: Install `latest` version of `@storybook/addon-svelte-csf` - [#&#8203;31398](https://redirect.github.com/storybookjs/storybook/pull/31398), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Svelte: Pin svelte2tsx to solve argType regression - [#&#8203;30783](https://redirect.github.com/storybookjs/storybook/pull/30783), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Svelte: Remove dependency on `sveltedoc-parser` - [#&#8203;31246](https://redirect.github.com/storybookjs/storybook/pull/31246), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Svelte: Remove unused `svelte-preprocess` dependency - [#&#8203;31332](https://redirect.github.com/storybookjs/storybook/pull/31332), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   SvelteKit: Forward form events when mocking `enhance` - [#&#8203;31360](https://redirect.github.com/storybookjs/storybook/pull/31360), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   Telemetry: Add Svelte CSF usage - [#&#8203;31255](https://redirect.github.com/storybookjs/storybook/pull/31255), thanks [@&#8203;shilman](https://redirect.github.com/shilman)!
-   Telemetry: Use version from our package.json for `storybookVersion` - [#&#8203;31577](https://redirect.github.com/storybookjs/storybook/pull/31577), thanks [@&#8203;tmeasday](https://redirect.github.com/tmeasday)!
-   Test Addon: Stabilize and remove experimental status - [#&#8203;30727](https://redirect.github.com/storybookjs/storybook/pull/30727), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Test: Allow generics in expect matchers - [#&#8203;31395](https://redirect.github.com/storybookjs/storybook/pull/31395), thanks [@&#8203;yannbf](https://redirect.github.com/yannbf)!
-   Test: Handle non-configurable properties in instrumenter for expect.toThrow - [#&#8203;30876](https://redirect.github.com/storybookjs/storybook/pull/30876), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Test: Make sure that expect has no different behavior after instrumentation - [#&#8203;30935](https://redirect.github.com/storybookjs/storybook/pull/30935), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Test: Move `@storybook/test` into `storybook/test` - [#&#8203;30742](https://redirect.github.com/storybookjs/storybook/pull/30742), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Test: Patch HTMLElement.prototype.focus method for settable focus in tests - [#&#8203;31487](https://redirect.github.com/storybookjs/storybook/pull/31487), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Test: Remove legacy Vitest v2 code - [#&#8203;31271](https://redirect.github.com/storybookjs/storybook/pull/31271), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Test: Upgrade to vitest 3 - [#&#8203;30840](https://redirect.github.com/storybookjs/storybook/pull/30840), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Test: Use [@&#8203;testing-library/dom](https://redirect.github.com/testing-library/dom) as devDependency - [#&#8203;31188](https://redirect.github.com/storybookjs/storybook/pull/31188), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Toolbars: Embed addon-toolbars into the core - [#&#8203;30871](https://redirect.github.com/storybookjs/storybook/pull/30871), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Typescript: Drop Typescript < 4.9 support - [#&#8203;30736](https://redirect.github.com/storybookjs/storybook/pull/30736), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   UI: Add options to hide sidebar and toolbar per story - [#&#8203;29516](https://redirect.github.com/storybookjs/storybook/pull/29516), thanks [@&#8203;Sidnioulz](https://redirect.github.com/Sidnioulz)!
-   UI: Clear filters on run all and clear all statuses - [#&#8203;31073](https://redirect.github.com/storybookjs/storybook/pull/31073), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   UI: Don't include error state in sidebar context menu - [#&#8203;31054](https://redirect.github.com/storybookjs/storybook/pull/31054), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   UI: Fix status missing from sidebar - [#&#8203;30830](https://redirect.github.com/storybookjs/storybook/pull/30830), thanks [@&#8203;JReinhold](https://redirect.github.com/JReinhold)!
-   UI: Visual tweaks to badges and improved layout for a11y panel - [#&#8203;30955](https://redirect.github.com/storybookjs/storybook/pull/30955), thanks [@&#8203;ghengeveld](https://redirect.github.com/ghengeveld)!
-   Update react-router-dom to lowest React19 type-compatible version - [#&#8203;31358](https://redirect.github.com/storybookjs/storybook/pull/31358), thanks [@&#8203;mrginglymus](https://redirect.github.com/mrginglymus)!
-   Viewport: Embed addon-viewport in the core - [#&#8203;30909](https://redirect.github.com/storybookjs/storybook/pull/30909), thanks [@&#8203;ndelangen](https://redirect.github.com/ndelangen)!
-   Viewport: Fix globals type - [#&#8203;31374](https://redirect.github.com/storybookjs/storybook/pull/31374), thanks [@&#8203;flaval](https://redirect.github.com/flaval)!
-   Vite-Builder: Handle undefined previewConfig - [#&#8203;31216](https://redirect.github.com/storybookjs/storybook/pull/31216), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Vite: Add 'storybook/viewport' to INCLUDE_CANDIDATES in optimizeDeps.ts - [#&#8203;31039](https://redirect.github.com/storybookjs/storybook/pull/31039), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Vite: Improve handling of preview annotations - [#&#8203;28798](https://redirect.github.com/storybookjs/storybook/pull/28798), thanks [@&#8203;tobiasdiez](https://redirect.github.com/tobiasdiez)!
-   Vite: Normalize preview annotation paths - [#&#8203;31238](https://redirect.github.com/storybookjs/storybook/pull/31238), thanks [@&#8203;mrginglymus](https://redirect.github.com/mrginglymus)!
-   Vite: Support Vite 6 and Docs - [#&#8203;31061](https://redirect.github.com/storybookjs/storybook/pull/31061), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Vitest: Remove beforeAll in vitest.setup.ts in automigration - [#&#8203;31460](https://redirect.github.com/storybookjs/storybook/pull/31460), thanks [@&#8203;kasperpeulen](https://redirect.github.com/kasperpeulen)!
-   Vue3: Remove support for Webpack 5 - [#&#8203;30958](https://redirect.github.com/storybookjs/storybook/pull/30958), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Web Components: Remove Webpack 5 support - [#&#8203;30988](https://redirect.github.com/storybookjs/storybook/pull/30988), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!
-   Yarn: Update Yarn package command execution to use 'exec' - [#&#8203;31065](https://redirect.github.com/storybookjs/storybook/pull/31065), thanks [@&#8203;valentinpalkovic](https://redirect.github.com/valentinpalkovic)!

Total contributions: 240
Unique contributors: 29

</details>

</details>

<details>
<summary>storybookjs/storybook (storybook)</summary>

### [`v9.0.0`](https://redirect.github.com/storybookjs/storybook/compare/v8.6.14...5dd81ae54583e9d445c515fa6640f26de0056592)

[Compare Source](https://redirect.github.com/storybookjs/storybook/compare/v8.6.14...v9.0.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4zMy42IiwidXBkYXRlZEluVmVyIjoiNDAuMzMuNiIsInRhcmdldEJyYW5jaCI6ImNhbmFyeSIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->
2025-05-29 04:05:23 +00:00
akumatus 58bbb017a0 feat(core): add ai playground components (#12588)
Close [AI-86](https://linear.app/affine-design/issue/AI-86)

![截屏2025-05-28 11.56.18.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/sJGviKxfE3Ap685cl5bj/bdf157ce-150c-407c-877f-24a88e7927b1.png)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Introduced an AI Playground accessible from the chat panel, allowing users to experiment with AI chat sessions in a dedicated modal interface.
  - Added a playground icon to the chat panel for quick access to the new playground feature.
  - Added new interactive components for managing AI chat sessions, including chat panels, session lists, and modal dialogs.

- **Improvements**
  - Enhanced chat panel session management for a smoother experience by simplifying session filtering.
  - Updated property names in chat input and composer components for improved clarity and consistency.
  - Made tracking options optional in chat input and composer components to improve flexibility.

- **Bug Fixes**
  - Corrected property bindings in AI chat composer to ensure proper panel sizing.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 02:49:11 +00:00
L-Sun c91a4eb0aa fix(editor): shloud get closest viewport element from editor (#12603)
Close [BS-3338](https://linear.app/affine-design/issue/BS-3338/center-peek-框选会出现奇怪的选区)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Improved the method for locating the viewport element to ensure it is found relative to a scoped host element rather than the entire document. No visible changes to user-facing features.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 02:34:15 +00:00
fundon 5590cdd8f1 fix(editor): improve status display of attachments and images (#12573)
Closes: [BS-3564](https://linear.app/affine-design/issue/BS-3564/ui-embed-view-报错-ui-加-title)
Closes: [BS-3454](https://linear.app/affine-design/issue/BS-3454/点击-reload-后应该隐藏-attachment-embed-view-左下角-status(待新状态))

<img width="807" alt="Screenshot 2025-05-28 at 17 23 26" src="https://github.com/user-attachments/assets/9ecc29f8-73c6-4441-bc38-dfe9bd876542" />

<img width="820" alt="Screenshot 2025-05-28 at 17 45 37" src="https://github.com/user-attachments/assets/68e6db17-a814-4df4-a9fa-067ca03dec30" />

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Added support for retrying failed uploads of attachments and images, allowing users to re-upload files directly from the error status interface.
  - The error status dialog now dynamically displays "Retry" for upload failures and "Reload" for download failures, with appropriate actions for each.
- **Enhancements**
  - Improved clarity and consistency in file type display and icon usage for attachments and citations.
  - Button labels in the attachment interface now have capitalized text for better readability.
- **Bug Fixes**
  - Streamlined error handling and status updates for attachment and image uploads/downloads, reducing redundant UI elements.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 02:18:51 +00:00
fundon de00040389 chore(editor): update loading css vars (#12557)
Related to: [BS-3559](https://linear.app/affine-design/issue/BS-3559/ui-%E5%9B%BE%E7%89%87-loading-%E5%8F%98%E9%87%8F%E6%9B%B4%E6%96%B0)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Style**
  - Improved the appearance of image loading indicators by updating background and ring colors for a more consistent visual experience.

- **New Features**
  - Added customization options for the loading icon's ring color.

- **Chores**
  - Updated the "@toeverything/theme" dependency to version ^1.1.15 across multiple packages for improved consistency and compatibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 02:01:06 +00:00
L-Sun 1b881cfb01 chore(editor): add max height to the dragging preview of toc card (#12605)
Close [BS-3030](https://linear.app/affine-design/issue/BS-3030/侧边栏:toc-目录,这里拖动要限定一个最大高度,建议就-500-px)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Style**
  - Limited the drag preview container's height to 500px and hid overflow content for improved visual consistency during drag operations.

- **Bug Fixes**
  - Enhanced drag preview appearance to prevent content from spilling outside the container.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-29 01:47:31 +00:00
EYHN 6e190b9703 fix(core): migrate collection info before update it (#12617)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Bug Fixes**
  - Improved reliability when updating collection information, ensuring data is correctly migrated and validated before saving changes. This prevents issues with incomplete or invalid collection data.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 14:40:31 +00:00
darkskygit acf92aa3da fix(server): handle edge case of empty docs (#12608)
fix AI-130
2025-05-28 11:25:53 +00:00
zzj3720 9f0d4536c7 feat(editor): add view event tracking (#12602)
close: BS-3567

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Improved the process for adding new views by centralizing related logic, resulting in a more streamlined and consistent user experience.
- **Chores**
  - Enhanced event tracking for database views to support better analytics.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 11:10:33 +00:00
L-Sun 9a651a5b53 fix(editor): tool panel not closed when user close keyboard with default gesture in android (#12613)
Close [BS-3159](https://linear.app/affine-design/issue/BS-3159/输入法自带的键盘收起操作后-占位符还留着)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Bug Fixes**
  - The toolbar now automatically closes when the keyboard is dismissed and no panel is open, ensuring smoother user experience.
  - Improved cleanup to prevent delayed actions after the toolbar is closed, enhancing stability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 10:55:32 +00:00
Flrande d4c5b40284 fix(editor): code block ui issues (#12609)
Close BS-3423
Close BS-3505

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Style**
  - Updated toolbar button background color and adjusted layout spacing for toolbar and preview buttons to improve visual consistency.
- **Refactor**
  - Reorganized toolbar menu groups for better clarity, separating toggle and clipboard actions within the code block toolbar.
- **Bug Fixes**
  - Improved UI interaction in code block tests to ensure menus behave as expected without closing prematurely.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 10:38:23 +00:00
fengmk2 85def83f5e chore(server): set log level to debug on canary (#12612)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Adjusted logging verbosity to be more detailed in the 'canary' environment, providing debug-level logs, while maintaining info-level logs elsewhere.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 10:23:16 +00:00
Flrande f610d7b8af chore(editor): add event track for html preview (#12592)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Enhanced tracking for code block interactions, including language selection and preview toggling.
  - Improved error reporting for HTML block preview failures, providing better visibility into issues.
- **Bug Fixes**
  - Added explicit feedback and tracking when cross-origin isolation is not supported during code block preview setup.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 10:08:19 +00:00
fengmk2 9e5d132bd0 chore(server): log job start and finish (#12610)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Improved visibility of job start and finish events by updating logging level, making these events more prominent in logs.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 09:51:37 +00:00
darkskygit 7ae564238d fix(server): link format in chat (#12606)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Documentation**
  - Clarified citation formatting rules, specifying that multiple citations should not be grouped within a single bracket.
  - Added support and examples for citing web URLs in the allowed citation formats.
  - Improved formatting in the "About AFFiNE" section for better readability.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 09:35:45 +00:00
fengmk2 9abbfa3ab4 chore(server): print jobId (#12593)
Need to query the payload through job id for debugging

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Tests**
  - Updated job metrics test to include an explicit job ID during execution.

- **Refactor**
  - Enhanced job execution to support an optional job ID, improving job tracking and logging.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 08:48:38 +00:00
CatsJuice 793823a9f9 feat(core): track web-clipper import (#12599)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Added tracking for document creation when importing with the clipper tool.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 08:34:22 +00:00
EYHN 2d5b9022fd feat(core): update migration data notification (#12594)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Updated the migration notification with a clearer header and description to better guide users through the data migration process.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 08:19:19 +00:00
EYHN b847de4980 fix(core): remove quota modal (#12586)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Removed Features**
  - Removed all quota-reached modal dialogs, including both cloud and local storage quota notifications.
  - Users will no longer see modal alerts when storage limits are reached in workspaces.
- **User Interface**
  - Quota-reached modals and related styles have been removed from workspace layouts on both desktop and mobile.
- **Other Changes**
  - Quota notification logic and related settings have been eliminated from the application.
  - Maximum blob size enforcement and related callbacks have been removed from blob management.
  - Localization entries related to file upload size limits and quota tips have been removed.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 08:04:22 +00:00
fengmk2 274319dd6c fix(server): 4xx error property is optional (#12595)
close CLOUD-223

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Bug Fixes**
  - Improved error handling for search requests to prevent issues when error details are missing, ensuring clearer fallback messages for unknown errors.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 07:50:05 +00:00
akumatus eb49ffaedb feat(core): support fork session without latestMessageId (#12587)
Close [AI-86](https://linear.app/affine-design/issue/AI-86)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Improved chat session forking to allow creating a fork without specifying the latest message, enabling more flexible session management.

- **Bug Fixes**
  - Forking a chat session with an invalid latest message ID now correctly returns an error.

- **Tests**
  - Added and updated test cases to cover session forking with missing or invalid latest message IDs, ensuring robust behavior in these scenarios.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 07:34:23 +00:00
EYHN a045786c6a fix(core): fix groupBy and orderBy error handling (#12584)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Bug Fixes**
  - Improved error handling for ordering and grouping features to prevent disruptions and ensure the app continues running smoothly if errors occur.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 06:58:26 +00:00
github-actions[bot] ace4b844fd chore(i18n): sync translations (#12549)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-05-28 06:57:47 +00:00
pengx17 d5dd680855 fix(core): update favicon (#12581)
not changing the favicon.ico file to make sure the change will be updated on the user's browser to get rid of caching

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Style**
  - Updated the favicon URL across the application and link previews to include a version query parameter (`?v=2`) for better cache control.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 05:52:16 +00:00
darkskygit f4e7595f4b feat(server): add copilot embedding feature (#12590)
fix AI-154
2025-05-28 04:36:37 +00:00
Saul-Mirone 88339b4022 fix(editor): inline code style (#12585)
Closes: #12576
Closes: [BS-2080](https://linear.app/affine-design/issue/BS-2080/update-inline-code-font-size)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Style**
  - Improved the appearance of code elements within lists by adjusting font size and padding.
  - Updated inline code styling for better vertical alignment and consistency with surrounding text.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 04:11:02 +00:00
doouding d49ecfbecc fix: avoid unnecessary rerendering of selected-rect (#12583)
### Changed

- Note scale issue
- Overlay should call refresh when `clear` is called
- Optimize edgeless-selected-rect to avoid unecessary rerendering

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Edgeless note blocks now respect both minimum and maximum size limits when resizing.

- **Improvements**
  - Enhanced performance and responsiveness of resize and rotate handles in selection overlays by caching allowed handles and optimizing cursor management.
  - Cursor styles for resize and rotate handles are now set more reliably and efficiently through declarative styling.

- **Bug Fixes**
  - Ensured overlay clearing now properly refreshes the renderer for more consistent visual updates.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 03:53:51 +00:00
EYHN 87dfd2b77d fix(core): fix share icon to filter type item (#12582)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Style**
  - Updated the icon for the "shared" property to use a new visual representation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 03:21:32 +00:00
fundon c43e1bcc4e refactor(editor): split openFileOrFiles into openSingleFileWith and openFilesWith (#12523)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
	- Improved file selection dialogs for attachments, imports, and uploads, allowing for more consistent and streamlined file picking across the app.

- **Bug Fixes**
	- Resolved inconsistencies when selecting single or multiple files, ensuring a smoother user experience during file import and upload.

- **Refactor**
	- Unified and simplified file selection logic throughout the app for better reliability and maintainability.
	- Standardized import functions to uniformly handle arrays of files, enhancing consistency in file processing.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 03:06:33 +00:00
doouding cf456c888f feat: support snap when resizing element (#12563)
Fixes [BS-2753](https://linear.app/affine-design/issue/BS-2753/)

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added snapping support when resizing elements, improving alignment and precision during resize operations.
  - Introduced new resize event handlers allowing extensions to customize resize behavior with start, move, and end callbacks.

- **Bug Fixes**
  - Improved handling of snapping state to prevent errors during drag and resize actions.

- **Tests**
  - Updated resizing tests to ensure consistent snapping behavior by removing default elements that could interfere with test results.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 02:47:01 +00:00
Saul-Mirone f5f959692a fix(editor): latex wrong config (#12578)
Closes: BS-2782

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added KaTeX as a dependency to improve LaTeX rendering support.
  - KaTeX styles are now applied globally for consistent math formatting.

- **Refactor**
  - Updated LaTeX rendering to use inline math mode and removed MathML output.

- **Tests**
  - Enhanced inline LaTeX tests with snapshot-based verification for consistent rendering.
  - Added new snapshot files capturing expected LaTeX rendering outputs for various scenarios.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-28 02:23:45 +00:00
darkskygit 9220b973c7 feat(server): increase embedding jobs concurrency & handle empty content after trim (#12574)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Improvements**
  - Increased the default concurrency for background tasks, enhancing processing efficiency.
  - Improved handling of empty or unsupported documents to ensure consistent processing.
  - Optimized document filtering to exclude certain documents from processing, improving performance.

- **Bug Fixes**
  - Enhanced detection of empty document summaries, reducing errors during processing.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 14:28:34 +00:00
Saul-Mirone 7eb6b268a6 fix(editor): auto focus between tab switch (#12572)
Closes: BS-2290

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **Bug Fixes**
  - Improved focus behavior when switching between tabs to prevent unwanted automatic focusing of the content-editable area.
  - Enhanced selection clearing to avoid unnecessary blurring when the main editable element is already focused.
  - Refined focus checks in tests to specifically target contenteditable elements, ensuring more accurate validation of focus behavior.
  - Adjusted test assertions for block selection to be less strict and removed redundant blur operations for smoother test execution.
  - Updated toolbar dropdown closing method to use keyboard interaction for better reliability.
- **New Features**
  - Added a recoverable property to selection types, improving selection state management and recovery.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 13:38:02 +00:00
forehalo dc7cd0487b refactor(server): decrypt license with provided aes key (#12570)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added support for a new AES key for license management, improving license encryption and decryption processes.

- **Bug Fixes**
  - Improved error messages and handling when activating expired or invalid licenses.

- **Refactor**
  - Updated license decryption logic to use a fixed AES key instead of deriving one from the workspace ID.
  - Added validation for environment variable values to prevent invalid configurations.

- **Tests**
  - Enhanced license-related tests to cover new key usage and updated error messages.
  - Updated environment variable validation tests with clearer error messages.

- **Chores**
  - Updated environment variable handling for improved consistency.
  - Set production environment variable explicitly in build configuration.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 11:54:28 +00:00
darkskygit 7175019a0a feat(server): improve pdf parsing (#12356) 2025-05-27 11:36:48 +00:00
darkskygit 3c0fa429c5 feat(server): switch i2i to gpt (#12238)
fix AI-14
fix AI-17
fix AI-39
fix AI-112

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Expanded and reorganized prompt options for text and image actions, adding new prompts for image generation, style conversions, upscaling, background removal, and sticker creation.
  - Enhanced image editing capabilities with direct support for image attachments in prompts.

- **Improvements**
  - Updated prompt names and descriptions to be more user-friendly and descriptive.
  - Simplified and clarified prompt selection and image processing workflows with improved default behaviors.
  - Better organization of prompts through clear grouping and categorization.

- **Bug Fixes**
  - Improved validation and handling of image attachments during editing requests.

- **Refactor**
  - Internal code restructuring of prompts and provider logic for clarity and maintainability without affecting user workflows.
  - Refined message handling and content merging logic to ensure consistent prompt processing.
  - Adjusted image attachment rendering logic for improved display consistency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 11:36:47 +00:00
darkskygit 1e9cbdb65d feat(server): use generative ai api for transcript (#12569)
fix AI-151
2025-05-27 11:36:47 +00:00
CatsJuice 192266c0fd feat(core): move sign in button to workspace list (#12566)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Improved the appearance and layout of the "Sign in" menu item with updated styling and icon.
  - The "Sign in" option now appears as a standalone menu item in the workspace list when the user is not authenticated.

- **Style**
  - Enhanced visual consistency for the "Sign in" menu item to better match the overall theme.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 11:22:17 +00:00
pengx17 4ad008f712 fix(electron): optimize meeting privacy settings (#12530)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Added support for requesting screen recording permission on macOS in addition to microphone permission.
  - Introduced a new "Permission issues" section in meeting privacy settings, including a button to restart the app if permission status is not updated.
- **Improvements**
  - Unified permission handling for screen and microphone settings, simplifying the user experience.
  - Added new localized strings for enhanced clarity regarding permission issues and app restart instructions.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 11:08:06 +00:00
forehalo d6476db64d chore: use PodMonitoring in charts instead (#12571)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Refactor**
  - Updated monitoring configuration to use a different resource type with simplified naming and label selectors for Kubernetes manifests.
- **Chores**
  - Removed Google Cloud Platform–specific monitoring configuration files from multiple components.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 10:53:38 +00:00
donteatfriedrice af3c002022 chore: remove link preview cache feature flag (#12568) 2025-05-27 10:07:33 +00:00
donteatfriedrice 69c7767003 chore: remove citation feature flag (#12567)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Footnote definitions and "Sources" headings are now always included in notes, without requiring a feature flag.
  - Enhanced footnote-related content with additional citation-style blocks such as bookmarks, embedded documents, and attachments.

- **Chores**
  - Removed the citation feature flag and its related configuration, logic, and translations from the application.

- **Documentation**
  - Updated localization files to remove entries related to the citation experimental feature.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 10:07:32 +00:00
renovate 28d8b35600 chore: bump up nestjs to v11.1.2 (#12524)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@nestjs/common](https://nestjs.com) ([source](https://redirect.github.com/nestjs/nest/tree/HEAD/packages/common)) | [`11.1.1` -> `11.1.2`](https://renovatebot.com/diffs/npm/@nestjs%2fcommon/11.1.1/11.1.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@nestjs%2fcommon/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@nestjs%2fcommon/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@nestjs%2fcommon/11.1.1/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@nestjs%2fcommon/11.1.1/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@nestjs/core](https://nestjs.com) ([source](https://redirect.github.com/nestjs/nest/tree/HEAD/packages/core)) | [`11.1.1` -> `11.1.2`](https://renovatebot.com/diffs/npm/@nestjs%2fcore/11.1.1/11.1.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@nestjs%2fcore/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@nestjs%2fcore/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@nestjs%2fcore/11.1.1/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@nestjs%2fcore/11.1.1/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@nestjs/platform-express](https://nestjs.com) ([source](https://redirect.github.com/nestjs/nest/tree/HEAD/packages/platform-express)) | [`11.1.1` -> `11.1.2`](https://renovatebot.com/diffs/npm/@nestjs%2fplatform-express/11.1.1/11.1.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@nestjs%2fplatform-express/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@nestjs%2fplatform-express/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@nestjs%2fplatform-express/11.1.1/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@nestjs%2fplatform-express/11.1.1/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@nestjs/platform-socket.io](https://nestjs.com) ([source](https://redirect.github.com/nestjs/nest/tree/HEAD/packages/platform-socket.io)) | [`11.1.1` -> `11.1.2`](https://renovatebot.com/diffs/npm/@nestjs%2fplatform-socket.io/11.1.1/11.1.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@nestjs%2fplatform-socket.io/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@nestjs%2fplatform-socket.io/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@nestjs%2fplatform-socket.io/11.1.1/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@nestjs%2fplatform-socket.io/11.1.1/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) |
| [@nestjs/websockets](https://redirect.github.com/nestjs/nest) ([source](https://redirect.github.com/nestjs/nest/tree/HEAD/packages/websockets)) | [`11.1.1` -> `11.1.2`](https://renovatebot.com/diffs/npm/@nestjs%2fwebsockets/11.1.1/11.1.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@nestjs%2fwebsockets/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@nestjs%2fwebsockets/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@nestjs%2fwebsockets/11.1.1/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@nestjs%2fwebsockets/11.1.1/11.1.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>nestjs/nest (@&#8203;nestjs/common)</summary>

### [`v11.1.2`](https://redirect.github.com/nestjs/nest/compare/v11.1.1...32b5febcfaf4c8e01bc0d664d875d186a4f76cee)

[Compare Source](https://redirect.github.com/nestjs/nest/compare/v11.1.1...v11.1.2)

</details>

<details>
<summary>nestjs/nest (@&#8203;nestjs/core)</summary>

### [`v11.1.2`](https://redirect.github.com/nestjs/nest/compare/v11.1.1...32b5febcfaf4c8e01bc0d664d875d186a4f76cee)

[Compare Source](https://redirect.github.com/nestjs/nest/compare/v11.1.1...v11.1.2)

</details>

<details>
<summary>nestjs/nest (@&#8203;nestjs/platform-express)</summary>

### [`v11.1.2`](https://redirect.github.com/nestjs/nest/compare/v11.1.1...32b5febcfaf4c8e01bc0d664d875d186a4f76cee)

[Compare Source](https://redirect.github.com/nestjs/nest/compare/v11.1.1...v11.1.2)

</details>

<details>
<summary>nestjs/nest (@&#8203;nestjs/platform-socket.io)</summary>

### [`v11.1.2`](https://redirect.github.com/nestjs/nest/releases/tag/v11.1.2)

[Compare Source](https://redirect.github.com/nestjs/nest/compare/v11.1.1...v11.1.2)

#### v11.1.2 (2025-05-26)

##### Bug fixes

-   `microservices`
    -   [#&#8203;15172](https://redirect.github.com/nestjs/nest/pull/15172) fix(microservices): support custom strategy in async usefactory config ([@&#8203;mag123c](https://redirect.github.com/mag123c))
    -   [#&#8203;15166](https://redirect.github.com/nestjs/nest/pull/15166) fix(microservice): prevent error logs during redis client shutdown ([@&#8203;janroker](https://redirect.github.com/janroker))

##### Dependencies

-   `common`
    -   [#&#8203;15185](https://redirect.github.com/nestjs/nest/pull/15185) chore(deps): bump file-type from 20.5.0 to 21.0.0 ([@&#8203;dependabot\[bot\]](https://redirect.github.com/apps/dependabot))
-   `platform-express`
    -   [#&#8203;15159](https://redirect.github.com/nestjs/nest/pull/15159) chore(deps): bump multer from 1.4.5-lts.2 to 2.0.0 ([@&#8203;dependabot\[bot\]](https://redirect.github.com/apps/dependabot))

##### Committers: 2

-   JaeHo Jang ([@&#8203;mag123c](https://redirect.github.com/mag123c))
-   Jan Roček ([@&#8203;janroker](https://redirect.github.com/janroker))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/). View the [repository job log](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MC4xNi4wIiwidXBkYXRlZEluVmVyIjoiNDAuMTYuMCIsInRhcmdldEJyYW5jaCI6ImNhbmFyeSIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiXX0=-->
2025-05-27 09:53:13 +00:00
zzj3720 0f1a3c212d refactor(editor): add a layer of ui-logic to enhance type safety (#12511)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Introduced modular UI logic layers for Kanban and Table views, enhancing maintainability and scalability.
  - Added new CSS-in-JS style modules for database blocks and table views, improving visual consistency.
  - Expanded telemetry event tracking for database views, properties, filters, and groups.
  - Added utility functions for lazy initialization and cached computed values.

- **Refactor**
  - Unified logic and state management across Kanban and Table views by replacing direct component dependencies with logic-centric architecture.
  - Updated components and widgets to use the new logic-based approach for state, selection, and event handling.
  - Replaced inline styles with CSS classes; updated class names to align with new component structure.
  - Centralized state access through UI logic instances, eliminating direct DOM queries and simplifying dependencies.
  - Consolidated Kanban and Table view presets effects for streamlined initialization.
  - Replaced Lit reactive state with Preact signals in multiple components for improved reactivity.
  - Split monolithic components into separate logic and UI classes for clearer separation of concerns.
  - Removed obsolete components and consolidated exports for cleaner API surface.

- **Bug Fixes**
  - Enhanced selection and interaction reliability in database cells and views.
  - Fixed scrolling issues on mobile table views for improved compatibility.

- **Chores**
  - Updated end-to-end test selectors to reflect new component names and structure.
  - Removed deprecated utilities and cleaned up unused imports.

- **Documentation**
  - Improved type definitions and public API exports for better developer experience.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 09:36:44 +00:00
pengx17 9bf86e3f61 fix(core): add invite members button to sidebar (#12491)
fix AF-2661

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added an "Invite Members" button to the sidebar, allowing users to quickly access workspace member settings (visible only for non-local workspaces).
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 09:20:18 +00:00
yoyoyohamapi c649ae5628 fix(core): ai chat button align (#12555)
> CLOSE AI-134

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Style**
  - Improved alignment and layout of the chat panel send button for a more visually balanced appearance.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 09:04:33 +00:00
EYHN dd1cc28194 fix(core): fix relative date filter (#12561)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Bug Fixes**
  - Corrected date filtering to ensure months are consistently interpreted, improving accuracy when comparing dates.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-27 08:49:43 +00:00
403 changed files with 12719 additions and 4585 deletions
+2 -2
View File
@@ -52,14 +52,14 @@
},
"queues.copilot": {
"type": "object",
"description": "The config for copilot job queue\n@default {\"concurrency\":5}",
"description": "The config for copilot job queue\n@default {\"concurrency\":10}",
"properties": {
"concurrency": {
"type": "number"
}
},
"default": {
"concurrency": 5
"concurrency": 10
}
},
"queues.doc": {
@@ -1,12 +0,0 @@
{{- if eq .Values.global.deployment.platform "gcp" -}}
apiVersion: monitoring.googleapis.com/v1
kind: ClusterPodMonitoring
metadata:
name: "{{ include "graphql.fullname" . }}"
spec:
selector:
{{- include "graphql.selectorLabels" . | nindent 4 }}
endpoints:
- port: 9464
interval: 30s
{{- end }}
@@ -1,12 +0,0 @@
{{- if eq .Values.global.deployment.platform "gcp" -}}
apiVersion: monitoring.googleapis.com/v1
kind: ClusterPodMonitoring
metadata:
name: "{{ include "renderer.fullname" . }}"
spec:
selector:
{{- include "renderer.selectorLabels" . | nindent 4 }}
endpoints:
- port: 9464
interval: 30s
{{- end }}
@@ -1,12 +0,0 @@
{{- if eq .Values.global.deployment.platform "gcp" -}}
apiVersion: monitoring.googleapis.com/v1
kind: ClusterPodMonitoring
metadata:
name: "{{ include "sync.fullname" . }}"
spec:
selector:
{{- include "sync.selectorLabels" . | nindent 4 }}
endpoints:
- port: 9464
interval: 30s
{{- end }}
@@ -1,11 +1,12 @@
{{- if eq .Values.global.deployment.platform "gcp" -}}
apiVersion: monitoring.googleapis.com/v1
kind: ClusterPodMonitoring
kind: PodMonitoring
metadata:
name: "{{ include "doc.fullname" . }}"
name: "{{ .Release.Name }}-monitoring"
spec:
selector:
{{- include "doc.selectorLabels" . | nindent 4 }}
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
endpoints:
- port: 9464
interval: 30s
+1
View File
@@ -138,6 +138,7 @@ jobs:
uses: ./.github/actions/build-rust
env:
AFFINE_PRO_PUBLIC_KEY: ${{ secrets.AFFINE_PRO_PUBLIC_KEY }}
AFFINE_PRO_LICENSE_AES_KEY: ${{ secrets.AFFINE_PRO_LICENSE_AES_KEY }}
with:
target: ${{ matrix.targets.name }}
package: '@affine/server-native'
Generated
+50 -7
View File
@@ -20,8 +20,7 @@ checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]]
name = "adobe-cmap-parser"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae8abfa9a4688de8fc9f42b3f013b6fffec18ed8a554f5f113577e0b9b3212a3"
source = "git+https://github.com/darkskygit/adobe-cmap-parser#610513ae6035c63eab69f33299b86c43693cabb4"
dependencies = [
"pom",
]
@@ -2737,9 +2736,9 @@ dependencies = [
[[package]]
name = "path-ext"
version = "0.1.1"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0de7a86239a8b87b5094977b64893fcf0ed768072744dd4ee0df237686b2d815"
checksum = "7603010004b5cdecf8006605bf7b6f07b0e59d3003010f52b767e91bf2582a45"
dependencies = [
"path-slash",
"walkdir",
@@ -2754,7 +2753,7 @@ checksum = "1e91099d4268b0e11973f036e885d652fb0b21fedcf69738c627f94db6a44f42"
[[package]]
name = "pdf-extract"
version = "0.8.2"
source = "git+https://github.com/toeverything/pdf-extract?branch=darksky%2Fimprove-font-decoding#e74beed894e1b8dc228c2bf078ed92814b27759f"
source = "git+https://github.com/toeverything/pdf-extract?branch=darksky%2Fimprove-font-decoding#040751a61aba51e7a28217b758c18db4415c3ee4"
dependencies = [
"adobe-cmap-parser",
"cff-parser",
@@ -2763,6 +2762,7 @@ dependencies = [
"log",
"lopdf",
"postscript",
"rust-embed",
"type1-encoding-parser",
"unicode-normalization",
]
@@ -2943,9 +2943,12 @@ checksum = "60f6ce597ecdcc9a098e7fddacb1065093a3d66446fa16c675e7e71d1b5c28e6"
[[package]]
name = "postscript"
version = "0.14.1"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78451badbdaebaf17f053fd9152b3ffb33b516104eacb45e7864aaa9c712f306"
checksum = "9a2238e788cf2c9b6edc23b83cf8ccdd4a6380cc9bf0598cc220fac42a55def6"
dependencies = [
"typeface",
]
[[package]]
name = "potential_utf"
@@ -3333,6 +3336,40 @@ dependencies = [
"realfft",
]
[[package]]
name = "rust-embed"
version = "8.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "025908b8682a26ba8d12f6f2d66b987584a4a87bc024abc5bbc12553a8cd178a"
dependencies = [
"rust-embed-impl",
"rust-embed-utils",
"walkdir",
]
[[package]]
name = "rust-embed-impl"
version = "8.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6065f1a4392b71819ec1ea1df1120673418bf386f50de1d6f54204d836d4349c"
dependencies = [
"proc-macro2",
"quote",
"rust-embed-utils",
"syn 2.0.101",
"walkdir",
]
[[package]]
name = "rust-embed-utils"
version = "8.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6cc0c81648b20b70c491ff8cce00c1c3b223bb8ed2b5d41f0e54c6c4c0a3594"
dependencies = [
"sha2",
"walkdir",
]
[[package]]
name = "rustc-demangle"
version = "0.1.24"
@@ -4670,6 +4707,12 @@ dependencies = [
"pom",
]
[[package]]
name = "typeface"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4f6b49e025f4dc953a29b83e4f5a905089117d09fa53491015d7678951b8be1"
[[package]]
name = "typenum"
version = "1.18.0"
+1 -1
View File
@@ -57,7 +57,7 @@ objc2-foundation = "0.3"
once_cell = "1"
ordered-float = "5"
parking_lot = "0.12"
path-ext = "0.1.1"
path-ext = "0.1.2"
pdf-extract = { git = "https://github.com/toeverything/pdf-extract", branch = "darksky/improve-font-decoding" }
phf = { version = "0.11", features = ["macros"] }
proptest = "1.3"
@@ -4393,6 +4393,61 @@ hhh
},
children: [],
},
{
type: 'block',
id: 'matchesReplaceMap[2]',
flavour: 'affine:paragraph',
props: {
type: 'h6',
text: {
'$blocksuite:internal:text$': true,
delta: [
{
insert: 'Sources',
},
],
},
collapsed: true,
},
children: [],
},
{
type: 'block',
id: 'matchesReplaceMap[3]',
flavour: 'affine:bookmark',
props: {
style: 'citation',
url,
title,
description,
icon: favicon,
footnoteIdentifier: '1',
},
children: [],
},
{
type: 'block',
id: 'matchesReplaceMap[4]',
flavour: 'affine:embed-linked-doc',
props: {
style: 'citation',
pageId: 'deadbeef',
footnoteIdentifier: '2',
},
children: [],
},
{
type: 'block',
id: 'matchesReplaceMap[5]',
flavour: 'affine:attachment',
props: {
name: 'test.txt',
sourceId: 'abcdefg',
footnoteIdentifier: '3',
style: 'citation',
},
children: [],
},
],
};
@@ -4469,6 +4524,38 @@ hhh
},
children: [],
},
{
type: 'block',
id: 'matchesReplaceMap[2]',
flavour: 'affine:paragraph',
props: {
type: 'h6',
text: {
'$blocksuite:internal:text$': true,
delta: [
{
insert: 'Sources',
},
],
},
collapsed: true,
},
children: [],
},
{
type: 'block',
id: 'matchesReplaceMap[3]',
flavour: 'affine:bookmark',
props: {
style: 'citation',
url,
title,
description,
icon: favicon,
footnoteIdentifier: '1',
},
children: [],
},
],
};
@@ -23,7 +23,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"file-type": "^21.0.0",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -10,7 +10,6 @@ import {
isFootnoteDefinitionNode,
type MarkdownAST,
} from '@blocksuite/affine-shared/adapters';
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
import { nanoid } from '@blocksuite/store';
const isAttachmentFootnoteDefinitionNode = (node: MarkdownAST) => {
@@ -36,15 +35,7 @@ export const attachmentBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatcher
fromMatch: o => o.node.flavour === AttachmentBlockSchema.model.flavour,
toBlockSnapshot: {
enter: (o, context) => {
const { provider } = context;
let enableCitation = false;
try {
const featureFlagService = provider?.get(FeatureFlagService);
enableCitation = !!featureFlagService?.getFlag('enable_citation');
} catch {
enableCitation = false;
}
if (!isFootnoteDefinitionNode(o.node) || !enableCitation) {
if (!isFootnoteDefinitionNode(o.node)) {
return;
}
@@ -73,6 +64,7 @@ export const attachmentBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatcher
name: fileName,
sourceId: blobId,
footnoteIdentifier,
style: 'citation',
},
children: [],
},
@@ -64,6 +64,11 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
return this.resourceController.blobUrl$.value;
}
get filetype() {
const name = this.model.props.name$.value;
return name.split('.').pop() ?? '';
}
protected containerStyleMap = styleMap({
position: 'relative',
width: '100%',
@@ -212,13 +217,23 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
);
};
protected renderReloadButton = () => {
protected renderNormalButton = (needUpload: boolean) => {
const label = needUpload ? 'retry' : 'reload';
const run = async () => {
if (needUpload) {
await this.resourceController.upload();
return;
}
this.refreshData();
};
return html`
<button
class="affine-attachment-content-button"
@click=${(event: MouseEvent) => {
event.stopPropagation();
this.refreshData();
run().catch(console.error);
{
const mode =
@@ -230,21 +245,28 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
segment,
page: `${segment} editor`,
module: 'attachment',
control: 'reload',
control: label,
category: 'card',
type: this.model.props.name.split('.').pop() ?? '',
type: this.filetype,
});
}
}}
>
${ResetIcon()} Reload
${ResetIcon()} ${label}
</button>
`;
};
protected renderWithHorizontal(
classInfo: ClassInfo,
{ icon, title, description, kind, state }: AttachmentResolvedStateInfo
{
icon,
title,
description,
kind,
state,
needUpload,
}: AttachmentResolvedStateInfo
) {
return html`
<div class=${classMap(classInfo)}>
@@ -261,7 +283,7 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
${description}
</div>
${choose(state, [
['error', this.renderReloadButton],
['error', () => this.renderNormalButton(needUpload)],
['error:oversize', this.renderUpgradeButton],
])}
</div>
@@ -274,7 +296,14 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
protected renderWithVertical(
classInfo: ClassInfo,
{ icon, title, description, kind, state }: AttachmentResolvedStateInfo
{
icon,
title,
description,
kind,
state,
needUpload,
}: AttachmentResolvedStateInfo
) {
return html`
<div class=${classMap(classInfo)}>
@@ -294,7 +323,7 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
<div class="affine-attachment-banner">
${kind}
${choose(state, [
['error', this.renderReloadButton],
['error', () => this.renderNormalButton(needUpload)],
['error:oversize', this.renderUpgradeButton],
])}
</div>
@@ -305,7 +334,7 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
protected resolvedState$ = computed<AttachmentResolvedStateInfo>(() => {
const size = this.model.props.size;
const name = this.model.props.name$.value;
const kind = getAttachmentFileIcon(name.split('.').pop() ?? '');
const kind = getAttachmentFileIcon(this.filetype);
const resolvedState = this.resourceController.resolveStateWith({
loadingIcon: LoadingIcon(),
@@ -359,11 +388,16 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
const message = resolvedState.description;
if (!message) return null;
const needUpload = resolvedState.needUpload;
const action = () =>
needUpload ? this.resourceController.upload() : this.reload();
return html`
<affine-resource-status
class="affine-attachment-embed-status"
.message=${message}
.reload=${() => this.reload()}
.needUpload=${needUpload}
.action=${action}
></affine-resource-status>
`;
})}
@@ -372,10 +406,10 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
private readonly _renderCitation = () => {
const { name, footnoteIdentifier } = this.model.props;
const fileType = name.split('.').pop() ?? '';
const fileTypeIcon = getAttachmentFileIcon(fileType);
const icon = getAttachmentFileIcon(this.filetype);
return html`<affine-citation-card
.icon=${fileTypeIcon}
.icon=${icon}
.citationTitle=${name}
.citationIdentifier=${footnoteIdentifier}
.active=${this.selected$.value}
@@ -1,4 +1,4 @@
import { openFileOrFiles } from '@blocksuite/affine-shared/utils';
import { openSingleFileWith } from '@blocksuite/affine-shared/utils';
import { type SlashMenuConfig } from '@blocksuite/affine-widget-slash-menu';
import { ExportToPdfIcon, FileIcon } from '@blocksuite/icons/lit';
@@ -21,7 +21,7 @@ export const attachmentSlashMenuConfig: SlashMenuConfig = {
model.store.schema.flavourSchemaMap.has('affine:attachment'),
action: ({ std, model }) => {
(async () => {
const file = await openFileOrFiles();
const file = await openSingleFileWith();
if (!file) return;
await addSiblingAttachmentBlocks(std, [file], model);
@@ -44,7 +44,7 @@ export const attachmentSlashMenuConfig: SlashMenuConfig = {
model.store.schema.flavourSchemaMap.has('affine:attachment'),
action: ({ std, model }) => {
(async () => {
const file = await openFileOrFiles();
const file = await openSingleFileWith();
if (!file) return;
await addSiblingAttachmentBlocks(std, [file], model);
@@ -91,6 +91,7 @@ export const styles = css`
font-size: var(--affine-font-xs);
font-style: normal;
font-weight: 500;
text-transform: capitalize;
line-height: 20px;
svg {
@@ -24,7 +24,7 @@
"@blocksuite/store": "workspace:*",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
"rxjs": "^7.8.1",
@@ -10,7 +10,6 @@ import {
isFootnoteDefinitionNode,
type MarkdownAST,
} from '@blocksuite/affine-shared/adapters';
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
import { nanoid } from '@blocksuite/store';
const isUrlFootnoteDefinitionNode = (node: MarkdownAST) => {
@@ -33,15 +32,7 @@ export const bookmarkBlockMarkdownAdapterMatcher =
toMatch: o => isUrlFootnoteDefinitionNode(o.node),
toBlockSnapshot: {
enter: (o, context) => {
const { provider } = context;
let enableCitation = false;
try {
const featureFlagService = provider?.get(FeatureFlagService);
enableCitation = !!featureFlagService?.getFlag('enable_citation');
} catch {
enableCitation = false;
}
if (!isFootnoteDefinitionNode(o.node) || !enableCitation) {
if (!isFootnoteDefinitionNode(o.node)) {
return;
}
@@ -25,7 +25,7 @@
"@floating-ui/dom": "^1.6.10",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/mdast": "^4.0.4",
"emoji-mart": "^5.6.0",
"lit": "^3.2.0",
+1 -1
View File
@@ -27,7 +27,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -35,14 +35,10 @@ export class AffineCodeToolbar extends WithDisposable(LitElement) {
.code-toolbar-button {
color: ${unsafeCSSVarV2('icon/primary')};
background-color: ${unsafeCSSVarV2('segment/background')};
background-color: ${unsafeCSSVarV2('button/secondary')};
box-shadow: var(--affine-shadow-1);
border-radius: 4px;
}
.copy-code {
margin-left: auto;
}
`;
private _currentOpenMenu: AbortController | null = null;
@@ -4,6 +4,10 @@ import {
showPopFilterableList,
} from '@blocksuite/affine-components/filterable-list';
import { ArrowDownIcon } from '@blocksuite/affine-components/icons';
import {
DocModeProvider,
TelemetryProvider,
} from '@blocksuite/affine-shared/services';
import { unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { noop } from '@blocksuite/global/utils';
@@ -73,6 +77,18 @@ export class LanguageListButton extends WithDisposable(
this.blockComponent.store.transact(() => {
this.blockComponent.model.props.language$.value = item.name;
});
const std = this.blockComponent.std;
const mode =
std.getOptional(DocModeProvider)?.getEditorMode() ?? 'page';
const telemetryService = std.getOptional(TelemetryProvider);
if (!telemetryService) return;
telemetryService.track('codeBlockLanguageSelect', {
page: mode,
segment: 'code block',
module: 'language selector',
control: item.name,
});
},
active: item => item.name === this.blockComponent.model.props.language,
items: this._sortedBundledLanguages,
@@ -1,3 +1,7 @@
import {
DocModeProvider,
TelemetryProvider,
} from '@blocksuite/affine-shared/services';
import { unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { css, html, LitElement, nothing } from 'lit';
@@ -9,6 +13,10 @@ import { CodeBlockPreviewIdentifier } from '../../code-preview-extension';
export class PreviewButton extends WithDisposable(SignalWatcher(LitElement)) {
static override styles = css`
:host {
margin-right: auto;
}
.preview-toggle-container {
display: flex;
padding: 2px;
@@ -55,6 +63,17 @@ export class PreviewButton extends WithDisposable(SignalWatcher(LitElement)) {
this.blockComponent.store.updateBlock(this.blockComponent.model, {
preview: value,
});
const std = this.blockComponent.std;
const mode = std.getOptional(DocModeProvider)?.getEditorMode() ?? 'page';
const telemetryService = std.getOptional(TelemetryProvider);
if (!telemetryService) return;
telemetryService.track('htmlBlockTogglePreview', {
page: mode,
segment: 'code block',
module: 'code toolbar container',
control: 'preview toggle button',
});
};
get preview() {
@@ -117,13 +117,12 @@ export const PRIMARY_GROUPS: MenuItemGroup<CodeBlockToolbarContext>[] = [
},
];
// Clipboard Group
export const clipboardGroup: MenuItemGroup<CodeBlockToolbarContext> = {
type: 'clipboard',
export const toggleGroup: MenuItemGroup<CodeBlockToolbarContext> = {
type: 'toggle',
items: [
{
type: 'wrap',
generate: ({ blockComponent, close }) => {
generate: ({ blockComponent }) => {
return {
action: () => {},
render: () => {
@@ -134,7 +133,6 @@ export const clipboardGroup: MenuItemGroup<CodeBlockToolbarContext> = {
<editor-menu-action
@click=${() => {
blockComponent.setWrap(!wrapped);
close();
}}
aria-label=${label}
>
@@ -155,7 +153,7 @@ export const clipboardGroup: MenuItemGroup<CodeBlockToolbarContext> = {
when: ({ std }) =>
std.getOptional(CodeBlockConfigExtension.identifier)?.showLineNumbers ??
true,
generate: ({ blockComponent, close }) => {
generate: ({ blockComponent }) => {
return {
action: () => {},
render: () => {
@@ -167,8 +165,6 @@ export const clipboardGroup: MenuItemGroup<CodeBlockToolbarContext> = {
blockComponent.store.updateBlock(blockComponent.model, {
lineNumber: !lineNumber,
});
close();
}}
aria-label=${label}
>
@@ -184,6 +180,13 @@ export const clipboardGroup: MenuItemGroup<CodeBlockToolbarContext> = {
};
},
},
],
};
// Clipboard Group
export const clipboardGroup: MenuItemGroup<CodeBlockToolbarContext> = {
type: 'clipboard',
items: [
{
type: 'duplicate',
label: 'Duplicate',
@@ -233,6 +236,7 @@ export const deleteGroup: MenuItemGroup<CodeBlockToolbarContext> = {
};
export const MORE_GROUPS: MenuItemGroup<CodeBlockToolbarContext>[] = [
toggleGroup,
clipboardGroup,
deleteGroup,
];
@@ -24,7 +24,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -23,9 +23,9 @@ import {
createRecordDetail,
createUniComponentFromWebComponent,
type DataSource,
DataView,
dataViewCommonStyle,
type DataViewProps,
DataViewRootUILogic,
type DataViewSelection,
type DataViewWidget,
type DataViewWidgetProps,
@@ -133,8 +133,6 @@ export class DataViewBlockComponent extends CaptionedBlockComponent<DataViewBloc
private _dataSource?: DataSource;
private readonly dataView = new DataView();
_bindHotkey: DataViewProps['bindHotkey'] = hotkeys => {
return {
dispose: this.host.event.bindHotkey(hotkeys, {
@@ -232,10 +230,6 @@ export class DataViewBlockComponent extends CaptionedBlockComponent<DataViewBloc
return this.rootComponent;
}
get view() {
return this.dataView.expose;
}
private renderDatabaseOps() {
if (this.store.readonly) {
return nothing;
@@ -250,68 +244,68 @@ export class DataViewBlockComponent extends CaptionedBlockComponent<DataViewBloc
this.setAttribute(RANGE_SYNC_EXCLUDE_ATTR, 'true');
}
private readonly dataViewRootLogic = new DataViewRootUILogic({
virtualPadding$: signal(0),
bindHotkey: this._bindHotkey,
handleEvent: this._handleEvent,
selection$: this.selection$,
setSelection: this.setSelection,
dataSource: this.dataSource,
headerWidget: this.headerWidget,
clipboard: this.std.clipboard,
notification: {
toast: message => {
const notification = this.std.getOptional(NotificationProvider);
if (notification) {
notification.toast(message);
} else {
toast(this.host, message);
}
},
},
eventTrace: (key, params) => {
const telemetryService = this.std.getOptional(TelemetryProvider);
telemetryService?.track(key, {
...(params as TelemetryEventMap[typeof key]),
blockId: this.blockId,
});
},
detailPanelConfig: {
openDetailPanel: (target, data) => {
const peekViewService = this.std.getOptional(PeekViewProvider);
if (peekViewService) {
const template = createRecordDetail({
...data,
openDoc: () => {},
detail: {
header: uniMap(
createUniComponentFromWebComponent(BlockRenderer),
props => ({
...props,
host: this.host,
})
),
note: uniMap(
createUniComponentFromWebComponent(NoteRenderer),
props => ({
...props,
model: this.model,
host: this.host,
})
),
},
});
return peekViewService.peek({ target, template });
} else {
return Promise.resolve();
}
},
},
});
override renderBlock() {
const peekViewService = this.std.getOptional(PeekViewProvider);
const telemetryService = this.std.getOptional(TelemetryProvider);
return html`
<div contenteditable="false" style="position: relative">
${this.dataView.render({
virtualPadding$: signal(0),
bindHotkey: this._bindHotkey,
handleEvent: this._handleEvent,
selection$: this.selection$,
setSelection: this.setSelection,
dataSource: this.dataSource,
headerWidget: this.headerWidget,
clipboard: this.std.clipboard,
notification: {
toast: message => {
const notification = this.std.getOptional(NotificationProvider);
if (notification) {
notification.toast(message);
} else {
toast(this.host, message);
}
},
},
eventTrace: (key, params) => {
telemetryService?.track(key, {
...(params as TelemetryEventMap[typeof key]),
blockId: this.blockId,
});
},
detailPanelConfig: {
openDetailPanel: (target, data) => {
if (peekViewService) {
const template = createRecordDetail({
...data,
openDoc: () => {},
detail: {
header: uniMap(
createUniComponentFromWebComponent(BlockRenderer),
props => ({
...props,
host: this.host,
})
),
note: uniMap(
createUniComponentFromWebComponent(NoteRenderer),
props => ({
...props,
model: this.model,
host: this.host,
})
),
},
});
return peekViewService.peek({ target, template });
} else {
return Promise.resolve();
}
},
},
})}
${this.dataViewRootLogic.render()}
</div>
`;
}
@@ -28,7 +28,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/mdast": "^4.0.4",
"date-fns": "^4.0.0",
"lit": "^3.2.0",
@@ -1,15 +1,19 @@
import { stopPropagation } from '@blocksuite/affine-shared/utils';
import { WithDisposable } from '@blocksuite/global/lit';
import type { DataViewUILogicBase } from '@blocksuite/data-view';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { ShadowlessElement } from '@blocksuite/std';
import type { Text } from '@blocksuite/store';
import { signal } from '@preact/signals-core';
import { css, html } from 'lit';
import { property, query, state } from 'lit/decorators.js';
import { property, query } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { styleMap } from 'lit/directives/style-map.js';
import type { DatabaseBlockComponent } from '../../database-block.js';
export class DatabaseTitle extends WithDisposable(ShadowlessElement) {
export class DatabaseTitle extends SignalWatcher(
WithDisposable(ShadowlessElement)
) {
static override styles = css`
.affine-database-title {
position: relative;
@@ -71,22 +75,23 @@ export class DatabaseTitle extends WithDisposable(ShadowlessElement) {
`;
private readonly compositionEnd = () => {
this.isComposing$.value = false;
this.titleText.replace(0, this.titleText.length, this.input.value);
};
private readonly onBlur = () => {
this.isFocus = false;
this.isFocus$.value = false;
};
private readonly onFocus = () => {
this.isFocus = true;
if (this.database?.viewSelection$?.value) {
this.database?.setSelection(undefined);
this.isFocus$.value = true;
if (this.dataViewLogic.selection$.value) {
this.dataViewLogic.setSelection(undefined);
}
};
private readonly onInput = (e: InputEvent) => {
this.text = this.input.value;
this.text$.value = this.input.value;
if (!e.isComposing) {
this.titleText.replace(0, this.titleText.length, this.input.value);
}
@@ -102,9 +107,9 @@ export class DatabaseTitle extends WithDisposable(ShadowlessElement) {
};
updateText = () => {
if (!this.isFocus) {
if (!this.isFocus$.value) {
this.input.value = this.titleText.toString();
this.text = this.input.value;
this.text$.value = this.input.value;
}
};
@@ -124,25 +129,25 @@ export class DatabaseTitle extends WithDisposable(ShadowlessElement) {
}
override render() {
const isEmpty = !this.text;
const isEmpty = !this.text$.value;
const classList = classMap({
'affine-database-title': true,
ellipsis: !this.isFocus,
ellipsis: !this.isFocus$.value,
});
const untitledStyle = styleMap({
height: isEmpty ? 'auto' : 0,
opacity: isEmpty && !this.isFocus ? 1 : 0,
opacity: isEmpty && !this.isFocus$.value ? 1 : 0,
});
return html` <div
class="${classList}"
data-title-empty="${isEmpty}"
data-title-focus="${this.isFocus}"
data-title-focus="${this.isFocus$.value}"
>
<div class="text" style="${untitledStyle}">Untitled</div>
<div class="text">${this.text}</div>
<div class="text">${this.text$.value}</div>
<textarea
.disabled="${this.readonly}"
.disabled="${this.readonly$.value}"
@input="${this.onInput}"
@keydown="${this.onKeyDown}"
@copy="${stopPropagation}"
@@ -159,23 +164,24 @@ export class DatabaseTitle extends WithDisposable(ShadowlessElement) {
@query('textarea')
private accessor input!: HTMLTextAreaElement;
@state()
accessor isComposing = false;
private readonly isComposing$ = signal(false);
private readonly isFocus$ = signal(false);
@state()
private accessor isFocus = false;
private onPressEnterKey() {
this.dataViewLogic.addRow?.('start');
}
@property({ attribute: false })
accessor onPressEnterKey: (() => void) | undefined = undefined;
get readonly$() {
return this.dataViewLogic.view.readonly$;
}
@property({ attribute: false })
accessor readonly!: boolean;
@state()
private accessor text = '';
private readonly text$ = signal('');
@property({ attribute: false })
accessor titleText!: Text;
@property({ attribute: false })
accessor dataViewLogic!: DataViewUILogicBase;
}
declare global {
@@ -0,0 +1,73 @@
import { css } from '@emotion/css';
import { cssVarV2 } from '@toeverything/theme/v2';
export const databaseBlockStyles = css({
display: 'block',
borderRadius: '8px',
backgroundColor: 'var(--affine-background-primary-color)',
padding: '8px',
margin: '8px -8px -8px',
});
export const databaseBlockSelectedStyles = css({
backgroundColor: 'var(--affine-hover-color)',
borderRadius: '4px',
});
export const databaseOpsStyles = css({
padding: '2px',
borderRadius: '4px',
display: 'flex',
cursor: 'pointer',
alignItems: 'center',
height: 'max-content',
fontSize: '16px',
color: cssVarV2.icon.primary,
':hover': {
backgroundColor: 'var(--affine-hover-color)',
},
'@media print': {
display: 'none',
},
});
export const databaseHeaderBarStyles = css({
'@media print': {
display: 'none !important',
},
});
export const databaseTitleStyles = css({
overflow: 'hidden',
});
export const databaseHeaderContainerStyles = css({
marginBottom: '16px',
display: 'flex',
flexDirection: 'column',
});
export const databaseTitleRowStyles = css({
display: 'flex',
gap: '12px',
marginBottom: '8px',
alignItems: 'center',
});
export const databaseToolbarRowStyles = css({
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
gap: '12px',
});
export const databaseViewBarContainerStyles = css({
flex: 1,
});
export const databaseContentStyles = css({
position: 'relative',
backgroundColor: 'var(--affine-background-primary-color)',
borderRadius: '4px',
});
@@ -19,15 +19,14 @@ import { getDropResult } from '@blocksuite/affine-widget-drag-handle';
import {
createRecordDetail,
createUniComponentFromWebComponent,
DataView,
dataViewCommonStyle,
type DataViewInstance,
type DataViewProps,
DataViewRootUILogic,
type DataViewSelection,
type DataViewUILogicBase,
type DataViewWidget,
type DataViewWidgetProps,
defineUniComponent,
ExternalGroupByConfigProvider,
lazy,
renderUniLit,
type SingleView,
uniMap,
@@ -44,12 +43,23 @@ import { RANGE_SYNC_EXCLUDE_ATTR } from '@blocksuite/std/inline';
import { Slice } from '@blocksuite/store';
import { autoUpdate } from '@floating-ui/dom';
import { computed, signal } from '@preact/signals-core';
import { css, html, nothing, unsafeCSS } from 'lit';
import { html, nothing } from 'lit';
import { popSideDetail } from './components/layout.js';
import { DatabaseConfigExtension } from './config.js';
import { EditorHostKey } from './context/host-context.js';
import { DatabaseBlockDataSource } from './data-source.js';
import {
databaseBlockStyles,
databaseContentStyles,
databaseHeaderBarStyles,
databaseHeaderContainerStyles,
databaseOpsStyles,
databaseTitleRowStyles,
databaseTitleStyles,
databaseToolbarRowStyles,
databaseViewBarContainerStyles,
} from './database-block-styles.js';
import { BlockRenderer } from './detail-panel/block-renderer.js';
import { NoteRenderer } from './detail-panel/note-renderer.js';
import { DatabaseSelection } from './selection.js';
@@ -58,52 +68,7 @@ import { getSingleDocIdFromText } from './utils/title-doc.js';
import type { DatabaseViewExtensionOptions } from './view';
export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBlockModel> {
static override styles = css`
${unsafeCSS(dataViewCommonStyle('affine-database'))}
affine-database {
display: block;
border-radius: 8px;
background-color: var(--affine-background-primary-color);
padding: 8px;
margin: 8px -8px -8px;
}
.database-block-selected {
background-color: var(--affine-hover-color);
border-radius: 4px;
}
.database-ops {
padding: 2px;
border-radius: 4px;
display: flex;
cursor: pointer;
align-items: center;
height: max-content;
}
.database-ops svg {
width: 16px;
height: 16px;
color: var(--affine-icon-color);
}
.database-ops:hover {
background-color: var(--affine-hover-color);
}
@media print {
.database-ops {
display: none;
}
.database-header-bar {
display: none !important;
}
}
`;
private readonly _clickDatabaseOps = (e: MouseEvent) => {
private readonly clickDatabaseOps = (e: MouseEvent) => {
const options = this.optionsConfig.configure(this.model, {
items: [
menu.input({
@@ -155,36 +120,33 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
});
};
private _dataSource?: DatabaseBlockDataSource;
private readonly dataSource = lazy(() => {
const dataSource = new DatabaseBlockDataSource(this.model, dataSource => {
dataSource.serviceSet(EditorHostKey, this.host);
this.std.provider
.getAll(ExternalGroupByConfigProvider)
.forEach(config => {
dataSource.serviceSet(
ExternalGroupByConfigProvider(config.name),
config
);
});
});
const id = currentViewStorage.getCurrentView(this.model.id);
if (id && dataSource.viewManager.viewGet(id)) {
dataSource.viewManager.setCurrentView(id);
}
return dataSource;
});
private readonly dataView = new DataView();
private readonly renderTitle = (dataViewMethod: DataViewInstance) => {
const addRow = () => dataViewMethod.addRow?.('start');
private readonly renderTitle = (dataViewLogic: DataViewUILogicBase) => {
return html` <affine-database-title
style="overflow: hidden"
class="${databaseTitleStyles}"
.titleText="${this.model.props.title}"
.readonly="${this.dataSource.readonly$.value}"
.onPressEnterKey="${addRow}"
.dataViewLogic="${dataViewLogic}"
></affine-database-title>`;
};
_bindHotkey: DataViewProps['bindHotkey'] = hotkeys => {
return {
dispose: this.host.event.bindHotkey(hotkeys, {
blockId: this.topContenteditableElement?.blockId ?? this.blockId,
}),
};
};
_handleEvent: DataViewProps['handleEvent'] = (name, handler) => {
return {
dispose: this.host.event.add(name, handler, {
blockId: this.blockId,
}),
};
};
createTemplate = (
data: {
view: SingleView;
@@ -218,18 +180,12 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
headerWidget: DataViewWidget = defineUniComponent(
(props: DataViewWidgetProps) => {
return html`
<div style="margin-bottom: 16px;display:flex;flex-direction: column">
<div
style="display:flex;gap:12px;margin-bottom: 8px;align-items: center"
>
${this.renderTitle(props.dataViewInstance)}
${this.renderDatabaseOps()}
<div class="${databaseHeaderContainerStyles}">
<div class="${databaseTitleRowStyles}">
${this.renderTitle(props.dataViewLogic)} ${this.renderDatabaseOps()}
</div>
<div
style="display:flex;align-items:center;justify-content: space-between;gap: 12px"
class="database-header-bar"
>
<div style="flex:1">
<div class="${databaseToolbarRowStyles} ${databaseHeaderBarStyles}">
<div class="${databaseViewBarContainerStyles}">
${renderUniLit(widgetPresets.viewBar, {
...props,
onChangeView: id => {
@@ -284,7 +240,9 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
return () => {};
};
setSelection = (selection: DataViewSelection | undefined) => {
private readonly setSelection = (
selection: DataViewSelection | undefined
) => {
if (selection) {
getSelection()?.removeAllRanges();
}
@@ -301,7 +259,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
);
};
toolsWidget: DataViewWidget = widgetPresets.createTools({
private readonly toolsWidget: DataViewWidget = widgetPresets.createTools({
table: [
widgetPresets.tools.filter,
widgetPresets.tools.sort,
@@ -318,7 +276,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
],
});
viewSelection$ = computed(() => {
private readonly viewSelection$ = computed(() => {
const databaseSelection = this.selection.value.find(
(selection): selection is DatabaseSelection => {
if (selection.blockId !== this.blockId) {
@@ -330,28 +288,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
return databaseSelection?.viewSelection;
});
virtualPadding$ = signal(0);
get dataSource(): DatabaseBlockDataSource {
if (!this._dataSource) {
this._dataSource = new DatabaseBlockDataSource(this.model, dataSource => {
dataSource.serviceSet(EditorHostKey, this.host);
this.std.provider
.getAll(ExternalGroupByConfigProvider)
.forEach(config => {
dataSource.serviceSet(
ExternalGroupByConfigProvider(config.name),
config
);
});
});
const id = currentViewStorage.getCurrentView(this.model.id);
if (id && this.dataSource.viewManager.viewGet(id)) {
this.dataSource.viewManager.setCurrentView(id);
}
}
return this._dataSource;
}
private readonly virtualPadding$ = signal(0);
get optionsConfig(): DatabaseViewExtensionOptions {
return {
@@ -369,15 +306,15 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
return this.rootComponent;
}
get view() {
return this.dataView.expose;
}
private renderDatabaseOps() {
if (this.dataSource.readonly$.value) {
if (this.dataSource.value.readonly$.value) {
return nothing;
}
return html` <div class="database-ops" @click="${this._clickDatabaseOps}">
return html` <div
data-testid="database-ops"
class="${databaseOpsStyles}"
@click="${this.clickDatabaseOps}"
>
${MoreHorizontalIcon()}
</div>`;
}
@@ -386,6 +323,7 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
super.connectedCallback();
this.setAttribute(RANGE_SYNC_EXCLUDE_ATTR, 'true');
this.classList.add(databaseBlockStyles);
this.listenFullWidthChange();
}
@@ -402,85 +340,97 @@ export class DatabaseBlockComponent extends CaptionedBlockComponent<DatabaseBloc
})
);
}
override renderBlock() {
const peekViewService = this.std.getOptional(PeekViewProvider);
const telemetryService = this.std.getOptional(TelemetryProvider);
return html`
<div
contenteditable="false"
style="position: relative;background-color: var(--affine-background-primary-color);border-radius: 4px"
>
${this.dataView.render({
virtualPadding$: this.virtualPadding$,
bindHotkey: this._bindHotkey,
handleEvent: this._handleEvent,
selection$: this.viewSelection$,
setSelection: this.setSelection,
dataSource: this.dataSource,
headerWidget: this.headerWidget,
onDrag: this.onDrag,
clipboard: this.std.clipboard,
notification: {
toast: message => {
const notification = this.std.getOptional(NotificationProvider);
if (notification) {
notification.toast(message);
} else {
toast(this.host, message);
}
},
},
eventTrace: (key, params) => {
telemetryService?.track(key, {
...(params as TelemetryEventMap[typeof key]),
private readonly dataViewRootLogic = lazy(
() =>
new DataViewRootUILogic({
virtualPadding$: this.virtualPadding$,
bindHotkey: hotkeys => {
return {
dispose: this.host.event.bindHotkey(hotkeys, {
blockId: this.topContenteditableElement?.blockId ?? this.blockId,
}),
};
},
handleEvent: (name, handler) => {
return {
dispose: this.host.event.add(name, handler, {
blockId: this.blockId,
});
}),
};
},
selection$: this.viewSelection$,
setSelection: this.setSelection,
dataSource: this.dataSource.value,
headerWidget: this.headerWidget,
onDrag: this.onDrag,
clipboard: this.std.clipboard,
notification: {
toast: message => {
const notification = this.std.getOptional(NotificationProvider);
if (notification) {
notification.toast(message);
} else {
toast(this.host, message);
}
},
detailPanelConfig: {
openDetailPanel: (target, data) => {
if (peekViewService) {
const openDoc = (docId: string) => {
return peekViewService.peek({
docId,
databaseId: this.blockId,
databaseDocId: this.model.store.id,
databaseRowId: data.rowId,
target: this,
});
};
const doc = getSingleDocIdFromText(
this.model.store.getBlock(data.rowId)?.model?.text
);
if (doc) {
return openDoc(doc);
}
const abort = new AbortController();
return new Promise<void>(focusBack => {
peekViewService
.peek(
{
target,
template: this.createTemplate(data, docId => {
// abort.abort();
openDoc(docId).then(focusBack).catch(focusBack);
}),
},
{ abortSignal: abort.signal }
)
.then(focusBack)
.catch(focusBack);
},
eventTrace: (key, params) => {
const telemetryService = this.std.getOptional(TelemetryProvider);
telemetryService?.track(key, {
...(params as TelemetryEventMap[typeof key]),
blockId: this.blockId,
});
},
detailPanelConfig: {
openDetailPanel: (target, data) => {
const peekViewService = this.std.getOptional(PeekViewProvider);
if (peekViewService) {
const openDoc = (docId: string) => {
return peekViewService.peek({
docId,
databaseId: this.blockId,
databaseDocId: this.model.store.id,
databaseRowId: data.rowId,
target: this,
});
} else {
return popSideDetail(
this.createTemplate(data, () => {
//
})
);
};
const doc = getSingleDocIdFromText(
this.model.store.getBlock(data.rowId)?.model?.text
);
if (doc) {
return openDoc(doc);
}
},
const abort = new AbortController();
return new Promise<void>(focusBack => {
peekViewService
.peek(
{
target,
template: this.createTemplate(data, docId => {
// abort.abort();
openDoc(docId).then(focusBack).catch(focusBack);
}),
},
{ abortSignal: abort.signal }
)
.then(focusBack)
.catch(focusBack);
});
} else {
return popSideDetail(
this.createTemplate(data, () => {
//
})
);
}
},
})}
},
})
);
override renderBlock() {
return html`
<div contenteditable="false" class="${databaseContentStyles}">
${this.dataViewRootLogic.value.render()}
</div>
`;
}
@@ -20,7 +20,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -26,7 +26,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
"rxjs": "^7.8.1",
@@ -26,7 +26,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/lodash-es": "^4.17.12",
"lit": "^3.2.0",
"lodash-es": "^4.17.21",
@@ -11,7 +11,6 @@ import {
isFootnoteDefinitionNode,
type MarkdownAST,
} from '@blocksuite/affine-shared/adapters';
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
import { nanoid } from '@blocksuite/store';
const isLinkedDocFootnoteDefinitionNode = (node: MarkdownAST) => {
@@ -36,15 +35,7 @@ export const embedLinkedDocBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatc
fromMatch: o => o.node.flavour === EmbedLinkedDocBlockSchema.model.flavour,
toBlockSnapshot: {
enter: (o, context) => {
const { provider } = context;
let enableCitation = false;
try {
const featureFlagService = provider?.get(FeatureFlagService);
enableCitation = !!featureFlagService?.getFlag('enable_citation');
} catch {
enableCitation = false;
}
if (!isFootnoteDefinitionNode(o.node) || !enableCitation) {
if (!isFootnoteDefinitionNode(o.node)) {
return;
}
@@ -13,7 +13,6 @@ import {
ActionPlacement,
DocDisplayMetaProvider,
EditorSettingProvider,
FeatureFlagService,
type LinkEventType,
type OpenDocMode,
type ToolbarAction,
@@ -216,12 +215,7 @@ const conversionsActionGroup = {
run(ctx) {
const block = ctx.getCurrentBlockByType(EmbedLinkedDocBlockComponent);
if (
ctx.std
.get(FeatureFlagService)
.getFlag('enable_embed_doc_with_alias') &&
isGfxBlockComponent(block)
) {
if (isGfxBlockComponent(block)) {
const editorSetting = ctx.std.getOptional(EditorSettingProvider);
editorSetting?.set?.(
'docCanvasPreferView',
@@ -17,7 +17,6 @@ import { REFERENCE_NODE } from '@blocksuite/affine-shared/consts';
import {
ActionPlacement,
EditorSettingProvider,
FeatureFlagService,
type LinkEventType,
type OpenDocMode,
type ToolbarAction,
@@ -163,12 +162,7 @@ const conversionsActionGroup = {
label: 'Card view',
run(ctx) {
const block = ctx.getCurrentBlockByType(EmbedSyncedDocBlockComponent);
if (
ctx.std
.get(FeatureFlagService)
.getFlag('enable_embed_doc_with_alias') &&
isGfxBlockComponent(block)
) {
if (isGfxBlockComponent(block)) {
const editorSetting = ctx.std.getOptional(EditorSettingProvider);
editorSetting?.set?.(
'docCanvasPreferView',
@@ -296,8 +290,6 @@ const builtinSurfaceToolbarConfig = {
label: 'Insert to page',
tooltip: 'Insert to page',
icon: InsertIntoPageIcon(),
when: ({ std }) =>
std.get(FeatureFlagService).getFlag('enable_embed_doc_with_alias'),
run: ctx => {
const model = ctx.getCurrentModelByType(EmbedSyncedDocModel);
if (!model) return;
@@ -334,8 +326,6 @@ const builtinSurfaceToolbarConfig = {
tooltip:
'Duplicate as note to create an editable copy, the original remains unchanged.',
icon: DuplicateIcon(),
when: ({ std }) =>
std.get(FeatureFlagService).getFlag('enable_embed_doc_with_alias'),
run: ctx => {
const { gfx } = ctx;
+1 -1
View File
@@ -26,7 +26,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/lodash-es": "^4.17.12",
"lit": "^3.2.0",
"lodash-es": "^4.17.21",
+1 -1
View File
@@ -25,7 +25,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
+1 -1
View File
@@ -25,7 +25,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"file-type": "^21.0.0",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -51,7 +51,10 @@ export class ImageBlockPageComponent extends SignalWatcher(
height: 36px;
padding: 5px;
border-radius: 8px;
background: ${unsafeCSSVarV2('loading/backgroundLayer')};
background: ${unsafeCSSVarV2(
'loading/imageLoadingBackground',
'#92929238'
)};
& > svg {
font-size: 25.71px;
@@ -356,7 +359,9 @@ export class ImageBlockPageComponent extends SignalWatcher(
? ImageSelectedRect(this._doc.readonly)
: null;
const { loading, error, icon, description } = this.state;
const blobUrl = this.block.blobUrl;
const caption = this.block.model.props.caption$.value ?? 'Image';
const { loading, error, icon, description, needUpload } = this.state;
return html`
<div class="resizable-img" style=${styleMap(imageSize)}>
@@ -364,8 +369,8 @@ export class ImageBlockPageComponent extends SignalWatcher(
class="drag-target"
draggable="false"
loading="lazy"
src=${this.block.blobUrl}
alt=${this.block.model.props.caption$.value ?? 'Image'}
src=${blobUrl}
alt=${caption}
@error=${this._handleError}
/>
@@ -374,12 +379,16 @@ export class ImageBlockPageComponent extends SignalWatcher(
${when(loading, () => html`<div class="loading">${icon}</div>`)}
${when(
error && description,
Boolean(error && description),
() =>
html`<affine-resource-status
class="affine-image-status"
.message=${description}
.reload=${() => this.block.refreshData()}
.needUpload=${needUpload}
.action=${() =>
needUpload
? this.block.resourceController.upload()
: this.block.refreshData()}
></affine-resource-status>`
)}
`;
@@ -135,6 +135,7 @@ export class ImageBlockComponent extends CaptionedBlockComponent<ImageBlockModel
const resovledState = this.resourceController.resolveStateWith({
loadingIcon: LoadingIcon({
strokeColor: cssVarV2('button/pureWhiteText'),
ringColor: cssVarV2('loading/imageLoadingLayer', '#ffffff8f'),
}),
errorIcon: BrokenImageIcon(),
icon: ImageIcon(),
@@ -42,7 +42,10 @@ export class ImageEdgelessBlockComponent extends GfxBlockComponent<ImageBlockMod
height: 36px;
padding: 5px;
border-radius: 8px;
background: ${unsafeCSSVarV2('loading/backgroundLayer')};
background: ${unsafeCSSVarV2(
'loading/imageLoadingBackground',
'#92929238'
)};
& > svg {
font-size: 25.71px;
@@ -126,6 +129,7 @@ export class ImageEdgelessBlockComponent extends GfxBlockComponent<ImageBlockMod
const resovledState = this.resourceController.resolveStateWith({
loadingIcon: LoadingIcon({
strokeColor: cssVarV2('button/pureWhiteText'),
ringColor: cssVarV2('loading/imageLoadingLayer', '#ffffff8f'),
}),
errorIcon: BrokenImageIcon(),
icon: ImageIcon(),
@@ -133,6 +137,8 @@ export class ImageEdgelessBlockComponent extends GfxBlockComponent<ImageBlockMod
description: formatSize(size),
});
const { loading, icon, description, error, needUpload } = resovledState;
return html`
<div class="affine-image-container" style=${containerStyleMap}>
${when(
@@ -148,17 +154,18 @@ export class ImageEdgelessBlockComponent extends GfxBlockComponent<ImageBlockMod
@error=${this._handleError}
/>
</div>
${when(loading, () => html`<div class="loading">${icon}</div>`)}
${when(
resovledState.loading,
() => html`<div class="loading">${resovledState.icon}</div>`
)}
${when(
resovledState.error && resovledState.description,
Boolean(error && description),
() =>
html`<affine-resource-status
class="affine-image-status"
.message=${resovledState.description}
.reload=${() => this.refreshData()}
.message=${description}
.needUpload=${needUpload}
.action=${() =>
needUpload
? this.resourceController.upload()
: this.refreshData()}
></affine-resource-status>`
)}
`,
+1 -1
View File
@@ -25,7 +25,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/katex": "^0.16.7",
"@types/mdast": "^4.0.4",
"katex": "^0.16.11",
@@ -58,7 +58,6 @@ export class LatexBlockComponent extends CaptionedBlockComponent<LatexBlockModel
try {
katex.render(latex, katexContainer, {
displayMode: true,
output: 'mathml',
});
} catch {
katexContainer.replaceChildren();
+1 -1
View File
@@ -24,7 +24,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -40,6 +40,11 @@ export const listBlockStyles = css`
font-size: var(--affine-font-base);
}
affine-list code {
font-size: calc(var(--affine-font-base) - 3px);
padding: 0px 4px 2px;
}
.affine-list-block-container {
box-sizing: border-box;
border-radius: 4px;
+1 -1
View File
@@ -27,7 +27,7 @@
"@blocksuite/store": "workspace:*",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/lodash-es": "^4.17.12",
"@types/mdast": "^4.0.4",
"@vanilla-extract/css": "^1.17.0",
@@ -6,7 +6,6 @@ import {
isFootnoteDefinitionNode,
type MarkdownAST,
} from '@blocksuite/affine-shared/adapters';
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
import type { Root } from 'mdast';
const isRootNode = (node: MarkdownAST): node is Root => node.type === 'root';
@@ -66,34 +65,19 @@ const createNoteBlockMarkdownAdapterMatcher = (
}
});
const { provider } = context;
let enableCitation = false;
try {
const featureFlagService = provider?.get(FeatureFlagService);
enableCitation = !!featureFlagService?.getFlag('enable_citation');
} catch {
enableCitation = false;
}
if (enableCitation) {
// if there are footnoteDefinition nodes, add a heading node to the noteAst before the first footnoteDefinition node
const footnoteDefinitionIndex = noteAst.children.findIndex(child =>
isFootnoteDefinitionNode(child)
);
if (footnoteDefinitionIndex !== -1) {
noteAst.children.splice(footnoteDefinitionIndex, 0, {
type: 'heading',
depth: 6,
data: {
collapsed: true,
},
children: [{ type: 'text', value: 'Sources' }],
});
}
} else {
// Remove the footnoteDefinition node from the noteAst
noteAst.children = noteAst.children.filter(
child => !isFootnoteDefinitionNode(child)
);
// if there are footnoteDefinition nodes, add a heading node to the noteAst before the first footnoteDefinition node
const footnoteDefinitionIndex = noteAst.children.findIndex(child =>
isFootnoteDefinitionNode(child)
);
if (footnoteDefinitionIndex !== -1) {
noteAst.children.splice(footnoteDefinitionIndex, 0, {
type: 'heading',
depth: 6,
data: {
collapsed: true,
},
children: [{ type: 'text', value: 'Sources' }],
});
}
},
},
@@ -400,7 +400,7 @@ export const EdgelessNoteInteraction =
onResizeMove(context): void {
const { originalBound, newBound, lockRatio, constraint } = context;
const { minWidth, minHeight } = constraint;
const { minWidth, minHeight, maxHeight, maxWidth } = constraint;
let scale = initialScale;
let edgelessProp = { ...model.props.edgeless };
@@ -411,8 +411,8 @@ export const EdgelessNoteInteraction =
edgelessProp.scale = scale;
}
newBound.w = clamp(newBound.w, minWidth, Number.MAX_SAFE_INTEGER);
newBound.h = clamp(newBound.h, minHeight, Number.MAX_SAFE_INTEGER);
newBound.w = clamp(newBound.w, minWidth * scale, maxWidth);
newBound.h = clamp(newBound.h, minHeight * scale, maxHeight);
if (newBound.h > minHeight * scale) {
edgelessProp.collapse = true;
@@ -23,7 +23,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
+1 -1
View File
@@ -44,7 +44,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/lodash-es": "^4.17.12",
"dompurify": "^3.2.4",
"html2canvas": "^1.4.1",
@@ -25,7 +25,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/lodash-es": "^4.17.12",
"fractional-indexing": "^3.2.0",
"lit": "^3.2.0",
@@ -20,7 +20,7 @@
"@blocksuite/store": "workspace:*",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/lodash-es": "^4.17.12",
"fractional-indexing": "^3.2.0",
"html2canvas": "^1.4.1",
@@ -43,6 +43,23 @@ type RendererOptions = {
surfaceModel: SurfaceBlockModel;
};
enum UpdateType {
ELEMENT_ADDED = 'element-added',
ELEMENT_REMOVED = 'element-removed',
ELEMENT_UPDATED = 'element-updated',
VIEWPORT_CHANGED = 'viewport-changed',
SIZE_CHANGED = 'size-changed',
ZOOM_STATE_CHANGED = 'zoom-state-changed',
}
interface IncrementalUpdateState {
dirtyElementIds: Set<string>;
viewportDirty: boolean;
sizeDirty: boolean;
usePlaceholderDirty: boolean;
pendingUpdates: Map<string, UpdateType[]>;
}
const PLACEHOLDER_RESET_STYLES = {
border: 'none',
borderRadius: '0',
@@ -141,6 +158,18 @@ export class DomRenderer {
private _sizeUpdatedRafId: number | null = null;
private readonly _updateState: IncrementalUpdateState = {
dirtyElementIds: new Set(),
viewportDirty: false,
sizeDirty: false,
usePlaceholderDirty: false,
pendingUpdates: new Map(),
};
private _lastViewportBounds: Bound | null = null;
private _lastZoom: number | null = null;
private _lastUsePlaceholder: boolean = false;
rootElement: HTMLElement;
private readonly _elementsMap = new Map<string, HTMLElement>();
@@ -186,6 +215,7 @@ export class DomRenderer {
private _initViewport() {
this._disposables.add(
this.viewport.viewportUpdated.subscribe(() => {
this._markViewportDirty();
this.refresh();
})
);
@@ -195,6 +225,7 @@ export class DomRenderer {
if (this._sizeUpdatedRafId) return;
this._sizeUpdatedRafId = requestConnectedFrame(() => {
this._sizeUpdatedRafId = null;
this._markSizeDirty();
this._resetSize();
this._render();
this.refresh();
@@ -208,6 +239,7 @@ export class DomRenderer {
if (this.usePlaceholder !== shouldRenderPlaceholders) {
this.usePlaceholder = shouldRenderPlaceholders;
this._markUsePlaceholderDirty();
this.refresh();
}
})
@@ -307,6 +339,292 @@ export class DomRenderer {
}
private _render() {
this._renderIncremental();
}
private _watchSurface(surfaceModel: SurfaceBlockModel) {
this._disposables.add(
surfaceModel.elementAdded.subscribe(payload => {
this._markElementDirty(payload.id, UpdateType.ELEMENT_ADDED);
this.refresh();
})
);
this._disposables.add(
surfaceModel.elementRemoved.subscribe(payload => {
this._markElementDirty(payload.id, UpdateType.ELEMENT_REMOVED);
this.refresh();
})
);
this._disposables.add(
surfaceModel.localElementAdded.subscribe(payload => {
this._markElementDirty(payload.id, UpdateType.ELEMENT_ADDED);
this.refresh();
})
);
this._disposables.add(
surfaceModel.localElementDeleted.subscribe(payload => {
this._markElementDirty(payload.id, UpdateType.ELEMENT_REMOVED);
this.refresh();
})
);
this._disposables.add(
surfaceModel.localElementUpdated.subscribe(payload => {
this._markElementDirty(payload.model.id, UpdateType.ELEMENT_UPDATED);
this.refresh();
})
);
this._disposables.add(
surfaceModel.elementUpdated.subscribe(payload => {
// ignore externalXYWH update cause it's updated by the renderer
if (payload.props['externalXYWH']) return;
this._markElementDirty(payload.id, UpdateType.ELEMENT_UPDATED);
this.refresh();
})
);
}
addOverlay(overlay: Overlay) {
overlay.setRenderer(null);
this._overlays.add(overlay);
this.refresh();
}
attach(container: HTMLElement) {
this._container = container;
container.append(this.rootElement);
this._resetSize();
this.refresh();
}
dispose(): void {
this._overlays.forEach(overlay => overlay.dispose());
this._overlays.clear();
this._disposables.dispose();
if (this._refreshRafId) {
cancelAnimationFrame(this._refreshRafId);
this._refreshRafId = null;
}
if (this._sizeUpdatedRafId) {
cancelAnimationFrame(this._sizeUpdatedRafId);
this._sizeUpdatedRafId = null;
}
this.rootElement.remove();
this._elementsMap.clear();
}
generateColorProperty(color: Color, fallback?: Color) {
return (
this.provider.generateColorProperty?.(color, fallback) ?? 'transparent'
);
}
getColorScheme() {
return this.provider.getColorScheme?.() ?? ColorScheme.Light;
}
getColorValue(color: Color, fallback?: Color, real?: boolean) {
return (
this.provider.getColorValue?.(color, fallback, real) ?? 'transparent'
);
}
getPropertyValue(property: string) {
return this.provider.getPropertyValue?.(property) ?? '';
}
refresh() {
if (this._refreshRafId !== null) return;
this._refreshRafId = requestConnectedFrame(() => {
this._refreshRafId = null;
this._render();
}, this._container);
}
removeOverlay(overlay: Overlay) {
if (!this._overlays.has(overlay)) {
return;
}
this._overlays.delete(overlay);
this.refresh();
}
/**
* Mark a specific element as dirty for incremental updates
* @param elementId - The ID of the element to mark as dirty
* @param updateType - The type of update (optional, defaults to ELEMENT_UPDATED)
*/
markElementDirty(
elementId: string,
updateType: UpdateType = UpdateType.ELEMENT_UPDATED
) {
this._markElementDirty(elementId, updateType);
}
/**
* Force a full re-render of all elements
*/
forceFullRender() {
this._updateState.viewportDirty = true;
this.refresh();
}
private _markElementDirty(elementId: string, updateType: UpdateType) {
this._updateState.dirtyElementIds.add(elementId);
const currentUpdates =
this._updateState.pendingUpdates.get(elementId) || [];
if (!currentUpdates.includes(updateType)) {
currentUpdates.push(updateType);
this._updateState.pendingUpdates.set(elementId, currentUpdates);
}
}
private _markViewportDirty() {
this._updateState.viewportDirty = true;
}
private _markSizeDirty() {
this._updateState.sizeDirty = true;
}
private _markUsePlaceholderDirty() {
this._updateState.usePlaceholderDirty = true;
}
private _clearUpdateState() {
this._updateState.dirtyElementIds.clear();
this._updateState.viewportDirty = false;
this._updateState.sizeDirty = false;
this._updateState.usePlaceholderDirty = false;
this._updateState.pendingUpdates.clear();
}
private _isViewportChanged(): boolean {
const { viewportBounds, zoom } = this.viewport;
if (!this._lastViewportBounds || !this._lastZoom) {
return true;
}
return (
this._lastViewportBounds.x !== viewportBounds.x ||
this._lastViewportBounds.y !== viewportBounds.y ||
this._lastViewportBounds.w !== viewportBounds.w ||
this._lastViewportBounds.h !== viewportBounds.h ||
this._lastZoom !== zoom
);
}
private _isUsePlaceholderChanged(): boolean {
return this._lastUsePlaceholder !== this.usePlaceholder;
}
private _updateLastState() {
const { viewportBounds, zoom } = this.viewport;
this._lastViewportBounds = {
x: viewportBounds.x,
y: viewportBounds.y,
w: viewportBounds.w,
h: viewportBounds.h,
} as Bound;
this._lastZoom = zoom;
this._lastUsePlaceholder = this.usePlaceholder;
}
private _renderIncremental() {
const { viewportBounds, zoom } = this.viewport;
const addedElements: HTMLElement[] = [];
const elementsToRemove: HTMLElement[] = [];
const needsFullRender =
this._isViewportChanged() ||
this._isUsePlaceholderChanged() ||
this._updateState.sizeDirty ||
this._updateState.viewportDirty ||
this._updateState.usePlaceholderDirty;
if (needsFullRender) {
this._renderFull();
this._updateLastState();
this._clearUpdateState();
return;
}
// Only update dirty elements
const elementsFromGrid = this.grid.search(viewportBounds, {
filter: ['canvas', 'local'],
}) as SurfaceElementModel[];
const visibleElementIds = new Set<string>();
// 1. Update dirty elements
for (const elementModel of elementsFromGrid) {
const display = (elementModel.display ?? true) && !elementModel.hidden;
if (
display &&
intersects(getBoundWithRotation(elementModel), viewportBounds)
) {
visibleElementIds.add(elementModel.id);
// Only update dirty elements
if (this._updateState.dirtyElementIds.has(elementModel.id)) {
if (
this.usePlaceholder &&
!(elementModel as GfxCompatibleInterface).forceFullRender
) {
this._renderOrUpdatePlaceholder(
elementModel,
viewportBounds,
zoom,
addedElements
);
} else {
this._renderOrUpdateFullElement(
elementModel,
viewportBounds,
zoom,
addedElements
);
}
}
}
}
// 2. Remove elements that are no longer in the grid
for (const elementId of this._updateState.dirtyElementIds) {
const updateTypes = this._updateState.pendingUpdates.get(elementId) || [];
if (
updateTypes.includes(UpdateType.ELEMENT_REMOVED) ||
!visibleElementIds.has(elementId)
) {
const domElem = this._elementsMap.get(elementId);
if (domElem) {
domElem.remove();
this._elementsMap.delete(elementId);
elementsToRemove.push(domElem);
}
}
}
// 3. Notify changes
if (addedElements.length > 0 || elementsToRemove.length > 0) {
this.elementsUpdated.next({
elements: Array.from(this._elementsMap.values()),
added: addedElements,
removed: elementsToRemove,
});
}
this._updateLastState();
this._clearUpdateState();
}
private _renderFull() {
const { viewportBounds, zoom } = this.viewport;
const addedElements: HTMLElement[] = [];
const elementsToRemove: HTMLElement[] = [];
@@ -387,100 +705,4 @@ export class DomRenderer {
});
}
}
private _watchSurface(surfaceModel: SurfaceBlockModel) {
this._disposables.add(
surfaceModel.elementAdded.subscribe(() => this.refresh())
);
this._disposables.add(
surfaceModel.elementRemoved.subscribe(() => this.refresh())
);
this._disposables.add(
surfaceModel.localElementAdded.subscribe(() => this.refresh())
);
this._disposables.add(
surfaceModel.localElementDeleted.subscribe(() => this.refresh())
);
this._disposables.add(
surfaceModel.localElementUpdated.subscribe(() => this.refresh())
);
this._disposables.add(
surfaceModel.elementUpdated.subscribe(payload => {
// ignore externalXYWH update cause it's updated by the renderer
if (payload.props['externalXYWH']) return;
this.refresh();
})
);
}
addOverlay(overlay: Overlay) {
overlay.setRenderer(null);
this._overlays.add(overlay);
this.refresh();
}
attach(container: HTMLElement) {
this._container = container;
container.append(this.rootElement);
this._resetSize();
this.refresh();
}
dispose(): void {
this._overlays.forEach(overlay => overlay.dispose());
this._overlays.clear();
this._disposables.dispose();
if (this._refreshRafId) {
cancelAnimationFrame(this._refreshRafId);
this._refreshRafId = null;
}
if (this._sizeUpdatedRafId) {
cancelAnimationFrame(this._sizeUpdatedRafId);
this._sizeUpdatedRafId = null;
}
this.rootElement.remove();
this._elementsMap.clear();
}
generateColorProperty(color: Color, fallback?: Color) {
return (
this.provider.generateColorProperty?.(color, fallback) ?? 'transparent'
);
}
getColorScheme() {
return this.provider.getColorScheme?.() ?? ColorScheme.Light;
}
getColorValue(color: Color, fallback?: Color, real?: boolean) {
return (
this.provider.getColorValue?.(color, fallback, real) ?? 'transparent'
);
}
getPropertyValue(property: string) {
return this.provider.getPropertyValue?.(property) ?? '';
}
refresh() {
if (this._refreshRafId !== null) return;
this._refreshRafId = requestConnectedFrame(() => {
this._refreshRafId = null;
this._render();
}, this._container);
}
removeOverlay(overlay: Overlay) {
if (!this._overlays.has(overlay)) {
return;
}
this._overlays.delete(overlay);
this.refresh();
}
}
@@ -35,7 +35,9 @@ export abstract class Overlay extends Extension {
]);
}
clear() {}
clear() {
this.refresh();
}
dispose() {}
@@ -67,6 +67,8 @@ export class TableSelection extends BaseSelection {
static override type = 'table';
static override recoverable = true;
readonly data: TableSelectionData;
constructor({
+1 -1
View File
@@ -21,7 +21,7 @@
"@lit/context": "^1.1.2",
"@lottiefiles/dotlottie-wc": "^0.5.0",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/hast": "^3.0.4",
"@types/katex": "^0.16.7",
"@types/lodash-es": "^4.17.12",
@@ -4,10 +4,12 @@ import { html } from 'lit';
export const LoadingIcon = ({
size = '1em',
progress = 0.2,
ringColor = cssVarV2('loading/background'),
strokeColor = cssVarV2('loading/foreground'),
}: {
size?: string;
progress?: number;
ringColor?: string;
strokeColor?: string;
} = {}) =>
html`<svg
@@ -28,13 +30,7 @@ export const LoadingIcon = ({
}
}
</style>
<circle
cx="12"
cy="12"
r="8"
stroke="${cssVarV2('loading/background')}"
stroke-width="4"
/>
<circle cx="12" cy="12" r="8" stroke="${ringColor}" stroke-width="4" />
<circle
class="spinner"
cx="12"
@@ -28,6 +28,7 @@ export type ResolvedStateInfoPart = {
error: boolean;
state: StateKind;
url: string | null;
needUpload: boolean;
};
export type ResolvedStateInfo = StateInfo & ResolvedStateInfoPart;
@@ -41,6 +42,7 @@ export class ResourceController implements Disposable {
readonly resolvedState$ = computed<ResolvedStateInfoPart>(() => {
const url = this.blobUrl$.value;
const {
needUpload = false,
uploading = false,
downloading = false,
overSize = false,
@@ -57,7 +59,13 @@ export class ResourceController implements Disposable {
const loading = state === 'uploading' || state === 'loading';
return { error: hasError, loading, state, url };
return {
error: hasError,
needUpload,
loading,
state,
url,
};
});
private engine?: BlobEngine;
@@ -92,7 +100,8 @@ export class ResourceController implements Disposable {
errorIcon?: TemplateResult;
} & StateInfo
): ResolvedStateInfo {
const { error, loading, state, url } = this.resolvedState$.value;
const { error, loading, state, url, needUpload } =
this.resolvedState$.value;
const { icon, title, description, loadingIcon, errorIcon } = info;
@@ -104,11 +113,11 @@ export class ResourceController implements Disposable {
title,
description,
url,
needUpload,
};
if (loading) {
result.icon = loadingIcon ?? icon;
result.title = state === 'uploading' ? 'Uploading...' : 'Loading...';
} else if (error) {
result.icon = errorIcon ?? icon;
result.description = this.state$.value.errorMessage ?? description;
@@ -130,13 +139,15 @@ export class ResourceController implements Disposable {
if (!blobState$) return;
const subscription = blobState$.subscribe(state => {
let { uploading, downloading } = state;
if (state.overSize || state.errorMessage) {
let { uploading, downloading, errorMessage } = state;
if (state.overSize) {
uploading = false;
downloading = false;
} else if ((uploading || downloading) && errorMessage) {
errorMessage = null;
}
this.updateState({ ...state, uploading, downloading });
this.updateState({ ...state, uploading, downloading, errorMessage });
});
return () => subscription.unsubscribe();
@@ -178,6 +189,9 @@ export class ResourceController implements Disposable {
}
async refreshUrlWith(type?: string) {
// Resets the state.
this.state$.value = {};
const url = await this.createUrlWith(type);
if (!url) return;
@@ -191,6 +205,21 @@ export class ResourceController implements Disposable {
URL.revokeObjectURL(prevUrl);
}
// Re-upload to the server.
async upload() {
const blobId = this.blobId$.peek();
if (!blobId) return;
const state = this.state$.peek();
if (!state.needUpload) return;
if (state.uploading) return;
// Resets the state.
this.state$.value = {};
return await this.engine?.upload(blobId);
}
dispose() {
const url = this.blobUrl$.peek();
if (!url) return;
@@ -2,7 +2,7 @@ import {
fontBaseStyle,
panelBaseColorsStyle,
} from '@blocksuite/affine-shared/styles';
import { unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme';
import { unsafeCSSVar, unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme';
import {
createButtonPopper,
stopPropagation,
@@ -15,7 +15,8 @@ import { property, query } from 'lit/decorators.js';
@requiredProperties({
message: PropTypes.string,
reload: PropTypes.instanceOf(Function),
needUpload: PropTypes.boolean,
action: PropTypes.instanceOf(Function),
})
export class ResourceStatus extends WithDisposable(LitElement) {
static override styles = css`
@@ -32,7 +33,7 @@ export class ResourceStatus extends WithDisposable(LitElement) {
cursor: pointer;
color: ${unsafeCSSVarV2('button/pureWhiteText')};
background: ${unsafeCSSVarV2('status/error')};
box-shadow: var(--affine-overlay-shadow);
box-shadow: ${unsafeCSSVar('overlayShadow')};
}
${panelBaseColorsStyle('.popper')}
@@ -43,28 +44,36 @@ export class ResourceStatus extends WithDisposable(LitElement) {
padding: 8px;
border-radius: 8px;
width: 260px;
font-size: var(--affine-font-sm);
font-style: normal;
font-weight: 400;
line-height: 22px;
font-size: ${unsafeCSSVar('fontSm')};
&[data-show] {
display: flex;
flex-direction: column;
gap: 8px;
gap: 4px;
}
}
.header {
font-weight: 500;
}
.content {
font-feature-settings:
'liga' off,
'clig' off;
color: ${unsafeCSSVarV2('text/primary')};
}
.footer {
display: flex;
justify-content: flex-end;
margin-top: 4px;
}
button.reload {
button.action {
display: flex;
align-items: center;
padding: 2px 12px;
@@ -102,23 +111,35 @@ export class ResourceStatus extends WithDisposable(LitElement) {
this._popper?.toggle();
});
this.disposables.addFromEvent(
this._reloadButton,
this._actionButton,
'click',
(_: MouseEvent) => {
this._popper?.hide();
this.reload();
this.action();
}
);
this.disposables.add(() => this._popper?.dispose());
}
override render() {
const { message, needUpload } = this;
const { type, label } = needUpload
? {
type: 'Upload',
label: 'Retry',
}
: {
type: 'Download',
label: 'Reload',
};
return html`
<button class="status">${InformationIcon()}</button>
<div class="popper">
<div class="content">${this.message}</div>
<div class="header">${type} failed</div>
<div class="content">${message}</div>
<div class="footer">
<button class="reload">Reload</button>
<button class="action">${label}</button>
</div>
</div>
`;
@@ -130,12 +151,15 @@ export class ResourceStatus extends WithDisposable(LitElement) {
@query('button.status')
private accessor _trigger!: HTMLButtonElement;
@query('button.reload')
private accessor _reloadButton!: HTMLButtonElement;
@query('button.action')
private accessor _actionButton!: HTMLButtonElement;
@property({ attribute: false })
accessor message!: string;
@property({ attribute: false })
accessor reload!: () => void;
accessor needUpload!: boolean;
@property({ attribute: false })
accessor action!: () => void;
}
+1 -1
View File
@@ -21,7 +21,7 @@
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.14",
"@toeverything/theme": "^1.1.15",
"@types/lodash-es": "^4.17.12",
"clsx": "^2.1.1",
"date-fns": "^4.0.0",
@@ -70,3 +70,19 @@ export const dividerV = css({
backgroundColor: 'var(--affine-divider-color)',
margin: '0 8px',
});
export const dv = {
p2,
p4,
p8,
hover,
icon16,
icon20,
border,
round4,
round8,
color2,
shadow2,
dividerH,
dividerV,
};
+137 -160
View File
@@ -2,42 +2,43 @@ import type {
DatabaseAllEvents,
EventTraceFn,
} from '@blocksuite/affine-shared/services';
import type { DisposableMember } from '@blocksuite/global/disposable';
import { IS_MOBILE } from '@blocksuite/global/env';
import { BlockSuiteError } from '@blocksuite/global/exceptions';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { ShadowlessElement } from '@blocksuite/std';
import {
type Clipboard,
type EventName,
ShadowlessElement,
type UIEventHandler,
} from '@blocksuite/std';
import { computed, type ReadonlySignal, signal } from '@preact/signals-core';
import { css, unsafeCSS } from 'lit';
import { property, state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { keyed } from 'lit/directives/keyed.js';
import { createRef, ref } from 'lit/directives/ref.js';
import { ref } from 'lit/directives/ref.js';
import { html } from 'lit/static-html.js';
import { dataViewCommonStyle } from './common/css-variable.js';
import type { DataViewSelection, DataViewSelectionState } from './types.js';
import type { DataSource } from './data-source/index.js';
import type { DataViewSelection } from './types.js';
import { cacheComputed } from './utils/cache.js';
import { renderUniLit } from './utils/uni-component/index.js';
import type { DataViewInstance, DataViewProps } from './view/types.js';
import type { DataViewUILogicBase } from './view/data-view-base.js';
import type { SingleView } from './view-manager/single-view.js';
import type { DataViewWidget } from './widget/index.js';
type ViewProps = {
view: SingleView;
selection$: ReadonlySignal<DataViewSelectionState>;
setSelection: (selection?: DataViewSelectionState) => void;
bindHotkey: DataViewProps['bindHotkey'];
handleEvent: DataViewProps['handleEvent'];
};
export type DataViewRendererConfig = Pick<
DataViewProps,
| 'bindHotkey'
| 'handleEvent'
| 'virtualPadding$'
| 'clipboard'
| 'dataSource'
| 'headerWidget'
| 'onDrag'
| 'notification'
> & {
export type DataViewRendererConfig = {
clipboard: Clipboard;
onDrag?: (evt: MouseEvent, id: string) => () => void;
notification: {
toast: (message: string) => void;
};
virtualPadding$: ReadonlySignal<number>;
headerWidget: DataViewWidget | undefined;
handleEvent: (name: EventName, handler: UIEventHandler) => DisposableMember;
bindHotkey: (hotkeys: Record<string, UIEventHandler>) => DisposableMember;
dataSource: DataSource;
selection$: ReadonlySignal<DataViewSelection | undefined>;
setSelection: (selection: DataViewSelection | undefined) => void;
eventTrace: EventTraceFn<DatabaseAllEvents>;
@@ -52,7 +53,104 @@ export type DataViewRendererConfig = Pick<
};
};
export class DataViewRenderer extends SignalWatcher(
export class DataViewRootUILogic {
private get dataSource() {
return this.config.dataSource;
}
private get viewManager() {
return this.dataSource.viewManager;
}
private createDataViewUILogic(viewId: string): DataViewUILogicBase {
const view = this.viewManager.viewGet(viewId);
if (!view) {
throw new BlockSuiteError(
BlockSuiteError.ErrorCode.DatabaseBlockError,
`View ${viewId} not found`
);
}
const pcLogic = view.meta.renderer.pcLogic;
const mobileLogic = view.meta.renderer.mobileLogic;
const logic = (IS_MOBILE ? mobileLogic : pcLogic) ?? pcLogic;
return new (logic(view))(this, view);
}
private readonly views$ = cacheComputed(this.viewManager.views$, viewId =>
this.createDataViewUILogic(viewId)
);
private readonly viewsMap$ = computed(() => {
return Object.fromEntries(
this.views$.list.value.map(logic => [logic.view.id, logic])
);
});
private readonly _uiRef = signal<DataViewRootUI>();
get selection$() {
return this.config.selection$;
}
setSelection(selection?: DataViewSelection) {
this.config.setSelection(selection);
}
constructor(public readonly config: DataViewRendererConfig) {}
get dataViewRenderer() {
return this._uiRef.value;
}
readonly currentViewId$ = computed(() => {
return this.dataSource.viewManager.currentViewId$.value;
});
readonly currentView$ = computed(() => {
const currentViewId = this.currentViewId$.value;
if (!currentViewId) {
return;
}
return this.viewsMap$.value[currentViewId];
});
focusFirstCell = () => {
this.currentView$.value?.focusFirstCell();
};
openDetailPanel = (ops: {
view: SingleView;
rowId: string;
onClose?: () => void;
}) => {
const openDetailPanel = this.config.detailPanelConfig.openDetailPanel;
const target = this.dataViewRenderer;
if (openDetailPanel && target) {
openDetailPanel(target, {
view: ops.view,
rowId: ops.rowId,
})
.catch(console.error)
.finally(ops.onClose);
}
};
setupViewChangeListener() {
let preId: string | undefined = undefined;
return this.currentViewId$.subscribe(current => {
if (current !== preId) {
this.config.setSelection(undefined);
}
preId = current;
});
}
render() {
return html` <affine-data-view-renderer
${ref(this._uiRef)}
.logic="${this}"
></affine-data-view-renderer>`;
}
}
export class DataViewRootUI extends SignalWatcher(
WithDisposable(ShadowlessElement)
) {
static override styles = css`
@@ -63,63 +161,14 @@ export class DataViewRenderer extends SignalWatcher(
}
`;
private readonly _view = signal<DataViewInstance>();
@property({ attribute: false })
accessor config!: DataViewRendererConfig;
accessor logic!: DataViewRootUILogic;
private readonly currentViewId$ = computed(() => {
return this.config.dataSource.viewManager.currentViewId$.value;
});
viewMap$ = computed(() => {
const manager = this.config.dataSource.viewManager;
return Object.fromEntries(
manager.views$.value.map(view => [view, manager.viewGet(view)])
);
});
currentViewConfig$ = computed<ViewProps | undefined>(() => {
const currentViewId = this.currentViewId$.value;
if (!currentViewId) {
return;
}
const view = this.viewMap$.value[currentViewId];
if (!view) {
return;
}
return {
view: view,
selection$: computed(() => {
const selection$ = this.config.selection$;
if (selection$.value?.viewId === currentViewId) {
return selection$.value;
}
return;
}),
setSelection: selection => {
this.config.setSelection(selection);
},
handleEvent: (name, handler) =>
this.config.handleEvent(name, context => {
return handler(context);
}),
bindHotkey: hotkeys =>
this.config.bindHotkey(
Object.fromEntries(
Object.entries(hotkeys).map(([key, fn]) => [
key,
ctx => {
return fn(ctx);
},
])
)
),
};
});
@state()
accessor currentView: string | undefined = undefined;
focusFirstCell = () => {
this.view?.focusFirstCell();
this.logic.focusFirstCell();
};
openDetailPanel = (ops: {
@@ -127,72 +176,12 @@ export class DataViewRenderer extends SignalWatcher(
rowId: string;
onClose?: () => void;
}) => {
const openDetailPanel = this.config.detailPanelConfig.openDetailPanel;
if (openDetailPanel) {
openDetailPanel(this, {
view: ops.view,
rowId: ops.rowId,
})
.catch(console.error)
.finally(ops.onClose);
}
this.logic.openDetailPanel(ops);
};
get view() {
return this._view.value;
}
private renderView(viewData?: ViewProps) {
if (!viewData) {
return;
}
const props: DataViewProps = {
dataViewEle: this,
headerWidget: this.config.headerWidget,
onDrag: this.config.onDrag,
dataSource: this.config.dataSource,
virtualPadding$: this.config.virtualPadding$,
clipboard: this.config.clipboard,
notification: this.config.notification,
view: viewData.view,
selection$: viewData.selection$,
setSelection: viewData.setSelection,
bindHotkey: viewData.bindHotkey,
handleEvent: viewData.handleEvent,
eventTrace: (key, params) => {
this.config.eventTrace(key, {
...(params as DatabaseAllEvents[typeof key]),
viewId: viewData.view.id,
viewType: viewData.view.type,
});
},
};
const renderer = viewData.view.meta.renderer;
const view =
(IS_MOBILE ? renderer.mobileView : renderer.view) ?? renderer.view;
return keyed(
viewData.view.id,
renderUniLit(
view,
{ props },
{
ref: this._view,
}
)
);
}
override connectedCallback() {
super.connectedCallback();
let preId: string | undefined = undefined;
this.disposables.add(
this.currentViewId$.subscribe(current => {
if (current !== preId) {
this.config.setSelection(undefined);
}
preId = current;
})
);
this.disposables.add(this.logic.setupViewChangeListener());
}
override render() {
@@ -201,34 +190,22 @@ export class DataViewRenderer extends SignalWatcher(
'data-view-root': true,
'prevent-reference-popup': true,
});
const currentView = this.logic.currentView$.value;
if (!currentView) {
return;
}
return html`
<div style="display: contents" class="${containerClass}">
${this.renderView(this.currentViewConfig$.value)}
${renderUniLit(currentView.renderer, {
logic: currentView,
})}
</div>
`;
}
@state()
accessor currentView: string | undefined = undefined;
}
declare global {
interface HTMLElementTagNameMap {
'affine-data-view-renderer': DataViewRenderer;
}
}
export class DataView {
private readonly _ref = createRef<DataViewRenderer>();
get expose() {
return this._ref.value?.view;
}
render(props: DataViewRendererConfig) {
return html` <affine-data-view-renderer
${ref(this._ref)}
.config="${props}"
></affine-data-view-renderer>`;
'affine-data-view-renderer': DataViewRootUI;
}
}
@@ -2,7 +2,7 @@ import { DataViewPropertiesSettingView } from './common/properties.js';
import { Button } from './component/button/button.js';
import { Overflow } from './component/overflow/overflow.js';
import { MultiTagSelect, MultiTagView } from './component/tags/index.js';
import { DataViewRenderer } from './data-view.js';
import { DataViewRootUI } from './data-view.js';
import { RecordDetail } from './detail/detail.js';
import { RecordField } from './detail/field.js';
import { VariableRefView } from './expression/ref/ref-view.js';
@@ -15,7 +15,7 @@ import { AffineLitIcon, UniAnyRender, UniLit } from './index.js';
import { AnyRender } from './utils/uni-component/render-template.js';
export function coreEffects() {
customElements.define('affine-data-view-renderer', DataViewRenderer);
customElements.define('affine-data-view-renderer', DataViewRootUI);
customElements.define('any-render', AnyRender);
customElements.define(
'data-view-properties-setting',
@@ -1,7 +1,7 @@
export * from './common/index.js';
export * from './component/index.js';
export { DataSourceBase } from './data-source/base.js';
export { DataView } from './data-view.js';
export { DataViewRootUILogic } from './data-view.js';
export * from './filter/index.js';
export * from './group-by';
export * from './logical/index.js';
@@ -183,7 +183,6 @@ export class TypeSystem {
// eslint-disable-next-line sonarjs/no-collapsible-if
if (realArg != null) {
if (!this._unify(newCtx, realArg, arg)) {
console.log('arg', realArg, arg);
return;
}
}
@@ -0,0 +1,32 @@
import { computed, type ReadonlySignal } from '@preact/signals-core';
export const cacheComputed = <T>(
ids: ReadonlySignal<string[]>,
create: (id: string) => T
) => {
const cache = new Map<string, T>();
const getOrCreate = (id: string): T => {
if (cache.has(id)) {
return cache.get(id)!;
}
const value = create(id);
if (value) {
cache.set(id, value);
}
return value;
};
return {
getOrCreate,
list: computed<T[]>(() => {
const list = ids.value;
const keys = new Set(cache.keys());
for (const [cachedId] of cache) {
keys.delete(cachedId);
}
for (const id of keys) {
cache.delete(id);
}
return list.map(id => getOrCreate(id));
}),
};
};
@@ -1,2 +1,3 @@
export * from './lazy.js';
export * from './uni-component/index.js';
export * from './uni-icon.js';
@@ -0,0 +1,11 @@
export const lazy = <T>(fn: () => T): { value: T } => {
let data: { value: T } | undefined;
return {
get value() {
if (!data) {
data = { value: fn() };
}
return data.value;
},
};
};
@@ -1,17 +1,106 @@
import type {
DatabaseAllEvents,
DatabaseAllViewEvents,
EventTraceFn,
} from '@blocksuite/affine-shared/services';
import type { UniComponent } from '@blocksuite/affine-shared/types';
import type { InsertToPosition } from '@blocksuite/affine-shared/utils';
import type { DisposableMember } from '@blocksuite/global/disposable';
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { ShadowlessElement } from '@blocksuite/std';
import {
type EventName,
ShadowlessElement,
type UIEventHandler,
} from '@blocksuite/std';
import { computed } from '@preact/signals-core';
import { property } from 'lit/decorators.js';
import type { DataViewRootUILogic } from '../data-view.js';
import type { DataViewSelection } from '../types.js';
import type { SingleView } from '../view-manager/single-view.js';
import type { DataViewWidget } from '../widget/index.js';
import type { DataViewInstance, DataViewProps } from './types.js';
export abstract class DataViewBase<
T extends SingleView = SingleView,
Selection extends DataViewSelection = DataViewSelection,
> extends SignalWatcher(WithDisposable(ShadowlessElement)) {
abstract expose: DataViewInstance;
@property({ attribute: false })
accessor props!: DataViewProps<T, Selection>;
accessor props!: DataViewProps<Selection>;
}
export abstract class DataViewUIBase<
Logic extends DataViewUILogicBase = DataViewUILogicBase,
> extends SignalWatcher(WithDisposable(ShadowlessElement)) {
@property({ attribute: false })
accessor logic!: Logic;
}
export abstract class DataViewUILogicBase<
T extends SingleView = SingleView,
Selection extends DataViewSelection = DataViewSelection,
> {
constructor(
public readonly root: DataViewRootUILogic,
public readonly view: T
) {}
get headerWidget(): DataViewWidget | undefined {
return this.root.config.headerWidget;
}
bindHotkey(hotkeys: Record<string, UIEventHandler>): DisposableMember {
return this.root.config.bindHotkey(
Object.fromEntries(
Object.entries(hotkeys).map(([key, fn]) => [
key,
ctx => {
return fn(ctx);
},
])
)
);
}
handleEvent(name: EventName, handler: UIEventHandler): DisposableMember {
return this.root.config.handleEvent(name, context => {
return handler(context);
});
}
setSelection(selection?: Selection): void {
this.root.setSelection(selection);
}
selection$ = computed<Selection | undefined>(() => {
const selection$ = this.root.selection$;
if (selection$.value?.viewId === this.view.id) {
return selection$.value as Selection | undefined;
}
return;
});
eventTrace: EventTraceFn<DatabaseAllViewEvents> = (key, params) => {
this.root.config.eventTrace(key, {
...(params as DatabaseAllEvents[typeof key]),
viewId: this.view.id,
viewType: this.view.type,
});
};
abstract clearSelection: () => void;
abstract addRow: (position: InsertToPosition) => string | undefined;
abstract focusFirstCell: () => void;
abstract showIndicator: (evt: MouseEvent) => boolean;
abstract hideIndicator: () => void;
abstract moveTo: (id: string, evt: MouseEvent) => void;
abstract renderer: UniComponent<{
logic: DataViewUILogicBase<T, Selection>;
}>;
}
type Constructor<T extends abstract new (...args: any) => any> = new (
...args: ConstructorParameters<T>
) => InstanceType<T>;
export type DataViewUILogicBaseConstructor = Constructor<
typeof DataViewUILogicBase
>;
@@ -2,6 +2,7 @@ import type { UniComponent } from '@blocksuite/affine-shared/types';
import type { SingleView } from '../view-manager/single-view.js';
import type { ViewManager } from '../view-manager/view-manager.js';
import type { DataViewUILogicBaseConstructor } from './data-view-base.js';
import type { DataViewInstance, DataViewProps } from './types.js';
export type BasicViewDataType<
@@ -48,9 +49,10 @@ type DataViewComponent = UniComponent<
>;
export interface DataViewRendererConfig {
view: DataViewComponent;
mobileView?: DataViewComponent;
icon: UniComponent;
pcLogic: (view: SingleView) => DataViewUILogicBaseConstructor;
mobileLogic?: (view: SingleView) => DataViewUILogicBaseConstructor;
}
export type ViewMeta<
@@ -1,3 +1,4 @@
export * from './convert.js';
export * from './data-view.js';
export * from './data-view-base.js';
export * from './types.js';
@@ -4,44 +4,21 @@ import type {
} from '@blocksuite/affine-shared/services';
import type { InsertToPosition } from '@blocksuite/affine-shared/utils';
import type { Disposable } from '@blocksuite/global/disposable';
import type { Clipboard, EventName, UIEventHandler } from '@blocksuite/std';
import type { EventName, UIEventHandler } from '@blocksuite/std';
import type { ReadonlySignal } from '@preact/signals-core';
import type { DataSource } from '../common/index.js';
import type { DataViewRenderer } from '../data-view.js';
import type { DataViewSelection } from '../types.js';
import type { SingleView } from '../view-manager/index.js';
import type { DataViewWidget } from '../widget/index.js';
export interface DataViewProps<
T extends SingleView = SingleView,
Selection extends DataViewSelection = DataViewSelection,
> {
dataViewEle: DataViewRenderer;
headerWidget?: DataViewWidget;
view: T;
dataSource: DataSource;
bindHotkey: (hotkeys: Record<string, UIEventHandler>) => Disposable;
handleEvent: (name: EventName, handler: UIEventHandler) => Disposable;
setSelection: (selection?: Selection) => void;
selection$: ReadonlySignal<Selection | undefined>;
virtualPadding$: ReadonlySignal<number>;
onDrag?: (evt: MouseEvent, id: string) => () => void;
clipboard: Clipboard;
notification: {
toast: (message: string) => void;
};
eventTrace: EventTraceFn<DatabaseAllViewEvents>;
}
@@ -1,8 +1,10 @@
import type { UniComponent } from '@blocksuite/affine-shared/types';
import type { DataViewInstance } from '../view/types.js';
import type { DataViewUILogicBase } from '../view/data-view-base.js';
export type DataViewWidgetProps = {
dataViewInstance: DataViewInstance;
export type DataViewWidgetProps<
ViewLogic extends DataViewUILogicBase = DataViewUILogicBase,
> = {
dataViewLogic: ViewLogic;
};
export type DataViewWidget = UniComponent<DataViewWidgetProps>;
@@ -2,30 +2,27 @@ import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { ShadowlessElement } from '@blocksuite/std';
import { property } from 'lit/decorators.js';
import type { DataViewInstance } from '../view/types.js';
import type { SingleView } from '../view-manager/index.js';
import type { DataViewUILogicBase } from '../view/data-view-base.js';
import type { DataViewWidgetProps } from './types.js';
export class WidgetBase<View extends SingleView = SingleView>
export class WidgetBase<
ViewLogic extends DataViewUILogicBase = DataViewUILogicBase,
>
extends SignalWatcher(WithDisposable(ShadowlessElement))
implements DataViewWidgetProps
implements DataViewWidgetProps<ViewLogic>
{
get dataSource() {
return this.view.manager.dataSource;
return this.viewManager.dataSource;
}
get view() {
return this.dataViewInstance.view;
return this.dataViewLogic.view;
}
get viewManager() {
return this.view.manager;
}
get viewMethods() {
return this.dataViewInstance;
}
@property({ attribute: false })
accessor dataViewInstance!: DataViewInstance<View>;
accessor dataViewLogic!: ViewLogic;
}
@@ -1,48 +1,7 @@
import { DataViewKanban, TableViewSelector } from './index.js';
import { MobileKanbanCard } from './kanban/mobile/card.js';
import { MobileKanbanCell } from './kanban/mobile/cell.js';
import { MobileKanbanGroup } from './kanban/mobile/group.js';
import { MobileDataViewKanban } from './kanban/mobile/kanban-view.js';
import { KanbanCard } from './kanban/pc/card.js';
import { KanbanCell } from './kanban/pc/cell.js';
import { KanbanGroup } from './kanban/pc/group.js';
import { KanbanHeader } from './kanban/pc/header.js';
import { MobileTableCell } from './table/mobile/cell.js';
import { MobileTableColumnHeader } from './table/mobile/column-header.js';
import { MobileTableGroup } from './table/mobile/group.js';
import { MobileTableHeader } from './table/mobile/header.js';
import { MobileTableRow } from './table/mobile/row.js';
import { MobileDataViewTable } from './table/mobile/table-view.js';
import { pcEffects } from './table/pc/effect.js';
import { pcVirtualEffects } from './table/pc-virtual/effect.js';
import { DataBaseColumnStats } from './table/stats/column-stats-bar.js';
import { DatabaseColumnStatsCell } from './table/stats/column-stats-column.js';
import { kanbanEffects } from './kanban/effect.js';
import { tableEffects } from './table/effect.js';
export function viewPresetsEffects() {
customElements.define('affine-data-view-kanban-card', KanbanCard);
customElements.define('mobile-kanban-card', MobileKanbanCard);
customElements.define('affine-data-view-kanban-cell', KanbanCell);
customElements.define('mobile-kanban-cell', MobileKanbanCell);
customElements.define('affine-data-view-kanban-group', KanbanGroup);
customElements.define('mobile-kanban-group', MobileKanbanGroup);
customElements.define('affine-data-view-kanban', DataViewKanban);
customElements.define('mobile-data-view-kanban', MobileDataViewKanban);
customElements.define('affine-data-view-kanban-header', KanbanHeader);
customElements.define('mobile-table-cell', MobileTableCell);
customElements.define('mobile-table-group', MobileTableGroup);
customElements.define('mobile-data-view-table', MobileDataViewTable);
customElements.define('mobile-table-header', MobileTableHeader);
customElements.define('mobile-table-column-header', MobileTableColumnHeader);
customElements.define('mobile-table-row', MobileTableRow);
customElements.define('affine-database-column-stats', DataBaseColumnStats);
customElements.define(
'affine-database-column-stats-cell',
DatabaseColumnStatsCell
);
customElements.define('affine-database-table-selector', TableViewSelector);
pcEffects();
pcVirtualEffects();
kanbanEffects();
tableEffects();
}
@@ -0,0 +1,7 @@
import { mobileEffects } from './mobile/effect.js';
import { pcEffects } from './pc/effect.js';
export function kanbanEffects() {
pcEffects();
mobileEffects();
}
@@ -1,5 +1,4 @@
export * from './define.js';
export * from './kanban-view-manager.js';
export * from './pc/kanban-view.js';
export * from './renderer.js';
export * from './selection.js';
@@ -10,8 +10,8 @@ import { classMap } from 'lit/directives/class-map.js';
import { repeat } from 'lit/directives/repeat.js';
import { html } from 'lit/static-html.js';
import type { DataViewRenderer } from '../../../core/data-view.js';
import type { KanbanColumn, KanbanSingleView } from '../kanban-view-manager.js';
import type { KanbanColumn } from '../kanban-view-manager.js';
import type { MobileKanbanViewUILogic } from './kanban-view-ui-logic.js';
import { popCardMenu } from './menu.js';
const styles = css`
@@ -94,7 +94,7 @@ export class MobileKanbanCard extends SignalWatcher(
private readonly clickCenterPeek = (e: MouseEvent) => {
e.stopPropagation();
this.dataViewEle.openDetailPanel({
this.kanbanViewLogic.root.openDetailPanel({
view: this.view,
rowId: this.cardId,
});
@@ -104,10 +104,9 @@ export class MobileKanbanCard extends SignalWatcher(
e.stopPropagation();
popCardMenu(
popupTargetFromElement(e.currentTarget as HTMLElement),
this.view,
this.groupKey,
this.cardId,
this.dataViewEle
this.kanbanViewLogic
);
};
@@ -126,10 +125,10 @@ export class MobileKanbanCard extends SignalWatcher(
return html` <mobile-kanban-cell
.contentOnly="${false}"
data-column-id="${column.id}"
.view="${this.view}"
.groupKey="${this.groupKey}"
.column="${column}"
.cardId="${this.cardId}"
.kanbanViewLogic="${this.kanbanViewLogic}"
></mobile-kanban-cell>`;
}
)}
@@ -184,10 +183,10 @@ export class MobileKanbanCard extends SignalWatcher(
<mobile-kanban-cell
.contentOnly="${true}"
data-column-id="${title.id}"
.view="${this.view}"
.groupKey="${this.groupKey}"
.column="${title}"
.cardId="${this.cardId}"
.kanbanViewLogic="${this.kanbanViewLogic}"
></mobile-kanban-cell>
</div>`;
}
@@ -205,9 +204,6 @@ export class MobileKanbanCard extends SignalWatcher(
@property({ attribute: false })
accessor cardId!: string;
@property({ attribute: false })
accessor dataViewEle!: DataViewRenderer;
@property({ attribute: false })
accessor groupKey!: string;
@@ -215,7 +211,11 @@ export class MobileKanbanCard extends SignalWatcher(
accessor isFocus = false;
@property({ attribute: false })
accessor view!: KanbanSingleView;
accessor kanbanViewLogic!: MobileKanbanViewUILogic;
get view() {
return this.kanbanViewLogic.view;
}
}
declare global {
@@ -14,7 +14,7 @@ import type {
} from '../../../core/property/index.js';
import { renderUniLit } from '../../../core/utils/uni-component/uni-component.js';
import type { Property } from '../../../core/view-manager/property.js';
import type { KanbanSingleView } from '../kanban-view-manager.js';
import type { MobileKanbanViewUILogic } from './kanban-view-ui-logic.js';
const styles = css`
mobile-kanban-cell {
@@ -53,7 +53,7 @@ export class MobileKanbanCell extends SignalWatcher(
private readonly _cell = signal<DataViewCellLifeCycle>();
isSelectionEditing$ = computed(() => {
const selection = this.kanban?.props.selection$.value;
const selection = this.kanbanViewLogic.selection$.value;
if (selection?.selectionType !== 'cell') {
return false;
}
@@ -73,8 +73,8 @@ export class MobileKanbanCell extends SignalWatcher(
if (this.view.readonly$.value) {
return;
}
const setSelection = this.kanban?.props.setSelection;
const viewId = this.kanban?.props.view.id;
const setSelection = this.kanbanViewLogic.setSelection;
const viewId = this.kanbanViewLogic.view.id;
if (setSelection && viewId) {
if (editing && this.cell?.beforeEnterEditMode() === false) {
return;
@@ -95,14 +95,6 @@ export class MobileKanbanCell extends SignalWatcher(
return this._cell.value;
}
get kanban() {
return this.closest('mobile-data-view-kanban');
}
get selection() {
return this.closest('mobile-data-view-kanban')?.props.selection$.value;
}
override connectedCallback() {
super.connectedCallback();
if (this.column.readonly$.value) return;
@@ -172,7 +164,11 @@ export class MobileKanbanCell extends SignalWatcher(
isEditing$ = signal(false);
@property({ attribute: false })
accessor view!: KanbanSingleView;
accessor kanbanViewLogic!: MobileKanbanViewUILogic;
get view() {
return this.kanbanViewLogic.view;
}
}
declare global {
@@ -0,0 +1,11 @@
import { MobileKanbanCard } from './card.js';
import { MobileKanbanCell } from './cell.js';
import { MobileKanbanGroup } from './group.js';
import { MobileKanbanViewUI } from './kanban-view-ui-logic.js';
export function mobileEffects() {
customElements.define('mobile-kanban-card', MobileKanbanCard);
customElements.define('mobile-kanban-cell', MobileKanbanCell);
customElements.define('mobile-kanban-group', MobileKanbanGroup);
customElements.define('mobile-data-view-kanban-ui', MobileKanbanViewUI);
}
@@ -11,11 +11,10 @@ import { property } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js';
import { html } from 'lit/static-html.js';
import type { DataViewRenderer } from '../../../core/data-view.js';
import { GroupTitle } from '../../../core/group-by/group-title.js';
import type { Group } from '../../../core/group-by/trait.js';
import { dragHandler } from '../../../core/utils/wc-dnd/dnd-context.js';
import type { KanbanSingleView } from '../kanban-view-manager.js';
import type { MobileKanbanViewUILogic } from './kanban-view-ui-logic.js';
const styles = css`
mobile-kanban-group {
@@ -112,9 +111,8 @@ export class MobileKanbanGroup extends SignalWatcher(
<mobile-kanban-card
data-card-id="${row.rowId}"
.groupKey="${this.group.key}"
.dataViewEle="${this.dataViewEle}"
.view="${this.view}"
.cardId="${row.rowId}"
.kanbanViewLogic="${this.kanbanViewLogic}"
></mobile-kanban-card>
`;
}
@@ -133,14 +131,15 @@ export class MobileKanbanGroup extends SignalWatcher(
`;
}
@property({ attribute: false })
accessor dataViewEle!: DataViewRenderer;
@property({ attribute: false })
accessor group!: Group;
@property({ attribute: false })
accessor view!: KanbanSingleView;
accessor kanbanViewLogic!: MobileKanbanViewUILogic;
get view() {
return this.kanbanViewLogic.view;
}
}
declare global {
@@ -0,0 +1,168 @@
import {
menu,
popMenu,
popupTargetFromElement,
} from '@blocksuite/affine-components/context-menu';
import { unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme';
import type { InsertToPosition } from '@blocksuite/affine-shared/utils';
import { AddCursorIcon } from '@blocksuite/icons/lit';
import { css } from '@emotion/css';
import { signal } from '@preact/signals-core';
import type { TemplateResult } from 'lit';
import { repeat } from 'lit/directives/repeat.js';
import { styleMap } from 'lit/directives/style-map.js';
import { html } from 'lit/static-html.js';
import {
createUniComponentFromWebComponent,
renderUniLit,
} from '../../../core/index.js';
import { sortable } from '../../../core/utils/wc-dnd/sort/sort-context.js';
import {
DataViewUIBase,
DataViewUILogicBase,
} from '../../../core/view/data-view-base.js';
import type { KanbanSingleView } from '../kanban-view-manager.js';
import type { KanbanViewSelectionWithType } from '../selection';
const mobileKanbanViewWrapper = css({
userSelect: 'none',
display: 'flex',
flexDirection: 'column',
});
const mobileKanbanGroups = css({
position: 'relative',
zIndex: 1,
display: 'flex',
gap: '20px',
paddingBottom: '4px',
overflowX: 'scroll',
overflowY: 'hidden',
});
const mobileAddGroup = css({
height: '32px',
flexShrink: 0,
display: 'flex',
alignItems: 'center',
padding: '4px',
borderRadius: '4px',
fontSize: '16px',
color: `var(${unsafeCSSVarV2('icon/primary')})`,
});
export class MobileKanbanViewUILogic extends DataViewUILogicBase<
KanbanSingleView,
KanbanViewSelectionWithType
> {
ui$ = signal<MobileKanbanViewUI | undefined>(undefined);
private get readonly() {
return this.view.readonly$.value;
}
clearSelection = () => {};
addRow = (position: InsertToPosition) => {
if (this.readonly) return;
return this.view.rowAdd(position);
};
focusFirstCell = () => {};
showIndicator = (_evt: MouseEvent) => {
return false;
};
hideIndicator = () => {};
moveTo = () => {};
get groupManager() {
return this.view.groupTrait;
}
renderAddGroup = () => {
const addGroup = this.groupManager.addGroup;
if (!addGroup) {
return;
}
const add = (e: MouseEvent) => {
const ele = e.currentTarget as HTMLElement;
popMenu(popupTargetFromElement(ele), {
options: {
items: [
menu.input({
onComplete: text => {
const column = this.groupManager.property$.value;
if (column) {
column.dataUpdate(() =>
addGroup({
text,
oldData: column.data$.value,
dataSource: this.view.manager.dataSource,
})
);
}
},
}),
],
},
});
};
return html` <div class="${mobileAddGroup}" @click="${add}">
${AddCursorIcon()}
</div>`;
};
renderer = createUniComponentFromWebComponent(MobileKanbanViewUI);
}
export class MobileKanbanViewUI extends DataViewUIBase<MobileKanbanViewUILogic> {
override connectedCallback(): void {
super.connectedCallback();
this.logic.ui$.value = this;
this.classList.add(mobileKanbanViewWrapper);
}
override render(): TemplateResult {
const groups = this.logic.groupManager.groupsDataList$.value;
if (!groups) {
return html``;
}
const vPadding = this.logic.root.config.virtualPadding$.value;
const wrapperStyle = styleMap({
marginLeft: `-${vPadding}px`,
marginRight: `-${vPadding}px`,
paddingLeft: `${vPadding}px`,
paddingRight: `${vPadding}px`,
});
return html`
${renderUniLit(this.logic.headerWidget, {
dataViewLogic: this.logic,
})}
<div class="${mobileKanbanGroups}" style="${wrapperStyle}">
${repeat(
groups,
group => group.key,
group => {
return html` <mobile-kanban-group
${sortable(group.key)}
data-key="${group.key}"
.kanbanViewLogic="${this.logic}"
.group="${group}"
></mobile-kanban-group>`;
}
)}
${this.logic.renderAddGroup()}
</div>
`;
}
}
declare global {
interface HTMLElementTagNameMap {
'mobile-data-view-kanban-ui': MobileKanbanViewUI;
}
}
@@ -1,149 +0,0 @@
import {
menu,
popMenu,
popupTargetFromElement,
} from '@blocksuite/affine-components/context-menu';
import { unsafeCSSVarV2 } from '@blocksuite/affine-shared/theme';
import { AddCursorIcon } from '@blocksuite/icons/lit';
import { css } from 'lit';
import { repeat } from 'lit/directives/repeat.js';
import { styleMap } from 'lit/directives/style-map.js';
import { html } from 'lit/static-html.js';
import { type DataViewInstance, renderUniLit } from '../../../core/index.js';
import { sortable } from '../../../core/utils/wc-dnd/sort/sort-context.js';
import { DataViewBase } from '../../../core/view/data-view-base.js';
import type { KanbanSingleView } from '../kanban-view-manager.js';
import type { KanbanViewSelectionWithType } from '../selection';
const styles = css`
mobile-data-view-kanban {
user-select: none;
display: flex;
flex-direction: column;
}
.mobile-kanban-groups {
position: relative;
z-index: 1;
display: flex;
gap: 20px;
padding-bottom: 4px;
overflow-x: scroll;
overflow-y: hidden;
}
.mobile-add-group {
height: 32px;
flex-shrink: 0;
display: flex;
align-items: center;
padding: 4px;
border-radius: 4px;
font-size: 16px;
color: ${unsafeCSSVarV2('icon/primary')};
}
`;
export class MobileDataViewKanban extends DataViewBase<
KanbanSingleView,
KanbanViewSelectionWithType
> {
static override styles = styles;
renderAddGroup = () => {
const addGroup = this.groupManager.addGroup;
if (!addGroup) {
return;
}
const add = (e: MouseEvent) => {
const ele = e.currentTarget as HTMLElement;
popMenu(popupTargetFromElement(ele), {
options: {
items: [
menu.input({
onComplete: text => {
const column = this.groupManager.property$.value;
if (column) {
column.dataUpdate(
() =>
addGroup({
text,
oldData: column.data$.value,
dataSource: this.props.view.manager.dataSource,
}) as never
);
}
},
}),
],
},
});
};
return html` <div class="mobile-add-group" @click="${add}">
${AddCursorIcon()}
</div>`;
};
get expose(): DataViewInstance {
return {
clearSelection: () => {},
focusFirstCell: () => {},
getSelection: () => {
return this.props.selection$.value;
},
hideIndicator: () => {},
moveTo: () => {},
showIndicator: () => {
return false;
},
view: this.props.view,
eventTrace: this.props.eventTrace,
};
}
get groupManager() {
return this.props.view.groupTrait;
}
override render() {
const groups = this.groupManager.groupsDataList$.value;
if (!groups) {
return html``;
}
const vPadding = this.props.virtualPadding$.value;
const wrapperStyle = styleMap({
marginLeft: `-${vPadding}px`,
marginRight: `-${vPadding}px`,
paddingLeft: `${vPadding}px`,
paddingRight: `${vPadding}px`,
});
return html`
${renderUniLit(this.props.headerWidget, {
dataViewInstance: this.expose,
})}
<div class="mobile-kanban-groups" style="${wrapperStyle}">
${repeat(
groups,
group => group.key,
group => {
return html` <mobile-kanban-group
${sortable(group.key)}
data-key="${group.key}"
.dataViewEle="${this.props.dataViewEle}"
.view="${this.props.view}"
.group="${group}"
></mobile-kanban-group>`;
}
)}
${this.renderAddGroup()}
</div>
`;
}
}
declare global {
interface HTMLElementTagNameMap {
'mobile-data-view-kanban': MobileDataViewKanban;
}
}
@@ -12,18 +12,16 @@ import {
} from '@blocksuite/icons/lit';
import { html } from 'lit';
import type { DataViewRenderer } from '../../../core/data-view.js';
import { groupTraitKey } from '../../../core/group-by/trait.js';
import type { KanbanSingleView } from '../kanban-view-manager.js';
import type { MobileKanbanViewUILogic } from './kanban-view-ui-logic.js';
export const popCardMenu = (
ele: PopupTarget,
view: KanbanSingleView,
groupKey: string,
cardId: string,
dataViewEle: DataViewRenderer
kanbanViewLogic: MobileKanbanViewUILogic
) => {
const groupTrait = view.traitGet(groupTraitKey);
const groupTrait = kanbanViewLogic.view.traitGet(groupTraitKey);
if (!groupTrait) {
return;
}
@@ -34,8 +32,8 @@ export const popCardMenu = (
name: 'Expand Card',
prefix: ExpandFullIcon(),
select: () => {
dataViewEle.openDetailPanel({
view: view,
kanbanViewLogic.root.openDetailPanel({
view: kanbanViewLogic.view,
rowId: cardId,
});
},
@@ -81,7 +79,10 @@ export const popCardMenu = (
${MoveLeftIcon()}
</div>`,
select: () => {
view.addCard({ before: true, id: cardId }, groupKey);
kanbanViewLogic.view.addCard(
{ before: true, id: cardId },
groupKey
);
},
}),
menu.action({
@@ -92,7 +93,10 @@ export const popCardMenu = (
${MoveRightIcon()}
</div>`,
select: () => {
view.addCard({ before: false, id: cardId }, groupKey);
kanbanViewLogic.view.addCard(
{ before: false, id: cardId },
groupKey
);
},
}),
],
@@ -106,7 +110,7 @@ export const popCardMenu = (
},
prefix: DeleteIcon(),
select: () => {
view.rowsDelete([cardId]);
kanbanViewLogic.view.rowsDelete([cardId]);
},
}),
],
@@ -2,15 +2,16 @@ import { popupTargetFromElement } from '@blocksuite/affine-components/context-me
import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { CenterPeekIcon, MoreHorizontalIcon } from '@blocksuite/icons/lit';
import { ShadowlessElement } from '@blocksuite/std';
import { signal } from '@preact/signals-core';
import { cssVarV2 } from '@toeverything/theme/v2';
import { css, unsafeCSS } from 'lit';
import { property, state } from 'lit/decorators.js';
import { property } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { repeat } from 'lit/directives/repeat.js';
import { html } from 'lit/static-html.js';
import type { DataViewRenderer } from '../../../core/data-view.js';
import type { KanbanColumn, KanbanSingleView } from '../kanban-view-manager.js';
import type { KanbanColumn } from '../kanban-view-manager.js';
import type { KanbanViewUILogic } from './kanban-view-ui-logic.js';
import { openDetail, popCardMenu } from './menu.js';
const styles = css`
@@ -130,7 +131,7 @@ export class KanbanCard extends SignalWatcher(
e.stopPropagation();
const selection = this.getSelection();
if (selection) {
openDetail(this.dataViewEle, this.cardId, selection);
openDetail(this.kanbanViewLogic, this.cardId, selection);
}
};
@@ -149,7 +150,7 @@ export class KanbanCard extends SignalWatcher(
],
};
popCardMenu(
this.dataViewEle,
this.kanbanViewLogic,
popupTargetFromElement(ele),
this.cardId,
selection
@@ -174,7 +175,7 @@ export class KanbanCard extends SignalWatcher(
const target = e.target as HTMLElement;
const ref = target.closest('affine-data-view-kanban-cell') ?? this;
popCardMenu(
this.dataViewEle,
this.kanbanViewLogic,
popupTargetFromElement(ref),
this.cardId,
selection
@@ -183,7 +184,7 @@ export class KanbanCard extends SignalWatcher(
};
private getSelection() {
return this.closest('affine-data-view-kanban')?.selectionController;
return this.kanbanViewLogic.selectionController;
}
private renderBody(columns: KanbanColumn[]) {
@@ -201,10 +202,10 @@ export class KanbanCard extends SignalWatcher(
return html` <affine-data-view-kanban-cell
.contentOnly="${false}"
data-column-id="${column.id}"
.view="${this.view}"
.groupKey="${this.groupKey}"
.column="${column}"
.cardId="${this.cardId}"
.kanbanViewLogic="${this.kanbanViewLogic}"
></affine-data-view-kanban-cell>`;
}
)}
@@ -259,7 +260,7 @@ export class KanbanCard extends SignalWatcher(
<affine-data-view-kanban-cell
.contentOnly="${true}"
data-column-id="${title.id}"
.view="${this.view}"
.kanbanViewLogic="${this.kanbanViewLogic}"
.groupKey="${this.groupKey}"
.column="${title}"
.cardId="${this.cardId}"
@@ -288,7 +289,7 @@ export class KanbanCard extends SignalWatcher(
if (selection) {
selection.selection = undefined;
}
this.dataViewEle.openDetailPanel({
this.kanbanViewLogic.root.openDetailPanel({
view: this.view,
rowId: this.cardId,
onClose: () => {
@@ -304,7 +305,7 @@ export class KanbanCard extends SignalWatcher(
const columns = this.view.properties$.value.filter(
v => !this.view.isInHeader(v.id)
);
this.style.border = this.isFocus
this.style.border = this.isFocus$.value
? '1px solid var(--affine-primary-color)'
: '';
return html`
@@ -316,17 +317,17 @@ export class KanbanCard extends SignalWatcher(
@property({ attribute: false })
accessor cardId!: string;
@property({ attribute: false })
accessor dataViewEle!: DataViewRenderer;
@property({ attribute: false })
accessor groupKey!: string;
@state()
accessor isFocus = false;
isFocus$ = signal(false);
@property({ attribute: false })
accessor view!: KanbanSingleView;
accessor kanbanViewLogic!: KanbanViewUILogic;
get view() {
return this.kanbanViewLogic.view;
}
}
declare global {
@@ -4,7 +4,7 @@ import { SignalWatcher, WithDisposable } from '@blocksuite/global/lit';
import { ShadowlessElement } from '@blocksuite/std';
import { signal } from '@preact/signals-core';
import { css } from 'lit';
import { property, state } from 'lit/decorators.js';
import { property } from 'lit/decorators.js';
import { html } from 'lit/static-html.js';
import type {
@@ -13,8 +13,8 @@ import type {
} from '../../../core/property/index.js';
import { renderUniLit } from '../../../core/utils/uni-component/uni-component.js';
import type { Property } from '../../../core/view-manager/property.js';
import type { KanbanSingleView } from '../kanban-view-manager.js';
import type { KanbanViewSelection } from '../selection';
import type { KanbanViewUILogic } from './kanban-view-ui-logic.js';
const styles = css`
affine-data-view-kanban-cell {
@@ -62,10 +62,7 @@ export class KanbanCell extends SignalWatcher(
private readonly _cell = signal<DataViewCellLifeCycle>();
selectCurrentCell = (editing: boolean) => {
const selectionView = this.closest(
'affine-data-view-kanban'
)?.selectionController;
if (!selectionView) return;
const selectionView = this.kanbanViewLogic.selectionController;
if (selectionView) {
const selection = selectionView.selection;
if (selection && this.isSelected(selection) && editing) {
@@ -93,7 +90,7 @@ export class KanbanCell extends SignalWatcher(
}
get selection() {
return this.closest('affine-data-view-kanban')?.selectionController;
return this.kanbanViewLogic.selectionController;
}
override connectedCallback() {
@@ -103,9 +100,7 @@ export class KanbanCell extends SignalWatcher(
return;
}
e.stopPropagation();
const selectionElement = this.closest(
'affine-data-view-kanban'
)?.selectionController;
const selectionElement = this.kanbanViewLogic.selectionController;
if (!selectionElement) return;
if (e.shiftKey) return;
@@ -138,7 +133,7 @@ export class KanbanCell extends SignalWatcher(
const { view } = renderer;
this.view.lockRows(this.isEditing$.value);
this.dataset['editing'] = `${this.isEditing$.value}`;
this.style.border = this.isFocus
this.style.border = this.isFocus$.value
? '1px solid var(--affine-primary-color)'
: '';
this.style.boxShadow = this.isEditing$.value
@@ -173,11 +168,14 @@ export class KanbanCell extends SignalWatcher(
@property({ attribute: false })
accessor groupKey!: string;
@state()
accessor isFocus = false;
isFocus$ = signal(false);
@property({ attribute: false })
accessor view!: KanbanSingleView;
accessor kanbanViewLogic!: KanbanViewUILogic;
get view() {
return this.kanbanViewLogic.view;
}
}
declare global {
@@ -2,7 +2,7 @@ import type { UIEventStateContext } from '@blocksuite/std';
import type { ReactiveController } from 'lit';
import type { KanbanViewSelectionWithType } from '../../selection';
import type { DataViewKanban } from '../kanban-view.js';
import type { KanbanViewUILogic } from '../kanban-view-ui-logic.js';
export class KanbanClipboardController implements ReactiveController {
private readonly _onCopy = (
@@ -19,31 +19,35 @@ export class KanbanClipboardController implements ReactiveController {
};
private get readonly() {
return this.host.props.view.readonly$.value;
return this.logic.view.readonly$.value;
}
constructor(public host: DataViewKanban) {
host.addController(this);
get host() {
return this.logic.ui$.value;
}
constructor(public logic: KanbanViewUILogic) {}
hostConnected() {
this.host.disposables.add(
this.host.props.handleEvent('copy', ctx => {
const kanbanSelection = this.host.selectionController.selection;
if (!kanbanSelection) return false;
if (this.host) {
this.host.disposables.add(
this.logic.handleEvent('copy', ctx => {
const kanbanSelection = this.logic.selectionController.selection;
if (!kanbanSelection) return false;
this._onCopy(ctx, kanbanSelection);
return true;
})
);
this._onCopy(ctx, kanbanSelection);
return true;
})
);
this.host.disposables.add(
this.host.props.handleEvent('paste', ctx => {
if (this.readonly) return false;
this.host.disposables.add(
this.logic.handleEvent('paste', ctx => {
if (this.readonly) return false;
this._onPaste(ctx);
return true;
})
);
this._onPaste(ctx);
return true;
})
);
}
}
}
@@ -7,10 +7,14 @@ import { autoScrollOnBoundary } from '../../../../core/utils/auto-scroll.js';
import { startDrag } from '../../../../core/utils/drag.js';
import { KanbanCard } from '../card.js';
import { KanbanGroup } from '../group.js';
import type { DataViewKanban } from '../kanban-view.js';
import type { KanbanViewUILogic } from '../kanban-view-ui-logic.js';
export class KanbanDragController implements ReactiveController {
dragStart = (ele: KanbanCard, evt: PointerEvent) => {
const host = this.host;
if (!host) {
return;
}
const eleRect = ele.getBoundingClientRect();
const offsetLeft = evt.x - eleRect.left;
const offsetTop = evt.y - eleRect.top;
@@ -36,8 +40,8 @@ export class KanbanDragController implements ReactiveController {
return;
}
preview.display(evt.x - offsetLeft, evt.y - offsetTop);
if (!Rect.fromDOM(this.host).isPointIn(Point.from(evt))) {
const callback = this.host.props.onDrag;
if (!Rect.fromDOM(host).isPointIn(Point.from(evt))) {
const callback = this.logic.root.config.onDrag;
if (callback) {
this.dropPreview.remove();
return {
@@ -47,7 +51,7 @@ export class KanbanDragController implements ReactiveController {
}
return;
}
const result = this.shooIndicator(evt, ele);
const result = this.showIndicator(evt, ele);
if (result) {
return {
type: 'self',
@@ -80,19 +84,26 @@ export class KanbanDragController implements ReactiveController {
}
},
});
const cancelScroll = autoScrollOnBoundary(
this.scrollContainer,
computed(() => {
return {
left: drag.mousePosition.value.x,
right: drag.mousePosition.value.x,
top: drag.mousePosition.value.y,
bottom: drag.mousePosition.value.y,
};
})
);
const cancelScroll =
this.scrollContainer != null
? autoScrollOnBoundary(
this.scrollContainer,
computed(() => {
return {
left: drag.mousePosition.value.x,
right: drag.mousePosition.value.x,
top: drag.mousePosition.value.y,
bottom: drag.mousePosition.value.y,
};
})
)
: () => {};
};
get host() {
return this.logic.ui$.value;
}
dropPreview = createDropPreview();
getInsertPosition = (
@@ -119,7 +130,7 @@ export class KanbanDragController implements ReactiveController {
}
};
shooIndicator = (
showIndicator = (
evt: MouseEvent,
self: KanbanCard | undefined
): { group: KanbanGroup; position: InsertToPosition } | undefined => {
@@ -133,38 +144,36 @@ export class KanbanDragController implements ReactiveController {
};
get scrollContainer() {
const scrollContainer = this.host.querySelector(
'.affine-data-view-kanban-groups'
) as HTMLElement;
const scrollContainer = this.logic.scrollContainer$.value;
return scrollContainer;
}
constructor(private readonly host: DataViewKanban) {
this.host.addController(this);
}
constructor(private readonly logic: KanbanViewUILogic) {}
hostConnected() {
if (this.host.props.view.readonly$.value) {
if (this.logic.view.readonly$.value) {
return;
}
this.host.disposables.add(
this.host.props.handleEvent('dragStart', context => {
const event = context.get('pointerState').raw;
const target = event.target;
if (target instanceof Element) {
const cell = target.closest('affine-data-view-kanban-cell');
if (cell?.isEditing$.value) {
return;
if (this.host) {
this.host.disposables.add(
this.logic.handleEvent('dragStart', context => {
const event = context.get('pointerState').raw;
const target = event.target;
if (target instanceof Element) {
const cell = target.closest('affine-data-view-kanban-cell');
if (cell?.isEditing$.value) {
return;
}
cell?.selectCurrentCell(false);
const card = target.closest('affine-data-view-kanban-card');
if (card) {
this.dragStart(card, event);
}
}
cell?.selectCurrentCell(false);
const card = target.closest('affine-data-view-kanban-card');
if (card) {
this.dragStart(card, event);
}
}
return true;
})
);
return true;
})
);
}
}
}
@@ -174,8 +183,8 @@ const createDragPreview = (card: KanbanCard, x: number, y: number) => {
const div = document.createElement('div');
const kanbanCard = new KanbanCard();
kanbanCard.cardId = card.cardId;
kanbanCard.view = card.view;
kanbanCard.isFocus = true;
kanbanCard.kanbanViewLogic = card.kanbanViewLogic;
kanbanCard.isFocus$.value = true;
kanbanCard.style.backgroundColor = 'var(--affine-background-primary-color)';
div.append(kanbanCard);
div.className = 'with-data-view-css-variable';
@@ -1,63 +1,67 @@
import type { ReactiveController } from 'lit';
import type { DataViewKanban } from '../kanban-view.js';
import type { KanbanViewUILogic } from '../kanban-view-ui-logic.js';
export class KanbanHotkeysController implements ReactiveController {
private get hasSelection() {
return !!this.host.selectionController.selection;
return !!this.logic.selectionController.selection;
}
constructor(private readonly host: DataViewKanban) {
this.host.addController(this);
constructor(public logic: KanbanViewUILogic) {}
get host() {
return this.logic.ui$.value;
}
hostConnected() {
this.host.disposables.add(
this.host.props.bindHotkey({
Escape: () => {
this.host.selectionController.focusOut();
return true;
},
Enter: () => {
this.host.selectionController.focusIn();
},
ArrowUp: context => {
if (!this.hasSelection) return false;
if (this.host) {
this.host.disposables.add(
this.logic.bindHotkey({
Escape: () => {
this.logic.selectionController.focusOut();
return true;
},
Enter: () => {
this.logic.selectionController.focusIn();
},
ArrowUp: context => {
if (!this.hasSelection) return false;
this.host.selectionController.focusNext('up');
context.get('keyboardState').raw.preventDefault();
return true;
},
ArrowDown: context => {
if (!this.hasSelection) return false;
this.logic.selectionController.focusNext('up');
context.get('keyboardState').raw.preventDefault();
return true;
},
ArrowDown: context => {
if (!this.hasSelection) return false;
this.host.selectionController.focusNext('down');
context.get('keyboardState').raw.preventDefault();
return true;
},
Tab: context => {
if (!this.hasSelection) return false;
this.logic.selectionController.focusNext('down');
context.get('keyboardState').raw.preventDefault();
return true;
},
Tab: context => {
if (!this.hasSelection) return false;
this.host.selectionController.focusNext('down');
context.get('keyboardState').raw.preventDefault();
return true;
},
ArrowLeft: () => {
if (!this.hasSelection) return false;
this.logic.selectionController.focusNext('down');
context.get('keyboardState').raw.preventDefault();
return true;
},
ArrowLeft: () => {
if (!this.hasSelection) return false;
this.host.selectionController.focusNext('left');
return true;
},
ArrowRight: () => {
if (!this.hasSelection) return false;
this.logic.selectionController.focusNext('left');
return true;
},
ArrowRight: () => {
if (!this.hasSelection) return false;
this.host.selectionController.focusNext('right');
return true;
},
Backspace: () => {
this.host.selectionController.deleteCard();
},
})
);
this.logic.selectionController.focusNext('right');
return true;
},
Backspace: () => {
this.logic.selectionController.deleteCard();
},
})
);
}
}
}
@@ -12,7 +12,7 @@ import type {
import { KanbanCard } from '../card.js';
import { KanbanCell } from '../cell.js';
import type { KanbanGroup } from '../group.js';
import type { DataViewKanban } from '../kanban-view.js';
import type { KanbanViewUILogic } from '../kanban-view-ui-logic.js';
export class KanbanSelectionController implements ReactiveController {
private _selection?: KanbanViewSelectionWithType;
@@ -47,52 +47,62 @@ export class KanbanSelectionController implements ReactiveController {
}
set selection(data: KanbanViewSelection | undefined) {
const host = this.host;
if (!host) {
return;
}
if (!data) {
this.host.props.setSelection();
this.logic.setSelection();
return;
}
const selection: KanbanViewSelectionWithType = {
...data,
viewId: this.host.props.view.id,
viewId: this.logic.view.id,
type: 'kanban',
};
if (selection.selectionType === 'cell' && selection.isEditing) {
const container = getFocusCell(this.host, selection);
const container = getFocusCell(host, selection);
const cell = container?.cell;
const isEditing = cell
? cell.beforeEnterEditMode()
? selection.isEditing
: false
: false;
this.host.props.setSelection({
this.logic.setSelection({
...selection,
isEditing,
});
} else {
this.host.props.setSelection(selection);
this.logic.setSelection(selection);
}
}
get view() {
return this.host.props.view;
return this.logic.view;
}
constructor(private readonly host: DataViewKanban) {
this.host.addController(this);
get host() {
return this.logic.ui$.value;
}
constructor(public logic: KanbanViewUILogic) {}
blur(selection: KanbanViewSelection) {
const host = this.host;
if (!host) {
return;
}
if (selection.selectionType !== 'cell') {
const selectCards = getSelectedCards(this.host, selection);
selectCards.forEach(card => (card.isFocus = false));
selectCards.forEach(card => (card.isFocus$.value = false));
return;
}
const container = getFocusCell(this.host, selection);
if (!container) {
return;
}
container.isFocus = false;
container.isFocus$.value = false;
const cell = container?.cell;
if (selection.isEditing) {
@@ -116,19 +126,23 @@ export class KanbanSelectionController implements ReactiveController {
return;
}
if (selection.selectionType === 'card') {
this.host.props.view.rowsDelete(selection.cards.map(v => v.cardId));
this.view.rowsDelete(selection.cards.map(v => v.cardId));
this.selection = undefined;
}
}
focus(selection: KanbanViewSelection) {
const host = this.host;
if (!host) {
return;
}
if (selection.selectionType !== 'cell') {
const selectCards = getSelectedCards(this.host, selection);
selectCards.forEach((card, index) => {
if (index === 0) {
card.scrollIntoView({ block: 'nearest', inline: 'nearest' });
}
card.isFocus = true;
card.isFocus$.value = true;
});
return;
}
@@ -137,7 +151,7 @@ export class KanbanSelectionController implements ReactiveController {
return;
}
container.scrollIntoView({ block: 'nearest', inline: 'nearest' });
container.isFocus = true;
container.isFocus$.value = true;
const cell = container?.cell;
if (selection.isEditing) {
if (cell?.focusCell()) {
@@ -153,10 +167,9 @@ export class KanbanSelectionController implements ReactiveController {
}
focusFirstCell() {
const group = this.host.groupManager?.groupsDataList$.value?.[0];
const group = this.logic.groups$.value?.[0];
const card = group?.rows[0];
const columnId =
card && this.host.props.view.getHeaderTitle(card.rowId)?.id;
const columnId = card && this.view.getHeaderTitle(card.rowId)?.id;
if (group && card && columnId) {
this.selection = {
selectionType: 'cell',
@@ -169,6 +182,10 @@ export class KanbanSelectionController implements ReactiveController {
}
focusIn() {
const host = this.host;
if (!host) {
return;
}
const selection = this.selection;
if (!selection) return;
if (selection.selectionType === 'cell' && selection.isEditing) return;
@@ -198,6 +215,10 @@ export class KanbanSelectionController implements ReactiveController {
}
focusNext(position: 'up' | 'down' | 'left' | 'right') {
const host = this.host;
if (!host) {
return;
}
const selection = this.selection;
if (!selection) {
return;
@@ -222,7 +243,7 @@ export class KanbanSelectionController implements ReactiveController {
}
} else if (selection.selectionType === 'card') {
// card focus
const group = this.host.querySelector(
const group = this.host?.querySelector(
`affine-data-view-kanban-group[data-key="${selection.cards[0].groupKey}"]`
);
const cardElements = Array.from(
@@ -292,7 +313,11 @@ export class KanbanSelectionController implements ReactiveController {
cards: KanbanCardSelectionCard[];
}
| undefined {
const group = this.host.querySelector(
const host = this.host;
if (!host) {
return;
}
const group = host.querySelector(
`affine-data-view-kanban-group[data-key="${selection.cards[0].groupKey}"]`
);
const kanbanCards = Array.from(
@@ -332,7 +357,7 @@ export class KanbanSelectionController implements ReactiveController {
}
const groups = Array.from(
this.host.querySelectorAll('affine-data-view-kanban-group')
this.host?.querySelectorAll('affine-data-view-kanban-group') ?? []
);
if (nextPosition === 'right') {
@@ -369,6 +394,10 @@ export class KanbanSelectionController implements ReactiveController {
groupKey?: string;
}
| undefined {
const host = this.host;
if (!host) {
return;
}
const kanbanCells = getCardCellsBySelection(this.host, selection);
const group = this.host.querySelector(
`affine-data-view-kanban-group[data-key="${selection.groupKey}"]`
@@ -426,7 +455,7 @@ export class KanbanSelectionController implements ReactiveController {
}
const groups = Array.from(
this.host.querySelectorAll('affine-data-view-kanban-group')
this.host?.querySelectorAll('affine-data-view-kanban-group') ?? []
);
if (nextPosition === 'right') {
@@ -453,8 +482,8 @@ export class KanbanSelectionController implements ReactiveController {
}
hostConnected() {
this.host.disposables.add(
this.host.props.selection$.subscribe(selection => {
this.host?.disposables.add(
this.logic.selection$.subscribe(selection => {
const old = this._selection;
if (old) {
this.blur(old);
@@ -0,0 +1,11 @@
import { KanbanCard } from './card.js';
import { KanbanCell } from './cell.js';
import { KanbanGroup } from './group.js';
import { KanbanHeader } from './header.js';
export function pcEffects() {
customElements.define('affine-data-view-kanban-card', KanbanCard);
customElements.define('affine-data-view-kanban-cell', KanbanCell);
customElements.define('affine-data-view-kanban-group', KanbanGroup);
customElements.define('affine-data-view-kanban-header', KanbanHeader);
}
@@ -11,11 +11,10 @@ import { property } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js';
import { html } from 'lit/static-html.js';
import type { DataViewRenderer } from '../../../core/data-view.js';
import { GroupTitle } from '../../../core/group-by/group-title.js';
import type { Group } from '../../../core/group-by/trait.js';
import { dragHandler } from '../../../core/utils/wc-dnd/dnd-context.js';
import type { KanbanSingleView } from '../kanban-view-manager.js';
import type { KanbanViewUILogic } from './kanban-view-ui-logic.js';
const styles = css`
affine-data-view-kanban-group {
@@ -99,40 +98,34 @@ export class KanbanGroup extends SignalWatcher(
private readonly clickAddCard = () => {
const id = this.view.addCard('end', this.group.key);
requestAnimationFrame(() => {
const kanban = this.closest('affine-data-view-kanban');
if (kanban) {
const columnId =
this.view.mainProperties$.value.titleColumn ||
this.view.propertyIds$.value[0];
if (!columnId) return;
kanban.selectionController.selection = {
selectionType: 'cell',
groupKey: this.group.key,
cardId: id,
columnId,
isEditing: true,
};
}
const columnId =
this.view.mainProperties$.value.titleColumn ||
this.view.propertyIds$.value[0];
if (!columnId) return;
this.kanbanViewLogic.selectionController.selection = {
selectionType: 'cell',
groupKey: this.group.key,
cardId: id,
columnId,
isEditing: true,
};
});
};
private readonly clickAddCardInStart = () => {
const id = this.view.addCard('start', this.group.key);
requestAnimationFrame(() => {
const kanban = this.closest('affine-data-view-kanban');
if (kanban) {
const columnId =
this.view.mainProperties$.value.titleColumn ||
this.view.propertyIds$.value[0];
if (!columnId) return;
kanban.selectionController.selection = {
selectionType: 'cell',
groupKey: this.group.key,
cardId: id,
columnId,
isEditing: true,
};
}
const columnId =
this.view.mainProperties$.value.titleColumn ||
this.view.propertyIds$.value[0];
if (!columnId) return;
this.kanbanViewLogic.selectionController.selection = {
selectionType: 'cell',
groupKey: this.group.key,
cardId: id,
columnId,
isEditing: true,
};
});
};
@@ -176,8 +169,7 @@ export class KanbanGroup extends SignalWatcher(
<affine-data-view-kanban-card
data-card-id="${row.rowId}"
.groupKey="${this.group.key}"
.dataViewEle="${this.dataViewEle}"
.view="${this.view}"
.kanbanViewLogic="${this.kanbanViewLogic}"
.cardId="${row.rowId}"
></affine-data-view-kanban-card>
`;
@@ -197,14 +189,15 @@ export class KanbanGroup extends SignalWatcher(
`;
}
@property({ attribute: false })
accessor dataViewEle!: DataViewRenderer;
@property({ attribute: false })
accessor group!: Group;
@property({ attribute: false })
accessor view!: KanbanSingleView;
accessor kanbanViewLogic!: KanbanViewUILogic;
get view() {
return this.kanbanViewLogic.view;
}
}
declare global {
@@ -0,0 +1,330 @@
import {
menu,
popMenu,
popupTargetFromElement,
} from '@blocksuite/affine-components/context-menu';
import type { InsertToPosition } from '@blocksuite/affine-shared/utils';
import { AddCursorIcon } from '@blocksuite/icons/lit';
import { css } from '@emotion/css';
import { computed, signal } from '@preact/signals-core';
import { type TemplateResult } from 'lit';
import { ref } from 'lit/directives/ref.js';
import { styleMap } from 'lit/directives/style-map.js';
import { html } from 'lit/static-html.js';
import {
type GroupTrait,
groupTraitKey,
} from '../../../core/group-by/trait.js';
import {
createUniComponentFromWebComponent,
renderUniLit,
} from '../../../core/index.js';
import { defaultActivators } from '../../../core/utils/wc-dnd/sensors/index.js';
import {
createSortContext,
sortable,
} from '../../../core/utils/wc-dnd/sort/sort-context.js';
import { horizontalListSortingStrategy } from '../../../core/utils/wc-dnd/sort/strategies/index.js';
import {
DataViewUIBase,
DataViewUILogicBase,
} from '../../../core/view/data-view-base.js';
import type { KanbanSingleView } from '../kanban-view-manager.js';
import type { KanbanViewSelectionWithType } from '../selection.js';
import { KanbanClipboardController } from './controller/clipboard.js';
import { KanbanDragController } from './controller/drag.js';
import { KanbanHotkeysController } from './controller/hotkeys.js';
import { KanbanSelectionController } from './controller/selection.js';
export class KanbanViewUILogic extends DataViewUILogicBase<
KanbanSingleView,
KanbanViewSelectionWithType
> {
ui$ = signal<KanbanViewUI | undefined>();
clipboardController = new KanbanClipboardController(this);
dragController = new KanbanDragController(this);
hotkeysController = new KanbanHotkeysController(this);
selectionController = new KanbanSelectionController(this);
groupTrait$ = computed(() => {
return this.view.traitGet(groupTraitKey);
});
groups$ = computed(() => {
const groupTrait = this.groupTrait$.value;
return groupTrait?.groupsDataList$.value || [];
});
private get readonly() {
return this.view.readonly$.value;
}
clearSelection = () => {
this.selectionController.clear();
};
addRow = (position: InsertToPosition) => {
if (this.readonly) return;
const rowId = this.view.rowAdd(position);
if (rowId) {
this.root.openDetailPanel({
view: this.view,
rowId,
});
}
return rowId;
};
focusFirstCell = () => {
this.selectionController.focusFirstCell();
};
showIndicator = (evt: MouseEvent) => {
return this.dragController.showIndicator(evt, undefined) != null;
};
hideIndicator = () => {
this.dragController.dropPreview.remove();
};
moveTo = (id: string, evt: MouseEvent) => {
const position = this.dragController.getInsertPosition(evt);
if (position) {
position.group.group.manager.moveCardTo(
id,
'',
position.group.group.key,
position.position
);
}
};
onWheel = (event: WheelEvent) => {
if (event.metaKey || event.ctrlKey) {
return;
}
const ele = event.currentTarget;
if (ele instanceof HTMLElement) {
if (ele.scrollWidth === ele.clientWidth) {
return;
}
event.stopPropagation();
}
};
renderAddGroup = (groupHelper: GroupTrait) => {
const addGroup = groupHelper.addGroup;
if (!addGroup) {
return;
}
const add = (e: MouseEvent) => {
const ele = e.currentTarget as HTMLElement;
popMenu(popupTargetFromElement(ele), {
options: {
items: [
menu.input({
onComplete: text => {
const column = groupHelper.property$.value;
if (column) {
column.dataUpdate(() =>
addGroup({
text,
oldData: column.data$.value,
dataSource: this.view.manager.dataSource,
})
);
}
},
}),
],
},
});
};
return html` <div
style="height: 32px;flex-shrink:0;display:flex;align-items:center;"
@click="${add}"
>
<div class="${addGroupIconStyle}">${AddCursorIcon()}</div>
</div>`;
};
scrollContainer$ = signal<HTMLElement | undefined>(undefined);
renderer = createUniComponentFromWebComponent(KanbanViewUI);
}
export class KanbanViewUI extends DataViewUIBase<KanbanViewUILogic> {
readonly sortContext = createSortContext({
activators: defaultActivators,
container: this,
onDragEnd: evt => {
const over = evt.over;
const activeId = evt.active.id;
const groupTrait = this.logic.groupTrait$.value;
const groups = groupTrait?.groupsDataList$.value;
if (over && over.id !== activeId && groups) {
const activeIndex = groups.findIndex(data => data?.key === activeId);
const overIndex = groups.findIndex(data => data?.key === over.id);
groupTrait?.moveGroupTo(
activeId,
activeIndex > overIndex
? {
before: true,
id: over.id,
}
: {
before: false,
id: over.id,
}
);
}
},
modifiers: [
({ transform }) => {
return {
...transform,
y: 0,
};
},
],
items: computed(() => {
return this.logic.groups$.value?.map(v => v?.key ?? 'default key') ?? [];
}),
strategy: horizontalListSortingStrategy,
});
private renderGroups() {
const groups = this.logic.groups$.value;
if (!groups) {
return html``;
}
return html`${groups.map(group => {
return html` <affine-data-view-kanban-group
${sortable(group.key)}
data-key="${group.key}"
.kanbanViewLogic="${this.logic}"
.group="${group}"
></affine-data-view-kanban-group>`;
})}`;
}
override connectedCallback(): void {
super.connectedCallback();
this.logic.ui$.value = this;
this.logic.clipboardController.hostConnected();
this.logic.dragController.hostConnected();
this.logic.hotkeysController.hostConnected();
this.logic.selectionController.hostConnected();
this.classList.add('kanban-view', kanbanViewStyle);
this.style.userSelect = 'none';
this.style.display = 'flex';
this.style.flexDirection = 'column';
}
override render(): TemplateResult {
const groups = this.logic.groups$.value;
if (!groups) {
return html``;
}
const vPadding = this.logic.root.config.virtualPadding$.value;
const wrapperStyle = styleMap({
marginLeft: `-${vPadding}px`,
marginRight: `-${vPadding}px`,
paddingLeft: `${vPadding}px`,
paddingRight: `${vPadding}px`,
});
const groupTrait = this.logic.groupTrait$.value;
return html`
${renderUniLit(this.logic.root.config.headerWidget, {
dataViewLogic: this.logic,
})}
<div
${ref(this.logic.scrollContainer$)}
class="${kanbanGroupsStyle}"
style="${wrapperStyle}"
@wheel="${this.logic.onWheel}"
>
${this.renderGroups()}
${groupTrait ? this.logic.renderAddGroup(groupTrait) : ''}
</div>
`;
}
}
const kanbanViewStyle = css({
userSelect: 'none',
display: 'flex',
flexDirection: 'column',
});
const kanbanGroupsStyle = css({
position: 'relative',
zIndex: 1,
display: 'flex',
gap: '20px',
paddingBottom: '4px',
overflowX: 'scroll',
overflowY: 'hidden',
'&:hover': {
paddingBottom: '0px',
},
'&::-webkit-scrollbar': {
WebkitAppearance: 'none',
display: 'block',
},
'&::-webkit-scrollbar:horizontal': {
height: '4px',
},
'&::-webkit-scrollbar-thumb': {
borderRadius: '2px',
backgroundColor: 'transparent',
},
'&:hover::-webkit-scrollbar:horizontal': {
height: '8px',
},
'&:hover::-webkit-scrollbar-thumb': {
borderRadius: '16px',
backgroundColor: 'var(--affine-black-30)',
},
'&:hover::-webkit-scrollbar-track': {
backgroundColor: 'var(--affine-hover-color)',
},
});
const addGroupIconStyle = css({
padding: '4px',
borderRadius: '4px',
display: 'flex',
alignItems: 'center',
cursor: 'pointer',
'&:hover': {
backgroundColor: 'var(--affine-hover-color)',
},
'& svg': {
width: '16px',
height: '16px',
fill: 'var(--affine-icon-color)',
color: 'var(--affine-icon-color)',
},
});
declare global {
interface HTMLElementTagNameMap {
'dv-kanban-view-ui': KanbanViewUI;
}
}
@@ -1,300 +0,0 @@
import {
menu,
popMenu,
popupTargetFromElement,
} from '@blocksuite/affine-components/context-menu';
import { AddCursorIcon } from '@blocksuite/icons/lit';
import { computed } from '@preact/signals-core';
import { css } from 'lit';
import { query } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js';
import { styleMap } from 'lit/directives/style-map.js';
import { html } from 'lit/static-html.js';
import { type DataViewInstance, renderUniLit } from '../../../core/index.js';
import { defaultActivators } from '../../../core/utils/wc-dnd/sensors/index.js';
import {
createSortContext,
sortable,
} from '../../../core/utils/wc-dnd/sort/sort-context.js';
import { horizontalListSortingStrategy } from '../../../core/utils/wc-dnd/sort/strategies/index.js';
import { DataViewBase } from '../../../core/view/data-view-base.js';
import type { KanbanSingleView } from '../kanban-view-manager.js';
import type { KanbanViewSelectionWithType } from '../selection';
import { KanbanClipboardController } from './controller/clipboard.js';
import { KanbanDragController } from './controller/drag.js';
import { KanbanHotkeysController } from './controller/hotkeys.js';
import { KanbanSelectionController } from './controller/selection.js';
const styles = css`
affine-data-view-kanban {
user-select: none;
display: flex;
flex-direction: column;
}
.affine-data-view-kanban-groups {
position: relative;
z-index: 1;
display: flex;
gap: 20px;
padding-bottom: 4px;
overflow-x: scroll;
overflow-y: hidden;
}
.affine-data-view-kanban-groups:hover {
padding-bottom: 0px;
}
.affine-data-view-kanban-groups::-webkit-scrollbar {
-webkit-appearance: none;
display: block;
}
.affine-data-view-kanban-groups::-webkit-scrollbar:horizontal {
height: 4px;
}
.affine-data-view-kanban-groups::-webkit-scrollbar-thumb {
border-radius: 2px;
background-color: transparent;
}
.affine-data-view-kanban-groups:hover::-webkit-scrollbar:horizontal {
height: 8px;
}
.affine-data-view-kanban-groups:hover::-webkit-scrollbar-thumb {
border-radius: 16px;
background-color: var(--affine-black-30);
}
.affine-data-view-kanban-groups:hover::-webkit-scrollbar-track {
background-color: var(--affine-hover-color);
}
.add-group-icon {
padding: 4px;
border-radius: 4px;
display: flex;
align-items: center;
cursor: pointer;
}
.add-group-icon:hover {
background-color: var(--affine-hover-color);
}
.add-group-icon svg {
width: 16px;
height: 16px;
fill: var(--affine-icon-color);
color: var(--affine-icon-color);
}
`;
export class DataViewKanban extends DataViewBase<
KanbanSingleView,
KanbanViewSelectionWithType
> {
static override styles = styles;
private readonly dragController = new KanbanDragController(this);
clipboardController = new KanbanClipboardController(this);
hotkeysController = new KanbanHotkeysController(this);
onWheel = (event: WheelEvent) => {
if (event.metaKey || event.ctrlKey) {
return;
}
const ele = event.currentTarget;
if (ele instanceof HTMLElement) {
if (ele.scrollWidth === ele.clientWidth) {
return;
}
event.stopPropagation();
}
};
renderAddGroup = () => {
const addGroup = this.groupManager.addGroup;
if (!addGroup) {
return;
}
const add = (e: MouseEvent) => {
const ele = e.currentTarget as HTMLElement;
popMenu(popupTargetFromElement(ele), {
options: {
items: [
menu.input({
onComplete: text => {
const column = this.groupManager.property$.value;
if (column) {
column.dataUpdate(
() =>
addGroup({
text,
oldData: column.data$.value,
dataSource: this.props.view.manager.dataSource,
}) as never
);
}
},
}),
],
},
});
};
return html` <div
style="height: 32px;flex-shrink:0;display:flex;align-items:center;"
@click="${add}"
>
<div class="add-group-icon">${AddCursorIcon()}</div>
</div>`;
};
selectionController = new KanbanSelectionController(this);
sortContext = createSortContext({
activators: defaultActivators,
container: this,
onDragEnd: evt => {
const over = evt.over;
const activeId = evt.active.id;
const groups = this.groupManager.groupsDataList$.value;
if (over && over.id !== activeId && groups) {
const activeIndex = groups.findIndex(data => data?.key === activeId);
const overIndex = groups.findIndex(data => data?.key === over.id);
this.groupManager.moveGroupTo(
activeId,
activeIndex > overIndex
? {
before: true,
id: over.id,
}
: {
before: false,
id: over.id,
}
);
}
},
modifiers: [
({ transform }) => {
return {
...transform,
y: 0,
};
},
],
items: computed(() => {
return (
this.groupManager.groupsDataList$.value?.map(
v => v?.key ?? 'default key'
) ?? []
);
}),
strategy: horizontalListSortingStrategy,
});
get expose(): DataViewInstance {
return {
clearSelection: () => {
this.selectionController.clear();
},
addRow: position => {
if (this.props.view.readonly$.value) return;
const rowId = this.props.view.rowAdd(position);
if (rowId) {
this.props.dataViewEle.openDetailPanel({
view: this.props.view,
rowId,
});
}
return rowId;
},
focusFirstCell: () => {
this.selectionController.focusFirstCell();
},
getSelection: () => {
return this.selectionController.selection;
},
hideIndicator: () => {
this.dragController.dropPreview.remove();
},
moveTo: (id, evt) => {
const position = this.dragController.getInsertPosition(evt);
if (position) {
position.group.group.manager.moveCardTo(
id,
'',
position.group.group.key,
position.position
);
}
},
showIndicator: evt => {
return this.dragController.shooIndicator(evt, undefined) != null;
},
view: this.props.view,
eventTrace: this.props.eventTrace,
};
}
get groupManager() {
return this.props.view.groupTrait;
}
override render() {
const groups = this.groupManager.groupsDataList$.value;
if (!groups) {
return html``;
}
const vPadding = this.props.virtualPadding$.value;
const wrapperStyle = styleMap({
marginLeft: `-${vPadding}px`,
marginRight: `-${vPadding}px`,
paddingLeft: `${vPadding}px`,
paddingRight: `${vPadding}px`,
});
return html`
${renderUniLit(this.props.headerWidget, {
dataViewInstance: this.expose,
})}
<div
class="affine-data-view-kanban-groups"
style="${wrapperStyle}"
@wheel="${this.onWheel}"
>
${repeat(
groups,
group => group?.key ?? 'default key',
group => {
if (!group) return;
return html` <affine-data-view-kanban-group
${sortable(group.key)}
data-key="${group.key}"
.dataViewEle="${this.props.dataViewEle}"
.view="${this.props.view}"
.group="${group}"
></affine-data-view-kanban-group>`;
}
)}
${this.renderAddGroup()}
</div>
`;
}
@query('.affine-data-view-kanban-groups')
accessor groups!: HTMLElement;
}
declare global {
interface HTMLElementTagNameMap {
'affine-data-view-kanban': DataViewKanban;
}
}
@@ -12,17 +12,17 @@ import {
} from '@blocksuite/icons/lit';
import { html } from 'lit';
import type { DataViewRenderer } from '../../../core/data-view.js';
import type { KanbanSelectionController } from './controller/selection.js';
import type { KanbanViewUILogic } from './kanban-view-ui-logic.js';
export const openDetail = (
dataViewEle: DataViewRenderer,
kanbanViewLogic: KanbanViewUILogic,
rowId: string,
selection: KanbanSelectionController
) => {
const old = selection.selection;
selection.selection = undefined;
dataViewEle.openDetailPanel({
kanbanViewLogic.root.openDetailPanel({
view: selection.view,
rowId: rowId,
onClose: () => {
@@ -32,7 +32,7 @@ export const openDetail = (
};
export const popCardMenu = (
dataViewEle: DataViewRenderer,
kanbanViewLogic: KanbanViewUILogic,
ele: PopupTarget,
rowId: string,
selection: KanbanSelectionController
@@ -42,7 +42,7 @@ export const popCardMenu = (
name: 'Expand Card',
prefix: ExpandFullIcon(),
select: () => {
openDetail(dataViewEle, rowId, selection);
openDetail(kanbanViewLogic, rowId, selection);
},
}),
menu.subMenu({
@@ -1,11 +1,12 @@
import { createUniComponentFromWebComponent } from '../../core/index.js';
import { createIcon } from '../../core/utils/uni-icon.js';
import { kanbanViewModel } from './define.js';
import { MobileDataViewKanban } from './mobile/kanban-view.js';
import { DataViewKanban } from './pc/kanban-view.js';
import { MobileKanbanViewUILogic } from './mobile/kanban-view-ui-logic.js';
import { KanbanViewUILogic } from './pc/kanban-view-ui-logic.js';
export const kanbanViewMeta = kanbanViewModel.createMeta({
icon: createIcon('DatabaseKanbanViewIcon'),
view: createUniComponentFromWebComponent(DataViewKanban),
mobileView: createUniComponentFromWebComponent(MobileDataViewKanban),
// @ts-expect-error fixme: typesafe
pcLogic: () => KanbanViewUILogic,
// @ts-expect-error fixme: typesafe
mobileLogic: () => MobileKanbanViewUILogic,
});
@@ -0,0 +1,11 @@
import { mobileEffects } from './mobile/effect.js';
import { pcEffects } from './pc/effect.js';
import { pcVirtualEffects } from './pc-virtual/effect.js';
import { statsEffects } from './stats/effect.js';
export function tableEffects() {
mobileEffects();
statsEffects();
pcEffects();
pcVirtualEffects();
}
@@ -1,8 +1,6 @@
export * from './define.js';
export * from './pc/effect.js';
export * from './pc/table-view.js';
export * from './pc-virtual/effect.js';
export * from './renderer.js';
export * from './selection.js';
export * from './table-view-manager.js';
export * from './table-view-selector.js';
@@ -8,10 +8,10 @@ import {
type CellRenderProps,
type DataViewCellLifeCycle,
renderUniLit,
type SingleView,
} from '../../../core/index.js';
import { TableViewAreaSelection } from '../selection';
import type { TableProperty } from '../table-view-manager.js';
import type { MobileTableViewUILogic } from './table-view-ui-logic.js';
export class MobileTableCell extends SignalWatcher(
WithDisposable(ShadowlessElement)
@@ -48,7 +48,7 @@ export class MobileTableCell extends SignalWatcher(
});
isSelectionEditing$ = computed(() => {
const selection = this.table?.props.selection$.value;
const selection = this.tableViewLogic.selection$.value;
if (selection?.selectionType !== 'area') {
return false;
}
@@ -68,8 +68,8 @@ export class MobileTableCell extends SignalWatcher(
if (this.view.readonly$.value) {
return;
}
const setSelection = this.table?.props.setSelection;
const viewId = this.table?.props.view.id;
const setSelection = this.tableViewLogic.setSelection;
const viewId = this.tableViewLogic.view.id;
if (setSelection && viewId) {
if (editing && this.cell?.beforeEnterEditMode() === false) {
return;
@@ -97,10 +97,6 @@ export class MobileTableCell extends SignalWatcher(
return this.closest('mobile-table-group')?.group?.key;
}
private get table() {
return this.closest('mobile-data-view-table');
}
override connectedCallback() {
super.connectedCallback();
if (this.column.readonly$.value) return;
@@ -160,7 +156,11 @@ export class MobileTableCell extends SignalWatcher(
accessor rowIndex!: number;
@property({ attribute: false })
accessor view!: SingleView;
accessor tableViewLogic!: MobileTableViewUILogic;
get view() {
return this.tableViewLogic.view;
}
}
declare global {
@@ -0,0 +1,15 @@
import { MobileTableCell } from './cell.js';
import { MobileTableColumnHeader } from './column-header.js';
import { MobileTableGroup } from './group.js';
import { MobileTableHeader } from './header.js';
import { MobileTableRow } from './row.js';
import { MobileTableViewUI } from './table-view-ui-logic.js';
export function mobileEffects() {
customElements.define('mobile-table-cell', MobileTableCell);
customElements.define('mobile-table-group', MobileTableGroup);
customElements.define('mobile-data-view-table-ui', MobileTableViewUI);
customElements.define('mobile-table-header', MobileTableHeader);
customElements.define('mobile-table-column-header', MobileTableColumnHeader);
customElements.define('mobile-table-row', MobileTableRow);
}
@@ -8,17 +8,14 @@ import { PlusIcon } from '@blocksuite/icons/lit';
import { ShadowlessElement } from '@blocksuite/std';
import { cssVarV2 } from '@toeverything/theme/v2';
import { css, html, unsafeCSS } from 'lit';
import { property, query } from 'lit/decorators.js';
import { property } from 'lit/decorators.js';
import { repeat } from 'lit/directives/repeat.js';
import type { DataViewRenderer } from '../../../core/data-view.js';
import { GroupTitle } from '../../../core/group-by/group-title.js';
import type { Group } from '../../../core/group-by/trait.js';
import type { Row } from '../../../core/index.js';
import { LEFT_TOOL_BAR_WIDTH } from '../consts.js';
import type { DataViewTable } from '../pc/table-view.js';
import { TableViewAreaSelection } from '../selection';
import type { TableSingleView } from '../table-view-manager.js';
import type { MobileTableViewUILogic } from './table-view-ui-logic.js';
const styles = css`
.data-view-table-group-add-row {
@@ -54,40 +51,10 @@ export class MobileTableGroup extends SignalWatcher(
private readonly clickAddRow = () => {
this.view.rowAdd('end', this.group?.key);
const selectionController = this.viewEle.selectionController;
selectionController.selection = undefined;
requestAnimationFrame(() => {
const index = this.view.properties$.value.findIndex(
v => v.type$.value === 'title'
);
selectionController.selection = TableViewAreaSelection.create({
groupKey: this.group?.key,
focus: {
rowIndex: this.rows.length - 1,
columnIndex: index,
},
isEditing: true,
});
});
};
private readonly clickAddRowInStart = () => {
this.view.rowAdd('start', this.group?.key);
const selectionController = this.viewEle.selectionController;
selectionController.selection = undefined;
requestAnimationFrame(() => {
const index = this.view.properties$.value.findIndex(
v => v.type$.value === 'title'
);
selectionController.selection = TableViewAreaSelection.create({
groupKey: this.group?.key,
focus: {
rowIndex: 0,
columnIndex: index,
},
isEditing: true,
});
});
};
private readonly clickGroupOptions = (e: MouseEvent) => {
@@ -150,8 +117,7 @@ export class MobileTableGroup extends SignalWatcher(
return html` <mobile-table-row
data-row-index="${idx}"
data-row-id="${row.rowId}"
.dataViewEle="${this.dataViewEle}"
.view="${this.view}"
.tableViewLogic="${this.tableViewLogic}"
.rowId="${row.rowId}"
.rowIndex="${idx}"
></mobile-table-row>`;
@@ -172,8 +138,6 @@ export class MobileTableGroup extends SignalWatcher(
${PlusIcon()}<span style="font-size: 12px">New Record</span>
</div>
</div>`}
<affine-database-column-stats .view="${this.view}" .group="${this.group}">
</affine-database-column-stats>
`;
}
@@ -181,20 +145,15 @@ export class MobileTableGroup extends SignalWatcher(
return this.renderRows(this.rows);
}
@property({ attribute: false })
accessor dataViewEle!: DataViewRenderer;
@property({ attribute: false })
accessor group: Group | undefined = undefined;
@query('.affine-database-block-rows')
accessor rowsContainer: HTMLElement | null = null;
@property({ attribute: false })
accessor view!: TableSingleView;
accessor tableViewLogic!: MobileTableViewUILogic;
@property({ attribute: false })
accessor viewEle!: DataViewTable;
get view() {
return this.tableViewLogic.view;
}
}
declare global {

Some files were not shown because too many files have changed in this diff Show More