🐛 Fix problem with empty strings on createText plugins method (#10219)

This commit is contained in:
Alonso Torres 2026-06-18 15:30:53 +02:00 committed by GitHub
parent 68dd8ecdf5
commit 5eb9753278
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 3 deletions

View File

@ -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

View File

@ -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)

View File

@ -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