
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
react-froala-wysiwyg
Advanced tools
react-froala-wyswiyg provides React bindings to the Froala WYSIWYG editor VERSION 2.
Clone this repo or download the zip.
Run bower install
or Download the editor from https://www.froala.com/wysiwyg-editor/ and jQuery
Load Froala WYSIWYG editor (and all desired plugins), jQuery, React framework and react-froala-wyswiyg component files into your project:
lib/froalaEditorFunctionality.js : Mixin: must be included before FroalaEditor
components:
FroalaEditor
componentFroalaEditorA
component: init on 'a' tagFroalaEditorButton
component: init on 'button' tagFroalaEditorImg
component: init on 'img' tagFroalaEditorInput
component: init on 'input' taglib/froalaView.js : FroalaView
component for displaing the editor HTML; can be used standalone without the mixin.
NB: You must ensure jQuery is included before React.
1. Import froala components into your html file:
<script type="text/babel" src="path/to/lib/froalaEditorFunctionality.js"></script>
<script type="text/babel" src="path/to/lib/froalaEditor.js"></script>
<script type="text/babel" src="path/to/lib/froalaEditorButton.js"></script>
<script type="text/babel" src="path/to/lib/froalaEditorInput.js"></script>
<script type="text/babel" src="path/to/lib/froalaEditorA.js"></script>
<script type="text/babel" src="path/to/lib/froalaEditorImg.js"></script>
<script type="text/babel" src="path/to/lib/froalaView.js"></script>
2. Use them in your component:
<FroalaEditor
tag='textarea'
config={this.config}
model={this.state.model}
onModelChange={this.handleModelChange}
/>
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.
NB: The code is written in React JSX. You must load babel-standalone in your HTML before lib files. Or you can compile them to plain javascript.
You can check src/ dir for a more detailed usage example.
'src' directory contains a working example that will need a server to run. To run them: npm start
.
'demo' directory contains a minified working example that can run without a server. To build demo/app.js in case you've modified the sources(src dir): npm run build
. To run: open demo/index.html directly into browser.
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:
config: {
placeholderText: 'Edit Your Content Here!',
charCounterCount: false
}
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.
options: {
placeholder: "Edit Me",
events : {
'froalaEditor.focus' : function(e, editor) {
console.log(editor.selection.get());
}
}
}
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:
getInitialState: function() {
return {model: 'Example text'};
},
handleModelChange: function(model) {
this.setState({model: model});
},
// ...
<FroalaEditor
model={this.state.model}
onModelChange={this.handleModelChange}
/>
To achieve one way binding and pass only the initial editor content, simply do not pass onModelChange
attribute.
Use the content in other places:
<input value={this.state.model}/>
You can also use the editor on img, button, input and a tags:
<FroalaEditorImg
config={this.config}
/>
<FroalaEditorButton
config={this.config}
/>
<FroalaEditorInput
config={this.config}
/>
<FroalaEditorA
config={this.config}
/>
The model must be an object containing the attributes for your special tags. Example:
getInitialState: function() {
return {model: {src: 'path/to/image.jpg'}};
},
The model will change as the attributes change during usage if you use two way binding and pass onModelChange
function.
getInitialState: function() {
return {content: {innerHTML: 'Click Me'}};
},
As the button text is modified by the editor, the innerHTML attribute from buttonModel model will be modified too.
config: {
reactIgnoreAttrs: ['class', 'id']
},
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}
handleManualController: function(initControls) {
//...
}
The object received by the function will contain the following methods:
To display content created with the froala editor use the FroalaView
component.
<FroalaEditor
model={this.state.content}
onModelChange={this.handleModelChange}
/>
<FroalaView
model={this.state.content}
/>
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 -g grunt-cli bower
$ npm install
$ bower install
$ npm start
FAQs
React component for Froala WYSIWYG HTML rich text editor.
The npm package react-froala-wysiwyg receives a total of 50,879 weekly downloads. As such, react-froala-wysiwyg popularity was classified as popular.
We found that react-froala-wysiwyg demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.