* Remove the "Input the text you want to type with this macro action." sentence from the type text macro action. * Move pointer and Scroll enhancement * remove the extra vertical space above the mouse buttons * macro delay enhancement * not allow user select on a few elements * fill the macro, keymap name the all space in the header
18 lines
387 B
TypeScript
18 lines
387 B
TypeScript
let canvas: HTMLCanvasElement;
|
|
|
|
export function getContentWidth(style: CSSStyleDeclaration, text: string): number {
|
|
if (!text) {
|
|
return 0;
|
|
}
|
|
|
|
if (!canvas) {
|
|
canvas = document.createElement('canvas');
|
|
}
|
|
|
|
const context = canvas.getContext('2d');
|
|
context.font = style.font;
|
|
const metrics = context.measureText(text);
|
|
|
|
return metrics.width;
|
|
}
|