mirror of
https://github.com/penpot/penpot.git
synced 2026-02-12 14:42:56 +00:00
🐛 Fix error exporting a file with deleted tokens (#7356)
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
- Fix moving elements up or down while pressing alt [Taiga Issue #11992](https://tree.taiga.io/project/penpot/issue/11992)
|
||||
- Fix conflicting shortcuts (remove dec/inc line height and letter spacing) [Taiga #12102](https://tree.taiga.io/project/penpot/issue/12102)
|
||||
- Fix conflicting shortcuts (remove text-align shortcuts) [Taiga #12047](https://tree.taiga.io/project/penpot/issue/12047)
|
||||
- Fix export file with empty tokens library [Taiga #12137](https://tree.taiga.io/project/penpot/issue/12137)
|
||||
|
||||
## 2.9.0
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
[app.common.types.page :as ctp]
|
||||
[app.common.types.plugins :as ctpg]
|
||||
[app.common.types.shape :as cts]
|
||||
[app.common.types.tokens-lib :as cto]
|
||||
[app.common.types.tokens-lib :as ctob]
|
||||
[app.common.types.typography :as cty]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
@@ -120,7 +120,7 @@
|
||||
(sm/encoder cty/schema:typography sm/json-transformer))
|
||||
|
||||
(def encode-tokens-lib
|
||||
(sm/encoder cto/schema:tokens-lib sm/json-transformer))
|
||||
(sm/encoder ctob/schema:tokens-lib sm/json-transformer))
|
||||
|
||||
(def encode-plugin-data
|
||||
(sm/encoder ctpg/schema:plugin-data sm/json-transformer))
|
||||
@@ -158,7 +158,7 @@
|
||||
(sm/decoder cty/schema:typography sm/json-transformer))
|
||||
|
||||
(def decode-tokens-lib
|
||||
(sm/decoder cto/schema:tokens-lib sm/json-transformer))
|
||||
(sm/decoder ctob/schema:tokens-lib sm/json-transformer))
|
||||
|
||||
(def decode-plugin-data
|
||||
(sm/decoder ctpg/schema:plugin-data sm/json-transformer))
|
||||
@@ -196,7 +196,7 @@
|
||||
(sm/check-fn cty/schema:typography))
|
||||
|
||||
(def validate-tokens-lib
|
||||
(sm/check-fn cto/schema:tokens-lib))
|
||||
(sm/check-fn ctob/schema:tokens-lib))
|
||||
|
||||
(def validate-plugin-data
|
||||
(sm/check-fn ctpg/schema:plugin-data))
|
||||
@@ -349,7 +349,8 @@
|
||||
typography (encode-typography object)]
|
||||
(write-entry! output path typography)))
|
||||
|
||||
(when tokens-lib
|
||||
(when (and tokens-lib
|
||||
(not (ctob/empty-lib? tokens-lib)))
|
||||
(let [path (str "files/" file-id "/tokens.json")
|
||||
encoded-tokens (encode-tokens-lib tokens-lib)]
|
||||
(write-entry! output path encoded-tokens)))))
|
||||
|
||||
@@ -768,7 +768,8 @@
|
||||
(theme-active? [_ group name] "predicate if token theme is active")
|
||||
(activate-theme [_ group name] "adds theme from the active-themes")
|
||||
(deactivate-theme [_ group name] "removes theme from the active-themes")
|
||||
(toggle-theme-active? [_ group name] "toggles theme in the active-themes"))
|
||||
(toggle-theme-active? [_ group name] "toggles theme in the active-themes")
|
||||
(get-hidden-theme [_] "get the hidden temporary theme"))
|
||||
|
||||
(def schema:token-themes
|
||||
[:and
|
||||
@@ -906,6 +907,7 @@
|
||||
|
||||
(defprotocol ITokensLib
|
||||
"A library of tokens, sets and themes."
|
||||
(empty-lib? [_] "True if the lib does not contain any token, set or theme")
|
||||
(set-path-exists? [_ path] "if a set at `path` exists")
|
||||
(set-group-path-exists? [_ path] "if a set group at `path` exists")
|
||||
(add-token-in-set [_ set-name token] "add token to a set")
|
||||
@@ -1235,7 +1237,16 @@ Will return a value that matches this schema:
|
||||
(filter #(theme-active? this (:group %) (:name %))))
|
||||
(tree-seq d/ordered-map? vals themes)))
|
||||
|
||||
(get-hidden-theme [this]
|
||||
(get-theme this hidden-theme-group hidden-theme-name))
|
||||
|
||||
ITokensLib
|
||||
(empty-lib? [this]
|
||||
(and (empty? sets)
|
||||
(or (empty? themes)
|
||||
(and (= (theme-count this) 1)
|
||||
(get-hidden-theme this)))))
|
||||
|
||||
(set-path-exists? [_ set-path]
|
||||
(some? (get-in sets (set-full-path->set-prefixed-full-path set-path))))
|
||||
|
||||
@@ -1338,10 +1349,6 @@ Will return a value that matches this schema:
|
||||
cljs.core/IEncodeJS
|
||||
(-clj->js [this] (clj->js (datafy this)))))
|
||||
|
||||
(defn get-hidden-theme
|
||||
[tokens-lib]
|
||||
(get-theme tokens-lib hidden-theme-group hidden-theme-name))
|
||||
|
||||
(defn valid-tokens-lib?
|
||||
[o]
|
||||
(and (instance? TokensLib o)
|
||||
@@ -1752,11 +1759,12 @@ Will return a value that matches this schema:
|
||||
active-set-names
|
||||
(get-active-themes-set-names tokens-lib)]
|
||||
|
||||
(-> sets
|
||||
(assoc "$themes" themes)
|
||||
(assoc "$metadata" {"tokenSetOrder" ordered-set-names
|
||||
"activeThemes" active-themes
|
||||
"activeSets" active-set-names}))))
|
||||
(when-not (empty-lib? tokens-lib)
|
||||
(-> sets
|
||||
(assoc "$themes" themes)
|
||||
(assoc "$metadata" {"tokenSetOrder" ordered-set-names
|
||||
"activeThemes" active-themes
|
||||
"activeSets" active-set-names})))))
|
||||
|
||||
(defn get-tokens-of-unknown-type
|
||||
"Search for all tokens in the decoded json file that have a type that is not currently
|
||||
|
||||
Reference in New Issue
Block a user