I would like to add a modified ProseMirror editor to a figwheel-main-based Clojurescript project. After setting up a small experimental project, I'm just trying to reproduce this nonfunctional editor from the ProseMirror guide.
import {schema} from "prosemirror-schema-basic"
import {EditorState} from "prosemirror-state"
import {EditorView} from "prosemirror-view"
let state = EditorState.create({schema})
let view = new EditorView(document.body, {state})
I set up a figwheel-main project from the template and added a few lines of code:
(ns ^:figwheel-hooks miraj.core
(:require
...
["prosemirror-schema-basic" :as pm-schema-basic]
["prosemirror-state" :as pm-state :refer [EditorState]]
["prosemirror-view" :as pm-view :refer [EditorView]]
...
(set! *warn-on-infer* true)
...
(let [schema pm-schema-basic/schema
editor-state (.create ^js/pm-state.EditorState EditorState #js {:schema schema})
view (pm-view/EditorView. (.-body js/document) editor-state)])
The let
is outside any other function -- I'm just trying to get the interop working to create some objects. This compiles without errors or warnings. An error is thrown at the browser console when it tries to load,
TypeError: undefined is not an object (evaluating 'this.state.plugins')
and the view
is never created. goog.object
's get
function shows that the editor-state
does contain an empty plugins
value, #js []
.
What is the problem causing the failure to construct the EditorView
object?