UNPKG

@wordpress/block-editor

Version:
51 lines (48 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = useClipboardBlock; var _data = require("@wordpress/data"); var _blocks = require("@wordpress/blocks"); var _components = require("@wordpress/components"); var _store = require("../../../store"); /** * WordPress dependencies */ /** * Internal dependencies */ function useClipboardBlock(destinationRootClientId) { const { canInsertBlockType } = (0, _data.useSelect)(_store.store); const { getBlockType } = (0, _data.useSelect)(_blocks.store); const clipboard = (0, _components.getClipboard)(); const clipboardBlock = (0, _blocks.rawHandler)({ HTML: clipboard })[0]; const canAddClipboardBlock = canInsertBlockType(clipboardBlock?.name, destinationRootClientId); const blockType = getBlockType(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