@studysync/draft-js-modifiers 0.4.15 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -5
- package/package.json +11 -4
- package/flow/stub/__dev__.js +0 -3
- package/script/add-module.js +0 -48
- package/src/addBlock.js +0 -98
- package/src/adjustBlockDepth.js +0 -21
- package/src/atEndOfBlock.js +0 -10
- package/src/atStartOfBlock.js +0 -7
- package/src/changeBlockType.js +0 -19
- package/src/getAllEntities.js +0 -14
- package/src/getEntitiesForBlock.js +0 -29
- package/src/getEntitiesForSelection.js +0 -20
- package/src/getSelectedText.js +0 -11
- package/src/getSimilarAdjacentBlocks.js +0 -53
- package/src/index.js +0 -41
- package/src/insertAtomicBlock.js +0 -23
- package/src/insertBlock.js +0 -40
- package/src/insertEmptyBlock.js +0 -12
- package/src/insertEntity.js +0 -56
- package/src/insertNewBlock.js +0 -61
- package/src/insertText.js +0 -23
- package/src/mergeBlockData.js +0 -13
- package/src/mergeBlockDataByKey.js +0 -12
- package/src/mergeEntityData.js +0 -13
- package/src/modifyBlock.js +0 -20
- package/src/modifyBlockByKey.js +0 -19
- package/src/moveCaretAfterBlock.js +0 -26
- package/src/moveCaretToEnd.js +0 -20
- package/src/removeBlock.js +0 -43
- package/src/removeBlockStyle.js +0 -17
- package/src/removeEntity.js +0 -38
- package/src/removeInlineStyles.js +0 -29
- package/src/resetBlock.js +0 -29
- package/src/selectAll.js +0 -15
- package/src/selectBlockByKey.js +0 -20
- package/src/setBlockData.js +0 -14
- package/src/toggleBlockStyle.js +0 -33
- package/src/toggleBlockType.js +0 -12
- package/src/toggleEntity.js +0 -11
- package/src/toggleInlineStyle.js +0 -11
- package/src/trimEditorState.js +0 -41
- package/src/utils/getCurrentBlock.js +0 -10
- package/src/utils/numbers.js +0 -3
- package/test/adjustBlockDepth.js +0 -45
- package/test/export.js +0 -14
- package/test/fixtures/createEditorState.js +0 -12
- package/test/fixtures/omitBlockKeysFromRawContent.js +0 -9
- package/test/insertAtomicBlock.js +0 -89
- package/test/insertEmptyBlock.js +0 -65
- package/test/insertNewBlock.js +0 -68
- package/test/insertText.js +0 -58
- package/test/mergeBlockData.js +0 -40
- package/test/mergeBlockDataByKey.js +0 -103
- package/test/mergeEntityData.js +0 -49
- package/test/modifyBlock.js +0 -52
- package/test/modifyBlockByKey.js +0 -91
- package/test/removeBlockStyle.js +0 -52
- package/test/removeInlineStyles.js +0 -68
- package/test/resetBlock.js +0 -83
- package/test/toggleBlockType.js +0 -4
- package/test/toggleEntity.js +0 -4
- package/test/toggleInlineStyle.js +0 -4
package/test/resetBlock.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import test from 'ava'
|
|
2
|
-
import { convertToRaw } from 'draft-js'
|
|
3
|
-
import createEditorState from './fixtures/createEditorState'
|
|
4
|
-
|
|
5
|
-
import resetBlock from '../src/resetBlock'
|
|
6
|
-
|
|
7
|
-
const blocks = () => [
|
|
8
|
-
{
|
|
9
|
-
key: 'item1',
|
|
10
|
-
text: 'asdf',
|
|
11
|
-
type: 'header-one',
|
|
12
|
-
depth: 0,
|
|
13
|
-
inlineStyleRanges: [],
|
|
14
|
-
entityRanges: [],
|
|
15
|
-
data: {},
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
key: 'item2',
|
|
19
|
-
text: 'fdsa',
|
|
20
|
-
type: 'header-two',
|
|
21
|
-
depth: 0,
|
|
22
|
-
inlineStyleRanges: [],
|
|
23
|
-
entityRanges: [],
|
|
24
|
-
// TODO: test Entity
|
|
25
|
-
// entityRanges: [{
|
|
26
|
-
// key: 0,
|
|
27
|
-
// length: 2,
|
|
28
|
-
// offset: 2
|
|
29
|
-
// }],
|
|
30
|
-
data: {},
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
key: 'item3',
|
|
34
|
-
text: 'jkl;',
|
|
35
|
-
type: 'ordered-list-item',
|
|
36
|
-
depth: 1,
|
|
37
|
-
inlineStyleRanges: [{
|
|
38
|
-
length: 4,
|
|
39
|
-
offset: 0,
|
|
40
|
-
style: 'ITALIC',
|
|
41
|
-
}],
|
|
42
|
-
entityRanges: [],
|
|
43
|
-
data: { foo: 1 },
|
|
44
|
-
},
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
const reset = block => Object.assign({}, block, {
|
|
48
|
-
text: '',
|
|
49
|
-
type: 'unstyled',
|
|
50
|
-
depth: 0,
|
|
51
|
-
inlineStyleRanges: [],
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
blocks().forEach(({ key }, i) => {
|
|
55
|
-
const beforeRawContentState = {
|
|
56
|
-
entityMap: {},
|
|
57
|
-
blocks: blocks(),
|
|
58
|
-
}
|
|
59
|
-
const afterRawContentState = {
|
|
60
|
-
entityMap: {},
|
|
61
|
-
blocks: blocks().map(block => block.key === key ? reset(block) : block),
|
|
62
|
-
}
|
|
63
|
-
const editorState = createEditorState(
|
|
64
|
-
beforeRawContentState,
|
|
65
|
-
{
|
|
66
|
-
anchorKey: 'item1',
|
|
67
|
-
anchorOffset: 0,
|
|
68
|
-
focusKey: 'item1',
|
|
69
|
-
focusOffset: 0,
|
|
70
|
-
isBackward: false,
|
|
71
|
-
hasFocus: true,
|
|
72
|
-
}
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
test(`resetBlock ${i}`, t => {
|
|
76
|
-
const newEditorState = resetBlock(editorState, editorState.getCurrentContent().getBlockForKey(key))
|
|
77
|
-
t.not(newEditorState, editorState)
|
|
78
|
-
t.deepEqual(
|
|
79
|
-
convertToRaw(newEditorState.getCurrentContent()),
|
|
80
|
-
afterRawContentState
|
|
81
|
-
)
|
|
82
|
-
})
|
|
83
|
-
})
|
package/test/toggleBlockType.js
DELETED
package/test/toggleEntity.js
DELETED