### Description 我发现官网上的示例代码也存在这个问题 https://platejs.org/docs/yjs#%E5%A4%9A%E6%96%87%E6%A1%A3%E5%A4%84%E7%90%86 <img width="1856" height="870" alt="Image" src="https://github.com/user-attachments/assets/82667789-8f0f-46bc-a4a0-0000d22cff64" /> 在我本地代码中,尝试把skipInitialization 注释掉,一切正常 <img width="2452" height="1193" alt="Image" src="https://github.com/user-attachments/assets/96c406d4-c702-4ce8-8550-4ca4c8715a37" /> 但是有一个额外的bug,不知道是我的写法问题还是什么,每次刷新,都会追加内容 https://github.com/user-attachments/assets/4dac16fa-ea97-42fd-8afa-16ba115bed10 ### Reproduction URL _No response_ ### Reproduction steps ```bash 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error ``` ### Plate version 52.0.1 ### Slate React version 0.120.0 ### Screenshots ```bash ``` ### Logs ```bash ``` ### Browsers Chrome
Activity
dosubot commentedon Dec 25, 2025
Hi @Capyhw! I'm Dosu and I’m helping the plate team.
你遇到的问题是 Plate 和 Yjs 初始化时机冲突导致的。正确做法是:
skipInitialization: true,这样 Plate 不会自动初始化内容,避免和 Yjs 状态冲突。官方文档说明useEffect),手动调用editor.getApi(YjsPlugin).yjs.init(),并传入文档 id 和初始内容。只有当 Yjs 文档是空的,初始内容才会被插入,否则会同步远端内容,不会重复追加。源码逻辑editor.getApi(YjsPlugin).yjs.destroy(),避免内存泄漏。skipInitialization: true,Plate 会在 Yjs 内容还没同步时插入初始值,每次刷新都可能追加内容,导致重复。相关讨论更多细节和例子可以参考 官方 Yjs 插件文档 和 协作示例。
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
felixfeng33 commentedon Dec 31, 2025
我花费较多时间,将potion中的bug修复了,platejs中的还没来得及修复,有时间会修复