Skip to content

Commit

Permalink
feat: add enableCoreExtensions flag (#1923)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviouk authored and philippkuehn committed Sep 21, 2021
1 parent 5cb6340 commit 4178281
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/core/src/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class Editor extends EventEmitter {
parseOptions: {},
enableInputRules: true,
enablePasteRules: true,
enableCoreExtensions: true,
onBeforeCreate: () => null,
onCreate: () => null,
onUpdate: () => null,
Expand Down Expand Up @@ -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)
})
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import * as extensions from './extensions'

export { extensions }
export * from './Editor'
export * from './Extension'
export * from './Node'
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 4178281

Please sign in to comment.