Mixed typographies for texts

This commit is contained in:
alonso.torres 2020-09-30 19:57:29 +02:00 committed by Hirunatan
parent 7248b168fa
commit c28fce58f1
3 changed files with 21 additions and 8 deletions

View file

@ -338,6 +338,7 @@
:left nil}) :left nil})
selected (mf/deref refs/selected-shapes) selected (mf/deref refs/selected-shapes)
local (deref refs/workspace-local)
add-typography add-typography
(mf/use-callback (mf/use-callback
@ -357,7 +358,7 @@
{:typography-ref-file (when-not local? file-id) {:typography-ref-file (when-not local? file-id)
:typography-ref-id (:id typography)} :typography-ref-id (:id typography)}
(d/without-keys typography [:id :name]))] (d/without-keys typography [:id :name]))]
(run! #(st/emit! (dwt/update-text-attrs {:id % :editor nil :attrs attrs})) (run! #(st/emit! (dwt/update-text-attrs {:id % :editor (get-in local [:editors %]) :attrs attrs}))
selected))) selected)))
on-context-menu on-context-menu

View file

@ -303,4 +303,5 @@
[:& text-menu {:ids ids [:& text-menu {:ids ids
:type type :type type
:values text-values :values text-values
:editor editor
:shapes [shape]}]])) :shapes [shape]}]]))

View file

@ -207,10 +207,23 @@
(mf/defc typography-entry (mf/defc typography-entry
[{:keys [typography read-only? on-select on-change on-deattach on-context-menu]}] [{:keys [typography read-only? on-select on-change on-deattach on-context-menu editting? focus-name?]}]
(let [open? (mf/use-state false) (let [open? (mf/use-state editting?)
selected (mf/deref refs/selected-shapes) selected (mf/deref refs/selected-shapes)
hover-deattach (mf/use-state false)] hover-deattach (mf/use-state false)
name-input-ref (mf/use-ref nil)]
(mf/use-effect
(mf/deps editting?)
(fn [] (reset! open? editting?)))
(mf/use-effect
(mf/deps focus-name?)
(fn []
(when-let [node (mf/ref-val name-input-ref)]
(dom/focus! node)
(dom/select-text! node))))
[:* [:*
[:div.element-set-options-group.typography-entry [:div.element-set-options-group.typography-entry
[:div.typography-selection-wrapper [:div.typography-selection-wrapper
@ -270,10 +283,8 @@
[:div.row-flex [:div.row-flex
[:input.element-name.adv-typography-name [:input.element-name.adv-typography-name
{:type "text" {:type "text"
:ref name-input-ref
:value (:name typography) :value (:name typography)
:on-change #(on-change {:name (dom/get-target-val %)})}]]] :on-change #(on-change {:name (dom/get-target-val %)})}]]]
[:& typography-options {:values typography [:& typography-options {:values typography
:on-change on-change}]] :on-change on-change}]])]]))
)
]]))