1
0
Эх сурвалжийг харах

improve(plugin): add api of query element rect data from host

charlie 3 жил өмнө
parent
commit
2b826f17de

+ 8 - 0
libs/src/LSPlugin.ts

@@ -360,10 +360,18 @@ export interface IAppProxy {
 
   // ui
   queryElementById: (id: string) => Promise<string | boolean>
+  queryElementRect: (selector: string) => Promise<DOMRectReadOnly | null>
+
+  /**
+   * @deprecated
+   * @param content
+   * @param status
+   */
   showMsg: (
     content: string,
     status?: 'success' | 'warning' | 'error' | string
   ) => void
+  
   setZoomFactor: (factor: number) => void
   setFullScreen: (flag: boolean | 'toggle') => void
   setLeftSidebarVisible: (flag: boolean | 'toggle') => void

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
resources/js/lsplugin.core.js


+ 6 - 1
src/main/logseq/api.cljs

@@ -796,9 +796,14 @@
 ;; helpers
 (defn ^:export query_element_by_id
   [id]
-  (let [^js el (gdom/getElement id)]
+  (when-let [^js el (gdom/getElement id)]
     (if el (str (.-tagName el) "#" id) false)))
 
+(defn ^:export query_element_rect
+  [selector]
+  (when-let [^js el (js/document.querySelector selector)]
+    (bean/->js (.toJSON (.getBoundingClientRect el)))))
+
 (defn ^:export set_focused_settings
   [pid]
   (when-let [plugin (state/get-plugin-by-id pid)]

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно