Skip to content

Instantly share code, notes, and snippets.

@laynor
Created November 22, 2017 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laynor/93e185584e48d866bd45fab7f0cbe3ac to your computer and use it in GitHub Desktop.
Save laynor/93e185584e48d866bd45fab7f0cbe3ac to your computer and use it in GitHub Desktop.
(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