Advertisement
Guest User

Untitled

a guest
Oct 26th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import * as React from "react";
  2. import * as ReactDOM from "react-dom";
  3. import TinyMCE from 'react-tinymce';
  4.  
  5. // Import TinyMCE
  6. import tinymce from 'tinymce/tinymce';
  7.  
  8. // A theme is also required
  9. import 'tinymce/themes/modern/theme';
  10.  
  11. // Any plugins you want to use has to be imported
  12. import 'tinymce/plugins/lists';
  13. import 'tinymce/plugins/textcolor';
  14. import 'tinymce/plugins/colorpicker';
  15.  
  16. require.context(
  17.     'file?name=[path][name].[ext]&context=node_modules/tinymce!tinymce/skins',
  18.     true,
  19.     /.*/
  20. );
  21.  
  22. // Initialize the app
  23. tinymce.init({
  24.     selector: '.tiny',
  25.     plugins: ['lists', 'textcolor', 'colorpicker']
  26. });
  27.  
  28. export function generateHtmlRedactor(content: string, plugins: string | boolean, toolbar: string | boolean, callback: (e: any) => void, readonly: number = 0,): JSX.Element {
  29.     return(
  30.         <TinyMCE
  31.             content={content}
  32.             config={{
  33.                 menubar: false,
  34.                 plugins: plugins,
  35.                 toolbar: toolbar,
  36.                 readonly: readonly
  37.             }}
  38.             onChange={callback}
  39.         />
  40.     );
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement