Skip to content

Commit

Permalink
Merge pull request #70 from KevinBatdorf/fix-highlight-resize-bug
Browse files Browse the repository at this point in the history
Fix resize bug
  • Loading branch information
KevinBatdorf committed Nov 21, 2022
2 parents cc490fd + 1d4ab62 commit fcb6a29
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion code-block-pro.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Code highlighting powered by the VS Code engine
* Requires at least: 6.0
* Requires PHP: 7.0
* Version: 1.9.0
* Version: 1.9.1
* Author: Kevin Batdorf
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contributors: kbat82
Tags: block, code, syntax, highlighting, snippet, highlighter, JavaScript, php, vs code, editor, torchlight, shiki
Tested up to: 6.1
Stable tag: 1.9.0
Stable tag: 1.9.1
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -232,6 +232,9 @@ Themes are rendered inside the editor as you type or make changes, so the code b

== Changelog ==

= 1.9.1 - 2022-11-21 =
- Fix: Fixed a situations where the highlighter was miscalculating its width

= 1.9.0 - 2022-11-20 =
- Feature: Added line highlights
- Feature: Added blur effect to highlight lines
Expand Down
2 changes: 1 addition & 1 deletion src/front/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ addEventListener('DOMContentLoaded', () => {
const resizeObserver = new ResizeObserver((entries) => {
entries.forEach((entry) => {
// get width of inner code block
codeBlock.style.setProperty('--cbp-block-width', '0');
const codeWidth =
entry.target.querySelector('code').offsetWidth;
const computed =
codeWidth + 16 === entry.target.scrollWidth
? codeWidth + 16
: entry.target.scrollWidth + 16;
codeBlock.style.setProperty('--cbp-block-width', '0');
codeBlock.style.setProperty(
'--cbp-block-width',
`${computed}px`,
Expand Down

0 comments on commit fcb6a29

Please sign in to comment.