mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 12:06: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 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 exception on paste invalid html [Taiga #11047](https://tree.taiga.io/project/penpot/issue/11047)
|
||||
|
||||
## 2.6.2
|
||||
|
||||
|
|
|
@ -214,8 +214,7 @@
|
|||
|
||||
(defn lazy-validator
|
||||
[s]
|
||||
(let [s (schema s)
|
||||
vfn (delay (validator s))]
|
||||
(let [vfn (delay (validator s))]
|
||||
(fn [v] (@vfn v))))
|
||||
|
||||
(defn lazy-explainer
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
|
||||
(def node-types #{"root" "paragraph-set" "paragraph"})
|
||||
|
||||
(sm/register!
|
||||
^{::sm/type ::content}
|
||||
(def schema:content
|
||||
[:map
|
||||
[:type [:= "root"]]
|
||||
[:key {:optional true} :string]
|
||||
|
@ -63,7 +62,10 @@
|
|||
[:typography-ref-id {: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/type ::position-data}
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
[app.common.types.shape :as cts]
|
||||
[app.common.types.shape-tree :as ctst]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.common.types.shape.text :as types.text]
|
||||
[app.common.types.typography :as ctt]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
|
@ -2193,9 +2194,9 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [root (dwtxt/create-root-from-html html)
|
||||
content (tc/dom->cljs root)
|
||||
|
||||
id (uuid/next)
|
||||
content (tc/dom->cljs root)]
|
||||
(when (types.text/valid-content? content)
|
||||
(let [id (uuid/next)
|
||||
width (max 8 (min (* 7 (count text)) 700))
|
||||
height 16
|
||||
{:keys [x y]} (calculate-paste-position state)
|
||||
|
@ -2212,7 +2213,7 @@
|
|||
undo-id (js/Symbol)]
|
||||
(rx/of (dwu/start-undo-transaction undo-id)
|
||||
(dwsh/create-and-add-shape :text x y shape)
|
||||
(dwu/commit-undo-transaction undo-id))))))
|
||||
(dwu/commit-undo-transaction undo-id))))))))
|
||||
|
||||
(defn- paste-text
|
||||
[text]
|
||||
|
|
|
@ -83,7 +83,10 @@ export function mapContentFragmentFromDocument(document, root, styleDefaults) {
|
|||
currentNode = nodeIterator.nextNode();
|
||||
}
|
||||
|
||||
if (currentParagraph) {
|
||||
fragment.appendChild(currentParagraph);
|
||||
}
|
||||
|
||||
if (fragment.children.length === 1) {
|
||||
const isContentInline = isContentFragmentFromDocumentInline(document);
|
||||
if (isContentInline) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue