Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
draftjs-md-converter-support-video
Advanced tools
Converter for converting Draft.js state into Markdown and vice versa
Converts rich text content between Draft.js blocks and Markdown forked from draftjs-md-converter to support video embed from youtube and vimeo (at the moment).
npm i draftjs-md-converter-support-video
The following inline styles are supported:
The following block styles are supported:
The following media types are supported:
mdToDraftjs(markdown: String): RawDraftContentState
Use convertToRaw from the draft-js library
to convert the resulting RawDraftContentState into a draft-js ContentState.
draftjsToMd(rawData: RawDraftContentState): String
Use convertFromRaw from the draft-js library
to get the raw RawDraftContentState to then pass into the converter.
The default Markdown dictionary is
{
BOLD: '__',
ITALIC: '*'
};
The inline styles can be extended or overridden by passing a custom dictionary object as a second optional argument to draftjsToMd
, e.g.
const myMdDict = {
BOLD: '**',
STRIKETHROUGH: '~~'
};
const markdown = draftjsToMd(blocks, myMdDict);
NOTE: at this point you cannot override block styles!
[---]
import { mdToDraftjs, draftjsToMd } from 'draftjs-md-converter';
import { EditorState, ContentState, convertToRaw, convertFromRaw } from 'draft-js';
[---]
constructor(props) {
super(props);
// some default value in markdown
const defaultValue = this.props.defaultValue;
const rawData = mdToDraftjs(defaultValue);
const contentState = convertFromRaw(rawData);
const newEditorState = EditorState.createWithContent(contentState);
this.state = {
editorState: newEditorState,
};
this.onChange = (editorState) => {
this.props.onChange(this.getMarkdown());
this.setState({ editorState });
};
}
[---]
getMarkdown() {
const content = this.state.editorState.getCurrentContent();
return draftjsToMd(convertToRaw(content));
}
[---]
npm test
npm run test-dev
npm run lint
FAQs
Converter for converting Draft.js state into Markdown and vice versa
The npm package draftjs-md-converter-support-video receives a total of 0 weekly downloads. As such, draftjs-md-converter-support-video popularity was classified as not popular.
We found that draftjs-md-converter-support-video 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.