forked from logseq/logseq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhance(dwim): re-number its items when dwim in an ordered list (logs…
…eq#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 <[email protected]>
- Loading branch information
Showing
3 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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))))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters