Add enableCoreExtensions flag (#1923)

This commit is contained in:
Flávio Carvalho 2021-09-21 18:20:38 +01:00 committed by GitHub
parent 5cb63406a8
commit 2785278e83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 1 deletions

View File

@ -59,6 +59,7 @@ export class Editor extends EventEmitter {
parseOptions: {},
enableInputRules: true,
enablePasteRules: true,
enableCoreExtensions: true,
onBeforeCreate: () => null,
onCreate: () => null,
onUpdate: () => null,
@ -218,7 +219,9 @@ export class Editor extends EventEmitter {
* Creates an extension manager.
*/
private createExtensionManager(): void {
const coreExtensions = Object.entries(extensions).map(([, extension]) => extension)
const coreExtensions = this.options.enableCoreExtensions
? Object.entries(extensions).map(([, extension]) => extension)
: []
const allExtensions = [...coreExtensions, ...this.options.extensions].filter(extension => {
return ['extension', 'node', 'mark'].includes(extension?.type)
})

View File

@ -1,3 +1,6 @@
import * as extensions from './extensions'
export { extensions }
export * from './Editor'
export * from './Extension'
export * from './Node'

View File

@ -50,6 +50,7 @@ export interface EditorOptions {
parseOptions: ParseOptions,
enableInputRules: boolean,
enablePasteRules: boolean,
enableCoreExtensions: boolean,
onBeforeCreate: (props: { editor: Editor }) => void,
onCreate: (props: { editor: Editor }) => void,
onUpdate: (props: { editor: Editor, transaction: Transaction }) => void,