1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-30 02:19:52 +02:00

Add marks option to Text.createFromString

This commit is contained in:
Soreine
2016-11-08 15:13:38 +01:00
parent e28b76b709
commit 49f6331075

View File

@@ -48,15 +48,16 @@ class Text extends new Record(DEFAULTS) {
* Create a new `Text` from a string * Create a new `Text` from a string
* *
* @param {String} content * @param {String} content
* @param {Set<Mark>} marks (optional)
* @return {Text} * @return {Text}
*/ */
static createFromString(content) { static createFromString(content, marks = Set()) {
return Text.create({ return Text.create({
characters: Character.createList( characters: Character.createList(
content.split('') content.split('')
.map(c => { .map(c => {
return { text: c } return { text: c, marks }
}) })
) )
}) })