Added wrapper element around react editor loading/error/editor states

no issue

- has a default class of `koenig-react-editor` which can be added to by using `@className`
- adds classes of `koenig-react-editor-loading` and `koenig-react-editor-error` to the `<p>` elements rendered during loading or when loading fails
This commit is contained in:
Kevin Ansfield 2022-08-04 15:55:37 +01:00
parent fa8d94fce2
commit 677f2961f4

View File

@ -13,7 +13,7 @@ class ErrorHandler extends React.Component {
render() { render() {
if (this.state.hasError) { if (this.state.hasError) {
return ( return (
<p>Loading has failed. Try refreshing the browser!</p> <p className="koenig-react-editor-error">Loading has failed. Try refreshing the browser!</p>
); );
} }
@ -80,15 +80,17 @@ const Koenig = (props) => {
export default class KoenigReactEditor extends Component { export default class KoenigReactEditor extends Component {
ReactComponent = () => { ReactComponent = () => {
return ( return (
<ErrorHandler> <div className={['koenig-react-editor', this.args.className].filter(Boolean).join(' ')}>
<Suspense fallback={<p>Loading editor...</p>}> <ErrorHandler>
<Koenig <Suspense fallback={<p className="koenig-react-editor-loading">Loading editor...</p>}>
mobiledoc={this.args.mobiledoc} <Koenig
didCreateEditor={this.args.didCreateEditor} mobiledoc={this.args.mobiledoc}
onChange={this.args.onChange} didCreateEditor={this.args.didCreateEditor}
/> onChange={this.args.onChange}
</Suspense> />
</ErrorHandler> </Suspense>
</ErrorHandler>
</div>
); );
}; };
} }