1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-01 05:16:10 +01:00

Merge decorations from multiple plugins (#2197)

* Merge decorations from multiple plugins

Previously, `decorateNode` would search the plugin stack for the first
`decorateNode` handler that returned a value. Now, it will call the
`decorateNode` handler on every plugin in the stack and merge their results
together.

* Call List() to instantiate empty list instead of using new keyword

* Fix linting errors and use Immutable's flatten()

* Use boolean flatten() argument for clarity (shallow flatten)
This commit is contained in:
Alan Christopher Thomas 2018-09-22 13:12:12 -05:00 committed by Ian Storm Taylor
parent bf9b03e634
commit 0f5d95e98e

View File

@ -436,8 +436,10 @@ class ElementInterface {
*/
getDecorations(stack) {
const decorations = stack.find('decorateNode', this)
const list = Decoration.createList(decorations || [])
const allDecorations = stack
.map('decorateNode', this)
.map(decorations => Decoration.createList(decorations))
const list = List(allDecorations).flatten(true)
return list
}