Commit Graph

97 Commits

Author SHA1 Message Date
Saul-Mirone
6fb7f51ea2 refactor(editor): history as a store extension (#12214)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Improved history and undo/redo management across the app by introducing a dedicated history extension. Undo/redo operations now use a more focused undo manager, resulting in clearer and more consistent behavior.
- **Documentation**
  - Updated API documentation to reflect changes in history management, including revised method signatures and removal of outdated event references.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-12 01:50:57 +00:00
Saul-Mirone
97aa3fc672 fix(editor): array proxy splice will cause too large yjs update (#12201)
Splice will produce large yjs updates for splice because it will call insert and delete operation for every item in yarray.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added support for `splice`, `shift`, and `unshift` methods on reactive arrays, enabling enhanced dynamic array operations with synchronization.
- **Tests**
  - Expanded test coverage for array operations including `push`, `splice`, `shift`, and `unshift`, verifying complete array state after each change.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-09 06:19:57 +00:00
EYHN
2d1600fa00 refactor(core): implement doc created/updated by service (#12150)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Documents now automatically track and display "created by" and "updated by" user information.
  - Document creation and update timestamps are now managed and shown more accurately.
  - Workspace and document metadata (name, avatar) updates are more responsive and reliable.
  - Document creation supports middleware for customizing properties and behavior.

- **Improvements**
  - Simplified and unified event handling for document list updates, reducing redundant event subscriptions.
  - Enhanced integration of editor and theme settings into the document creation process.
  - Explicit Yjs document initialization for improved workspace stability and reliability.
  - Consolidated journal-related metadata display in document icons and titles for clarity.

- **Bug Fixes**
  - Fixed inconsistencies in how workspace and document names are set and updated.
  - Improved accuracy of "last updated" indicators by handling timestamps automatically.

- **Refactor**
  - Removed deprecated event subjects and direct metadata manipulation in favor of more robust, reactive patterns.
  - Streamlined document creation logic across various features (quick search, journal, recording, etc.).
  - Simplified user avatar display components and removed cloud metadata dependencies.
  - Removed legacy editor setting and theme service dependencies from multiple modules.

- **Chores**
  - Updated internal APIs and interfaces to support new metadata and event handling mechanisms.
  - Cleaned up unused code and dependencies related to editor settings and theme services.
  - Skipped flaky end-to-end test to improve test suite stability.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-08 07:53:33 +00:00
Saul-Mirone
95b9e4b3d0 refactor(editor): rename model.doc to store (#12172) 2025-05-07 09:17:01 +00:00
Saul-Mirone
eb62d0e853 refactor(editor): doc as store extension (#12170)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **New Features**
  - Introduced new exports related to workspace management, making additional workspace features available.

- **Refactor**
  - Updated how document and workspace types are imported and exported, consolidating and reorganizing module structure.
  - Shifted dependency management for document instances to use an internal provider mechanism.
  - Streamlined and centralized type imports across various modules.

- **Bug Fixes**
  - Removed an unused schema definition to improve code clarity.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-07 09:17:01 +00:00
Saul-Mirone
267bb3a975 refactor(editor): introduce store container to make implement doc easier (#12146)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Introduced a new store management system for handling document stores, improving efficiency and flexibility when working with document data.

- **Refactor**
  - Updated internal store handling to use a centralized store container, simplifying store retrieval and removal across various components.
  - Renamed and updated several store-related method signatures for consistency and clarity.
  - Replaced editor extension loading logic with a new local implementation for better modularity.

- **Chores**
  - Improved and streamlined the export of store-related modules for better maintainability.
  - Removed obsolete and redundant code related to previous store management approaches.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-07 06:08:43 +00:00
Saul-Mirone
1e89aa48cb refactor(editor): remove unused code (#12142)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Streamlined internal logic for handling block operations to improve efficiency.
  - Removed unused reactive subject and related code from document handling classes.
  - Renamed a private initialization method for improved clarity.

- **Chores**
  - Cleaned up redundant code and imports to simplify maintenance.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-06 09:00:40 +00:00
Saul-Mirone
88ceeba5b6 refactor(editor): move block yjs listener to store (#12140)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

- **Refactor**
  - Streamlined internal event handling for block updates, removing previous notification mechanisms from several components.
- **Chores**
  - Simplified and cleaned up internal logic related to block addition and deletion tracking.

No visible changes to the user interface or end-user features.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-06 07:44:57 +00:00
Saul-Mirone
d859c4252b refactor(editor): move history from doc to store (#12131)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Undo/redo history management is now centralized in the workspace, providing more consistent and robust undo/redo behavior.
  - History update events are emitted at the workspace level, enabling better tracking of changes.

- **Bug Fixes**
  - Improved reliability of undo/redo actions by shifting history management from documents to the workspace.

- **Documentation**
  - Updated and clarified documentation for history-related APIs, including improved examples and clearer descriptions.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-05 09:24:09 +00:00
fundon
85e40e4026 refactor(editor): simplify attachment and image upload handling (#11987)
Closes: [BS-3303](https://linear.app/affine-design/issue/BS-3303/改進-pack-attachment-props-流程)

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

- **New Features**
  - Enhanced attachment and image uploads with improved file size validation and clearer notifications.
  - Upload telemetry tracking added for attachments to monitor upload success or failure.

- **Refactor**
  - Streamlined and unified the process of adding attachments and images, making uploads more reliable and efficient.
  - Parameter names updated for clarity across attachment and image insertion features.

- **Documentation**
  - Updated API documentation to reflect parameter name changes for consistency.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-04-28 07:03:30 +00:00
L-Sun
e457e2f8a8 fix(editor): add reference after duplicate edgeless embed doc as note (#11877)
- fix(editor): add reference in the copied note of embed doc
- refactor(editor): add generics parameter `TextAttributes` into `Text`
2025-04-22 08:03:52 +00:00
Saul-Mirone
01429f8f66 fix(editor): clear remote selection when editor is deactive (#11450)
Closes: BS-3022
2025-04-03 09:36:28 +00:00
Saul-Mirone
773db7860a feat(editor): not sync selection from awareness (#11420) 2025-04-03 09:22:26 +00:00
Saul-Mirone
0a8d8e0a6b feat: seperate createDoc and createStore (#11182) 2025-03-26 11:03:47 +00:00
Saul-Mirone
e84c60f53d feat(editor): add provider for base adapter (#11169) 2025-03-25 12:09:23 +00:00
Saul-Mirone
258c70cf07 refactor(editor): store should not rely on inline (#11017) 2025-03-20 01:33:29 +00:00
Saul-Mirone
5cb2abab76 docs(editor): add doc for reactive types in store (#10958) 2025-03-18 09:07:42 +00:00
Saul-Mirone
ef00a158fc docs(editor): improve documentation for store class (#10949) 2025-03-18 07:57:58 +00:00
Saul-Mirone
9f3cf271e3 feat(editor): support user provided role and role schema (#10939)
Let me analyze the key changes in this diff:

1. **Role System Changes**:
- Changed from a fixed enum of roles (`root`, `hub`, `content`) to a more flexible string-based system
- Removed strict role hierarchy validation rules (hub/content/root relationships)
- Added support for role-based matching using `@` prefix (e.g., `@root`, `@content`)

2. **Schema Validation Updates**:
- Added new `_matchFlavourOrRole` method to handle both flavour and role-based matching
- Updated `_validateParent` to consider both roles and flavours when validating parent-child relationships
- Simplified `_validateRole` by removing specific role hierarchy constraints

3. **Block Schema Changes**:
- Updated parent/children references in various block schemas to use the new `@` prefix notation
- Changed parent definitions from `['affine:page']` to `['@root']` in several blocks
- Updated children definitions to use role-based references (e.g., `['@content']`)

4. **Test Updates**:
- Added new test cases for role-based schema validation
- Introduced new test block schemas (`TestRoleBlockSchema`, `TestParagraphBlockSchema`) to verify role-based functionality

This appears to be a significant architectural change that makes the block schema system more flexible by:
1. Moving away from hardcoded role hierarchies
2. Introducing a more dynamic role-based relationship system
3. Supporting both flavour-based and role-based parent-child relationships
4. Using the `@` prefix convention to distinguish role references from flavour references

The changes make the system more extensible while maintaining backward compatibility with existing flavour-based relationships.
2025-03-18 01:58:59 +00:00
Saul-Mirone
3de7d85eea feat(editor): improve api for store, and add docs (#10941) 2025-03-17 16:30:59 +00:00
Saul-Mirone
1d04438049 docs(editor): scaffolding docs generator (#10925) 2025-03-17 12:51:08 +00:00
doodlewind
81af7a0571 docs(editor): add guide for extension usage (#10911)
The guide is baed on #10847 to improve the code quality for migrating extensions using LLM.
2025-03-17 05:38:10 +00:00
Saul-Mirone
808c053c3c feat(editor): add block meta for table block (#10915) 2025-03-17 05:20:10 +00:00
Saul-Mirone
26285f7dcb feat(editor): unify block props api (#10888)
Closes: [BS-2707](https://linear.app/affine-design/issue/BS-2707/统一使用props获取和更新block-prop)
2025-03-16 05:48:34 +00:00
Saul-Mirone
5566632b30 refactor(editor): improve the implementation of flat proxy (#10872) 2025-03-14 23:25:47 +09:00
Saul-Mirone
517817e66f refactor(editor): separate yjs subscribe logic of flat model (#10863) 2025-03-14 23:09:31 +09:00
Saul-Mirone
a3ce67a59d refactor(editor): separate init logic of flat model (#10862) 2025-03-14 23:09:31 +09:00
Saul-Mirone
1ce290094e refactor(editor): improve implementation of flat model (#10848) 2025-03-14 13:18:03 +00:00
EYHN
05200ad7b7 feat(nbstore): add blob sync storage (#10752) 2025-03-14 18:05:54 +08:00
Saul-Mirone
250f3f1efd feat(editor): add isLocal flag in blockUpdated subject (#10799) 2025-03-13 05:33:06 +00:00
Mirone
cd63e0ed8b feat(editor): replace slot with rxjs subject (#10768) 2025-03-12 11:29:24 +09:00
Saul-Mirone
9cfd1c321e fix(editor): missing re-subscription for slots on store (#10750) 2025-03-11 04:07:06 +00:00
Saul-Mirone
dc047aa1a4 feat(editor): allow undefined default props (#10701)
Closes: [BS-2771](https://linear.app/affine-design/issue/BS-2771/%E6%84%9F%E8%A7%89%E5%BE%97%E6%94%AF%E6%8C%81%E5%8F%AF%E9%80%89%E5%AD%97%E6%AE%B5[mirone]1f862b1b-8523-4487-a948-fef9174e8825)
2025-03-07 15:57:12 +00:00
Saul-Mirone
8d10b40b72 feat(editor): add loaded and disposed hook for store extension (#10669) 2025-03-06 13:31:09 +00:00
Saul-Mirone
84e2dda3f8 refactor(editor): separate lit and slot in global (#10666) 2025-03-06 10:24:59 +00:00
EYHN
5c8b81581c feat(core): doc level awareness (#10646) 2025-03-06 06:05:45 +00:00
Saul-Mirone
b8ecfbdae6 refactor(editor): remove assertExists (#10615) 2025-03-05 00:13:08 +00:00
Saul-Mirone
22924c767c fix(editor): onChange notification for flat model (#10589)
The primary purpose of this PR appears to be:
1. Simplifying the change notification API by removing the redundant value parameter from callbacks
2. Improving the reactive system's handling of specialized types (Text and Boxed) in flat data
3. Adding better test coverage for text handling in the flat data model
2025-03-04 05:57:06 +00:00
Saul-Mirone
a587abca85 feat(editor): add block meta service (#10561) 2025-03-03 06:13:06 +00:00
Saul-Mirone
e90c00c3b7 refactor(editor): perf optimization of flat data (#10494)
The new code should be more efficient as it:
- Avoids unnecessary iterations when objects aren't empty
- Has clearer path management
- Reduces redundant object traversals
2025-02-28 04:51:54 +00:00
Saul-Mirone
b19c1df43e fix: table collab (#10489)
[Screen Recording 2025-02-27 at 20.24.15.mov <span class="graphite__hidden">(uploaded via Graphite)</span> <img class="graphite__hidden" src="https://app.graphite.dev/api/v1/graphite/video/thumbnail/EUhyG5TOGVlHZ0Suk1wH/b3ac681f-a14d-483a-820c-53c584f0fb44.mov" />](https://app.graphite.dev/media/video/EUhyG5TOGVlHZ0Suk1wH/b3ac681f-a14d-483a-820c-53c584f0fb44.mov)
2025-02-27 12:37:57 +00:00
Saul-Mirone
4c736bc190 feat(editor): type safe draft model and transformer (#10486) 2025-02-27 09:19:49 +00:00
Saul-Mirone
d57ef5c5b3 fix(editor): transform to draftmodel first when get snapshot (#10477) 2025-02-27 07:52:18 +00:00
zzj3720
18dfad28d7 fix(editor): toDraftModal supports flat data structures (#10466)
fix: PD-2374
fix: BS-2703
2025-02-27 05:16:10 +00:00
Saul-Mirone
fd6d96a38e refactor(editor): use transformer from store when possible (#10453) 2025-02-26 14:15:04 +00:00
Saul-Mirone
ce87dcf58e feat(editor): schema extension (#10447)
1. **Major Architectural Change: Schema Management**
   - Moved from `workspace.schema` to `store.schema` throughout the codebase
   - Removed schema property from Workspace and Doc interfaces
   - Added `BlockSchemaExtension` pattern across multiple block types

2. **Block Schema Extensions Added**
   - Added new `BlockSchemaExtension` to numerous block types including:
     - DataView, Surface, Attachment, Bookmark, Code
     - Database, Divider, EdgelessText, Embed blocks (Figma, Github, HTML, etc.)
     - Frame, Image, Latex, List, Note, Paragraph
     - Root, Surface Reference, Table blocks

3. **Import/Export System Updates**
   - Updated import functions to accept `schema` parameter:
     - `importHTMLToDoc`
     - `importHTMLZip`
     - `importMarkdownToDoc`
     - `importMarkdownZip`
     - `importNotionZip`
   - Modified export functions to use new schema pattern

4. **Test Infrastructure Updates**
   - Updated test files to use new schema extensions
   - Modified test document creation to include schema extensions
   - Removed direct schema registration in favor of extensions

5. **Service Layer Changes**
   - Updated various services to use `getAFFiNEWorkspaceSchema()`
   - Modified transformer initialization to use document schema
   - Updated collection initialization patterns

6. **Version Management**
   - Removed version-related properties and methods from:
     - `WorkspaceMetaImpl`
     - `TestMeta`
     - `DocImpl`
   - Removed `blockVersions` and `workspaceVersion/pageVersion`

7. **Store and Extension Updates**
   - Added new store extensions and adapters
   - Updated store initialization patterns
   - Added new schema-related functionality in store extension

This PR represents a significant architectural shift in how schemas are managed, moving from a workspace-centric to a store-centric approach, while introducing a more extensible block schema system through `BlockSchemaExtension`. The changes touch multiple layers of the application including core functionality, services, testing infrastructure, and import/export capabilities.
2025-02-26 11:31:29 +00:00
CatsJuice
e1fd8f5d80 fix(core): correctly toggle visibility of starter-bar based on doc.isEmpty (#10439) 2025-02-26 07:49:51 +00:00
Saul-Mirone
faf6e2c79f refactor(editor): optimize store map (#10246) 2025-02-18 13:30:09 +00:00
doouding
eed00e0b26 fix: mindmap ai preview (#10222) 2025-02-17 12:45:20 +00:00
Saul-Mirone
9321ce94a7 refactor(editor): remove global types in config (#10143)
Closes: [BS-2554](https://linear.app/affine-design/issue/BS-2554/remove-global-types-in-block-config)
2025-02-13 04:35:35 +00:00