@elementor/editor-controls 4.0.0-509 → 4.0.0-511
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.
- package/dist/index.d.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/size/unstable-size-field.tsx +1 -0
- package/src/hooks/use-font-families.ts +52 -0
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -7134,6 +7134,44 @@ var UnstableSizeField = ({
|
|
|
7134
7134
|
var hasValue = (value) => {
|
|
7135
7135
|
return value !== null && value !== "";
|
|
7136
7136
|
};
|
|
7137
|
+
|
|
7138
|
+
// src/hooks/use-font-families.ts
|
|
7139
|
+
import { useMemo as useMemo16 } from "react";
|
|
7140
|
+
import { getElementorConfig } from "@elementor/editor-v1-adapters";
|
|
7141
|
+
import { __ as __53 } from "@wordpress/i18n";
|
|
7142
|
+
var supportedCategories = {
|
|
7143
|
+
system: __53("System", "elementor"),
|
|
7144
|
+
custom: __53("Custom Fonts", "elementor"),
|
|
7145
|
+
googlefonts: __53("Google Fonts", "elementor")
|
|
7146
|
+
};
|
|
7147
|
+
var getFontFamilies = () => {
|
|
7148
|
+
const { controls } = getElementorConfig();
|
|
7149
|
+
const options = controls?.font?.options;
|
|
7150
|
+
if (!options) {
|
|
7151
|
+
return null;
|
|
7152
|
+
}
|
|
7153
|
+
return options;
|
|
7154
|
+
};
|
|
7155
|
+
var useFontFamilies = () => {
|
|
7156
|
+
const fontFamilies = getFontFamilies();
|
|
7157
|
+
return useMemo16(() => {
|
|
7158
|
+
const categoriesOrder = ["system", "custom", "googlefonts"];
|
|
7159
|
+
return Object.entries(fontFamilies || {}).reduce((acc, [font, category]) => {
|
|
7160
|
+
if (!supportedCategories[category]) {
|
|
7161
|
+
return acc;
|
|
7162
|
+
}
|
|
7163
|
+
const categoryIndex = categoriesOrder.indexOf(category);
|
|
7164
|
+
if (!acc[categoryIndex]) {
|
|
7165
|
+
acc[categoryIndex] = {
|
|
7166
|
+
label: supportedCategories[category],
|
|
7167
|
+
fonts: []
|
|
7168
|
+
};
|
|
7169
|
+
}
|
|
7170
|
+
acc[categoryIndex].fonts.push(font);
|
|
7171
|
+
return acc;
|
|
7172
|
+
}, []).filter(Boolean);
|
|
7173
|
+
}, [fontFamilies]);
|
|
7174
|
+
};
|
|
7137
7175
|
export {
|
|
7138
7176
|
AspectRatioControl,
|
|
7139
7177
|
BackgroundControl,
|
|
@@ -7196,6 +7234,7 @@ export {
|
|
|
7196
7234
|
useControlActions,
|
|
7197
7235
|
useControlReplacement,
|
|
7198
7236
|
useElementCanHaveChildren,
|
|
7237
|
+
useFontFamilies,
|
|
7199
7238
|
useSyncExternalState
|
|
7200
7239
|
};
|
|
7201
7240
|
//# sourceMappingURL=index.mjs.map
|