UNPKG

@wordpress/block-library

Version:
35 lines (34 loc) 1.02 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())) } ) }); } export { CodeEdit as default }; //# sourceMappingURL=edit.js.map