Merge branch 'master' into enhance/undo-redo

pull/1072/head
Tienson Qin 2021-01-12 05:12:32 -08:00 committed by GitHub
commit eb4d56f666
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 108 additions and 26 deletions

View File

@ -28,13 +28,13 @@
hiccups/hiccups {:mvn/version "0.3.0"}
tongue/tongue {:mvn/version "0.2.9"}
org.clojure/core.async {:mvn/version "1.3.610"}
thheller/shadow-cljs {:mvn/version "2.11.11"}
thheller/shadow-cljs {:mvn/version "2.8.81"}
expound/expound {:mvn/version "0.8.6"}
lambdaisland/glogi {:mvn/version "1.0.74"}}
:aliases {:cljs {:extra-paths ["src/dev-cljs/" "src/test/"]
:extra-deps {org.clojure/clojurescript {:mvn/version "1.10.764"}
thheller/shadow-cljs {:mvn/version "2.11.11"}
thheller/shadow-cljs {:mvn/version "2.8.81"}
binaryage/devtools {:mvn/version "1.0.2"}
org.clojure/tools.namespace {:mvn/version "0.2.11"}
cider/cider-nrepl {:mvn/version "0.25.5"}}

View File

@ -565,15 +565,6 @@ li p:last-child,
/** endregion **/
/* region FIXME: override elements (?) */
a.block-control,
a.block-control:hover {
text-decoration: none;
cursor: pointer;
font-size: 14px;
min-width: 10px;
color: initial;
}
h1.title {
margin-bottom: 1.5rem;
color: var(--ls-title-text-color, #222);

View File

@ -1,6 +1,16 @@
.blocks-container {
}
.block-control,
.block-control:hover {
text-decoration: none;
cursor: pointer;
font-size: 14px;
min-width: 10px;
color: initial;
user-select: none;
}
.block-content {
min-height: 24px;
max-width: 100%;
@ -12,6 +22,7 @@
max-width: 100%;
/* FIXME: img macros */
&.left {
float: left;
}
@ -201,8 +212,8 @@
.bullet-container {
display: flex;
height: 13px;
width: 13px;
height: 12px;
width: 12px;
border-radius: 50%;
justify-content: center;
align-items: center;
@ -213,9 +224,16 @@
.bullet {
border-radius: 50%;
width: 5px;
height: 5px;
width: 6px;
height: 6px;
background-color: var(--ls-block-bullet-color, #394b59);
transition: transform .2s;
}
&:hover {
.bullet {
transform: scale(1.2);
}
}
&.bullet-closed {

View File

@ -42,6 +42,14 @@
}
}
.is-mobile {
.absolute-modal {
&.is-overflow-vw-x {
transform: translateX(-1%);
}
}
}
.non-block-editor textarea,
pre {
display: block;

View File

@ -237,8 +237,8 @@
[:tr [:td (t :help/new-line-in-block)] [:td "Shift-Enter"]]
[:tr [:td (t :undo)] [:td (util/->platform-shortcut "Ctrl-z")]]
[:tr [:td (t :redo)] [:td (util/->platform-shortcut "Ctrl-y")]]
[:tr [:td (t :help/zoom-in)] [:td (util/->platform-shortcut "Alt-Right")]]
[:tr [:td (t :help/zoom-out)] [:td (util/->platform-shortcut "Alt-left")]]
[:tr [:td (t :help/zoom-in)] [:td (util/->platform-shortcut (if util/mac? "Alt-." "Alt-Right"))]]
[:tr [:td (t :help/zoom-out)] [:td (util/->platform-shortcut (if util/mac? "Alt-," "Alt-left"))]]
[:tr [:td (t :help/follow-link-under-cursor)] [:td (util/->platform-shortcut "Ctrl-o")]]
[:tr [:td (t :help/open-link-in-sidebar)] [:td (util/->platform-shortcut "Ctrl-shift-o")]]
[:tr [:td (t :expand)] [:td (util/->platform-shortcut "Ctrl-Down")]]

View File

@ -86,7 +86,7 @@
properties (->> (take-while directive? ast)
(map (fn [[_ k v]]
(let [k (keyword (string/lower-case k))
v (if (contains? #{:title :description} k)
v (if (contains? #{:title :description :roam_tags} k)
v
(text/split-page-refs-without-brackets v))]
[k v])))
@ -115,11 +115,22 @@
(seq macros)
(assoc :macros macros))
alias (->vec-concat (:roam_alias properties) (:alias properties))
tags (->vec-concat (:roam_tags properties) (:tags properties) definition-tags)
filetags (if-let [org-file-tags (:filetags properties)]
(->> (string/split org-file-tags ":")
(remove string/blank?)))
roam-tags (if-let [org-roam-tags (:roam_tags properties)]
(let [pat #"\"(.*?)\"" ;; note: lazy, capturing group
quoted (map second (re-seq pat org-roam-tags))
rest (string/replace org-roam-tags pat "")
rest (->> (string/split rest " ")
(remove string/blank?))]
(concat quoted rest)))
tags (->vec-concat roam-tags (:tags properties) definition-tags filetags)
properties (assoc properties :tags tags :alias alias)
properties (-> properties
(update :roam_alias ->vec)
(update :roam_tags ->vec))
(update :roam_tags (constantly roam-tags))
(update :filetags (constantly filetags)))
properties (medley/filter-kv (fn [k v] (not (empty? v))) properties)
other-ast (drop-while (fn [[item _pos]] (directive? item)) original-ast)]
(if (seq properties)

View File

@ -0,0 +1,44 @@
(ns frontend.format.mldoc-test
(:require [frontend.format.mldoc :refer [parse-properties]]
[clojure.string :as string]
[cljs.test :refer [deftest are is testing]]))
(deftest test-parse-org-properties
[]
(testing "just title"
(let [content "#+TITLE: some title "
props (parse-properties content "org")]
(are [x y] (= x y)
;; TODO: should we trim in parse-properties?
"some title" (string/trim (:title props)))))
(testing "filetags"
(let [content "
#+FILETAGS: :tag1:tag_2:@tag:
#+ROAM_TAGS: roamtag
body"
props (parse-properties content "org")]
(are [x y] (= x y)
(list "@tag" "tag1" "tag_2") (sort (:filetags props))
["roamtag"] (:roam_tags props)
(list "@tag" "roamtag" "tag1" "tag_2") (sort (:tags props)))))
(testing "roam tags"
(let [content "
#+FILETAGS: filetag
#+ROAM_TAGS: roam1 roam2
body
"
props (parse-properties content "org")]
(are [x y] (= x y)
["roam1" "roam2"] (:roam_tags props)
(list "filetag" "roam1" "roam2") (sort (:tags props)))))
(testing "quoted roam tags"
(let [content "
#+ROAM_TAGS: \"why would\" you use \"spaces\" xxx
body
"
props (parse-properties content "org")]
;; TODO maybe need to sort or something
(is (= ["why would" "spaces" "you" "use" "xxx"] (:roam_tags props))))))

View File

@ -60,8 +60,10 @@
"ctrl+y" history-handler/redo!
"ctrl+u" route-handler/go-to-search!
"alt+j" route-handler/go-to-journals!
(or (state/get-shortcut :editor/zoom-in) "alt+right") editor-handler/zoom-in!
(or (state/get-shortcut :editor/zoom-out) "alt+left") editor-handler/zoom-out!
(or (state/get-shortcut :editor/zoom-in)
(if util/mac? "alt+." "alt+right")) editor-handler/zoom-in!
(or (state/get-shortcut :editor/zoom-out)
(if util/mac? "alt+," "alt+left")) editor-handler/zoom-out!
"ctrl+enter" editor-handler/cycle-todo!
"ctrl+down" editor-handler/expand!
"ctrl+up" editor-handler/collapse!

View File

@ -228,6 +228,7 @@
(let [cl (.-classList js/document.documentElement)]
(if util/mac? (.add cl "is-mac"))
(if (util/ios?) (.add cl "is-ios"))
(if (util/mobile?) (.add cl "is-mobile"))
(if (util/safari?) (.add cl "is-safari"))))
(defn inject-dynamic-style-node!

View File

@ -40,6 +40,11 @@
(and (string/includes? ua "webkit")
(not (string/includes? ua "chrome")))))
(defn mobile?
[]
(when-not node-test?
(re-find #"Mobi" js/navigator.userAgent)))
(defn format
[fmt & args]
(apply gstring/format fmt args))
@ -877,7 +882,9 @@
(defn ->system-modifier
[keyboard-shortcut]
(if mac?
(string/replace keyboard-shortcut "ctrl" "meta")
(-> keyboard-shortcut
(string/replace "ctrl" "meta")
(string/replace "alt" "meta"))
keyboard-shortcut))
(defn default-content-with-title

View File

@ -128,10 +128,10 @@ export var verifyPermission = async function (handle, readWrite) {
throw new Error("Permission is not granted");
}
// NOTE: Need externs to prevent `options.recursive` been munged
// When building with release.
export var openDirectory = async function (options = {}, cb) {
// FIXME: options.recursive will be undefined after the `getFiles` call get resolved
// It's caused by bumping shadow-cljs to 2.11.11.
options.recursive = true;
options.recursive = options.recursive || false;
const handle = await window.showDirectoryPicker({ mode: 'readwrite' });
const _ask = await verifyPermission(handle, true);
return [handle, getFiles(handle, options.recursive, cb)];