Skip to content

Commit 8442735

Browse files
committed
docs: fix wrong panel name and expand developer reference
1 parent 69b92b9 commit 8442735

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

docs/02-wzcbh-advanced/per-block-controls.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ status: publish
88
order: 0
99
---
1010

11-
Each code block has its own highlighting settings, available in the **Code Highlighting** panel of the Inspector Controls sidebar. These override the global defaults set on the [Code Block Highlighting settings page](https://webberzone.com/plugins/webberzone-code-block-highlighting/).
11+
Each code block has its own highlighting settings, available in the **Syntax Highlighting** panel of the Inspector Controls sidebar. These override the global defaults set on the [Code Block Highlighting settings page](https://webberzone.com/plugins/webberzone-code-block-highlighting/).
1212

1313
[kbtoc]
1414

@@ -37,3 +37,9 @@ Set a maximum visible height in pixels. When the code block content exceeds this
3737
## Word Wrap
3838

3939
Toggle soft word wrapping for long lines. When disabled (the default), long lines scroll horizontally.
40+
41+
## Save as Default
42+
43+
After configuring the controls above, click **Save as default** at the bottom of the **Syntax Highlighting** panel to copy the current block's settings (language, line numbers, line numbers start, word wrap, max height) into the global `default-lang` setting and the equivalent global defaults. Future code blocks inserted via the editor will inherit these values.
44+
45+
The button calls the `POST /wzcbh/v1/default-settings` REST endpoint under the `wzcbh/v1` namespace. Only users with the `manage_options` capability can call it. See the [Developer Reference](https://webberzone.com/support/knowledgebase/code-block-highlighting-developer-reference/) for the full route schema.

docs/03-wzcbh-developer-docs/developer-reference.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,62 @@ add_filter( 'wzcbh_force_load_assets', '__return_true' );
161161

162162
---
163163

164+
## JavaScript objects
165+
166+
The plugin exposes several JavaScript globals via `wp_add_inline_script()`. They are read by the editor bundle and the frontend bundles.
167+
168+
### `cbhLanguages`
169+
170+
Available in the block editor. Maps language slugs to display labels.
171+
172+
```js
173+
cbhLanguages.javascript // "JavaScript"
174+
cbhLanguages.php // "PHP"
175+
```
176+
177+
The same array is exposed through the `wzcbh_languages` filter.
178+
179+
### `cbhDefaultLang`
180+
181+
Available in the block editor. The slug pre-selected on new code blocks, from the `default-lang` setting. Empty string when no default is configured.
182+
183+
### `cbhDefaultSettings`
184+
185+
Available in the block editor. Object containing the per-block defaults applied to a fresh code block:
186+
187+
```js
188+
cbhDefaultSettings.language // Default language slug.
189+
cbhDefaultSettings.lineNumbers // Whether line numbers are on by default.
190+
cbhDefaultSettings.lineNumbersStart // Default starting line number (1).
191+
cbhDefaultSettings.wordWrap // Whether soft word wrap is on by default.
192+
cbhDefaultSettings.maxHeight // Default max height in pixels (0 = unlimited).
193+
```
194+
195+
### `cbhSettings`
196+
197+
Available on the frontend in client-side mode (inlined before the `wzcbh-prism-js` script). Toggles the toolbar features that the frontend bundle reads at runtime:
198+
199+
```js
200+
cbhSettings.copyToClipboard // Show the Copy button.
201+
cbhSettings.showLanguageLabel // Show the language label in the toolbar.
202+
cbhSettings.showFileName // Show the file-name label in the toolbar.
203+
```
204+
205+
### `wzcbhI18n`
206+
207+
Available on the frontend in server-side mode (inlined before the `wzcbh-hljs-clipboard` script). Translation strings used by the toolbar:
208+
209+
```js
210+
wzcbhI18n.copy // "Copy"
211+
wzcbhI18n.copied // "Copied!"
212+
wzcbhI18n.copySuccess // "Copied code to clipboard."
213+
wzcbhI18n.copyError // "Unable to copy code to clipboard."
214+
wzcbhI18n.expand // "Expand"
215+
wzcbhI18n.collapse // "Collapse"
216+
```
217+
218+
---
219+
164220
## Adding a language
165221

166222
To add a custom language to the block editor picker and to the Prism frontend bundle:

0 commit comments

Comments
 (0)