Skip to content

Commit

Permalink
fix: prevent placeholders on each empty block
Browse files Browse the repository at this point in the history
  • Loading branch information
sibiraj-s committed Mar 26, 2021
1 parent 3b9fc66 commit ef2c452
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib/plugins/placeholder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ const placeholderPlugin = (text?: string): Plugin => {
props: {
decorations(state: EditorState): DecorationSet {
const { doc } = state;
const { textContent, childCount } = doc;

const placeholder = this.getState(state);

if (!placeholder) {
if (!placeholder || childCount > 1) {
return DecorationSet.empty;
}

const decorations: Decoration[] = [];

const decorate = (node: ProseMirrorNode, pos: number) => {
if (node.type.isBlock && node.childCount === 0 && doc.textContent.length === 0) {

if (node.type.isBlock && node.childCount === 0 && textContent.length === 0) {
const placeholderNode = Decoration.node(pos, (pos + node.nodeSize), {
class: PLACEHOLDER_CLASSNAME,
'data-placeholder': placeholder,
Expand Down

0 comments on commit ef2c452

Please sign in to comment.