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