From a503954bf1942e50325cb220175139946af8ab4c Mon Sep 17 00:00:00 2001 From: Jules Randolph Date: Mon, 27 May 2019 15:27:57 +0200 Subject: [PATCH] refactor: add constructor to fix jest test failing See: https://github.com/facebook/react-native/issues/22175#issuecomment-474795611 --- src/model/TextBlock.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/model/TextBlock.ts b/src/model/TextBlock.ts index a6a26184..8700dcf3 100644 --- a/src/model/TextBlock.ts +++ b/src/model/TextBlock.ts @@ -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 extends Block { @@ -14,6 +15,12 @@ export default class TextBlock extends Block { } private length: number = 0 + constructor( + blockInterface: Document.BlockInterface + ) { + super(blockInterface) + } + getSelection(): Selection { // TODO inspect dependencies and refactor return this.selection @@ -43,7 +50,6 @@ export default class TextBlock extends Block { @boundMethod handleOnTextChange(newText: string, context: DeltaChangeContext): void { - // Sanitize newText here const updatedDelta = this.getDelta().applyTextDiff(newText, context) this.updateDelta(updatedDelta) this.length = newText.length