UNPKG

@atlaskit/editor-plugin-block-controls

Version:

Block controls plugin for @atlaskit/editor-core

20 lines (19 loc) 686 B
/** * Check if the fragment has only one node of the specified type */ export var isFragmentOfType = function isFragmentOfType(fragment, type) { var _fragment$firstChild; return fragment.childCount === 1 && ((_fragment$firstChild = fragment.firstChild) === null || _fragment$firstChild === void 0 ? void 0 : _fragment$firstChild.type.name) === type; }; /** * Check if the fragment contains at least a node of the specified type */ export var containsNodeOfType = function containsNodeOfType(fragment, type) { for (var i = 0; i < fragment.childCount; i++) { var child = fragment.child(i); if (child.type.name === type) { return true; } } return false; };