Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@toast-ui/react-editor

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@toast-ui/react-editor - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0-alpha

index.d.ts

2

dist/toastui-react-editor.js

@@ -1,1 +0,1 @@

module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=3)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("tui-editor")},function(e,t){e.exports=require("tui-editor/dist/tui-editor-Viewer")},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),i=n(1),u=n.n(i);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var y=function(e){function t(){var e,n,r,i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var u=arguments.length,f=new Array(u),l=0;l<u;l++)f[l]=arguments[l];return r=this,n=!(i=(e=a(t)).call.apply(e,[this].concat(f)))||"object"!==c(i)&&"function"!=typeof i?s(r):i,p(s(s(n)),"rootEl",o.a.createRef()),p(s(s(n)),"editorInst",null),n}var n,r,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(t,o.a.Component),n=t,(r=[{key:"getRootElement",value:function(){return this.rootEl.current}},{key:"getInstance",value:function(){return this.editorInst}},{key:"bindEventHandlers",value:function(e,t){var n=this;Object.keys(e).filter(function(e){return/on[A-Z][a-zA-Z]+/.test(e)}).forEach(function(r){var o=r[2].toLowerCase()+r.slice(3);t&&t[r]!==e[r]&&n.editorInst.off(o),n.editorInst.on(o,e[r])})}},{key:"componentDidMount",value:function(){this.editorInst=new u.a(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){p(e,t,n[t])})}return e}({el:this.rootEl.current},this.props)),this.bindEventHandlers(this.props)}},{key:"shouldComponentUpdate",value:function(e){var t=this.getInstance(),n=e.height,r=e.previewStyle;return this.props.height!==n&&t.height(n),this.props.previewStyle!==r&&t.changePreviewStyle(r),this.bindEventHandlers(e,this.props),!1}},{key:"render",value:function(){return o.a.createElement("div",{ref:this.rootEl})}}])&&f(n.prototype,r),i&&f(n,i),t}(),b=n(2),h=n.n(b);function v(e){return(v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function m(e){return(m=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function O(e,t){return(O=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function w(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function g(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var j=function(e){function t(){var e,n,r,i;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var u=arguments.length,c=new Array(u),f=0;f<u;f++)c[f]=arguments[f];return r=this,n=!(i=(e=m(t)).call.apply(e,[this].concat(c)))||"object"!==v(i)&&"function"!=typeof i?w(r):i,g(w(w(n)),"rootEl",o.a.createRef()),g(w(w(n)),"viewerInst",null),n}var n,r,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&O(e,t)}(t,o.a.Component),n=t,(r=[{key:"getRootElement",value:function(){return this.rootEl.current}},{key:"getInstance",value:function(){return this.viewerInst}},{key:"bindEventHandlers",value:function(e,t){var n=this;Object.keys(this.props).filter(function(e){return/on[A-Z][a-zA-Z]+/.test(e)}).forEach(function(r){var o=r[2].toLowerCase()+r.slice(3);t&&t[r]!==e[r]&&n.viewerInst.off(o),n.viewerInst.on(o,e[r])})}},{key:"componentDidMount",value:function(){this.viewerInst=new h.a(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){g(e,t,n[t])})}return e}({el:this.rootEl.current},this.props)),this.bindEventHandlers(this.props)}},{key:"shouldComponentUpdate",value:function(e){var t=this.props.initialValue,n=e.initialValue;return t!==n&&this.getInstance().setValue(n),this.bindEventHandlers(e,this.props),!1}},{key:"render",value:function(){return o.a.createElement("div",{ref:this.rootEl})}}])&&d(n.prototype,r),i&&d(n,i),t}();n.d(t,"Editor",function(){return y}),n.d(t,"Viewer",function(){return j})}]);
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=3)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("@toast-ui/editor")},function(e,t){e.exports=require("@toast-ui/editor/dist/toastui-editor-viewer")},function(e,t,r){"use strict";r.r(t),r.d(t,"Editor",(function(){return v})),r.d(t,"Viewer",(function(){return I}));var n=r(0),o=r.n(n),i=r(1),u=r.n(i);function c(e){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t){return!t||"object"!==c(t)&&"function"!=typeof t?y(e):t}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var v=function(e){function t(){var e,r;a(this,t);for(var n=arguments.length,i=new Array(n),u=0;u<n;u++)i[u]=arguments[u];return h(y(r=s(this,(e=p(t)).call.apply(e,[this].concat(i)))),"rootEl",o.a.createRef()),h(y(r),"editorInst",null),r}var r,n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(t,e),r=t,(n=[{key:"getRootElement",value:function(){return this.rootEl.current}},{key:"getInstance",value:function(){return this.editorInst}},{key:"bindEventHandlers",value:function(e){var t=this;Object.keys(this.props).filter((function(e){return/^on[A-Z][a-zA-Z]+/.test(e)})).forEach((function(r){var n=r[2].toLowerCase()+r.slice(3);t.editorInst.off(n),t.editorInst.on(n,e[r])}))}},{key:"componentDidMount",value:function(){this.editorInst=new u.a(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){h(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({el:this.rootEl.current},this.props)),this.bindEventHandlers(this.props)}},{key:"shouldComponentUpdate",value:function(e){var t=this.getInstance(),r=e.height,n=e.previewStyle;return this.props.height!==r&&t.height(r),this.props.previewStyle!==n&&t.changePreviewStyle(n),this.bindEventHandlers(e,this.props),!1}},{key:"render",value:function(){return o.a.createElement("div",{ref:this.rootEl})}}])&&l(r.prototype,n),i&&l(r,i),t}(o.a.Component),d=r(2),O=r.n(d);function j(e){return(j="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function w(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function g(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function P(e,t){return!t||"object"!==j(t)&&"function"!=typeof t?S(e):t}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function S(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function k(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var I=function(e){function t(){var e,r;m(this,t);for(var n=arguments.length,i=new Array(n),u=0;u<n;u++)i[u]=arguments[u];return k(S(r=P(this,(e=E(t)).call.apply(e,[this].concat(i)))),"rootEl",o.a.createRef()),k(S(r),"viewerInst",null),r}var r,n,i;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_(e,t)}(t,e),r=t,(n=[{key:"getRootElement",value:function(){return this.rootEl.current}},{key:"getInstance",value:function(){return this.viewerInst}},{key:"bindEventHandlers",value:function(e){var t=this;Object.keys(this.props).filter((function(e){return/^on[A-Z][a-zA-Z]+/.test(e)})).forEach((function(r){var n=r[2].toLowerCase()+r.slice(3);t.viewerInst.off(n),t.viewerInst.on(n,e[r])}))}},{key:"componentDidMount",value:function(){this.viewerInst=new O.a(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?w(Object(r),!0).forEach((function(t){k(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):w(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({el:this.rootEl.current},this.props)),this.bindEventHandlers(this.props)}},{key:"shouldComponentUpdate",value:function(e){var t=this.props.initialValue,r=e.initialValue;return t!==r&&this.getInstance().setValue(r),this.bindEventHandlers(e,this.props),!1}},{key:"render",value:function(){return o.a.createElement("div",{ref:this.rootEl})}}])&&g(r.prototype,n),i&&g(r,i),t}(o.a.Component)}]);
{
"name": "@toast-ui/react-editor",
"version": "1.0.1",
"version": "2.0.0-alpha",
"description": "TOAST UI Editor for React",
"main": "dist/toastui-react-editor.js",
"files": [
"dist",
"src",
"index.d.ts"
],
"scripts": {

@@ -51,4 +56,4 @@ "lint": "eslint src/**",

"dependencies": {
"tui-editor": "^1.3.0"
"@toast-ui/editor": "^2.0.0-alpha"
}
}
# TOAST UI Editor for React
> This is a React component wrapping [TOAST UI Editor](https://github.com/nhn/tui.editor).
> This is a [React](https://reactjs.org/) component wrapping [TOAST UI Editor](https://github.com/nhn/tui.editor/apps/editor).
[![github version](https://img.shields.io/github/release/nhn/toast-ui.react-editor.svg)](https://github.com/nhn/toast-ui.react-editor/releases/latest)
[![npm version](https://img.shields.io/npm/v/@toast-ui/react-editor.svg)](https://www.npmjs.com/package/@toast-ui/react-editor)
[![license](https://img.shields.io/github/license/nhn/toast-ui.react-editor.svg)](https://github.com/nhn/toast-ui.react-editor/blob/master/LICENSE)
[![PRs welcome](https://img.shields.io/badge/PRs-welcome-ff69b4.svg)](https://github.com/nhn/toast-ui.react-editor/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22)
[![code with hearth by NHN](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-NHN-ff1414.svg)](https://github.com/nhn)
## 🚩 Table of Contents
* [Collect statistics on the use of open source](#collect-statistics-on-the-use-of-open-source)
* [Install](#-install)
* [Using npm](#using-npm)
* [Usage](#-usage)
* [Import](#import)
* [Props](#props)
* [Instance Methods](#instance-methods)
* [Getting the root element](#getting-the-root-element)
* [Events](#events)
* [Pull Request Steps](#-pull-request-steps)
* [Documents](#-documents)
* [Contributing](#-contributing)
* [License](#-license)
## Collect statistics on the use of open source
- [Collect Statistics on the Use of Open Source](#collect-statistics-on-the-use-of-open-source)
- [Install](#-install)
- [Usage](#-usage)
React Wrapper of TOAST UI Editor applies Google Analytics (GA) to collect statistics on the use of open source, in order to identify how widely TOAST UI Editor is used throughout the world. It also serves as important index to determine the future course of projects. location.hostname (e.g. > “ui.toast.com") is to be collected and the sole purpose is nothing but to measure statistics on the usage. To disable GA, use the `usageStatistics` props like the example below.
## Collect Statistics on the Use of Open Source
React Wrapper of TOAST UI Editor applies Google Analytics (GA) to collect statistics on the use of open source, in order to identify how widely TOAST UI Editor is used throughout the world. It also serves as important index to determine the future course of projects. location.hostname (e.g. ui.toast.com) is to be collected and the sole purpose is nothing but to measure statistics on the usage. To disable GA, use the `usageStatistics` props like the example below.
```js
<Editor
<Editor
...
usageStatistics={false}
usageStatistics={false}
/>
```
Or, import `tui-code-snippet.js` (**v1.4.0** or **later**) and then immediately write the options as follows:
```js
tui.usageStatistics = false;
```
## 💾 Install

@@ -50,24 +32,24 @@

## 🔡 Usage
## 📝 Usage
### Import
You can use Toast UI Editor for React as a ECMAScript module or a CommonJS module. As this module does not contain CSS files, you should import `tui-editor.css`, `tui-editor-contents.css` from `tui-editor` and `codemirror.css` from `codemirror.css` in the script.
You can use TOAST UI Editor for React as a ECMAScript module or a CommonJS module. As this module does not contain CSS files, you should import `toastui-editor.css` from `@toast-ui/editor` and `codemirror.css` from `CodeMirror` in the script.
* Using ECMAScript module
- ES Modules
```js
import 'codemirror/lib/codemirror.css';
import 'tui-editor/dist/tui-editor.min.css';
import 'tui-editor/dist/tui-editor-contents.min.css';
import { Editor } from '@toast-ui/react-editor'
import '@toast-ui/editor/dist/toastui-editor.css';
import { Editor } from '@toast-ui/react-editor';
```
* Using CommonJS module
- CommonJS
```js
require('codemirror/lib/codemirror.css');
require('tui-editor/dist/tui-editor.min.css');
require('tui-editor/dist/tui-editor-contents.min.css');
const Editor = require('@toast-ui/react-editor');
require('@toast-ui/editor/dist/toastui-editor.css');
const { Editor } = require('@toast-ui/react-editor');
```

@@ -77,3 +59,3 @@

[All the options of the TOAST UI Editor](https://nhn.github.io/tui.editor/api/latest/ToastUIEditor.html#ToastUIEditor) are supported in the form of props.
[All the options of the TOAST UI Editor](https://nhn.github.io/tui.editor/latest/ToastUIEditor) are supported in the form of props.

@@ -88,16 +70,2 @@ ```js

useCommandShortcut={true}
exts={[
{
name: 'chart',
minWidth: 100,
maxWidth: 600,
minHeight: 100,
maxHeight: 300
},
'scrollSync',
'colorSyntax',
'uml',
'mark',
'table'
]}
/>

@@ -109,3 +77,3 @@ );

For using [instance methods of TOAST UI Editor](https://nhn.github.io/tui.editor/api/latest/ToastUIEditor.html#.defineExtension), first thing to do is creating Refs of wrapper component using [`createRef()`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs). But the wrapper component does not provide a way to call instance methods of TOAST UI Editor directly. Instead, you can call `getInstance()` method of the wrapper component to get the instance, and call the methods on it.
For using [instance methods of TOAST UI Editor](https://nhn.github.io/tui.editor/latest/ToastUIEditor#addHook), first thing to do is creating Refs of wrapper component using [`createRef()`](https://reactjs.org/docs/refs-and-the-dom.html#creating-refs). But the wrapper component does not provide a way to call instance methods of TOAST UI Editor directly. Instead, you can call `getInstance()` method of the wrapper component to get the instance, and call the methods on it.

@@ -137,3 +105,3 @@ ```js

### Getting the root element
#### Getting the Root Element

@@ -145,6 +113,6 @@ An instance of the wrapper component also provides a handy method for getting the root element. If you want to manipulate the root element directly, you can call `getRootElement` to get the element.

editorRef = React.createRef();
handleClickButton = () => {
this.editorRef.current.getRootElement().classList.add('my-editor-root');
}
};

@@ -169,4 +137,5 @@ render() {

### Events
[All the events of TOAST UI Editor](https://nhn.github.io/tui.editor/api/latest/ToastUIEditor.html#focus) are supported in the form of `on[EventName]` props. The first letter of each event name should be capitalized. For example, for using `focus` event you can use `onFocus` prop like the example below.
[All the events of TOAST UI Editor](https://nhn.github.io/tui.editor/latest/ToastUIEditor#focus) are supported in the form of `on[EventName]` props. The first letter of each event name should be capitalized. For example, for using `focus` event you can use `onFocus` prop like the example below.
```js

@@ -176,8 +145,8 @@ class MyComponent extends React.Component {

console.log('focus!!');
}
};
render() {
return (
<Editor
data={data}
<Editor
data={data}
previewStyle="vertical"

@@ -194,37 +163,1 @@ height="400px"

```
## 🔧 Pull Request Steps
TOAST UI products are open source, so you can create a pull request(PR) after you fix issues.
Run npm scripts and develop yourself with the following process.
### Setup
Fork `master` branch into your personal repository.
Clone it to local computer. Install node modules.
Before starting development, you should check to have any errors.
``` sh
$ git clone https://github.com/{your-personal-repo}/[[repo name]].git
$ cd [[repo name]]
$ npm install
```
### Develop
Let's start development!
### Pull Request
Before PR, check to test lastly and then check any errors.
If it has no error, commit and then push it!
For more information on PR's step, please see links of Contributing section.
## 💬 Contributing
* [Code of Conduct](https://github.com/nhn/toast-ui.react-editor/blob/master/CODE_OF_CONDUCT.md)
* [Contributing guideline](https://github.com/nhn/toast-ui.react-editor/blob/master/CONTRIBUTING.md)
* [Commit convention](https://github.com/nhn/toast-ui.react-editor/blob/master/docs/COMMIT_MESSAGE_CONVENTION.md)
## 📜 License
This software is licensed under the [MIT](./LICENSE) © [NHN.](https://github.com/nhn)
import React from 'react';
import Editor from 'tui-editor';
import Editor from '@toast-ui/editor';
export default class extends React.Component {
rootEl = React.createRef();
editorInst = null;

@@ -16,11 +17,8 @@

bindEventHandlers(props, prevProps) {
Object.keys(props)
.filter((key) => /on[A-Z][a-zA-Z]+/.test(key))
.forEach((key) => {
bindEventHandlers(props) {
Object.keys(this.props)
.filter(key => /^on[A-Z][a-zA-Z]+/.test(key))
.forEach(key => {
const eventName = key[2].toLowerCase() + key.slice(3);
// For <Editor onFocus={condition ? onFocus1 : onFocus2} />
if(prevProps && prevProps[key] !== props[key]) {
this.editorInst.off(eventName);
}
this.editorInst.off(eventName);
this.editorInst.on(eventName, props[key]);

@@ -41,3 +39,3 @@ });

const instance = this.getInstance();
const {height, previewStyle} = nextProps;
const { height, previewStyle } = nextProps;

@@ -44,0 +42,0 @@ if (this.props.height !== height) {

import React from 'react';
import Viewer from 'tui-editor/dist/tui-editor-Viewer';
import Viewer from '@toast-ui/editor/dist/toastui-editor-viewer';

@@ -17,11 +17,8 @@ export default class ViewerComponent extends React.Component {

bindEventHandlers(props, prevProps) {
bindEventHandlers(props) {
Object.keys(this.props)
.filter((key) => /on[A-Z][a-zA-Z]+/.test(key))
.forEach((key) => {
.filter(key => /^on[A-Z][a-zA-Z]+/.test(key))
.forEach(key => {
const eventName = key[2].toLowerCase() + key.slice(3);
// For <Viewer onFocus={condition ? onFocus1 : onFocus2} />
if(prevProps && prevProps[key] !== props[key]) {
this.viewerInst.off(eventName);
}
this.viewerInst.off(eventName);
this.viewerInst.on(eventName, props[key]);

@@ -28,0 +25,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc