2

I am working with slatejs, and I have the following html line, <p>Line one<br /> Line two</p>

My current rule for br is the following,

deserialize(el, next) {
    const block = BLOCK_TAGS[el.tagName.toLowerCase()];
    if (!block) return;
    return {
        kind: 'block',
        type: block,
        nodes: next(el.childNodes),
    };
},

const BLOCK_TAGS = {
  p: 'paragraph',
  li: 'list-item',
  ul: 'bulleted-list',
  ol: 'numbered-list',
  blockquote: 'quote',
  pre: 'code',
  h1: 'heading-one',
  h2: 'heading-two',
  h3: 'heading-three',
  h4: 'heading-four',
  h5: 'heading-five',
  h6: 'heading-six',
  br: 'br',
}

But this creates a empty line, that causes issues on backspace, I have tried passing a new block in my serialize, but that gave me the same result.

What should my deserialize rule be so that my text is rendered as following in the slate editor.

Line one
Line two
Max Doumit
  • 1,065
  • 12
  • 33

0 Answers0