To keep the core lightweight, most functionality is provided via optional extensions. Extensions are implemented as React components that use the usePrismEditor hook to access the editor instance.
Common extensions include:
useBracketMatcher / useHighlightBracketPairs: Bracket matching.useTagMatcher / useHighlightMatchingTags: Tag matching.useSearchWidget / useHighlightSelectionMatches: Search and selection highlighting.useEditorCommands / useEditHistory: Commands and undo/redo.useCopyButton: Copy button functionality.IndentGuides: Visual indentation guides.
You can use BasicSetup for a pre-configured set of common extensions, or manually compose your own by importing specific hooks and components.
import { Editor, PrismEditor } from "prism-react-editor"
import { usePrismEditor } from "prism-react-editor/extensions"
import { useBracketMatcher } from "prism-react-editor/match-brackets"
import { IndentGuides } from "prism-react-editor/guides"
function MyExtensions() {
const [editor] = usePrismEditor()
useBracketMatcher(editor)
return <IndentGuides />
}
function MyEditor() {
return <Editor language="jsx" value="const foo = 'bar'">
<MyExtensions />
</Editor>
}