优化窗格显示
This commit is contained in:
@@ -226,6 +226,51 @@ export function buildItemPaneSectionButtons(kind: ItemPaneKind) {
|
||||
];
|
||||
}
|
||||
|
||||
export function isItemPaneSectionBody(body: HTMLElement): boolean {
|
||||
return Boolean(body.closest("collapsible-section"));
|
||||
}
|
||||
|
||||
export type SectionSummaryUpdater = (summary: string) => void;
|
||||
|
||||
export function clearSectionSummary(
|
||||
body: HTMLElement,
|
||||
updater?: SectionSummaryUpdater,
|
||||
): void {
|
||||
updater?.("");
|
||||
const section = body.closest("collapsible-section");
|
||||
if (section) section.setAttribute("summary", "");
|
||||
}
|
||||
|
||||
const SECTION_HEAD_MESSAGE: Record<ItemPaneKind, FluentMessageId> = {
|
||||
chat: "item-section-chat-head",
|
||||
lecture: "item-section-lecture-head",
|
||||
};
|
||||
|
||||
/** Ensure native section head shows plugin name (not just the icon). */
|
||||
export function applyItemPaneSectionHeadLabel(
|
||||
body: HTMLElement,
|
||||
kind: ItemPaneKind,
|
||||
): void {
|
||||
const section = body.closest("collapsible-section") as HTMLElement | null;
|
||||
if (!section) return;
|
||||
|
||||
const messageId = SECTION_HEAD_MESSAGE[kind];
|
||||
const l10nId = getLocaleID(messageId);
|
||||
section.dataset.l10nId = l10nId;
|
||||
|
||||
const label = getString(messageId, "label");
|
||||
if (label && label !== l10nId) {
|
||||
section.setAttribute("label", label);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
body.ownerDocument?.l10n?.setAttributes?.(section, l10nId);
|
||||
} catch {
|
||||
// Fluent may not be ready yet; label stays empty until next render hook.
|
||||
}
|
||||
}
|
||||
|
||||
function resolveCollapsibleSection(
|
||||
body: HTMLElement,
|
||||
event?: Event,
|
||||
|
||||
Reference in New Issue
Block a user