@wordpress/block-library
Version:
Block library for the WordPress editor.
43 lines (42 loc) • 1.2 kB
JavaScript
// packages/block-library/src/list-item/index.js
import { listItem as icon } from "@wordpress/icons";
import { privateApis } from "@wordpress/block-editor";
import initBlock from "../utils/init-block.mjs";
import metadata from "./block.json";
import edit from "./edit.mjs";
import save from "./save.mjs";
import transforms from "./transforms.mjs";
import { unlock } from "../lock-unlock.mjs";
var { name } = metadata;
var settings = {
icon,
edit,
save,
merge(attributes, attributesToMerge) {
return {
...attributes,
content: attributes.content + attributesToMerge.content
};
},
transforms,
[unlock(privateApis).requiresWrapperOnCopy]: true,
__experimentalLabel(attributes, { context }) {
const { content } = attributes;
const customName = attributes?.metadata?.name;
const hasContent = content?.trim().length > 0;
if (context === "list-view" && (customName || hasContent)) {
return customName || content;
}
if (context === "breadcrumb" && customName) {
return customName;
}
}
};
var init = () => initBlock({ name, metadata, settings });
export {
init,
metadata,
name,
settings
};
//# sourceMappingURL=index.mjs.map