Skip to content

Commit 4bd1075

Browse files
committed
Rewrite build-assets.js to support comprehensive CSS/JS minification, RTL generation, and file combination with configurable exclusions
1 parent 6b4a019 commit 4bd1075

14 files changed

Lines changed: 1192 additions & 266 deletions

build-assets.js

Lines changed: 485 additions & 94 deletions
Large diffs are not rendered by default.

build-prism.js

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/**
2+
* Build script: copies Prism theme CSS files from node_modules into includes/assets/.
3+
*
4+
* Run via: npm run build:prism
5+
*/
6+
7+
const fs = require( 'fs' );
8+
const path = require( 'path' );
9+
10+
const root = __dirname;
11+
12+
const themes = [
13+
{
14+
src: 'node_modules/prism-themes/themes/prism-a11y-dark.css',
15+
dest: 'includes/assets/prism-a11y-dark.css',
16+
},
17+
{
18+
src: 'node_modules/prism-themes/themes/prism-atom-dark.css',
19+
dest: 'includes/assets/prism-atom-dark.css',
20+
},
21+
{
22+
src: 'node_modules/prism-themes/themes/prism-darcula.css',
23+
dest: 'includes/assets/prism-darcula.css',
24+
},
25+
{
26+
src: 'node_modules/prism-themes/themes/prism-dracula.css',
27+
dest: 'includes/assets/prism-dracula.css',
28+
},
29+
{
30+
src: 'node_modules/prism-themes/themes/prism-ghcolors.css',
31+
dest: 'includes/assets/prism-ghcolors.css',
32+
},
33+
{
34+
src: 'node_modules/prism-themes/themes/prism-gruvbox-dark.css',
35+
dest: 'includes/assets/prism-gruvbox-dark.css',
36+
},
37+
{
38+
src: 'node_modules/prism-themes/themes/prism-gruvbox-light.css',
39+
dest: 'includes/assets/prism-gruvbox-light.css',
40+
},
41+
{
42+
src: 'node_modules/prism-themes/themes/prism-material-dark.css',
43+
dest: 'includes/assets/prism-material-dark.css',
44+
},
45+
{
46+
src: 'node_modules/prism-themes/themes/prism-material-oceanic.css',
47+
dest: 'includes/assets/prism-material-oceanic.css',
48+
},
49+
{
50+
src: 'node_modules/prism-themes/themes/prism-night-owl.css',
51+
dest: 'includes/assets/prism-night-owl.css',
52+
},
53+
{
54+
src: 'node_modules/prism-themes/themes/prism-nord.css',
55+
dest: 'includes/assets/prism-nord.css',
56+
},
57+
{
58+
src: 'node_modules/prism-themes/themes/prism-one-dark.css',
59+
dest: 'includes/assets/prism-onedark.css',
60+
},
61+
{
62+
src: 'node_modules/prism-themes/themes/prism-one-light.css',
63+
dest: 'includes/assets/prism-one-light.css',
64+
},
65+
{
66+
src: 'node_modules/prism-themes/themes/prism-shades-of-purple.css',
67+
dest: 'includes/assets/prism-shades-of-purple.css',
68+
},
69+
{
70+
src: 'node_modules/prism-themes/themes/prism-solarized-dark-atom.css',
71+
dest: 'includes/assets/prism-solarized-dark-atom.css',
72+
},
73+
{
74+
src: 'node_modules/prism-themes/themes/prism-synthwave84.css',
75+
dest: 'includes/assets/prism-synthwave84.css',
76+
},
77+
{
78+
src: 'node_modules/prism-themes/themes/prism-vs.css',
79+
dest: 'includes/assets/prism-vs.css',
80+
},
81+
{
82+
src: 'node_modules/prism-themes/themes/prism-vsc-dark-plus.css',
83+
dest: 'includes/assets/prism-vsc-dark-plus.css',
84+
},
85+
];
86+
87+
let success = true;
88+
89+
themes.forEach( ( { src, dest } ) => {
90+
const srcPath = path.resolve( root, src );
91+
const destPath = path.resolve( root, dest );
92+
93+
if ( ! fs.existsSync( srcPath ) ) {
94+
console.error( `✖ Source not found: ${ src }` );
95+
success = false;
96+
return;
97+
}
98+
99+
fs.mkdirSync( path.dirname( destPath ), { recursive: true } );
100+
fs.copyFileSync( srcPath, destPath );
101+
console.log( `✔ ${ src }${ dest }` );
102+
} );
103+
104+
if ( ! success ) {
105+
process.exit( 1 );
106+
}

