mirror of
https://github.com/langgenius/dify.git
synced 2026-03-26 08:40:14 +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:
@ -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)
|
||||
|
||||
Reference in New Issue
Block a user