UNPKG

1.27 kBJavaScriptView Raw
1"use strict";
2
3/**
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 *
9 * @format
10 *
11 * @emails oncall+draft_js
12 *
13 * This is unstable and not part of the public API and should not be used by
14 * production systems. This file may be update/removed without notice.
15 */
16var ContentBlockNode = require("./ContentBlockNode");
17
18var getNextDelimiterBlockKey = function getNextDelimiterBlockKey(block, blockMap) {
19 var isExperimentalTreeBlock = block instanceof ContentBlockNode;
20
21 if (!isExperimentalTreeBlock) {
22 return null;
23 }
24
25 var nextSiblingKey = block.getNextSiblingKey();
26
27 if (nextSiblingKey) {
28 return nextSiblingKey;
29 }
30
31 var parent = block.getParentKey();
32
33 if (!parent) {
34 return null;
35 }
36
37 var nextNonDescendantBlock = blockMap.get(parent);
38
39 while (nextNonDescendantBlock && !nextNonDescendantBlock.getNextSiblingKey()) {
40 var parentKey = nextNonDescendantBlock.getParentKey();
41 nextNonDescendantBlock = parentKey ? blockMap.get(parentKey) : null;
42 }
43
44 if (!nextNonDescendantBlock) {
45 return null;
46 }
47
48 return nextNonDescendantBlock.getNextSiblingKey();
49};
50
51module.exports = getNextDelimiterBlockKey;
\No newline at end of file