enhance: align center bullets and headings

pull/1735/head
Tienson Qin 2021-05-02 11:14:01 +08:00
parent 2cca6a46cf
commit 9a8b00a849
5 changed files with 21 additions and 14 deletions

View File

@ -1026,7 +1026,7 @@
collapsed? (get (:block/properties block) :collapsed)
control-show? (util/react *control-show?)
dark? (= "dark" (state/sub :ui/theme))]
[:div.mr-2.flex.flex-row.items-center
[:div.bullet.mr-2.flex.flex-row.items-center
{:style {:height 24
:margin-top 0
:float "left"}}
@ -1418,7 +1418,7 @@
:on-drag-over (fn [event] (block-content-on-drag-over event uuid))
:on-drag-leave (fn [_event] (block-content-on-drag-leave uuid))
:on-drop (fn [event] (block-content-on-drop event block uuid))}]
[:div.flex.relative
[:div.flex.relative {:style {:width "100%"}}
[:div.flex-1.flex-col.relative.block-content
(cond-> {:id (str "block-content-" uuid)}
(not slide?)
@ -1492,8 +1492,8 @@
(rum/defc block-content-or-editor < rum/reactive
[config {:block/keys [uuid title body meta content dummy? page format repo children pre-block? idx] :as block} edit-input-id block-id slide?]
(let [edit? (state/sub [:editor/editing? edit-input-id])
editor-box (get config :editor-box)]
(let [editor-box (get config :editor-box)
edit? (state/sub [:editor/editing? edit-input-id])]
(if (and edit? editor-box)
[:div.editor-wrapper {:id (str "editor-" edit-input-id)}
(editor-box {:block block
@ -1655,8 +1655,9 @@
:should-update (fn [old-state new-state]
(not= (:block/content (second (:rum/args old-state)))
(:block/content (second (:rum/args new-state)))))}
[state config {:block/keys [uuid title body meta content dummy? page format repo children pre-block? top? properties refs-with-children] :as block}]
(let [*control-show? (get state ::control-show?)
[state config {:block/keys [uuid title body meta content dummy? page format repo children pre-block? top? properties refs-with-children heading-level level type] :as block}]
(let [heading? (and (= type :heading) (<= level 6))
*control-show? (get state ::control-show?)
collapsed? (get properties :collapsed)
ref? (boolean (:ref? config))
breadcrumb-show? (:breadcrumb-show? config)
@ -1672,7 +1673,8 @@
(or (seq children)
(seq body))))
attrs (on-drag-and-mouse-attrs block uuid top? block-id *move-to-top? has-child? *control-show? doc-mode?)
[data-refs data-refs-self] (get-data-refs-and-self block refs-with-children)]
[data-refs data-refs-self] (get-data-refs-and-self block refs-with-children)
edit-input-id (str "edit-block-" unique-dom-id uuid)]
[:div.ls-block.flex.flex-col.rounded-sm
(cond->
{:id block-id
@ -1687,7 +1689,9 @@
:repo repo
:haschild (str has-child?)}
(not slide?)
(merge attrs))
(merge attrs)
(and heading? heading-level)
(assoc :data-heading-level heading-level))
(when (and ref? breadcrumb-show?)
(when-let [comp (block-parents config repo uuid format false)]
@ -1695,12 +1699,11 @@
(dnd-separator-wrapper block slide? top?)
[:div.flex-1.flex-row
[:div.flex.flex-row {:class (if heading? "items-center" "")}
(when (not slide?)
(block-control config block uuid block-id body children dummy? *control-show?))
(let [edit-input-id (str "edit-block-" unique-dom-id uuid)]
(block-content-or-editor config block edit-input-id block-id slide?))]
(block-content-or-editor config block edit-input-id block-id slide?)]
(when (seq children)
[:div.block-children {:style {:margin-left (if doc-mode? 12 21)

View File

@ -17,6 +17,7 @@
}
.editor-wrapper {
width: 100%;
margin: 0 auto;
}

View File

@ -446,7 +446,10 @@
(remove string/blank?))
block (second block)
block (if markdown-heading?
(assoc block :level 1 :heading-level (:level block))
(assoc block
:type :heading
:level 1
:heading-level (:level block))
block)
level (:level block)
[children current-block-children]

View File

@ -2051,7 +2051,7 @@
(util/cursor-move-back input 1)
(util/cursor-move-forward input 1))))))
(defn- delete-and-update [input start end]
(defn- delete-and-update [^js input start end]
(.setRangeText input "" start end)
(state/set-edit-content! (state/get-edit-input-id) (.-value input)))

View File

@ -57,7 +57,7 @@
"org"
"* What's **Contents**?\n** It's a normal page called [[Contents]], you can use it for:\n*** 1. table of content/index/MOC\n*** 2. pinning/bookmarking favorites pages/blocks (e.g. [[Logseq]])\n*** 3. You can also put many different things, depending on your personal workflow."
"markdown"
"## What's **Contents**?\n### It's a normal page called [[Contents]], you can use it for:\n#### 1. table of content/index/MOC\n#### 2. pinning/bookmarking favorites pages/blocks (e.g. [[Logseq]])\n#### 3. You can also put many different things, depending on your personal workflow."
"- What's **Contents**?\n - It's a normal page called [[Contents]], you can use it for:\n - 1. table of content/index/MOC\n - 2. pinning/bookmarking favorites pages/blocks (e.g. [[Logseq]])\n - 3. You can also put many different things, depending on your personal workflow."
"")]
(p/let [_ (fs/mkdir-if-not-exists (str repo-dir "/" (state/get-pages-directory)))
file-exists? (fs/create-if-not-exists repo-url repo-dir file-path default-content)]