generated from NekitCorp/chrome-extension-svelte-typescript-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
94 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,26 @@ | ||
import type {Talk} from "../storage"; | ||
|
||
export type FocusableTarget = HTMLTextAreaElement | HTMLInputElement | ||
|
||
export const HIDDEN_KEYS = ['id', '__revision']; | ||
|
||
export const getTalkName = (talk: Talk) => { | ||
return talk.title || talk.Title || talk.id; | ||
} | ||
|
||
export const publicKeysOnly = (key: string) => !HIDDEN_KEYS.includes(key); | ||
export const publicKeysOnly = (key: string) => !HIDDEN_KEYS.includes(key); | ||
|
||
export const isElementVisible = (el: Element) => { | ||
const style = window.getComputedStyle(el); | ||
return !((style.display === 'none') || (style.visibility === 'hidden')) | ||
} | ||
|
||
export const simulateInput = (element: FocusableTarget, text: string) => { | ||
element.focus() | ||
element.select() | ||
try { | ||
document.execCommand("insertText", false, text) | ||
} catch (e) { | ||
console.error("is document.execCommand already disabled in your browser? Tough luck.", e); | ||
} | ||
} |