(wrapper: HTMLElement, pre: HTMLPreElement)
| 81 | } |
| 82 | |
| 83 | function ensureCodeBlockToolbar(wrapper: HTMLElement, pre: HTMLPreElement): void { |
| 84 | if (wrapper.querySelector(`.${CODE_BLOCK_TOOLBAR_CLASS}`)) return |
| 85 | |
| 86 | const toolbar = pre.ownerDocument.createElement('div') |
| 87 | toolbar.className = CODE_BLOCK_TOOLBAR_CLASS |
| 88 | |
| 89 | const foldButton = pre.ownerDocument.createElement('button') |
| 90 | foldButton.type = 'button' |
| 91 | foldButton.className = CODE_FOLD_BUTTON_SELECTOR.slice(1) |
| 92 | foldButton.setAttribute('aria-label', 'Collapse code block') |
| 93 | foldButton.setAttribute('aria-expanded', 'true') |
| 94 | foldButton.title = 'Collapse code block' |
| 95 | foldButton.textContent = 'Fold' |
| 96 | |
| 97 | const copyButton = pre.ownerDocument.createElement('button') |
| 98 | copyButton.type = 'button' |
| 99 | copyButton.className = CODE_COPY_BUTTON_SELECTOR.slice(1) |
| 100 | copyButton.setAttribute('aria-label', 'Copy code block') |
| 101 | copyButton.title = 'Copy code block' |
| 102 | copyButton.textContent = 'Copy' |
| 103 | |
| 104 | toolbar.append(foldButton, copyButton) |
| 105 | wrapper.insertBefore(toolbar, pre) |
| 106 | } |
| 107 | |
| 108 | function ensureCodeBlockSummary(wrapper: HTMLElement, code: HTMLElement): void { |
| 109 | let summary = wrapper.querySelector<HTMLElement>(`.${CODE_BLOCK_SUMMARY_CLASS}`) |
no outgoing calls
no test coverage detected