Closed jerry-f closed 6 days ago
同样的, 也是因为 packages/framework/store/src/store/collection.ts
createDoc(options: { id?: string; selector?: BlockSelector } = {}) {
const { id: docId = this.idGenerator(), selector } = options;
if (this._hasDoc(docId)) {
throw new Error('doc already exists');
}
console.log('this.meta.addDocMeta 1');
this.meta.addDocMeta({
id: docId,
title: '',
createDate: Date.now(),
tags: [],
});
console.log('this.meta.addDocMeta 2');
return this.getDoc(docId, { selector }) as Doc; // 这里返回的就是一个NULL ,然后这里强制转为了 Doc, 让类型检测通过了
}
导致了 路由 [examples/provider](http://localhost:5173/examples/provider/)
执行不通过
Hi @jerry-f , I've fixed the issue in the PR #7531. Please pull the updated code and let me know if everything works as expected now.
我已更新到最新的代码,在路由尝试:
但是出现了新的错误:
space.ts:118 An error occurred while Y.doc doc:home transacting: (匿名) @ space.ts:118 transact @ chunk-XOUFF4M4.js?v=ec7f1bcb:2482 transact @ chunk-XOUFF4M4.js?v=ec7f1bcb:696 transact @ space.ts:113 transact @ block-collection.ts:256 addBlock @ doc.ts:492 initDoc @ main.ts:15 main @ main.ts:63 (匿名) @ main.ts:73 显示另外 2 个框架 收起 space.ts:121 BlockSuiteError: Invalid schema for todo:container: Hub/Content must have parent. at Schema.validate (schema.ts:162:13) at DocCRUD.addBlock (crud.ts:82:18) at doc.ts:493:18 at space.ts:116:11 at transact (chunk-XOUFF4M4.js?v=ec7f1bcb:2482:14) at _Doc.transact (chunk-XOUFF4M4.js?v=ec7f1bcb:696:12) at BlockCollection.transact (space.ts:113:21) at BlockCollection.transact (block-collection.ts:256:11) at Doc.addBlock (doc.ts:492:10) at initDoc (main.ts:15:7) (匿名) @ space.ts:121 transact @ chunk-XOUFF4M4.js?v=ec7f1bcb:2482 transact @ chunk-XOUFF4M4.js?v=ec7f1bcb:696 transact @ space.ts:113 transact @ block-collection.ts:256 addBlock @ doc.ts:492 initDoc @ main.ts:15 main @ main.ts:63 (匿名) @ main.ts:73 显示另外 2 个框架 收起 main.ts:68 Uncaught TypeError: Cannot read properties of undefined (reading 'childrenUpdated') at main (main.ts:68:13) at main.ts:73:1
这个错误出现的路由地址是: http://localhost:5173/examples/store/
Hi @jerry-f , I have updated this example in PR#7541. Please check the latest code.
packages/playground/examples/store/main.ts
这里执行会报错: 由于由于 packages/framework/store/src/store/collection.ts