Skip to content

Instantly share code, notes, and snippets.

@laynor
Created Nov 22, 2017
Embed
What would you like to do?
(def editor-state (atom #{:value "foobaar"}))
(defn on-plain-text-change [& args] (println args))
(rum/defc PlainText < rum/reactive
[]
(js/React.createElement js/Slate.Editor
#js {:placeholder "enter enter enter"
:value (:value (rum/react editor-state))}))
(rum/defc plain-text
[]
(js/React.createElement PlainText))
(defn MyPlainText [props context updater]
(this-as this
(js/React.Component.call this props context updater)
(js/goog.object.set this :state (js-obj :value (js/Slate.Plain.deserialize "foo")))
this))
(js/goog.object.extend (.-prototype MyPlainText)
js/React.Component.prototype
#js {:render (fn []
(this-as this
(js/React.createElement js/Slate.Editor
#js {:placeholder "bar"
:value this.state.value})))})
(set! (.. MyPlainText -prototype -constructor) MyPlainText)
(rum/defc my-plain-text
[]
(js/React.createElement MyPlainText))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment