Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | 47x 47x 47x 376x 47x 47x 47x | import { HeadingKeys, optionType } from "./types";
const blocksTypes = {
h1: { id: "heading", key: "h1", label: "H1", style: "header-one" },
h2: { id: "heading", key: "h2", label: "H2", style: "header-two" },
h3: { id: "heading", key: "h3", label: "H3", style: "header-three" },
h4: { id: "heading", key: "h4", label: "H4", style: "header-four" },
h5: { id: "heading", key: "h5", label: "H5", style: "header-five" },
h6: { id: "heading", key: "h6", label: "H6", style: "header-six" },
p: { id: "heading", key: "p", label: "P", style: "unstyled" },
pSmall: {
id: "heading",
key: "pSmall",
label: "Paragraph Small",
style: "paragraph-small",
},
};
export const optionsMapHeadings: { [K in HeadingKeys]: string } = {
h1: "Heading 1",
h2: "Heading 2",
h3: "Heading 3",
h4: "Heading 4",
h5: "Heading 5",
h6: "Heading 6",
p: "Paragraph",
pSmall: "Paragraph Small",
};
const buildOption = (key: HeadingKeys): optionType =>
({
value: key,
label: optionsMapHeadings[key],
blockTypeValue: blocksTypes[key].style,
}) as optionType;
// Heading keys offered in every editor by default. "pSmall" is intentionally
// excluded — it is opt-in (legal documents only) via `optionsWithParagraphSmall`.
const DEFAULT_HEADING_KEYS: HeadingKeys[] = [
"h1",
"h2",
"h3",
"h4",
"h5",
"h6",
"p",
];
export const options: optionType[] = DEFAULT_HEADING_KEYS.map(buildOption);
// Default headings plus "Paragraph Small"; opt in by passing the
// "paragraph-small" option to HFRichInput.
export const optionsWithParagraphSmall: optionType[] = [
...options,
buildOption("pSmall"),
];
|