fix: don't show action bar when clicking property value

Also, clear selection when clicking property value
This commit is contained in:
Tienson Qin
2025-05-20 19:14:25 +08:00
parent 09b6d37894
commit 44bf54ba08
3 changed files with 16 additions and 11 deletions

View File

@@ -931,7 +931,11 @@
(defn- on-mouse-up
[e]
(when-not (.closest (.-target e) ".block-control-wrap")
(when-not (or (.closest (.-target e) ".block-control-wrap")
(.closest (.-target e) "button")
(.closest (.-target e) "input")
(.closest (.-target e) "textarea")
(.closest (.-target e) "a"))
(editor-handler/show-action-bar!)))
(rum/defcs ^:large-vars/cleanup-todo root-container < rum/reactive

View File

@@ -1156,7 +1156,7 @@
(if editing?
(popup-content nil)
(let [show! (fn [e]
(util/stop e)
(state/clear-selection!)
(let [target (when e (.-target e))]
(when-not (or config/publishing?
(util/shift-key? e)
@@ -1171,7 +1171,7 @@
{:ref *el
:id trigger-id
:tabIndex 0
:on-click show!
:on-pointer-down show!
:on-key-down (fn [e]
(case (util/ekey e)
("Backspace" "Delete")

View File

@@ -2,6 +2,7 @@
(:require [clojure.set :as set]
[clojure.string :as string]
[clojure.walk :as w]
[dommy.core :as d]
[dommy.core :as dom]
[electron.ipc :as ipc]
[frontend.commands :as commands]
@@ -1242,15 +1243,20 @@
(defonce *action-bar-timeout (atom nil))
(defn popup-exists?
[id]
(some->> (shui-popup/get-popups)
(some #(some-> % (:id) (str) (string/includes? (str id))))))
(defn show-action-bar!
[& {:keys [delay]
:or {delay 200}}]
(when (config/db-based-graph?)
(when (and (config/db-based-graph?) (not (popup-exists? :selection-action-bar)))
(when-let [timeout @*action-bar-timeout]
(js/clearTimeout timeout))
(state/pub-event! [:editor/hide-action-bar])
(when (seq (state/get-selection-blocks))
(when (seq (remove (fn [b] (d/has-class? b "ls-table-cell"))
(state/get-selection-blocks)))
(let [timeout (js/setTimeout #(state/pub-event! [:editor/show-action-bar]) delay)]
(reset! *action-bar-timeout timeout)))))
@@ -3325,11 +3331,6 @@
(cursor/select-up-down input direction anchor cursor-rect)))
(select-block-up-down direction))))
(defn popup-exists?
[id]
(some->> (shui-popup/get-popups)
(some #(some-> % (:id) (str) (string/includes? (str id))))))
(defn editor-commands-popup-exists?
[]
(popup-exists? "editor.commands"))