@quillforms/block-editor
Version:
71 lines (67 loc) • 1.93 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _richText = require("@quillforms/rich-text");
var _components = require("@wordpress/components");
var _icons = require("@wordpress/icons");
var _data = require("@wordpress/data");
var _jsxRuntime = require("react/jsx-runtime");
/**
* QuillForms Dependencies
*/
/**
* Internal Dependencies
*/
/**
* WordPress Dependencies
*/
const DraggedBlock = ({
name,
id
}) => {
const {
blockType,
block
} = (0, _data.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: _icons.blockDefault
};
}
if (!icon) {
icon = _icons.plus;
}
const renderedIcon = /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
icon: icon?.src ? icon.src : icon
});
const blockLabel = (0, _richText.getPlainExcerpt)(block?.attributes?.label);
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
className: "block-editor-block-dragging__wrapper",
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
className: "block-editor-block-dragging",
children: [/*#__PURE__*/(0, _jsxRuntime.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__*/(0, _jsxRuntime.jsx)("div", {
className: "block-editor-block-dragging__title-excerpt",
dangerouslySetInnerHTML: {
__html: blockLabel
}
})]
})
});
};
var _default = exports.default = DraggedBlock;
//# sourceMappingURL=index.js.map