Skip to content

[BUG]: Whitespace being stripped from HTML content during parsing #327

@rikardwissing

Description

@rikardwissing

Describe the bug

TenTap editor strips whitespace between HTML nodes when setting content via initialContent or setContent. This causes formatting issues where intended spacing between inline elements is lost.

Expected behavior

When setting HTML content like "<a href='hello'>hello</a> <a href='world'>world</a>", the two spaces between the anchor tags should be preserved in the editor.

Actual behavior

The whitespace between HTML nodes is stripped, resulting in "<a href='hello'>hello</a><a href='world'>world</a>" (no spaces between links).

To Reproduce

import { useEditorBridge, RichText, CoreBridge } from '@10play/tentap-editor';

const TestEditor = () => {
  const editor = useEditorBridge({
    bridgeExtensions: [CoreBridge],
    initialContent: "<a href='hello'>hello</a>  <a href='world'>world</a>",
  });

  return <RichText editor={editor} />;
};

Test cases that fail:

  1. Inline elements with spaces: "<a href='hello'>hello</a> <a href='world'>world</a>"
  2. Multiple spaces in text: "<span>Text with multiple spaces</span>"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions