@elementor/editor-controls 4.0.0-669 → 4.0.0-670
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.js +16 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/hooks/use-font-families.ts +22 -25
package/dist/index.js
CHANGED
|
@@ -7470,39 +7470,33 @@ var hasValue = (value) => {
|
|
|
7470
7470
|
// src/hooks/use-font-families.ts
|
|
7471
7471
|
var import_react63 = require("react");
|
|
7472
7472
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
7473
|
-
var
|
|
7474
|
-
var supportedCategories = {
|
|
7475
|
-
system: (0, import_i18n57.__)("System", "elementor"),
|
|
7476
|
-
custom: (0, import_i18n57.__)("Custom Fonts", "elementor"),
|
|
7477
|
-
googlefonts: (0, import_i18n57.__)("Google Fonts", "elementor")
|
|
7478
|
-
};
|
|
7479
|
-
var getFontFamilies = () => {
|
|
7473
|
+
var getFontControlConfig = () => {
|
|
7480
7474
|
const { controls } = (0, import_editor_v1_adapters.getElementorConfig)();
|
|
7481
|
-
|
|
7482
|
-
if (!options) {
|
|
7483
|
-
return null;
|
|
7484
|
-
}
|
|
7485
|
-
return options;
|
|
7475
|
+
return controls?.font ?? {};
|
|
7486
7476
|
};
|
|
7487
7477
|
var useFontFamilies = () => {
|
|
7488
|
-
const
|
|
7478
|
+
const { groups, options } = getFontControlConfig();
|
|
7489
7479
|
return (0, import_react63.useMemo)(() => {
|
|
7490
|
-
|
|
7491
|
-
|
|
7492
|
-
|
|
7480
|
+
if (!groups || !options) {
|
|
7481
|
+
return [];
|
|
7482
|
+
}
|
|
7483
|
+
const groupKeys = Object.keys(groups);
|
|
7484
|
+
const groupIndexMap = new Map(groupKeys.map((key, index) => [key, index]));
|
|
7485
|
+
return Object.entries(options).reduce((acc, [font, category]) => {
|
|
7486
|
+
const groupIndex = groupIndexMap.get(category);
|
|
7487
|
+
if (groupIndex === void 0) {
|
|
7493
7488
|
return acc;
|
|
7494
7489
|
}
|
|
7495
|
-
|
|
7496
|
-
|
|
7497
|
-
|
|
7498
|
-
label: supportedCategories[category],
|
|
7490
|
+
if (!acc[groupIndex]) {
|
|
7491
|
+
acc[groupIndex] = {
|
|
7492
|
+
label: groups[category],
|
|
7499
7493
|
fonts: []
|
|
7500
7494
|
};
|
|
7501
7495
|
}
|
|
7502
|
-
acc[
|
|
7496
|
+
acc[groupIndex].fonts.push(font);
|
|
7503
7497
|
return acc;
|
|
7504
7498
|
}, []).filter(Boolean);
|
|
7505
|
-
}, [
|
|
7499
|
+
}, [groups, options]);
|
|
7506
7500
|
};
|
|
7507
7501
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7508
7502
|
0 && (module.exports = {
|