- 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

Former-commit-id: 1993ec5b16
pull/2/head
jensp 2018-01-20 16:53:17 +00:00
parent 78e7b499ed
commit 3bddb3da66
17 changed files with 125 additions and 278 deletions

View File

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

View File

@ -53,11 +53,6 @@
<artifactId>ccm-cms</artifactId> <artifactId>ccm-cms</artifactId>
<version>${project.parent.version}</version> <version>${project.parent.version}</version>
</dependency> </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 --> <!-- Dependencies for log4j 2 including adapter for the log4j 1.2 API -->

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

View File

@ -128,6 +128,8 @@ public class ContentItems {
result.put("itemId", result.put("itemId",
Long.toString(item.getObjectId())); Long.toString(item.getObjectId()));
result.put("name", item.getDisplayName());
result.put("title", result.put("title",
item.getTitle().getValue(globalizationHelper item.getTitle().getValue(globalizationHelper
.getNegotiatedLocale())); .getNegotiatedLocale()));
@ -155,7 +157,7 @@ public class ContentItems {
@GET @GET
@Path("/") @Path("/")
@Produces("text/json; charset=utf-8") @Produces("application/json; charset=utf-8")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public List<Map<String, String>> findItems( public List<Map<String, String>> findItems(
@PathParam("content-section") final String section, @PathParam("content-section") final String section,
@ -202,7 +204,7 @@ public class ContentItems {
@GET @GET
@Path("/folders") @Path("/folders")
@Produces("text/json; charset=utf-8") @Produces("application/json; charset=utf-8")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public List<Map<String, String>> findItemsInRootFolder( public List<Map<String, String>> findItemsInRootFolder(
@PathParam("content-section") final String section, @PathParam("content-section") final String section,
@ -221,7 +223,7 @@ public class ContentItems {
@GET @GET
@Path("/folders/{folder}/") @Path("/folders/{folder}/")
@Produces("text/json; charset=utf-8") @Produces("application/json; charset=utf-8")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public List<Map<String, String>> findItemsInFolder( public List<Map<String, String>> findItemsInFolder(
@PathParam("content-section") final String section, @PathParam("content-section") final String section,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -387,28 +387,28 @@ export class FormatBlockCommand extends CCMEditorCommand {
private findBlockElement(node: Node): Element { private findBlockElement(node: Node): Element {
if (node instanceof 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; 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) { 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) { if (elem.parentNode === null) {
console.log("elem has no parent node. Returning null."); // console.log("elem has no parent node. Returning null.");
return null; return null;
} else { } else {
console.log("Continuing with elem.parentNode"); // console.log("Continuing with elem.parentNode");
return this.findBlockElement(elem.parentNode); return this.findBlockElement(elem.parentNode);
} }
} else { } else {
return elem; return elem;
} }
} else { } else {
console.log("Current node is not an element node."); // console.log("Current node is not an element node.");
if (node.parentNode === null) { if (node.parentNode === null) {
console.log("Current node has no parent, returning null."); // console.log("Current node has no parent, returning null.");
return null; return null;
} else { } else {
console.log("Continuing with parent node..."); // console.log("Continuing with parent node...");
return this.findBlockElement(node.parentNode); return this.findBlockElement(node.parentNode);
} }
} }

View File

@ -52,7 +52,6 @@
<!-- CMS modules --> <!-- CMS modules -->
<module>ccm-cms</module> <module>ccm-cms</module>
<module>ccm-cms-editor</module>
<module>ccm-cms-types-agenda</module> <module>ccm-cms-types-agenda</module>
<module>ccm-cms-types-bookmark</module> <module>ccm-cms-types-bookmark</module>