-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
[Feature] Paste[Feature] Rich TextRelated to the Rich Text component that allows developers to render a contenteditableRelated to the Rich Text component that allows developers to render a contenteditable[Package] Format library/packages/format-library/packages/format-library[Package] Rich text/packages/rich-text/packages/rich-text[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Description
Describe the bug
I registered a new format type. Lets say: <span class="great-class">. When I copy a text now into the Component, the span.great-class tags get removed:
Received HTML:
df df <span class="great-class">df</span> df df. editor.min.js:55:146144
Received plain text:
df df df df df. editor.min.js:55:146187
Processed inline HTML:
df df df df df. blocks.min.js:2:115611
To Reproduce
const {createElement} = window.wp.element;
const {registerFormatType, toggleFormat} = window.wp.richText;
const {RichTextToolbarButton} = window.wp.editor;
registerFormatType('some/type', {
title: 'Title',
tagName: 'span',
className: 'great-class',
edit({ isActive, value, onChange}) {
const onClick = () => {
onChange(toggleFormat(value, { type: 'some/type' }));
};
return (
createElement(RichTextToolbarButton, {
icon: 'admin-home',
title: 'Title',
onClick,
isActive,
shortcutType: 'primary',
shortcutCharacter: '8',
})
)
}
});
- Add this script
- Add a text in a RichText component
- Select a part of the text and click the new button in the toolbar
- Copy all the text in the clipboard
- Paste the text in a RichText component
- See error
Expected behavior
The new format should survive the copy/pasting
Screenshots
https://www.youtube.com/watch?v=9SiyAROa1Iw
Desktop (please complete the following information):
- OS: Ubuntu 14.04
- Browser Firefox
Metadata
Metadata
Assignees
Labels
[Feature] Paste[Feature] Rich TextRelated to the Rich Text component that allows developers to render a contenteditableRelated to the Rich Text component that allows developers to render a contenteditable[Package] Format library/packages/format-library/packages/format-library[Package] Rich text/packages/rich-text/packages/rich-text[Type] EnhancementA suggestion for improvement.A suggestion for improvement.