Browse Source

enhance: support inline tags in block content

Tienson Qin 1 năm trước cách đây
mục cha
commit
09ad27b0ff

+ 0 - 1
src/main/frontend/common.css

@@ -681,7 +681,6 @@ img.small {
 }
 
 a.tag {
-  @apply text-sm;
   text-align: center;
   text-decoration: none;
   display: inline-block;

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

@@ -2305,7 +2305,7 @@
 (rum/defc tags
   [config block]
   (when (seq (:block/tags block))
-    [:div.flex.flex-row.flex-wrap.items-center.ml-4.gap-1
+    [:div.flex.flex-row.flex-wrap.items-center.ml-4.gap-1.text-sm
      (for [tag (:block/tags block)]
        (page-cp (assoc config
                        :tag? true
@@ -2389,7 +2389,7 @@
                nil)
 
              [:div.flex.flex-row.items-center.gap-1
-              (when (seq block-tags)
+              (when (and (seq block-tags) (:block/name block))
                 (tags config block))
               (when (and (:original-block config) (not (:block/name block)))
                 [:a.fade-link {:title "Embed block"

+ 5 - 18
src/main/frontend/modules/outliner/core.cljs

@@ -309,24 +309,11 @@
           db-based? (config/db-based-graph? repo)
           id (:db/id (:data this))
           block-entity (db/entity id)
-          structured-tags? (and db-based? (seq (:block/tags m)))
-          m (if (:block/content m)
-              (update m :block/content
-                      (fn [content]
-                        (mldoc/content-without-tags content
-                                                    (->>
-                                                     (map
-                                                      (fn [tag]
-                                                        (when (:block/uuid tag)
-                                                          (str config/page-ref-special-chars (:block/uuid tag))))
-                                                      (:block/tags m))
-                                                     (remove nil?)))))
-              m)
-          m-without-tags (if db-based? (dissoc m :block/tags) m)]
+          structured-tags? (and db-based? (seq (:block/tags m)))]
       (when id
         ;; Retract attributes to prepare for tx which rewrites block attributes
         (let [retract-attributes (when db-based?
-                                   (remove #{:block/tags :block/properties} db-schema/retract-attributes))]
+                                   (remove #{:block/properties} db-schema/retract-attributes))]
           (swap! txs-state (fn [txs]
                              (vec
                               (concat txs
@@ -335,12 +322,12 @@
                                            retract-attributes))))))
 
         ;; Update block's page attributes
-        (update-page-when-save-block txs-state block-entity m-without-tags)
+        (update-page-when-save-block txs-state block-entity m)
         ;; Remove macros as they are replaced by new ones
         (remove-macros-when-save repo txs-state block-entity)
 
         ;; Remove orphaned refs from block
-        (remove-orphaned-refs-when-save txs-state block-entity m-without-tags))
+        (remove-orphaned-refs-when-save txs-state block-entity m))
 
       ;; handle others txs
       (let [other-tx (:db/other-tx m)]
@@ -348,7 +335,7 @@
           (swap! txs-state (fn [txs]
                              (vec (concat txs other-tx)))))
         (swap! txs-state conj
-               (dissoc m-without-tags :db/other-tx)))
+               (dissoc m :db/other-tx)))
 
       (create-object-when-save txs-state block-entity m structured-tags?)