|
|
@@ -30,6 +30,7 @@
|
|
|
[frontend.handler.route :as route-handler]
|
|
|
[frontend.handler.ui :as ui-handler]
|
|
|
[frontend.image :as image]
|
|
|
+ [frontend.idb :as idb]
|
|
|
[frontend.mobile.util :as mobile]
|
|
|
[frontend.modules.outliner.core :as outliner-core]
|
|
|
[frontend.modules.outliner.datascript :as ds]
|
|
|
@@ -79,7 +80,7 @@
|
|
|
:input input})))))
|
|
|
|
|
|
(defn- format-new-selection
|
|
|
- [{:keys [selection-start selection-end format value edit-id input]}]
|
|
|
+ [{:keys [selection-start selection-end value]}]
|
|
|
(let [selected (subs value selection-start selection-end)]
|
|
|
[(+ selection-start (count (take-while #(= " " %) selected)))
|
|
|
(- selection-end (count (take-while #(= " " %) (reverse selected))))]))
|
|
|
@@ -87,7 +88,7 @@
|
|
|
(defn- format-text!
|
|
|
[pattern-fn]
|
|
|
(when-let [m (get-selection-and-format)]
|
|
|
- (let [{:keys [selection-start selection-end format value edit-id input]} m
|
|
|
+ (let [{:keys [format value edit-id input]} m
|
|
|
[selection-start selection-end] (format-new-selection m)
|
|
|
empty-selection? (= selection-start selection-end)
|
|
|
pattern (pattern-fn format)
|
|
|
@@ -548,7 +549,6 @@
|
|
|
(defn insert-new-block-before-block-aux!
|
|
|
[config
|
|
|
{:block/keys [repo]
|
|
|
- db-id :db/id
|
|
|
:as block}
|
|
|
value
|
|
|
{:keys [ok-handler]
|
|
|
@@ -567,18 +567,16 @@
|
|
|
(wrap-parse-block))
|
|
|
left-block (db/pull (:db/id (:block/left block)))
|
|
|
_ (outliner-core/save-node (outliner-core/block current-block))
|
|
|
- sibling? (not= (:db/id left-block) (:db/id (:block/parent block)))
|
|
|
- {:keys [sibling? blocks]} (profile
|
|
|
- "outliner insert block"
|
|
|
- (outliner-insert-block! config left-block prev-block sibling?))]
|
|
|
-
|
|
|
+ sibling? (not= (:db/id left-block) (:db/id (:block/parent block)))]
|
|
|
+ (profile
|
|
|
+ "outliner insert block"
|
|
|
+ (outliner-insert-block! config left-block prev-block sibling?))
|
|
|
(db/refresh! repo {:key :block/insert :data [prev-block left-block current-block]})
|
|
|
(profile "ok handler" (ok-handler prev-block))))
|
|
|
|
|
|
(defn insert-new-block-aux!
|
|
|
[config
|
|
|
{:block/keys [uuid repo]
|
|
|
- db-id :db/id
|
|
|
:as block}
|
|
|
value
|
|
|
{:keys [ok-handler]
|
|
|
@@ -650,7 +648,7 @@
|
|
|
(defn insert-new-block!
|
|
|
([state]
|
|
|
(insert-new-block! state nil))
|
|
|
- ([state block-value]
|
|
|
+ ([_state block-value]
|
|
|
(when (and (not config/publishing?)
|
|
|
(not= :insert (state/get-editor-op)))
|
|
|
(state/set-editor-op! :insert)
|
|
|
@@ -894,6 +892,7 @@
|
|
|
|
|
|
(defn cycle-todo!
|
|
|
[]
|
|
|
+ #_:clj-kondo/ignore
|
|
|
(if-let [blocks (seq (get-selected-blocks-with-children))]
|
|
|
(cycle-todos!)
|
|
|
(when (state/get-edit-block)
|
|
|
@@ -1041,6 +1040,7 @@
|
|
|
(defn- batch-set-block-property!
|
|
|
"col: a collection of [block-id property-key property-value]."
|
|
|
[col]
|
|
|
+ #_:clj-kondo/ignore
|
|
|
(when-let [repo (state/get-current-repo)]
|
|
|
(ds/auto-transact!
|
|
|
[txs-state (ds/new-outliner-txs-state)]
|
|
|
@@ -1069,8 +1069,8 @@
|
|
|
block-id (if (string? block-id) (uuid block-id) block-id)
|
|
|
input-pos (or (state/get-edit-pos) :max)]
|
|
|
(db/refresh! (state/get-current-repo)
|
|
|
- {:key :block/change
|
|
|
- :data [(db/pull [:block/uuid block-id])]})
|
|
|
+ {:key :block/change
|
|
|
+ :data [(db/pull [:block/uuid block-id])]})
|
|
|
;; update editing input content
|
|
|
(when-let [editing-block (state/get-edit-block)]
|
|
|
(when (= (:block/uuid editing-block) block-id)
|
|
|
@@ -1234,7 +1234,7 @@
|
|
|
adjusted-blocks (map-indexed
|
|
|
(fn [index {:keys [id level]}]
|
|
|
{:id id
|
|
|
- :level (if (and (< index first-root-level-index))
|
|
|
+ :level (if (< index first-root-level-index)
|
|
|
(if (< level @root-level)
|
|
|
(do
|
|
|
(reset! root-level level)
|
|
|
@@ -1405,7 +1405,6 @@
|
|
|
[block-id]
|
|
|
(when-let [block (db/pull [:block/uuid block-id])]
|
|
|
(let [repo (state/get-current-repo)
|
|
|
- content (:block/content block)
|
|
|
;; TODO: support org mode
|
|
|
[md-content _tree] (compose-copied-blocks-contents-&-block-tree repo [block-id])]
|
|
|
(common-handler/copy-to-clipboard-without-id-property! (:block/format block) md-content)
|
|
|
@@ -1578,7 +1577,7 @@
|
|
|
(fn [] [repo-dir assets-dir]))))
|
|
|
|
|
|
(defn save-assets!
|
|
|
- ([{block-id :block/uuid} repo files]
|
|
|
+ ([_ repo files]
|
|
|
(p/let [[repo-dir assets-dir] (ensure-assets-dir! repo)]
|
|
|
(save-assets! repo repo-dir assets-dir files
|
|
|
(fn [index file-base]
|
|
|
@@ -1633,7 +1632,7 @@
|
|
|
cached-url (get @*assets-url-cache (keyword handle-path))]
|
|
|
(if cached-url
|
|
|
(p/resolved cached-url)
|
|
|
- (p/let [handle (frontend.idb/get-item handle-path)
|
|
|
+ (p/let [handle (idb/get-item handle-path)
|
|
|
file (and handle (.getFile handle))]
|
|
|
(when file
|
|
|
(p/let [url (js/URL.createObjectURL file)]
|
|
|
@@ -1749,9 +1748,7 @@
|
|
|
(keys delete-map)))
|
|
|
|
|
|
(defn autopair
|
|
|
- [input-id prefix format {:keys [restore?]
|
|
|
- :or {restore? true}
|
|
|
- :as _option}]
|
|
|
+ [input-id prefix _format _option]
|
|
|
(let [value (get autopair-map prefix)
|
|
|
selected (util/get-selected-text)
|
|
|
postfix (str selected value)
|
|
|
@@ -2095,7 +2092,7 @@
|
|
|
|
|
|
;; TODO: is it cross-browser compatible?
|
|
|
;; (not= (gobj/get native-e "inputType") "insertFromPaste")
|
|
|
- (if (= last-input-char (state/get-editor-command-trigger))
|
|
|
+ (when (= last-input-char (state/get-editor-command-trigger))
|
|
|
(when (seq (get-matched-commands input))
|
|
|
(reset! commands/*slash-caret-pos (cursor/get-caret-pos input))
|
|
|
(reset! commands/*show-commands true)))
|
|
|
@@ -2107,7 +2104,7 @@
|
|
|
nil)))
|
|
|
|
|
|
(defn block-on-chosen-handler
|
|
|
- [input id q format]
|
|
|
+ [_input id q format]
|
|
|
(fn [chosen _click?]
|
|
|
(state/set-editor-show-block-search! false)
|
|
|
(let [uuid-string (str (:block/uuid chosen))]
|
|
|
@@ -2451,7 +2448,7 @@
|
|
|
(insert "\n")))))))
|
|
|
|
|
|
(defn- dwim-in-list
|
|
|
- [state]
|
|
|
+ [_state]
|
|
|
(when-not (auto-complete?)
|
|
|
(let [{:keys [block]} (get-state)]
|
|
|
(when block
|
|
|
@@ -2503,6 +2500,7 @@
|
|
|
index-of-current-item (inc (.indexOf items-without-bullet
|
|
|
(last (string/split (:raw-content item) splitter-reg 2))))
|
|
|
numbers-length (->> (map-indexed
|
|
|
+ #_:clj-kondo/ignore
|
|
|
#(str (inc %1) ". ")
|
|
|
(subvec items-without-bullet 0 index-of-current-item))
|
|
|
string/join
|
|
|
@@ -2542,7 +2540,7 @@
|
|
|
(let [selection (get-selection-and-format)
|
|
|
{:keys [selection-start selection-end value]} selection]
|
|
|
(if (not= selection-start selection-end)
|
|
|
- (do (delete-and-update selection-start selection-end)
|
|
|
+ (do (delete-and-update input selection-start selection-end)
|
|
|
(insert (util/format "[[%s]]" value)))
|
|
|
(if-let [embed-ref (thingatpt/embed-macro-at-point input)]
|
|
|
(let [{:keys [raw-content start end]} embed-ref]
|
|
|
@@ -2551,7 +2549,7 @@
|
|
|
(page-ref-fn "[[]]" 2)
|
|
|
(insert raw-content)))
|
|
|
(if-let [page-ref (thingatpt/page-ref-at-point input)]
|
|
|
- (let [{:keys [start end link full-content raw-content]} page-ref]
|
|
|
+ (let [{:keys [start end full-content raw-content]} page-ref]
|
|
|
(delete-and-update input start end)
|
|
|
(if (= raw-content "")
|
|
|
(page-ref-fn "{{embed [[]]}}" 4)
|
|
|
@@ -2800,7 +2798,7 @@
|
|
|
(cursor/move-cursor-to input current-pos)))))
|
|
|
|
|
|
(defn keydown-delete-handler
|
|
|
- [e]
|
|
|
+ [_e]
|
|
|
(let [^js input (state/get-input)
|
|
|
current-pos (cursor/pos input)
|
|
|
value (gobj/get input "value")
|
|
|
@@ -2938,7 +2936,7 @@
|
|
|
|
|
|
(defn keydown-not-matched-handler
|
|
|
[format]
|
|
|
- (fn [e key-code]
|
|
|
+ (fn [e _key-code]
|
|
|
(let [input-id (state/get-edit-input-id)
|
|
|
input (state/get-input)
|
|
|
key (gobj/get e "key")
|
|
|
@@ -2946,8 +2944,6 @@
|
|
|
ctrlKey (gobj/get e "ctrlKey")
|
|
|
metaKey (gobj/get e "metaKey")
|
|
|
pos (cursor/pos input)
|
|
|
- shift? (.-shiftKey e)
|
|
|
- code (gobj/getValueByKeys e "event_" "code")
|
|
|
hashtag? (or (surround-by? input "#" " ")
|
|
|
(surround-by? input "#" :end)
|
|
|
(= key "#"))]
|
|
|
@@ -3025,7 +3021,7 @@
|
|
|
nil))))
|
|
|
|
|
|
(defn keyup-handler
|
|
|
- [state input input-id search-timeout]
|
|
|
+ [_state input input-id search-timeout]
|
|
|
(fn [e key-code]
|
|
|
(when-not (util/event-is-composing? e)
|
|
|
(let [k (gobj/get e "key")
|
|
|
@@ -3036,7 +3032,6 @@
|
|
|
c (util/nth-safe value (dec current-pos))
|
|
|
last-key-code (state/get-last-key-code)
|
|
|
blank-selected? (string/blank? (util/get-selected-text))
|
|
|
- shift? (.-shiftKey e)
|
|
|
is-processed? (util/event-is-composing? e true) ;; #3440
|
|
|
non-enter-processed? (and is-processed? ;; #3251
|
|
|
(not= code keycode/enter-code))] ;; #3459
|
|
|
@@ -3152,11 +3147,6 @@
|
|
|
timeout)))
|
|
|
(edit-box-on-change! e block id))))
|
|
|
|
|
|
-(defn- get-current-page-format
|
|
|
- []
|
|
|
- (when-let [page (state/get-current-page)]
|
|
|
- (db/get-page-format page)))
|
|
|
-
|
|
|
(defn blocks->tree-by-level
|
|
|
[blocks]
|
|
|
(let [min-level (apply min (mapv :block/level blocks))
|