mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
feat(server): parse ydoc to ai editable markdown format (#12846)
close AI-213 #### PR Dependency Tree * **PR #12846** 👈 * **PR #12811** This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced support for AI-editable blocks in document parsing, allowing blocks to include metadata for AI-based editing. - Added rendering for todo list items with markdown checkbox syntax. - Unsupported block types are now marked with placeholders in the parsed output. - **Tests** - Added new test cases and snapshots to verify parsing behavior with AI-editable content enabled. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -17,6 +17,12 @@ const rootDocSnapshot = readFileSync(
|
||||
const docSnapshot = readFileSync(
|
||||
path.join(import.meta.dirname, './__fixtures__/test-doc.snapshot.bin')
|
||||
);
|
||||
const docSnapshotWithAiEditable = readFileSync(
|
||||
path.join(
|
||||
import.meta.dirname,
|
||||
'./__fixtures__/test-doc-with-ai-editable.snapshot.bin'
|
||||
)
|
||||
);
|
||||
|
||||
test('should read doc blocks work', async () => {
|
||||
const rootDoc = new YDoc({
|
||||
@@ -118,3 +124,39 @@ test('should parse page doc work', () => {
|
||||
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should parse page doc work with ai editable', () => {
|
||||
const doc = new YDoc({
|
||||
guid: 'test-doc',
|
||||
});
|
||||
applyUpdate(doc, docSnapshot);
|
||||
|
||||
const result = parsePageDoc({
|
||||
workspaceId: 'test-space',
|
||||
doc,
|
||||
buildBlobUrl: id => `blob://${id}`,
|
||||
buildDocUrl: id => `doc://${id}`,
|
||||
renderDocTitle: id => `Doc Title ${id}`,
|
||||
aiEditable: true,
|
||||
});
|
||||
|
||||
expect(result.md).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('should parse page full doc work with ai editable', () => {
|
||||
const doc = new YDoc({
|
||||
guid: 'test-doc',
|
||||
});
|
||||
applyUpdate(doc, docSnapshotWithAiEditable);
|
||||
|
||||
const result = parsePageDoc({
|
||||
workspaceId: 'test-space',
|
||||
doc,
|
||||
buildBlobUrl: id => `blob://${id}`,
|
||||
buildDocUrl: id => `doc://${id}`,
|
||||
renderDocTitle: id => `Doc Title ${id}`,
|
||||
aiEditable: true,
|
||||
});
|
||||
|
||||
expect(result.md).toMatchSnapshot();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user