|
|
|
@ -31,6 +31,7 @@ |
|
|
|
let editorView: EditorView | null = $state(null); |
|
|
|
let editorView: EditorView | null = $state(null); |
|
|
|
let isDark = $state(false); |
|
|
|
let isDark = $state(false); |
|
|
|
let initialized = $state(false); |
|
|
|
let initialized = $state(false); |
|
|
|
|
|
|
|
let originalValue = $state<string>(''); // Store original value to restore on cancel |
|
|
|
|
|
|
|
|
|
|
|
// Toolbar state |
|
|
|
// Toolbar state |
|
|
|
let showGifPicker = $state(false); |
|
|
|
let showGifPicker = $state(false); |
|
|
|
@ -49,6 +50,9 @@ |
|
|
|
|
|
|
|
|
|
|
|
// Check for dark mode preference |
|
|
|
// Check for dark mode preference |
|
|
|
onMount(() => { |
|
|
|
onMount(() => { |
|
|
|
|
|
|
|
// Store original value when editor opens |
|
|
|
|
|
|
|
originalValue = value; |
|
|
|
|
|
|
|
|
|
|
|
if (initialized || !editorContainer) return; |
|
|
|
if (initialized || !editorContainer) return; |
|
|
|
|
|
|
|
|
|
|
|
const checkDarkMode = () => { |
|
|
|
const checkDarkMode = () => { |
|
|
|
@ -84,12 +88,7 @@ |
|
|
|
...completionKeymap |
|
|
|
...completionKeymap |
|
|
|
]), |
|
|
|
]), |
|
|
|
language, |
|
|
|
language, |
|
|
|
EditorView.updateListener.of((update) => { |
|
|
|
// Removed real-time update listener - only update on Save |
|
|
|
if (update.docChanged && onUpdate) { |
|
|
|
|
|
|
|
const newValue = update.state.doc.toString(); |
|
|
|
|
|
|
|
onUpdate(newValue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
EditorView.theme({ |
|
|
|
EditorView.theme({ |
|
|
|
'&': { |
|
|
|
'&': { |
|
|
|
fontSize: '14px', |
|
|
|
fontSize: '14px', |
|
|
|
@ -163,6 +162,10 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function handleCancel() { |
|
|
|
function handleCancel() { |
|
|
|
|
|
|
|
// Restore original value before closing |
|
|
|
|
|
|
|
if (onUpdate && originalValue !== undefined) { |
|
|
|
|
|
|
|
onUpdate(originalValue); |
|
|
|
|
|
|
|
} |
|
|
|
if (onClose) { |
|
|
|
if (onClose) { |
|
|
|
onClose(); |
|
|
|
onClose(); |
|
|
|
} |
|
|
|
} |
|
|
|
|