@atlaskit/editor-plugin-block-controls
Version:
Block controls plugin for @atlaskit/editor-core
37 lines (36 loc) • 2.06 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shouldAllowInlineDropTarget = void 0;
var _utils = require("@atlaskit/editor-common/utils");
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
var _checkMediaLayout = require("./check-media-layout");
var _consts = require("./consts");
var syncedBlockTypes = ['syncBlock', 'bodiedSyncBlock'];
var shouldAllowInlineDropTarget = exports.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 ((0, _experiments.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 && (0, _experiments.editorExperiment)('platform_synced_block', true) && (0, _experiments.editorExperiment)('platform_synced_block_patch_6', true)) {
return true;
}
return false;
}
if ((0, _checkMediaLayout.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) || '')) && (0, _experiments.editorExperiment)('platform_synced_block', true)) {
return false;
}
if ((node === null || node === void 0 ? void 0 : node.type.name) === 'layoutSection') {
return node.childCount < (0, _consts.maxLayoutColumnSupported)() || isSameLayout;
}
return !(0, _utils.isEmptyParagraph)(node);
};