Browse Source

Remove deprecated :editor/command-trigger option

This option has been deprecated for a couple months
Gabriel Horner 2 years ago
parent
commit
4c2e61cbd3

+ 14 - 13
src/main/frontend/commands.cljs

@@ -30,6 +30,7 @@
 (defonce angle-bracket "<")
 (defonce angle-bracket "<")
 (defonce hashtag "#")
 (defonce hashtag "#")
 (defonce colon ":")
 (defonce colon ":")
+(defonce command-trigger "/")
 (defonce *current-command (atom nil))
 (defonce *current-command (atom nil))
 
 
 (def query-doc
 (def query-doc
@@ -52,7 +53,7 @@
     "."]])
     "."]])
 
 
 (defn link-steps []
 (defn link-steps []
-  [[:editor/input (str (state/get-editor-command-trigger) "link")]
+  [[:editor/input (str command-trigger "link")]
    [:editor/show-input [{:command :link
    [:editor/show-input [{:command :link
                          :id :link
                          :id :link
                          :placeholder "Link"
                          :placeholder "Link"
@@ -62,7 +63,7 @@
                          :placeholder "Label"}]]])
                          :placeholder "Label"}]]])
 
 
 (defn image-link-steps []
 (defn image-link-steps []
-  [[:editor/input (str (state/get-editor-command-trigger) "link")]
+  [[:editor/input (str command-trigger "link")]
    [:editor/show-input [{:command :image-link
    [:editor/show-input [{:command :image-link
                          :id :link
                          :id :link
                          :placeholder "Link"
                          :placeholder "Link"
@@ -72,7 +73,7 @@
                          :placeholder "Label"}]]])
                          :placeholder "Label"}]]])
 
 
 (defn zotero-steps []
 (defn zotero-steps []
-  [[:editor/input (str (state/get-editor-command-trigger) "zotero")]
+  [[:editor/input (str command-trigger "zotero")]
    [:editor/show-zotero]])
    [:editor/show-zotero]])
 
 
 (def *extend-slash-commands (atom []))
 (def *extend-slash-commands (atom []))
@@ -96,19 +97,19 @@
   [type]
   [type]
   (let [template (util/format "@@%s: @@"
   (let [template (util/format "@@%s: @@"
                               type)]
                               type)]
-    [[:editor/input template {:last-pattern (state/get-editor-command-trigger)
+    [[:editor/input template {:last-pattern command-trigger
                               :backward-pos 2}]]))
                               :backward-pos 2}]]))
 
 
 (defn embed-page
 (defn embed-page
   []
   []
   (conj
   (conj
-   [[:editor/input "{{embed [[]]}}" {:last-pattern (state/get-editor-command-trigger)
+   [[:editor/input "{{embed [[]]}}" {:last-pattern command-trigger
                                      :backward-pos 4}]]
                                      :backward-pos 4}]]
    [:editor/search-page :embed]))
    [:editor/search-page :embed]))
 
 
 (defn embed-block
 (defn embed-block
   []
   []
-  [[:editor/input "{{embed (())}}" {:last-pattern (state/get-editor-command-trigger)
+  [[:editor/input "{{embed (())}}" {:last-pattern command-trigger
                                     :backward-pos 4}]
                                     :backward-pos 4}]
    [:editor/search-block :embed]])
    [:editor/search-block :embed]])
 
 
@@ -229,9 +230,9 @@
      ["Image link" (image-link-steps) "Create a HTTP link to a image"]
      ["Image link" (image-link-steps) "Create a HTTP link to a image"]
      (when (state/markdown?)
      (when (state/markdown?)
        ["Underline" [[:editor/input "<ins></ins>"
        ["Underline" [[:editor/input "<ins></ins>"
-                      {:last-pattern (state/get-editor-command-trigger)
+                      {:last-pattern command-trigger
                        :backward-pos 6}]] "Create a underline text decoration"])
                        :backward-pos 6}]] "Create a underline text decoration"])
-     ["Template" [[:editor/input (state/get-editor-command-trigger) nil]
+     ["Template" [[:editor/input command-trigger nil]
                   [:editor/search-template]] "Insert a created template here"]
                   [:editor/search-template]] "Insert a created template here"]
      (cond
      (cond
        (and (util/electron?) (config/local-db? (state/get-current-repo)))
        (and (util/electron?) (config/local-db? (state/get-current-repo)))
@@ -239,7 +240,7 @@
        ["Upload an asset" [[:editor/click-hidden-file-input :id]] "Upload file types like image, pdf, docx, etc.)"])]
        ["Upload an asset" [[:editor/click-hidden-file-input :id]] "Upload file types like image, pdf, docx, etc.)"])]
 
 
        ;; ["Upload an image" [[:editor/click-hidden-file-input :id]]]
        ;; ["Upload an image" [[:editor/click-hidden-file-input :id]]]
