xonomy icon indicating copy to clipboard operation
xonomy copied to clipboard

Can't edit content of XML with empty tag

Open jasoncslaughter opened this issue 8 years ago • 2 comments

I have an xml document that includes empty tags:

<dataStatistics>
  <statistic></statistic>
<dataStatistics>

I have specified in the settings that the content of <statistics> should be settable (at least if I understand correctly).

elements: {
   "statistic": {
      asker: Xonomy.askString,
      menu: [
         {
             caption: "Delete this <statistic>",
             action: Xonomy.deleteElement
         }
       ]
   }
}

In the editor, the <statistic> tag appears as <statistic/>, and there appears no way to add text content inside of it.

Is this a bug, or am I doing something wrong?

jasoncslaughter avatar Oct 06 '17 13:10 jasoncslaughter

Here is a workaround I just came up with until this is sorted correctly.

var stdMenu = [
			{
				caption: "Make Null",
				action: function(htmlID, actionParameter) {
					Xonomy.editRaw(htmlID, actionParameter);
				},
				actionParameter: {
					fromJs: function(jsElement) {
						return "<" + jsElement.name + " />";
					},
					toXml: function(txt, origElement) {
						return txt;
					}
				}
			},
			{
				caption: "Make ?",
				action: function(htmlID, actionParameter) {
					Xonomy.editRaw(htmlID, actionParameter);
				},
				actionParameter: {
					fromJs: function(jsElement) {
						return "<" + jsElement.name + ">?</" + jsElement.name + ">";
					},
					toXml: function(txt, origElement) {
						return txt;
					}
				}
			}
		];
var docSpec = {
  elements: {
     "MessageID": { oneliner: true, menu: stdMenu }
  }
}

Now when you "click" on the element name it will pop open this standard menu and use the inbuilt "editRaw" function to set the contents of the element.

MarkPerryBV avatar Oct 25 '17 14:10 MarkPerryBV

@rexrhino You should set hasText:true for the statistics element.

viceice avatar Jan 10 '18 13:01 viceice