contenido
Version:
Contenido is a library with a set of tools to help you create your own rich text editor on top of draft-js without thinking about how to handle things.
27 lines (21 loc) • 579 B
text/typescript
// Core
import { EditorState, Modifier } from '../../core';
// Custom Types
import type { State, StateHandler } from '../../types';
const clearEntities = (state: State, stateHandler: StateHandler) => {
const contentState = state.getCurrentContent();
const selection = state.getSelection();
const contentWithoutEntities = Modifier.applyEntity(
contentState,
selection,
null
);
const newState = EditorState.push(
state,
contentWithoutEntities,
'apply-entity'
);
stateHandler(newState);
return newState;
};
export default clearEntities;