mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Extract scene functions to their respective modules (#208)
- Also, extract utilities into utils module -- capitalizeString, getDateTime, isInputLike
This commit is contained in:
parent
01805f734d
commit
86a1c29eec
12 changed files with 695 additions and 530 deletions
25
src/utils.ts
Normal file
25
src/utils.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
export function getDateTime() {
|
||||
const date = new Date();
|
||||
const year = date.getFullYear();
|
||||
const month = date.getMonth() + 1;
|
||||
const day = date.getDate();
|
||||
const hr = date.getHours();
|
||||
const min = date.getMinutes();
|
||||
const secs = date.getSeconds();
|
||||
|
||||
return `${year}${month}${day}${hr}${min}${secs}`;
|
||||
}
|
||||
|
||||
export function capitalizeString(str: string) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
|
||||
export function isInputLike(
|
||||
target: Element | EventTarget | null
|
||||
): target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement {
|
||||
return (
|
||||
target instanceof HTMLInputElement ||
|
||||
target instanceof HTMLTextAreaElement ||
|
||||
target instanceof HTMLSelectElement
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue