![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
draft-js-select-image-plugin
Advanced tools
Embed a local image in your draft-js editor
This is a plugin for draft-js-plugins-editor
.
npm install draft-js-select-image-plugin
This plugin exposes a button that integrates with the side toolbar.
import createSelectImagePlugin from 'draft-js-select-image-plugin';
const selectImagePlugin = createSelectImagePlugin({});
const { SelectImageButton } = selectImagePlugin;
Param | Default | Description |
---|---|---|
imageType | IMAGE | Type of entity created when inserting the atomic block. By default it's the same value as draft-js-image-plugin |
Rendering the image is out of scope, but in the following example you can see how to integrate draft-js-image-plugin
.
import React from 'react';
import ReactDOM from 'react-dom';
import Editor from 'draft-js-plugins-editor';
import { EditorState } from 'draft-js';
import createSideToolbarPlugin from 'draft-js-side-toolbar-plugin';
import BlockTypeSelect from 'draft-js-side-toolbar-plugin/lib/components/BlockTypeSelect';
import createImagePlugin from 'draft-js-image-plugin';
import createSelectImagePlugin from 'draft-js-select-image-plugin';
import 'draft-js-side-toolbar-plugin/lib/plugin.css';
const imagePlugin = createImagePlugin();
const selectImagePlugin = createSelectImagePlugin();
const DefaultBlockTypeSelect = ({ getEditorState, setEditorState, theme }) => (
<BlockTypeSelect
getEditorState={getEditorState}
setEditorState={setEditorState}
theme={theme}
structure={[
selectImagePlugin.SelectImageButton
]}
/>
);
const sideToolbarPlugin = createSideToolbarPlugin({
structure: [DefaultBlockTypeSelect],
});
const { SideToolbar } = sideToolbarPlugin;
class MyEditor extends React.Component {
constructor(props) {
super(props);
this.state = {
editorState: EditorState.createEmpty()
};
this.plugins = [
sideToolbarPlugin,
imagePlugin
];
}
onChange = (editorState) => {
this.setState({ editorState });
}
render() {
return (
<div className="editor">
<Editor
editorState={this.state.editorState}
onChange={this.onChange}
plugins={this.plugins}
placeholder="Tell a story" />
<SideToolbar />
</div>
);
}
}
ReactDOM.render(<MyEditor />, document.getElementById('root'));
FAQs
Embed a local image in your draft-js editor
We found that draft-js-select-image-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.