Skip to content

Commit 1020409

Browse files
freedomlangjuliankrispel
authored andcommitted
docs(static-toolbar): update doc and story for refactor via render prop
1 parent 9b8b12f commit 1020409

File tree

2 files changed

+42
-32
lines changed
  • docs/client/components/pages/StaticToolbar/CustomToolbarEditor
  • stories/static-toolbar-custom-buttons/src

2 files changed

+42
-32
lines changed

docs/client/components/pages/StaticToolbar/CustomToolbarEditor/index.js

+20-15
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,7 @@ class HeadlinesButton extends Component {
6464
}
6565
}
6666

67-
const toolbarPlugin = createToolbarPlugin({
68-
structure: [
69-
BoldButton,
70-
ItalicButton,
71-
UnderlineButton,
72-
CodeButton,
73-
Separator,
74-
HeadlinesButton,
75-
UnorderedListButton,
76-
OrderedListButton,
77-
BlockquoteButton,
78-
CodeBlockButton
79-
]
80-
});
67+
const toolbarPlugin = createToolbarPlugin();
8168
const { Toolbar } = toolbarPlugin;
8269
const plugins = [toolbarPlugin];
8370
const text = 'In this editor a toolbar shows up once you select part of the text …';
@@ -108,7 +95,25 @@ export default class CustomToolbarEditor extends Component {
10895
plugins={plugins}
10996
ref={(element) => { this.editor = element; }}
11097
/>
111-
<Toolbar />
98+
<Toolbar>
99+
{
100+
// may be use React.Fragment instead of div to improve perfomance after React 16
101+
(externalProps) => (
102+
<div>
103+
<BoldButton {...externalProps} />
104+
<ItalicButton {...externalProps} />
105+
<UnderlineButton {...externalProps} />
106+
<CodeButton {...externalProps} />
107+
<Separator {...externalProps} />
108+
<HeadlinesButton {...externalProps} />
109+
<UnorderedListButton {...externalProps} />
110+
<OrderedListButton {...externalProps} />
111+
<BlockquoteButton {...externalProps} />
112+
<CodeBlockButton {...externalProps} />
113+
</div>
114+
)
115+
}
116+
</Toolbar>
112117
</div>
113118
</div>
114119
);

stories/static-toolbar-custom-buttons/src/App.js

+22-17
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,7 @@ class HeadlinesButton extends Component {
6666
}
6767
}
6868

69-
const toolbarPlugin = createToolbarPlugin({
70-
structure: [
71-
BoldButton,
72-
ItalicButton,
73-
UnderlineButton,
74-
CodeButton,
75-
Separator,
76-
HeadlinesButton,
77-
UnorderedListButton,
78-
OrderedListButton,
79-
BlockquoteButton,
80-
CodeBlockButton,
81-
SubButton,
82-
SupButton
83-
]
84-
});
69+
const toolbarPlugin = createToolbarPlugin();
8570
const { Toolbar } = toolbarPlugin;
8671
const plugins = [toolbarPlugin];
8772
const text = 'Remember to place the <Toolbar> component bellow the Editor component …';
@@ -116,7 +101,27 @@ export default class CustomToolbarEditor extends Component {
116101
}}
117102
ref={(element) => { this.editor = element; }}
118103
/>
119-
<Toolbar />
104+
<Toolbar>
105+
{
106+
// may be use React.Fragment instead of div to improve perfomance after React 16
107+
(externalProps) => (
108+
<div>
109+
<BoldButton {...externalProps} />
110+
<ItalicButton {...externalProps} />
111+
<UnderlineButton {...externalProps} />
112+
<CodeButton {...externalProps} />
113+
<Separator {...externalProps} />
114+
<HeadlinesButton {...externalProps} />
115+
<UnorderedListButton {...externalProps} />
116+
<OrderedListButton {...externalProps} />
117+
<BlockquoteButton {...externalProps} />
118+
<CodeBlockButton {...externalProps} />
119+
<SubButton {...externalProps} />
120+
<SupButton {...externalProps} />
121+
</div>
122+
)
123+
}
124+
</Toolbar>
120125
</div>
121126
</div>
122127
);

0 commit comments

Comments
 (0)