mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
chore: [Idle detection] Deal with users on systems that don't handle emoji (#2941)
* Deal with users on systems that don't handle emoji
* Leave no trailing space
* Move function to utils, and actually call it 🤣
Chapeau, TypeScript!
* Use grinning face instead of koala
* Tweak globalAlpha
This commit is contained in:
parent
6aa22bada8
commit
1a67642fd1
2 changed files with 39 additions and 9 deletions
17
src/utils.ts
17
src/utils.ts
|
@ -369,3 +369,20 @@ export const getVersion = () => {
|
|||
DEFAULT_VERSION
|
||||
);
|
||||
};
|
||||
|
||||
// Adapted from https://github.com/Modernizr/Modernizr/blob/master/feature-detects/emoji.js
|
||||
export const supportsEmoji = () => {
|
||||
const canvas = document.createElement("canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
if (!ctx) {
|
||||
return false;
|
||||
}
|
||||
const offset = 12;
|
||||
ctx.fillStyle = "#f00";
|
||||
ctx.textBaseline = "top";
|
||||
ctx.font = "32px Arial";
|
||||
// Modernizr used 🐨, but it is sort of supported on Windows 7.
|
||||
// Luckily 😀 isn't supported.
|
||||
ctx.fillText("😀", 0, 0);
|
||||
return ctx.getImageData(offset, offset, 1, 1).data[0] !== 0;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue