Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rich Text: Void blocks are considered plain-text, aren't converted #14534

Closed
aduth opened this issue Mar 20, 2019 · 1 comment · Fixed by #14536
Closed

Rich Text: Void blocks are considered plain-text, aren't converted #14534

aduth opened this issue Mar 20, 2019 · 1 comment · Fixed by #14536

Comments

@aduth
Copy link
Member

aduth commented Mar 20, 2019

Describe the bug

A void block (a block with no content, self-closing), when pasted, is not converted to a block (at least in macOS Chrome). The root cause is that ClipboardData#getData considers the comment-only markup as plain-text, not HTML. This could be considered a browser bug, though it has the practical impact of preventing blocks from being converted correctly.

Example void block:

<!-- wp:latest-posts /-->

To Reproduce

Steps to reproduce the behavior:

  1. Copy the block markup above
  2. Navigate to Posts > Add New
  3. Click on the writing prompt
  4. Paste the block markup

Expected behavior

The pasted text is converted into a Latest Posts block.

Alternatively, if it was interpreted as plain-text, the plain text of the markup should be inserted into the paragraph.

Actual behavior

Nothing happens.

Desktop:

  • OS: macOS Mojave Version 10.14.3 (18D109)
  • Browser: Chrome Version 73.0.3683.75 (Official Build) (64-bit)

Additional context

Both HTML and plain text data are retrieved from the clipboard and passed to clipboardData.

plainText = clipboardData.getData( 'text/plain' );
html = clipboardData.getData( 'text/html' );

For this reason, if it's not possible to have the browser consider the comment markup as HTML, an alternative to consider may be to update the following condition to consider plainText, in addition to HTML:

// If we detect block delimiters, parse entirely as blocks.
if ( mode !== 'INLINE' && HTML.indexOf( '<!-- wp:' ) !== -1 ) {
return parseWithGrammar( HTML );
}

cc @ellatrix

@aduth aduth added [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable [Feature] Paste labels Mar 20, 2019
@ellatrix
Copy link
Member

Fixed in #14536.

@ellatrix ellatrix removed the [Feature] Rich Text Related to the Rich Text component that allows developers to render a contenteditable label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants