UNPKG

draft-js-ast-exporter

Version:

Export content from draft-js into an abstract syntax tree.

30 lines (23 loc) 912 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _processor = require('./processor'); var _processor2 = _interopRequireDefault(_processor); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Exporter * * @param {EditorState} editorState Draft JS EditorState object * @param {Object} options Additional configuration options * @return {Array} An abstract syntax tree representing the draft-js editorState */ function exporter(editorState) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; // Retrieve the content state and its blocks var contentState = editorState.getCurrentContent(); var blocks = contentState.getBlocksAsArray(); // Convert to an abstract syntax tree return (0, _processor2.default)(blocks, contentState, options); } exports.default = exporter;