-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add readonly RTE to sandbox. Add caption image for initial content.
- Loading branch information
1 parent
91b9eed
commit 3fae668
Showing
4 changed files
with
862 additions
and
1,203 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,5 @@ | ||
.container { | ||
width: 60vw; | ||
max-width: 1024px; | ||
margin: 24px auto; | ||
} |
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,101 @@ | ||
import * as React from 'react'; | ||
import { | ||
SlateEditor, | ||
defaultPlugins, | ||
imagePlugin, | ||
videoPlugin, | ||
attachmentPlugin, | ||
toDoListPlugin, | ||
baseMarksPlugin, | ||
linkPlugin, | ||
iframePlugin, | ||
notePlugin, | ||
separatorPlugin, | ||
uploadFilePlugin, | ||
tablePlugin, | ||
quotePlugin, | ||
colorPlugin, | ||
superscriptPlugin, | ||
headerPlugin, | ||
listPlugin, | ||
placeholderPlugin, | ||
codeBlockPlugin, | ||
EditorValue, | ||
} from '@epam/uui-editor'; | ||
import { svc } from '../../services'; | ||
import { demoData } from '@epam/uui-docs'; | ||
import css from './RichTextEditorDemo.module.scss'; | ||
import { ErrorNotification, Text } from '@epam/uui'; | ||
import { FileUploadResponse } from '@epam/uui-core'; | ||
|
||
interface SlateEditorBasicExampleState { | ||
value: EditorValue; | ||
} | ||
|
||
export class RichTextEditorDemoReadonly extends React.Component<any, SlateEditorBasicExampleState> { | ||
state: SlateEditorBasicExampleState = { | ||
value: demoData.slateInitialValue, | ||
}; | ||
|
||
onChange = (value: EditorValue) => { | ||
this.setState({ value: value }); | ||
}; | ||
|
||
uploadFile = (file: File): Promise<FileUploadResponse> => { | ||
return svc.uuiApi.uploadFile('/upload/uploadFileMock', file, {}) | ||
.catch((res) => { | ||
svc.uuiNotifications.show((props) => | ||
<ErrorNotification { ...props }><Text>{ res.error.message }</Text></ErrorNotification>).catch(() => {}); | ||
return Promise.reject(res); | ||
}); | ||
}; | ||
|
||
plugins = [ | ||
...defaultPlugins, | ||
...baseMarksPlugin(), | ||
headerPlugin(), | ||
colorPlugin(), | ||
superscriptPlugin(), | ||
listPlugin(), | ||
toDoListPlugin(), | ||
quotePlugin(), | ||
linkPlugin(), | ||
notePlugin(), | ||
uploadFilePlugin({ uploadFile: this.uploadFile }), | ||
attachmentPlugin(), | ||
imagePlugin(), | ||
videoPlugin(), | ||
iframePlugin(), | ||
separatorPlugin(), | ||
tablePlugin(), | ||
placeholderPlugin({ | ||
items: [ | ||
{ | ||
name: 'Name', | ||
field: 'name', | ||
}, | ||
{ | ||
name: 'Email', | ||
field: 'email', | ||
}, | ||
], | ||
}), | ||
codeBlockPlugin(), | ||
]; | ||
|
||
render() { | ||
return ( | ||
<div className={ css.container }> | ||
<SlateEditor | ||
value={ this.state.value } | ||
onValueChange={ this.onChange } | ||
autoFocus={ true } | ||
plugins={ this.plugins } | ||
placeholder="Add description" | ||
minHeight="none" | ||
isReadonly={ true } | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
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
Oops, something went wrong.