mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
### TL;DR * Fix the issue of inaccurate content replacement in AI Replace Selection * Optimize unit Tests utils ### What Changed 1. Fixed the issue of inaccurate content replacement in AI Replace Selection: - Convert the AI Answer into a Snapshot, then transform it into a sequence of Blocks ready for insertion. - Invoke the `replaceSelectedTextWithBlocks` command to replace the current selection with blocks (given the complexity of block combinations, this command uses [ts-pattern](https://github.com/gvergnaud/ts-pattern) implementation to ensure compile-time prevention of pattern handling omissions). 2. Optimized unit test assertions for commands, now allowing direct document content comparison using `toEqualDoc`. ```ts const host = affine` <affine-page id="page"> <affine-note id="note"> <affine-paragraph id="paragraph-1">Hel<anchor />lo</affine-paragraph> <affine-paragraph id="paragraph-2">Wor<focus />ld</affine-paragraph> </affine-note> </affine-page> `; // .... const expected = affine` <affine-page id="page"> <affine-note id="note"> <affine-paragraph id="paragraph-1">Hel111</affine-paragraph> <affine-code id="code"></affine-code> <affine-paragraph id="paragraph-2">222ld</affine-paragraph> </affine-note> </affine-page> `; expect(host.doc).toEqualDoc(expected.doc); ``` 3. Added support for text cursors in unit test template syntax. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit > CLOSE BS-3278 - **New Features** - Introduced the ability to replace selected text in documents with blocks, supporting advanced merging and insertion scenarios for various block types. - **Bug Fixes** - Improved handling of text selection and cursor placement in document templates used for testing. - **Tests** - Added comprehensive tests for replacing selected text with blocks, including edge cases and complex selection scenarios. - Enhanced test utilities for document structure comparison and selection handling. - Updated end-to-end tests to verify correct replacement of selected text via AI-driven actions. - **Chores** - Added and updated dependencies to support new features. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
76 lines
2.2 KiB
JSON
76 lines
2.2 KiB
JSON
{
|
|
"name": "@blocksuite/affine-shared",
|
|
"description": "Default BlockSuite editable blocks.",
|
|
"type": "module",
|
|
"scripts": {
|
|
"build": "tsc"
|
|
},
|
|
"sideEffects": false,
|
|
"keywords": [],
|
|
"author": "toeverything",
|
|
"license": "MIT",
|
|
"dependencies": {
|
|
"@blocksuite/affine-model": "workspace:*",
|
|
"@blocksuite/global": "workspace:*",
|
|
"@blocksuite/icons": "^2.2.12",
|
|
"@blocksuite/std": "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.14",
|
|
"@types/hast": "^3.0.4",
|
|
"@types/lodash-es": "^4.17.12",
|
|
"@types/mdast": "^4.0.4",
|
|
"dompurify": "^3.2.4",
|
|
"fractional-indexing": "^3.2.0",
|
|
"lit": "^3.2.0",
|
|
"lodash-es": "^4.17.21",
|
|
"mdast-util-gfm-autolink-literal": "^2.0.1",
|
|
"mdast-util-gfm-footnote": "^2.0.0",
|
|
"mdast-util-gfm-strikethrough": "^2.0.0",
|
|
"mdast-util-gfm-table": "^2.0.0",
|
|
"mdast-util-gfm-task-list-item": "^2.0.0",
|
|
"micromark-extension-gfm-autolink-literal": "^2.1.0",
|
|
"micromark-extension-gfm-footnote": "^2.1.0",
|
|
"micromark-extension-gfm-strikethrough": "^2.1.0",
|
|
"micromark-extension-gfm-table": "^2.1.0",
|
|
"micromark-extension-gfm-task-list-item": "^2.1.0",
|
|
"micromark-util-combine-extensions": "^2.0.0",
|
|
"minimatch": "^10.0.1",
|
|
"rehype-parse": "^9.0.0",
|
|
"rehype-stringify": "^10.0.0",
|
|
"remark-math": "^6.0.0",
|
|
"remark-parse": "^11.0.0",
|
|
"remark-stringify": "^11.0.0",
|
|
"rxjs": "^7.8.1",
|
|
"ts-pattern": "^5.1.0",
|
|
"unified": "^11.0.5",
|
|
"unist-util-visit": "^5.0.0",
|
|
"yjs": "^13.6.21",
|
|
"zod": "^3.23.8"
|
|
},
|
|
"exports": {
|
|
".": "./src/index.ts",
|
|
"./selection": "./src/selection/index.ts",
|
|
"./utils": "./src/utils/index.ts",
|
|
"./consts": "./src/consts/index.ts",
|
|
"./types": "./src/types/index.ts",
|
|
"./commands": "./src/commands/index.ts",
|
|
"./theme": "./src/theme/index.ts",
|
|
"./styles": "./src/styles/index.ts",
|
|
"./services": "./src/services/index.ts",
|
|
"./adapters": "./src/adapters/index.ts"
|
|
},
|
|
"files": [
|
|
"src",
|
|
"dist",
|
|
"!src/__tests__",
|
|
"!dist/__tests__"
|
|
],
|
|
"devDependencies": {
|
|
"vitest": "3.1.3"
|
|
},
|
|
"version": "0.21.0"
|
|
}
|