facebookarchive/draft-js

`aliasedElements` array not working for pasted elements

Open

#1,842 opened on Aug 23, 2018

View on GitHub
 (2 comments) (0 reactions) (0 assignees)JavaScript (22,554 stars) (2,646 forks)batch import
help wanted

Description

Do you want to request a feature or report a bug? Bug

What is the current behavior? When setting aliasedElements in my blockRenderMap, pasted elements do not use the block they are aliased under. I want to only allow h1 and h2 and for all other heading elements to render as h2, but they are rendering as unstyled / .

const blockRenderMap = Immutable.Map({
	'header-one': {
		element: 'h1',
	},
	'header-two': {
		element: 'h2',
		aliasedElements: ['h3', 'h4', 'h5', 'h6'],
	},
	unstyled: {
		element: 'p',
		aliasedElements: ['pre'],
	},
});

See docs here; https://draftjs.org/docs/advanced-topics-custom-block-render-map.html#configuring-block-render-map

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. I have reproduced the problem here https://jsfiddle.net/m6z0xn4r/1250/

What is the expected behavior? Any pasted h3, h4, h5, h6 should render as h2.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js? Happening on Chrome, Firefox and Safari for mac. I believe the above jsFiddle is the latest version?

Contributor guide