- Put all files for ccm-editor into one Maven module to avoid problems with TypeScript module resolution
- Internal Links Command for ccm-editor


git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@5209 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2018-01-20 16:53:17 +00:00
parent 332532e78c
commit c48ab80922
17 changed files with 125 additions and 278 deletions

View File

@ -69,12 +69,7 @@
<artifactId>ccm-editor</artifactId>
<type>jar</type>
</overlay>
<overlay>
<groupId>org.librecms</groupId>
<artifactId>ccm-cms-editor</artifactId>
<type>jar</type>
</overlay>
<overlay>
<overlay>
<groupId>org.libreccm</groupId>
<artifactId>ccm-theme-foundry</artifactId>
<type>jar</type>

View File

@ -53,12 +53,7 @@
<artifactId>ccm-cms</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.librecms</groupId>
<artifactId>ccm-cms-editor</artifactId>
<version>${project.parent.version}</version>
</dependency>
<!-- CCM Modules end -->
<!-- CCM Modules end -->
<!-- Dependencies for log4j 2 including adapter for the log4j 1.2 API -->
<dependency>

View File

@ -1,17 +0,0 @@
module.exports = function(grunt) {
grunt.initConfig({
ts: {
default : {
options: {
module: "amd",
tsconfig: true,
moduleResolution: "classic"
}
}
},
clean: ['scripts/*.js', 'scripts/*.js.map', 'scripts/.tscache']
});
grunt.loadNpmTasks("grunt-ts");
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask("default", ["ts"]);
};

View File

@ -1,23 +0,0 @@
{
"name": "ccm-cms-editor",
"version": "7.0.0",
"description": "CMS modules for the ccm-editor",
"repository": {
"type": "svn",
"url": "https://svn.libreccm.org/ccm/ccm_ng/ccm-cms-editor"
},
"author": "Jens Pelzetter",
"license": "GPL-3.0",
"dependencies": {
"font-awesome": "^4.7.0",
"requirejs": "^2.3.5",
"requirejs-domready": "^2.0.3"
},
"devDependencies": {
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-contrib-clean": "^1.1.0",
"grunt-ts": "^6.0.0-beta.17",
"typescript": "^2.6.2"
}
}

View File

@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'Z</maven.build.timestamp.format>
</properties>
<parent>
<groupId>org.libreccm</groupId>
<artifactId>libreccm-parent</artifactId>
<version>7.0.0-SNAPSHOT</version>
</parent>
<groupId>org.librecms</groupId>
<artifactId>ccm-cms-editor</artifactId>
<version>7.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>LibreCMS modules for the ccm-editor</name>
<description>
Provides CMS specific modules for the ccm-editor.
</description>
<licenses>
<license>
<name>Lesser GPL 2.1</name>
<url>http://www.gnu.org/licenses/old-licenses/lgpl-2.1</url>
</license>
</licenses>
<dependencies>
<dependency>
<groupId>org.libreccm</groupId>
<artifactId>ccm-editor</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<finalName>ccm-editor</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/typescript</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<executions>
<execution>
<id>Install node.js and NPM</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v6.12.3</nodeVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
</execution>
<execution>
<id>grunt build</id>
<goals>
<goal>grunt</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,8 +0,0 @@
CCM Editor modules for LibreCMS
---
This module provides two new commands for the CCM Editor which are only useful
in combination with the LibreCMS module:
* Insert Internal Link: Adds an internal link to a content item
* Insert Image: Inserts a image from the media library of LibreCMS

View File

@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0
http://maven.apache.org/xsd/decoration-1.3.0.xsd">
<body>
<menu name="Parent project">
<item name="LibreCCM" href="../index.html"/>
</menu>
<menu name="Overview">
<item name="CCM Editor modules for LibreCMS" href="index.html"/>
</menu>
<menu ref="reports"/>
</body>
</project>

View File

