PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.5
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.5
4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 All 203 releases
betterdocs / react-src / gutenberg / util / index.js

index.js in BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot 4.9.5, at react-src/gutenberg/util/index.js

46 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { createHigherOrderComponent } from "@wordpress/compose";
2 import { useEffect } from "@wordpress/element";
3 import WebFont from "webfontloader";
4 import { addFilter } from "@wordpress/hooks";
5
6 const withAdvancedControls = createHigherOrderComponent((BlockEdit) => {
7
8 return (props) => {
9 const { attributes } = props;
10
11 // typography
12 useEffect(() => {
13 let googleFontFamily = [];
14 for (var key in attributes) {
15 if (/^(\w+)FontFamily/.test(key)) {
16 if (attributes[key] !== "Default") {
17 googleFontFamily.push(
18 attributes[key] +
19 ":100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic"
20 );
21 }
22 }
23 }
24
25 if (googleFontFamily.length > 0) {
26 let webFontConfig = {
27 google: {
28 families: googleFontFamily,
29 },
30 context: frames["editor-canvas"],
31 };
32 WebFont.load(webFontConfig);
33 }
34 }, [attributes]);
35
36 return <BlockEdit {...props} />;
37
38 };
39 }, "withAdvancedControls");
40
41 /**
42 * Filter for modification of Edit Function
43 */
44 addFilter("editor.BlockEdit", "betterdocs/global", withAdvancedControls);
45
46