fix(comments): restore syntax highlighting for comment code blocks
Comment [code] blocks rendered as bare <pre><code> with only Bootstrap's
grey box — no syntax colours, unlike the reference.
The runtime gates EnlighterJS on `_win.highlight_kg`, which was hardcoded to
false. With that false the selector degrades to `pre code.gl, pre code.special`,
and comment code carries neither class, so it never highlighted. The admin
already exposes 「全局功能 → 代码高亮」 (default on), and jioData.codeHighlight
reads it — only the runtime payload disagreed.
- _win.highlight_kg / highlight_hh / highlight_zt (plus white/dark theme
names) now come from Settings::get_code_highlight_config(); the initial
theme follows cookie → mode → time-auto via initial_theme_mode()
- define those values before the _win localize (it sits above jioData in the
same method)
- inject the reference's two head rules the runtime path was missing:
max-height from `highlight_maxheight`, and
`.enlighter-toolbar{display:none}` when `highlight_btn` is off
Tests: comment-image-upload contract gains cases pinning the settings-backed
booleans (and their definition order) and the two inline CSS rules; suite
837/838 with the pre-existing frontend-lifecycle failure.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
0007e78bfe
commit
451b04160b
3 files changed
+90
-7
No files matched your search
@@ -49,6 +49,24 @@ trait ScriptsPart1b {
|
||||
wp_add_inline_style('jio-public', '.lazyloaded{--lazy-animation:lazy_scale!important;}');
|
||||
}
|
||||
|
||||
// 代码高亮的「最大高度」与「扩展按钮」由后台设置驱动。runtime 的
|
||||
// enlighter 路径(评论区 [code] 等)不走 precode.js,需要这两条规则兜底。
|
||||
if (class_exists('\Jio\Settings\Settings')) {
|
||||
$code_highlight_css = \Jio\Settings\Settings::get_code_highlight_config();
|
||||
if (!empty($code_highlight_css['enabled'])) {
|
||||
$max_height_css = (int) $code_highlight_css['maxHeight'];
|
||||
if ($max_height_css > 0) {
|
||||
wp_add_inline_style(
|
||||
'jio-public',
|
||||
'.enlighter-default .enlighter,.wp-block-code:not(:has(.enlighter)),.enlighter-pre:not(:has(.enlighter)){max-height:' . $max_height_css . 'px;overflow-y:auto !important;}'
|
||||
);
|
||||
}
|
||||
if (empty($code_highlight_css['showButtons'])) {
|
||||
wp_add_inline_style('jio-public', '.enlighter-toolbar{display:none !important;}');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$core_dep = 'jio-public';
|
||||
|
||||
$deps = [$core_dep];
|
||||
|
||||
Reference in new issue
Block a user