Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/EditorFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -65,11 +63,10 @@ const createPlainEditor = ({ language, extensions = [] } = {}) => {
return new Editor({
editorProps,
extensions: [
PlainText,
CodeBlockLowlight.configure({
PlainText.configure({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PlainText.configure({
PlainText.configure({
// Options to be passed through to `CodeBlockPlainText`

How about a short code comment here to explain why we pass codeblock config options to the plaintext extension?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively the options could be set as a separate object on the code block lowlight key similar to how tiptap defines its options in the starter kit.

Copy link
Member Author

@juliusknorr juliusknorr Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment for now, we can move to separate options if we have some for other extensions being passed as well

// Options to be passed through to `CodeBlockPlainText`
lowlight,
defaultLanguage: language,
exitOnTripleEnter: false,
}),
FocusTrap,
...extensions,
Expand Down
19 changes: 18 additions & 1 deletion src/extensions/PlainText.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
},
})
Loading