Class SyntaxHighlighterPrism
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.react.ReactAdapterComponent
com.flowingcode.vaadin.addons.syntaxhighlighter.BaseSyntaxHighlighter
com.flowingcode.vaadin.addons.syntaxhighlighter.SyntaxHighlighterPrism
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,Serializable
@NpmPackage(value="react-syntax-highlighter",
version="npm:@fengkx/react-syntax-highlighter@15.6.1")
@JsModule("./react-syntax-highlighter-prism.tsx")
@Tag("syntax-highlighter-prism")
public class SyntaxHighlighterPrism
extends BaseSyntaxHighlighter
A Vaadin component that wraps the react-syntax-highlighter library to provide syntax highlighting for code snippets.
This implementation is based on Prism.js (more information here: https://github.com/react-syntax-highlighter/react-syntax-highlighter?tab=readme-ov-file#prism)
- Since:
- 1.0.0
- Author:
- mlopezFC
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new SyntaxHighlighter for Java language with empty contentSyntaxHighlighterPrism(ShLanguagePrism language, String content) Constructs a new SyntaxHighlighter with the specified language and content using a11yDark theme. -
Method Summary
Modifier and TypeMethodDescriptionObtains the current SyntaxHighlighterPrism LanguageObtains the current SyntaxHighlighterPrism StylevoidsetShLanguage(ShLanguagePrism language) Sets the SyntaxHighlighterPrism LanguagevoidsetShStyle(ShStylePrism style) Sets the SyntaxHighlighter StyleMethods inherited from class com.flowingcode.vaadin.addons.syntaxhighlighter.BaseSyntaxHighlighter
getContent, isShowLineNumbers, isWrapLongLines, setContent, setHeight, setShowLineNumbers, setWidth, setWrapLongLinesMethods inherited from class com.vaadin.flow.component.react.ReactAdapterComponent
addStateChangeListener, addStateChangeListener, getState, getState, readFromJson, readFromJson, setState, writeAsJsonMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
SyntaxHighlighterPrism
public SyntaxHighlighterPrism()Constructs a new SyntaxHighlighter for Java language with empty content -
SyntaxHighlighterPrism
Constructs a new SyntaxHighlighter with the specified language and content using a11yDark theme.- Parameters:
language- The programming language to highlight.content- The code content to highlight.
-
-
Method Details
-
getShLanguage
Obtains the current SyntaxHighlighterPrism Language- Returns:
-
setShLanguage
Sets the SyntaxHighlighterPrism Language- Parameters:
language-
-
getShStyle
Obtains the current SyntaxHighlighterPrism Style- Returns:
-
setShStyle
Sets the SyntaxHighlighter Style- Parameters:
style-
-