UNPKG

568 BJavaScriptView Raw
1"use strict";
2
3/**
4 * Return the current list item, from current selection or from a node.
5 *
6 * @param {PluginOptions} opts
7 * @param {Slate.Value} value
8 * @param {Slate.Block} block?
9 * @return {Slate.Block || Void}
10 */
11function getCurrentItem(opts, value, block) {
12 var document = value.document;
13
14
15 if (!block) {
16 if (!value.selection.startKey) return null;
17 block = value.startBlock;
18 }
19
20 var parent = document.getParent(block.key);
21 return parent && parent.type === opts.typeItem ? parent : null;
22}
23
24module.exports = getCurrentItem;
\No newline at end of file