Fix action buttons position - insert after <pre> not inside it (#36)
Problem:
- Buttons were being inserted as children of <pre> element
- This caused buttons to appear inside code blocks with wrong styling
- Template caching made changes appear to require "two commits"
Solution:
- Change insertion point from block.parentNode to preElement.parentNode
- This places buttons as siblings of <pre>, not children
- Add TEMPLATES_AUTO_RELOAD=True to prevent Flask template caching
Technical Details:
- block is the <code> element
- block.parentNode is the <pre> element
- preElement.parentNode.insertBefore puts buttons after <pre>
- Previous code put buttons inside <pre> after <code>
DOM Structure Before:
<pre>
<code>...</code>
<buttons> <!-- Wrong: inside pre -->
</pre>
DOM Structure After:
<pre>
<code>...</code>
</pre>
<buttons> <!-- Correct: after pre -->
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
76b8058e92
commit
ccedf063a0
2 changed files with 7 additions and 2 deletions
|
|
@ -1368,8 +1368,11 @@ function addCopyButtonToCodeBlock(block, wasTruncated = false) {
|
|||
buttonContainer.appendChild(copyButton);
|
||||
buttonContainer.appendChild(playButton);
|
||||
|
||||
// Insert the button container after the code block
|
||||
block.parentNode.insertBefore(buttonContainer, block.nextSibling);
|
||||
// Insert the button container after the <pre> element (not inside it)
|
||||
// block is <code>, block.parentNode is <pre>
|
||||
// We want to insert after <pre>, so we use <pre>.parentNode and <pre>.nextSibling
|
||||
const preElement = block.parentNode;
|
||||
preElement.parentNode.insertBefore(buttonContainer, preElement.nextSibling);
|
||||
}
|
||||
|
||||
// Function to execute code block content
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue