|
2491 | 2491 | (:raw-title? config)
|
2492 | 2492 | (text-block-title (dissoc config :raw-title?) block)
|
2493 | 2493 |
|
2494 |
| - (ldb/asset? block) |
2495 |
| - [:div.grid.grid-cols-1.justify-items-center.asset-block-wrap |
2496 |
| - (asset-cp config block) |
2497 |
| - (when (img-audio-video? block) |
2498 |
| - [:div.text-xs.opacity-60.mt-1 |
2499 |
| - (text-block-title (dissoc config :raw-title?) block)])] |
2500 |
| - |
2501 | 2494 | (= :code node-display-type)
|
2502 | 2495 | [:div.flex.flex-1.w-full
|
2503 | 2496 | (src-cp (assoc config :code-block block) {:language (:logseq.property.code/lang block)})]
|
|
3082 | 3075 | (swap! *hide-block-refs? not)))}
|
3083 | 3076 | [:span.text-sm block-refs-count'])]))
|
3084 | 3077 |
|
| 3078 | +(defn- edit-block-content |
| 3079 | + [config block edit-input-id] |
| 3080 | + (let [content (:block/title block)] |
| 3081 | + (editor-handler/clear-selection!) |
| 3082 | + (editor-handler/unhighlight-blocks!) |
| 3083 | + (state/set-editing! edit-input-id content block content {:db (db/get-db) |
| 3084 | + :container-id (:container-id config)}))) |
| 3085 | + |
3085 | 3086 | (rum/defc block-content-with-error
|
3086 |
| - [config block edit-input-id block-id *show-query? editor-box] |
| 3087 | + [config block edit-input-id block-id *show-query? editor-box custom-block-content] |
3087 | 3088 | (let [[editing? set-editing!] (hooks/use-state false)
|
3088 | 3089 | query (:logseq.property/query block)]
|
3089 | 3090 | (ui/catch-error
|
|
3106 | 3107 | {:content (or (:block/title query)
|
3107 | 3108 | (:block/title block))
|
3108 | 3109 | :section-attrs
|
3109 |
| - {:on-click #(let [content (:block/title block)] |
3110 |
| - (editor-handler/clear-selection!) |
3111 |
| - (editor-handler/unhighlight-blocks!) |
3112 |
| - (state/set-editing! edit-input-id content block "" {:db (db/get-db) |
3113 |
| - :container-id (:container-id config)}))}})]) |
3114 |
| - (block-content config block edit-input-id block-id *show-query?)))) |
| 3110 | + {:on-click #(edit-block-content config block edit-input-id)}})]) |
| 3111 | + (or custom-block-content (block-content config block edit-input-id block-id *show-query?))))) |
3115 | 3112 |
|
3116 | 3113 | (rum/defcs ^:large-vars/cleanup-todo block-content-or-editor < rum/reactive
|
3117 | 3114 | [state config {:block/keys [uuid] :as block} {:keys [edit-input-id block-id edit? hide-block-refs-count? refs-count *hide-block-refs? *show-query?]}]
|
|
3138 | 3135 | (when (and db-based? (not table?)) (block-positioned-properties config block :block-left))
|
3139 | 3136 | [:div.block-content-or-editor-inner
|
3140 | 3137 | [:div.block-row.flex.flex-1.flex-row.gap-1.items-center
|
3141 |
| - (let [content-cp [:div.flex.flex-1.w-full.block-content-wrapper |
3142 |
| - {:style {:display "flex"}} |
3143 |
| - (when-let [actions-cp (:page-title-actions-cp config)] |
3144 |
| - (actions-cp block)) |
3145 |
| - (block-content-with-error config block edit-input-id block-id *show-query? editor-box) |
3146 |
| - |
3147 |
| - (when (and (not hide-block-refs-count?) |
3148 |
| - (not named?) |
3149 |
| - (not (:table-block-title? config))) |
3150 |
| - [:div.flex.flex-row.items-center |
3151 |
| - (when (and (:embed? config) |
3152 |
| - (:embed-parent config)) |
3153 |
| - [:a.opacity-70.hover:opacity-100.svg-small.inline |
3154 |
| - {:on-pointer-down (fn [e] |
3155 |
| - (util/stop e) |
3156 |
| - (when-let [block (:embed-parent config)] |
3157 |
| - (editor-handler/edit-block! block :max)))} |
3158 |
| - svg/edit]) |
3159 |
| - |
3160 |
| - (when block-reference-only? |
3161 |
| - [:a.opacity-70.hover:opacity-100.svg-small.inline |
3162 |
| - {:on-pointer-down (fn [e] |
3163 |
| - (util/stop e) |
3164 |
| - (editor-handler/edit-block! block :max))} |
3165 |
| - svg/edit])]) |
3166 |
| - |
3167 |
| - (when-not (or (:table? config) (:property? config) (:page-title? config)) |
3168 |
| - (block-refs-count block refs-count *hide-block-refs?))] |
| 3138 | + (let [block-content-f (fn block-content-f |
| 3139 | + [{:keys [custom-block-content]}] |
| 3140 | + [:div.flex.flex-1.w-full.block-content-wrapper |
| 3141 | + {:style {:display "flex"}} |
| 3142 | + (when-let [actions-cp (:page-title-actions-cp config)] |
| 3143 | + (actions-cp block)) |
| 3144 | + (block-content-with-error config block edit-input-id block-id *show-query? editor-box custom-block-content) |
| 3145 | + |
| 3146 | + (when (and (not hide-block-refs-count?) |
| 3147 | + (not named?) |
| 3148 | + (not (:table-block-title? config))) |
| 3149 | + [:div.flex.flex-row.items-center |
| 3150 | + (when (and (:embed? config) |
| 3151 | + (:embed-parent config)) |
| 3152 | + [:a.opacity-70.hover:opacity-100.svg-small.inline |
| 3153 | + {:on-pointer-down (fn [e] |
| 3154 | + (util/stop e) |
| 3155 | + (when-let [block (:embed-parent config)] |
| 3156 | + (editor-handler/edit-block! block :max)))} |
| 3157 | + svg/edit]) |
| 3158 | + |
| 3159 | + (when block-reference-only? |
| 3160 | + [:a.opacity-70.hover:opacity-100.svg-small.inline |
| 3161 | + {:on-pointer-down (fn [e] |
| 3162 | + (util/stop e) |
| 3163 | + (editor-handler/edit-block! block :max))} |
| 3164 | + svg/edit])]) |
| 3165 | + |
| 3166 | + (when-not (or (:table? config) (:property? config) (:page-title? config)) |
| 3167 | + (block-refs-count block refs-count *hide-block-refs?))]) |
3169 | 3168 | editor-cp [:div.editor-wrapper.flex.flex-1.w-full
|
3170 | 3169 | {:id editor-id
|
3171 | 3170 | :class (util/classnames [{:opacity-50 (boolean (or (ldb/built-in? block) (ldb/journal? block)))}])}
|
|
3176 | 3175 | :block-parent-id block-id
|
3177 | 3176 | :format format}
|
3178 | 3177 | edit-input-id
|
3179 |
| - config))]] |
3180 |
| - (if (and editor-box edit? (not type-block-editor?)) |
3181 |
| - editor-cp |
3182 |
| - content-cp)) |
| 3178 | + config))] |
| 3179 | + show-editor? (and editor-box edit? (not type-block-editor?))] |
| 3180 | + (if (ldb/asset? block) |
| 3181 | + [:div.flex.flex-col.asset-block-wrap.w-full |
| 3182 | + (block-content-f {:custom-block-content |
| 3183 | + [:div.flex.flex-1 |
| 3184 | + (asset-cp config block)]}) |
| 3185 | + (if show-editor? |
| 3186 | + [:div.mt-1 editor-cp] |
| 3187 | + (when (img-audio-video? block) |
| 3188 | + [:div.text-xs.opacity-60.mt-1.cursor-text |
| 3189 | + {:on-click #(edit-block-content config block edit-input-id)} |
| 3190 | + (text-block-title (dissoc config :raw-title?) block)]))] |
| 3191 | + (if show-editor? editor-cp (block-content-f {})))) |
3183 | 3192 |
|
3184 | 3193 | (when-not (:table-block-title? config)
|
3185 | 3194 | [:div.ls-block-right.flex.flex-row.items-center.self-start.gap-1
|
|
0 commit comments