UNPKG

@atlaskit/editor-plugin-block-controls

Version:

Block controls plugin for @atlaskit/editor-core

32 lines 1.67 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'; const syncedBlockTypes = ['syncBlock', 'bodiedSyncBlock']; export const shouldAllowInlineDropTarget = (isNested, node, /** * Is the active node in the same layout as the target node */ isSameLayout = false, activeNode, parentNode) => { const 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); };