Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Commit

Permalink
refactor: add constructor to fix jest test failing
Browse files Browse the repository at this point in the history
  • Loading branch information
jsamr committed May 27, 2019
1 parent 4ad277c commit a503954
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/model/TextBlock.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import Block from './Block'
import { TextAttributesMap, BlockAttributesMap } from '@delta/attributes'
import Document from './Document'
import { TextAttributesMap } from '@delta/attributes'
import { boundMethod } from 'autobind-decorator'
import { Selection } from '@delta/selection'
import TextTransformsRegistry from '@core/TextTransformsRegistry'
import { DeltaChangeContext } from '@delta/DocumentDelta';
import { DeltaChangeContext } from '@delta/DocumentDelta'

export default class TextBlock<T extends string> extends Block<T> {

Expand All @@ -14,6 +15,12 @@ export default class TextBlock<T extends string> extends Block<T> {
}
private length: number = 0

constructor(
blockInterface: Document.BlockInterface<T>
) {
super(blockInterface)
}

getSelection(): Selection {
// TODO inspect dependencies and refactor
return this.selection
Expand Down Expand Up @@ -43,7 +50,6 @@ export default class TextBlock<T extends string> extends Block<T> {

@boundMethod
handleOnTextChange(newText: string, context: DeltaChangeContext): void {
// Sanitize newText here
const updatedDelta = this.getDelta().applyTextDiff(newText, context)
this.updateDelta(updatedDelta)
this.length = newText.length
Expand Down

0 comments on commit a503954

Please sign in to comment.