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

Function destroyCodeMirror

vditor/src/ts/codeBlock/codeMirrorManager.ts:416–435  ·  view source on GitHub ↗
(blockElement: HTMLElement)

Source from the content-addressed store, hash-verified

414};
415
416const destroyCodeMirror = (blockElement: HTMLElement) => {
417 cancelLazyTeardown(blockElement);
418 const binding = bindings.get(blockElement);
419 if (!binding) {
420 return;
421 }
422 window.clearTimeout(binding.syncTimer);
423 window.clearTimeout(binding.previewTimer);
424 binding.syncCode.textContent = binding.view.state.doc.toString();
425 binding.view.destroy();
426 bindings.delete(blockElement);
427 binding.editPre.querySelector(".cm-editor")?.remove();
428 const wasSpecialEdit = blockElement.classList.contains(CM_EDITING_CLASS);
429 if (wasSpecialEdit) {
430 removeCodeBlockChrome(blockElement);
431 blockElement.classList.remove(CM_BLOCK_CLASS, CM_EDITING_CLASS, CM_SPLIT_CLASS);
432 } else if (isLazyManagedCodeBlock(blockElement)) {
433 showPlainCodeBlockPlaceholder(blockElement);
434 }
435};
436
437const getMountedCodeBlocks = (vditor: IVditor) => {
438 const editor = getModeEditor(vditor);

Callers 6

scheduleLazyTeardownFunction · 0.85
enforceMaxMountedFunction · 0.85
scheduleLazyCodeBlockFunction · 0.85
destroyAllCodeMirrorsFunction · 0.85
deactivateAllCodeMirrorsFunction · 0.85

Calls 10

removeCodeBlockChromeFunction · 0.90
cancelLazyTeardownFunction · 0.85
isLazyManagedCodeBlockFunction · 0.85
getMethod · 0.65
toStringMethod · 0.45
destroyMethod · 0.45
deleteMethod · 0.45
removeMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected