feat:pdf highlight drag & drop (#8103)

* refactor(pdf): names
* improve(pdf): support highlight region draggable
* improve(pdf): unused class of pdf container
* improve(pdf): unused class of pdf container
* fix(pdf): ensure highlight block ref exists when draging to editor & whiteboard region

Co-authored-by: Bad3r <bad3r@protonmail.com>
Co-authored-by: Andelf <andelf@gmail.com>
This commit is contained in:
Charlie
2023-01-12 01:25:10 +08:00
committed by GitHub
parent ba69f13d34
commit 401c416484
4 changed files with 98 additions and 66 deletions

View File

@@ -184,25 +184,26 @@
([pdf hl] (ensure-ref-block! pdf hl nil))
([pdf-current {:keys [id content page properties]} insert-opts]
(when-let [ref-page (and pdf-current (resolve-ref-page pdf-current))]
(if-let [ref-block (db-model/query-block-by-uuid id)]
(do
(println "[existed ref block]" ref-block)
ref-block)
(let [text (:text content)
wrap-props #(if-let [stamp (:image content)]
(assoc % :hl-type "area" :hl-stamp stamp) %)]
(let [ref-block (db-model/query-block-by-uuid id)]
(if-not (nil? (:block/content ref-block))
(do
(println "[existed ref block]" ref-block)
ref-block)
(let [text (:text content)
wrap-props #(if-let [stamp (:image content)]
(assoc % :hl-type "area" :hl-stamp stamp) %)]
(when (string? text)
(editor-handler/api-insert-new-block!
text (merge {:page (:block/name ref-page)
:custom-uuid id
:properties (wrap-props
{:ls-type "annotation"
:hl-page page
:hl-color (:color properties)
;; force custom uuid
:id (str id)})}
insert-opts))))))))
(when (string? text)
(editor-handler/api-insert-new-block!
text (merge {:page (:block/name ref-page)
:custom-uuid id
:properties (wrap-props
{:ls-type "annotation"
:hl-page page
:hl-color (:color properties)
;; force custom uuid
:id (str id)})}
insert-opts)))))))))
(defn del-ref-block!
[{:keys [id]}]