{/* Language Selector */}
{/* View Mode Toggle */}
{/* Main Editor Area */}
原始内容
修改内容
{
// Determine initial values if needed, but state is controlled slightly differently in DiffEditor
// actually DiffEditor is better uncontrolled for values usually or we need to manage models.
// But @monaco-editor/react handles `original` and `modified` props updates well.
// Listening to changes is a bit more complex if we want 2-way binding,
// but for a diff tool, usually users paste into it.
// Alternatively, we can use the modifiedModel to get content changes if we really needed
// but for a simple comparison tool, just passing props is often enough IF we provide a way to input.
// WAIT. The DiffEditor is often read-only for the comparison result, OR editable.
// By default originalEditable: false.
// Let's set originalEditable: true so users can paste into both sides.
}}
theme={theme === 'dark' ? "vs-dark" : "light"}
options={{
renderSideBySide: renderSideBySide,
originalEditable: true, // Allow editing left side
readOnly: false, // Allow editing right side
minimap: { enabled: false },
scrollBeyondLastLine: false,
fontSize: 14,
wordWrap: "on",
}}
/>
{/* Overlay hints if empty?
Monaco editor keeps state internally.
If we want to bind state, we might need a standard Editor first to input?
No, DiffEditor with `originalEditable: true` is fine for direct input.
*/}
💡 提示:您可以直接在左右两侧编辑器中粘贴或输入文本进行通过。上方工具栏可切换语言高亮和对比模式。