UNPKG

@wordpress/block-library

Version:
36 lines (35 loc) 1.06 kB
// packages/block-library/src/code/edit.js import { __ } from "@wordpress/i18n"; import { RichText, useBlockProps } from "@wordpress/block-editor"; import { createBlock, getDefaultBlockName } from "@wordpress/blocks"; import { jsx } from "react/jsx-runtime"; function CodeEdit({ attributes, setAttributes, onRemove, insertBlocksAfter, mergeBlocks }) { const blockProps = useBlockProps(); return /* @__PURE__ */ jsx("pre", { ...blockProps, children: /* @__PURE__ */ jsx( RichText, { tagName: "code", identifier: "content", value: attributes.content, onChange: (content) => setAttributes({ content }), onRemove, onMerge: mergeBlocks, placeholder: __("Write code\u2026"), "aria-label": __("Code"), preserveWhiteSpace: true, __unstablePastePlainText: true, __unstableOnSplitAtDoubleLineEnd: () => insertBlocksAfter(createBlock(getDefaultBlockName())), style: { whiteSpace: "break-spaces" } } ) }); } export { CodeEdit as default }; //# sourceMappingURL=edit.mjs.map