要使用汇总启动并运行最小编辑器,请先安装汇总:
npm i -g rollup
安装汇总解析插件:
npm i @rollup/plugin-node-resolve
然后将以下内容添加到rollup.config.js
文件中:
import resolve from '@rollup/plugin-node-resolve'
export default {
input: 'main.js',
output: {
file: 'build.js',
format: 'iife'
},
plugins: [resolve()]
}
安装 prosemiror 基础库:
npm i prosemirror-schema-basic prosemirror-state prosemirror-view
创建main.js
具有以下内容的文件:
import {schema} from 'prosemirror-schema-basic'
import {EditorState} from 'prosemirror-state'
import {EditorView} from 'prosemirror-view'
let state = EditorState.create({schema})
window.view = new EditorView(document.querySelector('#editor'), {state})
构建你的编辑器(到 build.js):
rollup -c
最后build.js
将 prosemiror-view 包中的样式包含并可选地包含到您的 HTML 文件中并享受:
<html>
<body>
<div id="editor"></div>
<script src="build.js"></script>
</body>
</html>