Ver código fonte

fix: hide empty blocks

Tienson Qin 4 anos atrás
pai
commit
ae89f9970b
1 arquivos alterados com 11 adições e 11 exclusões
  1. 11 11
      src/main/frontend/format/block.cljs

+ 11 - 11
src/main/frontend/format/block.cljs

@@ -728,18 +728,18 @@
                                   (:block/pre-block? block)
                                   (:block/content block)))))
   ([format pre-block? content]
-   (when content
+   (when-not (string/blank? content)
      (let [content (if pre-block? content
-                      (str (config/get-block-pattern format) " " (string/triml content)))
-          content (property/remove-properties format content)
-          ast (->> (format/to-edn content format nil)
-                   (map first))
-          title (when (heading-block? (first ast))
-                  (:title (second (first ast))))]
-      (cond->
-        {:block/body (vec (if title (rest ast) ast))}
-        title
-        (assoc :block/title title))))))
+                       (str (config/get-block-pattern format) " " (string/triml content)))
+           content (property/remove-properties format content)
+           ast (->> (format/to-edn content format nil)
+                    (map first))
+           title (when (heading-block? (first ast))
+                   (:title (second (first ast))))]
+       (cond->
+         {:block/body (vec (if title (rest ast) ast))}
+         title
+         (assoc :block/title title))))))
 
 (defn macro-subs
   [macro-content arguments]