1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-31 02:49:56 +02:00

Fixed mentions example (#2877)

This commit is contained in:
Nadeem Shaik
2019-06-12 23:37:35 +05:30
committed by Ian Storm Taylor
parent 67e397100e
commit 5471343ae8
3 changed files with 51 additions and 20 deletions

View File

@@ -58,6 +58,18 @@ Commands.setAnnotation = (editor, annotation, newProperties) => {
})
}
Commands.setAnnotations = (editor, annotations = []) => {
const { value } = editor
const newProperties = Value.createProperties({ annotations })
const prevProperties = pick(value, Object.keys(newProperties))
editor.applyOperation({
type: 'set_value',
properties: prevProperties,
newProperties,
})
}
/**
* Export.
*

View File

@@ -68,7 +68,7 @@ class Value extends Record(DEFAULTS) {
if (isPlainObject(a)) {
const p = {}
if ('annotations' in a)
p.annotations = Annotation.createList(a.annotations)
p.annotations = Annotation.createMap(a.annotations)
if ('data' in a) p.data = Data.create(a.data)
return p
}