@wordpress/block-library
Version:
Block library for the WordPress editor.
45 lines (44 loc) • 2.37 kB
JavaScript
;
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
let _wordpress_block_editor = require("@wordpress/block-editor");
let _wordpress_components = require("@wordpress/components");
let _wordpress_blocks = require("@wordpress/blocks");
let _wordpress_i18n = require("@wordpress/i18n");
let ___utils_hooks_js = require("../utils/hooks.cjs");
let react_jsx_runtime = require("react/jsx-runtime");
// packages/block-library/src/read-more/edit.jsx
function ReadMore({ attributes: { content, linkTarget }, setAttributes, insertBlocksAfter }) {
const blockProps = (0, _wordpress_block_editor.useBlockProps)();
const dropdownMenuProps = (0, ___utils_hooks_js.useToolsPanelDropdownMenuProps)();
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.InspectorControls, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalToolsPanel, {
label: (0, _wordpress_i18n.__)("Settings"),
resetAll: () => setAttributes({ linkTarget: "_self" }),
dropdownMenuProps,
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalToolsPanelItem, {
label: (0, _wordpress_i18n.__)("Open in new tab"),
isShownByDefault: true,
hasValue: () => linkTarget !== "_self",
onDeselect: () => setAttributes({ linkTarget: "_self" }),
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.ToggleControl, {
label: (0, _wordpress_i18n.__)("Open in new tab"),
onChange: (value) => setAttributes({ linkTarget: value ? "_blank" : "_self" }),
checked: linkTarget === "_blank"
})
})
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_block_editor.RichText, {
identifier: "content",
tagName: "a",
"aria-label": (0, _wordpress_i18n.__)("“Read more” link text"),
placeholder: (0, _wordpress_i18n.__)("Read more"),
value: content,
onChange: (newValue) => setAttributes({ content: newValue }),
__unstableOnSplitAtEnd: insertBlocksAfter ? () => insertBlocksAfter((0, _wordpress_blocks.createBlock)((0, _wordpress_blocks.getDefaultBlockName)())) : void 0,
withoutInteractiveFormatting: true,
...blockProps
})] });
}
exports.default = ReadMore;
//# sourceMappingURL=edit.cjs.map