Skip to content

Commit a096e6d

Browse files
authored
3.1.2 (#106)
* Fix slow call to ctx.font * Fix breaking const enum * Prep for 3.1.2 * Update readme
1 parent dd2fca4 commit a096e6d

File tree

10 files changed

+18
-19
lines changed

10 files changed

+18
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</h1>
55
<p align="center">A relatively small HTML5 Canvas based data editor supporting <b>millions</b> of rows, <b>rapid</b> updating, and fully <b>native scrolling</b>. We built <a href="https://grid.glideapps.com" target="_blank">Data Grid</a> as the basis for the <a href="https://docs.glideapps.com/all/reference/data-editor/introduction-to-the-data-editor" target="_blank">Glide Data Editor</a>.</p>
66

7-
<p align="center"><a href="https://github.com/glideapps/glide-data-grid/releases" target="_blank"><img src="https://img.shields.io/badge/version-v3.1.1-blue?style=for-the-badge&logo=none" alt="grid version" /></a>&nbsp;<a href="https://reactjs.org/" target="_blank"><img src="https://img.shields.io/badge/React-16+-00ADD8?style=for-the-badge&logo=react" alt="react version" /></a>&nbsp;<a href="https://www.typescriptlang.org/" target="_blank"><img src="https://img.shields.io/badge/Typescript-grey?style=for-the-badge&logo=typescript" alt="react version" /></a>&nbsp;<a href="https://bundlephobia.com/package/@glideapps/glide-data-grid" target="_blank"><img src="https://img.shields.io/badge/Bundle_Size-43.1kb-success?style=for-the-badge&logo=none" alt="go cover" /></a>&nbsp;<img src="https://img.shields.io/badge/license-mit-red?style=for-the-badge&logo=none" alt="license" />&nbsp;<a href="https://www.glideapps.com/jobs" target="_blank"><img src="https://img.shields.io/badge/❤_Made_by-Glide-11CCE5?style=for-the-badge&logo=none" alt="glide" /></a></p>
7+
<p align="center"><a href="https://github.com/glideapps/glide-data-grid/releases" target="_blank"><img src="https://img.shields.io/badge/version-v3.1.2-blue?style=for-the-badge&logo=none" alt="grid version" /></a>&nbsp;<a href="https://reactjs.org/" target="_blank"><img src="https://img.shields.io/badge/React-16+-00ADD8?style=for-the-badge&logo=react" alt="react version" /></a>&nbsp;<a href="https://www.typescriptlang.org/" target="_blank"><img src="https://img.shields.io/badge/Typescript-grey?style=for-the-badge&logo=typescript" alt="react version" /></a>&nbsp;<a href="https://bundlephobia.com/package/@glideapps/glide-data-grid" target="_blank"><img src="https://img.shields.io/badge/Bundle_Size-43.1kb-success?style=for-the-badge&logo=none" alt="go cover" /></a>&nbsp;<img src="https://img.shields.io/badge/license-mit-red?style=for-the-badge&logo=none" alt="license" />&nbsp;<a href="https://www.glideapps.com/jobs" target="_blank"><img src="https://img.shields.io/badge/❤_Made_by-Glide-11CCE5?style=for-the-badge&logo=none" alt="glide" /></a></p>
88

99
![Data Grid](https://raw.githubusercontent.com/glideapps/glide-data-grid/master/data-grid.jpg)
1010

cells/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</h1>
55
<p align="center">Additional cells and features for Glide Data Grid</p>
66

7-
<p align="center"><a href="https://github.com/glideapps/glide-data-grid/releases" target="_blank"><img src="https://img.shields.io/badge/version-v3.1.1-blue?style=for-the-badge&logo=none" alt="grid version" /></a>&nbsp;<a href="https://reactjs.org/" target="_blank"><img src="https://img.shields.io/badge/React-16+-00ADD8?style=for-the-badge&logo=react" alt="react version" /></a>&nbsp;<a href="https://www.typescriptlang.org/" target="_blank"><img src="https://img.shields.io/badge/Typescript-grey?style=for-the-badge&logo=typescript" alt="react version" /></a>&nbsp;<img src="https://img.shields.io/badge/license-mit-red?style=for-the-badge&logo=none" alt="license" />&nbsp;<a href="https://www.glideapps.com/jobs" target="_blank"><img src="https://img.shields.io/badge/❤_Made_by-Glide-11CCE5?style=for-the-badge&logo=none" alt="glide" /></a></p>
7+
<p align="center"><a href="https://github.com/glideapps/glide-data-grid/releases" target="_blank"><img src="https://img.shields.io/badge/version-v3.1.2-blue?style=for-the-badge&logo=none" alt="grid version" /></a>&nbsp;<a href="https://reactjs.org/" target="_blank"><img src="https://img.shields.io/badge/React-16+-00ADD8?style=for-the-badge&logo=react" alt="react version" /></a>&nbsp;<a href="https://www.typescriptlang.org/" target="_blank"><img src="https://img.shields.io/badge/Typescript-grey?style=for-the-badge&logo=typescript" alt="react version" /></a>&nbsp;<img src="https://img.shields.io/badge/license-mit-red?style=for-the-badge&logo=none" alt="license" />&nbsp;<a href="https://www.glideapps.com/jobs" target="_blank"><img src="https://img.shields.io/badge/❤_Made_by-Glide-11CCE5?style=for-the-badge&logo=none" alt="glide" /></a></p>
88

99
![Data Grid](https://raw.githubusercontent.com/glideapps/glide-data-grid/master/data-grid.jpg)
1010

cells/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@glideapps/glide-data-grid-cells",
3-
"version": "3.1.1-beta3",
3+
"version": "3.1.2",
44
"description": "Extra cells for glide-data-grid",
55
"main": "dist/js/index.js",
66
"types": "dist/ts/index.d.ts",
@@ -30,7 +30,7 @@
3030
"canvas"
3131
],
3232
"dependencies": {
33-
"@glideapps/glide-data-grid": "3.1.1-beta3"
33+
"@glideapps/glide-data-grid": "3.1.2"
3434
},
3535
"devDependencies": {
3636
"@babel/cli": "^7.16.0",

core/API.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ interface CustomCell<T extends {} = {}> extends BaseGridCell {
457457
readonly copyData: string;
458458
}
459459

460-
export const enum GridCellKind {
460+
export enum GridCellKind {
461461
Uri = "uri",
462462
Text = "text",
463463
Image = "image",

core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</h1>
55
<p align="center">A relatively small HTML5 Canvas based data editor supporting <b>millions</b> of rows, <b>rapid</b> updating, and fully <b>native scrolling</b>. We built <a href="https://grid.glideapps.com" target="_blank">Data Grid</a> as the basis for the <a href="https://docs.glideapps.com/all/reference/data-editor/introduction-to-the-data-editor" target="_blank">Glide Data Editor</a>.</p>
66

7-
<p align="center"><a href="https://github.com/glideapps/glide-data-grid/releases" target="_blank"><img src="https://img.shields.io/badge/version-v3.1.1-blue?style=for-the-badge&logo=none" alt="grid version" /></a>&nbsp;<a href="https://reactjs.org/" target="_blank"><img src="https://img.shields.io/badge/React-16+-00ADD8?style=for-the-badge&logo=react" alt="react version" /></a>&nbsp;<a href="https://www.typescriptlang.org/" target="_blank"><img src="https://img.shields.io/badge/Typescript-grey?style=for-the-badge&logo=typescript" alt="react version" /></a>&nbsp;<a href="https://bundlephobia.com/package/@glideapps/glide-data-grid" target="_blank"><img src="https://img.shields.io/badge/Bundle_Size-43.1kb-success?style=for-the-badge&logo=none" alt="go cover" /></a>&nbsp;<img src="https://img.shields.io/badge/license-mit-red?style=for-the-badge&logo=none" alt="license" />&nbsp;<a href="https://www.glideapps.com/jobs" target="_blank"><img src="https://img.shields.io/badge/❤_Made_by-Glide-11CCE5?style=for-the-badge&logo=none" alt="glide" /></a></p>
7+
<p align="center"><a href="https://github.com/glideapps/glide-data-grid/releases" target="_blank"><img src="https://img.shields.io/badge/version-v3.1.2-blue?style=for-the-badge&logo=none" alt="grid version" /></a>&nbsp;<a href="https://reactjs.org/" target="_blank"><img src="https://img.shields.io/badge/React-16+-00ADD8?style=for-the-badge&logo=react" alt="react version" /></a>&nbsp;<a href="https://www.typescriptlang.org/" target="_blank"><img src="https://img.shields.io/badge/Typescript-grey?style=for-the-badge&logo=typescript" alt="react version" /></a>&nbsp;<a href="https://bundlephobia.com/package/@glideapps/glide-data-grid" target="_blank"><img src="https://img.shields.io/badge/Bundle_Size-43.1kb-success?style=for-the-badge&logo=none" alt="go cover" /></a>&nbsp;<img src="https://img.shields.io/badge/license-mit-red?style=for-the-badge&logo=none" alt="license" />&nbsp;<a href="https://www.glideapps.com/jobs" target="_blank"><img src="https://img.shields.io/badge/❤_Made_by-Glide-11CCE5?style=for-the-badge&logo=none" alt="glide" /></a></p>
88

99
![Data Grid](https://raw.githubusercontent.com/glideapps/glide-data-grid/master/data-grid.jpg)
1010

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@glideapps/glide-data-grid",
3-
"version": "3.1.1-beta3",
3+
"version": "3.1.2",
44
"description": "Super fast, pure canvas Data Grid Editor",
55
"main": "dist/js/index.js",
66
"types": "dist/ts/index.d.ts",

core/src/data-grid/data-grid-lib.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,8 @@ async function clearCacheOnLoad() {
174174

175175
void clearCacheOnLoad();
176176

177-
export function measureTextCached(s: string, ctx: CanvasRenderingContext2D): TextMetrics {
178-
// return ctx.measureText(s).width;
179-
const key = `${s}_${ctx.font}`;
177+
export function measureTextCached(s: string, ctx: CanvasRenderingContext2D, font?: string): TextMetrics {
178+
const key = `${s}_${font ?? ctx.font}`;
180179
let metrics = metricsCache[key];
181180
if (metrics === undefined) {
182181
metrics = ctx.measureText(s);
@@ -230,7 +229,7 @@ export function drawTextCell(args: BaseDrawArgs, data: string) {
230229
const dir = direction(data);
231230

232231
if (dir === "rtl") {
233-
const textWidth = measureTextCached(data, ctx).width;
232+
const textWidth = measureTextCached(data, ctx, `${theme.baseFontStyle} ${theme.fontFamily}`).width;
234233
ctx.fillText(data, x + w - theme.cellHorizontalPadding - textWidth + 0.5, y + h / 2);
235234
} else {
236235
ctx.fillText(data, x + theme.cellHorizontalPadding + 0.5, y + h / 2);
@@ -332,7 +331,7 @@ export function drawMarkerRowCell(
332331
}
333332
if (markerKind === "number" || (markerKind === "both" && !checked)) {
334333
const text = (index + 1).toString();
335-
const w = measureTextCached(text, ctx).width;
334+
const w = measureTextCached(text, ctx, `9px ${theme.fontFamily}`).width;
336335

337336
const start = x + (width - w) / 2;
338337
if (markerKind === "both" && hoverAmount !== 0) {
@@ -430,7 +429,7 @@ export function drawBubbles(args: BaseDrawArgs, data: readonly string[]) {
430429
const renderBoxes: { x: number; width: number }[] = [];
431430
for (const s of data) {
432431
if (renderX > x + w) break;
433-
const textWidth = measureTextCached(s, ctx).width;
432+
const textWidth = measureTextCached(s, ctx, `${theme.baseFontStyle} ${theme.fontFamily}`).width;
434433
renderBoxes.push({
435434
x: renderX,
436435
width: textWidth,
@@ -470,7 +469,7 @@ export function drawDrilldownCell(args: BaseDrawArgs, data: readonly DrilldownCe
470469
const renderBoxes: { x: number; width: number }[] = [];
471470
for (const el of data) {
472471
if (renderX > x + w) break;
473-
const textWidth = measureTextCached(el.text, ctx).width;
472+
const textWidth = measureTextCached(el.text, ctx, `${theme.baseFontStyle} ${theme.fontFamily}`).width;
474473
let imgWidth = 0;
475474
if (el.img !== undefined) {
476475
const img = imageLoader.loadOrGetImage(el.img, col, row);

core/src/data-grid/data-grid-types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export type DrawCustomCellCallback = (args: {
8383
imageLoader: ImageWindowLoader;
8484
}) => boolean;
8585

86-
export const enum GridCellKind {
86+
export enum GridCellKind {
8787
Uri = "uri",
8888
Text = "text",
8989
Image = "image",
@@ -98,7 +98,7 @@ export const enum GridCellKind {
9898
Custom = "custom",
9999
}
100100

101-
export const enum GridColumnIcon {
101+
export enum GridColumnIcon {
102102
HeaderRowID = "headerRowID",
103103
HeaderCode = "headerCode",
104104
HeaderNumber = "headerNumber",
@@ -384,7 +384,7 @@ export interface UriCell extends BaseGridCell {
384384
readonly readonly?: boolean;
385385
}
386386

387-
export const enum InnerGridCellKind {
387+
export enum InnerGridCellKind {
388388
NewRow = "new-row",
389389
Marker = "marker",
390390
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "root",
3-
"version": "3.1.1",
3+
"version": "3.1.2",
44
"scripts": {
55
"bootstrap": "./bootstrap.sh",
66
"build": "./build-all.sh",

0 commit comments

Comments
 (0)