);
};
const HeadlinesButton = ({ onOverrideContent }): ReactElement => {
// When using a click event inside overridden content, mouse down
// events needs to be prevented so the focus stays in the editor
// and the toolbar remains visible onMouseDown = (event) => event.preventDefault()
const onMouseDown = (event): void => event.preventDefault();
const onClick = (): void =>
// A button can call `onOverrideContent` to replace the content
// of the toolbar. This can be useful for displaying sub
// menus or requesting additional information from the user.
onOverrideContent(HeadlinesPicker);
return (
);
};
const inlineToolbarPlugin = createInlineToolbarPlugin();
const { InlineToolbar } = inlineToolbarPlugin;
const plugins = [inlineToolbarPlugin];
const text =
'In this editor a toolbar shows up once you select part of the text …';
const CustomInlineToolbarEditor = (): ReactElement => {
const [editorState, setEditorState] = useState(
createEditorStateWithText(text)
);
const editor = useRef();
const onChange = (value): void => {
setEditorState(value);
};
const focus = (): void => {
editor.current.focus();
};
return (
{
editor.current = element;
}}
/>
{
// may be use React.Fragment instead of div to improve perfomance after React 16
(externalProps) => (