UNPKG

@prisma-cms/editor

Version:
34 lines 1.16 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.insertTextBlock = insertTextBlock; const draft_js_android_fix_1 = require("draft-js-android-fix"); // let count = 0; // const examples = [ // 'select * from table where col = 3;', // // '<p>\n' + // ' <span>some text</span>\n' + // '</p>', // // 'p{\n' + // ' color: red;\n' + // '}', // // '// javascript\n' + // 'class test extends test2{\n' + // ' function test(){\n' + // ' alert("sdfsdf")\n' + // ' }\n' + // '}' // ]; function insertTextBlock(editorState) { const contentState = editorState.getCurrentContent(); // const nextFormula = count++ % examples.length; const contentStateWithEntity = contentState.createEntity('TOKEN', 'IMMUTABLE', { content: '' }); const entityKey = contentStateWithEntity.getLastCreatedEntityKey(); const newEditorState = draft_js_android_fix_1.EditorState.set(editorState, { currentContent: contentStateWithEntity, }); return draft_js_android_fix_1.AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, ' '); } //# sourceMappingURL=insertTextBlock.js.map