// SPDX-License-Identifier: AGPL-3.0-or-later import { Details, DetailsContent, DetailsSummary } from "@tiptap/extension-details"; import type { AnyExtension } from "@tiptap/core"; import type { EditorLabels } from "./labels"; /** * Toggle blocks: a summary line that hides or shows the blocks under it. * Whether a toggle is open is not saved, so one reader opening it does not * open it for everyone editing the page. */ export function docwellToggles(labels: EditorLabels): AnyExtension[] { return [ Details.configure({ persist: false, HTMLAttributes: { class: "dw-toggle" }, renderToggleButton: ({ element, isOpen }) => { element.setAttribute("aria-label", isOpen ? labels.blocks.collapse : labels.blocks.expand); element.setAttribute("aria-expanded", String(isOpen)); }, }), DetailsSummary, DetailsContent, ]; }