1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | function getCurrentCode(opts, state, key) {
|
12 | var document = state.document;
|
13 |
|
14 |
|
15 | var currentBlock = void 0;
|
16 | if (key) {
|
17 | currentBlock = state.document.getDescendant(key);
|
18 | } else {
|
19 | if (!state.selection.startKey) return null;
|
20 | currentBlock = state.startBlock;
|
21 | }
|
22 |
|
23 |
|
24 |
|
25 | var parent = document.getParent(currentBlock.key);
|
26 | if (parent && parent.type === opts.containerType) {
|
27 | return parent;
|
28 | } else {
|
29 | return null;
|
30 | }
|
31 | }
|
32 |
|
33 | module.exports = getCurrentCode; |
\ | No newline at end of file |