Fixing Issue #1

This commit is contained in:
Random Penguin 2025-04-27 16:52:25 -05:00
parent 8609331987
commit 01f35199f4

View file

@ -2,7 +2,7 @@
/** /**
* Name: Zen Postbox * Name: Zen Postbox
* Description: Adds a button to editor to insert color background. Called Zen to load last. * Description: Adds a button to editor to insert color background. Called Zen to load last.
* Version: 1.0 * Version: 1.1
* Author: Random Penguin <https://gitlab.com/randompenguin> * Author: Random Penguin <https://gitlab.com/randompenguin>
*/ */
@ -20,88 +20,95 @@ function zen_postbox_jot_tool(string &$body)
{ {
$labels = [ $labels = [
'Black', ['White Smoke', 'whitesmoke'],
'Red', ['Dark Grey', 'darkgrey'],
'Green', ['Black', 'black'],
'Blue', ['Pink', 'pink'],
'Orange', ['Red', 'red'],
'Purple', ['Dark Red', 'darkred'],
'Forest', ['Light Pink', 'lightpink'],
'Ocean', ['Hot Pink', 'hotpink'],
'Pink', ['Medium Violet Red', 'mediumvioletred'],
'Salmon', ['Peach Puff', 'peachpuff'],
'Dark Gray', ['Dark Orange (Orange)', 'darkorange'],
'Minty', ['Sienna', 'sienna'],
'Mint Gray', ['Light Yellow', 'lightyellow'],
'Red-Blue', ['Gold', 'gold'],
'Violets', ['Goldenrod', 'goldenrod'],
'Gray-Black', ['Honeydew', 'honeydew'],
'Teal Blue', ['Yellow Green', 'yellowgreen'],
'Green Gray', ['Olive Drab', 'olivedrab'],
'Teal Gray', ['Pale Green', 'palegreen'],
'Blue Gray', ['Lime Green (Green)', 'limegreen'],
'Lavender Gray', ['Forest Green (Forest)', 'forestgreen'],
'Sunset', ['Mint Cream', 'mintcream'],
'Sherbert', ['Medium Aquamarine', 'mediumaquamarine'],
['Sea Green', 'seagreen'],
['Sky Blue', 'skyblue'],
['Cornflower Blue (Blue)', 'cornflowerblue'],
['Dark Slate Blue', 'darkslateblue'],
['Lavender', 'lavender'],
['Medium Slate Blue', 'mediumslateblue'],
['Dark Blue (Ocean)', 'darkblue'],
['Thistle', 'thistle'],
['Violet', 'violet'],
['Purple', 'purple'],
['Light Salmon (Salmon)', 'lightsalmon'],
['Aurora', 'aurora'],
['Blue-Gray', 'bluegray'],
['Gray-Grey', 'graygrey'],
['Gray-Black', 'grayblack'],
['Green-Gray', 'greengray'],
['Lavender-Gray', 'lavendergray'],
['Minty', 'minty'],
['Mint-Gray', 'mintgray'],
['Rainbow', 'rainbow'],
['Red-Blue', 'redblue'],
['Sherbet', 'sherbet'],
['Spectrum', 'spectrum'],
['Strawberry-Cream', 'strawberrycream'],
['Sunset', 'sunset'],
['Teal-Blue', 'tealblue'],
['Teal-Gray', 'tealgray'],
['Violets', 'violets'],
['Violet-Blue', 'violetblue'],
['Blueprint', 'blueprint'],
['Birds', 'birds'],
['Checkered', 'checkered'],
['Cubes', 'cubes'],
['Lemon-Lime', 'lemonlime'],
['Gingham', 'gingham'],
['Grid', 'grid'],
['Hearts', 'hearts'],
['Honeycomb', 'honeycomb'],
['Notebook', 'notebook'],
['Plaid', 'plaid'],
['Polkadots', 'polkadots'],
['Shade Dots', 'shadedots'],
['Shadowbox', 'shadowbox'],
['Stars', 'stars'],
['Warp Grid', 'warpgrid'],
['Wavy', 'wavy'],
['Ani-Gradient', 'anigradient'],
['Blob', 'blob'],
['Color Fade', 'colorfade'],
['Grid Runner', 'gridrunner'],
['Heartbeat', 'heartbeat'],
['Moonrise', 'moonrise'],
['Rainy', 'rainy'],
['Rocket', 'rocket'],
['Snowy', 'snowy'],
['Sunrise', 'sunrise'],
['Waves', 'waves'],
]; ];
$texts = [ // Generate Postbox Buttons
'[class=postbox-black]',
'[class=postbox-red]',
'[class=postbox-green]',
'[class=postbox-blue]',
'[class=postbox-orange]',
'[class=postbox-purple]',
'[class=postbox-forest]',
'[class=postbox-ocean]',
'[class=postbox-pink]',
'[class=postbox-salmon]',
'[class=postbox-darkgray]',
'[class=postbox-minty]',
'[class=postbox-mintgray]',
'[class=postbox-redblue]',
'[class=postbox-violets]',
'[class=postbox-grayblack]',
'[class=postbox-tealblue]',
'[class=postbox-greengray]',
'[class=postbox-tealgray]',
'[class=postbox-bluegray]',
'[class=postbox-lavendergray]',
'[class=postbox-sunset]',
'[class=postbox-sherbert]',
];
$icons = [
'<div class="pick-postbox postbox-black"></div>',
'<div class="pick-postbox postbox-red"></div>',
'<div class="pick-postbox postbox-green"></div>',
'<div class="pick-postbox postbox-blue"></div>',
'<div class="pick-postbox postbox-orange"></div>',
'<div class="pick-postbox postbox-purple"></div>',
'<div class="pick-postbox postbox-forest"></div>',
'<div class="pick-postbox postbox-ocean"></div>',
'<div class="pick-postbox postbox-pink"></div>',
'<div class="pick-postbox postbox-salmon"></div>',
'<div class="pick-postbox postbox-darkgray"></div>',
'<div class="pick-postbox postbox-minty"></div>',
'<div class="pick-postbox postbox-mintgray"></div>',
'<div class="pick-postbox postbox-redblue"></div>',
'<div class="pick-postbox postbox-violets"></div>',
'<div class="pick-postbox postbox-grayblack"></div>',
'<div class="pick-postbox postbox-tealblue"></div>',
'<div class="pick-postbox postbox-greengray"></div>',
'<div class="pick-postbox postbox-tealgray"></div>',
'<div class="pick-postbox postbox-bluegray"></div>',
'<div class="pick-postbox postbox-lavendergray"></div>',
'<div class="pick-postbox postbox-sunset"></div>',
'<div class="pick-postbox postbox-sherbert"></div>',
];
$params = ['texts' => $texts, 'icons' => $icons, 'string' => '', 'labels' => $labels];
//Generate html for smiley list
$s = '<div class="preview-postbox"><tr>'; $s = '<div class="preview-postbox"><tr>';
for ($x = 0; $x < count($params['texts']); $x++) { for ($x = 0; $x < count($labels); $x++){
$icon = $params['icons'][$x]; $s .= '<button type="button" title="' . $labels[$x][0] . '" onclick="postbox_addbox(\'[class=postbox-' . $labels[$x][1] . ']\')"><div class="pick-postbox postbox-' . $labels[$x][1] . '"></div></button>';
$s .= '<button type="button" title="' . $params['labels'][$x] . '" onclick="postbox_addbox(\'' . $params['texts'][$x] . '\')">' . $icon . '</button>';
} }
$s .= '</div>'; $s .= '</div>';
@ -113,10 +120,16 @@ function zen_postbox_jot_tool(string &$body)
DI::page()->registerStylesheet($css_file); DI::page()->registerStylesheet($css_file);
// Add zen_postbox Styling to Header /* Add Postbox Styling to Header
$box_styles = __DIR__ . '/view/postbox.min.css'; DI::page()->registerStylesheet($path) might load before theme
DI::page()->registerStylesheet($box_styles); so we will append with DI::page()['htmlhead'] to make it load much much later
*/
$path = __DIR__ . '/view/postbox.min.css?v=' . DI::app()::VERSION;
if (mb_strpos($path, DI::basePath() . DIRECTORY_SEPARATOR) === 0) {
$path = mb_substr($path, mb_strlen(DI::basePath() . DIRECTORY_SEPARATOR));
}
DI::page()['htmlhead'] .= '<link rel="stylesheet" href="'.$path.'" media="screen"/>';
//Get the correct image for the theme //Get the correct image for the theme
$image = 'addon/zen_postbox/view/default.png'; $image = 'addon/zen_postbox/view/default.png';