1 | 'use strict';
|
2 |
|
3 | var getCurrentItem = require('./getCurrentItem');
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | function getPreviousItem(opts, value, block) {
|
14 | var document = value.document,
|
15 | startBlock = value.startBlock;
|
16 |
|
17 | block = block || startBlock;
|
18 |
|
19 | var currentItem = getCurrentItem(opts, value, block);
|
20 |
|
21 | var previousSibling = document.getPreviousSibling(currentItem.key);
|
22 |
|
23 | if (!previousSibling) {
|
24 | return null;
|
25 | } else if (previousSibling.type === opts.typeItem) {
|
26 | return previousSibling;
|
27 | } else {
|
28 | return null;
|
29 | }
|
30 | }
|
31 |
|
32 | module.exports = getPreviousItem; |
\ | No newline at end of file |