includes/admin/class-settings.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,16 @@ public static function get_registered_settings(): array {
179179
'name' => __( 'Color Scheme', 'webberzone-code-block-highlighting' ),
180180
'desc' => __( 'Select the syntax highlighting color scheme applied to all code blocks.', 'webberzone-code-block-highlighting' ),
181181
'type' => 'select',
182-
'default' => 'prism-a11y-dark',
182+
'default' => 'prism-onedark',
183183
'options' => self::$color_schemes,
184184
),
185+
array(
186+
'id' => 'copy-to-clipboard',
187+
'name' => __( 'Copy to Clipboard', 'webberzone-code-block-highlighting' ),
188+
'desc' => __( 'Show a "Copy" button on code blocks, allowing visitors to copy the code with one click.', 'webberzone-code-block-highlighting' ),
189+
'type' => 'checkbox',
190+
'default' => true,
191+
),
185192
array(
186193
'id' => 'default-lang',
187194
'name' => __( 'Default Language', 'webberzone-code-block-highlighting' ),
@@ -286,11 +293,11 @@ public function enqueue_language_data( string $hook ): void {
286293
* @return string
287294
*/
288295
public static function get_color_scheme_css( bool $return_path = false ): string {
289-
$option = wz_cbh_get_option( 'color-scheme', 'prism-a11y-dark' );
296+
$option = wz_cbh_get_option( 'color-scheme', 'prism-onedark' );
290297
$rel_path = "includes/assets/{$option}.css";
291298

292299
if ( ! file_exists( WZ_CBH_PLUGIN_DIR . $rel_path ) ) {
293-
$rel_path = 'includes/assets/prism-a11y-dark.css';
300+
$rel_path = 'includes/assets/prism-onedark.css';
294301
}
295302

296303
if ( $return_path ) {

includes/admin/settings/class-metabox-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Class to display and save a Metabox.
44
*
5-
* @package WebberZone\Code_Block_Highlighting
5+
* @package WebberZone\Better_External_Links
66
*/
77

88
namespace WebberZone\Code_Block_Highlighting\Admin\Settings;

includes/admin/settings/class-settings-form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @link https://webberzone.com
66
*
7-
* @package WebberZone\Code_Block_Highlighting
7+
* @package WebberZone\CRP
88
*/
99

1010
namespace WebberZone\Code_Block_Highlighting\Admin\Settings;

includes/admin/settings/class-settings-sanitize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* @link https://webberzone.com
66
*
7-
* @package WebberZone\Code_Block_Highlighting
7+
* @package WebberZone\Better_External_Links
88
*/
99

1010
namespace WebberZone\Code_Block_Highlighting\Admin\Settings;

includes/admin/settings/class-settings-wizard-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* A reusable API class for creating multi-step settings wizards.
66
* This class provides the framework for creating guided setup experiences.
77
*
8-
* @package WebberZone\Code_Block_Highlighting
8+
* @package WebberZone\CRP
99
*/
1010

1111
namespace WebberZone\Code_Block_Highlighting\Admin\Settings;

includes/blocks/css/editor.css

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Editor styles for WebberZone Code Block Highlighting.
3+
*/
4+
5+
pre.wp-block-code {
6+
font-family: Hack, 'Fira Code', Consolas, Menlo, Monaco, 'Andale Mono',
7+
'Lucida Console', 'Lucida Sans Typewriter', 'DejaVu Sans Mono',
8+
'Bitstream Vera Sans Mono', 'Liberation Mono', 'Nimbus Mono L',
9+
'Courier New', Courier, monospace;
10+
padding: 1em;
11+
margin-top: 0.5rem !important;
12+
margin-bottom: 1rem;
13+
overflow: auto;
14+
border-radius: 0.3em;
15+
}
16+
17+
pre.wp-block-code code,
18+
pre.wp-block-code .rich-text {
19+
padding-left: 0;
20+
border: none;
21+
overflow-x: initial;
22+
white-space: pre;
23+
}
24+
25+
.editor-styles-wrapper .wp-block-code {
26+
margin-top: 0.5rem !important;
27+
}
28+
29+
.wz-cbh-block__labels {
30+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
31+
Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
32+
font-size: 0.85rem;
33+
margin-top: 1rem;
34+
margin-bottom: 0;
35+
text-align: left;
36+
}
37+
38+
.wz-cbh-block__labels span {
39+
padding: 8px;
40+
margin: 0 8px 0 0;
41+
color: #333;
42+
background-color: #eee;
43+
}
44+
45+
.editor-styles-wrapper pre.wp-block-code code[contenteditable='true'] {
46+
display: block;
47+
min-height: 1.5em;
48+
outline: none;
49+
}
50+
51+
.wz-cbh-save-default {
52+
display: flex;
53+
align-items: center;
54+
gap: 8px;
55+
width: 100%;
56+
}
57+
58+
.wz-cbh-save-default__notice {
59+
font-size: 0.85em;
60+
color: #1e7e34;
61+
}

0 commit comments

Comments
 (0)