Commit inicial powerservice

This commit is contained in:
Gabriel
2026-10-19 12:45:45 -06:00
commit ad85486fe2
10158 changed files with 2736804 additions and 0 deletions
@@ -0,0 +1,44 @@
<?php
/*
* This file is part of the Jooosi Fon package.
*
* (c) Joshua Gugun Siagian <suabahasa@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare (strict_types=1);
namespace JooosiFon\Builder\Pinegrow;
use JooosiFonDeps\JOOOSI_FON;
use JooosiFon\Admin\AdminPage;
use JooosiFon\Builder\BuilderInterface;
use JooosiFon\Core\Cache;
use JooosiFon\Utils\Font;
/**
* Pinegrow integration.
*
* @author Joshua Gugun Siagian <suabahasa@gmail.com>
*/
class Main implements BuilderInterface
{
public function __construct()
{
add_action('admin_menu', static fn() => AdminPage::add_redirect_submenu_page('pinegrow-projects'), 1000001);
add_action('load-toplevel_page_pinegrow-projects', fn() => $this->init_hooks());
}
public function get_name(): string
{
return 'pinegrow';
}
public function init_hooks(): void
{
add_action('admin_enqueue_scripts', fn() => $this->enqueue_scripts(), 1000001);
}
public function enqueue_scripts()
{
wp_enqueue_script('jooosi-fon-for-pinegrow', plugin_dir_url(__FILE__) . 'assets/script/pinegrow.js', [], JOOOSI_FON::VERSION, \true);
wp_localize_script('jooosi-fon-for-pinegrow', 'jooosiFonPinegrow', ['stylesheet_url' => Cache::get_versioned_cache_url(Cache::CSS_CACHE_FILE), 'font_families' => array_map(static fn($f) => ['name' => $f['title'], 'key' => $f['css']['variable'], 'family' => $f['family']], Font::get_fonts())]);
}
}
@@ -0,0 +1,81 @@
document.addEventListener('DOMContentLoaded', async function () {
await new Promise(resolve => {
let waitingForEditor = setInterval(() => {
if (
window.frames[0].pinegrow?.getSelectedPage() !== null
&& window.frames[0].pinegrow?.getSelectedPage() !== undefined
) {
clearInterval(waitingForEditor);
resolve();
}
}, 3000);
});
// add stylesheet
window.frames[0].pinegrow.getSelectedPage().addStylesheet(window.jooosiFonPinegrow.stylesheet_url);
// style tab
await new Promise(resolve => {
let waitingForFontFamily = setInterval(() => {
try {
if (
window.frames[0].$.fn.crsa.defaults.rulesDefinition.sections.text.fields['font-family'] !== null
&& window.frames[0].$.fn.crsa.defaults.rulesDefinition.sections.text.fields['font-family'] !== undefined
) {
clearInterval(waitingForFontFamily);
resolve();
}
} catch (err) { }
}, 100);
});
window.frames[0].$.fn.crsa.defaults.rulesDefinition.sections.text.fields['font-family'].options = function () {
return window.jooosiFonPinegrow.font_families || [];
};
// design tab
await new Promise(resolve => {
let waitingForFontLibrary = setInterval(() => {
try {
if (
window.frames[0].pinegrow.fontLibrary !== null
&& window.frames[0].pinegrow.fontLibrary !== undefined
) {
clearInterval(waitingForFontLibrary);
resolve();
}
} catch (err) { }
}, 100);
});
const preservedSystemFonts = [];
window.frames[0].pinegrow.fontLibrary.forEachFont(font => {
if (font.type === 'system') {
preservedSystemFonts.push(font);
}
});
const fontSystemClass = window.frames[0].pinegrow.fontLibrary.getFontClassForType('system');
window.frames[0].pinegrow.fontLibrary.removeAll();
window.jooosiFonPinegrow.font_families.forEach(font => {
const pfs = new fontSystemClass({
type: 'system',
family: font.family,
usage: 'all',
category: 'sans-serif',
w: '100, 200, 300, 400, 500, 600, 700, 800, 900'.split(/,\s?/)
});
window.frames[0].pinegrow.fontLibrary.addFont(pfs);
});
preservedSystemFonts.forEach(font => {
window.frames[0].pinegrow.fontLibrary.addFont(font);
});
window.frames[0].pinegrow.fontLibrary.save();
});