@elementor/editor-site-settings 4.3.0-1031

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.
@@ -0,0 +1,18 @@
1
+ import { ComponentType } from 'react';
2
+
3
+ declare function init(): void;
4
+
5
+ type Config = {
6
+ id: string;
7
+ component: ComponentType;
8
+ priority?: number;
9
+ };
10
+ declare function injectSiteSettingsTab({ id, component, priority }: Config): void;
11
+
12
+ declare function registerSiteSettingsTab({ id, priority, component, }: {
13
+ id: string;
14
+ priority?: number;
15
+ component: ComponentType;
16
+ }): void;
17
+
18
+ export { init, injectSiteSettingsTab, registerSiteSettingsTab };
@@ -0,0 +1,18 @@
1
+ import { ComponentType } from 'react';
2
+
3
+ declare function init(): void;
4
+
5
+ type Config = {
6
+ id: string;
7
+ component: ComponentType;
8
+ priority?: number;
9
+ };
10
+ declare function injectSiteSettingsTab({ id, component, priority }: Config): void;
11
+
12
+ declare function registerSiteSettingsTab({ id, priority, component, }: {
13
+ id: string;
14
+ priority?: number;
15
+ component: ComponentType;
16
+ }): void;
17
+
18
+ export { init, injectSiteSettingsTab, registerSiteSettingsTab };
package/dist/index.js ADDED
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ init: () => init,
34
+ injectSiteSettingsTab: () => injectSiteSettingsTab,
35
+ registerSiteSettingsTab: () => registerSiteSettingsTab
36
+ });
37
+ module.exports = __toCommonJS(index_exports);
38
+
39
+ // src/init.ts
40
+ var import_editor = require("@elementor/editor");
41
+
42
+ // src/components/site-settings-tab.tsx
43
+ var React = __toESM(require("react"));
44
+ var import_ui = require("@elementor/ui");
45
+
46
+ // src/consts.ts
47
+ var SITE_SETTINGS_ROUTE_PREFIX = "panel/global/";
48
+ var SITE_SETTINGS_PANEL_CONTENT_ID = "elementor-kit-panel-content-controls";
49
+
50
+ // src/hooks/use-active-site-settings-tab.ts
51
+ var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
52
+
53
+ // src/tabs.ts
54
+ var registry = /* @__PURE__ */ new Map();
55
+ var DEFAULT_PRIORITY = 10;
56
+ function registerSiteSettingsTab({
57
+ id,
58
+ priority = DEFAULT_PRIORITY,
59
+ component
60
+ }) {
61
+ const existing = registry.get(id);
62
+ if (!existing || priority <= existing.priority) {
63
+ registry.set(id, { component, priority });
64
+ }
65
+ }
66
+ function getSiteSettingsTab(id) {
67
+ return registry.get(id) ?? null;
68
+ }
69
+
70
+ // src/hooks/use-active-site-settings-tab.ts
71
+ function useActiveSiteSettingsTab() {
72
+ return (0, import_editor_v1_adapters.__privateUseListenTo)(
73
+ [(0, import_editor_v1_adapters.v1ReadyEvent)(), (0, import_editor_v1_adapters.routeOpenEvent)(SITE_SETTINGS_ROUTE_PREFIX), (0, import_editor_v1_adapters.routeCloseEvent)(SITE_SETTINGS_ROUTE_PREFIX)],
74
+ () => {
75
+ const panelRoute = window.$e?.routes?.getCurrent?.()?.panel;
76
+ if (!panelRoute || !panelRoute.startsWith(SITE_SETTINGS_ROUTE_PREFIX)) {
77
+ return null;
78
+ }
79
+ const tabId = panelRoute.replace(SITE_SETTINGS_ROUTE_PREFIX, "");
80
+ return getSiteSettingsTab(tabId) ?? null;
81
+ }
82
+ );
83
+ }
84
+
85
+ // src/components/site-settings-tab.tsx
86
+ function SiteSettingsTab() {
87
+ const tab = useActiveSiteSettingsTab();
88
+ const TabComponent = tab?.component;
89
+ const container = document.getElementById(SITE_SETTINGS_PANEL_CONTENT_ID);
90
+ return TabComponent && container ? /* @__PURE__ */ React.createElement(import_ui.Portal, { container }, /* @__PURE__ */ React.createElement(TabComponent, null)) : null;
91
+ }
92
+
93
+ // src/init.ts
94
+ function init() {
95
+ (0, import_editor.injectIntoTop)({
96
+ id: "editor-site-settings-tab",
97
+ component: SiteSettingsTab
98
+ });
99
+ }
100
+
101
+ // src/inject-site-settings-tab.ts
102
+ function injectSiteSettingsTab({ id, component, priority }) {
103
+ registerSiteSettingsTab({ id, component, priority });
104
+ }
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ init,
108
+ injectSiteSettingsTab,
109
+ registerSiteSettingsTab
110
+ });
111
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/init.ts","../src/components/site-settings-tab.tsx","../src/consts.ts","../src/hooks/use-active-site-settings-tab.ts","../src/tabs.ts","../src/inject-site-settings-tab.ts"],"sourcesContent":["export { init } from './init';\nexport { injectSiteSettingsTab } from './inject-site-settings-tab';\nexport { registerSiteSettingsTab } from './tabs';\n","import { injectIntoTop } from '@elementor/editor';\n\nimport { SiteSettingsTab } from './components/site-settings-tab';\n\nexport function init() {\n\tinjectIntoTop( {\n\t\tid: 'editor-site-settings-tab',\n\t\tcomponent: SiteSettingsTab,\n\t} );\n}\n","import * as React from 'react';\nimport { Portal } from '@elementor/ui';\n\nimport { SITE_SETTINGS_PANEL_CONTENT_ID } from '../consts';\nimport { useActiveSiteSettingsTab } from '../hooks/use-active-site-settings-tab';\n\nexport function SiteSettingsTab() {\n\tconst tab = useActiveSiteSettingsTab();\n\tconst TabComponent = tab?.component;\n\tconst container = document.getElementById( SITE_SETTINGS_PANEL_CONTENT_ID );\n\n\treturn TabComponent && container ? (\n\t\t<Portal container={ container }>\n\t\t\t<TabComponent />\n\t\t</Portal>\n\t) : null;\n}\n","export const SITE_SETTINGS_ROUTE_PREFIX = 'panel/global/';\n\nexport const SITE_SETTINGS_PANEL_CONTENT_ID = 'elementor-kit-panel-content-controls';\n","import {\n\t__privateUseListenTo as useListenTo,\n\trouteCloseEvent,\n\trouteOpenEvent,\n\tv1ReadyEvent,\n} from '@elementor/editor-v1-adapters';\n\nimport { SITE_SETTINGS_ROUTE_PREFIX } from '../consts';\nimport { getSiteSettingsTab } from '../tabs';\n\nexport function useActiveSiteSettingsTab() {\n\treturn useListenTo(\n\t\t[ v1ReadyEvent(), routeOpenEvent( SITE_SETTINGS_ROUTE_PREFIX ), routeCloseEvent( SITE_SETTINGS_ROUTE_PREFIX ) ],\n\t\t() => {\n\t\t\tconst panelRoute = window.$e?.routes?.getCurrent?.()?.panel;\n\n\t\t\tif ( ! panelRoute || ! panelRoute.startsWith( SITE_SETTINGS_ROUTE_PREFIX ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst tabId = panelRoute.replace( SITE_SETTINGS_ROUTE_PREFIX, '' );\n\n\t\t\treturn getSiteSettingsTab( tabId ) ?? null;\n\t\t}\n\t);\n}\n","import { type ComponentType } from 'react';\n\ntype Tab = {\n\tcomponent: ComponentType;\n\tpriority: number;\n};\n\nconst registry = new Map< string, Tab >();\n\nconst DEFAULT_PRIORITY = 10;\n\nexport function registerSiteSettingsTab( {\n\tid,\n\tpriority = DEFAULT_PRIORITY,\n\tcomponent,\n}: {\n\tid: string;\n\tpriority?: number;\n\tcomponent: ComponentType;\n} ) {\n\tconst existing = registry.get( id );\n\n\tif ( ! existing || priority <= existing.priority ) {\n\t\tregistry.set( id, { component, priority } );\n\t}\n}\n\nexport function getSiteSettingsTab( id: string ): Tab | null {\n\treturn registry.get( id ) ?? null;\n}\n","import { type ComponentType } from 'react';\n\nimport { registerSiteSettingsTab } from './tabs';\n\ntype Config = {\n\tid: string;\n\tcomponent: ComponentType;\n\tpriority?: number;\n};\n\nexport function injectSiteSettingsTab( { id, component, priority }: Config ) {\n\tregisterSiteSettingsTab( { id, component, priority } );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,oBAA8B;;;ACA9B,YAAuB;AACvB,gBAAuB;;;ACDhB,IAAM,6BAA6B;AAEnC,IAAM,iCAAiC;;;ACF9C,gCAKO;;;ACEP,IAAM,WAAW,oBAAI,IAAmB;AAExC,IAAM,mBAAmB;AAElB,SAAS,wBAAyB;AAAA,EACxC;AAAA,EACA,WAAW;AAAA,EACX;AACD,GAII;AACH,QAAM,WAAW,SAAS,IAAK,EAAG;AAElC,MAAK,CAAE,YAAY,YAAY,SAAS,UAAW;AAClD,aAAS,IAAK,IAAI,EAAE,WAAW,SAAS,CAAE;AAAA,EAC3C;AACD;AAEO,SAAS,mBAAoB,IAAyB;AAC5D,SAAO,SAAS,IAAK,EAAG,KAAK;AAC9B;;;ADnBO,SAAS,2BAA2B;AAC1C,aAAO,0BAAAA;AAAA,IACN,KAAE,wCAAa,OAAG,0CAAgB,0BAA2B,OAAG,2CAAiB,0BAA2B,CAAE;AAAA,IAC9G,MAAM;AACL,YAAM,aAAa,OAAO,IAAI,QAAQ,aAAa,GAAG;AAEtD,UAAK,CAAE,cAAc,CAAE,WAAW,WAAY,0BAA2B,GAAI;AAC5E,eAAO;AAAA,MACR;AAEA,YAAM,QAAQ,WAAW,QAAS,4BAA4B,EAAG;AAEjE,aAAO,mBAAoB,KAAM,KAAK;AAAA,IACvC;AAAA,EACD;AACD;;;AFnBO,SAAS,kBAAkB;AACjC,QAAM,MAAM,yBAAyB;AACrC,QAAM,eAAe,KAAK;AAC1B,QAAM,YAAY,SAAS,eAAgB,8BAA+B;AAE1E,SAAO,gBAAgB,YACtB,oCAAC,oBAAO,aACP,oCAAC,kBAAa,CACf,IACG;AACL;;;ADZO,SAAS,OAAO;AACtB,mCAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;;;AKCO,SAAS,sBAAuB,EAAE,IAAI,WAAW,SAAS,GAAY;AAC5E,0BAAyB,EAAE,IAAI,WAAW,SAAS,CAAE;AACtD;","names":["useListenTo"]}
package/dist/index.mjs ADDED
@@ -0,0 +1,77 @@
1
+ // src/init.ts
2
+ import { injectIntoTop } from "@elementor/editor";
3
+
4
+ // src/components/site-settings-tab.tsx
5
+ import * as React from "react";
6
+ import { Portal } from "@elementor/ui";
7
+
8
+ // src/consts.ts
9
+ var SITE_SETTINGS_ROUTE_PREFIX = "panel/global/";
10
+ var SITE_SETTINGS_PANEL_CONTENT_ID = "elementor-kit-panel-content-controls";
11
+
12
+ // src/hooks/use-active-site-settings-tab.ts
13
+ import {
14
+ __privateUseListenTo as useListenTo,
15
+ routeCloseEvent,
16
+ routeOpenEvent,
17
+ v1ReadyEvent
18
+ } from "@elementor/editor-v1-adapters";
19
+
20
+ // src/tabs.ts
21
+ var registry = /* @__PURE__ */ new Map();
22
+ var DEFAULT_PRIORITY = 10;
23
+ function registerSiteSettingsTab({
24
+ id,
25
+ priority = DEFAULT_PRIORITY,
26
+ component
27
+ }) {
28
+ const existing = registry.get(id);
29
+ if (!existing || priority <= existing.priority) {
30
+ registry.set(id, { component, priority });
31
+ }
32
+ }
33
+ function getSiteSettingsTab(id) {
34
+ return registry.get(id) ?? null;
35
+ }
36
+
37
+ // src/hooks/use-active-site-settings-tab.ts
38
+ function useActiveSiteSettingsTab() {
39
+ return useListenTo(
40
+ [v1ReadyEvent(), routeOpenEvent(SITE_SETTINGS_ROUTE_PREFIX), routeCloseEvent(SITE_SETTINGS_ROUTE_PREFIX)],
41
+ () => {
42
+ const panelRoute = window.$e?.routes?.getCurrent?.()?.panel;
43
+ if (!panelRoute || !panelRoute.startsWith(SITE_SETTINGS_ROUTE_PREFIX)) {
44
+ return null;
45
+ }
46
+ const tabId = panelRoute.replace(SITE_SETTINGS_ROUTE_PREFIX, "");
47
+ return getSiteSettingsTab(tabId) ?? null;
48
+ }
49
+ );
50
+ }
51
+
52
+ // src/components/site-settings-tab.tsx
53
+ function SiteSettingsTab() {
54
+ const tab = useActiveSiteSettingsTab();
55
+ const TabComponent = tab?.component;
56
+ const container = document.getElementById(SITE_SETTINGS_PANEL_CONTENT_ID);
57
+ return TabComponent && container ? /* @__PURE__ */ React.createElement(Portal, { container }, /* @__PURE__ */ React.createElement(TabComponent, null)) : null;
58
+ }
59
+
60
+ // src/init.ts
61
+ function init() {
62
+ injectIntoTop({
63
+ id: "editor-site-settings-tab",
64
+ component: SiteSettingsTab
65
+ });
66
+ }
67
+
68
+ // src/inject-site-settings-tab.ts
69
+ function injectSiteSettingsTab({ id, component, priority }) {
70
+ registerSiteSettingsTab({ id, component, priority });
71
+ }
72
+ export {
73
+ init,
74
+ injectSiteSettingsTab,
75
+ registerSiteSettingsTab
76
+ };
77
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/init.ts","../src/components/site-settings-tab.tsx","../src/consts.ts","../src/hooks/use-active-site-settings-tab.ts","../src/tabs.ts","../src/inject-site-settings-tab.ts"],"sourcesContent":["import { injectIntoTop } from '@elementor/editor';\n\nimport { SiteSettingsTab } from './components/site-settings-tab';\n\nexport function init() {\n\tinjectIntoTop( {\n\t\tid: 'editor-site-settings-tab',\n\t\tcomponent: SiteSettingsTab,\n\t} );\n}\n","import * as React from 'react';\nimport { Portal } from '@elementor/ui';\n\nimport { SITE_SETTINGS_PANEL_CONTENT_ID } from '../consts';\nimport { useActiveSiteSettingsTab } from '../hooks/use-active-site-settings-tab';\n\nexport function SiteSettingsTab() {\n\tconst tab = useActiveSiteSettingsTab();\n\tconst TabComponent = tab?.component;\n\tconst container = document.getElementById( SITE_SETTINGS_PANEL_CONTENT_ID );\n\n\treturn TabComponent && container ? (\n\t\t<Portal container={ container }>\n\t\t\t<TabComponent />\n\t\t</Portal>\n\t) : null;\n}\n","export const SITE_SETTINGS_ROUTE_PREFIX = 'panel/global/';\n\nexport const SITE_SETTINGS_PANEL_CONTENT_ID = 'elementor-kit-panel-content-controls';\n","import {\n\t__privateUseListenTo as useListenTo,\n\trouteCloseEvent,\n\trouteOpenEvent,\n\tv1ReadyEvent,\n} from '@elementor/editor-v1-adapters';\n\nimport { SITE_SETTINGS_ROUTE_PREFIX } from '../consts';\nimport { getSiteSettingsTab } from '../tabs';\n\nexport function useActiveSiteSettingsTab() {\n\treturn useListenTo(\n\t\t[ v1ReadyEvent(), routeOpenEvent( SITE_SETTINGS_ROUTE_PREFIX ), routeCloseEvent( SITE_SETTINGS_ROUTE_PREFIX ) ],\n\t\t() => {\n\t\t\tconst panelRoute = window.$e?.routes?.getCurrent?.()?.panel;\n\n\t\t\tif ( ! panelRoute || ! panelRoute.startsWith( SITE_SETTINGS_ROUTE_PREFIX ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst tabId = panelRoute.replace( SITE_SETTINGS_ROUTE_PREFIX, '' );\n\n\t\t\treturn getSiteSettingsTab( tabId ) ?? null;\n\t\t}\n\t);\n}\n","import { type ComponentType } from 'react';\n\ntype Tab = {\n\tcomponent: ComponentType;\n\tpriority: number;\n};\n\nconst registry = new Map< string, Tab >();\n\nconst DEFAULT_PRIORITY = 10;\n\nexport function registerSiteSettingsTab( {\n\tid,\n\tpriority = DEFAULT_PRIORITY,\n\tcomponent,\n}: {\n\tid: string;\n\tpriority?: number;\n\tcomponent: ComponentType;\n} ) {\n\tconst existing = registry.get( id );\n\n\tif ( ! existing || priority <= existing.priority ) {\n\t\tregistry.set( id, { component, priority } );\n\t}\n}\n\nexport function getSiteSettingsTab( id: string ): Tab | null {\n\treturn registry.get( id ) ?? null;\n}\n","import { type ComponentType } from 'react';\n\nimport { registerSiteSettingsTab } from './tabs';\n\ntype Config = {\n\tid: string;\n\tcomponent: ComponentType;\n\tpriority?: number;\n};\n\nexport function injectSiteSettingsTab( { id, component, priority }: Config ) {\n\tregisterSiteSettingsTab( { id, component, priority } );\n}\n"],"mappings":";AAAA,SAAS,qBAAqB;;;ACA9B,YAAY,WAAW;AACvB,SAAS,cAAc;;;ACDhB,IAAM,6BAA6B;AAEnC,IAAM,iCAAiC;;;ACF9C;AAAA,EACC,wBAAwB;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,OACM;;;ACEP,IAAM,WAAW,oBAAI,IAAmB;AAExC,IAAM,mBAAmB;AAElB,SAAS,wBAAyB;AAAA,EACxC;AAAA,EACA,WAAW;AAAA,EACX;AACD,GAII;AACH,QAAM,WAAW,SAAS,IAAK,EAAG;AAElC,MAAK,CAAE,YAAY,YAAY,SAAS,UAAW;AAClD,aAAS,IAAK,IAAI,EAAE,WAAW,SAAS,CAAE;AAAA,EAC3C;AACD;AAEO,SAAS,mBAAoB,IAAyB;AAC5D,SAAO,SAAS,IAAK,EAAG,KAAK;AAC9B;;;ADnBO,SAAS,2BAA2B;AAC1C,SAAO;AAAA,IACN,CAAE,aAAa,GAAG,eAAgB,0BAA2B,GAAG,gBAAiB,0BAA2B,CAAE;AAAA,IAC9G,MAAM;AACL,YAAM,aAAa,OAAO,IAAI,QAAQ,aAAa,GAAG;AAEtD,UAAK,CAAE,cAAc,CAAE,WAAW,WAAY,0BAA2B,GAAI;AAC5E,eAAO;AAAA,MACR;AAEA,YAAM,QAAQ,WAAW,QAAS,4BAA4B,EAAG;AAEjE,aAAO,mBAAoB,KAAM,KAAK;AAAA,IACvC;AAAA,EACD;AACD;;;AFnBO,SAAS,kBAAkB;AACjC,QAAM,MAAM,yBAAyB;AACrC,QAAM,eAAe,KAAK;AAC1B,QAAM,YAAY,SAAS,eAAgB,8BAA+B;AAE1E,SAAO,gBAAgB,YACtB,oCAAC,UAAO,aACP,oCAAC,kBAAa,CACf,IACG;AACL;;;ADZO,SAAS,OAAO;AACtB,gBAAe;AAAA,IACd,IAAI;AAAA,IACJ,WAAW;AAAA,EACZ,CAAE;AACH;;;AKCO,SAAS,sBAAuB,EAAE,IAAI,WAAW,SAAS,GAAY;AAC5E,0BAAyB,EAAE,IAAI,WAAW,SAAS,CAAE;AACtD;","names":[]}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@elementor/editor-site-settings",
3
+ "version": "4.3.0-1031",
4
+ "private": false,
5
+ "author": "Elementor Team",
6
+ "homepage": "https://elementor.com/",
7
+ "license": "GPL-3.0-or-later",
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.mjs",
10
+ "types": "dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.mjs",
15
+ "require": "./dist/index.js"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/elementor/elementor.git",
22
+ "directory": "packages/core/editor-site-settings"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/elementor/elementor/issues"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "files": [
31
+ "/dist",
32
+ "/src",
33
+ "!**/__tests__"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsup --config=../../tsup.build.ts",
37
+ "dev": "tsup --config=../../tsup.dev.ts"
38
+ },
39
+ "dependencies": {
40
+ "@elementor/editor": "4.3.0-1031",
41
+ "@elementor/editor-v1-adapters": "4.3.0-1031",
42
+ "@elementor/ui": "1.37.5"
43
+ },
44
+ "peerDependencies": {
45
+ "react": "^18.3.1",
46
+ "react-dom": "^18.3.1"
47
+ },
48
+ "devDependencies": {
49
+ "tsup": "^8.3.5"
50
+ }
51
+ }
@@ -0,0 +1,17 @@
1
+ import * as React from 'react';
2
+ import { Portal } from '@elementor/ui';
3
+
4
+ import { SITE_SETTINGS_PANEL_CONTENT_ID } from '../consts';
5
+ import { useActiveSiteSettingsTab } from '../hooks/use-active-site-settings-tab';
6
+
7
+ export function SiteSettingsTab() {
8
+ const tab = useActiveSiteSettingsTab();
9
+ const TabComponent = tab?.component;
10
+ const container = document.getElementById( SITE_SETTINGS_PANEL_CONTENT_ID );
11
+
12
+ return TabComponent && container ? (
13
+ <Portal container={ container }>
14
+ <TabComponent />
15
+ </Portal>
16
+ ) : null;
17
+ }
package/src/consts.ts ADDED
@@ -0,0 +1,3 @@
1
+ export const SITE_SETTINGS_ROUTE_PREFIX = 'panel/global/';
2
+
3
+ export const SITE_SETTINGS_PANEL_CONTENT_ID = 'elementor-kit-panel-content-controls';
@@ -0,0 +1,26 @@
1
+ import {
2
+ __privateUseListenTo as useListenTo,
3
+ routeCloseEvent,
4
+ routeOpenEvent,
5
+ v1ReadyEvent,
6
+ } from '@elementor/editor-v1-adapters';
7
+
8
+ import { SITE_SETTINGS_ROUTE_PREFIX } from '../consts';
9
+ import { getSiteSettingsTab } from '../tabs';
10
+
11
+ export function useActiveSiteSettingsTab() {
12
+ return useListenTo(
13
+ [ v1ReadyEvent(), routeOpenEvent( SITE_SETTINGS_ROUTE_PREFIX ), routeCloseEvent( SITE_SETTINGS_ROUTE_PREFIX ) ],
14
+ () => {
15
+ const panelRoute = window.$e?.routes?.getCurrent?.()?.panel;
16
+
17
+ if ( ! panelRoute || ! panelRoute.startsWith( SITE_SETTINGS_ROUTE_PREFIX ) ) {
18
+ return null;
19
+ }
20
+
21
+ const tabId = panelRoute.replace( SITE_SETTINGS_ROUTE_PREFIX, '' );
22
+
23
+ return getSiteSettingsTab( tabId ) ?? null;
24
+ }
25
+ );
26
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { init } from './init';
2
+ export { injectSiteSettingsTab } from './inject-site-settings-tab';
3
+ export { registerSiteSettingsTab } from './tabs';
package/src/init.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { injectIntoTop } from '@elementor/editor';
2
+
3
+ import { SiteSettingsTab } from './components/site-settings-tab';
4
+
5
+ export function init() {
6
+ injectIntoTop( {
7
+ id: 'editor-site-settings-tab',
8
+ component: SiteSettingsTab,
9
+ } );
10
+ }
@@ -0,0 +1,13 @@
1
+ import { type ComponentType } from 'react';
2
+
3
+ import { registerSiteSettingsTab } from './tabs';
4
+
5
+ type Config = {
6
+ id: string;
7
+ component: ComponentType;
8
+ priority?: number;
9
+ };
10
+
11
+ export function injectSiteSettingsTab( { id, component, priority }: Config ) {
12
+ registerSiteSettingsTab( { id, component, priority } );
13
+ }
package/src/tabs.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { type ComponentType } from 'react';
2
+
3
+ type Tab = {
4
+ component: ComponentType;
5
+ priority: number;
6
+ };
7
+
8
+ const registry = new Map< string, Tab >();
9
+
10
+ const DEFAULT_PRIORITY = 10;
11
+
12
+ export function registerSiteSettingsTab( {
13
+ id,
14
+ priority = DEFAULT_PRIORITY,
15
+ component,
16
+ }: {
17
+ id: string;
18
+ priority?: number;
19
+ component: ComponentType;
20
+ } ) {
21
+ const existing = registry.get( id );
22
+
23
+ if ( ! existing || priority <= existing.priority ) {
24
+ registry.set( id, { component, priority } );
25
+ }
26
+ }
27
+
28
+ export function getSiteSettingsTab( id: string ): Tab | null {
29
+ return registry.get( id ) ?? null;
30
+ }