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-plugin-buttons: Support sub and sup buttons + custom button

See original GitHub issue

Hi, 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
juliankrispelcommented, Sep 25, 2017

@tarjei wanna make a pr to add those buttons? Would be happy to merge that in 👍

0reactions
stale[bot]commented, Nov 20, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

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