Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing loading of materialdesign widgets
- Loading branch information
1 parent
c817bb3
commit 6afaf55
Showing
5 changed files
with
116 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import copy from 'copy-to-clipboard'; | ||
import AceEditor from 'react-ace'; | ||
|
||
import 'ace-builds/src-min-noconflict/mode-html'; | ||
import 'ace-builds/src-min-noconflict/worker-html'; | ||
import 'ace-builds/src-min-noconflict/ext-searchbox'; | ||
import 'ace-builds/src-min-noconflict/ext-language_tools'; | ||
import 'ace-builds/src-min-noconflict/theme-clouds_midnight'; | ||
import 'ace-builds/src-min-noconflict/theme-chrome'; | ||
|
||
import { | ||
Dialog, Button, DialogActions, DialogContent, DialogTitle, | ||
} from '@mui/material'; | ||
|
||
import IconCopy from '@mui/icons-material/ContentCopy'; | ||
import CloseIcon from '@mui/icons-material/Close'; | ||
|
||
import { I18n } from '@iobroker/adapter-react-v5'; | ||
|
||
class CodeDialog extends Component { | ||
render() { | ||
return <Dialog | ||
open={!0} | ||
onClose={() => this.props.onClose()} | ||
maxWidth="xl" | ||
fullWidth | ||
> | ||
<DialogTitle>{this.props.title || I18n.t('Code')}</DialogTitle> | ||
<DialogContent> | ||
<AceEditor | ||
mode={this.props.mode || 'html'} | ||
theme={this.props.themeType === 'dark' ? 'clouds_midnight' : 'chrome'} | ||
readOnly | ||
value={this.props.code} | ||
width="100%" | ||
setOptions={{ | ||
enableBasicAutocompletion: true, | ||
enableLiveAutocompletion: true, | ||
enableSnippets: true, | ||
}} | ||
/> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button | ||
variant="contained" | ||
onClick={() => { | ||
copy(this.props.code); | ||
window.alert(I18n.t('Copied to clipboard')); | ||
}} | ||
startIcon={<IconCopy />} | ||
color="primary" | ||
> | ||
{I18n.t('Copy to clipboard')} | ||
</Button> | ||
<Button | ||
variant="contained" | ||
color="grey" | ||
startIcon={<CloseIcon />} | ||
onClick={() => this.props.onClose()} | ||
> | ||
{I18n.t('Close')} | ||
</Button> | ||
</DialogActions> | ||
</Dialog>; | ||
} | ||
} | ||
|
||
CodeDialog.propTypes = { | ||
onClose: PropTypes.func.isRequired, | ||
title: PropTypes.string, | ||
themeType: PropTypes.string, | ||
code: PropTypes.string.isRequired, | ||
mode: PropTypes.string, | ||
}; | ||
|
||
export default CodeDialog; |
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