Skip to content

Instantly share code, notes, and snippets.

@VPKSoft
Created November 26, 2023 11:26
Show Gist options
  • Select an option

  • Save VPKSoft/4ae677a82235fe534ccf88f9c67f05f0 to your computer and use it in GitHub Desktop.

Select an option

Save VPKSoft/4ae677a82235fe534ccf88f9c67f05f0 to your computer and use it in GitHub Desktop.
Font family div for Quill with styled components.
import * as React from "react";
import { styled } from "styled-components";
const QuillFontCssDiv = styled.div<{ $fontFamilies: string[] }>`
${props =>
props.$fontFamilies
.map(f => {
const nameHyphenated = f.replaceAll(" ", "-").toLowerCase();
const name = f;
return `
.ql-font-${nameHyphenated},
.ql-font span[data-value="${nameHyphenated}"]::before {
font-family: ${name};
}`;
})
.join("")}
`;
// Register the font families with:
// const Font = Quill.import("formats/font");
// Font.whitelist = fontFamilies.map(f => f.replaceAll(" ", "-").toLowerCase());
// Quill.register(Font, true);
export { QuillFontCssDiv };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment