mirror of
https://github.com/penpot/penpot.git
synced 2026-06-20 06:12:04 +00:00
🐛 Fix problem with empty strings on createText plugins method (#10219)
This commit is contained in:
parent
68dd8ecdf5
commit
5eb9753278
@ -379,9 +379,12 @@
|
||||
:createText
|
||||
(fn [text]
|
||||
(cond
|
||||
(or (not (string? text)) (empty? text))
|
||||
(not (string? text))
|
||||
(u/not-valid plugin-id :createText text)
|
||||
|
||||
(empty? text)
|
||||
nil
|
||||
|
||||
:else
|
||||
(let [page (dsh/lookup-page @st/state)
|
||||
shape (-> (cts/setup-shape {:type :text
|
||||
|
||||
@ -339,6 +339,10 @@
|
||||
(t/is (= (-> (. text -fills) (aget 0) (aget "fillColor")) "#123456"))
|
||||
(t/is (nil? (-> (. text -fills) (aget 0) (aget "fillColorGradient")))))))
|
||||
|
||||
(t/testing "createText with empty string returns null"
|
||||
(t/is (nil? (.createText context "")))
|
||||
(t/is (some? (.createText context "Hello"))))
|
||||
|
||||
(t/testing "Relative properties"
|
||||
(let [board (.createBoard context)]
|
||||
(set! (.-x board) 100)
|
||||
|
||||
4
plugins/libs/plugin-types/index.d.ts
vendored
4
plugins/libs/plugin-types/index.d.ts
vendored
@ -1165,8 +1165,8 @@ export interface Context {
|
||||
|
||||
/**
|
||||
* Creates a Text shape with the specified text content. Requires `content:write` permission.
|
||||
* @param text The text content for the Text shape.
|
||||
* @return Returns the new created shape, if the shape wasn't created can return null.
|
||||
* @param text The text content for the Text shape. Must be a non-empty string.
|
||||
* @return Returns the new created shape. Returns null if an empty string is provided or the shape couldn't be created.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user