MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / applyCodeBlockFoldState

Function applyCodeBlockFoldState

packages/app-core/src/lib/code-block-copy.ts:141–150  ·  view source on GitHub ↗
(block: HTMLElement, folded: boolean)

Source from the content-addressed store, hash-verified

139}
140
141function applyCodeBlockFoldState(block: HTMLElement, folded: boolean): void {
142 block.setAttribute(CODE_BLOCK_FOLDED_ATTR, folded ? 'true' : 'false')
143
144 const button = block.querySelector<HTMLButtonElement>(CODE_FOLD_BUTTON_SELECTOR)
145 if (!button) return
146 button.textContent = folded ? 'Expand' : 'Fold'
147 button.setAttribute('aria-expanded', String(!folded))
148 button.setAttribute('aria-label', folded ? 'Expand code block' : 'Collapse code block')
149 button.title = folded ? 'Expand code block' : 'Collapse code block'
150}
151
152function persistCodeBlockFoldState(block: HTMLElement, folded: boolean): void {
153 const storageKey = block.getAttribute(CODE_BLOCK_STORAGE_KEY_ATTR)

Callers 2

enhanceCodeBlockCopyFunction · 0.85
toggleCodeBlockFoldFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected