@quillforms/block-editor
Version:
64 lines (62 loc) • 1.71 kB
JavaScript
/**
* QuillForms Dependencies
*/
/**
* Internal Dependencies
*/
import { getPlainExcerpt } from '@quillforms/rich-text';
/**
* WordPress Dependencies
*/
import { Icon } from '@wordpress/components';
import { blockDefault, plus } from '@wordpress/icons';
import { useSelect } from '@wordpress/data';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const DraggedBlock = ({
name,
id
}) => {
const {
blockType,
block
} = useSelect(select => {
return {
blockType: select('quillForms/blocks').getBlockType(name),
block: select('quillForms/block-editor').getBlockById(id)
};
});
let icon = blockType?.icon;
if (icon?.src === 'block-default') {
icon = {
src: blockDefault
};
}
if (!icon) {
icon = plus;
}
const renderedIcon = /*#__PURE__*/_jsx(Icon, {
icon: icon?.src ? icon.src : icon
});
const blockLabel = getPlainExcerpt(block?.attributes?.label);
return /*#__PURE__*/_jsx("div", {
className: "block-editor-block-dragging__wrapper",
children: /*#__PURE__*/_jsxs("div", {
className: "block-editor-block-dragging",
children: [/*#__PURE__*/_jsx("div", {
className: "block-editor-block-dragging__icon-box",
style: {
background: blockType?.color ? blockType.color : '#bb426f',
border: blockType?.color === '#fff' ? '1px solid #e3e3e3' : 'none'
},
children: renderedIcon
}), /*#__PURE__*/_jsx("div", {
className: "block-editor-block-dragging__title-excerpt",
dangerouslySetInnerHTML: {
__html: blockLabel
}
})]
})
});
};
export default DraggedBlock;
//# sourceMappingURL=index.js.map