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() {
if (this.state.hasError) {
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 {
ReactComponent = () => {
return (
<ErrorHandler>
<Suspense fallback={<p>Loading editor...</p>}>
<Koenig
mobiledoc={this.args.mobiledoc}
didCreateEditor={this.args.didCreateEditor}
onChange={this.args.onChange}
/>
</Suspense>
</ErrorHandler>
<div className={['koenig-react-editor', this.args.className].filter(Boolean).join(' ')}>
<ErrorHandler>
<Suspense fallback={<p className="koenig-react-editor-loading">Loading editor...</p>}>
<Koenig
mobiledoc={this.args.mobiledoc}
didCreateEditor={this.args.didCreateEditor}
onChange={this.args.onChange}
/>
</Suspense>
</ErrorHandler>
</div>
);
};
}