@webround/editor 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import postcss from 'postcss';
|
|
4
|
-
import { WR_THEME_START_PROPERTY } from '@webround/core/theme';
|
|
4
|
+
import { WR_THEME_START_PROPERTY, wrGoogleFamilyParam, wrGoogleWeightsOfParam } from '@webround/core/theme';
|
|
5
5
|
import { defineOperation, invalid, object, requiredText } from '../define.js';
|
|
6
6
|
// The site's theme: custom properties (`--wr-*`), Google fonts and custom fonts, all in `src/theme.css`. Read and written with postcss, so
|
|
7
7
|
// what the user wrote around them stays as it was.
|
|
@@ -75,15 +75,12 @@ function parseGoogleImport(rule) {
|
|
|
75
75
|
const entries = [];
|
|
76
76
|
for (const family of url.searchParams.getAll('family')) {
|
|
77
77
|
const [name, rest] = family.split(':');
|
|
78
|
-
|
|
79
|
-
entries.push({ family: name.replace(/\+/g, ' '), weights });
|
|
78
|
+
entries.push({ family: name.replace(/\+/g, ' '), weights: wrGoogleWeightsOfParam(rest) });
|
|
80
79
|
}
|
|
81
80
|
return entries;
|
|
82
81
|
}
|
|
83
82
|
function buildGoogleImportRule(entries) {
|
|
84
|
-
const params = entries
|
|
85
|
-
.map(({ family, weights }) => `family=${family.replace(/ /g, '+')}${weights ? `:wght@${weights}` : ''}`)
|
|
86
|
-
.join('&');
|
|
83
|
+
const params = entries.map(({ family, weights }) => wrGoogleFamilyParam(family, weights)).join('&');
|
|
87
84
|
return `url('https://fonts.googleapis.com/css2?${params}&display=swap')`;
|
|
88
85
|
}
|
|
89
86
|
function getThemeItems(root) {
|
|
@@ -11,6 +11,14 @@ function wrServerConfigPlugin(allowedHosts) {
|
|
|
11
11
|
config: () => ({ server: { allowedHosts } }),
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
+
// `.wr/` è dell'editor (i commenti, mai nel sito): nessuno dei suoi file è del sito, e il dev server non deve guardarli. Se li guarda,
|
|
15
|
+
// Tailwind li trova tra i file che scansiona e a ogni commento ricarica tutta la pagina (il flash bianco).
|
|
16
|
+
function wrWatchConfigPlugin() {
|
|
17
|
+
return {
|
|
18
|
+
name: 'wr-watch-config',
|
|
19
|
+
config: () => ({ server: { watch: { ignored: ['**/.wr/**'] } } }),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
14
22
|
/**
|
|
15
23
|
* Facade: tutti i plugin dell'editor, nell'ordine giusto. Il vite.config.ts di un progetto
|
|
16
24
|
* deve solo spargere `...wrPlugins()` accanto a react() e tailwindcss(); aggiungere un plugin
|
|
@@ -19,6 +27,7 @@ function wrServerConfigPlugin(allowedHosts) {
|
|
|
19
27
|
export function wrPlugins(options = {}) {
|
|
20
28
|
return [
|
|
21
29
|
...(options.allowedHosts ? [wrServerConfigPlugin(options.allowedHosts)] : []),
|
|
30
|
+
wrWatchConfigPlugin(),
|
|
22
31
|
// The one door into the project for the editor's page (see operations/)
|
|
23
32
|
wrOperationsPlugin(),
|
|
24
33
|
wrPagesPlugin(),
|