-
-
Save omsharp/1c368c01bee5d80b7569d2deafb2c128 to your computer and use it in GitHub Desktop.
Revisions
-
zhangshine revised this gist
Apr 30, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ 1. Install (TinyMCE 5.x) ```shell script npm install --save tinymce @tinymce/tinymce-react copy-webpack-plugin ``` -
zhangshine revised this gist
Apr 30, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ npm install --save tinymce @tinymce/tinymce-react copy-webpack-plugin ``` 2. Copy static files(tinymce skins) to `public` folder. Edit file `next.config.js` ```javascript const path = require('path'); const webpack = require('webpack'); -
zhangshine revised this gist
Apr 30, 2020 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ 1. Install ```shell script npm install --save tinymce @tinymce/tinymce-react copy-webpack-plugin ``` 2. Copy static files(tinymce skins) to `public` folder. next.config.js ```javascript const path = require('path'); const webpack = require('webpack'); @@ -21,7 +21,7 @@ module.exports = { }, } ``` 3. React components file ```javascript if(typeof window !== 'undefined'){ require ('tinymce/tinymce'); @@ -67,8 +67,8 @@ function AReactComponent(props) { alignleft aligncenter alignright alignjustify | \ bullist numlist outdent indent | removeformat | \ table | help', skin_url: '/assets/libs/tinymce/skins/ui/oxide', // Static files path(step 2) content_css: '/assets/libs/tinymce/skins/content/default/content.min.css' // Static files path(step 2) }} onEditorChange={props.handleOnEditorChange} /> -
zhangshine created this gist
Apr 30, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,77 @@ - Install ```shell script npm install --save tinymce @tinymce/tinymce-react copy-webpack-plugin ``` - Copy static files(tinymce skins) to `public` folder. next.config.js ```javascript const path = require('path'); const webpack = require('webpack'); const CopyPlugin = require('copy-webpack-plugin'); module.exports = { webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => { config.plugins.push(new CopyPlugin([ { from: path.join(__dirname, 'node_modules/tinymce/skins'), to: path.join(__dirname, 'public/assets/libs/tinymce/skins') }, /// Copy to public folder ])); return config }, webpackDevMiddleware: config => { return config }, } ``` - React components file ```javascript if(typeof window !== 'undefined'){ require ('tinymce/tinymce'); require ('tinymce/themes/silver'); require ('tinymce/plugins/advlist'); require ('tinymce/plugins/autolink'); require ('tinymce/plugins/lists'); require ('tinymce/plugins/link'); require ('tinymce/plugins/image'); require ('tinymce/plugins/charmap'); require ('tinymce/plugins/print'); require ('tinymce/plugins/preview'); require ('tinymce/plugins/anchor'); require ('tinymce/plugins/searchreplace'); require ('tinymce/plugins/visualblocks'); require ('tinymce/plugins/code'); require ('tinymce/plugins/fullscreen'); require ('tinymce/plugins/insertdatetime'); require ('tinymce/plugins/media'); require ('tinymce/plugins/table'); require ('tinymce/plugins/paste'); require ('tinymce/plugins/code'); require ('tinymce/plugins/help'); require ('tinymce/plugins/wordcount'); } import {Editor} from '@tinymce/tinymce-react'; function AReactComponent(props) { return ( <Editor value={props.content} init={{ height: 500, menubar: false, plugins: [ 'advlist autolink lists link image charmap print preview anchor', 'searchreplace visualblocks code fullscreen', 'insertdatetime media table paste code help wordcount' ], toolbar: 'undo redo | formatselect | bold italic backcolor | \ alignleft aligncenter alignright alignjustify | \ bullist numlist outdent indent | removeformat | \ table | help', skin_url: '/assets/libs/tinymce/skins/ui/oxide', content_css: '/assets/libs/tinymce/skins/content/default/content.min.css' }} onEditorChange={props.handleOnEditorChange} /> ); } ```