Gathering detailed insights and metrics for react-froala-wysiwyg
Gathering detailed insights and metrics for react-froala-wysiwyg
Gathering detailed insights and metrics for react-froala-wysiwyg
Gathering detailed insights and metrics for react-froala-wysiwyg
React component for Froala WYSIWYG HTML Rich Text Editor.
npm install react-froala-wysiwyg
Typescript
Module System
Node Version
NPM Version
86.3
Supply Chain
84.1
Quality
83.9
Maintenance
100
Vulnerability
99.1
License
JavaScript (51.41%)
Shell (46.5%)
Dockerfile (2.09%)
Total Downloads
12,187,661
Last Day
8,477
Last Week
58,134
Last Month
258,388
Last Year
3,114,845
565 Stars
211 Commits
132 Forks
16 Watching
11 Branches
26 Contributors
Minified
Minified + Gzipped
Latest Version
4.3.1
Package Id
react-froala-wysiwyg@4.3.1
Unpacked Size
177.88 kB
Size
30.08 kB
File Count
49
NPM Version
6.14.18
Node Version
14.21.3
Publised On
18 Nov 2024
Cumulative downloads
Total Downloads
Last day
-20.1%
8,477
Compared to previous day
Last week
-6.1%
58,134
Compared to previous week
Last month
-7%
258,388
Compared to previous month
Last year
20.4%
3,114,845
Compared to previous year
2
38
react-froala-wyswiyg provides React bindings to the Froala WYSIWYG editor VERSION 3.
1npm install react-froala-wysiwyg --save
1npm update froala-editor
1npm install font-awesome --save
1import React from 'react'; 2import ReactDOM from 'react-dom'; 3 4 5// Require Editor CSS files. 6import 'froala-editor/css/froala_style.min.css'; 7import 'froala-editor/css/froala_editor.pkgd.min.css'; 8 9import FroalaEditorComponent from 'react-froala-wysiwyg'; 10 11// Import all Froala Editor plugins; 12// import 'froala-editor/js/plugins.pkgd.min.js'; 13 14// Import a single Froala Editor plugin. 15// import 'froala-editor/js/plugins/align.min.js'; 16 17// Import a language file. 18// import 'froala-editor/js/languages/de.js'; 19 20// Import a third-party plugin. 21// import 'froala-editor/js/third_party/image_tui.min.js'; 22// import 'froala-editor/js/third_party/embedly.min.js'; 23// import 'froala-editor/js/third_party/spell_checker.min.js'; 24 25// Include font-awesome css if required. 26// install using "npm install font-awesome --save" 27// import 'font-awesome/css/font-awesome.css'; 28// import 'froala-editor/js/third_party/font_awesome.min.js'; 29 30// Include special components if required. 31// import FroalaEditorView from 'react-froala-wysiwyg/FroalaEditorView'; 32// import FroalaEditorA from 'react-froala-wysiwyg/FroalaEditorA'; 33// import FroalaEditorButton from 'react-froala-wysiwyg/FroalaEditorButton'; 34// import FroalaEditorImg from 'react-froala-wysiwyg/FroalaEditorImg'; 35// import FroalaEditorInput from 'react-froala-wysiwyg/FroalaEditorInput'; 36 37// Render Froala Editor component. 38ReactDOM.render(<FroalaEditorComponent tag='textarea'/>, document.getElementById('editor'));
<div id="editor">
</div>
1<FroalaEditor 2 tag='textarea' 3 config={this.config} 4 model={this.state.model} 5 onModelChange={this.handleModelChange} 6/>
tag attr is used to tell on which tag the editor is initialized.
There are special tags: a, button, img, input. Do not use them in FroalaEditor component. To initialize the editor on a special tag, use FroalaEditorA
, FroalaEditorButton
, FroalaEditorImg
and FroalaEditorInput
components.
You can pass editor options as component attribute (optional).
config={this.config}
You can pass any existing Froala option. Consult the Froala documentation to view the list of all the available options:
1config={{ 2 placeholderText: 'Edit Your Content Here!', 3 charCounterCount: false 4}}
Aditional option is used:
Events can be passed in with the options, with a key events and object where the key is the event name and the value is the callback function.
1config={{ 2 placeholder: "Edit Me", 3 events : { 4 'focus' : function(e, editor) { 5 console.log(editor.selection.get()); 6 } 7 } 8}}
Using the editor instance from the arguments of the callback you can call editor methods as described in the method docs.
Froala events are described in the events docs.
The WYSIWYG HTML editor content model.
model = {this.state.model}
Two way binding:
1import React from 'react'; 2 3class EditorComponent extends React.Component { 4 constructor () { 5 super(); 6 7 this.handleModelChange = this.handleModelChange.bind(this); 8 9 this.state = { 10 model: 'Example text' 11 }; 12 } 13 14 handleModelChange: function(model) { 15 this.setState({ 16 model: model 17 }); 18 } 19 20 render () { 21 return <FroalaEditor 22 model={this.state.model} 23 onModelChange={this.handleModelChange} 24 /> 25 } 26}
To achieve one way binding and pass only the initial editor content, simply do not pass onModelChange
attribute.
Use the content in other places:
1<input value={this.state.model}/>
You can also use the editor on img, button, input and a tags:
1<FroalaEditorImg 2 config={this.config} 3/> 4<FroalaEditorButton 5 config={this.config} 6/> 7<FroalaEditorInput 8 config={this.config} 9/> 10<FroalaEditorA 11 config={this.config} 12/>
The model must be an object containing the attributes for your special tags. Example:
1constructor () { 2 super(); 3 4 this.handleModelChange = this.handleModelChange.bind(this); 5 6 this.state = { 7 model: {src: 'path/to/image.jpg'} 8 }; 9}
1this.state = { 2 model: {innerHTML: 'Click Me'} 3};
As the button text is modified by the editor, the innerHTML attribute from buttonModel model will be modified too.
Gets the functionality to operate on the editor: create, destroy and get editor instance. Use it if you want to manually initialize the editor.
onManualControllerReady={this.handleManualController}
1handleManualController: function(initControls) { 2 //... 3}
The object received by the function will contain the following methods:
To display content created with the froala editor use the FroalaEditorView
component.
1<FroalaEditor 2 model={this.state.content} 3 onModelChange={this.handleModelChange} 4/> 5<FroalaEditorView 6 model={this.state.content} 7/>
1import React from 'react'; 2import ReactDOM from 'react-dom'; 3 4// Require Editor CSS files. 5import 'froala-editor/css/froala_style.min.css'; 6import 'froala-editor/css/froala_editor.pkgd.min.css'; 7 8import FroalaEditorComponent from 'react-froala-wysiwyg'; 9 10// Import all Froala Editor plugins; 11// import 'froala-editor/js/plugins.pkgd.min.js'; 12 13// Import a single Froala Editor plugin. 14// import 'froala-editor/js/plugins/align.min.js'; 15 16// Import a language file. 17// import 'froala-editor/js/languages/de.js'; 18 19// Import a third-party plugin. 20// import 'froala-editor/js/third_party/image_tui.min.js'; 21// import 'froala-editor/js/third_party/embedly.min.js'; 22// import 'froala-editor/js/third_party/spell_checker.min.js'; 23 24// Include font-awesome css if required. 25// install using "npm install font-awesome --save" 26// import 'font-awesome/css/font-awesome.css'; 27// import 'froala-editor/js/third_party/font_awesome.min.js'; 28 29// Include special components if required. 30// import FroalaEditorView from 'react-froala-wysiwyg/FroalaEditorView'; 31// import FroalaEditorA from 'react-froala-wysiwyg/FroalaEditorA'; 32// import FroalaEditorButton from 'react-froala-wysiwyg/FroalaEditorButton'; 33// import FroalaEditorImg from 'react-froala-wysiwyg/FroalaEditorImg'; 34// import FroalaEditorInput from 'react-froala-wysiwyg/FroalaEditorInput'; 35 36// Render Froala Editor component. 37const root = ReactDOM.createRoot(document.getElementById('editor')); 38root.render( 39 <FroalaEditorComponent tag='textarea'/> 40) 41
<div id="editor">
</div>
1<FroalaEditor 2 tag='textarea' 3 config={config} 4 model={model} 5 onModelChange={handleModelChange} 6/>
tag attr is used to tell on which tag the editor is initialized.
There are special tags: a, button, img, input. Do not use them in FroalaEditor component. To initialize the editor on a special tag, use FroalaEditorA
, FroalaEditorButton
, FroalaEditorImg
and FroalaEditorInput
components.
You can pass editor options as component attribute (optional).
config={config}
You can pass any existing Froala option. Consult the Froala documentation to view the list of all the available options:
1config={{ 2 placeholderText: 'Edit Your Content Here!', 3 charCounterCount: false 4}}
Aditional option is used:
Events can be passed in with the options, with a key events and object where the key is the event name and the value is the callback function.
1config={{ 2 placeholder: "Edit Me", 3 events : { 4 'focus' : function(e, editor) { 5 console.log(editor.selection.get()); 6 } 7 } 8}}
Using the editor instance from the arguments of the callback you can call editor methods as described in the method docs.
Froala events are described in the events docs.
Now you can use these buttons in options:
1toolbarButtons: [['undo', 'redo' , 'bold'], ['alert', 'clear', 'insert']], 2
The WYSIWYG HTML editor content model.
model = {model}
Two way binding:
1import React,{ useState } from 'react'; 2 3const App=()=> { 4 const [model,setModel] = useState("Example Set"); 5 6 const handleModelChange= (event)=>{ 7 setModel(event) 8 } 9 return ( 10 <div className="App"> 11 <FroalaEditorComponent 12 tag='textarea' 13 onModelChange={handleModelChange} 14 /> 15 <FroalaEditorView 16 model={model} 17 /> 18 </div> 19 ); 20}
To achieve one way binding and pass only the initial editor content, simply do not pass onModelChange
attribute.
Use the content in other places:
1<input value={model}/>
You can also use the editor on img, button, input and a tags:
1<FroalaEditorImg 2 model={model} 3/> 4<FroalaEditorButton 5 model={model} 6/> 7<FroalaEditorInput 8 model={model} 9/> 10<FroalaEditorA 11 model={model} 12/> 13
The model must be an object containing the attributes for your special tags. Example:
1 model={{src: 'path/to/image.jpg', 2 width:"300px", 3 alt:"Old Clock" 4 }}
1model={{innerHTML: 'Click Me'}}
As the button text is modified by the editor, the innerHTML attribute from buttonModel model will be modified too.
Gets the functionality to operate on the editor: create, destroy and get editor instance. Use it if you want to manually initialize the editor.
onManualControllerReady={handleManualController}
1handleManualController =(initControls) =>{ 2 //... 3}
The object received by the function will contain the following methods:
To display content created with the froala editor use the FroalaEditorView
component.
1<FroalaEditor 2 model={content} 3 onModelChange={handleModelChange} 4/> 5<FroalaEditorView 6 model={content} 7/>
1config: { 2 reactIgnoreAttrs: ['class', 'id'] 3},
index.d.ts
file is the type definition file for this repository. It is placed inside lib folder.In order to use it in your code , use the following line:
///<reference path= "index.d.ts" />
where path is the location of index.d.ts file.
You can pass the custom buttons to the editor by following way:
1<script> 2import Froalaeditor from 'froala-editor'; 3Froalaeditor.DefineIcon('alert', {NAME: 'info', SVG_KEY: 'help'}); 4 Froalaeditor.RegisterCommand('alert', { 5 title: 'Hello', 6 focus: false, 7 undo: false, 8 refreshAfterCallback: false, 9 callback: function () { 10 alert('Hello!'); 11 } 12 }); 13 14 Froalaeditor.DefineIcon('clear', {NAME: 'remove', SVG_KEY: 'remove'}); 15 Froalaeditor.RegisterCommand('clear', { 16 title: 'Clear HTML', 17 focus: false, 18 undo: true, 19 refreshAfterCallback: true, 20 callback: function () { 21 this.html.set(''); 22 this.events.focus(); 23 } 24 }); 25 26 Froalaeditor.DefineIcon('insert', {NAME: 'plus', SVG_KEY: 'add'}); 27 Froalaeditor.RegisterCommand('insert', { 28 title: 'Insert HTML', 29 focus: true, 30 undo: true, 31 refreshAfterCallback: true, 32 callback: function () { 33 this.html.insert('My New HTML'); 34 } 35 }); 36 </script> 37
Now you can use these buttons in options:
1toolbarButtons: [['undo', 'redo' , 'bold'], ['alert', 'clear', 'insert']], 2
The react-froala-wyswiyg
project is under MIT license. However, in order to use Froala WYSIWYG HTML Editor plugin you should purchase a license for it.
Froala Editor has 3 different licenses for commercial use. For details please see License Agreement.
If you want to contribute to react-froala-wyswiyg, you will first need to install the required tools to get the project going.
$ npm install
$ npm run build
$ npm run demo
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 6/26 approved changesets -- score normalized to 2
Reason
2 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More