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:
@@ -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 }
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user