Explorar o código

[wodml] update xonomy on codemirror changes

cgars %!s(int64=7) %!d(string=hai) anos
pai
achega
bfc6251fc3
Modificáronse 2 ficheiros con 78 adicións e 39 borrados
  1. 3 0
      public/css/gogs.css
  2. 75 39
      public/js/gogs.js

+ 3 - 0
public/css/gogs.css

@@ -3454,3 +3454,6 @@ textarea#description {
   border-top-right-radius: 0;
   border-top-right-radius: 0;
   border-bottom-right-radius: 0;
   border-bottom-right-radius: 0;
 }
 }
+.textnode.focusable.whitespace {
+  display: none !important;
+}

+ 75 - 39
public/js/gogs.js

@@ -677,6 +677,9 @@ function setCodeMirror($editArea) {
                 document.getElementById("parseerr").className = "ui negative message"
                 document.getElementById("parseerr").className = "ui negative message"
             }
             }
         }
         }
+        if (typeof (Xonomy) !== 'undefined') {
+            OdmlEditor();
+        }
     });
     });
 
 
     return true;
     return true;
@@ -1566,6 +1569,36 @@ function OdmlEditor() {
 	var docSpec = {
 	var docSpec = {
 		allowModeSwitching: true,
 		allowModeSwitching: true,
 		elements: {
 		elements: {
+			"odML": {
+				collapsible: true,
+				oneliner: false,
+				menu: [{
+					caption: "Add <section>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<section/>"
+				}, {
+					caption: "Add <author>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<author>...</author>"
+				}, {
+					caption: "Add <date>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<date>...</date>"
+				}, {
+					caption: "Add <repository>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<repository>...</repository>"
+				},
+				{
+					caption: "Add <version>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<version>...</version>"
+				}]
+			},
+			"author": {
+				collapsible: false,
+				oneliner: true
+			},
 			"value": {
 			"value": {
 				collapsible: false,
 				collapsible: false,
 				menu: [{
 				menu: [{
@@ -1581,7 +1614,6 @@ function OdmlEditor() {
 				collapsible: false
 				collapsible: false
 			},
 			},
 			"name": {
 			"name": {
-				mustBeBefore: ["value"],
 				collapsible: false
 				collapsible: false
 			},
 			},
 			"property": {
 			"property": {
@@ -1591,7 +1623,6 @@ function OdmlEditor() {
 				collapsoid: function (jsElement) {
 				collapsoid: function (jsElement) {
 					return jsElement.getChildElements("name")[0].getText() + ": " + jsElement.getChildElements("value")[0].getText();
 					return jsElement.getChildElements("name")[0].getText() + ": " + jsElement.getChildElements("value")[0].getText();
 				},
 				},
-
 				menu: [{
 				menu: [{
 					caption: "Delete this <property>",
 					caption: "Delete this <property>",
 					action: Xonomy.deleteElement
 					action: Xonomy.deleteElement
@@ -1616,28 +1647,33 @@ function OdmlEditor() {
 					action: Xonomy.newElementChild,
 					action: Xonomy.newElementChild,
 					actionParameter: "<reference>...</reference>"
 					actionParameter: "<reference>...</reference>"
 				},
 				},
-					{
-						caption: "Add <definition>",
-						action: Xonomy.newElementChild,
-						actionParameter: "<definition>...</definition>"
-					},
-					{
-						caption: "Add <dependency>",
-						action: Xonomy.newElementChild,
-						actionParameter: "<dependency>...</dependency>"
-					},
-					{
-						caption: "Add <value_origin>",
-						action: Xonomy.newElementChild,
-						actionParameter: "<value_origin>...</value_origin>"
-					}],
+				{
+					caption: "Add <definition>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<definition>...</definition>"
+				},
+				{
+					caption: "Add <dependency>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<dependency>...</dependency>"
+				},
+				{
+					caption: "Add <value_origin>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<value_origin>...</value_origin>"
+				}],
 			},
 			},
 			"section": {
 			"section": {
 				oneliner: false,
 				oneliner: false,
 				collapsible: true,
 				collapsible: true,
 				collapsed: true,
 				collapsed: true,
 				collapsoid: function (jsElement) {
 				collapsoid: function (jsElement) {
-					return jsElement.getChildElements("name")[0].getText();
+					if (jsElement.hasChildNodes("name")) {
+						return jsElement.getChildElements("name")[0].getText();
+					}
+					else {
+						return "..."
+					}
 				},
 				},
 				menu: [{
 				menu: [{
 					caption: "Delete this <section>",
 					caption: "Delete this <section>",
@@ -1663,27 +1699,27 @@ function OdmlEditor() {
 					action: Xonomy.newElementChild,
 					action: Xonomy.newElementChild,
 					actionParameter: "<reference>...</reference>"
 					actionParameter: "<reference>...</reference>"
 				},
 				},
-					{
-						caption: "Add <definition>",
-						action: Xonomy.newElementChild,
-						actionParameter: "<definition>...</definition>"
-					},
-					{
-						caption: "Add <link>",
-						action: Xonomy.newElementChild,
-						actionParameter: "<link>...</link>"
-					},
-					{
-						caption: "Add <repository>",
-						action: Xonomy.newElementChild,
-						actionParameter: "<repository>...</link>"
-					},
-					{
-						caption: "Add <property>",
-						action: Xonomy.newElementChild,
-						actionParameter: "<property><name>...</name><value>...</value></property>"
-					}
-				],
+				{
+					caption: "Add <definition>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<definition>...</definition>"
+				},
+				{
+					caption: "Add <link>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<link>...</link>"
+				},
+				{
+					caption: "Add <repository>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<repository>...</link>"
+				},
+				{
+					caption: "Add <property>",
+					action: Xonomy.newElementChild,
+					actionParameter: "<property><name>...</name><value>...</value></property>"
+				}
+			],
 			}
 			}
 		},
 		},
 		onchange: function () {
 		onchange: function () {