Skip to content

Commit 7a26d59

Browse files
committed
fix api and font servers are not the same fix #15
1 parent 9824c63 commit 7a26d59

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,13 @@ Also you should style the dialog:
130130

131131
## Options
132132

133+
The options `api_url` and `server_url` are used to support Google fonts proxies, e.g fontlay and a privacy-friendly drop-in replacement for Google Fonts, e.g coollabsio's fonts server. Their default values are the Google fonts API and server.
134+
133135
| Option | Description | Default |
134136
|-|-|-
135137
| `api_key` | Google fonts API key, [see this doc to get an API key](https://developers.google.com/fonts/docs/developer_api#APIKey) | Required |
136-
| `server_url` | Google fonts server or a free [privacy-friendly drop-in replacement for Google Fonts](https://github.com/coollabsio/fonts) or [a proxy server to speed up the load and protect privacy](https://fontlay.com/) | `https://fonts.googleapis.com` |
138+
| `api_url` | Fonts API | `https://www.googleapis.com` |
139+
| `server_url` | Fonts server | `https://fonts.googleapis.com` |
137140

138141
## Download
139142

src/fonts.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ let defaults = []
2525
* Options
2626
*/
2727
let fontServer = 'https://fonts.googleapis.com'
28+
let fontApi = 'https://www.googleapis.com'
2829

2930
/**
3031
* Load available fonts only once per session
@@ -82,6 +83,7 @@ async function loadFontList(url) {
8283
export const fontsDialogPlugin = (editor, opts) => {
8384
defaults = editor.StyleManager.getBuiltIn('font-family').options
8485
if(opts.server_url) fontServer = opts.server_url
86+
if(opts.api_url) fontApi = opts.api_url
8587
if(!opts.api_key) throw new Error(editor.I18n.t('grapesjs-fonts.You must provide Google font api key'))
8688
editor.Commands.add(cmdOpenFonts, {
8789
/* eslint-disable-next-line */
@@ -97,7 +99,7 @@ export const fontsDialogPlugin = (editor, opts) => {
9799
modal.setContent(el)
98100
loadFonts(editor)
99101
displayFonts(editor, opts, [])
100-
loadFontList(`${ fontServer }/webfonts/v1/webfonts?key=${ opts.api_key }`)
102+
loadFontList(`${ fontApi }/webfonts/v1/webfonts?key=${ opts.api_key }`)
101103
.then(fontsList => { // the run command will terminate before this is done, better for performance
102104
displayFonts(editor, opts, fontsList)
103105
const form = el.querySelector('form')

0 commit comments

Comments
 (0)