1
0
Эх сурвалжийг харах

chore: revert inline tags

Tienson Qin 1 жил өмнө
parent
commit
575624c650

+ 13 - 0
deps/db/src/logseq/db/frontend/content.cljs

@@ -43,3 +43,16 @@
         (assoc item :block/content (special-id->page content refs)))
       item)
     item))
+
+(defn content-without-tags
+  "Remove tags from content"
+  [content tags]
+  (->
+   (reduce
+    (fn [content tag]
+      (-> content
+          (string/replace (str "#" tag) "")
+          (string/replace (str "#" page-ref/left-brackets tag page-ref/right-brackets) "")))
+    content
+    tags)
+   (string/trim)))

+ 1 - 2
deps/db/src/logseq/db/frontend/schema.cljs

@@ -150,8 +150,7 @@
 
 ;; If only block/content changes
 (def db-version-retract-attributes
-  #{:block/tags
-    :block/refs
+  #{:block/refs
     :block/marker
     :block/priority
     :block/scheduled

+ 16 - 2
deps/outliner/src/logseq/outliner/core.cljs

@@ -16,7 +16,8 @@
             [logseq.graph-parser.property :as gp-property]
             [logseq.db.frontend.property :as db-property]
             [logseq.db.sqlite.util :as sqlite-util]
-            [cljs.pprint :as pprint]))
+            [cljs.pprint :as pprint]
+            [logseq.db.frontend.content :as db-content]))
 
 (def ^:private block-map
   (mu/optional-keys
@@ -318,7 +319,20 @@
           db-id (:db/id (:data this))
           block-uuid (:block/uuid (:data this))
           eid (or db-id (when block-uuid [:block/uuid block-uuid]))
-          block-entity (d/entity db eid)]
+          block-entity (d/entity db eid)
+          m (if (and (:block/content m) db-based?)
+              (update m :block/content
+                      (fn [content]
+                        (db-content/content-without-tags
+                         content
+                         (->>
+                          (map
+                           (fn [tag]
+                             (when (:block/uuid tag)
+                               (str db-content/page-ref-special-chars (:block/uuid tag))))
+                           (:block/tags m))
+                          (remove nil?)))))
+              m)]
 
       ;; Ensure block UUID never changes
       (when (and db-id block-uuid)

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

@@ -679,12 +679,11 @@ img.small {
 }
 
 a.tag {
-  font-size: 0.9em;
+  @apply text-sm;
   text-align: center;
   text-decoration: none;
   display: inline-block;
   cursor: pointer;
-  padding: 0 2px;
   border-radius: 4px;
   color: or(--ls-tag-text, --lx-accent-11, --ls-tag-text-color, #045591);
   opacity: var(--ls-tag-text-opacity, 0.7);

+ 4 - 3
src/main/frontend/components/block.cljs

@@ -2319,7 +2319,7 @@
 (rum/defc tags
   [config block]
   (when (seq (:block/tags block))
-    [:div.flex.flex-row.flex-wrap.items-center.ml-4.gap-1.text-sm
+    [:div.flex.flex-row.flex-wrap.items-center.ml-4.gap-1
      (for [tag (:block/tags block)]
        (page-cp (assoc config
                        :tag? true
@@ -2387,7 +2387,8 @@
          "Large block will not be editable or searchable to not slow down the app, please use another editor to edit this block."])
       [:div.flex.flex-row.justify-between.block-content-inner
        (when-not plugin-slotted?
-         (let [block-tags (:block/tags block)]
+         (let [block-tags (:block/tags block)
+               db-based? (config/db-based-graph? (state/get-current-repo))]
            [:div.flex-1.w-full
             [:div.flex.flex-1.w-full.flex-row.flex-wrap.justify-between.items-center
              (cond
@@ -2403,7 +2404,7 @@
                nil)
 
              [:div.flex.flex-row.items-center.gap-1
-              (when (and (seq block-tags) (:block/name block))
+              (when (and db-based? (seq block-tags))
                 (tags config block))
               (when (and (:original-block config) (not (:block/name block)))
                 [:a.fade-link {:title "Embed block"