convert-draftjs
Version:
Easily convert the result of DraftJS into useful and easy to read data. For example; Array of text, plain text, etc.
13 lines (11 loc) • 339 B
text/typescript
import { ParsedJson } from '../types/parsedjson';
export default function parseDraftResult(draftResult: ParsedJson | string) {
/**
* If draftResult is in stringify mode,
* then parse to JSON. If not simply return back.
*/
if (typeof draftResult === 'string') {
return JSON.parse(draftResult);
}
return draftResult;
}