Compare commits

...

110 Commits

Author SHA1 Message Date
zzj3720
9bee2cb0fa fix(editor): improve string conversion logic for checkbox property
- Add a FALSE_VALUES set containing various falsy string representations

- Support Chinese negation terms like "否", "不", "错", etc.

- Optimize the implementation of cellFromString method
2025-02-26 00:11:36 +08:00
zzj3720
1addd17d64 fix(editor): table block supports parsing rich text 2025-02-25 18:52:13 +08:00
darkskygit
842c39c3be feat(native): doc loader for common native (#9941) 2025-02-25 07:50:56 +00:00
EYHN
26674b0cb8 fix(core): fallback when loading share page (#10428) 2025-02-25 07:35:58 +00:00
EYHN
cafff4e0eb fix(nbstore): reduce unnecessary sync (#10426) 2025-02-25 07:21:46 +00:00
fundon
abc3f9f23f chore(editor): bump @floating-ui/dom to 1.6.13 (#10425) 2025-02-25 07:06:27 +00:00
Brooooooklyn
5dbffba08d feat(native): media capture (#9992) 2025-02-25 06:51:56 +00:00
EYHN
2ec7de7e32 fix(core): add linked doc button (#10417) 2025-02-25 13:03:56 +08:00
liuyi
e5e5c0a8ba perf(core): only full sync before exporting (#10408) 2025-02-25 04:41:56 +00:00
EYHN
c644a46b8d fix(nbstore): local doc update lost (#10422) 2025-02-25 04:26:49 +00:00
Peng Xiao
7e892b3a7e fix(core): unused blobs query (#10399) 2025-02-25 10:58:43 +08:00
JimmFly
848145150d fix(core): close popover after successful invite in member editor (#10388) 2025-02-25 09:51:22 +08:00
JimmFly
dee6be11fb fix(core): reorder plan card action button conditions (#10387) 2025-02-25 09:51:10 +08:00
JimmFly
abda70d2c8 fix(core): fix permission checks for export workspace (#10401) 2025-02-25 09:50:43 +08:00
Saul-Mirone
40104f2f87 refactor(editor): remove unused any convension (#10410) 2025-02-24 15:57:49 +00:00
fundon
162b7adc1b fix(editor): should check text length and stop event propagation when adding a link (#10391) 2025-02-24 11:10:05 +00:00
Saul-Mirone
6289981fd1 refactor(editor): optimize extension register and effects (#10406)
Key Changes:

1. **Code Reorganization and Consolidation**
   - Created new centralized extension management through new files:
     - `enableEditorExtension` in `extensions/entry/enable-editor.ts`
     - `enablePreviewExtension` in `extensions/entry/enable-preview.ts`
   - Removed several spec-related files that are now consolidated:
     - Removed `specs/edgeless.ts`
     - Removed `specs/page.ts`
     - Removed `specs/preview.ts`

2. **Template Management**
   - Added new `register-templates.ts` file to handle template registration
   - Moved template registration logic from `specs/edgeless.ts` to this new file
   - Templates now include both edgeless and sticker templates

3. **Extension Management Changes**
   - Simplified extension enabling process through new centralized functions
   - `enableEditorExtension` now handles both page and edgeless modes
   - `enablePreviewExtension` consolidates preview-related extensions
   - Removed duplicate code for extension management

4. **Preview Functionality Updates**
   - Streamlined preview spec management
   - Consolidated footnote configuration
   - Improved theme and preview extension handling

5. **Dependencies and Effects**
   - Updated how effects are registered and managed
   - Simplified initialization process in `index.ts`
   - More organized approach to handling framework providers

The main theme of this PR appears to be code consolidation and simplification, moving from multiple specialized files to more centralized, reusable extension management. This should make the codebase more maintainable and reduce duplication while keeping the same functionality.

The changes primarily affect the editor's extension system, preview functionality, and template management, making these systems more modular and easier to maintain.
2025-02-24 10:37:59 +00:00
EYHN
0e581c915c feat(core): add resetSync button (#10404) 2025-02-24 10:22:34 +00:00
EYHN
59a791fe1f fix(nbstore): fix doc sync logic (#10400) 2025-02-24 10:22:34 +00:00
donteatfriedrice
378bb3795d refactor(editor): use doc title and id as snapshot file name (#10397)
[BS-2549](https://linear.app/affine-design/issue/BS-2549/snap-shot-导出建议使用文档名称作为文件名,而不是一个-id)
2025-02-24 09:32:32 +00:00
Saul-Mirone
60b994f38b refactor(editor): modular custom specs (#10398)
Key Changes:

1. **Removal of Scroll Anchoring Widget**
- Removed the scroll anchoring widget import and its related implementation from `blocksuite/affine/block-root/src/common-specs/widgets.ts`

2. **Enhanced React-Lit Integration**
- Added `ReactWebComponent` type export in `packages/frontend/component/src/lit-react/index.ts`
- Refactored text renderer component to use React integration:
  - Added React import and created `LitTextRenderer` component using `createReactComponentFromLit`
  - Moved the component declaration to a more appropriate location

3. **AI Feature Flag Integration**
- Added feature flag check for AI functionality in `enableAIExtension`
- Only enables AI extensions if the `enable_ai` flag is true

4. **Component Restructuring**
- Moved several components and utilities to dedicated extension files
- Consolidated Lit adapter implementations
- Removed direct widget imports in favor of extension-based approach
- Reorganized editor component structure for better maintainability

5. **File Reorganization**
- Removed `specs/custom/spec-patchers.ts` and distributed its functionality across multiple extension files
- Created new extension files for various features like:
  - Attachment embed views
  - Doc mode service
  - Doc URL handling
  - Edgeless clipboard
  - Mobile support
  - Note configuration
  - Various service patches (notification, peek view, quick search, etc.)

6. **Mobile Support Improvements**
- Refactored mobile extension enablement to be more modular
- Moved mobile-specific widget omissions into a dedicated extension

7. **Type System Improvements**
- Added more specific type imports for editors and components
- Enhanced type safety across the codebase

This PR appears to be a significant refactoring effort focused on:
1. Improving code organization through better separation of concerns
2. Enhancing the integration between React and Lit components
3. Adding feature flag support for AI capabilities
4. Making the codebase more maintainable and modular
5. Improving mobile support
6. Strengthening type safety

The changes suggest a move towards a more extension-based architecture, where functionality is more clearly separated into distinct modules rather than being centralized in larger files.
2025-02-24 08:30:01 +00:00
donteatfriedrice
1b2a4377fd feat(editor): update footnote node style and config (#10392)
[BS-2581](https://linear.app/affine-design/issue/BS-2581/优化-footnote-node-正文样式)
2025-02-24 08:15:04 +00:00
CatsJuice
8b4175c44d chore(core): update free pricing plan description (#10393) 2025-02-24 07:37:30 +00:00
EYHN
da7ab51e2d fix(core): remove unnecessary doc loading (#10395) 2025-02-24 07:22:05 +00:00
EYHN
a59e640423 fix(nbstore): leave awareness when destroy (#10394) 2025-02-24 07:22:04 +00:00
doouding
9bb74bce6b fix: drag bookmark from note to edgeless (#10389) 2025-02-24 06:13:05 +00:00
doouding
a0a97d0751 fix: drag connector and group element (#10385) 2025-02-24 06:13:05 +00:00
forehalo
b9e3fc54fd fix(server): include check of prerelease versions (#10386) 2025-02-24 04:44:44 +00:00
forehalo
b71fe291d1 fix(core): version control session (#10384) 2025-02-24 04:44:43 +00:00
forehalo
f02b57d58b fix(server): too much redundant updates events (#10383) 2025-02-24 04:44:43 +00:00
forehalo
2e0f0c624a chore: set base version to 0.20 (#10382) 2025-02-24 04:44:42 +00:00
Saul-Mirone
9435118ef1 refactor(editor): optimize ai code structure (#10381)
Let me analyze this diff and provide a clear description of the changes.

This PR introduces several significant changes focused on AI integration and code organization in the AFFiNE codebase:

1. **Enhanced SpecBuilder Functionality** (`blocksuite/affine/shared/src/utils/spec/spec-builder.ts`):
   - Added method chaining by returning `this` from `extend`, `omit`, and `replace` methods
   - Added new utility methods:
     - `hasAll(target: ExtensionType[])`: Checks if all specified extensions exist
     - `hasOneOf(target: ExtensionType[])`: Checks if at least one specified extension exists

2. **AI Extensions Modularization**:
   - Split the large AI-related code into separate modular files under `packages/frontend/core/src/blocksuite/ai/extensions/`:
     - `ai-code.ts`: Code block AI integration
     - `ai-edgeless-root.ts`: Edgeless mode AI features
     - `ai-image.ts`: Image block AI capabilities
     - `ai-page-root.ts`: Page root AI integration
     - `ai-paragraph.ts`: Paragraph block AI features
     - `enable-ai.ts`: Central AI extension enablement logic

3. **Widget Improvements**:
   - Enhanced `AffineAIPanelWidget` and `EdgelessCopilotWidget` with proper widget extensions
   - Moved widget-specific extensions into their respective files
   - Added proper type definitions and component registrations

4. **Code Organization**:
   - Simplified exports in `index.ts`
   - Better separation of concerns between different AI-related components
   - More modular approach to AI feature integration

5. **AI Integration Architecture**:
   - Introduced a new `enableAIExtension` function that handles:
     - Replacing standard blocks with AI-enhanced versions
     - Conditional enabling of AI features based on the current spec configuration
     - Extension of AI chat capabilities

The changes primarily focus on improving code organization, maintainability, and the architecture of AI feature integration in the AFFiNE editor. The modularization will make it easier to maintain and extend AI capabilities across different block types and editor modes.
2025-02-24 04:30:08 +00:00
doodlewind
67889d9364 fix(editor): turbo renderer stale frame lag on zooming (#10376)
Before:

https://github.com/user-attachments/assets/593e91a3-042e-4619-93a0-dca21fa942aa

After:

https://github.com/user-attachments/assets/779d7582-f7b2-4135-a97a-d1f65c7cb467

This is only a bug fix that ensures correct baseline rendering result. There'll be more optimizations specific for zooming TBD.
2025-02-24 03:49:04 +00:00
pengx17
5fe4b2b3e4 fix(core): remove tag page semicolon (#10379) 2025-02-24 03:14:06 +00:00
donteatfriedrice
2d41c2ff8d chore: bump theme (#10358) 2025-02-24 10:08:47 +08:00
Flrande
9fd1ca1c09 refactor(editor): remove inline editor keyboard utils and add markdown property in rich-text (#10375) 2025-02-23 19:57:56 +08:00
Saul-Mirone
eef2f004b8 refactor(editor): reorg blocksuite ai code (#10372)
### TL;DR

Relocated AI-related code from `presets` directory to a dedicated `ai` directory for better organization and maintainability.

### What changed?

- Moved AI-related code from `blocksuite/presets/ai` to `blocksuite/ai`
- Relocated AI chat block code from `blocksuite/blocks` to `blocksuite/ai/blocks`
- Updated imports across files to reflect new directory structure
- Renamed `registerBlocksuitePresetsCustomComponents` to `registerAIEffects`
- Fixed path references in GitHub workflow file

### How to test?

1. Build and run the application
2. Verify AI functionality works as expected:
   - Test AI chat blocks
   - Check AI panel functionality
   - Verify AI copilot features
   - Ensure AI-related UI components render correctly

### Why make this change?

This restructuring improves code organization by:
- Giving AI features a dedicated directory that better reflects their importance
- Making the codebase more maintainable by grouping related AI functionality
- Reducing confusion by removing AI code from the more general `presets` directory
- Creating clearer boundaries between AI and non-AI related code
2025-02-23 09:26:00 +00:00
doodlewind
542f759ffb refactor(editor): add panning/zooming field in viewport event (#10373) 2025-02-23 08:58:15 +00:00
doodlewind
22f9db63bc refactor(editor): invalidate support in turbo renderer (#10368)
refactor(editor): invalidate support in turbo renderer

- Added `invalidate()` method to clear cache and canvas
- Simplified debug pane controls to single invalidate button
- Replaced layout update with refresh debounce on block updates
- Improved cache handling and bitmap drawing flow

refactor: refresh after invalidate
2025-02-23 03:23:20 +00:00
Saul-Mirone
f8cabe8bb1 refactor: move ai-item components to frontend core (#10369)
### TL;DR

Relocated AI item components from BlockSuite to the frontend codebase and updated related imports.

### What changed?

- Moved AI item components from `blocksuite/affine/components/src/ai-item` to `packages/frontend/core/src/blocksuite/presets/ai/_common/components/ai-item`
- Updated all imports referencing the old AI item component location to point to the new location
- Removed AI item exports from BlockSuite's package.json and effects registration
- Added AI item effects registration to frontend presets

### How to test?

1. Verify AI functionality works as expected in:
   - Chat panels
   - AI toolbars
   - Edgeless copilot
   - Slash menu
2. Confirm no AI-related console errors appear
3. Test error handling scenarios (unauthorized, payment required, network errors)

### Why make this change?

This change consolidates AI-related components into the frontend codebase where they are primarily used, rather than keeping them in BlockSuite. This improves code organization by placing components closer to their implementation and usage, while reducing unnecessary coupling between packages.
2025-02-22 17:03:07 +00:00
Saul-Mirone
3ff6176306 refactor(editor): extract ai widgets and tool (#10367)
### TL;DR
Moved AI-related components from BlockSuite core to the frontend presets directory to better organize AI functionality.

### What changed?
- Relocated AI panel, copilot tool, and related components from BlockSuite core to frontend presets
- Moved AI widget definitions and registrations to the presets directory
- Updated imports to reference new component locations
- Removed AI component registrations from core effects.ts
- Added AI component registrations to presets effects.ts

### How to test?
1. Verify AI panel functionality works as expected in the editor
2. Test copilot tool interactions in edgeless mode
3. Confirm AI suggestions and responses still appear correctly
4. Check that AI toolbar buttons and menus function properly
5. Ensure AI error states and loading indicators display correctly

### Why make this change?
This restructuring improves code organization by moving AI-specific functionality out of the core BlockSuite library and into the frontend presets where it more logically belongs. This separation of concerns makes the codebase more maintainable and allows for better modularity of AI features.
2025-02-22 13:58:40 +00:00
Yifeng Wang
963cc2e40e refactor(editor): reduce redundant canvas refresh on init (#10364) 2025-02-22 21:58:13 +08:00
Saul-Mirone
04ed2bdab7 refactor(editor): remove edgeless service in ai widgets (#10361) 2025-02-22 08:55:44 +00:00
renovate
77d31ea25a chore: bump up eslint-plugin-unicorn version to v57 (#10234)
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [eslint-plugin-unicorn](https://redirect.github.com/sindresorhus/eslint-plugin-unicorn) | [`^56.0.1` -> `^57.0.0`](https://renovatebot.com/diffs/npm/eslint-plugin-unicorn/56.0.1/57.0.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/eslint-plugin-unicorn/57.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/eslint-plugin-unicorn/57.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/eslint-plugin-unicorn/56.0.1/57.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/eslint-plugin-unicorn/56.0.1/57.0.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>sindresorhus/eslint-plugin-unicorn (eslint-plugin-unicorn)</summary>

### [`v57.0.0`](https://redirect.github.com/sindresorhus/eslint-plugin-unicorn/compare/v56.0.1...v57.0.0)

[Compare Source](https://redirect.github.com/sindresorhus/eslint-plugin-unicorn/compare/v56.0.1...v57.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:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNjcuMSIsInVwZGF0ZWRJblZlciI6IjM5LjE2Ny4xIiwidGFyZ2V0QnJhbmNoIjoiY2FuYXJ5IiwibGFiZWxzIjpbImRlcGVuZGVuY2llcyJdfQ==-->
2025-02-22 05:48:13 +00:00
Saul-Mirone
7945e1ed9f refactor: organize component registration by category (#10360)
### TL;DR
Reorganized component registration in the effects module by grouping related components into separate functions.

### What changed?
- Split the monolithic component registration into logical categories:
  - Root components (page, preview, edgeless)
  - Widgets (panels, toolbars, modals)
  - Edgeless toolbar components (tools, menus, buttons)
  - Edgeless panel components (alignment, color, style)
  - Edgeless editor components (text editors, label editors)
  - AI components (panels, placeholders)
  - Misc components (modals, loading, previews)
- Added descriptive comments for each component group
- Maintained all existing component registrations while improving code organization

### How to test?
1. Launch the application
2. Verify all components render correctly:
   - Check page/preview/edgeless views
   - Test toolbar functionality
   - Verify panels and modals work
   - Ensure AI features function properly
   - Validate edgeless editor capabilities

### Why make this change?
Improves code maintainability and readability by:
- Grouping related components together
- Making it easier to find and modify specific component registrations
- Providing better structure for future component additions
- Reducing cognitive load when working with component registrations
2025-02-21 15:50:56 +00:00
donteatfriedrice
734ca154ae refactor(core): use image preview component in chat (#10357)
[BS-2421](https://linear.app/affine-design/issue/BS-2421/chat-block-and-chat-panel-input-render-images-时存在内存泄露风险)
2025-02-21 15:36:55 +00:00
Saul-Mirone
2cf9a8f286 refactor: reorganize specs and adapter extensions (#10359)
### TL;DR
Refactored `SpecProvider` singleton access pattern and reorganized adapter/extension code structure.

### What changed?
- Changed `SpecProvider.getInstance()` to `SpecProvider._` for cleaner singleton access
- Moved adapter/extension code from `_common` directory to dedicated `adapters` and `extensions` folders
- Consolidated adapter extensions into a single file
- Removed unused dependencies from package.json
- Deleted unnecessary schema files
- Extracted `MobileSpecsPatches` class into the mobile patching code
- Updated all references to use the new `SpecProvider._` accessor

### How to test?
- Verify all specs are properly registered and accessible via `SpecProvider._`
- Test adapter functionality for HTML, Markdown, Notion HTML and plain text
- Check mobile-specific features and patches work correctly
- Ensure preview functionality works in both page and edgeless modes

### Why make this change?
- Improves code organization by properly separating adapters and extensions
- Simplifies singleton access pattern
- Removes unnecessary dependencies and files
- Makes the codebase more maintainable by consolidating related functionality
2025-02-21 14:25:35 +00:00
L-Sun
72b751943c fix(editor): using click event instead of pointerDown event for page block (#10351)
Close [BS-2647](https://linear.app/affine-design/issue/BS-2647/ios返回手势会误触发focus导致弹起键盘)

### What Changes:
- Using `click` event instead of `pointerDown` event to handle selection logic in page block, because gestures on mobile devices can trigger the `pointerDown` event, causing the cursor to update and unexpectedly bring up the virtual keyboard.
2025-02-21 13:19:51 +00:00
akumatus
07cbf5affe fix(core): slash ask ai returns make it real action result (#10349)
Fix issue [AF-2252](https://linear.app/affine-design/issue/AF-2252).

## What Changed?
- Remove useless `generateAnswer` configuration for inline ask ai
- Refactor the common `updateAIPanelConfig` function
- Use empty string instead of meaningless `placeholder` string
- Remove unnecessary high-order function wrappers
2025-02-21 12:52:53 +00:00
Saul-Mirone
55651503df refactor(editor): extract root block (#10356)
Closes: [BS-2207](https://linear.app/affine-design/issue/BS-2207/move-root-block-to-affineblock-root)
2025-02-21 12:38:26 +00:00
EYHN
4a66ec7400 fix(nbstore): fix doc clock check logic (#10355) 2025-02-21 11:10:16 +00:00
liuyi
7d68aa5b2f chore(server): ignore erorr when join joint room (#10354) 2025-02-21 10:48:53 +00:00
CatsJuice
64370980b3 fix(core): ensure the divider between cloud and local is displayed correctly (#10352) 2025-02-21 10:27:53 +00:00
pengx17
6e399ce34b fix(core): unused blobs query (#10350)
The default limit is 100.
2025-02-21 10:14:00 +00:00
zzj3720
4d759766b9 fix(editor): adjust the style of the table block (#10348) 2025-02-21 09:32:01 +00:00
Peng Xiao
83669f8fbb fix(core): settings storage empty styles (#10313) 2025-02-21 17:19:53 +08:00
DarkSky
24fa58df52 fix: quota switch (#10347) 2025-02-21 17:18:30 +08:00
Peng Xiao
dff68b9aae fix(core): blocksuite editor runtime configs in correct timing (#10344) 2025-02-21 17:16:53 +08:00
Cats Juice
09cc5c392b refactor(core): new workspace selector and create dialog (#10323) 2025-02-21 17:16:38 +08:00
Saul-Mirone
22e4bd8c20 refactor: move image proxy middleware and adapter extensions (#10345)
### TL;DR
Moved image proxy middleware and adapter extensions to their respective packages and introduced a new spec provider for adapter registration.

### What changed?
- Relocated `defaultImageProxyMiddleware` from blocks to `@blocksuite/affine-block-image`
- Moved `PresentTool` from fragment-frame-panel to block-frame
- Created new adapter extension specs for HTML, Markdown, and Notion HTML
- Introduced a spec provider pattern for adapter registration
- Removed direct transformer references from RootService
- Updated imports across affected files to use new locations

### How to test?
1. Verify image proxy functionality works in exports and imports
2. Test HTML, Markdown, and Notion HTML adapters still function correctly
3. Confirm presentation mode works with the relocated PresentTool
4. Check that all file import/export operations continue to work as expected

### Why make this change?
This reorganization improves code modularity by placing features in their logical packages and introduces a more maintainable pattern for adapter registration. The spec provider pattern makes it easier to manage and extend adapter functionality while reducing coupling between components.
2025-02-21 09:01:57 +00:00
darkskygit
296d88f721 fix: ignore unknown charset (#10346) 2025-02-21 08:36:27 +00:00
EYHN
244d683d83 fix(nbstore): adjust doc sync logic (#10342) 2025-02-21 08:17:07 +00:00
Saul-Mirone
f3218ab3bc refactor(editor): rename presets to integration test (#10340) 2025-02-21 06:26:03 +00:00
L-Sun
f79324b6a1 chore(editor): update shadow of ask-ai-panel (#10336)
Close [PD-2343](https://linear.app/affine-design/issue/PD-2343/[ui]-ai-面板-shadow-改为-overlaypanelshadow)
2025-02-21 06:12:05 +00:00
Saul-Mirone
adcc6b578c refactor(editor): move editor components to frontend core (#10335)
### TL;DR
Moved editor components from BlockSuite presets to AFFiNE core and updated imports accordingly.

### What changed?
- Relocated `EdgelessEditor` and `PageEditor` components from BlockSuite presets to AFFiNE core
- Removed basic editor examples from playground
- Updated import paths across the codebase to reference new component locations
- Added editor effects registration in AFFiNE core
- Removed editor exports from BlockSuite presets

### How to test?
1. Launch the application
2. Verify both page and edgeless editors load correctly
3. Confirm editor functionality remains intact including:
   - Document editing
   - Mode switching
   - Editor toolbars and controls
   - Multiple editor instances

### Why make this change?
This change better aligns with AFFiNE's architecture by moving editor components closer to where they are used. It reduces coupling with BlockSuite presets and gives AFFiNE more direct control over editor customization and implementation.
2025-02-21 04:28:54 +00:00
fengmk2
7f833f8c15 fix(server): don't sync blob meta on workspace deleted event (#10334)
close CLOUD-128
2025-02-21 04:11:57 +00:00
JimmFly
785951bbfa fix(core): adjust copy link button styles (#10337)
close PD-2344
![CleanShot 2025-02-21 at 11 22 32@2x](https://github.com/user-attachments/assets/97d1052b-c900-47df-89ba-476787a28587)
![CleanShot 2025-02-21 at 11 22 08@2x](https://github.com/user-attachments/assets/2b455797-dfc8-4572-95ac-3ee8b33b0528)
2025-02-21 03:58:03 +00:00
fundon
19e9f970f4 fix(editor): block selected style in note under edgeless (#10326)
Related to: https://github.com/toeverything/AFFiNE/pull/9849

Currently missing selected style in note under edgeless.
<img width="860" alt="Screenshot 2025-02-20 at 20 51 12" src="https://github.com/user-attachments/assets/77d68cfb-13d0-4e09-a567-f2a30ba72db1" />
2025-02-21 03:43:54 +00:00
doodlewind
c362737441 perf(editor): reduce dom ops in viewport update (#10333) 2025-02-21 03:30:10 +00:00
EYHN
618042812b fix(nbstore): fix cloud awareness (#10320) 2025-02-21 11:11:10 +08:00
fengmk2
0ff7c5f897 fix(server): gen new request id on websocket event request (#10330)
After

![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/hTwOityLamd4hitrae7M/22431b9a-30e8-48a3-8db6-de377671f9b7.png)
2025-02-21 02:00:58 +00:00
Saul-Mirone
b8dcb85007 refactor: move outline fragment to separate package (#10331)
### TL;DR

Moved outline functionality into a dedicated fragment package and updated vanilla-extract CSS dependency.

### What changed?

- Created new `@blocksuite/affine-fragment-outline` package
- Relocated outline-related code from presets to the new fragment package
- Updated imports across affected files to reference the new package location
- Upgraded `@vanilla-extract/css` dependency from 1.14.0/1.16.1 to 1.17.0
- Added necessary package configuration and TypeScript setup for the new fragment

### How to test?

1. Verify outline functionality works as expected in both desktop and mobile views
2. Check that outline panel, viewer, and mobile menu components render correctly
3. Ensure outline navigation and interactions continue to work
4. Confirm no regressions in outline-related features

### Why make this change?

This change improves code organization by isolating outline functionality into a dedicated package, following the modular architecture pattern. This makes the codebase more maintainable and allows for better separation of concerns. The vanilla-extract CSS upgrade ensures consistency across packages and provides access to the latest features and fixes.
2025-02-20 15:59:13 +00:00
Saul-Mirone
5ac15f12e6 refactor: replace editor container with editor host (#10328)
### TL;DR
Refactored editor access to use `EditorHost` instead of `AffineEditorContainer` and updated mode access through `DocModeProvider`.

### What changed?
- Changed editor property types from `AffineEditorContainer` to `EditorHost` across multiple components
- Updated mode access to use `DocModeProvider` service instead of direct editor mode access
- Modified editor references to use `editor.host` where appropriate
- Updated scroll and highlight utilities to work with `EditorHost`

### How to test?
1. Open a document in both page and edgeless modes
2. Verify outline panel functionality works as expected
3. Test outline viewer navigation and highlighting
4. Confirm mobile outline menu operates correctly
5. Check that frame panel and TOC features work in all modes

### Why make this change?
This change improves architectural consistency by using `EditorHost` directly and accessing mode through the proper service provider. This makes the code more maintainable and follows better dependency practices by using the correct abstraction levels.
2025-02-20 14:20:32 +00:00
akumatus
efe36161e8 fix(core): remove candidate doc chip suggestions (#10327)
Fix issue [AF-2247](https://linear.app/affine-design/issue/AF-2247).
2025-02-20 14:01:00 +00:00
akumatus
126677d7ad fix(core): no pop-ups if user click discard menu item (#10317)
Fix issue [BS-2628](https://linear.app/affine-design/issue/BS-2628).
2025-02-20 13:29:28 +00:00
Saul-Mirone
007bbabce4 refactor: move frame manager and panel to separate packages (#10324)
### TL;DR
Moved frame management functionality from `blocksuite/blocks` to `@blocksuite/affine-block-frame` package.

### What changed?
- Relocated `frame-manager.ts` from `blocksuite/blocks` to `@blocksuite/affine-block-frame`
- Added new dependencies to block-frame package: `@blocksuite/affine-block-surface` and `yjs`
- Updated imports across multiple components to reference frame manager from its new location
- Moved utility functions `areSetsEqual` and `isFrameBlock` into frame-manager file
- Replaced direct EdgelessRootService references with GfxController in frame panel components

### How to test?
1. Verify frame functionality works in edgeless mode
2. Test frame creation, selection, and manipulation
3. Confirm frame navigation and presentation modes operate correctly
4. Check that frame panel and toolbar interactions remain functional

### Why make this change?
This refactoring improves code organization by consolidating frame-related functionality into a dedicated package, making the codebase more modular and easier to maintain. It also reduces dependencies between packages and provides clearer boundaries for frame-related features.
2025-02-20 13:06:40 +00:00
doodlewind
64cc99354e refactor(editor): add zoom threshold for dom rendering fallback (#10322) 2025-02-20 11:45:19 +00:00
Saul-Mirone
1516903c77 refactor: move doc-title and ai-chat-block components (#10316)
### TL;DR
Moved doc title and AI chat block components to more appropriate locations while removing unused backlink functionality.

### What changed?
- Relocated doc title component from presets to affine-components
- Moved AI chat block from presets/blocks to blocks directory
- Removed unused backlink-related code and components
- Updated imports across files to reference new component locations
- Consolidated AI-related exports through a single entry point

### How to test?
1. Verify doc title still renders correctly in documents
2. Confirm AI chat functionality works as expected
3. Check that no backlink-related features are accessible
4. Ensure all AI features continue to work through the new import paths

### Why make this change?
This reorganization improves code organization by:
- Placing components closer to their related functionality
- Removing dead/unused code around backlinks
- Simplifying the import structure for AI-related features
- Making the codebase more maintainable by consolidating related components
2025-02-20 10:45:47 +00:00
EYHN
4f831732e1 fix(core): fix throw if aborted polyfill (#10321) 2025-02-20 10:32:02 +00:00
zzj3720
ef28e36441 fix(editor): data in the database will be completely overwritten in some cases (#10318) 2025-02-20 10:17:57 +00:00
doodlewind
7b1dfb7ee8 refactor(editor): reduce dom query per refresh (#10319) 2025-02-20 10:01:13 +00:00
Hwang
5fcc402280 style: update ios dark icon (#10312) 2025-02-20 08:01:32 +00:00
DarkSky
fa86f71853 feat(server): client version check (#9205)
Co-authored-by: forehalo <forehalo@gmail.com>
2025-02-20 15:50:22 +08:00
L-Sun
4fee2a9c4b chore(editor): update some widget styles (#10311) 2025-02-20 15:39:48 +08:00
fengmk2
b4097aef8e refactor(server): move bin content parser to doc reader (#10302) 2025-02-20 07:19:48 +00:00
Saul-Mirone
9f4311f654 refactor(editor): remove AbstractEditor type and feature flags in test (#10308) 2025-02-20 07:05:35 +00:00
darkskygit
13f1859cdf feat: allow retry with new message (#10307)
fix AF-1630
2025-02-20 06:07:53 +00:00
Flrande
50820482df fix(editor): auto focus after add inline latex (#10309)
https://github.com/user-attachments/assets/09e713ee-e600-464c-8614-d874d343cfb0

Close #10208
2025-02-20 05:52:06 +00:00
forehalo
ec67d30b27 chore(server): race condition during fixing doc owner (#10303) 2025-02-20 05:34:55 +00:00
forehalo
fd5897dbe6 chore(server): disable nightly subscriptions expirasion check (#10298) 2025-02-20 05:34:54 +00:00
liuyi
d490e767eb fix(server): wrong previous subscription check (#10306) 2025-02-20 13:33:49 +08:00
fundon
adc003862b fix(editor): image size and xywh when converting attachment to image (#10200)
In Edgeless, the image size should be read when converting attachment to image:

* fix `size`
* fix `xywh`
2025-02-20 05:16:21 +00:00
fengmk2
ff0ce1a962 fix(server): remove job on complete (#10305) 2025-02-20 04:39:05 +00:00
EYHN
5042d9f644 fix(nbstore): check before save empty update (#10304) 2025-02-20 04:24:50 +00:00
JimmFly
1d339c682b fix(core): adjust share menu and upgrade-to-team page style (#10299)
close PD-2330 PD-2331 AF-2238
2025-02-20 04:10:52 +00:00
doodlewind
b38abcb59c perf(editor): avoid recreation of Intl.Segmenter (#10295)
<img width="537" alt="image" src="https://github.com/user-attachments/assets/43e54d94-6228-4c26-b3d0-cf4725b251e4" />
2025-02-20 03:55:57 +00:00
Saul-Mirone
c3fc0a0d88 chore(editor): fix imports in legacy tests (#10300) 2025-02-20 03:30:05 +00:00
fengmk2
e0b2b2b33c fix(server): convert error type to lower case (#10301) 2025-02-20 03:04:21 +00:00
zzj3720
ba91b36cc3 feat(editor): add block creation tracking (#10294)
fix: PD-2090
2025-02-20 02:25:29 +00:00
github-actions[bot]
a0e3f9909c chore(i18n): sync translations (#10184)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-02-20 02:25:19 +00:00
EYHN
8f6ce2c3b4 fix(nbstore): fix doc clock comparison (#10296) 2025-02-20 10:10:17 +08:00
zzj3720
d8435421d2 fix(editor): improve table selection in edgeless mode (#10293)
fix: BS-2614, BS-2560
2025-02-20 01:50:40 +00:00
doodlewind
676ccc9094 refactor(editor): allow force refresh in worker renderer (#10289) 2025-02-19 14:23:45 +00:00
Saul-Mirone
091ba7bb51 chore: remove createEmptyEditor legacy test misc (#10291) 2025-02-19 21:38:00 +08:00
donteatfriedrice
2b11941c0e chore: bump theme (#10290) 2025-02-19 11:37:19 +00:00
forehalo
02f567f2c0 chore(core): better doc action error message (#10288) 2025-02-19 10:38:38 +00:00
donteatfriedrice
54b7515167 fix(editor): log when export blob failed (#10287) 2025-02-19 10:06:50 +00:00
CatsJuice
e726df9a1b fix(core): prevent all-docs header from overlapping scrollbar (#10270) 2025-02-19 09:24:49 +00:00
CatsJuice
926b35c91f chore(core): temporarily hide editor starter-bar on mobile (#10237) 2025-02-19 09:10:26 +00:00
JimmFly
b456feee63 fix(core): unexpected redirect to expired page after accepting invitation (#10257)
Co-authored-by: EYHN <cneyhn@gmail.com>
2025-02-19 09:10:12 +00:00
1314 changed files with 21445 additions and 8453 deletions

1
.github/CODEOWNERS vendored
View File

@@ -1 +1,2 @@
/blocksuite/ @toeverything/blocksuite-core
/packages/frontend/core/src/blocksuite @toeverything/blocksuite-core

View File

@@ -3,4 +3,4 @@ name: affine
description: AFFiNE cloud chart
type: application
version: 0.0.0
appVersion: "0.19.0"
appVersion: "0.20.0"

View File

@@ -3,7 +3,7 @@ name: graphql
description: AFFiNE GraphQL server
type: application
version: 0.0.0
appVersion: "0.19.0"
appVersion: "0.20.0"
dependencies:
- name: gcloud-sql-proxy
version: 0.0.0

View File

@@ -3,7 +3,7 @@ name: sync
description: AFFiNE Sync Server
type: application
version: 0.0.0
appVersion: "0.19.0"
appVersion: "0.20.0"
dependencies:
- name: gcloud-sql-proxy
version: 0.0.0

View File

@@ -624,8 +624,7 @@ jobs:
with:
filters: |
changed:
- 'packages/frontend/core/src/blocksuite/presets/ai/**'
- 'packages/frontend/core/src/components/blocksuite/block-suite-editor/ai/**'
- 'packages/frontend/core/src/blocksuite/ai/**'
- 'tests/affine-cloud-copilot/**'
- name: Setup Node.js

1327
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -15,8 +15,12 @@ affine_common = { path = "./packages/common/native" }
affine_nbstore = { path = "./packages/frontend/native/nbstore" }
anyhow = "1"
base64-simd = "0.8"
block2 = "0.6"
chrono = "0.4"
core-foundation = "0.10"
coreaudio-rs = "0.12"
criterion2 = { version = "2", default-features = false }
dispatch2 = "0.2"
dotenvy = "0.15"
file-format = { version = "0.26", features = ["reader"] }
homedir = "0.3"
@@ -31,6 +35,8 @@ once_cell = "1"
parking_lot = "0.12"
rand = "0.9"
rayon = "1.10"
rubato = "0.16"
screencapturekit = "0.3"
serde = "1"
serde_json = "1"
sha3 = "0.10"

View File

@@ -17,7 +17,6 @@
"@blocksuite/blocks": "workspace:*",
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/presets": "workspace:*",
"@blocksuite/store": "workspace:*",
"@blocksuite/sync": "workspace:*"
},
@@ -37,7 +36,6 @@
"./inline": "./src/inline/index.ts",
"./inline/consts": "./src/inline/consts.ts",
"./inline/types": "./src/inline/types.ts",
"./presets": "./src/presets/index.ts",
"./blocks": "./src/blocks/index.ts",
"./blocks/schemas": "./src/blocks/schemas.ts",
"./sync": "./src/sync/index.ts"
@@ -83,9 +81,6 @@
"inline/types": [
"dist/inline/types.d.ts"
],
"presets": [
"dist/presets/index.d.ts"
],
"blocks": [
"dist/blocks/index.d.ts"
],
@@ -103,5 +98,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -1,7 +1,5 @@
import { effects as blocksEffects } from '@blocksuite/blocks/effects';
import { effects as presetsEffects } from '@blocksuite/presets/effects';
export function effects() {
blocksEffects();
presetsEffects();
}

View File

@@ -1 +0,0 @@
export * from '@blocksuite/presets';

View File

@@ -11,7 +11,6 @@
{ "path": "../../blocks" },
{ "path": "../../framework/global" },
{ "path": "../../framework/inline" },
{ "path": "../../presets" },
{ "path": "../../framework/store" },
{ "path": "../../framework/sync" }
]

View File

@@ -23,10 +23,10 @@
"@blocksuite/icons": "^2.2.1",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"file-type": "^20.0.0",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -42,5 +42,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -38,8 +38,6 @@ export class AttachmentBlockComponent extends CaptionedBlockComponent<Attachment
protected _isResizing = false;
protected _isSelected = false;
protected _whenHover: HoverController | null = new HoverController(
this,
({ abortController }) => {

View File

@@ -35,7 +35,7 @@ export class AttachmentEdgelessBlockComponent extends toGfxBlockComponent(
this.slots.elementResizeEnd.on(() => {
this._isResizing = false;
this._showOverlay =
this._isResizing || this._isDragging || !this._isSelected;
this._isResizing || this._isDragging || !this.selected$.peek();
})
);
}

View File

@@ -1,20 +1,25 @@
import type {
AttachmentBlockModel,
ImageBlockProps,
import {
type AttachmentBlockModel,
type ImageBlockProps,
MAX_IMAGE_WIDTH,
} from '@blocksuite/affine-model';
import { FileSizeLimitService } from '@blocksuite/affine-shared/services';
import {
readImageSize,
transformModel,
withTempBlobData,
} from '@blocksuite/affine-shared/utils';
import { type BlockStdScope, StdIdentifier } from '@blocksuite/block-std';
import type { Container } from '@blocksuite/global/di';
import { createIdentifier } from '@blocksuite/global/di';
import { Bound } from '@blocksuite/global/utils';
import type { ExtensionType } from '@blocksuite/store';
import { Extension } from '@blocksuite/store';
import type { TemplateResult } from 'lit';
import { html } from 'lit';
import { getAttachmentBlob } from './utils';
export type AttachmentEmbedConfig = {
name: string;
/**
@@ -24,7 +29,10 @@ export type AttachmentEmbedConfig = {
/**
* The action will be executed when the 「Turn into embed view」 button is clicked.
*/
action?: (model: AttachmentBlockModel) => Promise<void> | void;
action?: (
model: AttachmentBlockModel,
std: BlockStdScope
) => Promise<void> | void;
/**
* The template will be used to render the embed view.
*/
@@ -89,11 +97,11 @@ export class AttachmentEmbedService extends Extension {
// Converts to embed view.
convertTo(model: AttachmentBlockModel, maxFileSize = this._maxFileSize) {
const config = this.values.find(config => config.check(model, maxFileSize));
if (!config || !config.action) {
if (!config?.action) {
model.doc.updateBlock(model, { embed: true });
return;
}
config.action(model)?.catch(console.error);
config.action(model, this.std)?.catch(console.error);
}
embedded(model: AttachmentBlockModel, maxFileSize = this._maxFileSize) {
@@ -123,7 +131,12 @@ const embedConfig: AttachmentEmbedConfig[] = [
check: model =>
model.doc.schema.flavourSchemaMap.has('affine:image') &&
model.type.startsWith('image/'),
action: model => turnIntoImageBlock(model),
async action(model, std) {
const component = std.view.getBlock(model.id);
if (!component) return;
await turnIntoImageBlock(model);
},
},
{
name: 'pdf',
@@ -171,7 +184,7 @@ const embedConfig: AttachmentEmbedConfig[] = [
/**
* Turn the attachment block into an image block.
*/
export function turnIntoImageBlock(model: AttachmentBlockModel) {
export async function turnIntoImageBlock(model: AttachmentBlockModel) {
if (!model.doc.schema.flavourSchemaMap.has('affine:image')) {
console.error('The image flavour is not supported!');
return;
@@ -183,15 +196,37 @@ export function turnIntoImageBlock(model: AttachmentBlockModel) {
const { saveAttachmentData, getImageData } = withTempBlobData();
saveAttachmentData(sourceId, { name: model.name });
const imageConvertData = model.sourceId
? getImageData(model.sourceId)
let imageSize = model.sourceId ? getImageData(model.sourceId) : undefined;
const bounds = model.xywh
? Bound.fromXYWH(model.deserializedXYWH)
: undefined;
if (bounds) {
if (!imageSize?.width || !imageSize?.height) {
const blob = await getAttachmentBlob(model);
if (blob) {
imageSize = await readImageSize(blob);
}
}
if (imageSize?.width && imageSize?.height) {
const p = imageSize.height / imageSize.width;
imageSize.width = Math.min(imageSize.width, MAX_IMAGE_WIDTH);
imageSize.height = imageSize.width * p;
bounds.w = imageSize.width;
bounds.h = imageSize.height;
}
}
const others = bounds ? { xywh: bounds.serialize() } : undefined;
const imageProp: Partial<ImageBlockProps> = {
sourceId,
caption: model.caption,
size: model.size,
...imageConvertData,
...imageSize,
...others,
};
transformModel(model, 'affine:image', imageProp);
}

View File

@@ -97,7 +97,7 @@ export async function uploadAttachmentBlob(
}
}
async function getAttachmentBlob(model: AttachmentBlockModel) {
export async function getAttachmentBlob(model: AttachmentBlockModel) {
const sourceId = model.sourceId;
if (!sourceId) {
return null;

View File

@@ -22,10 +22,10 @@
"@blocksuite/icons": "^2.2.1",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
"zod": "^3.23.8"
@@ -40,5 +40,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -4,9 +4,10 @@ import {
} from '@blocksuite/affine-components/caption';
import type { BookmarkBlockModel } from '@blocksuite/affine-model';
import { DocModeProvider } from '@blocksuite/affine-shared/services';
import { computed, type ReadonlySignal } from '@preact/signals-core';
import { html } from 'lit';
import { property, query } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { type ClassInfo, classMap } from 'lit/directives/class-map.js';
import { type StyleInfo, styleMap } from 'lit/directives/style-map.js';
import { refreshBookmarkUrlData } from './utils.js';
@@ -14,6 +15,12 @@ import { refreshBookmarkUrlData } from './utils.js';
export const BOOKMARK_MIN_WIDTH = 450;
export class BookmarkBlockComponent extends CaptionedBlockComponent<BookmarkBlockModel> {
selectedStyle$: ReadonlySignal<ClassInfo> | null = computed<ClassInfo>(
() => ({
'selected-style': this.selected$.value,
})
);
private _fetchAbortController?: AbortController;
blockDraggable = true;
@@ -69,16 +76,12 @@ export class BookmarkBlockComponent extends CaptionedBlockComponent<BookmarkBloc
}
override renderBlock() {
const selected = this.selected$.value;
const isInEdgeless =
this.std.get(DocModeProvider).getEditorMode() === 'edgeless';
return html`
<div
draggable="${this.blockDraggable ? 'true' : 'false'}"
class=${classMap({
'affine-bookmark-container': true,
'selected-style': selected && !isInEdgeless,
...this.selectedStyle$?.value,
})}
style=${this.containerStyleMap}
>

View File

@@ -10,6 +10,8 @@ import { BookmarkBlockComponent } from './bookmark-block.js';
export class BookmarkEdgelessBlockComponent extends toGfxBlockComponent(
BookmarkBlockComponent
) {
override selectedStyle$ = null;
override blockDraggable = false;
override getRenderingRect() {

View File

@@ -21,10 +21,10 @@
"@blocksuite/icons": "^2.2.3",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -41,5 +41,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -23,10 +23,10 @@
"@blocksuite/icons": "^2.2.3",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -42,5 +42,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -23,10 +23,10 @@
"@blocksuite/icons": "^2.2.1",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"@types/mdast": "^4.0.4",
"date-fns": "^4.0.0",
"lit": "^3.2.0",
@@ -44,5 +44,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -1,9 +1,9 @@
import { DatabaseBlockSchema } from '@blocksuite/affine-model';
import {
AdapterTextUtils,
BlockNotionHtmlAdapterExtension,
type BlockNotionHtmlAdapterMatcher,
HastUtils,
TextUtils,
} from '@blocksuite/affine-shared/adapters';
import { getTagColor } from '@blocksuite/data-view';
import { type BlockSnapshot, nanoid } from '@blocksuite/store';
@@ -219,7 +219,7 @@ export const databaseBlockNotionHtmlAdapterMatcher: BlockNotionHtmlAdapterMatche
column.type = 'rich-text';
row[column.id] = {
columnId: column.id,
value: TextUtils.createText(text),
value: AdapterTextUtils.createText(text),
};
} else {
row[column.id] = {
@@ -235,11 +235,11 @@ export const databaseBlockNotionHtmlAdapterMatcher: BlockNotionHtmlAdapterMatche
}
if (
column.type === 'rich-text' &&
!TextUtils.isText(row[column.id].value)
!AdapterTextUtils.isText(row[column.id].value)
) {
row[column.id] = {
columnId: column.id,
value: TextUtils.createText(row[column.id].value),
value: AdapterTextUtils.createText(row[column.id].value),
};
}
});

View File

@@ -34,8 +34,6 @@ import {
} from './properties/index.js';
import {
addProperty,
applyCellsUpdate,
applyPropertyUpdate,
copyCellsByProperty,
deleteRows,
deleteView,
@@ -169,7 +167,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
columnId: propertyId,
value: newValue,
});
applyCellsUpdate(this._model);
}
}
@@ -199,7 +196,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
insertToPosition,
property.create(this.newPropertyName())
);
applyPropertyUpdate(this._model);
return result;
}
@@ -283,7 +279,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
propertyDataSet(propertyId: string, data: Record<string, unknown>): void {
this._runCapture();
this.updateProperty(propertyId, () => ({ data }));
applyPropertyUpdate(this._model);
}
propertyDataTypeGet(propertyId: string): TypeInstance | undefined {
@@ -337,7 +332,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
schema
);
copyCellsByProperty(this._model, copyId, id);
applyPropertyUpdate(this._model);
return id;
}
@@ -366,7 +360,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
propertyNameSet(propertyId: string, name: string): void {
this.doc.captureSync();
this.updateProperty(propertyId, () => ({ name }));
applyPropertyUpdate(this._model);
}
override propertyReadonlyGet(propertyId: string): boolean {
@@ -421,7 +414,6 @@ export class DatabaseBlockDataSource extends DataSourceBase {
}
});
updateCells(this._model, propertyId, cells);
applyPropertyUpdate(this._model);
}
rowAdd(insertPosition: InsertToPosition | number): string {

View File

@@ -127,7 +127,7 @@ export class BlockRenderer
.attributesSchema=${this.attributesSchema}
.attributeRenderer=${this.attributeRenderer}
.embedChecker=${this.inlineManager.embedChecker}
.markdownShortcutHandler=${this.inlineManager.markdownShortcutHandler}
.markdownMatches=${this.inlineManager.markdownMatches}
class="inline-editor"
></rich-text>
`;

View File

@@ -221,7 +221,7 @@ export class RichTextCell extends BaseRichTextCell {
.attributesSchema=${this.attributesSchema}
.attributeRenderer=${this.attributeRenderer}
.embedChecker=${this.inlineManager?.embedChecker}
.markdownShortcutHandler=${this.inlineManager?.markdownShortcutHandler}
.markdownMatches=${this.inlineManager?.markdownMatches}
.readonly=${true}
class="affine-database-rich-text inline-editor"
></rich-text>`
@@ -525,7 +525,7 @@ export class RichTextCellEditing extends BaseRichTextCell {
.attributesSchema=${this.attributesSchema}
.attributeRenderer=${this.attributeRenderer}
.embedChecker=${this.inlineManager?.embedChecker}
.markdownShortcutHandler=${this.inlineManager?.markdownShortcutHandler}
.markdownMatches=${this.inlineManager?.markdownMatches}
.verticalScrollContainerGetter=${() =>
this.topContenteditableElement?.host
? getViewportElement(this.topContenteditableElement.host)

View File

@@ -187,7 +187,7 @@ export class HeaderAreaTextCell extends BaseTextCell {
.attributesSchema="${this.attributesSchema}"
.attributeRenderer="${this.attributeRenderer}"
.embedChecker="${this.inlineManager?.embedChecker}"
.markdownShortcutHandler="${this.inlineManager?.markdownShortcutHandler}"
.markdownMatches="${this.inlineManager?.markdownMatches}"
.readonly="${true}"
class="data-view-header-area-rich-text"
></rich-text>`;
@@ -391,7 +391,7 @@ export class HeaderAreaTextCellEditing extends BaseTextCell {
.attributesSchema="${this.attributesSchema}"
.attributeRenderer="${this.attributeRenderer}"
.embedChecker="${this.inlineManager?.embedChecker}"
.markdownShortcutHandler="${this.inlineManager?.markdownShortcutHandler}"
.markdownMatches="${this.inlineManager?.markdownMatches}"
.readonly="${this.readonly}"
.enableClipboard="${false}"
.verticalScrollContainerGetter="${() =>

View File

@@ -37,24 +37,6 @@ export function addProperty(
return id;
}
export function applyCellsUpdate(model: DatabaseBlockModel) {
model.doc.updateBlock(model, {
cells: model.cells,
});
}
export function applyPropertyUpdate(model: DatabaseBlockModel) {
model.doc.updateBlock(model, {
columns: model.columns,
});
}
export function applyViewsUpdate(model: DatabaseBlockModel) {
model.doc.updateBlock(model, {
views: model.views,
});
}
export function copyCellsByProperty(
model: DatabaseBlockModel,
fromId: Column['id'],
@@ -156,7 +138,6 @@ export function moveViewTo(
arr => insertPositionToIndex(position, arr)
);
});
applyViewsUpdate(model);
}
export function updateCell(
@@ -255,6 +236,5 @@ export const updateView = <ViewData extends ViewBasicDataType>(
return { ...v, ...update(v as ViewData) };
});
});
applyViewsUpdate(model);
};
export const DATABASE_CONVERT_WHITE_LIST = ['affine:list', 'affine:paragraph'];

View File

@@ -20,10 +20,10 @@
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -39,5 +39,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -22,10 +22,10 @@
"@blocksuite/icons": "^2.2.1",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
"zod": "^3.23.8"
@@ -40,5 +40,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -22,10 +22,10 @@
"@blocksuite/icons": "^2.2.1",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
"yjs": "^13.6.21",
@@ -44,5 +44,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -12,10 +12,11 @@ import { DocModeProvider } from '@blocksuite/affine-shared/services';
import type { BlockService } from '@blocksuite/block-std';
import type { GfxCompatibleProps } from '@blocksuite/block-std/gfx';
import type { BlockModel } from '@blocksuite/store';
import { computed, type ReadonlySignal } from '@preact/signals-core';
import type { TemplateResult } from 'lit';
import { html } from 'lit';
import { query } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { type ClassInfo, classMap } from 'lit/directives/class-map.js';
import { type StyleInfo, styleMap } from 'lit/directives/style-map.js';
export class EmbedBlockComponent<
@@ -23,6 +24,12 @@ export class EmbedBlockComponent<
Service extends BlockService = BlockService,
WidgetName extends string = string,
> extends CaptionedBlockComponent<Model, Service, WidgetName> {
selectedStyle$: ReadonlySignal<ClassInfo> | null = computed<ClassInfo>(
() => ({
'selected-style': this.selected$.value,
})
);
private _fetchAbortController = new AbortController();
_cardStyle: EmbedCardStyle = 'horizontal';
@@ -43,10 +50,6 @@ export class EmbedBlockComponent<
protected embedContainerStyle: StyleInfo = {};
renderEmbed = (content: () => TemplateResult) => {
const selected = this.selected$.value;
const isInEdgeless =
this.std.get(DocModeProvider).getEditorMode() === 'edgeless';
if (
this._cardStyle === 'horizontal' ||
this._cardStyle === 'horizontalThin' ||
@@ -54,7 +57,7 @@ export class EmbedBlockComponent<
) {
this.style.display = 'block';
if (isInEdgeless) {
if (this.std.get(DocModeProvider).getEditorMode() === 'edgeless') {
this.style.minWidth = `${EMBED_CARD_MIN_WIDTH}px`;
}
}
@@ -64,7 +67,7 @@ export class EmbedBlockComponent<
draggable="${this.blockDraggable ? 'true' : 'false'}"
class=${classMap({
'embed-block-container': true,
'selected-style': selected && !isInEdgeless,
...this.selectedStyle$?.value,
})}
style=${styleMap({
height: `${this._cardHeight}px`,

View File

@@ -197,7 +197,7 @@ async function renderNoteContent(
match: ids.map(id => ({ id, viewType: 'display' })),
};
const previewDoc = doc.doc.getStore({ query });
const previewSpec = SpecProvider.getInstance().getSpec('page:preview');
const previewSpec = SpecProvider._.getSpec('preview:page');
const previewStd = new BlockStdScope({
store: previewDoc,
extensions: previewSpec.value,

View File

@@ -22,6 +22,8 @@ export function toEdgelessEmbedBlock<
B extends typeof EmbedBlockComponent<Model, Service, WidgetName>,
>(block: B) {
return class extends toGfxBlockComponent(block) {
override selectedStyle$ = null;
_isDragging = false;
_isResizing = false;

View File

@@ -1,8 +1,8 @@
import { EmbedLinkedDocBlockSchema } from '@blocksuite/affine-model';
import {
AdapterTextUtils,
BlockHtmlAdapterExtension,
type BlockHtmlAdapterMatcher,
TextUtils,
} from '@blocksuite/affine-shared/adapters';
export const embedLinkedDocBlockHtmlAdapterMatcher: BlockHtmlAdapterMatcher = {
@@ -18,7 +18,7 @@ export const embedLinkedDocBlockHtmlAdapterMatcher: BlockHtmlAdapterMatcher = {
return;
}
const title = configs.get('title:' + o.node.props.pageId) ?? 'untitled';
const url = TextUtils.generateDocUrl(
const url = AdapterTextUtils.generateDocUrl(
configs.get('docLinkBaseUrl') ?? '',
String(o.node.props.pageId),
o.node.props.params ?? Object.create(null)

View File

@@ -1,8 +1,8 @@
import { EmbedLinkedDocBlockSchema } from '@blocksuite/affine-model';
import {
AdapterTextUtils,
BlockMarkdownAdapterExtension,
type BlockMarkdownAdapterMatcher,
TextUtils,
} from '@blocksuite/affine-shared/adapters';
export const embedLinkedDocBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatcher =
@@ -19,7 +19,7 @@ export const embedLinkedDocBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatc
return;
}
const title = configs.get('title:' + o.node.props.pageId) ?? 'untitled';
const url = TextUtils.generateDocUrl(
const url = AdapterTextUtils.generateDocUrl(
configs.get('docLinkBaseUrl') ?? '',
String(o.node.props.pageId),
o.node.props.params ?? Object.create(null)

View File

@@ -1,8 +1,8 @@
import { EmbedLinkedDocBlockSchema } from '@blocksuite/affine-model';
import {
AdapterTextUtils,
BlockPlainTextAdapterExtension,
type BlockPlainTextAdapterMatcher,
TextUtils,
} from '@blocksuite/affine-shared/adapters';
export const embedLinkedDocBlockPlainTextAdapterMatcher: BlockPlainTextAdapterMatcher =
@@ -19,7 +19,7 @@ export const embedLinkedDocBlockPlainTextAdapterMatcher: BlockPlainTextAdapterMa
return;
}
const title = configs.get('title:' + o.node.props.pageId) ?? 'untitled';
const url = TextUtils.generateDocUrl(
const url = AdapterTextUtils.generateDocUrl(
configs.get('docLinkBaseUrl') ?? '',
String(o.node.props.pageId),
o.node.props.params ?? Object.create(null)

View File

@@ -70,7 +70,7 @@ export class EmbedEdgelessSyncedDocBlockComponent extends toEdgelessEmbedBlock(
<div class="affine-page-viewport" data-theme=${appTheme}>
${new BlockStdScope({
store: syncedDoc,
extensions: this._buildPreviewSpec('page:preview'),
extensions: this._buildPreviewSpec('preview:page'),
}).render()}
</div>
`,
@@ -81,7 +81,7 @@ export class EmbedEdgelessSyncedDocBlockComponent extends toEdgelessEmbedBlock(
<div class="affine-edgeless-viewport" data-theme=${edgelessTheme}>
${new BlockStdScope({
store: syncedDoc,
extensions: this._buildPreviewSpec('edgeless:preview'),
extensions: this._buildPreviewSpec('preview:edgeless'),
}).render()}
</div>
`,

View File

@@ -116,9 +116,9 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
],
};
protected _buildPreviewSpec = (name: 'page:preview' | 'edgeless:preview') => {
protected _buildPreviewSpec = (name: 'preview:page' | 'preview:edgeless') => {
const nextDepth = this.depth + 1;
const previewSpecBuilder = SpecProvider.getInstance().getSpec(name);
const previewSpecBuilder = SpecProvider._.getSpec(name);
const currentDisposables = this.disposables;
const editorSetting =
this.std.getOptional(EditorSettingProvider) ??
@@ -203,7 +203,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
<div class="affine-page-viewport" data-theme=${appTheme}>
${new BlockStdScope({
store: syncedDoc,
extensions: this._buildPreviewSpec('page:preview'),
extensions: this._buildPreviewSpec('preview:page'),
}).render()}
</div>
`,
@@ -214,7 +214,7 @@ export class EmbedSyncedDocBlockComponent extends EmbedBlockComponent<EmbedSynce
<div class="affine-edgeless-viewport" data-theme=${edgelessTheme}>
${new BlockStdScope({
store: syncedDoc,
extensions: this._buildPreviewSpec('edgeless:preview'),
extensions: this._buildPreviewSpec('preview:edgeless'),
}).render()}
</div>
`,

View File

@@ -13,6 +13,7 @@
"author": "toeverything",
"license": "MIT",
"dependencies": {
"@blocksuite/affine-block-surface": "workspace:*",
"@blocksuite/affine-components": "workspace:*",
"@blocksuite/affine-model": "workspace:*",
"@blocksuite/affine-shared": "workspace:*",
@@ -20,13 +21,14 @@
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
"yjs": "^13.6.21",
"zod": "^3.23.8"
},
"exports": {
@@ -39,5 +41,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -21,14 +21,13 @@ import {
type IVec,
type SerializedXYWH,
} from '@blocksuite/global/utils';
import { Text } from '@blocksuite/store';
import { type BlockModel, Text } from '@blocksuite/store';
import * as Y from 'yjs';
import { areSetsEqual } from './utils/misc.js';
import { isFrameBlock } from './utils/query.js';
const FRAME_PADDING = 40;
export type NavigatorMode = 'fill' | 'fit';
export class FrameOverlay extends Overlay {
static override overlayName: string = 'frame';
@@ -461,3 +460,13 @@ export class EdgelessFrameManager extends GfxExtension {
this._disposable.dispose();
}
}
function areSetsEqual<T>(setA: Set<T>, setB: Set<T>) {
if (setA.size !== setB.size) return false;
for (const a of setA) if (!setB.has(a)) return false;
return true;
}
export function isFrameBlock(element: unknown): element is FrameBlockModel {
return !!element && (element as BlockModel).flavour === 'affine:frame';
}

View File

@@ -1,2 +1,4 @@
export * from './frame-block.js';
export * from './frame-manager.js';
export * from './frame-spec.js';
export * from './tool.js';

View File

@@ -1,6 +1,6 @@
import { BaseTool } from '@blocksuite/block-std/gfx';
import type { NavigatorMode } from '../../../_common/edgeless/frame/consts.js';
import type { NavigatorMode } from './frame-manager';
type PresentToolOption = {
mode?: NavigatorMode;

View File

@@ -7,6 +7,7 @@
},
"include": ["./src"],
"references": [
{ "path": "../block-surface" },
{ "path": "../components" },
{ "path": "../model" },
{ "path": "../shared" },

View File

@@ -23,10 +23,10 @@
"@blocksuite/icons": "^2.2.1",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"file-type": "^20.0.0",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -42,5 +42,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -1,3 +1,4 @@
export * from './html.js';
export * from './markdown.js';
export * from './middleware.js';
export * from './notion-html.js';

View File

@@ -12,6 +12,7 @@ import {
import {
downloadBlob,
humanFileSize,
readImageSize,
transformModel,
withTempBlobData,
} from '@blocksuite/affine-shared/utils';
@@ -425,27 +426,6 @@ export async function turnImageIntoCardView(
transformModel(model, 'affine:attachment', attachmentProp);
}
export function readImageSize(file: File | Blob) {
return new Promise<{ width: number; height: number }>(resolve => {
const size = { width: 0, height: 0 };
const img = new Image();
img.onload = () => {
size.width = img.width;
size.height = img.height;
URL.revokeObjectURL(img.src);
resolve(size);
};
img.onerror = () => {
URL.revokeObjectURL(img.src);
resolve(size);
};
img.src = URL.createObjectURL(file);
});
}
export async function addImages(
std: BlockStdScope,
files: File[],

View File

@@ -21,10 +21,10 @@
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"@types/katex": "^0.16.7",
"@types/mdast": "^4.0.4",
"katex": "^0.16.11",
@@ -43,5 +43,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -20,10 +20,10 @@
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -42,5 +42,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -1,9 +1,9 @@
import { ListBlockSchema } from '@blocksuite/affine-model';
import {
AdapterTextUtils,
BlockHtmlAdapterExtension,
type BlockHtmlAdapterMatcher,
HastUtils,
TextUtils,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import { nanoid } from '@blocksuite/store';
@@ -124,7 +124,7 @@ export const listBlockHtmlAdapterMatcher: BlockHtmlAdapterMatcher = {
Array.isArray(currentTNode.properties.className) &&
currentTNode.properties.className.includes('todo-list')
) ===
TextUtils.isNullish(
AdapterTextUtils.isNullish(
o.node.props.type === 'todo'
? (o.node.props.checked as boolean)
: undefined
@@ -177,7 +177,7 @@ export const listBlockHtmlAdapterMatcher: BlockHtmlAdapterMatcher = {
Array.isArray(previousTNode.properties.className) &&
previousTNode.properties.className.includes('todo-list')
) ===
TextUtils.isNullish(
AdapterTextUtils.isNullish(
o.node.props.type === 'todo'
? (o.node.props.checked as boolean)
: undefined

View File

@@ -1,9 +1,9 @@
import { ListBlockSchema } from '@blocksuite/affine-model';
import {
AdapterTextUtils,
BlockMarkdownAdapterExtension,
type BlockMarkdownAdapterMatcher,
type MarkdownAST,
TextUtils,
} from '@blocksuite/affine-shared/adapters';
import type { DeltaInsert } from '@blocksuite/inline';
import { nanoid } from '@blocksuite/store';
@@ -75,8 +75,8 @@ export const listBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatcher = {
walkerContext.getNodeContext('affine:list:parent') === o.parent &&
currentTNode.type === 'list' &&
currentTNode.ordered === (o.node.props.type === 'numbered') &&
TextUtils.isNullish(currentTNode.children[0].checked) ===
TextUtils.isNullish(
AdapterTextUtils.isNullish(currentTNode.children[0].checked) ===
AdapterTextUtils.isNullish(
o.node.props.type === 'todo'
? (o.node.props.checked as boolean)
: undefined
@@ -129,8 +129,8 @@ export const listBlockMarkdownAdapterMatcher: BlockMarkdownAdapterMatcher = {
currentTNode.type === 'listItem' &&
previousTNode?.type === 'list' &&
previousTNode.ordered === (o.node.props.type === 'numbered') &&
TextUtils.isNullish(currentTNode.checked) ===
TextUtils.isNullish(
AdapterTextUtils.isNullish(currentTNode.checked) ===
AdapterTextUtils.isNullish(
o.node.props.type === 'todo'
? (o.node.props.checked as boolean)
: undefined

View File

@@ -85,10 +85,6 @@ export class ListBlockComponent extends CaptionedBlockComponent<ListBlockModel>
return this.std.get(DefaultInlineManagerExtension.identifier);
}
get markdownShortcutHandler() {
return this.inlineManager.markdownShortcutHandler;
}
override get topContenteditableElement() {
if (this.std.get(DocModeProvider).getEditorMode() === 'edgeless') {
return this.closest<BlockComponent>(NOTE_SELECTOR);
@@ -193,7 +189,7 @@ export class ListBlockComponent extends CaptionedBlockComponent<ListBlockModel>
.undoManager=${this.doc.history}
.attributeRenderer=${this.attributeRenderer}
.attributesSchema=${this.attributesSchema}
.markdownShortcutHandler=${this.markdownShortcutHandler}
.markdownMatches=${this.inlineManager?.markdownMatches}
.embedChecker=${this.embedChecker}
.readonly=${this.doc.readonly}
.inlineRangeProvider=${this._inlineRangeProvider}

View File

@@ -23,10 +23,10 @@
"@blocksuite/icons": "^2.2.1",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"@types/mdast": "^4.0.4",
"@vanilla-extract/css": "^1.17.0",
"lit": "^3.2.0",
@@ -43,5 +43,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -20,10 +20,10 @@
"@blocksuite/global": "workspace:*",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.10",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.7",
"@toeverything/theme": "^1.1.12",
"@types/mdast": "^4.0.4",
"lit": "^3.2.0",
"minimatch": "^10.0.1",
@@ -39,5 +39,5 @@
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.19.0"
"version": "0.20.0"
}

View File

@@ -90,10 +90,6 @@ export class ParagraphBlockComponent extends CaptionedBlockComponent<
return this.std.get(DefaultInlineManagerExtension.identifier);
}
get markdownShortcutHandler() {
return this.inlineManager.markdownShortcutHandler;
}
override get topContenteditableElement() {
if (this.std.get(DocModeProvider).getEditorMode() === 'edgeless') {
return this.closest<BlockComponent>(NOTE_SELECTOR);
@@ -294,7 +290,7 @@ export class ParagraphBlockComponent extends CaptionedBlockComponent<
.undoManager=${this.doc.history}
.attributesSchema=${this.attributesSchema}
.attributeRenderer=${this.attributeRenderer}
.markdownShortcutHandler=${this.markdownShortcutHandler}
.markdownMatches=${this.inlineManager?.markdownMatches}
.embedChecker=${this.embedChecker}
.readonly=${this.doc.readonly}
.inlineRangeProvider=${this._inlineRangeProvider}

View File

@@ -0,0 +1,73 @@
{
"name": "@blocksuite/affine-block-root",
"description": "Root block for BlockSuite.",
"type": "module",
"scripts": {
"build": "tsc",
"test:unit": "nx vite:test --run --passWithNoTests",
"test:unit:coverage": "nx vite:test --run --coverage",
"test:e2e": "playwright test"
},
"sideEffects": false,
"keywords": [],
"author": "toeverything",
"license": "MIT",
"dependencies": {
"@blocksuite/affine-block-attachment": "workspace:*",
"@blocksuite/affine-block-bookmark": "workspace:*",
"@blocksuite/affine-block-data-view": "workspace:*",
"@blocksuite/affine-block-database": "workspace:*",
"@blocksuite/affine-block-edgeless-text": "workspace:*",
"@blocksuite/affine-block-embed": "workspace:*",
"@blocksuite/affine-block-frame": "workspace:*",
"@blocksuite/affine-block-image": "workspace:*",
"@blocksuite/affine-block-latex": "workspace:*",
"@blocksuite/affine-block-list": "workspace:*",
"@blocksuite/affine-block-note": "workspace:*",
"@blocksuite/affine-block-paragraph": "workspace:*",
"@blocksuite/affine-block-surface": "workspace:*",
"@blocksuite/affine-block-surface-ref": "workspace:*",
"@blocksuite/affine-block-table": "workspace:*",
"@blocksuite/affine-components": "workspace:*",
"@blocksuite/affine-model": "workspace:*",
"@blocksuite/affine-shared": "workspace:*",
"@blocksuite/affine-widget-drag-handle": "workspace:*",
"@blocksuite/affine-widget-edgeless-auto-connect": "workspace:*",
"@blocksuite/affine-widget-frame-title": "workspace:*",
"@blocksuite/affine-widget-remote-selection": "workspace:*",
"@blocksuite/affine-widget-scroll-anchoring": "workspace:*",
"@blocksuite/block-std": "workspace:*",
"@blocksuite/data-view": "workspace:*",
"@blocksuite/global": "workspace:*",
"@blocksuite/icons": "^2.2.1",
"@blocksuite/inline": "workspace:*",
"@blocksuite/store": "workspace:*",
"@floating-ui/dom": "^1.6.13",
"@lit/context": "^1.1.2",
"@preact/signals-core": "^1.8.0",
"@toeverything/theme": "^1.1.12",
"@types/lodash-es": "^4.17.12",
"@types/mdast": "^4.0.4",
"@vanilla-extract/css": "^1.17.0",
"dompurify": "^3.2.4",
"fflate": "^0.8.2",
"html2canvas": "^1.4.1",
"lit": "^3.2.0",
"lodash-es": "^4.17.21",
"minimatch": "^10.0.1",
"simple-xml-to-json": "^1.2.2",
"yjs": "^13.6.21",
"zod": "^3.23.8"
},
"exports": {
".": "./src/index.ts",
"./effects": "./src/effects.ts"
},
"files": [
"src",
"dist",
"!src/__tests__",
"!dist/__tests__"
],
"version": "0.20.0"
}

View File

@@ -1,6 +1,7 @@
import { deleteTextCommand } from '@blocksuite/affine-components/rich-text';
import {
pasteMiddleware,
replaceIdMiddleware,
surfaceRefToEmbed,
} from '@blocksuite/affine-shared/adapters';
import {
@@ -17,7 +18,6 @@ import type { UIEventHandler } from '@blocksuite/block-std';
import { DisposableGroup } from '@blocksuite/global/utils';
import type { BlockSnapshot, Store } from '@blocksuite/store';
import { replaceIdMiddleware } from '../../_common/transformers/middlewares';
import { ReadOnlyClipboard } from './readonly-clipboard';
/**

View File

@@ -1,3 +1,4 @@
import { defaultImageProxyMiddleware } from '@blocksuite/affine-block-image';
import {
AttachmentAdapter,
copyMiddleware,
@@ -5,6 +6,7 @@ import {
ImageAdapter,
MixTextAdapter,
NotionTextAdapter,
titleMiddleware,
} from '@blocksuite/affine-shared/adapters';
import {
copySelectedModelsCommand,
@@ -14,10 +16,6 @@ import {
import type { BlockComponent, UIEventHandler } from '@blocksuite/block-std';
import { DisposableGroup } from '@blocksuite/global/utils';
import {
defaultImageProxyMiddleware,
titleMiddleware,
} from '../../_common/transformers/middlewares.js';
import { ClipboardAdapter } from './adapter.js';
/**

View File

@@ -6,19 +6,19 @@ import {
PageViewportServiceExtension,
ThemeService,
} from '@blocksuite/affine-shared/services';
import { dragHandleWidget } from '@blocksuite/affine-widget-drag-handle';
import { docRemoteSelectionWidget } from '@blocksuite/affine-widget-remote-selection';
import { scrollAnchoringWidget } from '@blocksuite/affine-widget-scroll-anchoring';
import { FlavourExtension } from '@blocksuite/block-std';
import type { ExtensionType } from '@blocksuite/store';
import { RootBlockAdapterExtensions } from '../adapters/extension';
import {
docRemoteSelectionWidget,
dragHandleWidget,
embedCardToolbarWidget,
formatBarWidget,
innerModalWidget,
linkedDocWidget,
modalWidget,
scrollAnchoringWidget,
slashMenuWidget,
viewportOverlayWidget,
} from './widgets';

View File

@@ -1,6 +1,3 @@
import { AFFINE_DRAG_HANDLE_WIDGET } from '@blocksuite/affine-widget-drag-handle';
import { AFFINE_DOC_REMOTE_SELECTION_WIDGET } from '@blocksuite/affine-widget-remote-selection';
import { AFFINE_SCROLL_ANCHORING_WIDGET } from '@blocksuite/affine-widget-scroll-anchoring';
import { WidgetViewExtension } from '@blocksuite/block-std';
import { literal, unsafeStatic } from 'lit/static-html.js';
@@ -32,11 +29,6 @@ export const linkedDocWidget = WidgetViewExtension(
AFFINE_LINKED_DOC_WIDGET,
literal`${unsafeStatic(AFFINE_LINKED_DOC_WIDGET)}`
);
export const dragHandleWidget = WidgetViewExtension(
'affine:page',
AFFINE_DRAG_HANDLE_WIDGET,
literal`${unsafeStatic(AFFINE_DRAG_HANDLE_WIDGET)}`
);
export const embedCardToolbarWidget = WidgetViewExtension(
'affine:page',
AFFINE_EMBED_CARD_TOOLBAR_WIDGET,
@@ -47,18 +39,8 @@ export const formatBarWidget = WidgetViewExtension(
AFFINE_FORMAT_BAR_WIDGET,
literal`${unsafeStatic(AFFINE_FORMAT_BAR_WIDGET)}`
);
export const docRemoteSelectionWidget = WidgetViewExtension(
'affine:page',
AFFINE_DOC_REMOTE_SELECTION_WIDGET,
literal`${unsafeStatic(AFFINE_DOC_REMOTE_SELECTION_WIDGET)}`
);
export const viewportOverlayWidget = WidgetViewExtension(
'affine:page',
AFFINE_VIEWPORT_OVERLAY_WIDGET,
literal`${unsafeStatic(AFFINE_VIEWPORT_OVERLAY_WIDGET)}`
);
export const scrollAnchoringWidget = WidgetViewExtension(
'affine:page',
AFFINE_SCROLL_ANCHORING_WIDGET,
literal`${unsafeStatic(AFFINE_SCROLL_ANCHORING_WIDGET)}`
);

View File

@@ -1,4 +1,5 @@
import type { FrameBlockModel } from '@blocksuite/affine-model';
import { SpecProvider } from '@blocksuite/affine-shared/utils';
import {
BlockServiceWatcher,
BlockStdScope,
@@ -18,7 +19,6 @@ import { css, html, nothing, type PropertyValues } from 'lit';
import { property, query, state } from 'lit/decorators.js';
import { styleMap } from 'lit/directives/style-map.js';
import { SpecProvider } from '../../../../_specs/index.js';
import type { EdgelessRootPreviewBlockComponent } from '../../edgeless-root-preview-block.js';
const DEFAULT_PREVIEW_CONTAINER_WIDTH = 280;
@@ -80,8 +80,7 @@ export class FramePreview extends WithDisposable(ShadowlessElement) {
private _previewDoc: Store | null = null;
private readonly _previewSpec =
SpecProvider.getInstance().getSpec('edgeless:preview');
private readonly _previewSpec = SpecProvider._.getSpec('preview:edgeless');
private readonly _updateFrameViewportWH = () => {
const [, , w, h] = deserializeXYWH(this.frame.xywh);

View File

@@ -1,5 +1,10 @@
import type { NoteBlockComponent } from '@blocksuite/affine-block-note';
import { isNoteBlock } from '@blocksuite/affine-block-surface';
import { DEFAULT_NOTE_HEIGHT } from '@blocksuite/affine-model';
import {
DEFAULT_NOTE_HEIGHT,
type NoteBlockModel,
type RootBlockModel,
} from '@blocksuite/affine-model';
import { EDGELESS_BLOCK_CHILD_PADDING } from '@blocksuite/affine-shared/consts';
import { TelemetryProvider } from '@blocksuite/affine-shared/services';
import { getRectByBlockComponent } from '@blocksuite/affine-shared/utils';
@@ -17,12 +22,7 @@ import { state } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { styleMap } from 'lit/directives/style-map.js';
import type {
EdgelessRootBlockComponent,
NoteBlockComponent,
NoteBlockModel,
RootBlockModel,
} from '../../../../index.js';
import type { EdgelessRootBlockComponent } from '../../edgeless-root-block';
const DIVIDING_LINE_OFFSET = 4;
const NEW_NOTE_GAP = 40;
@@ -373,7 +373,7 @@ export class NoteSlicer extends WidgetComponent<
if (!noteBlock || !this._divingLinePositions.length) return nothing;
const rect = getRectByBlockComponent(noteBlock);
const width = rect.width - 2 * EDGELESS_BLOCK_CHILD_PADDING;
const width = rect.width - 2 * EDGELESS_BLOCK_CHILD_PADDING * this._zoom;
const buttonPosition = this._divingLinePositions[this._activeSlicerIndex];
return html`<div class="note-slicer-container">
@@ -383,7 +383,6 @@ export class NoteSlicer extends WidgetComponent<
left: `${buttonPosition.x - 66 * this._zoom}px`,
top: `${buttonPosition.y}px`,
opacity: 1,
scale: `${this._zoom}`,
transform: 'translateY(-50%)',
})}
>

View File

@@ -6,6 +6,11 @@ import {
SYNCED_MIN_HEIGHT,
SYNCED_MIN_WIDTH,
} from '@blocksuite/affine-block-embed';
import {
type EdgelessFrameManager,
type FrameOverlay,
isFrameBlock,
} from '@blocksuite/affine-block-frame';
import {
CanvasElementType,
isNoteBlock,
@@ -65,10 +70,6 @@ import { ifDefined } from 'lit/directives/if-defined.js';
import { styleMap } from 'lit/directives/style-map.js';
import type { EdgelessRootBlockComponent } from '../../edgeless-root-block.js';
import type {
EdgelessFrameManager,
FrameOverlay,
} from '../../frame-manager.js';
import {
AI_CHAT_BLOCK_MAX_HEIGHT,
AI_CHAT_BLOCK_MAX_WIDTH,
@@ -90,7 +91,6 @@ import {
isEmbedLoomBlock,
isEmbedSyncedDocBlock,
isEmbedYoutubeBlock,
isFrameBlock,
isImageBlock,
isMindmapNode,
} from '../../utils/query.js';

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