mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
rewrite clipboard handling (#689)
This commit is contained in:
parent
dab35c9033
commit
954d805cb3
6 changed files with 259 additions and 99 deletions
17
src/utils.ts
17
src/utils.ts
|
@ -28,6 +28,7 @@ export function isInputLike(
|
|||
| HTMLInputElement
|
||||
| HTMLTextAreaElement
|
||||
| HTMLSelectElement
|
||||
| HTMLBRElement
|
||||
| HTMLDivElement {
|
||||
return (
|
||||
(target instanceof HTMLElement && target.dataset.type === "wysiwyg") ||
|
||||
|
@ -38,6 +39,22 @@ export function isInputLike(
|
|||
);
|
||||
}
|
||||
|
||||
export function isWritableElement(
|
||||
target: Element | EventTarget | null,
|
||||
): target is
|
||||
| HTMLInputElement
|
||||
| HTMLTextAreaElement
|
||||
| HTMLBRElement
|
||||
| HTMLDivElement {
|
||||
return (
|
||||
(target instanceof HTMLElement && target.dataset.type === "wysiwyg") ||
|
||||
target instanceof HTMLBRElement || // newline in wysiwyg
|
||||
target instanceof HTMLTextAreaElement ||
|
||||
(target instanceof HTMLInputElement &&
|
||||
(target.type === "text" || target.type === "number"))
|
||||
);
|
||||
}
|
||||
|
||||
// https://github.com/grassator/canvas-text-editor/blob/master/lib/FontMetrics.js
|
||||
export function measureText(text: string, font: string) {
|
||||
const line = document.createElement("div");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue