Browse Source

fix: ignore properties when displaying block's body

Tienson Qin 4 years ago
parent
commit
c722f6ec83
1 changed files with 10 additions and 2 deletions
  1. 10 2
      src/main/frontend/format/block.cljs

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

@@ -21,6 +21,12 @@
    (vector? block)
    (= "Heading" (first block))))
 
+(defn properties-block?
+  [block]
+  (and
+   (vector? block)
+   (= "Properties" (first block))))
+
 (defn get-tag
   [block]
   (when-let [tag-value (and (vector? block)
@@ -736,9 +742,11 @@
            ast (->> (format/to-edn content format (mldoc/default-config format))
                     (map first))
            title (when (heading-block? (first ast))
-                   (:title (second (first ast))))]
+                   (:title (second (first ast))))
+           body (vec (if title (rest ast) ast))
+           body (drop-while properties-block? body)]
        (cond->
-         {:block/body (vec (if title (rest ast) ast))}
+         {:block/body body}
          title
          (assoc :block/title title))))))