clean up Carbon

main
Mike Fix 5 years ago
parent 625bbd4773
commit 8c906db3c5
No known key found for this signature in database
GPG Key ID: 1D85E862314CA79F

@ -371,10 +371,7 @@ function useHighlightLoader() {
React.useEffect(() => { React.useEffect(() => {
if (!highLightsLoaded) { if (!highLightsLoaded) {
import('../lib/highlight-languages') import('../lib/highlight-languages')
.then(res => { .then(res => res.default.map(config => hljs.registerLanguage(config[0], config[1])))
// console.log(res.default)
res.default.map(config => hljs.registerLanguage(config[0], config[1]))
})
.then(() => { .then(() => {
highLightsLoaded = true highLightsLoaded = true
}) })
@ -442,8 +439,12 @@ function useSelectedLines(props, editorRef) {
}, [state.selected, props.children, props.config, editorRef]) }, [state.selected, props.children, props.config, editorRef])
React.useEffect(() => { React.useEffect(() => {
let selectedLines = props.config.selectedLines || [] if (props.config.selectedLines) {
dispatch({ type: 'MULTILINE', selectedLines }) dispatch({
type: 'MULTILINE',
selectedLines: props.config.selectedLines
})
}
}, [props.config.selectedLines]) }, [props.config.selectedLines])
return React.useCallback(function onGutterClick(editor, lineNumber, gutter, e) { return React.useCallback(function onGutterClick(editor, lineNumber, gutter, e) {
@ -453,14 +454,14 @@ function useSelectedLines(props, editorRef) {
}, []) }, [])
} }
function useShowInvisibleLoader() { function useShowInvisiblesLoader() {
React.useEffect(() => void require('cm-show-invisibles'), []) React.useEffect(() => void require('cm-show-invisibles'), [])
} }
function CarbonContainer(props, ref) { function CarbonContainer(props, ref) {
useModeLoader() useModeLoader()
useHighlightLoader() useHighlightLoader()
useShowInvisibleLoader() useShowInvisiblesLoader()
const editorRef = React.createRef() const editorRef = React.createRef()
const onGutterClick = useSelectedLines(props, editorRef) const onGutterClick = useSelectedLines(props, editorRef)

Loading…
Cancel
Save