Skip to content

Commit f931dcf

Browse files
committed
fix: prevent loading the code block extension twice for plain text
Signed-off-by: Julius Knorr <[email protected]>
1 parent fa7b1d6 commit f931dcf

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/EditorFactory.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import hljs from 'highlight.js/lib/core'
1313

1414
import { logger } from './helpers/logger.js'
1515
import { FocusTrap, Mention, PlainText, RichText } from './extensions/index.js'
16-
// eslint-disable-next-line import/no-named-as-default
17-
import CodeBlockLowlight from '@tiptap/extension-code-block-lowlight'
1816

1917
const lowlight = createLowlight()
2018

@@ -65,8 +63,7 @@ const createPlainEditor = ({ language, extensions = [] } = {}) => {
6563
return new Editor({
6664
editorProps,
6765
extensions: [
68-
PlainText,
69-
CodeBlockLowlight.configure({
66+
PlainText.configure({
7067
lowlight,
7168
defaultLanguage: language,
7269
exitOnTripleEnter: false,

src/extensions/PlainText.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,25 @@ import Text from '@tiptap/extension-text'
1414
export default Extension.create({
1515
name: 'PlainText',
1616

17+
addOptions() {
18+
return {
19+
...this.parent?.(),
20+
lowlight: undefined,
21+
defaultLanguage: undefined,
22+
exitOnTripleEnter: true,
23+
}
24+
},
25+
1726
addExtensions() {
18-
return [CodeBlockPlainText, Keymap, PlainTextDocument, Text]
27+
return [
28+
CodeBlockPlainText.configure({
29+
lowlight: this.options.lowlight,
30+
defaultLanguage: this.options.defaultLanguage,
31+
exitOnTripleEnter: this.options.exitOnTripleEnter,
32+
}),
33+
Keymap,
34+
PlainTextDocument,
35+
Text,
36+
]
1937
},
2038
})

0 commit comments

Comments
 (0)