Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(client/ts): port services/image
Elian Doranf15bebd330e5
diff --git a/src/public/app/services/image.js b/src/public/app/services/image.tssimilarity index 66%rename from src/public/app/services/image.jsrename to src/public/app/services/image.tsindex f732e843c1..deedc7c0e7 100644--- a/src/public/app/services/image.js+++ b/src/public/app/services/image.ts@@ -1,6 +1,7 @@+import { t } from "./i18n.js";import toastService from "./toast.js";-function copyImageReferenceToClipboard($imageWrapper) {+function copyImageReferenceToClipboard($imageWrapper: JQuery<HTMLElement>) {try {$imageWrapper.attr('contenteditable', 'true');selectImage($imageWrapper.get(0));@@ -14,17 +15,21 @@ function copyImageReferenceToClipboard($imageWrapper) {}}finally {- window.getSelection().removeAllRanges();+ window.getSelection()?.removeAllRanges();$imageWrapper.removeAttr('contenteditable');}}-function selectImage(element) {+function selectImage(element: HTMLElement | undefined) {+ if (!element) {+ return;+ }+const selection = window.getSelection();const range = document.createRange();range.selectNodeContents(element);- selection.removeAllRanges();- selection.addRange(range);+ selection?.removeAllRanges();+ selection?.addRange(range);}export default {