mirror of
https://github.com/penpot/penpot.git
synced 2025-04-16 08:51:32 -05:00
fix(frontend): add render-to-html function
This commit is contained in:
parent
b428d1dc23
commit
ea1bfd5eaa
3 changed files with 10 additions and 4 deletions
|
@ -14,6 +14,7 @@
|
|||
[uxbox.main.ui.shapes.path :refer [path-shape]]
|
||||
[uxbox.main.ui.shapes.circle :refer [circle-shape]]
|
||||
[uxbox.main.ui.shapes.image :refer [image-shape]]
|
||||
[uxbox.util.dom :as dom]
|
||||
[rumext.core :as mx :include-macros true]))
|
||||
|
||||
(def ^:dynamic *state* st/state)
|
||||
|
@ -67,6 +68,6 @@
|
|||
(try
|
||||
(let [page (get-in @*state* [:pages id])]
|
||||
(when (:shapes page)
|
||||
(mx/render-static-html (page-svg page))))
|
||||
(dom/render-to-html (page-svg page))))
|
||||
(catch :default e
|
||||
nil)))
|
||||
|
|
|
@ -142,7 +142,7 @@
|
|||
[own]
|
||||
(let [[shape] (:rum/args own)
|
||||
dom (mx/ref-node own "fobject")
|
||||
html (mx/render-static-html (text-shape-html shape))]
|
||||
html (dom/render-to-html (text-shape-html shape))]
|
||||
(set! (.-innerHTML dom) html))
|
||||
own)
|
||||
|
||||
|
@ -152,7 +152,7 @@
|
|||
[shape] (:rum/args own)]
|
||||
(when (not= shape old-shape)
|
||||
(let [dom (mx/ref-node own "fobject")
|
||||
html (mx/render-static-html (text-shape-html shape))]
|
||||
html (dom/render-to-html (text-shape-html shape))]
|
||||
(set! (.-innerHTML dom) html)))
|
||||
own))
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||
|
||||
(ns uxbox.util.dom
|
||||
(:require [goog.dom :as dom]))
|
||||
(:require [goog.dom :as dom]
|
||||
[cljsjs.react.dom.server]))
|
||||
|
||||
;; --- Deprecated methods
|
||||
|
||||
|
@ -24,6 +25,10 @@
|
|||
|
||||
;; --- New methods
|
||||
|
||||
(defn render-to-html
|
||||
[component]
|
||||
(.renderToStatciMarkup js/ReactDOMServer component))
|
||||
|
||||
(defn get-element-by-class
|
||||
([classname]
|
||||
(dom/getElementByClass classname))
|
||||
|
|
Loading…
Add table
Reference in a new issue