Skip to content

Commit 0a0827e

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 0a0827e

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/EditorFactory.js

Lines changed: 2 additions & 5 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,11 +63,10 @@ const createPlainEditor = ({ language, extensions = [] } = {}) => {
6563
return new Editor({
6664
editorProps,
6765
extensions: [
68-
PlainText,
69-
CodeBlockLowlight.configure({
66+
PlainText.configure({
67+
// Options to be passed through to `CodeBlockPlainText`
7068
lowlight,
7169
defaultLanguage: language,
72-
exitOnTripleEnter: false,
7370
}),
7471
FocusTrap,
7572
...extensions,

src/extensions/PlainText.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,24 @@ 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+
}
23+
},
24+
1725
addExtensions() {
18-
return [CodeBlockPlainText, Keymap, PlainTextDocument, Text]
26+
return [
27+
CodeBlockPlainText.configure({
28+
lowlight: this.options.lowlight,
29+
defaultLanguage: this.options.defaultLanguage,
30+
exitOnTripleEnter: false,
31+
}),
32+
Keymap,
33+
PlainTextDocument,
34+
Text,
35+
]
1936
},
2037
})

0 commit comments

Comments
 (0)