我想将修改后的 ProseMirror 编辑器添加到基于 figwheel-main 的 Clojurescript 项目中。在建立了一个小型实验项目之后,我只是想从ProseMirror 指南中重现这个非功能编辑器。
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})
我从模板中设置了一个 figwheel-main 项目并添加了几行代码:
(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)])
它let
在任何其他功能之外——我只是想让互操作性工作以创建一些对象。这编译没有错误或警告。尝试加载时,浏览器控制台会抛出错误,
TypeError: undefined is not an object (evaluating 'this.state.plugins')
并且view
永远不会创建。goog.object
的get
函数显示editor-state
确实包含一个空plugins
值,#js []
。
导致构造EditorView
对象失败的问题是什么?