UNPKG

@atlaskit/editor-plugin-block-controls

Version:

Block controls plugin for @atlaskit/editor-core

31 lines 1.82 kB
import { isEmptyParagraph } from '@atlaskit/editor-common/utils'; import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments'; import { isWrappedMedia } from './check-media-layout'; import { maxLayoutColumnSupported } from './consts'; var syncedBlockTypes = ['syncBlock', 'bodiedSyncBlock']; export var shouldAllowInlineDropTarget = function shouldAllowInlineDropTarget(isNested, node) { var isSameLayout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; var activeNode = arguments.length > 3 ? arguments[3] : undefined; var parentNode = arguments.length > 4 ? arguments[4] : undefined; var isInsideBodiedSyncBlock = (parentNode === null || parentNode === void 0 ? void 0 : parentNode.type.name) === 'bodiedSyncBlock'; if (editorExperiment('advanced_layouts', false) || isNested) { // If nested inside bodiedSyncBlock, enable inline drop target so user can drop to create a layout inside it if (isInsideBodiedSyncBlock && editorExperiment('platform_synced_block', true) && editorExperiment('platform_synced_block_patch_6', true)) { return true; } return false; } if (isWrappedMedia(node)) { return false; } if ((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) === 'layoutSection') { return false; } if ((syncedBlockTypes.includes((activeNode === null || activeNode === void 0 ? void 0 : activeNode.nodeType) || '') || syncedBlockTypes.includes((node === null || node === void 0 ? void 0 : node.type.name) || '')) && editorExperiment('platform_synced_block', true)) { return false; } if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') { return node.childCount < maxLayoutColumnSupported() || isSameLayout; } return !isEmptyParagraph(node); };