From a59eb788f4f90f6ef66ee6bb94ae83d9fbb9f6c7 Mon Sep 17 00:00:00 2001 From: prabhanshuguptagit Date: Wed, 19 Jun 2024 20:59:10 +0530 Subject: [PATCH] Auto bold cells when they're marked a label --- src/bean/grid.cljs | 14 +++++++++++++- src/bean/ui/events.cljs | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/bean/grid.cljs b/src/bean/grid.cljs index e038d48..f8cc6cd 100644 --- a/src/bean/grid.cljs +++ b/src/bean/grid.cljs @@ -240,7 +240,9 @@ (util/map-on-matrix-addressed (fn [address item] (when (and (not= (:content item) "") - (not (nil? (:content item)))) + (not (nil? (:content item))) + ;; only reval formulas + (= (first (:content item)) "=")) address))) (mapcat identity) (remove nil?))] @@ -313,6 +315,16 @@ (unmerge-cells sheet (map #(offset % start) (keys addressed-attrs)))) eval-sheet-a-few-times)) +(defn add-frame-labels [sheet frame-name addresses dirn] + (-> (reduce #(set-cell-style %1 %2 :bold true) sheet addresses) + (frames/add-labels frame-name addresses dirn) + eval-sheet-a-few-times)) + +(defn remove-frame-labels [sheet frame-name addresses] + (-> (reduce #(set-cell-style %1 %2 :bold false) sheet addresses) + (frames/remove-labels frame-name addresses) + eval-sheet-a-few-times)) + (defn pasted-area [pasted-at addresses] (let [{:keys [start end]} (area/addresses->area addresses)] {:start (offset start pasted-at) diff --git a/src/bean/ui/events.cljs b/src/bean/ui/events.cljs index 155c6db..f554664 100644 --- a/src/bean/ui/events.cljs +++ b/src/bean/ui/events.cljs @@ -159,14 +159,14 @@ ::add-labels (fn add-labels [db [_ frame-name addresses dirn]] (update-in db [:sheet] - #(frames/add-labels % frame-name addresses dirn)))) + #(grid/add-frame-labels % frame-name addresses dirn)))) (rf/reg-event-db ::remove-labels (fn remove-labels [db [_ frame-name addresses]] (-> db (update-in [:sheet] #(frames/unmark-skipped % frame-name addresses)) - (update-in [:sheet] #(frames/remove-labels % frame-name addresses))))) + (update-in [:sheet] #(grid/remove-frame-labels % frame-name addresses))))) (rf/reg-event-db ::mark-skip-cells