Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
draft-js-html
Advanced tools
Readme
This repository is used to convert draft-js RawDraftContentState's into html content
It supports custom inline styling, custom block styling and custom multi block style (multiple elements of the same type, for example custom 'ul', 'ol', codeblock of multiple blocks)
Function:
// Element interface:
export interface IElementStyle {
element: string;
properties?: {[key: string]: string};
}
// It will append 'properties' to the element
// Eg. '{element: "span", properties: {class: "color-red"}}'
// Types used as module parameters:
type InlineStyleCallback = (type: DraftInlineStyleType) => IElementStyle | void;
type BlockStyleCallback = (type: DraftBlockType) => IElementStyle | void;
type MultiBlockStyleCallback = (type: DraftBlockType) => IElementStyle | void;
// Exported function from this module:
convertDraftToHtml(rawContent: RawDraftContentState, customInlineStyleFn?: InlineStyleCallback, customBlockStyleFn?: BlockStyleCallback, customMultiBlockStyleFn?: MultiBlockStyleCallback)
Example usage:
convertDraftToHtml(rawContent); // Convert with default styles
convertDraftToHtml(rawContent, type => {
if(type == "BOLD") return {element: "strong", properties: {class: "example", placeholder: "example", customProp: "this is a custom prop"}};
}, type => {
if(type == "unstyled") return {element: "span", properties: {class: "custom-unstyled"}};
}, type => {
if(type == "unordered-list-item") return {element: "ul"};
if(type == "code-block") return {element: "code"};
});
BOLD
=> {element: 'strong'}
,ITALIC
=> {element: 'i'}
,UNDERLINE
=> {element: 'u'}
unstyled
/ paragraph
=> {element: 'p'}
,header-one
=> {element: 'h1'}
,header-two
=> {element: 'h2'}
,header-three
=> {element: 'h3'}
,header-four
=> {element: 'h4'}
,header-five
=> {element: 'h5'}
,header-six
=> {element: 'h6'}
,ordered-list-item
/ unordered-list-item
=> {element: 'li'}
,blockquote
=> {element: 'blockquote'}
,code-block
=> {element: 'pre'}
ordered-list-item
=> {element: 'ol'}
,unordered-list-item
=> {element: 'ul'}
Coming soon: Conversion from HTML to RawDraftContentState
FAQs
This repository is used to convert draft-js RawDraftContentState's into html content
The npm package draft-js-html receives a total of 89 weekly downloads. As such, draft-js-html popularity was classified as not popular.
We found that draft-js-html 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.