Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
ticket #10, resolve #9, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
blutorange committed Aug 30, 2019
1 parent 0fc407d commit efe602c
Show file tree
Hide file tree
Showing 26 changed files with 731 additions and 1,163 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
See also [the changelog of monaco-editor](https://github.com/Microsoft/monaco-editor/blob/master/CHANGELOG.md).

# 0.17.2

- Fix #10. Load CSS worker when language is set to SCSS or LESS
- Fix a missing localization (CSS specificity tooltip)
- Implement #9. Add new method to extender: `createEditorOverrideOptions`. This lets you pass specify custom override services to the
editor.
- Demo project: change from cargo to jetty

# 0.17.1

- Update to monaco editor 0.17.1
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,19 @@ cd primefaces-monaco
mvn clean install
```

To create a dev build with JavaScript source maps:

```bash
mvn clean install -P dev
```

If you did not make any changes to the monaco editor JavaScript files, you can
speed up the build by skipping npm/webpack:

```bash
mvn install -P dev -Dskip.npm -Dskip.webpack
```

This will clone the [Microsoft/vscode-loc](Microsoft/vscode-loc) repository, download a local
installation of [node](https://nodejs.org) and [npm](http://npmjs.com/), generate some source
files and finally build the `jar`.
Expand Down Expand Up @@ -410,7 +423,7 @@ To run it, first build the editor via `mvn clean install`, then

```bash
cd demo
mvn package cargo:run
mvn package jetty:run
```

This starts a local application server with the demo project. Navigate to [http://localhost:8094/monaco/test.xhtml](http://localhost:8094/monaco/test.xhtml).
133 changes: 36 additions & 97 deletions demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>monacotest</groupId>
<artifactId>monacotest</artifactId>
<version>0.17.1</version>
<version>0.17.2</version>
<packaging>war</packaging>

<repositories>
Expand All @@ -19,61 +19,20 @@
</repositories>

<properties>
<blutorange-common-java-version>0.0.1-SNAPSHOT</blutorange-common-java-version>
<blutorange-nullannotation-version>0.0.1-SNAPSHOT</blutorange-nullannotation-version>
<build-helper-maven-plugin-version>3.0.0</build-helper-maven-plugin-version>
<cargo-maven2-plugin-version>1.6.9</cargo-maven2-plugin-version>
<commons-dbcp-version>1.4</commons-dbcp-version>
<commons-io-version>2.4</commons-io-version>
<commons-lang3-version>3.6</commons-lang3-version>
<commons-math3-version>3.6.1</commons-math3-version>
<commons-text-version>1.1</commons-text-version>
<dagger-version>2.11</dagger-version>
<eclipse-annotation-version>2.0.0</eclipse-annotation-version>
<exec-maven-plugin-version>1.5.0</exec-maven-plugin-version>
<fastjson-version>1.2.37</fastjson-version>
<hibernate-version>5.2.10.Final</hibernate-version>
<hikari-cp-version>2.6.2</hikari-cp-version>
<javax-annotation-api>1.3</javax-annotation-api>
<javax-ejb-api-version>3.2</javax-ejb-api-version>
<javax-el-api-version>2.2.5</javax-el-api-version>
<javax-el-impl-version>2.2</javax-el-impl-version>
<javax-faces-version>2.2.14</javax-faces-version>
<javax-servlet-api-version>3.0.1</javax-servlet-api-version>
<javax-websocket-api-version>1.1</javax-websocket-api-version>
<javax-ws-rs-api-version>2.0.1</javax-ws-rs-api-version>
<jsf-impl-version>2.2.14</jsf-impl-version>
<jsoniter-version>0.9.15</jsoniter-version>
<jsp-api-version>2.3.1</jsp-api-version>
<jstl-version>1.2</jstl-version>
<lifecycle-mapping>1.0.0</lifecycle-mapping>
<log4j-version>1.2.17</log4j-version>
<m2e.jdt.annotationpath>/nullannotation/src/main/java</m2e.jdt.annotationpath>
<mariadb-java-client-version>2.1.0</mariadb-java-client-version>
<maven-antrun-plugin-version>1.8</maven-antrun-plugin-version>
<maven-compiler-plugin-version>3.5.1</maven-compiler-plugin-version>
<maven-gpg-plugin-version>1.6</maven-gpg-plugin-version>
<maven-javadoc-plugin-version>2.10.4</maven-javadoc-plugin-version>
<maven-processor-plugin-version>3.3.1</maven-processor-plugin-version>
<maven-resources-plugin-version>2.6</maven-resources-plugin-version>
<maven-source-plugin-version>3.0.1</maven-source-plugin-version>
<maven-war-plugin-version>3.2.0</maven-war-plugin-version>
<myfaces-version>2.2.12</myfaces-version>
<mysql-connector-java-version>6.0.6</mysql-connector-java-version>
<nexus-staging-version>1.6.8</nexus-staging-version>
<omnifaces-version>1.14.1</omnifaces-version>
<postgresql-version>42.1.4</postgresql-version>
<primefaces-themes-version>1.0.10</primefaces-themes-version>
<javax-el-impl.version>2.2</javax-el-impl.version>
<javax-faces.version>2.2.14</javax-faces.version>
<javax-servlet-api.version>3.0.1</javax-servlet-api.version>
<javax-ws-rs-api.version>2.0.1</javax-ws-rs-api.version>
<jetty-maven-plugin.version>9.4.20.v20190813</jetty-maven-plugin.version>
<jstl.version>1.2</jstl.version>
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
<maven-war-plugin.version>3.2.0</maven-war-plugin.version>
<primefaces-themes.version>1.0.10</primefaces-themes.version>
<primefaces.version>7.0</primefaces.version>
<primefaces.extensions.version>7.0</primefaces.extensions.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<quartz-version>2.3.0</quartz-version>
<sfm-version>3.13</sfm-version>
<slf4j-api-version>1.7.25</slf4j-api-version>
<slf4j-log4j12-version>1.7.25</slf4j-log4j12-version>
<tika-version>1.16</tika-version>
<tomcat7-maven-plugin-version>2.2</tomcat7-maven-plugin-version>
<validation-api-version>2.0.0.Final</validation-api-version>
<slf4j-api.version>1.7.25</slf4j-api.version>
<slf4j-log4j12.version>1.7.25</slf4j-log4j12.version>
</properties>

<dependencies>
Expand All @@ -86,12 +45,13 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>${jstl-version}</version>
<version>${jstl.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>${javax-el-impl-version}</version>
<version>${javax-el-impl.version}</version>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
Expand All @@ -106,32 +66,33 @@
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>all-themes</artifactId>
<version>${primefaces-themes-version}</version>
<version>${primefaces-themes.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>${javax-faces-version}</version>
<version>${javax-faces.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-api-version}</version>
<version>${slf4j-api.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j-log4j12-version}</version>
<version>${slf4j-log4j12.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${javax-ws-rs-api-version}</version>
<version>${javax-ws-rs-api.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${javax-servlet-api-version}</version>
<version>${javax-servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.blutorange</groupId>
Expand All @@ -157,7 +118,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin-version}</version>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand All @@ -166,46 +127,24 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven-war-plugin-version}</version>
<version>${maven-war-plugin.version}</version>
<configuration>
<failOnMissingWebXml>true</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>${cargo-maven2-plugin-version}</version>
<configuration>
<container>
<containerId>jetty8x</containerId>
</container>
<configuration>
<type>standalone</type>
<home>
${project.build.directory}/server
</home>
<properties>
<cargo.servlet.port>8094</cargo.servlet.port>
<cargo.logging>medium</cargo.logging>
<cargo.start.jvmargs>
-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
-Xnoagent
-Djava.compiler=NONE
</cargo.start.jvmargs>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<type>war</type>
<properties>
<context>/monaco</context>
</properties>
</deployable>
</deployables>
</configuration>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-maven-plugin.version}</version>
<configuration>
<scanIntervalSeconds>2</scanIntervalSeconds>
<httpConnector>
<port>8094</port>
</httpConnector>
<webApp>
<contextPath>/monaco</contextPath>
</webApp>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
5 changes: 5 additions & 0 deletions demo/src/main/java/TestBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public class TestBean implements Serializable {

@PostConstruct
private void init() {
resetSettings();
}

public void resetSettings() {
uiLanguage = "en";
theEnum = TheEnum.Foo;
code = "/**\n" + " * @param {number} x The first number.\n" + " * @param {number} y The second number.\n" + " * @return {number} The sum of the numbers\n" + " */\n" + "function testbar(x, y) {\n" + "\treturn x + y;\n" + "}\n" + "const z1 = testbar(5, 3);\n" + "const z2 = testbar(5, 3);\n" + "const z3 = testbar(5, 3);\n\n$(\".acc\").accordion(\"refresh\");";
Expand All @@ -36,6 +40,7 @@ private void init() {
.setSuggest(new EditorSuggestOptions()
.addFilteredType("keyword", false)
)
.setSuggestSelection(ESuggestSelection.RECENTLY_USED)
.setLineNumbers(ELineNumbers.ON)
.setWordWrap(EWordWrap.ON)
.addRuler(60, 100)
Expand Down
2 changes: 1 addition & 1 deletion demo/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<display-name>HelloWorldJSF</display-name>

<welcome-file-list>
<welcome-file>faces/test.xhtml</welcome-file>
<welcome-file>test.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
Expand Down
75 changes: 71 additions & 4 deletions demo/src/main/webapp/resources/extender.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,65 @@
// An extener that loads the given typescript definition files into the editor
function createExtender(...typescriptDefinitionFiles) {
/// <reference path="../../../../../src/npm/primefaces-monaco.d.ts" />

const StorageScopeGlobal = 0;
const StorageScopeWorkspace = 1;

class LocalStorageService {

constructor() {
this._onDidChangeStorage = new monaco.Emitter();
this.onDidChangeStorage = this._onDidChangeStorage.event;
this.onWillSaveState = () => ({dispose(){}});
log("[LocalStorageService] creating");
}

dispose() {
this._onDidChangeStorage.dispose();
}

get(key, scope, fallbackValue = undefined) {
log("[LocalStorageService] get", key);
const value = localStorage.getItem(this.getKey(key));
return value != undefined ? value : fallbackValue;
}

getBoolean(key, scope, fallbackValue = undefined) {
const value = localStorage.getItem(this.getKey(key));
return value != undefined ? value === "true" : fallbackValue;
}

getNumber(key, scope, fallbackValue = undefined) {
const value = localStorage.getItem(this.getKey(key));
return value != undefined ? parseInt(value) : fallbackValue;
}

remove(key, scope) {
localStorage.removeItem(key);
}

store(key, value, scope) {
log("[LocalStorageService] store", key);
if (value == undefined) {
this.remove(key, scope);
}
else {
localStorage.setItem(this.getKey(key), String(value));
}
}

logStorage() {
// cannot list items in localStorage
}

getKey(key) {
return "monaco." + key;
}
}

/**
* An extener that loads the given typescript definition files into the editor
* @return {import("../../../../../src/npm/primefaces-monaco").MonacoExtender}
*/
function createExtender(useLocalStorage, ...typescriptDefinitionFiles) {
return {
beforeCreate(widget, options, wasLibLoaded) {
// Since the configuration is global, we must add the typescript definitions files only
Expand All @@ -18,12 +78,19 @@ function createExtender(...typescriptDefinitionFiles) {
}))
.then(() => options);
},
createEditorOverrideServices(editorWidget, options) {
const overrides = {};
if (useLocalStorage) {
overrides.storageService = new LocalStorageService();
}
return overrides;
}
};
}

// An extender that loads jquery/jqueryui definition files
function createExtenderBasic() {
return createExtender(
function createExtenderBasic(useLocalStorage = false) {
return createExtender(useLocalStorage,
"https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/sizzle/index.d.ts",
"https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/jquery/JQuery.d.ts",
"https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/types/jquery/JQueryStatic.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions demo/src/main/webapp/template.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
#log pre {
margin: 0.5em 0;
white-space: normal;
white-space: pre-wrap;
}
#log {
counter-reset: line 0;
Expand All @@ -30,7 +30,7 @@
counter-increment: line;
display: flex;
flex-direction: row;
}
}
.line::before {
content: counter(line) ">";
margin-right: 0.5em;
Expand Down Expand Up @@ -75,7 +75,7 @@
</pe:layout>
<script>
function log() {
var div = document.getElementById("log")
var div = document.getElementById("log");
var message = Array.prototype.join.call(arguments, " ");
var pre = document.createElement("pre");
pre.setAttribute("class", "line");
Expand Down
Loading

0 comments on commit efe602c

Please sign in to comment.