Skip to content

Conversation

@o1y
Copy link

@o1y o1y commented Oct 21, 2025

Fixes a bug where duplicate mark types (e.g., multiple textStyle marks on the same node) were incorrectly handled, causing marks to stay open.

Example:

$document = [
      'type' => 'doc',
      'content' => [
          [
              'type' => 'paragraph',
              'content' => [
                  [
                      'type' => 'text',
                      'text' => 'Example',
                      'marks' => [
                          [
                              'type' => 'bold',
                          ],
                          [
                              'type' => 'textStyle',
                          ],
                          [
                              'type' => 'textStyle', // duplicate
                          ],
                      ],
                  ],
                  [
                      'type' => 'text',
                      'text' => ' Text',
                  ],
              ],
          ],
      ],
  ];

Before:

<p><strong><span><span>Example</span></span></strong><span> Text</p>

After:

<p><strong><span><span>Example</span></span></strong> Text</p>

Replace array_udiff with manual removal to ensure only one mark instance is removed at a time, preventing duplicate marks from incorrectly staying open and wrapping subsequent text nodes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant