@wordpress/block-library
Version:
Block library for the WordPress editor.
28 lines (27 loc) • 1.03 kB
JavaScript
import { __ } from "@wordpress/i18n";
import { RichText, useBlockProps } from "@wordpress/block-editor";
import { createBlock, getDefaultBlockName } from "@wordpress/blocks";
import { jsx } from "react/jsx-runtime";
// packages/block-library/src/code/edit.jsx
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…"),
"aria-label": __("Code"),
preserveWhiteSpace: true,
__unstablePastePlainText: true,
__unstableOnSplitAtDoubleLineEnd: insertBlocksAfter ? () => insertBlocksAfter(createBlock(getDefaultBlockName())) : void 0,
style: { whiteSpace: "break-spaces" }
})
});
}
export { CodeEdit as default };
//# sourceMappingURL=edit.mjs.map