mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
Merge branch 'main' into develop
This commit is contained in:
commit
9a0f6018a7
9 changed files with 78 additions and 75 deletions
|
@ -78,6 +78,12 @@
|
|||
- Fix titles in viewer thumbnails too long [Taiga #1474](https://tree.taiga.io/project/penpot/issue/1474)
|
||||
- Fix when right click on a selected text shows artboard contextual menu [Taiga #1226](https://tree.taiga.io/project/penpot/issue/1226)
|
||||
|
||||
### :boom: Breaking changes
|
||||
|
||||
- The LDAP configuration variables interpolation starts using `:`
|
||||
(example `:username`) instead of `$`. The main reason is avoid
|
||||
unnecesary conflict with bash interpolation.
|
||||
|
||||
|
||||
### :arrow_up: Deps updates
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
(defn ^boolean empty-path-element?
|
||||
[item]
|
||||
(and (= (get item "name") "path")
|
||||
(let [d (get item ["attributes" "d"])]
|
||||
(let [d (get-in item ["attributes" "d"])]
|
||||
(or (str/blank? d)
|
||||
(nil? d)
|
||||
(str/empty? d)))))
|
||||
|
@ -93,16 +93,7 @@
|
|||
item))
|
||||
|
||||
(process-element [item xform]
|
||||
(let [item (d/update-when item "elements" #(into [] xform %))]
|
||||
(if (shape-element? item)
|
||||
(update item "elements"
|
||||
(fn [elements]
|
||||
;; flatten content of a shape element
|
||||
(into [] (mapcat (fn [item]
|
||||
(if (group-element? item)
|
||||
(get item "elements")
|
||||
[item]))) elements)))
|
||||
item)))]
|
||||
(d/update-when item "elements" #(into [] xform %)))]
|
||||
|
||||
(let [xform (comp (remove empty-defs-element?)
|
||||
(remove empty-path-element?)
|
||||
|
|
|
@ -105,6 +105,10 @@
|
|||
%)))]
|
||||
(attrs/get-attrs-multi nodes attrs)))
|
||||
|
||||
(defn current-root-values
|
||||
[{:keys [attrs shape]}]
|
||||
(shape-current-values shape txt/is-root-node? attrs))
|
||||
|
||||
(defn current-paragraph-values
|
||||
[{:keys [editor-state attrs shape]}]
|
||||
(if editor-state
|
||||
|
|
|
@ -234,17 +234,18 @@
|
|||
:stroke-dasharray (/ select-guide-dasharray zoom)}}])])
|
||||
|
||||
(mf/defc measurement [{:keys [bounds frame selected-shapes hover-shape zoom]}]
|
||||
(let [selected-ids (into #{} (map :id) selected-shapes)
|
||||
selected-selrect (gsh/selection-rect selected-shapes)
|
||||
hover-selrect (:selrect hover-shape)
|
||||
bounds-selrect (bound->selrect bounds)]
|
||||
(let [selected-ids (into #{} (map :id) selected-shapes)
|
||||
selected-selrect (gsh/selection-rect selected-shapes)
|
||||
hover-selrect (:selrect hover-shape)
|
||||
bounds-selrect (bound->selrect bounds)
|
||||
hover-selected-shape? (not (contains? selected-ids (:id hover-shape)))]
|
||||
|
||||
(when (and (seq selected-shapes) (not (contains? selected-ids (:id hover-shape))))
|
||||
(when (seq selected-shapes)
|
||||
[:g.measurement-feedback {:pointer-events "none"}
|
||||
[:& selection-guides {:selrect selected-selrect :bounds bounds :zoom zoom}]
|
||||
[:& size-display {:selrect selected-selrect :zoom zoom}]
|
||||
|
||||
(if (not hover-shape)
|
||||
(if (or (not hover-shape) (not hover-selected-shape?))
|
||||
(when frame
|
||||
[:g.hover-shapes
|
||||
[:& distance-display {:from (:selrect frame)
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
")
|
||||
|
||||
;; -- Embed fonts into styles
|
||||
|
||||
(defn get-node-fonts
|
||||
[node]
|
||||
(let [current-font (if (not (nil? (:font-id node)))
|
||||
|
@ -39,35 +40,39 @@
|
|||
children-font (map get-node-fonts (:children node))]
|
||||
(reduce set/union (conj children-font current-font))))
|
||||
|
||||
(defn get-local-font-css
|
||||
[font-id font-variant-id]
|
||||
(let [{:keys [family variants] :as font} (get @fonts/fontsdb font-id)
|
||||
{:keys [name weight style suffix] :as variant} (d/seek #(= (:id %) font-variant-id) variants)]
|
||||
(-> (str/format font-face-template {:family family :suffix (or suffix font-variant-id) :width weight})
|
||||
(p/resolved))))
|
||||
(defn get-font-css
|
||||
"Given a font and the variant-id, retrieves the style CSS for it."
|
||||
[{:keys [id backend family variants] :as font} font-variant-id]
|
||||
(if (= :google backend)
|
||||
(-> (fonts/gfont-url family [{:id font-variant-id}])
|
||||
(js/fetch)
|
||||
(p/then (fn [res] (.text res))))
|
||||
|
||||
(defn fetch-font-css
|
||||
[font-id font-variant-id]
|
||||
(let [{:keys [backend family] :as entry} (get @fonts/fontsdb font-id)]
|
||||
(if (= :google backend)
|
||||
(-> (fonts/gfont-url family [{:id font-variant-id}])
|
||||
(js/fetch)
|
||||
(p/then (fn [res] (.text res))))
|
||||
(get-local-font-css font-id font-variant-id))))
|
||||
(let [{:keys [name weight style suffix] :as variant} (d/seek #(= (:id %) font-variant-id) variants)
|
||||
result (str/fmt font-face-template {:family family
|
||||
:style style
|
||||
:suffix (or suffix font-variant-id)
|
||||
:weight weight})]
|
||||
(p/resolved result))))
|
||||
|
||||
(defn get-text-font-data [text]
|
||||
(->> text
|
||||
(defn get-font-data
|
||||
"Parses the CSS and retrieves the font data as DataURI."
|
||||
[^string css]
|
||||
(->> css
|
||||
(re-seq #"url\(([^)]+)\)")
|
||||
(map second)
|
||||
(map df/fetch-as-data-uri)
|
||||
(p/all)))
|
||||
|
||||
(defn embed-font [{:keys [font-id font-variant-id] :or {font-variant-id "regular"}}]
|
||||
(let [{:keys [backend family]} (get @fonts/fontsdb font-id)]
|
||||
(p/let [font-text (fetch-font-css font-id font-variant-id)
|
||||
url-to-data (get-text-font-data font-text)
|
||||
(defn embed-font
|
||||
"Given a font-id and font-variant-id, retrieves the CSS for it and
|
||||
convert all external urls to embedded data URI's."
|
||||
[{:keys [font-id font-variant-id] :or {font-variant-id "regular"}}]
|
||||
(let [{:keys [backend family] :as font} (get @fonts/fontsdb font-id)]
|
||||
(p/let [css (get-font-css font font-variant-id)
|
||||
url-to-data (get-font-data css)
|
||||
replace-text (fn [text [url data]] (str/replace text url data))]
|
||||
(reduce replace-text font-text url-to-data))))
|
||||
(reduce replace-text css url-to-data))))
|
||||
|
||||
(mf/defc embed-fontfaces-style
|
||||
{::mf/wrap-props false}
|
||||
|
@ -81,7 +86,9 @@
|
|||
font-to-embed (if (empty? font-to-embed) #{txt/default-text-attrs} font-to-embed)
|
||||
embeded (map embed-font font-to-embed)]
|
||||
(-> (p/all embeded)
|
||||
(p/then (fn [result] (reset! style (str/join "\n" result))))))))
|
||||
(p/then (fn [result]
|
||||
(reset! style (str/join "\n" result))))))))
|
||||
|
||||
|
||||
(when (some? @style)
|
||||
[:style @style])))
|
||||
|
|
|
@ -67,8 +67,7 @@
|
|||
(def shape-attrs
|
||||
[:grow-type])
|
||||
|
||||
(def root-attrs
|
||||
(d/concat text-valign-attrs text-align-attrs))
|
||||
(def root-attrs text-valign-attrs)
|
||||
|
||||
(def paragraph-attrs
|
||||
(d/concat text-align-attrs
|
||||
|
|
|
@ -42,12 +42,11 @@
|
|||
(:fill fill-values) (assoc :fill-color (:fill fill-values))
|
||||
(:opacity fill-values) (assoc :fill-opacity (:fill fill-values)))
|
||||
|
||||
text-values (merge
|
||||
(select-keys shape [:grow-type :vertical-align :text-align])
|
||||
#_(dwt/current-root-values
|
||||
{:editor-state editor-state
|
||||
:shape shape
|
||||
:attrs root-attrs})
|
||||
text-values (d/merge
|
||||
(select-keys shape [:grow-type])
|
||||
(dwt/current-root-values
|
||||
{:shape shape
|
||||
:attrs root-attrs})
|
||||
(dwt/current-paragraph-values
|
||||
{:editor-state editor-state
|
||||
:shape shape
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
[app.main.refs :as refs]
|
||||
[app.main.ui.context :as ctx]
|
||||
[app.main.ui.context :as muc]
|
||||
[app.main.ui.measurements :as msr]
|
||||
[app.main.ui.workspace.shapes :as shapes]
|
||||
[app.main.ui.workspace.shapes.text.editor :as editor]
|
||||
[app.main.ui.workspace.viewport.actions :as actions]
|
||||
|
@ -87,6 +88,11 @@
|
|||
zoom (d/check-num zoom 1)
|
||||
drawing-tool (:tool drawing)
|
||||
drawing-obj (:object drawing)
|
||||
selected-shapes (->> selected (mapv #(get objects %)))
|
||||
selected-frames (into #{} (map :frame-id) selected-shapes)
|
||||
|
||||
;; Only when we have all the selected shapes in one frame
|
||||
selected-frame (when (= (count selected-frames) 1) (get objects (first selected-frames)))
|
||||
|
||||
drawing-path? (or (and edition (= :draw (get-in edit-path [edition :edit-mode])))
|
||||
(and (some? drawing-obj) (= :path (:type drawing-obj))))
|
||||
|
@ -213,10 +219,17 @@
|
|||
{:selected selected
|
||||
:zoom zoom
|
||||
:edition edition
|
||||
:show-distances (and (not transform) show-distances?)
|
||||
:disable-handlers (or drawing-tool edition)
|
||||
:on-move-selected on-move-selected}])
|
||||
|
||||
(when (and (not transform) show-distances?)
|
||||
[:& msr/measurement
|
||||
{:bounds vbox
|
||||
:selected-shapes selected-shapes
|
||||
:frame selected-frame
|
||||
:hover-shape @hover
|
||||
:zoom zoom}])
|
||||
|
||||
(when text-editing?
|
||||
[:& editor/text-shape-edit {:shape (get objects edition)}])
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
[app.main.streams :as ms]
|
||||
[app.main.ui.cursors :as cur]
|
||||
[app.main.ui.hooks :as hooks]
|
||||
[app.main.ui.measurements :as msr]
|
||||
[app.main.ui.workspace.viewport.outline :refer [outline]]
|
||||
[app.main.ui.workspace.shapes.path.editor :refer [path-editor]]
|
||||
[app.util.data :as d]
|
||||
|
@ -295,7 +294,7 @@
|
|||
:fill "transparent"}}]]))
|
||||
|
||||
(mf/defc multiple-selection-handlers
|
||||
[{:keys [shapes selected zoom color show-distances disable-handlers on-move-selected] :as props}]
|
||||
[{:keys [shapes selected zoom color disable-handlers on-move-selected] :as props}]
|
||||
(let [shape (mf/use-memo
|
||||
(mf/deps shapes)
|
||||
#(->> shapes
|
||||
|
@ -327,17 +326,11 @@
|
|||
:on-resize on-resize
|
||||
:on-rotate on-rotate}]
|
||||
|
||||
(when show-distances
|
||||
[:& msr/measurement {:bounds vbox
|
||||
:selected-shapes shapes
|
||||
:hover-shape hover-shape
|
||||
:zoom zoom}])
|
||||
|
||||
(when (debug? :selection-center)
|
||||
[:circle {:cx (:x shape-center) :cy (:y shape-center) :r 5 :fill "yellow"}])]))
|
||||
|
||||
(mf/defc single-selection-handlers
|
||||
[{:keys [shape zoom color show-distances disable-handlers on-move-selected] :as props}]
|
||||
[{:keys [shape zoom color disable-handlers on-move-selected] :as props}]
|
||||
(let [shape-id (:id shape)
|
||||
shape (geom/transform-shape shape)
|
||||
|
||||
|
@ -357,25 +350,17 @@
|
|||
on-rotate
|
||||
#(do (dom/stop-propagation %)
|
||||
(st/emit! (dw/start-rotate [shape])))]
|
||||
[:*
|
||||
[:& controls {:shape shape'
|
||||
:zoom zoom
|
||||
:color color
|
||||
:on-rotate on-rotate
|
||||
:on-resize on-resize
|
||||
:disable-handlers disable-handlers
|
||||
:on-move-selected on-move-selected}]
|
||||
|
||||
(when show-distances
|
||||
[:& msr/measurement {:bounds vbox
|
||||
:frame frame
|
||||
:selected-shapes [shape]
|
||||
:hover-shape hover-shape
|
||||
:zoom zoom}])]))
|
||||
[:& controls {:shape shape'
|
||||
:zoom zoom
|
||||
:color color
|
||||
:on-rotate on-rotate
|
||||
:on-resize on-resize
|
||||
:disable-handlers disable-handlers
|
||||
:on-move-selected on-move-selected}]))
|
||||
|
||||
(mf/defc selection-handlers
|
||||
{::mf/wrap [mf/memo]}
|
||||
[{:keys [selected edition zoom show-distances disable-handlers on-move-selected] :as props}]
|
||||
[{:keys [selected edition zoom disable-handlers on-move-selected] :as props}]
|
||||
(let [;; We need remove posible nil values because on shape
|
||||
;; deletion many shape will reamin selected and deleted
|
||||
;; in the same time for small instant of time
|
||||
|
@ -396,7 +381,6 @@
|
|||
:selected selected
|
||||
:zoom zoom
|
||||
:color color
|
||||
:show-distances show-distances
|
||||
:disable-handlers disable-handlers
|
||||
:on-move-selected on-move-selected}]
|
||||
|
||||
|
@ -415,6 +399,5 @@
|
|||
[:& single-selection-handlers {:shape shape
|
||||
:zoom zoom
|
||||
:color color
|
||||
:show-distances show-distances
|
||||
:disable-handlers disable-handlers
|
||||
:on-move-selected on-move-selected}])))
|
||||
|
|
Loading…
Reference in a new issue