question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[draft-js-static-toolbar-plugin] custom buttons

See original GitHub issue

It seems that passing a structure array doesn’t work anymore to customize the toolbar buttons, i’ve seen the last commit where you deleted it.

https://github.com/draft-js-plugins/draft-js-plugins/commit/9b8b12ffdc4552d13ba5dfcfa1a1be4a21956cea

Would be nice to update the documentation (https://www.draft-js-plugins.com/plugin/static-toolbar), i’m still trying to figure out what you expect as Toolbar Children

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
kamikycommented, Oct 24, 2018

ok i managed to make it work, but it’s kinda dirty, i’m not sure this module version should remain. Toolbar children prop expect a function, so i copied this function (https://github.com/draft-js-plugins/draft-js-plugins/blob/9975f41d7f0533843882e5bf4e483081c17f7d12/draft-js-static-toolbar-plugin/src/components/Toolbar/index.js#L38)

export default class ToolbarEditor extends PureComponent {
...
renderButtons = (externalProps) => (
    <div>
      <ItalicButton {...externalProps} />
      <BoldButton {...externalProps} />
      <UnderlineButton {...externalProps} />
      <CodeButton {...externalProps} />
    </div>
  )

...

render() {
    return (
      <div>
        <div className='editor' onClick={this.focus}>
          <Editor
            editorState={this.state.editorState}
            onChange={this.onChange}
            plugins={plugins}
            ref={(element) => { this.editor = element; }}
          />
          <Toolbar children={this.renderButtons}></Toolbar>
        </div>
      </div>
    );
  }
}

you can then customize which button you want to return

0reactions
kamikycommented, Nov 30, 2018

great

Read more comments on GitHub >

github_iconTop Results From Across the Web

draftjs - custom button in inline toolbar that calls custom function
Basically, this is what you need to do: 1) import the inline toolbar plugin (bonus there is ...
Read more >
Toolbar - DraftJS Plugins - High quality plugins with great UX
Custom Static Toolbar Example. In this editor a toolbar shows up once you select part of the text …
Read more >
@draft-js-plugins/buttons - npm
Start using @draft-js-plugins/buttons in your project by running `npm i ... @draft-js-plugins/static-toolbar · @draft-js-plugins/emoji ...
Read more >
Customising toolbars - Draftail
By default, Draftail comes with a top static toolbar that ... styles hidden as individual buttons, and only present in the custom dropdown: ......
Read more >
@draft-js-plugins/buttons - npm package | Snyk
Learn more about @draft-js-plugins/buttons: package health score, popularity, security, maintenance, versions and more. ... @draft-js-plugins/static-toolbar.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found