Replies: 2 comments
-
|
Hi @Capyhw! I'm Dosu and I’m helping the plate team. 你遇到的问题是 Plate 和 Yjs 初始化时机冲突导致的。正确做法是:
const editor = useMemo(() => createPlateEditor({
plugins: [/* ... */],
skipInitialization: true,
}), []);
useEffect(() => {
// 等 Yjs provider ready 后再初始化
editor.getApi(YjsPlugin).yjs.init({
id: docId,
value: initialValue,
});
return () => editor.getApi(YjsPlugin).yjs.destroy();
}, [editor, docId, initialValue]);
更多细节和例子可以参考 官方 Yjs 插件文档 和 协作示例。 To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
我花费较多时间,将potion中的bug修复了,platejs中的还没来得及修复,有时间会修复 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
我发现官网上的示例代码也存在这个问题
https://platejs.org/docs/yjs#%E5%A4%9A%E6%96%87%E6%A1%A3%E5%A4%84%E7%90%86
在我本地代码中,尝试把skipInitialization 注释掉,一切正常
但是有一个额外的bug,不知道是我的写法问题还是什么,每次刷新,都会追加内容
PixPin_2025-12-25_18-47-54.mp4
Reproduction URL
No response
Reproduction steps
Plate version
52.0.1
Slate React version
0.120.0
Screenshots
Logs
Browsers
Chrome
Beta Was this translation helpful? Give feedback.
All reactions