1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-02-24 17:23:07 +01:00
slate/lib/models/mark.js
2016-06-20 12:57:31 -07:00

49 lines
686 B
JavaScript

import { Map, Record, Set } 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 set from an array of marks.
*
* @param {Array} array
* @return {Set} marks
*/
static createSet(array = []) {
return new Set(array)
}
}
/**
* Export.
*/
export default Mark