UNPKG

@atlaskit/editor-plugin-block-controls

Version:

Block controls plugin for @atlaskit/editor-core

26 lines (24 loc) 872 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isFragmentOfType = exports.containsNodeOfType = void 0; /** * Check if the fragment has only one node of the specified type */ var isFragmentOfType = exports.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 */ var containsNodeOfType = exports.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; };