@wordpress/block-library
Version:
Block library for the WordPress editor.
45 lines (44 loc) • 1.98 kB
JavaScript
import { __ } from "@wordpress/i18n";
import { ToggleControl, __experimentalToolsPanel, __experimentalToolsPanelItem } from "@wordpress/components";
import { InspectorControls, PlainText, useBlockProps } from "@wordpress/block-editor";
import { createBlock, getDefaultBlockName } from "@wordpress/blocks";
import { useToolsPanelDropdownMenuProps } from "../utils/hooks.mjs";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
// packages/block-library/src/more/edit.jsx
const DEFAULT_TEXT = __("Read more");
function MoreEdit({ attributes: { customText, noTeaser }, insertBlocksAfter, setAttributes }) {
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(InspectorControls, { children: /* @__PURE__ */ jsx(__experimentalToolsPanel, {
label: __("Settings"),
resetAll: () => {
setAttributes({ noTeaser: false });
},
dropdownMenuProps,
children: /* @__PURE__ */ jsx(__experimentalToolsPanelItem, {
label: __("Hide excerpt"),
isShownByDefault: true,
hasValue: () => noTeaser,
onDeselect: () => setAttributes({ noTeaser: false }),
children: /* @__PURE__ */ jsx(ToggleControl, {
label: __("Hide the excerpt on the full content page"),
checked: !!noTeaser,
onChange: () => setAttributes({ noTeaser: !noTeaser }),
help: (checked) => checked ? __("The excerpt is hidden.") : __("The excerpt is visible.")
})
})
}) }), /* @__PURE__ */ jsx("div", {
...useBlockProps(),
children: /* @__PURE__ */ jsx(PlainText, {
__experimentalVersion: 2,
tagName: "span",
"aria-label": __("\"Read more\" text"),
value: customText,
placeholder: DEFAULT_TEXT,
onChange: (value) => setAttributes({ customText: value }),
disableLineBreaks: true,
__unstableOnSplitAtEnd: insertBlocksAfter ? () => insertBlocksAfter(createBlock(getDefaultBlockName())) : void 0
})
})] });
}
export { MoreEdit as default };
//# sourceMappingURL=edit.mjs.map