UNPKG

@gechiui/block-editor

Version:
46 lines (43 loc) 1.22 kB
/** * GeChiUI dependencies */ import { useSelect } from '@gechiui/data'; import { rawHandler, store as blocksStore } from '@gechiui/blocks'; import { getClipboard } from '@gechiui/components'; /** * Internal dependencies */ import { store as blockEditorStore } from '../../../store'; export default function useClipboardBlock(destinationRootClientId) { const { canInsertBlockType } = useSelect(blockEditorStore); const { getBlockType } = useSelect(blocksStore); const clipboard = getClipboard(); const clipboardBlock = rawHandler({ HTML: clipboard })[0]; const canAddClipboardBlock = canInsertBlockType(clipboardBlock === null || clipboardBlock === void 0 ? void 0 : clipboardBlock.name, destinationRootClientId); const blockType = getBlockType(clipboardBlock === null || clipboardBlock === void 0 ? void 0 : clipboardBlock.name); if (!canAddClipboardBlock || !blockType) { return undefined; } const { name, icon } = blockType; const { attributes: initialAttributes, innerBlocks } = clipboardBlock; return { id: 'clipboard', name, icon, initialAttributes, innerBlocks }; } //# sourceMappingURL=use-clipboard-block.native.js.map