@wordpress/block-library
Version:
Block library for the WordPress editor.
17 lines (16 loc) • 456 B
JavaScript
// packages/block-library/src/tab/slug-from-label.js
import { cleanForSlug } from "@wordpress/url";
function slugFromLabel(label, tabIndex) {
const htmlDocument = new window.DOMParser().parseFromString(
label,
"text/html"
);
if (htmlDocument.body?.textContent) {
return cleanForSlug(htmlDocument.body.textContent);
}
return `tab-panel-${tabIndex}`;
}
export {
slugFromLabel as default
};
//# sourceMappingURL=slug-from-label.js.map