diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml
index f272a72..232ec1b 100644
--- a/.github/ISSUE_TEMPLATE/bug-report.yml
+++ b/.github/ISSUE_TEMPLATE/bug-report.yml
@@ -1,5 +1,5 @@
name: Bug Report
-description: Please report issues related to X add-on here.
+description: Please report issues related to Syntax Highlighter add-on here.
body:
- type: textarea
id: problem-description
diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml
index 6880986..14c624d 100644
--- a/.github/ISSUE_TEMPLATE/feature-request.yml
+++ b/.github/ISSUE_TEMPLATE/feature-request.yml
@@ -1,5 +1,5 @@
name: Feature Request
-description: Please add feature suggestions related to TEMPLATE_ADDON add-on here.
+description: Please add feature suggestions related to Syntax Highlighter add-on here.
body:
- type: textarea
id: feature-proposal
diff --git a/.gitignore b/.gitignore
index 8a30ffa..2201857 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,8 +13,9 @@ drivers
tsconfig.json
.idea
types.d.ts
-/frontend/generated
-/frontend/index.html
vite.generated.ts
vite.config.ts
-/src/main/dev-bundle
\ No newline at end of file
+/src/main/dev-bundle
+/src/main/bundles
+/src/main/frontend/generated
+/src/main/frontend/index.html
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 5756052..7f8889b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,7 +1,3 @@
-All parts are licensed under Apache License v2.0. See the license text below.
-
------------------------------------------------------------------------------
-
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
diff --git a/README.md b/README.md
index 44743af..ae5cbf5 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,24 @@
-[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/template-addon)
-[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/template-addon.svg)](https://vaadin.com/directory/component/template-addon)
-[![Build Status](https://jenkins.flowingcode.com/job/template-addon/badge/icon)](https://jenkins.flowingcode.com/job/template-addon)
-[![Maven Central](https://img.shields.io/maven-central/v/com.flowingcode.vaadin.addons/template-addon)](https://mvnrepository.com/artifact/com.flowingcode.vaadin.addons/template-addon)
+[![Published on Vaadin Directory](https://img.shields.io/badge/Vaadin%20Directory-published-00b4f0.svg)](https://vaadin.com/directory/component/syntax-highlighter-add-on)
+[![Stars on vaadin.com/directory](https://img.shields.io/vaadin-directory/star/syntax-highlighter-addon.svg)](https://vaadin.com/directory/component/syntax-highlighter-add-on)
+[![Build Status](https://jenkins.flowingcode.com/job/syntax-highlighter-addon/badge/icon)](https://jenkins.flowingcode.com/job/syntax-highlighter-addon)
+[![Maven Central](https://img.shields.io/maven-central/v/org.vaadin.addons.flowingcode/syntax-highlighter-addon)](https://mvnrepository.com/artifact/com.flowingcode.vaadin.addons/syntax-highlighter-addon)
-# Template Add-on
+# SyntaxHighlighter Add-on
-This is a template project for building new Vaadin 24 add-ons
+This is a wrapper around the [React Syntax Highlighter](https://github.com/react-syntax-highlighter/react-syntax-highlighter) component
## Features
-* List the features of your add-on in here
+* Supports both hljs and prism modes
+* Enums with styles and languages
## Online demo
-[Online demo here](http://addonsv24.flowingcode.com/template)
+[Online demo here](http://addonsv24.flowingcode.com/syntax-highlighter)
## Download release
-[Available in Vaadin Directory](https://vaadin.com/directory/component/template-addon)
+[Available in Vaadin Directory](https://vaadin.com/directory/component/syntax-highlighter-add-on)
### Maven install
@@ -26,20 +27,13 @@ Add the following dependencies in your pom.xml file:
```xml
com.flowingcode.vaadin.addons
- template-addon
+ syntax-highlighter-addon
X.Y.Z
```
-```xml
-
- vaadin-addons
- https://maven.vaadin.com/vaadin-addons
-
-```
-
-For SNAPSHOT versions see [here](https://maven.flowingcode.com/snapshots/).
+Release versions are available from Maven Central repository. For SNAPSHOT versions see [here](https://maven.flowingcode.com/snapshots/).
## Building and running demo
@@ -50,7 +44,7 @@ To see the demo, navigate to http://localhost:8080/
## Release notes
-See [here](https://github.com/FlowingCode/TemplateAddon/releases)
+See [here](https://github.com/FlowingCode/SyntaxHighlighter/releases)
## Issue tracking
@@ -75,20 +69,30 @@ Then, follow these steps for creating a contribution:
This add-on is distributed under Apache License 2.0. For license terms, see LICENSE.txt.
-TEMPLATE_ADDON is written by Flowing Code S.A.
+SyntaxHighlighter Add-on is written by Flowing Code S.A.
# Developer Guide
## Getting started
-Add your code samples in this section
+You can instantiate the add-on by using the following syntax:
+
+ SyntaxHighlighter sh = new SyntaxHighlighter(SHLanguage.JAVASCRIPT, SHStyle.A11YDARK, defaultValue, false, false);
+
+You can also change the style and language by calling the appropriate getters:
+
+ sh.setSHLanguage(SHLanguage.JAVASCRIPT);
+
+The same with the styling:
+
+ sh.setSHStyle(SHStyle.A11YDARK);
## Special configuration when using Spring
-By default, Vaadin Flow only includes ```com/vaadin/flow/component``` to be always scanned for UI components and views. For this reason, the add-on might need to be whitelisted in order to display correctly.
+By default, Vaadin Flow only includes ```com/vaadin/flow/component``` to be always scanned for UI components and views. For this reason, the add-on might need to be allowed in order to display correctly.
+
+To do so, just add ```com.flowingcode``` to the ```vaadin.allowed-packages``` property in ```src/main/resources/application.properties```, like:
-To do so, just add ```com.flowingcode``` to the ```vaadin.whitelisted-packages``` property in ```src/main/resources/application.properties```, like:
+```vaadin.allowed-packages = com.vaadin,org.vaadin,dev.hilla,com.flowingcode```
-```vaadin.whitelisted-packages = com.vaadin,org.vaadin,dev.hilla,com.flowingcode```
-
-More information on Spring whitelisted configuration [here](https://vaadin.com/docs/latest/integrations/spring/configuration/#configure-the-scanning-of-packages).
+More information on Spring scanning configuration [here](https://vaadin.com/docs/latest/integrations/spring/configuration/#configure-the-scanning-of-packages).
diff --git a/pom.xml b/pom.xml
index 227f24a..92211e7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,14 +5,14 @@
4.0.0
com.flowingcode.vaadin.addons
- template-addon
+ syntax-highlighter-addon
1.0.0-SNAPSHOT
- Template Add-on
- Template Add-on for Vaadin Flow
+ Syntax Highlighter Add-on
+ Syntax Highlighter Add-on for Vaadin Flow
https://www.flowingcode.com/en/open-source/
- 24.3.0
+ 24.4.7
4.10.0
17
17
@@ -20,7 +20,7 @@
UTF-8
${project.basedir}/drivers
11.0.12
- 3.9.0
+ 4.1.0
true
@@ -29,7 +29,7 @@
https://www.flowingcode.com
- 2023
+ 2024
Apache 2
@@ -39,9 +39,9 @@
- https://github.com/FlowingCode/AddonStarter24
- scm:git:git://github.com/FlowingCode/AddonStarter24.git
- scm:git:ssh://git@github.com:/FlowingCode/AddonStarter24.git
+ https://github.com/FlowingCode/SyntaxHighlighter
+ scm:git:git://github.com/FlowingCode/SyntaxHighlighter.git
+ scm:git:ssh://git@github.com:/FlowingCode/SyntaxHighlighter.git
master
diff --git a/src/main/frontend/index.html b/src/main/frontend/index.html
new file mode 100644
index 0000000..282cf05
--- /dev/null
+++ b/src/main/frontend/index.html
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/BaseSyntaxHighlighter.java b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/BaseSyntaxHighlighter.java
new file mode 100644
index 0000000..cfdc742
--- /dev/null
+++ b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/BaseSyntaxHighlighter.java
@@ -0,0 +1,77 @@
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
+
+import com.vaadin.flow.component.HasSize;
+import com.vaadin.flow.component.react.ReactAdapterComponent;
+
+/**
+ * Base class for SyntaxHighlighters
+ */
+@SuppressWarnings("serial")
+public class BaseSyntaxHighlighter extends ReactAdapterComponent implements HasSize {
+
+ /**
+ * Returns true if the wrapLongLines feature is enabled
+ * More info: https://github.com/react-syntax-highlighter/react-syntax-highlighter?tab=readme-ov-file#props
+ * @return true if the wrapLongLines feature is enabled
+ */
+ public boolean isWrapLongLines() {
+ return getState("wrapLongLines", Boolean.class);
+ }
+
+ /**
+ * Enable or disable the wrapLongLines feature
+ * @param wrapLongLines boolean to enable or disable the wrapLongLines feature
+ */
+ public void setWrapLongLines(boolean wrapLongLines) {
+ setState("wrapLongLines", wrapLongLines);
+ }
+
+ /**
+ * Returns true if the showLineNumbers feature is enabled
+ * More info: https://github.com/react-syntax-highlighter/react-syntax-highlighter?tab=readme-ov-file#props
+ * @return true if the showLineNumbers feature is enabled
+ */
+ public boolean isShowLineNumbers() {
+ return getState("showLineNumbers", Boolean.class);
+ }
+
+ /**
+ * Enable or disable the showLineNumbers feature
+ * @param showLineNumbers boolean to enable or disable the showLineNumbers feature
+ */
+ public void setShowLineNumbers(boolean showLineNumbers) {
+ setState("showLineNumbers", showLineNumbers);
+ }
+
+ /**
+ * Returns the content of the Syntax Highlighter
+ * @return string with the contents
+ */
+ public String getContent() {
+ return getState("content", String.class);
+ }
+
+ /**
+ * Sets the content of the Syntax Highlighter
+ * @param content
+ */
+ public void setContent(String content) {
+ setState("content", content);
+ }
+
+ /**
+ * Sets the width of the Syntax Highlighter
+ */
+ @Override
+ public void setWidth(String width) {
+ getElement().executeJs("this.style.width = $0;", width);
+ }
+
+ /**
+ * Obtains the width of the Syntax Highlighter
+ */
+ public void setHeight(String height) {
+ getElement().executeJs("this.style.height = $0;", height);
+ }
+
+}
diff --git a/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShLanguage.java b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShLanguage.java
new file mode 100644
index 0000000..52121d7
--- /dev/null
+++ b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShLanguage.java
@@ -0,0 +1,232 @@
+/*-
+ * #%L
+ * Syntax Highlighter Add-on
+ * %%
+ * Copyright (C) 2024 Flowing Code
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
+
+/**
+ * Enum representing different programming languages supported by Syntax Highlighter.
+ *
+ * @author mlopezFC
+ * @since 1.0.0
+ */
+public enum ShLanguage {
+
+ ONEC("oneC"),
+ ABNF("abnf"),
+ ACCESSLOG("accesslog"),
+ ACTIONSCRIPT("actionscript"),
+ ADA("ada"),
+ ANGELSCRIPT("angelscript"),
+ APACHE("apache"),
+ APPLESCRIPT("applescript"),
+ ARCADE("arcade"),
+ ARDUINO("arduino"),
+ ARMASM("armasm"),
+ ASCIIDOC("asciidoc"),
+ ASPECTJ("aspectj"),
+ AUTOHOTKEY("autohotkey"),
+ AUTOIT("autoit"),
+ AVRASM("avrasm"),
+ AWK("awk"),
+ AXAPTA("axapta"),
+ BASH("bash"),
+ BASIC("basic"),
+ BNF("bnf"),
+ BRAINFUCK("brainfuck"),
+ CLIKE("cLike"),
+ C("c"),
+ CAL("cal"),
+ CAPNPROTO("capnproto"),
+ CEYLON("ceylon"),
+ CLEAN("clean"),
+ CLOJUREREPL("clojureRepl"),
+ CLOJURE("clojure"),
+ CMAKE("cmake"),
+ COFFEESCRIPT("coffeescript"),
+ COQ("coq"),
+ COS("cos"),
+ CPP("cpp"),
+ CRMSH("crmsh"),
+ CRYSTAL("crystal"),
+ CSHARP("csharp"),
+ CSP("csp"),
+ CSS("css"),
+ D("d"),
+ DART("dart"),
+ DELPHI("delphi"),
+ DIFF("diff"),
+ DJANGO("django"),
+ DNS("dns"),
+ DOCKERFILE("dockerfile"),
+ DOS("dos"),
+ DSCONFIG("dsconfig"),
+ DTS("dts"),
+ DUST("dust"),
+ EBNF("ebnf"),
+ ELIXIR("elixir"),
+ ELM("elm"),
+ ERB("erb"),
+ ERLANGREPL("erlangRepl"),
+ ERLANG("erlang"),
+ EXCEL("excel"),
+ FIX("fix"),
+ FLIX("flix"),
+ FORTRAN("fortran"),
+ FSHARP("fsharp"),
+ GAMS("gams"),
+ GAUSS("gauss"),
+ GCODE("gcode"),
+ GHERKIN("gherkin"),
+ GLSL("glsl"),
+ GML("gml"),
+ GO("go"),
+ GOLO("golo"),
+ GRADLE("gradle"),
+ GROOVY("groovy"),
+ HAML("haml"),
+ HANDLEBARS("handlebars"),
+ HASKELL("haskell"),
+ HAXE("haxe"),
+ HSP("hsp"),
+ HTMLBARS("htmlbars"),
+ HTTP("http"),
+ HY("hy"),
+ INFORM7("inform7"),
+ INI("ini"),
+ IRPF90("irpf90"),
+ ISBL("isbl"),
+ JAVA("java"),
+ JAVASCRIPT("javascript"),
+ JBOSSCLI("jbossCli"),
+ JSON("json"),
+ JULIAREPL("juliaRepl"),
+ JULIA("julia"),
+ KOTLIN("kotlin"),
+ LASSO("lasso"),
+ LATEX("latex"),
+ LDIF("ldif"),
+ LEAF("leaf"),
+ LESS("less"),
+ LISP("lisp"),
+ LIVECODESERVER("livecodeserver"),
+ LIVESCRIPT("livescript"),
+ LLVM("llvm"),
+ LSL("lsl"),
+ LUA("lua"),
+ MAKEFILE("makefile"),
+ MARKDOWN("markdown"),
+ MATHEMATICA("mathematica"),
+ MATLAB("matlab"),
+ MAXIMA("maxima"),
+ MEL("mel"),
+ MERCURY("mercury"),
+ MIPSASM("mipsasm"),
+ MIZAR("mizar"),
+ MOJOLICIOUS("mojolicious"),
+ MONKEY("monkey"),
+ MOONSCRIPT("moonscript"),
+ N1QL("n1ql"),
+ NGINX("nginx"),
+ NIM("nim"),
+ NIX("nix"),
+ NODEREPL("nodeRepl"),
+ NSIS("nsis"),
+ OBJECTIVEC("objectivec"),
+ OCAML("ocaml"),
+ OPENSCAD("openscad"),
+ OXYGENE("oxygene"),
+ PARSER3("parser3"),
+ PERL("perl"),
+ PF("pf"),
+ PGSQL("pgsql"),
+ PHPTEMPLATE("phpTemplate"),
+ PHP("php"),
+ PLAINTEXT("plaintext"),
+ PONY("pony"),
+ POWERSHELL("powershell"),
+ PROCESSING("processing"),
+ PROFILE("profile"),
+ PROLOG("prolog"),
+ PROPERTIES("properties"),
+ PROTOBUF("protobuf"),
+ PUPPET("puppet"),
+ PUREBASIC("purebasic"),
+ PYTHONREPL("pythonRepl"),
+ PYTHON("python"),
+ Q("q"),
+ QML("qml"),
+ R("r"),
+ REASONML("reasonml"),
+ RIB("rib"),
+ ROBOCONF("roboconf"),
+ ROUTEROS("routeros"),
+ RSL("rsl"),
+ RUBY("ruby"),
+ RULESLANGUAGE("ruleslanguage"),
+ RUST("rust"),
+ SAS("sas"),
+ SCALA("scala"),
+ SCHEME("scheme"),
+ SCILAB("scilab"),
+ SCSS("scss"),
+ SHELL("shell"),
+ SMALI("smali"),
+ SMALLTALK("smalltalk"),
+ SML("sml"),
+ SQF("sqf"),
+ SQL("sql"),
+ SQLMORE("sqlMore"),
+ STAN("stan"),
+ STATA("stata"),
+ STEP21("step21"),
+ STYLUS("stylus"),
+ SUBUNIT("subunit"),
+ SWIFT("swift"),
+ TAGGERSCRIPT("taggerscript"),
+ TAP("tap"),
+ TCL("tcl"),
+ THRIFT("thrift"),
+ TP("tp"),
+ TWIG("twig"),
+ TYPESCRIPT("typescript"),
+ VALA("vala"),
+ VBNET("vbnet"),
+ VBSCRIPTHTML("vbscriptHtml"),
+ VBSCRIPT("vbscript"),
+ VERILOG("verilog"),
+ VHDL("vhdl"),
+ VIM("vim"),
+ X86ASM("x86asm"),
+ XL("xl"),
+ XML("xml"),
+ XQUERY("xquery"),
+ YAML("yaml"),
+ ZEPHIR("zephir");
+
+ private final String name;
+
+ private ShLanguage(String language) {
+ name = language;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
diff --git a/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShLanguagePrism.java b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShLanguagePrism.java
new file mode 100644
index 0000000..908cbed
--- /dev/null
+++ b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShLanguagePrism.java
@@ -0,0 +1,317 @@
+/*-
+ * #%L
+ * Syntax Highlighter Add-on
+ * %%
+ * Copyright (C) 2024 Flowing Code
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
+
+/**
+ * Enum representing different programming languages supported by the Syntax Highlighter.
+ * Used only with Prism implementation
+ *
+ * @author mlopezFC
+ * @since 1.0.0
+ */
+public enum ShLanguagePrism {
+
+ ACTIONSCRIPT("actionscript"),
+ ADA("ada"),
+ AGDA("agda"),
+ AL("al"),
+ ANTLR4("antlr4"),
+ APACHECONF("apacheconf"),
+ APEX("apex"),
+ APL("apl"),
+ APPLESCRIPT("applescript"),
+ AQL("aql"),
+ ARDUINO("arduino"),
+ ARFF("arff"),
+ ASCIIDOC("asciidoc"),
+ ASM6502("asm6502"),
+ ASMATMEL("asmatmel"),
+ ASPNET("aspnet"),
+ AUTOHOTKEY("autohotkey"),
+ AUTOIT("autoit"),
+ AVISYNTH("avisynth"),
+ AVROIDL("avroIdl"),
+ BASH("bash"),
+ BASIC("basic"),
+ BATCH("batch"),
+ BBCODE("bbcode"),
+ BICEP("bicep"),
+ BIRB("birb"),
+ BISON("bison"),
+ BNF("bnf"),
+ BRAINFUCK("brainfuck"),
+ BRIGHTSCRIPT("brightscript"),
+ BRO("bro"),
+ BSL("bsl"),
+ C("c"),
+ CFSCRIPT("cfscript"),
+ CHAISCRIPT("chaiscript"),
+ CIL("cil"),
+ CLIKE("clike"),
+ CLOJURE("clojure"),
+ CMAKE("cmake"),
+ COBOL("cobol"),
+ COFFEESCRIPT("coffeescript"),
+ CONCURNAS("concurnas"),
+ COQ("coq"),
+ CPP("cpp"),
+ CRYSTAL("crystal"),
+ CSHARP("csharp"),
+ CSHTML("cshtml"),
+ CSP("csp"),
+ CSSEXTRAS("cssExtras"),
+ CSS("css"),
+ CSV("csv"),
+ CYPHER("cypher"),
+ D("d"),
+ DART("dart"),
+ DATAWEAVE("dataweave"),
+ DAX("dax"),
+ DHALL("dhall"),
+ DIFF("diff"),
+ DJANGO("django"),
+ DNSZONEFILE("dnsZoneFile"),
+ DOCKER("docker"),
+ DOT("dot"),
+ EBNF("ebnf"),
+ EDITORCONFIG("editorconfig"),
+ EIFFEL("eiffel"),
+ EJS("ejs"),
+ ELIXIR("elixir"),
+ ELM("elm"),
+ ERB("erb"),
+ ERLANG("erlang"),
+ ETLUA("etlua"),
+ EXCELFORMULA("excelFormula"),
+ FACTOR("factor"),
+ FALSELANG("falselang"),
+ FIRESTORESECURITYRULES("firestoreSecurityRules"),
+ FLOW("flow"),
+ FORTRAN("fortran"),
+ FSHARP("fsharp"),
+ FTL("ftl"),
+ GAP("gap"),
+ GCODE("gcode"),
+ GDSCRIPT("gdscript"),
+ GEDCOM("gedcom"),
+ GHERKIN("gherkin"),
+ GIT("git"),
+ GLSL("glsl"),
+ GML("gml"),
+ GN("gn"),
+ GOMODULE("goModule"),
+ GO("go"),
+ GRAPHQL("graphql"),
+ GROOVY("groovy"),
+ HAML("haml"),
+ HANDLEBARS("handlebars"),
+ HASKELL("haskell"),
+ HAXE("haxe"),
+ HCL("hcl"),
+ HLSL("hlsl"),
+ HOON("hoon"),
+ HPKP("hpkp"),
+ HSTS("hsts"),
+ HTTP("http"),
+ ICHIGOJAM("ichigojam"),
+ ICON("icon"),
+ ICUMESSAGEFORMAT("icuMessageFormat"),
+ IDRIS("idris"),
+ IECST("iecst"),
+ IGNORE("ignore"),
+ INFORM7("inform7"),
+ INI("ini"),
+ IO("io"),
+ J("j"),
+ JAVA("java"),
+ JAVADOC("javadoc"),
+ JAVADOCLIKE("javadoclike"),
+ JAVASCRIPT("javascript"),
+ JAVASTACKTRACE("javastacktrace"),
+ JEXL("jexl"),
+ JOLIE("jolie"),
+ JQ("jq"),
+ JSEXTRAS("jsExtras"),
+ JSTEMPLATES("jsTemplates"),
+ JSDOC("jsdoc"),
+ JSON("json"),
+ JSON5("json5"),
+ JSONP("jsonp"),
+ JSSTACKTRACE("jsstacktrace"),
+ JSX("jsx"),
+ JULIA("julia"),
+ KEEPALIVED("keepalived"),
+ KEYMAN("keyman"),
+ KOTLIN("kotlin"),
+ KUMIR("kumir"),
+ KUSTO("kusto"),
+ LATEX("latex"),
+ LATTE("latte"),
+ LESS("less"),
+ LILYPOND("lilypond"),
+ LIQUID("liquid"),
+ LISP("lisp"),
+ LIVESCRIPT("livescript"),
+ LLVM("llvm"),
+ LOG("log"),
+ LOLCODE("lolcode"),
+ LUA("lua"),
+ MAGMA("magma"),
+ MAKEFILE("makefile"),
+ MARKDOWN("markdown"),
+ MARKUPTEMPLATING("markupTemplating"),
+ MARKUP("markup"),
+ MATLAB("matlab"),
+ MAXSCRIPT("maxscript"),
+ MEL("mel"),
+ MERMAID("mermaid"),
+ MIZAR("mizar"),
+ MONGODB("mongodb"),
+ MONKEY("monkey"),
+ MOONSCRIPT("moonscript"),
+ N1QL("n1ql"),
+ N4JS("n4js"),
+ NAND2TETRISHDL("nand2tetrisHdl"),
+ NANISCRIPT("naniscript"),
+ NASM("nasm"),
+ NEON("neon"),
+ NEVOD("nevod"),
+ NGINX("nginx"),
+ NIM("nim"),
+ NIX("nix"),
+ NSIS("nsis"),
+ OBJECTIVEC("objectivec"),
+ OCAML("ocaml"),
+ OPENCL("opencl"),
+ OPENQASM("openqasm"),
+ OZ("oz"),
+ PARIGP("parigp"),
+ PARSER("parser"),
+ PASCAL("pascal"),
+ PASCALIGO("pascaligo"),
+ PCAXIS("pcaxis"),
+ PEOPLECODE("peoplecode"),
+ PERL("perl"),
+ PHPEXTRAS("phpExtras"),
+ PHP("php"),
+ PHPDOC("phpdoc"),
+ PLSQL("plsql"),
+ POWERQUERY("powerquery"),
+ POWERSHELL("powershell"),
+ PROCESSING("processing"),
+ PROLOG("prolog"),
+ PROMQL("promql"),
+ PROPERTIES("properties"),
+ PROTOBUF("protobuf"),
+ PSL("psl"),
+ PUG("pug"),
+ PUPPET("puppet"),
+ PURE("pure"),
+ PUREBASIC("purebasic"),
+ PURESCRIPT("purescript"),
+ PYTHON("python"),
+ Q("q"),
+ QML("qml"),
+ QORE("qore"),
+ QSHARP("qsharp"),
+ R("r"),
+ RACKET("racket"),
+ REASON("reason"),
+ REGEX("regex"),
+ REGO("rego"),
+ RENPY("renpy"),
+ REST("rest"),
+ RIP("rip"),
+ ROBOCONF("roboconf"),
+ ROBOTFRAMEWORK("robotframework"),
+ RUBY("ruby"),
+ RUST("rust"),
+ SAS("sas"),
+ SASS("sass"),
+ SCALA("scala"),
+ SCHEME("scheme"),
+ SCSS("scss"),
+ SHELLSESSION("shellSession"),
+ SMALI("smali"),
+ SMALLTALK("smalltalk"),
+ SMARTY("smarty"),
+ SML("sml"),
+ SOLIDITY("solidity"),
+ SOLUTIONFILE("solutionFile"),
+ SOY("soy"),
+ SPARQL("sparql"),
+ SPLUNKSPL("splunkSpl"),
+ SQF("sqf"),
+ SQL("sql"),
+ SQUIRREL("squirrel"),
+ STAN("stan"),
+ STYLUS("stylus"),
+ SWIFT("swift"),
+ SYSTEMD("systemd"),
+ T4CS("t4Cs"),
+ T4TEMPLATING("t4Templating"),
+ T4VB("t4Vb"),
+ TAP("tap"),
+ TCL("tcl"),
+ TEXTILE("textile"),
+ TOML("toml"),
+ TREMOR("tremor"),
+ TSX("tsx"),
+ TT2("tt2"),
+ TURTLE("turtle"),
+ TWIG("twig"),
+ TYPESCRIPT("typescript"),
+ TYPOSCRIPT("typoscript"),
+ UNREALSCRIPT("unrealscript"),
+ UORAZOR("uorazor"),
+ URI("uri"),
+ V("v"),
+ VALA("vala"),
+ VBNET("vbnet"),
+ VELOCITY("velocity"),
+ VERILOG("verilog"),
+ VHDL("vhdl"),
+ VIM("vim"),
+ VISUALBASIC("visualBasic"),
+ WARPSCRIPT("warpscript"),
+ WASM("wasm"),
+ WEBIDL("webIdl"),
+ WIKI("wiki"),
+ WOLFRAM("wolfram"),
+ WREN("wren"),
+ XEORA("xeora"),
+ XMLDOC("xmlDoc"),
+ XOJO("xojo"),
+ XQUERY("xquery"),
+ YAML("yaml"),
+ YANG("yang"),
+ ZIG("zig");
+
+ private final String name;
+
+ private ShLanguagePrism(String language) {
+ name = language;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
diff --git a/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShStyle.java b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShStyle.java
new file mode 100644
index 0000000..2de2340
--- /dev/null
+++ b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShStyle.java
@@ -0,0 +1,138 @@
+/*-
+ * #%L
+ * Syntax Highlighter Add-on
+ * %%
+ * Copyright (C) 2024 Flowing Code
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
+
+/**
+ * Enum representing different styles supported by the Syntax Highlighter.
+ *
+ * @author mlopezFC
+ * @since 1.0.0
+ */
+public enum ShStyle {
+
+ A11YDARK("a11yDark"),
+ A11YLIGHT("a11yLight"),
+ AGATE("agate"),
+ ANOLDHOPE("anOldHope"),
+ ANDROIDSTUDIO("androidstudio"),
+ ARDUINOLIGHT("arduinoLight"),
+ ARTA("arta"),
+ ASCETIC("ascetic"),
+ ATELIERCAVEDARK("atelierCaveDark"),
+ ATELIERCAVELIGHT("atelierCaveLight"),
+ ATELIERDUNEDARK("atelierDuneDark"),
+ ATELIERDUNELIGHT("atelierDuneLight"),
+ ATELIERESTUARYDARK("atelierEstuaryDark"),
+ ATELIERESTUARYLIGHT("atelierEstuaryLight"),
+ ATELIERFORESTDARK("atelierForestDark"),
+ ATELIERFORESTLIGHT("atelierForestLight"),
+ ATELIERHEATHDARK("atelierHeathDark"),
+ ATELIERHEATHLIGHT("atelierHeathLight"),
+ ATELIERLAKESIDEDARK("atelierLakesideDark"),
+ ATELIERLAKESIDELIGHT("atelierLakesideLight"),
+ ATELIERPLATEAUDARK("atelierPlateauDark"),
+ ATELIERPLATEAULIGHT("atelierPlateauLight"),
+ ATELIERSAVANNADARK("atelierSavannaDark"),
+ ATELIERSAVANNALIGHT("atelierSavannaLight"),
+ ATELIERSEASIDEDARK("atelierSeasideDark"),
+ ATELIERSEASIDELIGHT("atelierSeasideLight"),
+ ATELIERSULPHURPOOLDARK("atelierSulphurpoolDark"),
+ ATELIERSULPHURPOOLLIGHT("atelierSulphurpoolLight"),
+ ATOMONEDARKREASONABLE("atomOneDarkReasonable"),
+ ATOMONEDARK("atomOneDark"),
+ ATOMONELIGHT("atomOneLight"),
+ BROWNPAPER("brownPaper"),
+ CODEPENEMBED("codepenEmbed"),
+ COLORBREWER("colorBrewer"),
+ DARCULA("darcula"),
+ DARK("dark"),
+ DEFAULTSTYLE("defaultStyle"),
+ DOCCO("docco"),
+ DRACULA("dracula"),
+ FAR("far"),
+ FOUNDATION("foundation"),
+ GITHUBGIST("githubGist"),
+ GITHUB("github"),
+ GML("gml"),
+ GOOGLECODE("googlecode"),
+ GRADIENTDARK("gradientDark"),
+ GRADIENTLIGHT("gradientLight"),
+ GRAYSCALE("grayscale"),
+ GRUVBOXDARK("gruvboxDark"),
+ GRUVBOXLIGHT("gruvboxLight"),
+ HOPSCOTCH("hopscotch"),
+ HYBRID("hybrid"),
+ IDEA("idea"),
+ IRBLACK("irBlack"),
+ ISBLEDITORDARK("isblEditorDark"),
+ ISBLEDITORLIGHT("isblEditorLight"),
+ KIMBIEDARK("kimbieDark"),
+ KIMBIELIGHT("kimbieLight"),
+ LIGHTFAIR("lightfair"),
+ LIOSHI("lioshi"),
+ MAGULA("magula"),
+ MONOBLUE("monoBlue"),
+ MONOKAISUBLIME("monokaiSublime"),
+ MONOKAI("monokai"),
+ NIGHTOWL("nightOwl"),
+ NNFXDARK("nnfxDark"),
+ NNFX("nnfx"),
+ NORD("nord"),
+ OBSIDIAN("obsidian"),
+ OCEAN("ocean"),
+ PARAISODARK("paraisoDark"),
+ PARAISOLIGHT("paraisoLight"),
+ POJOAQUE("pojoaque"),
+ PUREBASIC("purebasic"),
+ QTCREATORDARK("qtcreatorDark"),
+ QTCREATORLIGHT("qtcreatorLight"),
+ RAILSCASTS("railscasts"),
+ RAINBOW("rainbow"),
+ ROUTEROS("routeros"),
+ SCHOOLBOOK("schoolBook"),
+ SHADESOFPURPLE("shadesOfPurple"),
+ SOLARIZEDDARK("solarizedDark"),
+ SOLARIZEDLIGHT("solarizedLight"),
+ SRCERY("srcery"),
+ STACKOVERFLOWDARK("stackoverflowDark"),
+ STACKOVERFLOWLIGHT("stackoverflowLight"),
+ SUNBURST("sunburst"),
+ TOMORROWNIGHTBLUE("tomorrowNightBlue"),
+ TOMORROWNIGHTBRIGHT("tomorrowNightBright"),
+ TOMORROWNIGHTEIGHTIES("tomorrowNightEighties"),
+ TOMORROWNIGHT("tomorrowNight"),
+ TOMORROW("tomorrow"),
+ VS("vs"),
+ VS2015("vs2015"),
+ XCODE("xcode"),
+ XT256("xt256"),
+ ZENBURN("zenburn");
+
+ private final String name;
+
+ private ShStyle(String style) {
+ name = style;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
diff --git a/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShStylePrism.java b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShStylePrism.java
new file mode 100644
index 0000000..dbb44de
--- /dev/null
+++ b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/ShStylePrism.java
@@ -0,0 +1,86 @@
+/*-
+ * #%L
+ * Syntax Highlighter Add-on
+ * %%
+ * Copyright (C) 2024 Flowing Code
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
+
+/**
+ * Enum representing different styles supported by the Syntax Highlighter.
+ * Used only with Prism implementation
+ *
+ * @author mlopezFC
+ * @since 1.0.0
+ */
+public enum ShStylePrism {
+
+ COY("coy"),
+ DARK("dark"),
+ FUNKY("funky"),
+ OKAIDIA("okaidia"),
+ SOLARIZEDLIGHT("solarizedlight"),
+ TOMORROW("tomorrow"),
+ TWILIGHT("twilight"),
+ PRISM("prism"),
+ A11YDARK("a11yDark"),
+ ATOMDARK("atomDark"),
+ BASE16ATELIERSULPHURPOOLLIGHT("base16AteliersulphurpoolLight"),
+ CB("cb"),
+ COLDARKCOLD("coldarkCold"),
+ COLDARKDARK("coldarkDark"),
+ COYWITHOUTSHADOWS("coyWithoutShadows"),
+ DARCULA("darcula"),
+ DRACULA("dracula"),
+ DUOTONEDARK("duotoneDark"),
+ DUOTONEEARTH("duotoneEarth"),
+ DUOTONEFOREST("duotoneForest"),
+ DUOTONELIGHT("duotoneLight"),
+ DUOTONESEA("duotoneSea"),
+ DUOTONESPACE("duotoneSpace"),
+ GHCOLORS("ghcolors"),
+ GRUVBOXDARK("gruvboxDark"),
+ GRUVBOXLIGHT("gruvboxLight"),
+ HOLITHEME("holiTheme"),
+ HOPSCOTCH("hopscotch"),
+ LUCARIO("lucario"),
+ MATERIALDARK("materialDark"),
+ MATERIALLIGHT("materialLight"),
+ MATERIALOCEANIC("materialOceanic"),
+ NIGHTOWL("nightOwl"),
+ NORD("nord"),
+ ONEDARK("oneDark"),
+ ONELIGHT("oneLight"),
+ POJOAQUE("pojoaque"),
+ SHADESOFPURPLE("shadesOfPurple"),
+ SOLARIZEDDARKATOM("solarizedDarkAtom"),
+ SYNTHWAVE84("synthwave84"),
+ VS("vs"),
+ VSCDARKPLUS("vscDarkPlus"),
+ XONOKAI("xonokai"),
+ ZTOUCH("zTouch");
+
+ private final String name;
+
+ private ShStylePrism(String style) {
+ name = style;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+}
diff --git a/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighter.java b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighter.java
new file mode 100644
index 0000000..7b5111a
--- /dev/null
+++ b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighter.java
@@ -0,0 +1,92 @@
+/*-
+ * #%L
+ * Syntax Highlighter Add-on
+ * %%
+ * Copyright (C) 2024 Flowing Code
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
+
+import com.vaadin.flow.component.Tag;
+import com.vaadin.flow.component.dependency.JsModule;
+import com.vaadin.flow.component.dependency.NpmPackage;
+
+/**
+ * A Vaadin component that wraps the react-syntax-highlighter library to provide syntax highlighting for code snippets.
+ *
+ * @author mlopezFC
+ * @since 1.0.0
+ */
+@SuppressWarnings("serial")
+@NpmPackage(value = "react-syntax-highlighter", version = "15.5.0")
+@JsModule("./react-syntax-highlighter.tsx")
+@Tag("syntax-highlighter")
+public class SyntaxHighlighter extends BaseSyntaxHighlighter {
+
+ /**
+ * Constructs a new SyntaxHighlighter for Java language with empty content
+ */
+ public SyntaxHighlighter() {
+ this(ShLanguage.JAVA, "");
+ }
+
+ /**
+ * Constructs a new SyntaxHighlighter with the specified language and content using a11yDark theme.
+ *
+ * @param language The programming language to highlight.
+ * @param content The code content to highlight.
+ */
+ public SyntaxHighlighter(ShLanguage language, String content) {
+ setShStyle(ShStyle.A11YDARK);
+ setShLanguage(language);
+ setContent(content);
+ setShowLineNumbers(false);
+ setWrapLongLines(false);
+ }
+
+ /**
+ * Obtains the current SyntaxHighlighter Language
+ * @return current language
+ */
+ public ShLanguage getShLanguage() {
+ return ShLanguage.valueOf(getState("language", String.class).toUpperCase());
+ }
+
+ /**
+ * Sets the SyntaxHighlighter Language
+ * @param language
+ */
+ public void setShLanguage(ShLanguage language) {
+ setState("language", language.getName());
+ }
+
+ /**
+ * Obtains the current SyntaxHighlighter Style
+ * @return style
+ */
+ public ShStyle getShStyle() {
+ return ShStyle.valueOf(getState("stylename", String.class).toUpperCase());
+ }
+
+ /**
+ * Sets the SyntaxHighlighter Style
+ * @param style
+ */
+ public void setShStyle(ShStyle style) {
+ setState("stylename", style.getName());
+ }
+
+}
diff --git a/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterPrism.java b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterPrism.java
new file mode 100644
index 0000000..7d664e2
--- /dev/null
+++ b/src/main/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterPrism.java
@@ -0,0 +1,93 @@
+/*-
+ * #%L
+ * Syntax Highlighter Add-on
+ * %%
+ * Copyright (C) 2024 Flowing Code
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
+
+import com.vaadin.flow.component.Tag;
+import com.vaadin.flow.component.dependency.JsModule;
+import com.vaadin.flow.component.dependency.NpmPackage;
+
+/**
+ * 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)
+ *
+ * @author mlopezFC
+ * @since 1.0.0
+ */
+@SuppressWarnings("serial")
+@NpmPackage(value = "react-syntax-highlighter", version = "15.5.0")
+@JsModule("./react-syntax-highlighter-prism.tsx")
+@Tag("syntax-highlighter-prism")
+public class SyntaxHighlighterPrism extends BaseSyntaxHighlighter {
+
+ /**
+ * Constructs a new SyntaxHighlighter for Java language with empty content
+ */
+ public SyntaxHighlighterPrism() {
+ this(ShLanguagePrism.JAVA, "");
+ }
+
+ /**
+ * Constructs a new SyntaxHighlighter with the specified language and content using a11yDark theme.
+ *
+ * @param language The programming language to highlight.
+ * @param content The code content to highlight.
+ */
+ public SyntaxHighlighterPrism(ShLanguagePrism language, String content) {
+ setShStyle(ShStylePrism.A11YDARK);
+ setShLanguage(language);
+ setContent(content);
+ setShowLineNumbers(false);
+ setWrapLongLines(false);
+ }
+
+ /**
+ * Obtains the current SyntaxHighlighterPrism Language
+ * @return
+ */
+ public ShLanguagePrism getShLanguage() {
+ return ShLanguagePrism.valueOf(getState("language", String.class).toUpperCase());
+ }
+
+ /**
+ * Sets the SyntaxHighlighterPrism Language
+ * @param language
+ */
+ public void setShLanguage(ShLanguagePrism language) {
+ setState("language", language.getName());
+ }
+
+ /**
+ * Obtains the current SyntaxHighlighterPrism Style
+ * @return
+ */
+ public ShStylePrism getShStyle() {
+ return ShStylePrism.valueOf(getState("stylename", String.class).toUpperCase());
+ }
+
+ /**
+ * Sets the SyntaxHighlighter Style
+ * @param style
+ */
+ public void setShStyle(ShStylePrism style) {
+ setState("stylename", style.getName());
+ }
+
+}
diff --git a/src/main/java/com/flowingcode/vaadin/addons/template/TemplateAddon.java b/src/main/java/com/flowingcode/vaadin/addons/template/TemplateAddon.java
deleted file mode 100644
index ab06f5a..0000000
--- a/src/main/java/com/flowingcode/vaadin/addons/template/TemplateAddon.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * #%L
- * Template Add-on
- * %%
- * Copyright (C) 2023 Flowing Code
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-package com.flowingcode.vaadin.addons.template;
-
-import com.vaadin.flow.component.Tag;
-import com.vaadin.flow.component.dependency.JsModule;
-import com.vaadin.flow.component.dependency.NpmPackage;
-import com.vaadin.flow.component.html.Div;
-
-@SuppressWarnings("serial")
-@NpmPackage(value = "@polymer/paper-input", version = "3.2.1")
-@JsModule("@polymer/paper-input/paper-input.js")
-@Tag("paper-input")
-public class TemplateAddon extends Div {}
diff --git a/src/main/resources/META-INF/resources/frontend/react-syntax-highlighter-prism.tsx b/src/main/resources/META-INF/resources/frontend/react-syntax-highlighter-prism.tsx
new file mode 100644
index 0000000..a7c4a4e
--- /dev/null
+++ b/src/main/resources/META-INF/resources/frontend/react-syntax-highlighter-prism.tsx
@@ -0,0 +1,31 @@
+import {type ReactElement} from 'react';
+import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
+import * as styles from 'react-syntax-highlighter/dist/esm/styles/prism';
+import {ReactAdapterElement, type RenderHooks} from "Frontend/generated/flow/ReactAdapter";
+import React from 'react';
+
+class SyntaxHighlighterPrismElement extends ReactAdapterElement {
+
+ protected override render(hooks: RenderHooks): ReactElement | null {
+ const [language] = hooks.useState("language");
+ const [content] = hooks.useState("content");
+ const [stylename] = hooks.useState("stylename");
+ const [showLineNumbers] = hooks.useState("showLineNumbers");
+ const [wrapLongLines] = hooks.useState("wrapLongLines");
+
+ return
+ {content}
+ ;
+ }
+}
+
+customElements.define("syntax-highlighter-prism",SyntaxHighlighterPrismElement);
\ No newline at end of file
diff --git a/src/main/resources/META-INF/resources/frontend/react-syntax-highlighter.tsx b/src/main/resources/META-INF/resources/frontend/react-syntax-highlighter.tsx
new file mode 100644
index 0000000..73544ad
--- /dev/null
+++ b/src/main/resources/META-INF/resources/frontend/react-syntax-highlighter.tsx
@@ -0,0 +1,31 @@
+import {type ReactElement} from 'react';
+import SyntaxHighlighter from 'react-syntax-highlighter';
+import * as styles from 'react-syntax-highlighter/dist/esm/styles/hljs';
+import {ReactAdapterElement, type RenderHooks} from "Frontend/generated/flow/ReactAdapter";
+import React from 'react';
+
+class SyntaxHighlighterElement extends ReactAdapterElement {
+
+ protected override render(hooks: RenderHooks): ReactElement | null {
+ const [language] = hooks.useState("language");
+ const [content] = hooks.useState("content");
+ const [stylename] = hooks.useState("stylename");
+ const [showLineNumbers] = hooks.useState("showLineNumbers");
+ const [wrapLongLines] = hooks.useState("wrapLongLines");
+
+ return
+ {content}
+ ;
+ }
+}
+
+customElements.define("syntax-highlighter",SyntaxHighlighterElement);
\ No newline at end of file
diff --git a/src/main/resources/META-INF/frontend/styles/static_addon_styles b/src/main/resources/META-INF/resources/frontend/styles/static_addon_styles
similarity index 100%
rename from src/main/resources/META-INF/frontend/styles/static_addon_styles
rename to src/main/resources/META-INF/resources/frontend/styles/static_addon_styles
diff --git a/src/test/java/com/flowingcode/vaadin/addons/DemoLayout.java b/src/test/java/com/flowingcode/vaadin/addons/DemoLayout.java
index 8d29aba..1dd2b87 100644
--- a/src/test/java/com/flowingcode/vaadin/addons/DemoLayout.java
+++ b/src/test/java/com/flowingcode/vaadin/addons/DemoLayout.java
@@ -1,15 +1,15 @@
/*-
* #%L
- * Template Add-on
+ * Syntax Highlighter Add-on
* %%
- * Copyright (C) 2023 Flowing Code
+ * Copyright (C) 2024 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
diff --git a/src/test/java/com/flowingcode/vaadin/addons/template/DemoView.java b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/DemoView.java
similarity index 84%
rename from src/test/java/com/flowingcode/vaadin/addons/template/DemoView.java
rename to src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/DemoView.java
index a6a1d28..f7df9e7 100644
--- a/src/test/java/com/flowingcode/vaadin/addons/template/DemoView.java
+++ b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/DemoView.java
@@ -1,15 +1,15 @@
/*-
* #%L
- * Template Add-on
+ * Syntax Highlighter Add-on
* %%
- * Copyright (C) 2023 Flowing Code
+ * Copyright (C) 2024 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +18,7 @@
* #L%
*/
-package com.flowingcode.vaadin.addons.template;
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.BeforeEnterEvent;
@@ -31,6 +31,6 @@ public class DemoView extends VerticalLayout implements BeforeEnterObserver {
@Override
public void beforeEnter(BeforeEnterEvent event) {
- event.forwardTo(TemplateDemoView.class);
+ event.forwardTo(SyntaxHighlighterDemoView.class);
}
}
diff --git a/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterDemo.java b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterDemo.java
new file mode 100644
index 0000000..4b648a3
--- /dev/null
+++ b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterDemo.java
@@ -0,0 +1,83 @@
+/*-
+ * #%L
+ * Syntax Highlighter Add-on
+ * %%
+ * Copyright (C) 2024 Flowing Code
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
+
+import com.flowingcode.vaadin.addons.demo.DemoSource;
+import com.vaadin.flow.component.button.Button;
+import com.vaadin.flow.component.checkbox.Checkbox;
+import com.vaadin.flow.component.combobox.ComboBox;
+import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
+import com.vaadin.flow.component.orderedlayout.VerticalLayout;
+import com.vaadin.flow.component.textfield.TextArea;
+import com.vaadin.flow.router.PageTitle;
+import com.vaadin.flow.router.Route;
+
+@DemoSource
+@PageTitle("Syntax Highlighter Add-on Demo")
+@SuppressWarnings("serial")
+@Route(value = "syntax-highlighter/basic", layout = SyntaxHighlighterDemoView.class)
+public class SyntaxHighlighterDemo extends VerticalLayout {
+
+ public SyntaxHighlighterDemo() {
+ String defaultValue = """
+import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
+import { dark } from 'react-syntax-highlighter/dist/esm/styles/prism';
+const Component = () => {
+ const codeString = '(num) => num + 1';
+ return (
+
+ {codeString}
+
+ );
+};
+ """;
+ SyntaxHighlighter sh = new SyntaxHighlighter(ShLanguage.JAVASCRIPT, defaultValue);
+ sh.setSizeFull();
+ ComboBox style = new ComboBox<>();
+ style.setItems(ShStyle.values());
+ style.addValueChangeListener(ev->{
+ sh.setShStyle(style.getValue());
+ });
+ style.setValue(ShStyle.A11YDARK);
+ ComboBox languages = new ComboBox<>();
+ languages.setItems(ShLanguage.values());
+ languages.setItemLabelGenerator(language->language.getName());
+ languages.setValue(ShLanguage.JAVASCRIPT);
+ languages.addValueChangeListener(ev->{
+ sh.setShLanguage(ev.getValue());
+ });
+ Checkbox showLineNumbers = new Checkbox("Show Line Numbers");
+ showLineNumbers.addValueChangeListener(ev->{
+ sh.setShowLineNumbers(ev.getValue());
+ });
+ Checkbox wrapLongLines = new Checkbox("Wrap long lines");
+ wrapLongLines.addValueChangeListener(ev->{
+ sh.setWrapLongLines(ev.getValue());
+ });
+ TextArea ta = new TextArea();
+ ta.setValue(defaultValue);
+ ta.setWidthFull();
+ Button button = new Button("Update code");
+ button.addClickListener(ev->{
+ sh.setContent(ta.getValue());
+ });
+ add(new HorizontalLayout(style,languages), showLineNumbers, wrapLongLines, sh, ta, button);
+ }
+}
diff --git a/src/test/java/com/flowingcode/vaadin/addons/template/TemplateDemoView.java b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterDemoView.java
similarity index 64%
rename from src/test/java/com/flowingcode/vaadin/addons/template/TemplateDemoView.java
rename to src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterDemoView.java
index 1c3aecd..073c083 100644
--- a/src/test/java/com/flowingcode/vaadin/addons/template/TemplateDemoView.java
+++ b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterDemoView.java
@@ -1,15 +1,15 @@
/*-
* #%L
- * Template Add-on
+ * Syntax Highlighter Add-on
* %%
- * Copyright (C) 2023 Flowing Code
+ * Copyright (C) 2024 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,10 @@
* limitations under the License.
* #L%
*/
-package com.flowingcode.vaadin.addons.template;
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
import com.flowingcode.vaadin.addons.DemoLayout;
+import com.flowingcode.vaadin.addons.GithubBranch;
import com.flowingcode.vaadin.addons.GithubLink;
import com.flowingcode.vaadin.addons.demo.TabbedDemo;
import com.vaadin.flow.router.ParentLayout;
@@ -27,12 +28,14 @@
@SuppressWarnings("serial")
@ParentLayout(DemoLayout.class)
-@Route("template")
-@GithubLink("https://github.com/FlowingCode/AddonStarter24")
-public class TemplateDemoView extends TabbedDemo {
+@Route("syntax-highlighter")
+@GithubLink("https://github.com/FlowingCode/SyntaxHighlighter")
+@GithubBranch("initial-implementation")
+public class SyntaxHighlighterDemoView extends TabbedDemo {
- public TemplateDemoView() {
- addDemo(TemplateDemo.class);
+ public SyntaxHighlighterDemoView() {
+ addDemo(SyntaxHighlighterDemo.class);
+ addDemo(SyntaxHighlighterPrismDemo.class);
setSizeFull();
}
}
diff --git a/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterPrismDemo.java b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterPrismDemo.java
new file mode 100644
index 0000000..6cc87bb
--- /dev/null
+++ b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/SyntaxHighlighterPrismDemo.java
@@ -0,0 +1,83 @@
+/*-
+ * #%L
+ * Syntax Highlighter Add-on
+ * %%
+ * Copyright (C) 2024 Flowing Code
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+package com.flowingcode.vaadin.addons.syntaxhighlighter;
+
+import com.flowingcode.vaadin.addons.demo.DemoSource;
+import com.vaadin.flow.component.button.Button;
+import com.vaadin.flow.component.checkbox.Checkbox;
+import com.vaadin.flow.component.combobox.ComboBox;
+import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
+import com.vaadin.flow.component.orderedlayout.VerticalLayout;
+import com.vaadin.flow.component.textfield.TextArea;
+import com.vaadin.flow.router.PageTitle;
+import com.vaadin.flow.router.Route;
+
+@DemoSource
+@PageTitle("Syntax Highlighter Add-on Demo (Prism)")
+@SuppressWarnings("serial")
+@Route(value = "syntax-highlighter/prism", layout = SyntaxHighlighterDemoView.class)
+public class SyntaxHighlighterPrismDemo extends VerticalLayout {
+
+ public SyntaxHighlighterPrismDemo() {
+ String defaultValue = """
+import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
+import { dark } from 'react-syntax-highlighter/dist/esm/styles/prism';
+const Component = () => {
+ const codeString = '(num) => num + 1';
+ return (
+
+ {codeString}
+
+ );
+};
+ """;
+ SyntaxHighlighterPrism sh = new SyntaxHighlighterPrism(ShLanguagePrism.JAVASCRIPT, defaultValue);
+ sh.setSizeFull();
+ ComboBox style = new ComboBox<>();
+ style.setItems(ShStylePrism.values());
+ style.addValueChangeListener(ev->{
+ sh.setShStyle(style.getValue());
+ });
+ style.setValue(ShStylePrism.A11YDARK);
+ ComboBox languages = new ComboBox<>();
+ languages.setItems(ShLanguagePrism.values());
+ languages.setItemLabelGenerator(language->language.getName());
+ languages.setValue(ShLanguagePrism.TYPESCRIPT);
+ languages.addValueChangeListener(ev->{
+ sh.setShLanguage(ev.getValue());
+ });
+ Checkbox showLineNumbers = new Checkbox("Show Line Numbers");
+ showLineNumbers.addValueChangeListener(ev->{
+ sh.setShowLineNumbers(ev.getValue());
+ });
+ Checkbox wrapLongLines = new Checkbox("Wrap long lines");
+ wrapLongLines.addValueChangeListener(ev->{
+ sh.setWrapLongLines(ev.getValue());
+ });
+ TextArea ta = new TextArea();
+ ta.setValue(defaultValue);
+ ta.setWidthFull();
+ Button button = new Button("Update code");
+ button.addClickListener(ev->{
+ sh.setContent(ta.getValue());
+ });
+ add(new HorizontalLayout(style,languages), showLineNumbers, wrapLongLines, sh, ta, button);
+ }
+}
diff --git a/src/test/java/com/flowingcode/vaadin/addons/template/it/AbstractViewTest.java b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/it/AbstractViewTest.java
similarity index 96%
rename from src/test/java/com/flowingcode/vaadin/addons/template/it/AbstractViewTest.java
rename to src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/it/AbstractViewTest.java
index c2fda15..f493290 100644
--- a/src/test/java/com/flowingcode/vaadin/addons/template/it/AbstractViewTest.java
+++ b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/it/AbstractViewTest.java
@@ -1,15 +1,15 @@
/*-
* #%L
- * Template Add-on
+ * Syntax Highlighter Add-on
* %%
- * Copyright (C) 2023 Flowing Code
+ * Copyright (C) 2024 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +18,7 @@
* #L%
*/
-package com.flowingcode.vaadin.addons.template.it;
+package com.flowingcode.vaadin.addons.syntaxhighlighter.it;
import com.vaadin.testbench.ScreenshotOnFailureRule;
import com.vaadin.testbench.TestBench;
diff --git a/src/test/java/com/flowingcode/vaadin/addons/template/it/ViewIT.java b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/it/ViewIT.java
similarity index 90%
rename from src/test/java/com/flowingcode/vaadin/addons/template/it/ViewIT.java
rename to src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/it/ViewIT.java
index 16a2a12..c536984 100644
--- a/src/test/java/com/flowingcode/vaadin/addons/template/it/ViewIT.java
+++ b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/it/ViewIT.java
@@ -1,15 +1,15 @@
/*-
* #%L
- * Template Add-on
+ * Syntax Highlighter Add-on
* %%
- * Copyright (C) 2023 Flowing Code
+ * Copyright (C) 2024 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +18,7 @@
* #L%
*/
-package com.flowingcode.vaadin.addons.template.it;
+package com.flowingcode.vaadin.addons.syntaxhighlighter.it;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
@@ -58,7 +58,7 @@ protected boolean matchesSafely(TestBenchElement item, Description mismatchDescr
@Test
public void componentWorks() {
- TestBenchElement element = $("paper-input").first();
+ TestBenchElement element = $("syntax-highlighter").first();
assertThat(element, hasBeenUpgradedToCustomElement);
}
}
diff --git a/src/test/java/com/flowingcode/vaadin/addons/template/test/SerializationTest.java b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/test/SerializationTest.java
similarity index 85%
rename from src/test/java/com/flowingcode/vaadin/addons/template/test/SerializationTest.java
rename to src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/test/SerializationTest.java
index dcf9b4e..6ed7c0f 100644
--- a/src/test/java/com/flowingcode/vaadin/addons/template/test/SerializationTest.java
+++ b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/test/SerializationTest.java
@@ -1,15 +1,15 @@
/*-
* #%L
- * Template Add-on
+ * Syntax Highlighter Add-on
* %%
- * Copyright (C) 2023 Flowing Code
+ * Copyright (C) 2024 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,9 +17,8 @@
* limitations under the License.
* #L%
*/
-package com.flowingcode.vaadin.addons.template.test;
+package com.flowingcode.vaadin.addons.syntaxhighlighter.test;
-import com.flowingcode.vaadin.addons.template.TemplateAddon;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -27,6 +26,7 @@
import java.io.ObjectOutputStream;
import org.junit.Assert;
import org.junit.Test;
+import com.flowingcode.vaadin.addons.syntaxhighlighter.SyntaxHighlighter;
public class SerializationTest {
@@ -44,7 +44,7 @@ private void testSerializationOf(Object obj) throws IOException, ClassNotFoundEx
@Test
public void testSerialization() throws ClassNotFoundException, IOException {
try {
- testSerializationOf(new TemplateAddon());
+ testSerializationOf(new SyntaxHighlighter());
} catch (Exception e) {
Assert.fail("Problem while testing serialization: " + e.getMessage());
}
diff --git a/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/test/SyntaxHighlighterPrismTest.java b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/test/SyntaxHighlighterPrismTest.java
new file mode 100644
index 0000000..37eb9ff
--- /dev/null
+++ b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/test/SyntaxHighlighterPrismTest.java
@@ -0,0 +1,55 @@
+package com.flowingcode.vaadin.addons.syntaxhighlighter.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import com.flowingcode.vaadin.addons.syntaxhighlighter.ShLanguagePrism;
+import com.flowingcode.vaadin.addons.syntaxhighlighter.ShStylePrism;
+import com.flowingcode.vaadin.addons.syntaxhighlighter.SyntaxHighlighterPrism;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SyntaxHighlighterPrismTest {
+
+ private SyntaxHighlighterPrism syntaxHighlighter;
+
+ @Before
+ public void setUp() {
+ syntaxHighlighter = new SyntaxHighlighterPrism();
+ }
+
+ @Test
+ public void testDefaultConstructor() {
+ assertEquals(ShLanguagePrism.JAVA, syntaxHighlighter.getShLanguage());
+ assertEquals(ShStylePrism.A11YDARK, syntaxHighlighter.getShStyle());
+ assertEquals("", syntaxHighlighter.getContent());
+ assertFalse(syntaxHighlighter.isShowLineNumbers());
+ assertFalse(syntaxHighlighter.isWrapLongLines());
+ }
+
+ @Test
+ public void testParameterizedConstructor() {
+ SyntaxHighlighterPrism sh = new SyntaxHighlighterPrism(ShLanguagePrism.JAVASCRIPT,
+ "test");
+ assertEquals(ShLanguagePrism.JAVASCRIPT, sh.getShLanguage());
+ assertEquals(ShStylePrism.A11YDARK, sh.getShStyle());
+ assertEquals("test", sh.getContent());
+ assertFalse(sh.isShowLineNumbers());
+ assertFalse(sh.isWrapLongLines());
+ }
+
+ @Test
+ public void testSettersAndGetters() {
+ syntaxHighlighter.setShLanguage(ShLanguagePrism.PYTHON);
+ syntaxHighlighter.setShStyle(ShStylePrism.A11YDARK);
+ syntaxHighlighter.setContent("test content");
+ syntaxHighlighter.setShowLineNumbers(true);
+ syntaxHighlighter.setWrapLongLines(true);
+
+ assertEquals(ShLanguagePrism.PYTHON, syntaxHighlighter.getShLanguage());
+ assertEquals(ShStylePrism.A11YDARK, syntaxHighlighter.getShStyle());
+ assertEquals("test content", syntaxHighlighter.getContent());
+ assertTrue(syntaxHighlighter.isShowLineNumbers());
+ assertTrue(syntaxHighlighter.isWrapLongLines());
+ }
+}
diff --git a/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/test/SyntaxHighlighterTest.java b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/test/SyntaxHighlighterTest.java
new file mode 100644
index 0000000..7248b9c
--- /dev/null
+++ b/src/test/java/com/flowingcode/vaadin/addons/syntaxhighlighter/test/SyntaxHighlighterTest.java
@@ -0,0 +1,55 @@
+package com.flowingcode.vaadin.addons.syntaxhighlighter.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import com.flowingcode.vaadin.addons.syntaxhighlighter.ShLanguage;
+import com.flowingcode.vaadin.addons.syntaxhighlighter.ShStyle;
+import com.flowingcode.vaadin.addons.syntaxhighlighter.SyntaxHighlighter;
+import org.junit.Before;
+import org.junit.Test;
+
+public class SyntaxHighlighterTest {
+
+ private SyntaxHighlighter syntaxHighlighter;
+
+ @Before
+ public void setUp() {
+ syntaxHighlighter = new SyntaxHighlighter();
+ }
+
+ @Test
+ public void testDefaultConstructor() {
+ assertEquals(ShLanguage.JAVA, syntaxHighlighter.getShLanguage());
+ assertEquals(ShStyle.A11YDARK, syntaxHighlighter.getShStyle());
+ assertEquals("", syntaxHighlighter.getContent());
+ assertFalse(syntaxHighlighter.isShowLineNumbers());
+ assertFalse(syntaxHighlighter.isWrapLongLines());
+ }
+
+ @Test
+ public void testParameterizedConstructor() {
+ SyntaxHighlighter sh =
+ new SyntaxHighlighter(ShLanguage.JAVASCRIPT, "test");
+ assertEquals(ShLanguage.JAVASCRIPT, sh.getShLanguage());
+ assertEquals(ShStyle.A11YDARK, sh.getShStyle());
+ assertEquals("test", sh.getContent());
+ assertFalse(sh.isShowLineNumbers());
+ assertFalse(sh.isWrapLongLines());
+ }
+
+ @Test
+ public void testSettersAndGetters() {
+ syntaxHighlighter.setShLanguage(ShLanguage.PYTHON);
+ syntaxHighlighter.setShStyle(ShStyle.A11YDARK);
+ syntaxHighlighter.setContent("test content");
+ syntaxHighlighter.setShowLineNumbers(true);
+ syntaxHighlighter.setWrapLongLines(true);
+
+ assertEquals(ShLanguage.PYTHON, syntaxHighlighter.getShLanguage());
+ assertEquals(ShStyle.A11YDARK, syntaxHighlighter.getShStyle());
+ assertEquals("test content", syntaxHighlighter.getContent());
+ assertTrue(syntaxHighlighter.isShowLineNumbers());
+ assertTrue(syntaxHighlighter.isWrapLongLines());
+ }
+}
diff --git a/src/test/java/com/flowingcode/vaadin/addons/template/TemplateDemo.java b/src/test/java/com/flowingcode/vaadin/addons/template/TemplateDemo.java
deleted file mode 100644
index 5f6e6ee..0000000
--- a/src/test/java/com/flowingcode/vaadin/addons/template/TemplateDemo.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.flowingcode.vaadin.addons.template;
-
-import com.flowingcode.vaadin.addons.demo.DemoSource;
-import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.router.PageTitle;
-import com.vaadin.flow.router.Route;
-
-@DemoSource
-@PageTitle("Template Add-on Demo")
-@SuppressWarnings("serial")
-@Route(value = "demo", layout = TemplateDemoView.class)
-public class TemplateDemo extends Div {
-
- public TemplateDemo() {
- add(new TemplateAddon());
- }
-}
diff --git a/src/test/resources/META-INF/frontend/styles/shared-styles.css b/src/test/resources/META-INF/frontend/styles/shared-styles.css
index 6680e2d..d493937 100644
--- a/src/test/resources/META-INF/frontend/styles/shared-styles.css
+++ b/src/test/resources/META-INF/frontend/styles/shared-styles.css
@@ -1 +1,20 @@
-/*Demo styles*/
\ No newline at end of file
+/*-
+ * #%L
+ * Syntax Highlighter Add-on
+ * %%
+ * Copyright (C) 2024 Flowing Code
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * #L%
+ */
+/*Demo styles*/