![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
draft-js-export-html
Advanced tools
Readme
This is a module for DraftJS that will export your editor content to semantic HTML.
It was extracted from React-RTE and placed into a separate module for more general use. Hopefully it can be helpful in your projects.
npm install --save draft-js-export-html
import {stateToHTML} from 'draft-js-export-html';
let html = stateToHTML(contentState);
You can optionally pass a second "options" argument to stateToHTML
which should be an object with one or more of the following properties:
inlineStyles
You can define rendering options for inline styles. This applies to built-in inline styles (e.g. BOLD
) or your own custom inline styles (e.g. RED
). You can specify which element/tag name will be used (e.g. use <b>
instead of <strong>
for BOLD
). You can add custom attributes (e.g. class="foo"
) or add some styling (e.g. color: red
).
Example:
let options = {
inlineStyles: {
// Override default element (`strong`).
BOLD: {element: 'b'},
ITALIC: {
// Add custom attributes. You can also use React-style `className`.
attributes: {class: 'foo'},
// Use camel-case. Units (`px`) will be added where necessary.
style: {fontSize: 12}
},
// Use a custom inline style. Default element is `span`.
RED: {style: {color: '#900'}},
},
};
let html = stateToHTML(contentState, options);
blockRenderers
You can define a custom renderer for any block type. Pass a function that accepts block
as an argument. You can return a string to render this block yourself, or return nothing (null or undefined) to defer to the default renderer.
Example:
let options = {
blockRenderers: {
ATOMIC: (block) => {
let data = block.getData();
if (data.foo === 'bar') {
return '<div>' + escape(block.getText()) + '</div>';
}
},
},
};
let html = stateToHTML(contentState, options);
If you want to help out, please open an issue to discuss or join us on Slack.
This software is BSD Licensed.
FAQs
DraftJS: Export ContentState to HTML
The npm package draft-js-export-html receives a total of 187,879 weekly downloads. As such, draft-js-export-html popularity was classified as popular.
We found that draft-js-export-html demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.