add element option
This commit is contained in:
@@ -30,6 +30,7 @@ export interface CommandSpec {
|
||||
type EditorContent = string | JSON | null
|
||||
|
||||
interface Options {
|
||||
element: HTMLElement,
|
||||
content: EditorContent
|
||||
extensions: (Extension | Node | Mark)[]
|
||||
injectCSS: Boolean
|
||||
@@ -39,11 +40,11 @@ interface Options {
|
||||
export class Editor extends EventEmitter {
|
||||
|
||||
proxy!: any
|
||||
element = document.createElement('div')
|
||||
extensionManager!: ExtensionManager
|
||||
schema!: Schema
|
||||
view!: EditorView
|
||||
options: Options = {
|
||||
element: document.createElement('div'),
|
||||
content: '',
|
||||
injectCSS: true,
|
||||
extensions: [],
|
||||
@@ -161,7 +162,7 @@ export class Editor extends EventEmitter {
|
||||
}
|
||||
|
||||
private createView() {
|
||||
this.view = new EditorView(this.element, {
|
||||
this.view = new EditorView(this.options.element, {
|
||||
state: EditorState.create({
|
||||
doc: this.createDocument(this.options.content),
|
||||
plugins: this.plugins,
|
||||
|
||||
@@ -12,9 +12,9 @@ export default Vue.extend({
|
||||
editor: {
|
||||
immediate: true,
|
||||
handler(editor) {
|
||||
if (editor && editor.element) {
|
||||
if (editor && editor.options.element) {
|
||||
this.$nextTick(() => {
|
||||
this.$el.appendChild(editor.element.firstChild)
|
||||
this.$el.appendChild(editor.options.element.firstChild)
|
||||
// editor.setParentComponent(this)
|
||||
})
|
||||
}
|
||||
@@ -27,6 +27,6 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.editor.element = this.$el
|
||||
this.editor.options.element = this.$el
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user