Skip to content

Commit

Permalink
fix: rename provider
Browse files Browse the repository at this point in the history
  • Loading branch information
z4o4z committed Jun 21, 2023
1 parent 8e81690 commit c822352
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ReactEditor } from '../plugin/react-editor'

import { Provider } from './provider'

export const ControlsProvider = (props: {
export const ToolbarProvider = (props: {
editor: ReactEditor
children: React.ReactNode
}) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/slate-react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export {
export { DefaultElement } from './components/element'
export { DefaultLeaf } from './components/leaf'
export { Slate } from './components/slate'
export { ControlsProvider } from './components/controls-provider'
export { ToolbarProvider } from './components/toolbar-provider'

// Hooks
export { useEditor } from './hooks/use-editor'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
withReact,
useSlate,
Slate,
ControlsProvider,
ToolbarProvider,
} from 'slate-react'
import {
Editor,
Expand All @@ -28,14 +28,14 @@ const HOTKEYS = {
const LIST_TYPES = ['numbered-list', 'bulleted-list']
const TEXT_ALIGN_TYPES = ['left', 'center', 'right', 'justify']

const RichTextDetachedControlsExample = () => {
const RichTextDetachedToolbarExample = () => {
const renderElement = useCallback(props => <Element {...props} />, [])
const renderLeaf = useCallback(props => <Leaf {...props} />, [])
const editor = useMemo(() => withHistory(withReact(createEditor())), [])

return (
<>
<ControlsProvider editor={editor}>
<ToolbarProvider editor={editor}>
<Toolbar style={{ marginBottom: 20 }}>
<MarkButton format="bold" icon="format_bold" />
<MarkButton format="italic" icon="format_italic" />
Expand All @@ -51,7 +51,7 @@ const RichTextDetachedControlsExample = () => {
<BlockButton format="right" icon="format_align_right" />
<BlockButton format="justify" icon="format_align_justify" />
</Toolbar>
</ControlsProvider>
</ToolbarProvider>

<Slate editor={editor} initialValue={initialValue}>
<Editable
Expand Down Expand Up @@ -281,4 +281,4 @@ const initialValue: Descendant[] = [
},
]

export default RichTextDetachedControlsExample
export default RichTextDetachedToolbarExample
8 changes: 4 additions & 4 deletions site/pages/examples/[example].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Styling from '../../examples/styling'
import Tables from '../../examples/tables'
import IFrames from '../../examples/iframe'
import CustomPlaceholder from '../../examples/custom-placeholder'
import ReachTextDetachedControls from '../../examples/richtext-detached-controls'
import RichTextDetachedToolbarExample from '../../examples/richtext-detached-toolbar'

// node
import { getAllExamples } from '../api'
Expand All @@ -52,9 +52,9 @@ const EXAMPLES = [
['Read-only', ReadOnly, 'read-only'],
['Rich Text', RichText, 'richtext'],
[
'Rich Text Detached Controls',
ReachTextDetachedControls,
'richtext-detached-controls',
'Rich Text Detached Toolbar',
RichTextDetachedToolbarExample,
'richtext-detached-toolbar',
],
['Search Highlighting', SearchHighlighting, 'search-highlighting'],
['Shadow DOM', ShadowDOM, 'shadow-dom'],
Expand Down

0 comments on commit c822352

Please sign in to comment.