mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
improve clipboard handling (#596)
* improve clipboard handling * fix regression of not defocusing tool icons
This commit is contained in:
parent
de68561df5
commit
26048ee469
4 changed files with 38 additions and 21 deletions
21
src/utils.ts
21
src/utils.ts
|
@ -14,14 +14,25 @@ export function capitalizeString(str: string) {
|
|||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
|
||||
export function isToolIcon(
|
||||
target: Element | EventTarget | null,
|
||||
): target is HTMLElement {
|
||||
return target instanceof HTMLElement && target.className.includes("ToolIcon");
|
||||
}
|
||||
|
||||
export function isInputLike(
|
||||
target: Element | EventTarget | null,
|
||||
): target is HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement {
|
||||
): target is
|
||||
| HTMLInputElement
|
||||
| HTMLTextAreaElement
|
||||
| HTMLSelectElement
|
||||
| HTMLDivElement {
|
||||
return (
|
||||
(target instanceof HTMLElement && target.dataset.type === "wysiwyg") ||
|
||||
target instanceof HTMLInputElement ||
|
||||
target instanceof HTMLTextAreaElement ||
|
||||
target instanceof HTMLSelectElement
|
||||
((target instanceof HTMLElement && target.dataset.type === "wysiwyg") ||
|
||||
target instanceof HTMLInputElement ||
|
||||
target instanceof HTMLTextAreaElement ||
|
||||
target instanceof HTMLSelectElement) &&
|
||||
!isToolIcon(target)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue