From 6bdffc8a65cd1c9dcc2fd71d593c2279ede1e25c Mon Sep 17 00:00:00 2001 From: Matthew Huebert Date: Mon, 14 Aug 2023 14:34:45 -0600 Subject: [PATCH] add Bug Report link, fix command bar --- editor2/src/main/maria/cloud/menubar.cljs | 7 ++++++- editor2/src/main/maria/cloud/persistence.cljs | 5 +++-- .../src/main/maria/editor/command_bar.cljs | 4 ++-- editor2/src/main/maria/editor/keymaps.cljs | 15 +++++++------- editor2/src/main/maria/editor/util.cljc | 20 +++++++++---------- editor2/src/maria.cloud.css | 9 ++++++--- 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/editor2/src/main/maria/cloud/menubar.cljs b/editor2/src/main/maria/cloud/menubar.cljs index bf14f69f..4e282aaf 100644 --- a/editor2/src/main/maria/cloud/menubar.cljs +++ b/editor2/src/main/maria/cloud/menubar.cljs @@ -46,6 +46,7 @@ (def trigger-classes (v/classes ["px-1 h-7 bg-transparent rounded" "hover:bg-zinc-200" + "text-zinc-500 visited:text-zinc-500 hover:text-zinc-700 " "data-[highlighted]:bg-zinc-200" "data-[delayed-open]:bg-zinc-200" "data-[state*=open]:bg-zinc-200"])) @@ -187,7 +188,11 @@ menubar-content [:div.flex-grow] #_[:a.text-black.inline-flex.items-center {:class trigger-classes - :href "/"} [icons/home "w-4 h-4"]] + :href "/"} [icons/home "w-4 h-4"]] + [:a.cursor-pointer.p-1.no-underline + {:href "https://github.com/mhuebert/maria/issues" + :target "_blank" + :class trigger-classes} "Bug Report"] (let [cmd (keymaps/resolve-command :file/new)] [:div.cursor-pointer.p-1 {:class [trigger-classes diff --git a/editor2/src/main/maria/cloud/persistence.cljs b/editor2/src/main/maria/cloud/persistence.cljs index 06641f74..5a42313a 100644 --- a/editor2/src/main/maria/cloud/persistence.cljs +++ b/editor2/src/main/maria/cloud/persistence.cljs @@ -183,7 +183,7 @@ (keymaps/register-commands! {:file/new {:bindings [:Shift-Mod-b] :f (fn [_] (new-blank-file!))} - :file/duplicate {:when (every-pred :ProseView :file/id) + :file/duplicate {:when (every-pred :file/id :ProseView) ;; create a new gist with contents of current doc. :f (fn [{:keys [ProseView file/id]}] (let [source (state-source (j/get ProseView :state))] @@ -197,7 +197,8 @@ (commands/prose:replace-doc ProseView source)))} :file/save {:bindings [:Ctrl-s] :when (fn [{:keys [file/id]}] - (and (gh/get-token) + (and id + (gh/get-token) (writable? id))) ;; if local, create a new gist and then navigate there. ;; if gist, save a new revision of that gist. diff --git a/editor2/src/main/maria/editor/command_bar.cljs b/editor2/src/main/maria/editor/command_bar.cljs index 6b7d44e2..9330f06f 100644 --- a/editor2/src/main/maria/editor/command_bar.cljs +++ b/editor2/src/main/maria/editor/command_bar.cljs @@ -53,8 +53,8 @@ (reset! !search "") (keymaps/hide-command-bar! {:command-bar/element @!input})) :onValueChange #(reset! !search %) - :ref #(do (keymaps/add-context :command-bar/element %) - (reset! !input %))}]] + :ref #(do (reset! !input %) + (keymaps/add-context :command-bar/element %))}]] [:div.absolute.h7.flex.items-center.right-2.top-0.bottom-0.placeholder {:class (when (and @!open (not (str/blank? @!search))) "opacity-0")} (-> (:editor/toggle-command-bar keymaps/commands:global) diff --git a/editor2/src/main/maria/editor/keymaps.cljs b/editor2/src/main/maria/editor/keymaps.cljs index 36676359..5d134839 100644 --- a/editor2/src/main/maria/editor/keymaps.cljs +++ b/editor2/src/main/maria/editor/keymaps.cljs @@ -375,12 +375,12 @@ false)} :editor/toggle-command-bar {:bindings [:Mod-k] :kind :global + :hidden? true :prepare (fn [cmd ctx] - (merge cmd (if (command-bar-open? ctx) - {:title "Hide command bar" - :f hide-command-bar!} - {:title "Show command bar" - :f show-command-bar!})))} + (assoc cmd :f + (if (command-bar-open? ctx) + hide-command-bar! + show-command-bar!)))} :prose/toggle-prose-visibility {:kind :global :when :ProseView :prepare (fn [cmd {:keys [ProseView]}] @@ -478,8 +478,9 @@ (let [cmd (if (keyword? cmd) (@!command-registry cmd) cmd) - cmd (assoc cmd :active? (active? context cmd)) - cmd (if-let [prepare (:prepare cmd)] + is-active (active? context cmd) + cmd (assoc cmd :active? is-active) + cmd (if-let [prepare (and is-active (:prepare cmd))] (prepare cmd context) cmd)] (assoc cmd :context context)))) diff --git a/editor2/src/main/maria/editor/util.cljc b/editor2/src/main/maria/editor/util.cljc index b7d1bf11..5054bfce 100644 --- a/editor2/src/main/maria/editor/util.cljc +++ b/editor2/src/main/maria/editor/util.cljc @@ -122,16 +122,16 @@ second)) (defn truncate-segmented [s n ellipsis] - (let [segments (str/split s #"\s+") - segments-truncated (reduce (fn [out segment] - (if (>= (count out) n) - (reduced out) - (str out " " segment))) - (first segments) - (rest segments))] - (if (< (count segments-truncated) (count s)) - (str segments-truncated ellipsis) - segments-truncated))) + (let [segments (str/split s #"[\s\n]+") + [truncated? s] (reduce (fn [[_ out] segment] + (if (>= (count out) n) + (reduced [true out]) + [false (str out " " segment)])) + [false (first segments)] + (rest segments))] + (if truncated? + (str s ellipsis) + s))) (defn slug [title] (-> title diff --git a/editor2/src/maria.cloud.css b/editor2/src/maria.cloud.css index 30963539..e5c9880f 100644 --- a/editor2/src/maria.cloud.css +++ b/editor2/src/maria.cloud.css @@ -20,8 +20,13 @@ .prose code::before, .prose code::after { content: none; } + a { + @apply underline text-blue-600 hover:text-blue-800 visited:text-purple-700 + } } +@layer components { +} @layer utilities { ::placeholder, .placeholder { @@ -199,9 +204,7 @@ h5 { align-self: end; } -a { - @apply underline text-blue-600 hover:text-blue-800 visited:text-purple-700 -} + /* Radix UI */