Browse Source

fix: heading style in single block

Peng Xiao 3 years ago
parent
commit
9382750dc2
2 changed files with 4 additions and 3 deletions
  1. 1 1
      src/main/frontend/components/block.cljs
  2. 3 2
      src/main/frontend/format/block.cljs

+ 1 - 1
src/main/frontend/components/block.cljs

@@ -2251,7 +2251,7 @@
         edit? (state/sub [:editor/editing? edit-input-id])
         block (block/parse-title-and-body block)]
     (when (:block/content block)
-      [:div.single-block
+      [:div.single-block.ls-block
        {:class (str block-uuid)
         :id (str "ls-block-" blocks-container-id "-" block-uuid)}
        (block-content-or-editor config block edit-input-id block-el-id (:block/heading-level block) edit? true)])))

+ 3 - 2
src/main/frontend/format/block.cljs

@@ -70,13 +70,14 @@ and handles unexpected failure."
          (let [ast (->> (format/to-edn content format (gp-mldoc/default-config format))
                         (map first))
                title (when (gp-block/heading-block? (first ast))
-                       (:title (second (first ast))))
+                       (second (first ast)))
                body (vec (if title (rest ast) ast))
                body (drop-while gp-property/properties-ast? body)
                result (cond->
                        (if (seq body) {:block/body body} {})
                         title
-                        (assoc :block/title title))]
+                        (assoc :block/title (:title title)
+                               :block/heading-level (:size title)))]
            (state/add-block-ast-cache! block-uuid content result)
            result))))))