I'm currently working on integrating a custom Adobe Typekit font into a TinyMCE React component to customize the text styling within the editor. Here is the setup I have:
<Editor
init={{
allow_html_in_named_anchor: false,
branding: false,
plugins: [
"autolink lists link image preview anchor",
"searchreplace",
"insertdatetime media table paste code"
],
toolbar: "bold italic | bullist numlist",
content_css: ["https://use.typekit.net/XXXXXX.css", "/overrides.css"]
}}
/>
To maintain privacy, I have redacted the Typekit CSS filename, as it is specific to each user account.
The overrides.css
file is structured as follows:
@import url("https://use.typekit.net/XXXXX.css");
body {
font-family: "neue-haas-grotesk-text, Arial, sans-serif" !important;
font-size: 14px;
font-weight: 400;
}
Within the <head>
tag of the TinyMCE editor-generated <iframe>
, there are two CSS <link>
tags present in the correct sequence:
<link rel="stylesheet" type="text/css" id="mce-u0" crossorigin="anonymous" referrerpolicy="origin" href="https://cdn.tiny.cloud/1/k9s4r4mdxeukqc7mrign93b26zofvznzyw98lj16y5rlb73z/tinymce/5.10.3-128/skins/ui/oxide/content.min.css">
<link rel="stylesheet" type="text/css" id="mce-u1" crossorigin="anonymous" referrerpolicy="origin" href="https://use.typekit.net/XXXXXX.css">
<link rel="stylesheet" type="text/css" id="mce-u0" crossorigin="anonymous" referrerpolicy="origin" href="https://cdn.tiny.cloud/1/k9s4r4mdxeukqc7mrign93b26zofvznzyw98lj16y5rlb73z/tinymce/5.10.3-128/skins/ui/oxide/content.min.css">
I have attempted to import the CSS file twice, once in the overrides.css
and once in the content_css
property. However, I am facing issues as the editor displays a bizarre serif font, not even the specified Arial or default 'sans-serif'.
Although the CSS stylesheets load correctly and the Adobe font is functioning on the page where the editor is placed, it does not reflect within the editor preview itself.