Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Extensions #10

Open
stanonyime opened this issue Dec 22, 2015 · 9 comments
Open

Custom Extensions #10

stanonyime opened this issue Dec 22, 2015 · 9 comments

Comments

@stanonyime
Copy link

How does one add custom extensions? I followed the custom button example on the medium editor website added to the options but nothing appeared.

@wangzuo
Copy link
Owner

wangzuo commented Dec 23, 2015

what's the error?

@stanonyime
Copy link
Author

There was no error but the custom button did not show

@wangzuo
Copy link
Owner

wangzuo commented Dec 23, 2015

Any code snippet?

@stanonyime
Copy link
Author

This is how I tried using them together:

import Editor from 'react-medium-editor'
import React from 'react'
import MediumEditor from 'medium-editor'
var HighlighterButton = MediumEditor.Extension.extend({
  name: 'highlighter',

  init: function () {
    this.button = this.document.createElement('button');
    this.button.classList.add('medium-editor-action');
    this.button.innerHTML = '<b>H</b>';
  },

  getButton: function () {
    return this.button;
  }
});
class EditorMedium extends React.Component {
  render(){
  const buttons  = ['bold', 'italic', 'underline']
    return ( <Editor
          {...this.props}
          tag="p"
          text="Sample text"
          onChange={this.props.onValue}
          options={{toolbar: {buttons: buttons,extensions:{'highlighter': new HighlighterButton()}}}}
        />)
  }
}

When I render the element and make a selection, I only see the buttons for Bold, Italic, and Underline

@oyeanuj
Copy link

oyeanuj commented Jan 6, 2016

@wangzuo, thanks for this library! An add-on question:

  • Can extensions be React Components, i.e., the element is a React Component instead of a native HTML element?

@oyeanuj
Copy link

oyeanuj commented Feb 17, 2016

@stanonyime Did you find a solution to your problem above?

@wangzuo Any thoughts on my question above?

@stanonyime
Copy link
Author

@oyeanuj No

@ilyadoroshin
Copy link

I've used MediumButton and it worked fine, the only thing is that clicking this button doesn't trigger onChange event of react component..

@EugeneSnihovsky
Copy link

EugeneSnihovsky commented Nov 21, 2019

Hello guys! Is there a way to add medium-editor-insert-plugin? For now I can't figure out how to do this and switch to dark side - write my own react component with medium-editor. I already see this issue, but I don't use class component

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants