Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Theme Config Editor (#39621)
* feat: add Theme Editor theme upload * verision 2 * 移除lodash、同步当前Config * remove export,add into devDependencies,add tool link
- Loading branch information
1 parent
e3e1b85
commit 5644c63
Showing
5 changed files
with
123 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { JSONEditor as Editor, Mode, type JSONEditorPropsOptional } from 'vanilla-jsoneditor'; | ||
import React from 'react'; | ||
|
||
const JSONEditor = (props: JSONEditorPropsOptional) => { | ||
const refContainer = React.useRef(null); | ||
const refEditor = React.useRef(null); | ||
|
||
React.useEffect(() => { | ||
refEditor.current = new Editor({ | ||
target: refContainer.current, | ||
props: { | ||
mode: Mode.text, | ||
}, | ||
}); | ||
|
||
return () => { | ||
if (refEditor.current) { | ||
refEditor.current.destroy(); | ||
refEditor.current = null; | ||
} | ||
}; | ||
}, []); | ||
|
||
React.useEffect(() => { | ||
if (refEditor.current) { | ||
refEditor.current.updateProps(props); | ||
} | ||
}, [props]); | ||
|
||
return <div className="vanilla-jsoneditor-react" ref={refContainer} />; | ||
}; | ||
|
||
export default JSONEditor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
export function isObject(target: any) { | ||
return Object.prototype.toString.call(target) === '[object Object]'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters