mirror of
https://github.com/penpot/penpot.git
synced 2025-04-06 12:01:19 -05:00
✨ Make last font used the default for next text box
This commit is contained in:
parent
26467187c4
commit
9ebafddac2
7 changed files with 31 additions and 14 deletions
|
@ -64,7 +64,8 @@
|
|||
|
||||
(defn ^boolean is-text-node?
|
||||
[node]
|
||||
(string? (:text node)))
|
||||
(and (string? (:text node))
|
||||
(not= (:text node) "")))
|
||||
|
||||
(defn ^boolean is-paragraph-node?
|
||||
[node]
|
||||
|
|
|
@ -207,7 +207,16 @@
|
|||
:workspace-file
|
||||
:workspace-project
|
||||
:workspace-media-objects
|
||||
:workspace-persistence))
|
||||
:workspace-persistence
|
||||
:workspace-local
|
||||
:workspace-data
|
||||
:workspace-editor-state
|
||||
:workspace-undo
|
||||
:current-file-id
|
||||
:current-project-id
|
||||
:workspace-layout
|
||||
:workspace-libraries
|
||||
:workspace-presence))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ _]
|
||||
|
@ -242,9 +251,10 @@
|
|||
(update [_ state]
|
||||
(let [page-id (or page-id (get-in state [:workspace-data :pages 0]))
|
||||
local (-> (:workspace-local state)
|
||||
(dissoc :edition)
|
||||
(dissoc :edit-path)
|
||||
(dissoc :selected))]
|
||||
(dissoc
|
||||
:edition
|
||||
:edit-path
|
||||
:selected))]
|
||||
(-> state
|
||||
(assoc-in [:workspace-cache page-id] local)
|
||||
(dissoc :current-page-id :workspace-local :trimmed-page :workspace-drawing))))))
|
||||
|
|
|
@ -75,11 +75,14 @@
|
|||
(ptk/reify ::initialize-editor-state
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(update-in state [:workspace-editor-state id]
|
||||
(fn [_]
|
||||
(ted/create-editor-state
|
||||
(some->> content ted/import-content)
|
||||
decorator))))
|
||||
(let [text-state (some->> content ted/import-content)
|
||||
attrs (get-in state [:workspace-local :defaults :font])
|
||||
|
||||
editor (cond-> (ted/create-editor-state text-state decorator)
|
||||
(and (nil? content) (some? attrs))
|
||||
(ted/update-editor-current-block-data attrs))]
|
||||
(-> state
|
||||
(assoc-in [:workspace-editor-state id] editor))))
|
||||
|
||||
ptk/WatchEvent
|
||||
(watch [_ _ stream]
|
||||
|
@ -326,3 +329,4 @@
|
|||
(assoc-in state
|
||||
[:workspace-local :defaults :font]
|
||||
data))))
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@
|
|||
text-align (:text-align data "start")
|
||||
grow-type (:grow-type shape)
|
||||
|
||||
base #js {:fontSize (str (:font-size txt/default-text-attrs) "px")
|
||||
:lineHeight (:line-height txt/default-text-attrs)
|
||||
base #js {:fontSize (str (:font-size data (:font-size txt/default-text-attrs)) "px")
|
||||
:lineHeight (:line-height data (:line-height txt/default-text-attrs))
|
||||
:margin "inherit"}]
|
||||
(cond-> base
|
||||
(some? line-height) (obj/set! "lineHeight" line-height)
|
||||
|
|
|
@ -222,7 +222,7 @@
|
|||
(mf/use-callback
|
||||
(mf/deps values)
|
||||
(fn [id attrs]
|
||||
(st/emit! (dwt/save-font (merge values attrs)))
|
||||
(st/emit! (dwt/save-font (merge txt/default-text-attrs values attrs)))
|
||||
|
||||
(let [attrs (select-keys attrs root-attrs)]
|
||||
(when-not (empty? attrs)
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[app.common.data :as d]
|
||||
[app.main.data.workspace.texts :as dwt]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-attrs]]
|
||||
[app.main.ui.workspace.sidebar.options.menus.blur :refer [blur-menu]]
|
||||
[app.main.ui.workspace.sidebar.options.menus.constraints :refer [constraint-attrs constraints-menu]]
|
||||
[app.main.ui.workspace.sidebar.options.menus.fill :refer [fill-menu]]
|
||||
|
@ -42,6 +43,7 @@
|
|||
|
||||
text-values (d/merge
|
||||
(select-keys shape [:grow-type])
|
||||
(select-keys shape fill-attrs)
|
||||
(dwt/current-root-values
|
||||
{:shape shape
|
||||
:attrs root-attrs})
|
||||
|
|
|
@ -122,7 +122,7 @@ export function applyInlineStyle(state, styles) {
|
|||
let selection = state.getSelection();
|
||||
|
||||
if (selection.isCollapsed()) {
|
||||
selection = selection.set("anchorOffset", 0);
|
||||
selection = getSelectAllSelection(state);
|
||||
}
|
||||
|
||||
let content = null;
|
||||
|
|
Loading…
Add table
Reference in a new issue