/sharepoint-react-suneditor

A simple SunEditor React component wrapper made to work with SharePoint 2016 On-Premises

Primary LanguageJavaScript

sharepoint-react-suneditor

A simple SunEditor React component wrapper made to work with SharePoint 2016 On-Premises

NPM JavaScript Style Guide

Description

This package aims to provide a React component wrapper for the SunEditor WYSIWYG that should work with SharePoint Framework (SPFx) 1.1 (which is the required version for SharePoint 2016 On-Premises) and consequently relies on React 15.4.2 (since SPFx 1.1 is pinned to) (See Andrew Connell comment about versions).

If you are looking for a more general component, please see suneditor-react.

Install

npm install --save sharepoint-react-suneditor

Usage

import React from 'react'

import { SPSunEditor } from 'sharepoint-react-suneditor';
import 'suneditor/dist/css/suneditor.min.css';

class Example extends React.Component {
  render() {
    return <SPSunEditor />
  }
}

Default SunEditor options can be passed through sunEditorOptions prop. However, some options such as plugins and lang have their own prop (See below, Props).

<SPSunEditor sunEditorOptions={{
    height: 220, 
    width: 512, 
    buttonList: [ ['bold', 'underline', 'italic'], ['list'], ['link'], ['image'] ], 
  }} 
  onChange={this._onChange.bind(this)} 
/>

Props

sunEditorOptions : SunEditor native options

Those are the native options that come with SunEditor.

customPlugins : Add your custom plugins

An array of custom plugins.

lang : Define language

Takes a language code (en, de, fr...).

Run an example

  1. Clone this repository,
  2. run npm install,
  3. run npm start both in root and example folders.

Todo

  • Make upload work with SharePoint

Credits

A great thank you to SunEditor's creator and active maintainer, JiHong88.

License

MIT © Salah