|
| 1 | +/** |
| 2 | + * Copyright (c) 2013-present, Facebook, Inc. |
| 3 | + * All rights reserved. |
| 4 | + * |
| 5 | + * This source code is licensed under the BSD-style license found in the |
| 6 | + * LICENSE file in the root directory of this source tree. An additional grant |
| 7 | + * of patent rights can be found in the PATENTS file in the same directory. |
| 8 | + * |
| 9 | + * @providesModule BlockNode |
| 10 | + * @format |
| 11 | + * @flow |
| 12 | + */ |
| 13 | + |
| 14 | +'use strict'; |
| 15 | + |
| 16 | +import type CharacterMetadata from '../../node_modules/draft-js/lib/CharacterMetadata'; |
| 17 | +import type { DraftBlockType } from '../../node_modules/draft-js/lib/DraftBlockType'; |
| 18 | +import type { DraftInlineStyle } from '../../node_modules/draft-js/lib/DraftInlineStyle'; |
| 19 | +import type { List, Map } from 'immutable'; |
| 20 | + |
| 21 | +export type BlockNodeKey = string; |
| 22 | + |
| 23 | +export type BlockNodeConfig = { |
| 24 | + characterList?: List<CharacterMetadata>; |
| 25 | + data?: Map<any, any>; |
| 26 | + depth?: number; |
| 27 | + key?: BlockNodeKey; |
| 28 | + text?: string; |
| 29 | + type?: DraftBlockType; |
| 30 | +}; |
| 31 | + |
| 32 | +// https://github.com/facebook/draft-js/issues/1492 |
| 33 | +// prettier-ignore |
| 34 | +export interface BlockNode { |
| 35 | + +findEntityRanges: (filterFn: (value: CharacterMetadata) => boolean, callback: (start: number, end: number) => void) => void; |
| 36 | + |
| 37 | + +findStyleRanges: (filterFn: (value: CharacterMetadata) => boolean, callback: (start: number, end: number) => void) => void; |
| 38 | + |
| 39 | + +getCharacterList: () => List<CharacterMetadata>; |
| 40 | + |
| 41 | + +getData: () => Map<any, any>; |
| 42 | + |
| 43 | + +getDepth: () => number; |
| 44 | + |
| 45 | + +getEntityAt: (offset: number) => ?string; |
| 46 | + |
| 47 | + +getInlineStyleAt: (offset: number) => DraftInlineStyle; |
| 48 | + |
| 49 | + +getKey: () => BlockNodeKey; |
| 50 | + |
| 51 | + +getLength: () => number; |
| 52 | + |
| 53 | + +getText: () => string; |
| 54 | + |
| 55 | + +getType: () => DraftBlockType; |
| 56 | +} |
0 commit comments