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

How do you install a plugin? #44

Open
GraemeFulton opened this issue Mar 3, 2018 · 3 comments
Open

How do you install a plugin? #44

GraemeFulton opened this issue Mar 3, 2018 · 3 comments

Comments

@GraemeFulton
Copy link

I tried adding a script for a plugin to the bottom of my react app, but it's not picked up when I add it to the plugins in React

I add the Summernote image attributes:

<body>
    <div id="root"></div>
  </body>
  <script src="/summernote-image-attributes.js"></script>

Then include in react:

<ReactSummernote
        value="Default value"
        options={{
          lang: 'ru-RU',
          height: 350,
          dialogsInBody: true,
          toolbar: [
            ['style', ['style']],
            ['font', ['bold', 'underline', 'clear']],
            ['fontname', ['fontname']],
            ['para', ['ul', 'ol', 'paragraph']],
            ['table', ['table']],
            ['insert', ['link', 'picture', 'video']],
            ['view', ['fullscreen', 'codeview']]
          ],
          **popover: {
            image: [
                ['custom', ['imageAttributes']],
                ['imagesize', ['imageSize100', 'imageSize50', 'imageSize25']],
                ['float', ['floatLeft', 'floatRight', 'floatNone']],
                ['remove', ['removeMedia']]
            ]}**
        }}
        onChange={this.onChange}
      />

But nothing changes

@jakeols
Copy link

jakeols commented Mar 16, 2018

I'm experiencing the same issue, does anyone have an idea on how exactly should this be done?

@AdrianPasalega
Copy link

AdrianPasalega commented Feb 12, 2019

You need to find the npm module and install it (ex: npm i @dsvllc/summernote-image-attributes) , then import the plugin (ex: import ImagePulgin from '@dsvllc/summernote-image-attributes') in the component where you use and it should work.

In case there is no npm module try: https://stackoverflow.com/questions/34424845/adding-script-tag-to-react-jsx

@zedtux
Copy link

zedtux commented Nov 13, 2022

Here is how I made it working :

  1. Install the library
  • yarn add <plugin name> if there's an NPM package existing on npmjs.com
  • yarn add <Git URL to the repository> if there's a public git repository. You can also add the last commit SHA to the yarn command by adding a dash # and then the commit SHA avoiding to update the plugin accidentally.
  1. Require the plugin code and CSS from the JSX file where you're mounting ReactSummernote :
import React from 'react'
import ReactSummernote from 'react-summernote'
import 'react-summernote/dist/react-summernote.css'
// ...

import 'plugin name here'
import 'plugin CSS file path here'

const MyComponent = () => (
  <ReactSummernote options={{ ... }} />
)

export default MyComponent

A non-NPM example

Let's say I'd like to add the summernote-paper-size plugin which doesn't have a published NPM package, nor a package.json file (I have to give the path to the JavaScript file) :

yarn add https://github.com/DiemenDesign/summernote-paper-size.git#0a9d09b3d09a22e9d824e66e0836dfb8cdf9773d
import React from 'react'
import ReactSummernote from 'react-summernote'
import 'react-summernote/dist/react-summernote.css'

import 'summernote-paper-size/summernote-paper-size'

const MyComponent = () => (
  <ReactSummernote
    options={{
      ['paperSize', ['paperSize']]
    }}
  />
)

export default MyComponent

I also added the line @import "summernote-paper-size/css/css.css"; in my SCSS file of my application so that the plugin's CSS is available.

An NPM example

Let's say I'd like to add the summernote-ext-print plugin :

yarn add summernote-ext-print
import React from 'react'
import ReactSummernote from 'react-summernote'
import 'react-summernote/dist/react-summernote.css'

import 'summernote-ext-print'

const MyComponent = () => (
  <ReactSummernote
    options={{
      ['misc', ['print']]
    }}
  />
)

export default MyComponent

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

4 participants