You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/02-wzcbh-advanced/per-block-controls.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ status: publish
8
8
order: 0
9
9
---
10
10
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/).
12
12
13
13
[kbtoc]
14
14
@@ -37,3 +37,9 @@ Set a maximum visible height in pixels. When the code block content exceeds this
37
37
## Word Wrap
38
38
39
39
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.
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
+
164
220
## Adding a language
165
221
166
222
To add a custom language to the block editor picker and to the Prism frontend bundle:
0 commit comments