all files / model/ EditingBehavior.js

18.75% Statements 3/16
0% Branches 0/4
10% Functions 1/10
18.75% Lines 3/16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53      206× 206× 206×                                                                                              
class EditingBehavior {
 
  constructor() {
    this._merge = {}
    this._mergeComponents = {}
    this._break = {}
  }
 
  defineMerge(firstType, secondType, impl) {
    if (!this._merge[firstType]) {
      this._merge[firstType] = {}
    }
    this._merge[firstType][secondType] = impl
    return this
  }
 
  canMerge(firstType, secondType) {
    return (this._merge[firstType] && this._merge[firstType][secondType])
  }
 
  getMerger(firstType, secondType) {
    return this._merge[firstType][secondType]
  }
 
  defineComponentMerge(nodeType, impl) {
    this._mergeComponents[nodeType] = impl
  }
 
  canMergeComponents(nodeType) {
    return this._mergeComponents[nodeType]
  }
 
  getComponentMerger(nodeType) {
    return this._mergeComponents[nodeType]
  }
 
  defineBreak(nodeType, impl) {
    this._break[nodeType] = impl
    return this
  }
 
  canBreak(nodeType) {
    return this._break[nodeType]
  }
 
  getBreaker(nodeType) {
    return this._break[nodeType]
  }
 
}
 
export default EditingBehavior