mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 11:26:26 +00:00
enhance(dwim): re-number its items when dwim in an ordered list (#3358)
* enhance(dwim): re-number list if dwim in ordered list * fix: regexp for matching a list item * enhance: don't enable dwim in list if cursor is at beginning of item Co-authored-by: leizhe <leizhe@leizhedeMacBook-Air.local>
This commit is contained in:
20
src/main/frontend/util/list.cljs
Normal file
20
src/main/frontend/util/list.cljs
Normal file
@@ -0,0 +1,20 @@
|
||||
(ns frontend.util.list
|
||||
(:require [frontend.util.thingatpt :as thingatpt]
|
||||
[frontend.util.cursor :as cursor]))
|
||||
|
||||
(defn- get-prev-item [& [input]]
|
||||
(when-let [item (thingatpt/list-item-at-point input)]
|
||||
(let [{:keys [bullet ordered]} item]
|
||||
(when-not (or (cursor/textarea-cursor-first-row? input)
|
||||
(and ordered
|
||||
(= bullet "1")))
|
||||
(cursor/move-cursor-up input)
|
||||
(thingatpt/list-item-at-point input)))))
|
||||
|
||||
(defn- get-next-item [& [input]]
|
||||
(when-let [item (thingatpt/list-item-at-point input)]
|
||||
(let [{:keys [_bullet _ordered]} item]
|
||||
(when-not (cursor/textarea-cursor-last-row? input)
|
||||
(cursor/move-cursor-down input)
|
||||
(thingatpt/list-item-at-point input)))))
|
||||
|
||||
Reference in New Issue
Block a user