@wordpress/block-library
Version:
Block library for the WordPress editor.
19 lines (18 loc) • 596 B
JavaScript
// packages/block-library/src/navigation-link/shared/select-label-text.js
/**
* Focus the Link label text and select it.
*
* @param {Object} ref React ref object pointing to the label element.
*/
function selectLabelText(ref) {
ref.current.focus();
const { ownerDocument } = ref.current;
const { defaultView } = ownerDocument;
const selection = defaultView.getSelection();
const range = ownerDocument.createRange();
range.selectNodeContents(ref.current);
selection.removeAllRanges();
selection.addRange(range);
}
export { selectLabelText };
//# sourceMappingURL=select-label-text.mjs.map