ultisuite-client/lib/drive/docs-list-styles.ts
R3D347HR4Y 303b2b1074
Some checks are pending
E2E / Playwright e2e (push) Waiting to run
wow
2026-06-11 01:22:40 +02:00

49 lines
2.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export const DOCS_BULLET_STYLE_PRESETS = [
{ id: "disc", label: "Plein", listStyleType: "disc", marker: null },
{ id: "circle", label: "Cercle", listStyleType: "circle", marker: null },
{ id: "square", label: "Carré", listStyleType: "square", marker: null },
{ id: "arrow", label: "Flèche", listStyleType: "none", marker: "➤" },
{ id: "check", label: "Coche", listStyleType: "none", marker: "✓" },
{ id: "dash", label: "Tiret", listStyleType: "none", marker: "" },
] as const
export type DocsBulletStyleId = (typeof DOCS_BULLET_STYLE_PRESETS)[number]["id"]
export const DOCS_ORDERED_STYLE_PRESETS = [
{ id: "decimal", label: "1. 2. 3.", olType: null as string | null },
{ id: "decimal-paren", label: "1) 2) 3)", olType: null },
{ id: "outline", label: "1. / 1.1.", olType: null },
{ id: "upper-alpha", label: "A. B. C.", olType: "A" },
{ id: "upper-roman", label: "I. II. III.", olType: "I" },
{ id: "zero-padded", label: "01. 02.", olType: null },
] as const
export type DocsOrderedStyleId = (typeof DOCS_ORDERED_STYLE_PRESETS)[number]["id"]
export type DocsChecklistStyleId = "simple" | "strikethrough"
export const DOCS_DEFAULT_BULLET_STYLE: DocsBulletStyleId = "disc"
export const DOCS_DEFAULT_ORDERED_STYLE: DocsOrderedStyleId = "decimal"
export function normalizeBulletStyleId(raw: unknown): DocsBulletStyleId {
const id = String(raw ?? DOCS_DEFAULT_BULLET_STYLE)
return DOCS_BULLET_STYLE_PRESETS.some((preset) => preset.id === id)
? (id as DocsBulletStyleId)
: DOCS_DEFAULT_BULLET_STYLE
}
export function normalizeOrderedStyleId(raw: unknown): DocsOrderedStyleId {
const id = String(raw ?? DOCS_DEFAULT_ORDERED_STYLE)
return DOCS_ORDERED_STYLE_PRESETS.some((preset) => preset.id === id)
? (id as DocsOrderedStyleId)
: DOCS_DEFAULT_ORDERED_STYLE
}
export function orderedPresetById(id: DocsOrderedStyleId) {
return DOCS_ORDERED_STYLE_PRESETS.find((preset) => preset.id === id)!
}
export function bulletPresetById(id: DocsBulletStyleId) {
return DOCS_BULLET_STYLE_PRESETS.find((preset) => preset.id === id)!
}