mirror of
https://github.com/go-gitea/gitea.git
synced 2026-05-20 19:11:09 +09:00
Fix markup code block layout (#36578)
This commit is contained in:
@@ -301,7 +301,7 @@ export function createElementFromHTML<T extends HTMLElement>(htmlString: string)
|
||||
return div.firstChild as T;
|
||||
}
|
||||
|
||||
export function createElementFromAttrs(tagName: string, attrs: Record<string, any> | null, ...children: (Node | string)[]): HTMLElement {
|
||||
export function createElementFromAttrs<T extends HTMLElement>(tagName: string, attrs: Record<string, any> | null, ...children: (Node | string)[]): T {
|
||||
const el = document.createElement(tagName);
|
||||
for (const [key, value] of Object.entries(attrs || {})) {
|
||||
if (value === undefined || value === null) continue;
|
||||
@@ -314,7 +314,7 @@ export function createElementFromAttrs(tagName: string, attrs: Record<string, an
|
||||
for (const child of children) {
|
||||
el.append(child instanceof Node ? child : document.createTextNode(child));
|
||||
}
|
||||
return el;
|
||||
return el as T;
|
||||
}
|
||||
|
||||
export function animateOnce(el: Element, animationClassName: string): Promise<void> {
|
||||
@@ -352,22 +352,6 @@ export function isPlainClick(e: MouseEvent) {
|
||||
return e.button === 0 && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey;
|
||||
}
|
||||
|
||||
let cssRootVariablesTextCache: string = '';
|
||||
export function getCssRootVariablesText(): string {
|
||||
if (cssRootVariablesTextCache) return cssRootVariablesTextCache;
|
||||
const style = getComputedStyle(document.documentElement);
|
||||
let text = ':root {\n';
|
||||
for (let i = 0; i < style.length; i++) {
|
||||
const name = style.item(i);
|
||||
if (name.startsWith('--')) {
|
||||
text += ` ${name}: ${style.getPropertyValue(name)};\n`;
|
||||
}
|
||||
}
|
||||
text += '}\n';
|
||||
cssRootVariablesTextCache = text;
|
||||
return text;
|
||||
}
|
||||
|
||||
let elemIdCounter = 0;
|
||||
export function generateElemId(prefix: string = ''): string {
|
||||
return `${prefix}${elemIdCounter++}`;
|
||||
|
||||
Reference in New Issue
Block a user