浏览代码

fix: some displaying styles

Peng Xiao 3 年之前
父节点
当前提交
aa224fb6de

+ 15 - 10
deps/graph-parser/src/logseq/graph_parser/extract.cljc

@@ -76,7 +76,7 @@
       (assoc
        (gp-block/page-name->map page false db true date-formatter)
        :block/file {:file/path (gp-util/path-normalize file)}))
-      
+
       (seq properties)
       (assoc :block/properties properties)
 
@@ -117,7 +117,7 @@
                                        :block/page [:block/name page-name]
                                        :block/refs block-ref-pages
                                        :block/path-refs block-path-ref-pages)))))
-                   blocks)
+                      blocks)
           page-entity (build-page-entity properties file page-name page ref-tags options)
           namespace-pages (let [page (:block/original-name page-entity)]
                             (when (text/namespace-page? page)
@@ -155,7 +155,7 @@
           _ (when verbose (println "Parsing start: " file))
           ast (gp-mldoc/->edn content (gp-mldoc/default-config format
                                         ;; {:parse_outline_only? true}
-                                        )
+                                                               )
                               user-config)]
       (when verbose (println "Parsing finished: " file))
       (let [first-block (ffirst ast)
@@ -202,12 +202,17 @@
                     (str "whiteboard " (:type shape)))})
 
 (defn with-whiteboard-block-props
-  [block]
-  (let [shape (:block/properties block)]
-    (when (= :whiteboard-shape (:ls-type shape))
-      (merge {:block/uuid (uuid (:id shape))}
-             (with-whiteboard-block-refs shape)
-             (with-whiteboard-content shape)))))
+  [block page-name]
+  (let [shape (:block/properties block)
+        shape? (= :whiteboard-shape (:ls-type shape))]
+    (merge (when shape?
+             (merge
+              {:block/uuid (uuid (:id shape))}
+              (with-whiteboard-block-refs shape)
+              (with-whiteboard-content shape)))
+           (when (nil? (:block/parent block)) {:block/name (gp-util/page-name-sanity-lc page-name)})
+           (when (nil? (:block/format block)) {:block/format :markdown})
+           {:block/page {:block/name (gp-util/page-name-sanity-lc page-name)}})))
 
 (defn extract-whiteboard-edn
   "Extracts whiteboard page from given edn file
@@ -226,7 +231,7 @@
                     (map #(merge % {:block/level 1 ;; fixme
                                     :block/uuid (or (:block/uuid %)
                                                     (gp-block/get-custom-id-or-new-id (:block/properties %)))}
-                                 (with-whiteboard-block-props %)))
+                                 (with-whiteboard-block-props % page-name)))
                     (gp-block/with-parent-and-left {:block/name page-name}))
         _ (when verbose (println "Parsing finished: " file))]
     {:pages [page-block]

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

@@ -1803,7 +1803,7 @@
        (if title
          (conj
           (map-inline config title)
-          (when (and (util/electron?) (not= block-type :default))
+          (when (and (util/electron?) (not (#{:default :whiteboard-shape} block-type)))
             [:a.prefix-link
              {:on-click #(case block-type
                            ;; pdf annotation
@@ -2083,7 +2083,7 @@
                                (util/clear-selection!)))}
        (not slide?)
        (merge attrs))
-
+     
      [:<>
       [:div.flex.flex-row.justify-between.block-content-inner
        [:div.flex-1.w-full
@@ -2092,7 +2092,8 @@
           (build-block-title config block)
 
           (= block-type :whiteboard-shape)
-          content
+          [:<> (ui/icon "whiteboard-element")
+           (inline config (first (:block/title block)))]
 
           :else
           nil)]

+ 1 - 1
src/main/frontend/handler/whiteboard.cljs

@@ -65,7 +65,7 @@
         block {:block/page {:block/name (util/page-name-sanity-lc page-name)}
                :block/parent {:block/name page-name}
                :block/properties properties}
-        additional-props (gp-extract/with-whiteboard-block-props block)]
+        additional-props (gp-extract/with-whiteboard-block-props block page-name)]
     (merge block additional-props)))
 
 (defn- tldr-page->blocks-tx [page-name tldr-data]

+ 3 - 1
tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx

@@ -31,7 +31,9 @@ const LogseqPortalShapeHeader = observer(
   ({ type, children }: { type: 'P' | 'B'; children: React.ReactNode }) => {
     return (
       <div className="tl-logseq-portal-header">
-        <span className="type-tag">{type}</span>
+        <span className="type-tag">
+          <i className={`tie tie-${type === 'B' ? 'block' : 'page'}`} />
+        </span>
         {children}
       </div>
     )

+ 5 - 4
tldraw/apps/tldraw-logseq/src/styles.css

@@ -547,14 +547,15 @@
 
 .tl-logseq-portal-header .type-tag {
   display: flex;
-  flex-direction: column;
   align-items: center;
-  font-size: 12px;
+  justify-content: center;
+  flex-shrink: 0;
+  font-size: 16px;
+  width: 20px;
+  height: 20px;
   line-height: 1;
-  padding: 1px 4px;
   color: #fff;
   background: rgba(0, 0, 0, 0.5);
-  border: 1px solid #fff;
   border-radius: 4px;
   order: 0;
   flex-grow: 0;