facebookarchive/draft-js

`aliasedElements` array not working for pasted elements

Open

#1842 aperta il 23 ago 2018

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)JavaScript (2646 fork)batch import
help wanted

Metriche repository

Star
 (22.554 star)
Metriche merge PR
 (Nessuna PR mergiata in 30 g)

Descrizione

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?

Guida contributor