diff --git a/src/EditorFactory.js b/src/EditorFactory.js index 3f53582cf43..d1a72a0645f 100644 --- a/src/EditorFactory.js +++ b/src/EditorFactory.js @@ -13,8 +13,6 @@ import hljs from 'highlight.js/lib/core' import { logger } from './helpers/logger.js' import { FocusTrap, Mention, PlainText, RichText } from './extensions/index.js' -// eslint-disable-next-line import/no-named-as-default -import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight' const lowlight = createLowlight() @@ -65,11 +63,10 @@ const createPlainEditor = ({ language, extensions = [] } = {}) => { return new Editor({ editorProps, extensions: [ - PlainText, - CodeBlockLowlight.configure({ + PlainText.configure({ + // Options to be passed through to `CodeBlockPlainText` lowlight, defaultLanguage: language, - exitOnTripleEnter: false, }), FocusTrap, ...extensions, diff --git a/src/extensions/PlainText.js b/src/extensions/PlainText.js index bc8ab3eacee..6852394f981 100644 --- a/src/extensions/PlainText.js +++ b/src/extensions/PlainText.js @@ -14,7 +14,24 @@ import Text from '@tiptap/extension-text' export default Extension.create({ name: 'PlainText', + addOptions() { + return { + ...this.parent?.(), + lowlight: undefined, + defaultLanguage: undefined, + } + }, + addExtensions() { - return [CodeBlockPlainText, Keymap, PlainTextDocument, Text] + return [ + CodeBlockPlainText.configure({ + lowlight: this.options.lowlight, + defaultLanguage: this.options.defaultLanguage, + exitOnTripleEnter: false, + }), + Keymap, + PlainTextDocument, + Text, + ] }, })