draft-js-plugin-buttons: Support sub and sup buttons + custom button
See original GitHub issueHi, it would be great if draft-js-buttons
could have support for sub and sup buttons. Also, it would be nice if there was a function to create custom buttons where one could extend the click event to handle external stuff like file uploads etc.
This is the code I use today to get sub/sup:
import React from 'react'
import createInlineStyleButton from 'draft-js-buttons/lib/utils/createInlineStyleButton'
export default createInlineStyleButton({
style: 'SUBSCRIPT',
children: (
<div className="SubButton-button ToolbarButton-button">
x<sub>2</sub>
</div>
)
})
import React from 'react'
import createInlineStyleButton from 'draft-js-buttons/lib/utils/createInlineStyleButton'
export default createInlineStyleButton({
style: 'SUPERSCRIPT',
children: (
<div className="SupButton-button ToolbarButton-button">
x<sup>2</sup>
</div>
)
})
And also in the editor customStyleFn:
<Editor ....
customStyleMap={ {
SUBSCRIPT: { fontSize: '0.6em', verticalAlign: 'sub' },
SUPERSCRIPT: { fontSize: '0.6em', verticalAlign: 'super' }
}} />
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top Results From Across the Web
@draft-js-plugins/buttons - npm
Start using @draft-js-plugins/buttons in your project by running `npm i @draft-js-plugins/buttons`. There are 14 other projects in the npm ...
Read more >Editor Component - Draft.js
This article discusses the API and props of the core controlled contentEditable.
Read more >How to use the draft-js-buttons.createBlockStyleButton ... - Snyk
To help you get started, we've selected a few draft-js-buttons.createBlockStyleButton examples, based on popular ways it is used in public projects.
Read more >NetSuite Applications Suite - Configuring Buttons and Actions
SCM (Supply Chain Management) ... JavaScript Configuration Files ... Working with Standard Buttons · Working with Custom Buttons · About Button and Action ......
Read more >npm:@draft-js-plugins/buttons - Skypack.dev
DraftJS Buttons · Important: Include after the Editor · Using the Subscript and Superscript buttons requires a custom style map: · Details.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@tarjei wanna make a pr to add those buttons? Would be happy to merge that in 👍
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.