mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-02-25 01:33:37 +01:00
49 lines
691 B
JavaScript
49 lines
691 B
JavaScript
|
|
import { List, Map, Record } from 'immutable'
|
|
|
|
/**
|
|
* Record.
|
|
*/
|
|
|
|
const MarkRecord = new Record({
|
|
data: new Map(),
|
|
type: null
|
|
})
|
|
|
|
/**
|
|
* Mark.
|
|
*/
|
|
|
|
class Mark extends MarkRecord {
|
|
|
|
/**
|
|
* Create a new `Mark` with `properties`.
|
|
*
|
|
* @param {Object} properties
|
|
* @return {Mark} mark
|
|
*/
|
|
|
|
static create(properties = {}) {
|
|
if (!properties.type) throw new Error('You must provide a `type` for the mark.')
|
|
return new Mark(properties)
|
|
}
|
|
|
|
/**
|
|
* Create a marks list from an array of marks.
|
|
*
|
|
* @param {Array} array
|
|
* @return {List} marks
|
|
*/
|
|
|
|
static createList(array = []) {
|
|
return new List(array)
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* Export.
|
|
*/
|
|
|
|
export default Mark
|