@ -1,11 +0,0 @@
{
"include": [
"./src/main/typescript/**/*"
],
"compilerOptions": {
"rootDirs": [
"../ccm-editor/src/main/typescript/ccm-editor",
"./src/main/typescript/ccm-editor"
]
}
}

View File

@ -153,7 +153,7 @@ public class Assets {
@GET
@Path("/")
@Produces("text/json; charset=utf-8")
@Produces("application/json; charset=utf-8")
@Transactional(Transactional.TxType.REQUIRED)
public List<Map<String, String>> findAssets(
@PathParam("content-section") final String section,
@ -194,7 +194,7 @@ public class Assets {
@GET
@Path("/folders/")
@Produces("text/json; charset=utf-8")
@Produces("application/json; charset=utf-8")
@Transactional(Transactional.TxType.REQUIRED)
public List<Map<String, String>> findAssetsInRootFolder(
@PathParam("content-section") final String section,
@ -213,7 +213,7 @@ public class Assets {
@GET
@Path("/folders/{folder}/")
@Produces("text/json; charset=utf-8")
@Produces("application/json; charset=utf-8")
@Transactional(Transactional.TxType.REQUIRED)
public List<Map<String, String>> findAssetsInFolder(
@PathParam("content-section") final String section,

View File

@ -128,6 +128,8 @@ public class ContentItems {
result.put("itemId",
Long.toString(item.getObjectId()));
result.put("name", item.getDisplayName());
result.put("title",
item.getTitle().getValue(globalizationHelper
.getNegotiatedLocale()));
@ -155,7 +157,7 @@ public class ContentItems {
@GET
@Path("/")
@Produces("text/json; charset=utf-8")
@Produces("application/json; charset=utf-8")
@Transactional(Transactional.TxType.REQUIRED)
public List<Map<String, String>> findItems(
@PathParam("content-section") final String section,
@ -177,7 +179,7 @@ public class ContentItems {
&& (type == null || type.trim().isEmpty())) {
items = itemRepo.findByNameAndContentSection(query,
contentSection);
contentSection);
} else if ((query == null || query.trim().isEmpty())
&& (type != null && !type.trim().isEmpty())) {
@ -202,7 +204,7 @@ public class ContentItems {
@GET
@Path("/folders")
@Produces("text/json; charset=utf-8")
@Produces("application/json; charset=utf-8")
@Transactional(Transactional.TxType.REQUIRED)
public List<Map<String, String>> findItemsInRootFolder(
@PathParam("content-section") final String section,
@ -221,7 +223,7 @@ public class ContentItems {
@GET
@Path("/folders/{folder}/")
@Produces("text/json; charset=utf-8")
@Produces("application/json; charset=utf-8")
@Transactional(Transactional.TxType.REQUIRED)
public List<Map<String, String>> findItemsInFolder(
@PathParam("content-section") final String section,
@ -279,11 +281,11 @@ public class ContentItems {
.stream()
.map(item -> createItemMapEntry(item))
.collect(Collectors.toList());
final List<Map<String, String>> result = new ArrayList<>();
result.addAll(subFolderEntries);
result.addAll(itemEntries);
return result;
}

View File

@ -47,7 +47,7 @@ public class ContentSections {
@GET
@Path("/")
@Produces("text/json; charset=utf-8")
@Produces("application/json; charset=utf-8")
@Transactional(Transactional.TxType.REQUIRED)
public List<Map<String, String>> listContentSections() {

View File

@ -200,7 +200,7 @@ public class PagesRouter {
@GET
@Path("/{name:[\\w\\-]+}.{lang:\\w+}.json")
@Produces("text/json")
@Produces("application/json")
@Transactional(Transactional.TxType.REQUIRED)
public String getRootPageAsJson(
@Context
@ -433,7 +433,7 @@ public class PagesRouter {
*/
@GET
@Path("/{page:[\\w/]+}/{name:[\\w\\-]+}.{lang:\\w+}.json")
@Produces("text/json")
@Produces("application/json")
@Transactional(Transactional.TxType.REQUIRED)
public String getPageAsJson(
@Context

View File

@ -2,16 +2,14 @@ module.exports = function(grunt) {
grunt.initConfig({
ts: {
default : {
src: ["src/main/typescript/**/*.ts"],
tsconfig: true,
options: {
module: "amd"
module: "amd",
moduleResolution: "classic"
}
}
},
clean: ['scripts/*.js', 'scripts/*.js.map', 'scripts/.tscache']
});
grunt.loadNpmTasks("grunt-ts");
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask("default", ["ts"]);
};

View File

@ -82,25 +82,34 @@
padding: 1em 0.75em;
position: absolute;
left: 50%;
top: 50%;
left: 50%;
margin-top: -35em;
margin-left: -20em;
margin-top: -20em;
margin-left: -35em;
width: 70em;
height: 40em;
overflow: scroll;
}
.ccm-editor-selectdialog h1 {
padding: 0.5em;
margin-bottom: 0.8em;
}
.ccm-editor-selectdialog .ccm-editor-selectdialog-closebutton {
postion: absolute;
font-size: 1em;
padding: 0.25em;
position: absolute;
top: 0;
right: 0;
width: 1em;
height: 1em;
width: 2.5em;
height: 2.5em;
}
.ccm-editor-selectdialog div {

View File

@ -38,8 +38,8 @@ export class InsertInternalLinkCommand extends CCMEditorCommand {
const closeButton = dialogElem
.appendChild(document.createElement("button"));
closeButton.setAttribute("id", "ccm-editor-selectdialog-closebutton");
closeButton.textContent = "&#x2715";
closeButton.setAttribute("class", "ccm-editor-selectdialog-closebutton");
closeButton.textContent = "\u2715";
closeButton.addEventListener("click", function(event){
event.preventDefault();
const bodyElem = document.getElementsByTagName("body").item(0);
@ -127,12 +127,22 @@ export class InsertInternalLinkCommand extends CCMEditorCommand {
}
}
});
sectionsRequest.send();
console.log("Current sections is \"" + currentSection + "\"");
// Get items
let itemsUrl = contextPrefix
+ "/content-sections/"
+ contentSectionSelect.value
+ "/items";
+ "/content-sections";
if (!(new RegExp("^/.*").test(currentSection))) {
console.log("Current sections does not start with an \"/\", adding one...");
itemsUrl += "/";
}
itemsUrl += currentSection;
if (!(new RegExp(".*/$").test(currentSection))) {
console.log("Current sections does not end with an \"/\", adding one...");
itemsUrl += "/";
}
itemsUrl += "items";
if (filterInput.value !== null && filterInput.value.length > 0) {
itemsUrl + "?query=" + filterInput.value;
}
@ -156,17 +166,25 @@ export class InsertInternalLinkCommand extends CCMEditorCommand {
const selectItemButton = dataTitle
.appendChild(document.createElement("button"));
selectItemButton.textContent = item["title"];
if (item["title"] === null
|| item["title"].length <= 0) {
selectItemButton.textContent = item["name"];
} else {
selectItemButton.textContent = item["title"];
}
selectItemButton
.addEventListener("click", function(event) {
event.preventDefault();
document.removeChild(dialogElem);
const bodyElem = document
.getElementsByTagName("body")
.item(0);
bodyElem.removeChild(dialogElem);
document.getSelection().removeAllRanges();
document.getSelection().addRange(currentRange);
document.execCommand("insertLink",
document.execCommand("createLink",
false,
contextPrefix
+ "/redirect/?oid="
@ -180,6 +198,7 @@ export class InsertInternalLinkCommand extends CCMEditorCommand {
}
}
});
itemsRequest.send();
const bodyElem = document.getElementsByTagName("body").item(0);
bodyElem.appendChild(dialogFragment);

View File

@ -387,28 +387,28 @@ export class FormatBlockCommand extends CCMEditorCommand {
private findBlockElement(node: Node): Element {
if (node instanceof Element) {
console.log("Current node is an element.");
// console.log("Current node is an element.");
const elem: Element = node as Element;
console.log("elem.tagName = " + elem.tagName.toLowerCase());
// console.log("elem.tagName = " + elem.tagName.toLowerCase());
if(this.values.indexOf(elem.tagName.toLowerCase()) === -1) {
console.log("elem.tagName is not in the values array.");
// console.log("elem.tagName is not in the values array.");
if (elem.parentNode === null) {
console.log("elem has no parent node. Returning null.");
// console.log("elem has no parent node. Returning null.");
return null;
} else {
console.log("Continuing with elem.parentNode");
// console.log("Continuing with elem.parentNode");
return this.findBlockElement(elem.parentNode);
}
} else {
return elem;
}
} else {
console.log("Current node is not an element node.");
// console.log("Current node is not an element node.");
if (node.parentNode === null) {
console.log("Current node has no parent, returning null.");
// console.log("Current node has no parent, returning null.");
return null;
} else {
console.log("Continuing with parent node...");
// console.log("Continuing with parent node...");
return this.findBlockElement(node.parentNode);
}
}

113
pom.xml
View File

@ -39,21 +39,20 @@
</licenses>
<modules>
<!-- Provides basic functionality required by all modules -->
<module>ccm-core</module>
<!-- Additional modules used by most/all modules (including ccm-core) -->
<module>ccm-testutils</module>
<module>ccm-xafilesystemadapter</module>
<!-- Simple HTML editor for use in the backend -->
<module>ccm-editor</module>
<!-- CMS modules -->
<module>ccm-cms</module>
<module>ccm-cms-editor</module>
<module>ccm-cms-types-agenda</module>
<module>ccm-cms-types-bookmark</module>
<module>ccm-cms-types-decisiontree</module>
@ -61,20 +60,20 @@
<module>ccm-cms-types-faqitem</module>
<module>ccm-cms-types-glossaryitem</module>
<module>ccm-cms-types-minutes</module>
<!-- Miscellaneous modules -->
<module>ccm-docrepo</module>
<module>ccm-shortcuts</module>
<!-- Modules providing themes -->
<module>ccm-theme-foundry</module>
<!-- Bundle modules -->
<module>ccm-bundle-devel</module>
<module>ccm-bundle-devel-wildfly-web</module>
<module>ccm-bundle-devel-wildfly</module>
<module>ccm-bundle-devel-wildfly-swarm</module>
<!-- Archetypes -->
<module>ccm-archetype-module</module>
<module>ccm-cms-archetype-contenttype</module>
@ -291,7 +290,7 @@
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -315,7 +314,7 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.wildfly.plugins</groupId>
<artifactId>wildfly-maven-plugin</artifactId>
@ -323,7 +322,7 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
@ -333,10 +332,10 @@
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<!--
<!--
*******************************
JavaEE and related dependencies
*******************************
@ -347,11 +346,11 @@
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
<!--
<!--
Hibernate, used as JPA provider, replacing the default
provider of the container. This is necessary because we use
some features/extensions only available for Hibernate,
some features/extensions only available for Hibernate,
for example Envers for versioning.
-->
<dependency>
@ -359,8 +358,8 @@
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.10.Final</version>
</dependency>
<!--
<!--
Hibernate Envers, used for providing versioning/auditing for
Entities.
-->
@ -369,9 +368,9 @@
<artifactId>hibernate-envers</artifactId>
<version>5.0.10.Final</version>
</dependency>
<!--
Hibernate Validator used as implemenation of the Bean
<!--
Hibernate Validator used as implemenation of the Bean
Validation API -->
<dependency>
<groupId>org.hibernate</groupId>
@ -395,7 +394,7 @@
</dependency>
<!--
Hibernate Search provides seamless integration of Apache Lucene with
Hibernate Search provides seamless integration of Apache Lucene with
Hibernate/JPA
-->
<dependency>
@ -403,7 +402,7 @@
<artifactId>hibernate-search-orm</artifactId>
<version>5.5.4.Final</version>
</dependency>
<!--
Flyway framework for database schema migrations
-->
@ -412,7 +411,7 @@
<artifactId>flyway-core</artifactId>
<version>4.0.3</version>
</dependency>
<!-- Shiro lib for security stuff -->
<dependency>
<groupId>org.apache.shiro</groupId>
@ -424,14 +423,14 @@
<artifactId>shiro-web</artifactId>
<version>1.3.2</version>
</dependency>
<!-- PrimeFaces for JSF prototype -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.1</version>
</dependency>
<!-- Vaadin dependencies for Vaadin prototype -->
<!-- Vaadin dependencies -->
<dependency>
@ -456,13 +455,13 @@
<artifactId>vaadin-themes</artifactId>
<version>8.1.2</version>
</dependency>-->
<!--
<!--
*********************
Libraries used by CCM
*********************
-->
<!-- Unclear if needed anymore because javax.activation is part
of the standard API since JavaSE 6 -->
<!--<dependency>
@ -470,7 +469,7 @@
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>-->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
@ -478,9 +477,9 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<!--
Needs to be upgraded, but the complete search part needs
<!--
Needs to be upgraded, but the complete search part needs
refactoring. Therefore we keep using the old version for now.
-->
<dependency>
@ -488,14 +487,14 @@
<artifactId>lucene-core</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>1.4.0</version>
</dependency>
<!-- Libraries from the Apache Commons project -->
<dependency>
<groupId>commons-beanutils</groupId>
@ -560,37 +559,37 @@
<artifactId>bcmail-jdk16</artifactId>
<version>1.46</version>
</dependency>
<dependency>
<groupId>org.imgscalr</groupId>
<artifactId>imgscalr-lib</artifactId>
<version>4.2</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.3.9</version>
</dependency>
<dependency>
<groupId>net.sf.jtidy</groupId>
<artifactId>jtidy</artifactId>
<version>r938</version>
</dependency>
<dependency>
<groupId>oro</groupId>
<artifactId>oro</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
@ -627,16 +626,16 @@
<version>2.9.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependency>
<!-- better xml library -->
<dependency>
<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-asl</artifactId>
<version>4.4.1</version>
</dependency>
<!--
<!--
**********************
Dependencies for tests
**********************
@ -647,9 +646,9 @@
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<!--
Arquillian test framework for running tests inside an JavaEE
<!--
Arquillian test framework for running tests inside an JavaEE
container
-->
<dependency>
@ -694,7 +693,7 @@
<version>8.2.1.Final</version>
<scope>test</scope>
</dependency>
<!--
JaCoCo is used to measure the test coverage
-->
@ -704,8 +703,8 @@
<version>0.7.9</version>
<scope>test</scope>
</dependency>
<!--
<!--
Hamcrest provides nice Matchers for JUnit test, making the
assertions in the tests for readable.
-->
@ -720,10 +719,10 @@
<version>1.3</version>
<scope>test</scope>
</dependency>
<!--
<!--
The EqualsVerifier from Jan Ouwens for checking the equals and
hashCode implementations for objects. Used especially for
hashCode implementations for objects. Used especially for
verifying equals and hashCode implementations of entities.
-->
<dependency>
@ -732,7 +731,7 @@
<!--<version>1.7.8</version>-->
<version>2.2</version>
</dependency>
<!-- h2 database in used to check some database related things -->
<dependency>
<groupId>com.h2database</groupId>
@ -742,5 +741,5 @@
</dependencies>
</dependencyManagement>
</project>