add basic lowlight extension
This commit is contained in:
@@ -58,6 +58,7 @@ export class Editor extends EventEmitter {
|
||||
parseOptions: {},
|
||||
enableInputRules: true,
|
||||
enablePasteRules: true,
|
||||
onBeforeCreate: () => null,
|
||||
onCreate: () => null,
|
||||
onUpdate: () => null,
|
||||
onSelectionUpdate: () => null,
|
||||
@@ -75,6 +76,8 @@ export class Editor extends EventEmitter {
|
||||
this.createExtensionManager()
|
||||
this.createCommandManager()
|
||||
this.createSchema()
|
||||
this.on('beforeCreate', this.options.onCreate)
|
||||
this.emit('beforeCreate', { editor: this })
|
||||
this.createView()
|
||||
this.injectCSS()
|
||||
this.on('create', this.options.onCreate)
|
||||
|
||||
@@ -94,6 +94,14 @@ declare module '@tiptap/core' {
|
||||
[key: string]: any,
|
||||
}) | null,
|
||||
|
||||
/**
|
||||
* The editor is not ready yet.
|
||||
*/
|
||||
onBeforeCreate?: ((this: {
|
||||
options: Options,
|
||||
editor: Editor,
|
||||
}) => void) | null,
|
||||
|
||||
/**
|
||||
* The editor is ready.
|
||||
*/
|
||||
|
||||
@@ -43,6 +43,13 @@ export default class ExtensionManager {
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(extension.config.onBeforeCreate)
|
||||
|
||||
if (typeof extension.config.onBeforeCreate === 'function') {
|
||||
console.log('JOOO')
|
||||
this.editor.on('beforeCreate', extension.config.onBeforeCreate.bind(context))
|
||||
}
|
||||
|
||||
if (typeof extension.config.onCreate === 'function') {
|
||||
this.editor.on('create', extension.config.onCreate.bind(context))
|
||||
}
|
||||
|
||||
@@ -104,6 +104,15 @@ declare module '@tiptap/core' {
|
||||
[key: string]: any,
|
||||
}) | null,
|
||||
|
||||
/**
|
||||
* The editor is not ready yet.
|
||||
*/
|
||||
onBeforeCreate?: ((this: {
|
||||
options: Options,
|
||||
editor: Editor,
|
||||
type: MarkType,
|
||||
}) => void) | null,
|
||||
|
||||
/**
|
||||
* The editor is ready.
|
||||
*/
|
||||
|
||||
@@ -109,6 +109,15 @@ declare module '@tiptap/core' {
|
||||
[key: string]: any,
|
||||
}) | null,
|
||||
|
||||
/**
|
||||
* The editor is not ready yet.
|
||||
*/
|
||||
onBeforeCreate?: ((this: {
|
||||
options: Options,
|
||||
editor: Editor,
|
||||
type: NodeType,
|
||||
}) => void) | null,
|
||||
|
||||
/**
|
||||
* The editor is ready.
|
||||
*/
|
||||
|
||||
@@ -29,6 +29,7 @@ export interface EditorOptions {
|
||||
parseOptions: ParseOptions,
|
||||
enableInputRules: boolean,
|
||||
enablePasteRules: boolean,
|
||||
onBeforeCreate: (props: { editor: Editor }) => void,
|
||||
onCreate: (props: { editor: Editor }) => void,
|
||||
onUpdate: (props: { editor: Editor }) => void,
|
||||
onViewUpdate: (props: { editor: Editor }) => void,
|
||||
|
||||
Reference in New Issue
Block a user