import { EditorState, Plugin } from 'prosemirror-state'; import { Node as ProseMirrorNode, DOMSerializer } from 'prosemirror-model'; import { Decoration, DecorationSet } from 'prosemirror-view'; import schema from '../schema'; import changedDescendants from '../vendor/changedDescendants'; const nonbreakingSpace = '\u00A0'; // Creates a custom serializer that can preserve empty paragraphs. // See https://discuss.prosemirror.net/t/how-to-preserve-br-tags-in-empty-paragraphs/2051/8. const createSerializer = () => { const baseSerializer = DOMSerializer.fromSchema(schema); return new DOMSerializer({ ...baseSerializer.nodes, // When converting back to markup, restore the