MCPcopy Create free account
hub / github.com/cweijan/vscode-office / resolveCmCodeBlock

Function resolveCmCodeBlock

vditor/src/ts/codeBlock/codeMirrorManager.ts:230–247  ·  view source on GitHub ↗
(vditor: IVditor, blockElement?: HTMLElement | null)

Source from the content-addressed store, hash-verified

228};
229
230export 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
249const getBlockParts = (blockElement: HTMLElement) => {
250 const editPre = blockElement.querySelector(

Callers 4

bindDeleteButtonFunction · 0.90
getBlockFunction · 0.90

Calls 2

getModeEditorFunction · 0.70

Tested by

no test coverage detected