| 1 |
import { useCallback } from "react"; |
| 2 |
|
| 3 |
export function useBlockCardUpdateShim() { |
| 4 |
return useCallback( |
| 5 |
(element: HTMLElement, title: string, description: string) => { |
| 6 |
const ownerDoc = element.ownerDocument; |
| 7 |
const parentDoc = |
| 8 |
ownerDoc.defaultView?.parent?.document || ownerDoc; |
| 9 |
|
| 10 |
const blockCardTitle = parentDoc.querySelector( |
| 11 |
".block-editor-block-card__title" |
| 12 |
); |
| 13 |
if (blockCardTitle) { |
| 14 |
blockCardTitle.textContent = title; |
| 15 |
} |
| 16 |
|
| 17 |
const blockCardDescription = parentDoc.querySelector( |
| 18 |
".block-editor-block-card__description" |
| 19 |
); |
| 20 |
if (blockCardDescription) { |
| 21 |
blockCardDescription.textContent = description; |
| 22 |
} |
| 23 |
}, |
| 24 |
[] |
| 25 |
); |
| 26 |
} |
| 27 |
|