mirror of
https://github.com/penpot/penpot.git
synced 2025-05-30 21:46:12 +02:00
🐛 Fix exception on paste invalid html
This commit is contained in:
parent
ecb85778bc
commit
79a164be6d
5 changed files with 75 additions and 69 deletions
|
@ -49,6 +49,7 @@
|
||||||
- Fix issue that makes workspace shortcuts stop working [Taiga #11062](https://tree.taiga.io/project/penpot/issue/11062)
|
- Fix issue that makes workspace shortcuts stop working [Taiga #11062](https://tree.taiga.io/project/penpot/issue/11062)
|
||||||
- Fix problem while syncing library colors and typographies [Taiga #11068](https://tree.taiga.io/project/penpot/issue/11068)
|
- Fix problem while syncing library colors and typographies [Taiga #11068](https://tree.taiga.io/project/penpot/issue/11068)
|
||||||
- Fix problem with path edition of shapes [Taiga #9496](https://tree.taiga.io/project/penpot/issue/9496)
|
- Fix problem with path edition of shapes [Taiga #9496](https://tree.taiga.io/project/penpot/issue/9496)
|
||||||
|
- Fix exception on paste invalid html [Taiga #11047](https://tree.taiga.io/project/penpot/issue/11047)
|
||||||
|
|
||||||
## 2.6.2
|
## 2.6.2
|
||||||
|
|
||||||
|
|
|
@ -214,8 +214,7 @@
|
||||||
|
|
||||||
(defn lazy-validator
|
(defn lazy-validator
|
||||||
[s]
|
[s]
|
||||||
(let [s (schema s)
|
(let [vfn (delay (validator s))]
|
||||||
vfn (delay (validator s))]
|
|
||||||
(fn [v] (@vfn v))))
|
(fn [v] (@vfn v))))
|
||||||
|
|
||||||
(defn lazy-explainer
|
(defn lazy-explainer
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
|
|
||||||
(def node-types #{"root" "paragraph-set" "paragraph"})
|
(def node-types #{"root" "paragraph-set" "paragraph"})
|
||||||
|
|
||||||
(sm/register!
|
(def schema:content
|
||||||
^{::sm/type ::content}
|
|
||||||
[:map
|
[:map
|
||||||
[:type [:= "root"]]
|
[:type [:= "root"]]
|
||||||
[:key {:optional true} :string]
|
[:key {:optional true} :string]
|
||||||
|
@ -63,7 +62,10 @@
|
||||||
[:typography-ref-id {:optional true} [:maybe ::sm/uuid]]
|
[:typography-ref-id {:optional true} [:maybe ::sm/uuid]]
|
||||||
[:typography-ref-file {:optional true} [:maybe ::sm/uuid]]]]]]]]]]]]])
|
[:typography-ref-file {:optional true} [:maybe ::sm/uuid]]]]]]]]]]]]])
|
||||||
|
|
||||||
|
(sm/register! ::content schema:content)
|
||||||
|
|
||||||
|
(def valid-content?
|
||||||
|
(sm/lazy-validator schema:content))
|
||||||
|
|
||||||
(sm/register!
|
(sm/register!
|
||||||
^{::sm/type ::position-data}
|
^{::sm/type ::position-data}
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
[app.common.types.shape-tree :as ctst]
|
[app.common.types.shape-tree :as ctst]
|
||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
|
[app.common.types.shape.text :as types.text]
|
||||||
[app.common.types.typography :as ctt]
|
[app.common.types.typography :as ctt]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
|
@ -2193,9 +2194,9 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [root (dwtxt/create-root-from-html html)
|
(let [root (dwtxt/create-root-from-html html)
|
||||||
content (tc/dom->cljs root)
|
content (tc/dom->cljs root)]
|
||||||
|
(when (types.text/valid-content? content)
|
||||||
id (uuid/next)
|
(let [id (uuid/next)
|
||||||
width (max 8 (min (* 7 (count text)) 700))
|
width (max 8 (min (* 7 (count text)) 700))
|
||||||
height 16
|
height 16
|
||||||
{:keys [x y]} (calculate-paste-position state)
|
{:keys [x y]} (calculate-paste-position state)
|
||||||
|
@ -2212,7 +2213,7 @@
|
||||||
undo-id (js/Symbol)]
|
undo-id (js/Symbol)]
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dwsh/create-and-add-shape :text x y shape)
|
(dwsh/create-and-add-shape :text x y shape)
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))))
|
||||||
|
|
||||||
(defn- paste-text
|
(defn- paste-text
|
||||||
[text]
|
[text]
|
||||||
|
|
|
@ -83,7 +83,10 @@ export function mapContentFragmentFromDocument(document, root, styleDefaults) {
|
||||||
currentNode = nodeIterator.nextNode();
|
currentNode = nodeIterator.nextNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentParagraph) {
|
||||||
fragment.appendChild(currentParagraph);
|
fragment.appendChild(currentParagraph);
|
||||||
|
}
|
||||||
|
|
||||||
if (fragment.children.length === 1) {
|
if (fragment.children.length === 1) {
|
||||||
const isContentInline = isContentFragmentFromDocumentInline(document);
|
const isContentInline = isContentFragmentFromDocumentInline(document);
|
||||||
if (isContentInline) {
|
if (isContentInline) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue