1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | 'use strict';
|
12 |
|
13 | var BlockMapBuilder = require("./BlockMapBuilder");
|
14 |
|
15 | var CharacterMetadata = require("./CharacterMetadata");
|
16 |
|
17 | var ContentBlock = require("./ContentBlock");
|
18 |
|
19 | var ContentState = require("./ContentState");
|
20 |
|
21 | var EditorState = require("./EditorState");
|
22 |
|
23 | var SampleDraftInlineStyle = require("./SampleDraftInlineStyle");
|
24 |
|
25 | var SelectionState = require("./SelectionState");
|
26 |
|
27 | var Immutable = require("immutable");
|
28 |
|
29 | var BOLD = SampleDraftInlineStyle.BOLD,
|
30 | ITALIC = SampleDraftInlineStyle.ITALIC;
|
31 | var ENTITY_KEY = '2';
|
32 | var BLOCKS = [new ContentBlock({
|
33 | key: 'a',
|
34 | type: 'unstyled',
|
35 | text: 'Alpha',
|
36 | characterList: Immutable.List(Immutable.Repeat(CharacterMetadata.EMPTY, 5))
|
37 | }), new ContentBlock({
|
38 | key: 'b',
|
39 | type: 'unordered-list-item',
|
40 | text: 'Bravo',
|
41 | characterList: Immutable.List(Immutable.Repeat(CharacterMetadata.create({
|
42 | style: BOLD,
|
43 | entity: ENTITY_KEY
|
44 | }), 5))
|
45 | }), new ContentBlock({
|
46 | key: 'c',
|
47 | type: 'code-block',
|
48 | text: 'Test',
|
49 | characterList: Immutable.List(Immutable.Repeat(CharacterMetadata.EMPTY, 4))
|
50 | }), new ContentBlock({
|
51 | key: 'd',
|
52 | type: 'code-block',
|
53 | text: '',
|
54 | characterList: Immutable.List()
|
55 | }), new ContentBlock({
|
56 | key: 'e',
|
57 | type: 'code-block',
|
58 | text: '',
|
59 | characterList: Immutable.List()
|
60 | }), new ContentBlock({
|
61 | key: 'f',
|
62 | type: 'blockquote',
|
63 | text: 'Charlie',
|
64 | characterList: Immutable.List(Immutable.Repeat(CharacterMetadata.create({
|
65 | style: ITALIC,
|
66 | entity: null
|
67 | }), 7))
|
68 | })];
|
69 | var selectionState = new SelectionState({
|
70 | anchorKey: 'a',
|
71 | anchorOffset: 0,
|
72 | focusKey: 'a',
|
73 | focusOffset: 0,
|
74 | isBackward: false,
|
75 | hasFocus: true
|
76 | });
|
77 | var blockMap = BlockMapBuilder.createFromArray(BLOCKS);
|
78 | var contentState = new ContentState({
|
79 | blockMap: blockMap,
|
80 | entityMap: Immutable.OrderedMap(),
|
81 | selectionBefore: selectionState,
|
82 | selectionAfter: selectionState
|
83 | }).createEntity({
|
84 | type: 'IMAGE',
|
85 | mutability: 'IMMUTABLE',
|
86 | data: null
|
87 | });
|
88 | var editorState = EditorState.createWithContent(contentState);
|
89 | editorState = EditorState.forceSelection(editorState, selectionState);
|
90 |
|
91 | var getSampleStateForTesting = function getSampleStateForTesting() {
|
92 | return {
|
93 | editorState: editorState,
|
94 | contentState: contentState,
|
95 | selectionState: selectionState
|
96 | };
|
97 | };
|
98 |
|
99 | module.exports = getSampleStateForTesting; |
\ | No newline at end of file |