@prisma-cms/editor
Version:
Editor for @prisma-cms
32 lines • 1.7 kB
JavaScript
/**
* Copyright (c) 2013-present, Facebook, Inc. All rights reserved.
*
* This file provided by Facebook is for non-commercial testing and evaluation
* purposes only. Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeTextBlock = removeTextBlock;
const draft_js_android_fix_1 = require("draft-js-android-fix");
function removeTextBlock(editorState, blockKey) {
const content = editorState.getCurrentContent();
const block = content.getBlockForKey(blockKey);
const targetRange = new draft_js_android_fix_1.SelectionState({
anchorKey: blockKey,
anchorOffset: 0,
focusKey: blockKey,
focusOffset: block.getLength(),
});
const withoutTeX = draft_js_android_fix_1.Modifier.removeRange(content, targetRange, 'backward');
const resetBlock = draft_js_android_fix_1.Modifier.setBlockType(withoutTeX, withoutTeX.getSelectionAfter(), 'unstyled');
const newState = draft_js_android_fix_1.EditorState.push(editorState, resetBlock, 'remove-range');
return draft_js_android_fix_1.EditorState.forceSelection(newState, resetBlock.getSelectionAfter());
}
//# sourceMappingURL=removeTextBlock.js.map