(vditor: IVditor, blockElement?: HTMLElement | null)
| 228 | }; |
| 229 | |
| 230 | export const resolveCmCodeBlock = (vditor: IVditor, blockElement?: HTMLElement | null) => { |
| 231 | if (blockElement?.isConnected && shouldShowLanguagePopover(blockElement)) { |
| 232 | return blockElement; |
| 233 | } |
| 234 | const fromActive = document.activeElement?.closest("[data-type='code-block']") as HTMLElement; |
| 235 | if (fromActive?.isConnected && shouldShowLanguagePopover(fromActive)) { |
| 236 | return fromActive; |
| 237 | } |
| 238 | const editor = getModeEditor(vditor); |
| 239 | if (editor) { |
| 240 | const focusedCm = editor.querySelector(`.${CM_BLOCK_CLASS} .cm-editor.cm-focused`); |
| 241 | const fromCm = focusedCm?.closest("[data-type='code-block']") as HTMLElement; |
| 242 | if (fromCm?.isConnected && shouldShowLanguagePopover(fromCm)) { |
| 243 | return fromCm; |
| 244 | } |
| 245 | } |
| 246 | return blockElement?.isConnected ? blockElement : null; |
| 247 | }; |
| 248 | |
| 249 | const getBlockParts = (blockElement: HTMLElement) => { |
| 250 | const editPre = blockElement.querySelector( |
no test coverage detected