Created
November 26, 2023 11:26
-
-
Save VPKSoft/4ae677a82235fe534ccf88f9c67f05f0 to your computer and use it in GitHub Desktop.
Font family div for Quill with styled components.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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