rewrite clipboard handling (#689)
This commit is contained in:
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");
|
||||
|
Reference in New Issue
Block a user