
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.
npm install react-froala-wysiwyg --save
npm install react-froala-wysiwyg react --save
var React = require('react');
var ReactDOM = require('react-dom');
// Require Editor JS files.
require("froala-editor/js/froala_editor.pkgd.min.js");
require("froala-editor/css/froala_editor.pkgd.min.css");
// Require Font Awesome.
require('font-awesome/css/font-awesome.css');
var FroalaEditor = require('react-froala-wysiwyg');
// Include special components if required.
// var FroalaEditorView = require('react-froala-wysiwyg/FroalaEditorView');
// var FroalaEditorA = require('react-froala-wysiwyg/FroalaEditorA');
// var FroalaEditorButton= require('react-froala-wysiwyg/FroalaEditorButton');
// var FroalaEditorImg = require('react-froala-wysiwyg/FroalaEditorImg');
// var FroalaEditorInput = require('react-froala-wysiwyg/FroalaEditorInput');
// Render Froala Editor component.
ReactDOM.render(<FroalaEditor tag='textarea'/>, document.getElementById('editor'));
var webpack = require("webpack");
module.exports = {
module: {
loaders: [
{
test: /\.jsx$/,
loader: 'babel',
query: {
cacheDirectory: true,
presets: ['react','es2015', 'stage-2']
}
}, {
test: /\.css$/,
loader: "style-loader!css-loader?root=."
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
}, {
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/font-woff"
}, {
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=application/octet-stream"
}, {
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
loader: "file"
}, {
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
loader: "url?limit=10000&mimetype=image/svg+xml"
}
]
},
resolve: {
modulesDirectories: ['node_modules']
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
]
};
<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.
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 FroalaEditorView
component.
<FroalaEditor
model={this.state.content}
onModelChange={this.handleModelChange}
/>
<FroalaEditorView
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
$ npm run build
$ npm run demo
FAQs
React component for Froala WYSIWYG HTML rich text editor.
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.