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