Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .plugin-data
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "1.1.2",
"version": "1.1.3",
"slug": "blockparty-key-figure"
}
4 changes: 2 additions & 2 deletions blockparty-key-figure.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Key Figure block for WordPress.
* Requires at least: 6.2
* Requires PHP: 8.1
* Version: 1.1.2
* Version: 1.1.3
* Author: Be API Technical team
* Author URI: https://beapi.fr
* License: GPL-2.0-or-later
Expand All @@ -17,7 +17,7 @@

use Blockparty\Key_Figure\Cli\MigrateFromKeyFigureBlockCommand;

define( 'BLOCKPARTY_KEY_FIGURE_VERSION', '1.1.2' );
define( 'BLOCKPARTY_KEY_FIGURE_VERSION', '1.1.3' );
define( 'BLOCKPARTY_KEY_FIGURE_URL', plugin_dir_url( __FILE__ ) );
define( 'BLOCKPARTY_KEY_FIGURE_DIR', plugin_dir_path( __FILE__ ) );

Expand Down
2 changes: 1 addition & 1 deletion languages/blockparty-key-figure-fr_FR.po
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is distributed under the GPL-2.0-or-later.
msgid ""
msgstr ""
"Project-Id-Version: Be API Key Figure block 1.1.2\n"
"Project-Id-Version: Be API Key Figure block 1.1.3\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/blockparty-key-"
"figure\n"
"POT-Creation-Date: 2024-04-02T21:11:52+00:00\n"
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blockparty-key-figure",
"version": "1.1.2",
"version": "1.1.3",
"description": "Key Figure block for WordPress.",
"author": "Be API Technical team",
"license": "GPL-2.0-or-later",
Expand Down
12 changes: 8 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Contributors: beapi, candrietti
Tags: block, key, figure, gutenberg
Tested up to: 6.5
Stable tag: 1.1.2
Stable tag: 1.1.3
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -74,9 +74,13 @@ Run `wp help blockparty key-figure migrate` for the full list of options.
= 1.1.0 - 2026-02-16 =
* Markup change: __key wrapper was div, now p (a11y/semantic)

= 1.1.2 - 2026-09-22 =
* Add WP-CLI command to migrate legacy beapi/key-figure block content.

= 1.1.1 - 2026-09-04 =
* Add block example.
* Move suffix attribute after number control for UX improvment

= 1.1.2 - 2026-09-22 =
* Add WP-CLI command to migrate legacy beapi/key-figure block content.

= 1.1.3 - 2026-10-08 =
* Fix fr-FR Intl thousands separator so CSS letter-spacing applies (U+202F replaced with U+2009).
* Share number formatting between frontend script and block editor.
2 changes: 1 addition & 1 deletion src/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://schemas.wp.org/trunk/block.json",
"apiVersion": 3,
"name": "blockparty/key-figure",
"version": "1.1.2",
"version": "1.1.3",
"title": "Key Figure",
"category": "widgets",
"description": "Key Figure block.",
Expand Down
35 changes: 3 additions & 32 deletions src/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,9 @@ import {

import classnames from 'classnames';

import './editor.scss';

// Custom hook for number formatting
function useNumberFormatter(number, decimalSeparator, minimumFractionDigits) {
const formatNumber = (numberToFormat) => {
if (!numberToFormat && numberToFormat !== 0) {
return numberToFormat;
}

if (decimalSeparator === 'none') {
return numberToFormat.toString();
} else if (decimalSeparator === '.' || decimalSeparator === ',') {
return (numberToFormat || 0)
.toString()
.replace('.', decimalSeparator);
}

const options = {
minimumFractionDigits: minimumFractionDigits || 0,
};
import { formatNumber } from './utils/format-number';

try {
return new Intl.NumberFormat(decimalSeparator, options).format(
numberToFormat
);
} catch (error) {
return numberToFormat.toString();
}
};

return formatNumber(number);
}
import './editor.scss';

export default function Edit({ attributes, setAttributes }) {
const {
Expand All @@ -63,7 +34,7 @@ export default function Edit({ attributes, setAttributes }) {
} = attributes;

const numberRef = useRef();
const formattedNumber = useNumberFormatter(
const formattedNumber = formatNumber(
number,
decimalSeparator,
minimumFractionDigits
Expand Down
28 changes: 2 additions & 26 deletions src/number-formatter.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,8 @@
/**
* Number formatting utility for Key Figure blocks
* Frontend-only formatting (editor formatting handled in React components)
* Number formatting utility for Key Figure blocks (frontend).
*/

function formatNumber(numberToFormat, decimalSeparator, minimumFractionDigits) {
if (!numberToFormat && numberToFormat !== 0) {
return numberToFormat;
}

if (decimalSeparator === 'none') {
return numberToFormat.toString();
} else if (decimalSeparator === '.' || decimalSeparator === ',') {
return (numberToFormat || 0).toString().replace('.', decimalSeparator);
}

const options = {
minimumFractionDigits: minimumFractionDigits || 0,
};

try {
return new Intl.NumberFormat(decimalSeparator, options).format(
numberToFormat
);
} catch (error) {
// Fallback to simple string conversion if formatting fails
return numberToFormat.toString();
}
}
import { formatNumber } from './utils/format-number';

function initializeNumberFormatting() {
// Only run on frontend (not in editor)
Expand Down
54 changes: 54 additions & 0 deletions src/utils/format-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Intl.NumberFormat (e.g. fr-FR) may insert U+202F (narrow no-break space) as the
* thousands separator. Some fonts in Chromium ignore letter-spacing on text that
* contains U+202F. Thin space (U+2009) keeps grouped digits readable and allows
* CSS tracking (letter-spacing).
*/
const INTNL_NARROW_NO_BREAK_SPACE = /\u202f/g;
const THIN_SPACE = '\u2009';

/**
* @param {string} formatted Formatted number string from Intl.
* @return {string} Formatted number with thousands separators safe for CSS tracking.
*/
function normalizeIntlFormattedNumber(formatted) {
return formatted.replace(INTNL_NARROW_NO_BREAK_SPACE, THIN_SPACE);
}

/**
* @param {number} numberToFormat Value to format.
* @param {string} decimalSeparator Locale id, "none", or literal "." / "," separator.
* @param {number|string} minimumFractionDigits Minimum fraction digits for Intl locales.
* @return {string|number|undefined} Formatted value, or the input when formatting is skipped.
*/
export function formatNumber(
numberToFormat,
decimalSeparator,
minimumFractionDigits
) {
if (!numberToFormat && numberToFormat !== 0) {
return numberToFormat;
}

if (decimalSeparator === 'none') {
return numberToFormat.toString();
}

if (decimalSeparator === '.' || decimalSeparator === ',') {
return (numberToFormat || 0).toString().replace('.', decimalSeparator);
}

const options = {
minimumFractionDigits: minimumFractionDigits || 0,
};

try {
return normalizeIntlFormattedNumber(
new Intl.NumberFormat(decimalSeparator, options).format(
numberToFormat
)
);
} catch (error) {
return numberToFormat.toString();
}
}
Loading