Register <label> in defaultProcessorMap to prevent spurious div injection on paste - #3416
Open
JiuqingSong with Copilot wants to merge 4 commits into
Open
Register <label> in defaultProcessorMap to prevent spurious div injection on paste#3416JiuqingSong with Copilot wants to merge 4 commits into
<label> in defaultProcessorMap to prevent spurious div injection on paste#3416JiuqingSong with Copilot wants to merge 4 commits into
Conversation
Add `label: knownElementProcessor` to the `defaultProcessorMap` so that `<label>` HTML elements are treated as known elements (like `span`) instead of falling through to the `generalProcessor`. This prevents an extra `<div>` wrapper from being inserted inside `<label>` elements when pasting HTML content, fixing issue #2447.
Copilot
AI
changed the title
[WIP] Fix bug where pasting labels adds unexpected div elements
Register Jul 27, 2026
<label> in defaultProcessorMap to prevent spurious div injection on paste
JiuqingSong
marked this pull request as ready for review
July 27, 2026 18:40
|
Collaborator
|
@copilot The PR has test case failure. Fix it. |
Contributor
Author
Fixed in commit |
JiuqingSong
approved these changes
Jul 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pasting HTML containing
<label>elements caused an extra<div>to be injected inside each label, resulting in double-line rendering. The root cause:labelwas absent fromdefaultProcessorMap, so it fell through togeneralProcessor('*'), which wraps unknown elements in aContentModelGeneralBlock— serialized back as a<div>.Changes
defaultProcessors.ts— Registerlabel: knownElementProcessorindefaultProcessorMap. This treats<label>like other inline-capable elements (span,b,em, etc.), processing its children as segments rather than wrapping them in a new block.knownElementProcessorTest.ts— Add a test case verifying that a<label>with text content produces a paragraph with a text segment and no extra block wrappers.Before the fix, pasting a
<label>Test</label>would produce:After the fix, the label content is preserved as-is without any injected wrapper.