Merge branch 'feat/outliner-core' of github.com:logseq/logseq into feat/outliner-core

This commit is contained in:
Tienson Qin
2021-05-14 16:21:25 +08:00
22 changed files with 950 additions and 622 deletions

View File

@@ -1,6 +1,7 @@
(ns frontend.components.commit
(:require [rum.core :as rum]
[frontend.util :as util :refer-macros [profile]]
[clojure.string :as string]
[frontend.handler.repo :as repo-handler]
[frontend.state :as state]
[frontend.mixins :as mixins]
@@ -53,3 +54,16 @@
{:type "button"
:on-click close-fn}
"Cancel"]]]]))
(defn show-commit-modal! [e]
(when (and
(string/starts-with? (state/get-current-repo) "https://")
(not (util/input? (gobj/get e "target")))
(not (gobj/get e "shiftKey"))
(not (gobj/get e "ctrlKey"))
(not (gobj/get e "altKey"))
(not (gobj/get e "metaKey")))
(when-let [repo-url (state/get-current-repo)]
(when-not (state/get-edit-input-id)
(util/stop e)
(state/set-modal! commit-and-push!)))))

View File

@@ -14,7 +14,6 @@
[frontend.mixins :as mixins]
[frontend.ui :as ui]
[frontend.db :as db]
[frontend.modules.shortcut.handler :as shortcut-handler]
[dommy.core :as d]
[goog.object :as gobj]
[goog.dom :as gdom]
@@ -382,10 +381,7 @@
(state/set-editor-args! (:rum/args state))
state)}
(mixins/event-mixin setup-key-listener!)
(mixins/shortcuts
#(shortcut/install-shortcut! % {})
:shortcut-listener/editor-prevent-default
shortcut-handler/editing-only-prevent-default)
(shortcut/mixin :shortcut.handler/block-editing-only)
lifecycle/lifecycle
[state {:keys [on-hide dummy? node format block block-parent-id heading-level]
:or {dummy? false}

View File

@@ -79,7 +79,7 @@
(svg/horizontal-dots nil)])
(->>
[(when-not (util/mobile?)
{:title (t :help/toggle-right-sidebar)
{:title (t :shortcut.ui/toggle-right-sidebar)
:options {:on-click state/toggle-sidebar-open?!}})
(when current-repo

View File

@@ -1,10 +1,12 @@
(ns frontend.components.onboarding
(:require [rum.core :as rum]
(:require [frontend.components.shortcut :as shortcut]
[frontend.components.svg :as svg]
[frontend.extensions.latex :as latex]
[frontend.extensions.highlight :as highlight]
[frontend.context.i18n :as i18n]
[frontend.util :as util]))
[frontend.extensions.highlight :as highlight]
[frontend.extensions.latex :as latex]
[frontend.handler.route :as route-handler]
[frontend.ui :as ui]
[rum.core :as rum]))
(rum/defc intro
[]
@@ -216,70 +218,16 @@
svg/discord]]]
[:li
(t :help/shortcuts)
[:table
[:thead
[:tr
[:th [:b (t :help/shortcuts-triggers)]]
[:th (t :help/shortcut)]]]
[:tbody
[:tr [:td (t :help/slash-autocomplete)] [:td "/"]]
[:tr [:td (t :help/block-content-autocomplete)] [:td "<"]]
[:tr [:td (t :help/reference-autocomplete)] [:td "[[]]"]]
[:tr [:td (t :help/block-reference)] [:td "(())"]]]]
[:table
[:thead
[:tr
[:th [:span [:b (t :help/key-commands)]
(t :help/working-with-lists)]]
[:th (t :help/shortcut)]]]
[:tbody
[:tr [:td (t :help/indent-block-tab)] [:td "Tab"]]
[:tr [:td (t :help/unindent-block)] [:td "Shift-Tab"]]
[:tr [:td (t :help/move-block-up)] [:td (util/->platform-shortcut "Alt-Shift-Up")]]
[:tr [:td (t :help/move-block-down)] [:td (util/->platform-shortcut "Alt-Shift-Down")]]
[:tr [:td (t :help/create-new-block)] [:td "Enter"]]
[: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 (if util/mac? "Cmd-." "Alt-Right"))]]
[:tr [:td (t :help/zoom-out)] [:td (util/->platform-shortcut (if util/mac? "Cmd-," "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")]]
[:tr [:td (t :collapse)] [:td (util/->platform-shortcut "Ctrl-Up")]]
[:tr [:td (t :select-block-above)] [:td "Shift-Up"]]
[:tr [:td (t :select-block-below)] [:td "Shift-Down"]]
[:tr [:td (t :select-all-blocks)] [:td (util/->platform-shortcut "Ctrl-Shift-a")]]]]
[:table
[:thead
[:tr
[:th [:b (t :general)]]
[:th (t :help/shortcut)]]]
[:tbody
[:tr [:td (t :help/toggle)] [:td "?"]]
[:tr [:td (t :help/git-commit-message)] [:td "c"]]
[:tr [:td (t :help/full-text-search)] [:td (util/->platform-shortcut "Ctrl-u")]]
[:tr [:td (t :help/page-search)] [:td (util/->platform-shortcut "Ctrl-Shift-u")]]
[:tr [:td (t :help/open-link-in-sidebar)] [:td "Shift-Click"]]
[:tr [:td (t :help/context-menu)] [:td "Right Click"]]
[:tr [:td (t :help/fold-unfold)] [:td "Tab"]]
[:tr [:td (t :help/toggle-contents)] [:td "t c"]]
[:tr [:td (t :help/toggle-doc-mode)] [:td "t d"]]
[:tr [:td (t :help/toggle-theme)] [:td "t t"]]
[:tr [:td (t :help/toggle-right-sidebar)] [:td "t r"]]
[:tr [:td (t :help/toggle-settings)] [:td "t s"]]
[:tr [:td (t :help/toggle-insert-new-block)] [:td "t e"]]
[:tr [:td (t :help/jump-to-journals)] [:td (if util/mac? "Cmd-j" "Alt-j")]]]]
[:table
[:thead
[:tr
[:th [:b (t :formatting)]]
[:th (t :help/shortcut)]]]
[:tbody
[:tr [:td (t :bold)] [:td (util/->platform-shortcut "Ctrl-b")]]
[:tr [:td (t :italics)] [:td (util/->platform-shortcut "Ctrl-i")]]
[:tr [:td (t :html-link)] [:td (util/->platform-shortcut "Ctrl-k")]]
[:tr [:td (t :highlight)] [:td (util/->platform-shortcut "Ctrl-Shift-h")]]]]]
[:br]
(ui/button
"Learn more"
:on-click
(fn []
(route-handler/redirect! {:to :shortcut})))
(shortcut/trigger-table)
(shortcut/shortcut-table :shortcut.category/basics)
(shortcut/shortcut-table :shortcut.category/block-editing)
(shortcut/shortcut-table :shortcut.category/formatting)]
[:li
(t :help/markdown-syntax)

View File

@@ -0,0 +1,65 @@
(ns frontend.components.shortcut
(:require [frontend.context.i18n :as i18n]
[frontend.modules.shortcut.data-helper :as dh]
[frontend.state :as state]
[rum.core :as rum]))
(def *shortcut-config (rum/cursor-in state/state [:config (state/get-current-repo) :shortcuts]))
(rum/defc shortcut-table < rum/reactive
[name]
(let [_ (rum/react *shortcut-config)]
(rum/with-context [[t] i18n/*tongue-context*]
[:div
[:table
[:thead
[:tr
[:th.text-left [:b (t name)]]
[:th.text-right [:b (t :help/shortcut)]]]]
[:tbody
(map (fn [[k {:keys [binding]}]]
[:tr {:key k}
[:td.text-left (t (dh/decorate-namespace k))]
[:td.text-right (dh/binding-for-display k binding)]])
(dh/binding-by-category name))]]])))
(rum/defc trigger-table []
(rum/with-context [[t] i18n/*tongue-context*]
[:table
[:thead
[:tr
[:th.text-left [:b (t :help/shortcuts-triggers)]]
[:th.text-right [:b (t :help/shortcut)]]]]
[:tbody
[:tr
[:td.text-left (t :help/slash-autocomplete)]
[:td.text-right "/"]]
[:tr
[:td.text-left (t :help/block-content-autocomplete)]
[:td.text-right "<"]]
[:tr
[:td.text-left (t :help/reference-autocomplete)]
[:td.text-right "[[]]"]]
[:tr
[:td.text-left (t :help/block-reference)]
[:td.text-right "(())"]]
[:tr
[:td.text-left (t :shortcut.editor/open-link-in-sidebar)]
[:td.text-right "shift-click"]]
[:tr
[:td.text-left (t :help/context-menu)]
[:td.text-right "right click"]]]]))
(rum/defc shortcut
[]
(rum/with-context [[t] i18n/*tongue-context*]
[:div
[:h1.title (t :help/shortcut-page-title)]
(trigger-table)
(shortcut-table :shortcut.category/basics)
(shortcut-table :shortcut.category/navigating)
(shortcut-table :shortcut.category/block-editing)
(shortcut-table :shortcut.category/block-command-editing)
(shortcut-table :shortcut.category/block-selection)
(shortcut-table :shortcut.category/formatting)
(shortcut-table :shortcut.category/toggle)
(shortcut-table :shortcut.category/others)]))