-       
+
 
 
     (headings)
     (headings)
 
 
@@ -290,12 +291,12 @@
                  text)) "Draw a graph with Excalidraw"]
                  text)) "Draw a graph with Excalidraw"]
      ["Embed HTML " (->inline "html")]
      ["Embed HTML " (->inline "html")]
 
 
-     ["Embed Video URL" [[:editor/input "{{video }}" {:last-pattern (state/get-editor-command-trigger)
+     ["Embed Video URL" [[:editor/input "{{video }}" {:last-pattern command-trigger
                                                       :backward-pos 2}]]]
                                                       :backward-pos 2}]]]
 
 
      ["Embed Youtube timestamp" [[:youtube/insert-timestamp]]]
      ["Embed Youtube timestamp" [[:youtube/insert-timestamp]]]
 
 
-     ["Embed Twitter tweet" [[:editor/input "{{tweet }}" {:last-pattern (state/get-editor-command-trigger)
+     ["Embed Twitter tweet" [[:editor/input "{{tweet }}" {:last-pattern command-trigger
                                                           :backward-pos 2}]]]]
                                                           :backward-pos 2}]]]]
 
 
     @*extend-slash-commands
     @*extend-slash-commands
@@ -335,7 +336,7 @@
   (when-let [input (gdom/getElement id)]
   (when-let [input (gdom/getElement id)]
     (let [last-pattern (when-not (= last-pattern :skip-check)
     (let [last-pattern (when-not (= last-pattern :skip-check)
                          (when-not backward-truncate-number
                          (when-not backward-truncate-number
-                          (or last-pattern (state/get-editor-command-trigger))))
+                           (or last-pattern command-trigger)))
           edit-content (gobj/get input "value")
           edit-content (gobj/get input "value")
           current-pos (cursor/pos input)
           current-pos (cursor/pos input)
           current-pos (or
           current-pos (or
@@ -527,7 +528,7 @@
       (let [edit-content (gobj/get current-input "value")
       (let [edit-content (gobj/get current-input "value")
             current-pos (cursor/pos current-input)
             current-pos (cursor/pos current-input)
             prefix (subs edit-content 0 current-pos)
             prefix (subs edit-content 0 current-pos)
-            prefix (util/replace-last (state/get-editor-command-trigger) prefix "" (boolean space?))
+            prefix (util/replace-last command-trigger prefix "" (boolean space?))
             new-value (str prefix
             new-value (str prefix
                            (subs edit-content current-pos))]
                            (subs edit-content current-pos))]
         (state/set-block-content-and-last-pos! input-id
         (state/set-block-content-and-last-pos! input-id

+ 1 - 1
src/main/frontend/handler/common/config_edn.cljs

@@ -92,7 +92,7 @@ nested keys or positional errors e.g. tuples"
   (let [body (try (edn/read-string content)
   (let [body (try (edn/read-string content)
                (catch :default _ ::failed-to-detect))
                (catch :default _ ::failed-to-detect))
         warnings {:editor/command-trigger
         warnings {:editor/command-trigger
-                  "Will no longer be supported soon. Please use '/' and report bugs on it."}]
+                  "is no longer supported. Please use '/' and report bugs on it."}]
     (cond
     (cond
       (= body ::failed-to-detect)
       (= body ::failed-to-detect)
       (log/info :msg "Skip deprecation check since config is not valid edn")
       (log/info :msg "Skip deprecation check since config is not valid edn")

+ 8 - 8
src/main/frontend/handler/editor.cljs

@@ -1536,7 +1536,7 @@
                                        (if file-obj (.-name file-obj) (if image? "image" "asset"))
                                        (if file-obj (.-name file-obj) (if image? "image" "asset"))
                                        image?)
                                        image?)
                   format
                   format
-                  {:last-pattern (if drop-or-paste? "" (state/get-editor-command-trigger))
+                  {:last-pattern (if drop-or-paste? "" commands/command-trigger)
                    :restore?     true
                    :restore?     true
                    :command      :insert-asset})))))
                    :command      :insert-asset})))))
           (p/finally
           (p/finally
@@ -1675,7 +1675,7 @@
           last-command (and last-slash-caret-pos (subs edit-content last-slash-caret-pos pos))]
           last-command (and last-slash-caret-pos (subs edit-content last-slash-caret-pos pos))]
       (when (> pos 0)
       (when (> pos 0)
         (or
         (or
-         (and (= (state/get-editor-command-trigger) (util/nth-safe edit-content (dec pos)))
+         (and (= commands/command-trigger (util/nth-safe edit-content (dec pos)))
               @commands/*initial-commands)
               @commands/*initial-commands)
          (and last-command
          (and last-command
               (commands/get-matched-commands last-command)))))
               (commands/get-matched-commands last-command)))))
@@ -1793,7 +1793,7 @@
                id
                id
                (get-link format link label)
                (get-link format link label)
                format
                format
-               {:last-pattern (str (state/get-editor-command-trigger) "link")
+               {:last-pattern (str commands/command-trigger "link")
                 :command :link})))
                 :command :link})))
 
 
     :image-link (let [{:keys [link label]} m]
     :image-link (let [{:keys [link label]} m]
@@ -1802,7 +1802,7 @@
                      id
                      id
                      (get-image-link format link label)
                      (get-image-link format link label)
                      format
                      format
-                     {:last-pattern (str (state/get-editor-command-trigger) "link")
+                     {:last-pattern (str commands/command-trigger "link")
                       :command :image-link})))
                       :command :image-link})))
 
 
     nil)
     nil)
@@ -1879,7 +1879,7 @@
         (-> (p/delay 10)
         (-> (p/delay 10)
             (p/then #(state/pub-event! [:editor/toggle-own-number-list edit-block]))))
             (p/then #(state/pub-event! [:editor/toggle-own-number-list edit-block]))))
 
 
-      (and (= last-input-char (state/get-editor-command-trigger))
+      (and (= last-input-char commands/command-trigger)
            (or (re-find #"(?m)^/" (str (.-value input))) (start-of-new-word? input pos)))
            (or (re-find #"(?m)^/" (str (.-value input))) (start-of-new-word? input pos)))
       (do
       (do
         (state/set-editor-action-data! {:pos (cursor/get-caret-pos input)})
         (state/set-editor-action-data! {:pos (cursor/get-caret-pos input)})
@@ -2730,7 +2730,7 @@
             (delete-block! repo false))))
             (delete-block! repo false))))
 
 
       (and (> current-pos 1)
       (and (> current-pos 1)
-           (= (util/nth-safe value (dec current-pos)) (state/get-editor-command-trigger)))
+           (= (util/nth-safe value (dec current-pos)) commands/command-trigger))
       (do
       (do
         (util/stop e)
         (util/stop e)
         (commands/restore-state)
         (commands/restore-state)
@@ -3014,8 +3014,8 @@
                (util/event-is-composing? e true)])]
                (util/event-is-composing? e true)])]
         (cond
         (cond
           ;; When you type something after /
           ;; When you type something after /
-          (and (= :commands (state/get-editor-action)) (not= k (state/get-editor-command-trigger)))
-          (if (= (state/get-editor-command-trigger) (second (re-find #"(\S+)\s+$" value)))
+          (and (= :commands (state/get-editor-action)) (not= k commands/command-trigger))
+          (if (= commands/command-trigger (second (re-find #"(\S+)\s+$" value)))
             (state/clear-editor-action!)
             (state/clear-editor-action!)
             (let [matched-commands (get-matched-commands input)]
             (let [matched-commands (get-matched-commands input)]
               (if (seq matched-commands)
               (if (seq matched-commands)

+ 0 - 9
src/main/frontend/state.cljs

@@ -426,15 +426,6 @@ should be done through this fn in order to get global config and config defaults
 
 
        (get-in @state [:me :preferred_format] "markdown")))))
        (get-in @state [:me :preferred_format] "markdown")))))
 
 
-;; TODO: consider adding a pane in Settings to set this through the GUI (rather
-;; than having to go through the config.edn file)
-(defn get-editor-command-trigger
-  ([] (get-editor-command-trigger (get-current-repo)))
-  ([repo-url]
-   (or
-     (:editor/command-trigger (get-config repo-url))        ;; Get from user config
-     "/")))                                                 ;; Set the default
-
 (defn markdown?
 (defn markdown?
   []
   []
   (= (keyword (get-preferred-format))
   (= (keyword (get-preferred-format))

+ 1 - 1
src/test/frontend/handler/common/config_edn_test.cljs

@@ -60,7 +60,7 @@
 
 
 (deftest detect-deprecations
 (deftest detect-deprecations
   (is (re-find
   (is (re-find
-       #":editor/command-trigger.*Will"
+       #":editor/command-trigger.*is"
        (deprecation-warnings-for "{:preferred-workflow :todo :editor/command-trigger \",\"}"))
        (deprecation-warnings-for "{:preferred-workflow :todo :editor/command-trigger \",\"}"))
       "Warning when there is a deprecation")
       "Warning when there is a deprecation")