mirror of
https://github.com/langgenius/dify.git
synced 2026-05-10 14:14:17 +08:00
fix(skill-editor): compare content with original to determine dirty state
Previously, any edit would mark the file as dirty even if the content was restored to its original state. Now we compare against the original content and clear the dirty flag when they match.
This commit is contained in:
parent
b82b73ef94
commit
bbf1247f80
@ -99,9 +99,16 @@ const SkillDocEditor: FC = () => {
|
||||
const handleEditorChange = useCallback((value: string | undefined) => {
|
||||
if (!activeTabId || !isEditable)
|
||||
return
|
||||
storeApi.getState().setDraftContent(activeTabId, value ?? '')
|
||||
const newValue = value ?? ''
|
||||
const originalContent = fileContent?.content ?? ''
|
||||
|
||||
if (newValue === originalContent)
|
||||
storeApi.getState().clearDraftContent(activeTabId)
|
||||
else
|
||||
storeApi.getState().setDraftContent(activeTabId, newValue)
|
||||
|
||||
storeApi.getState().pinTab(activeTabId)
|
||||
}, [activeTabId, isEditable, storeApi])
|
||||
}, [activeTabId, isEditable, storeApi, fileContent?.content])
|
||||
|
||||
const handleSave = useCallback(async () => {
|
||||
if (!activeTabId || !appId || !isEditable)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user