Skip to content

Commit 8dc8971

Browse files
merge 0.12-rc into main branch (#391)
1 parent 99bc7dd commit 8dc8971

30 files changed

+1512
-16
lines changed

pom.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<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">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
35
<modelVersion>4.0.0</modelVersion>
46

57
<groupId>org.symphonyoss.symphony</groupId>
68
<artifactId>messageml</artifactId>
7-
<version>0.11.2</version>
9+
<version>0.12.0</version>
810
<name>MessageML Utils</name>
911
<url>https://github.com/finos/messageml-utils</url>
10-
<description>A set of utilities for parsing, processing and rendering of MessageML messages</description>
12+
<description>A set of utilities for parsing, processing and rendering of MessageML messages
13+
</description>
1114

1215
<licenses>
1316
<license>
@@ -18,7 +21,8 @@
1821

1922
<scm>
2023
<connection>scm:git:git://github.com/finos/messageml-utils.git</connection>
21-
<developerConnection>scm:git:https://github.com/finos/messageml-utils.git</developerConnection>
24+
<developerConnection>scm:git:https://github.com/finos/messageml-utils.git
25+
</developerConnection>
2226
<url>https://github.com/finos/messageml-utils</url>
2327
</scm>
2428

@@ -317,8 +321,10 @@
317321
<configuration>
318322
<archive>
319323
<manifest>
320-
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
321-
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
324+
<addDefaultSpecificationEntries>true
325+
</addDefaultSpecificationEntries>
326+
<addDefaultImplementationEntries>true
327+
</addDefaultImplementationEntries>
322328
</manifest>
323329
</archive>
324330
</configuration>

src/main/java/org/symphonyoss/symphony/messageml/MessageMLParser.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@
5959
import org.symphonyoss.symphony.messageml.elements.PersonSelector;
6060
import org.symphonyoss.symphony.messageml.elements.Preformatted;
6161
import org.symphonyoss.symphony.messageml.elements.Radio;
62+
import org.symphonyoss.symphony.messageml.elements.RoomSelector;
6263
import org.symphonyoss.symphony.messageml.elements.Select;
6364
import org.symphonyoss.symphony.messageml.elements.Span;
6465
import org.symphonyoss.symphony.messageml.elements.SplittableElement;
66+
import org.symphonyoss.symphony.messageml.elements.Subscript;
67+
import org.symphonyoss.symphony.messageml.elements.Superscript;
6568
import org.symphonyoss.symphony.messageml.elements.Table;
6669
import org.symphonyoss.symphony.messageml.elements.TableBody;
6770
import org.symphonyoss.symphony.messageml.elements.TableCell;
@@ -585,6 +588,9 @@ public Element createElement(org.w3c.dom.Element element, Element parent) throws
585588
case PersonSelector.MESSAGEML_TAG:
586589
return new PersonSelector(parent, messageFormat);
587590

591+
case RoomSelector.MESSAGEML_TAG:
592+
return new RoomSelector(parent, messageFormat);
593+
588594
case DateSelector.MESSAGEML_TAG:
589595
return new DateSelector(parent, messageFormat);
590596

@@ -617,6 +623,12 @@ public Element createElement(org.w3c.dom.Element element, Element parent) throws
617623
createSplittable(id, LabelableElement.class, Pair.of(LabelableElement.LABEL, element.getTextContent()));
618624
return null;
619625

626+
case Subscript.MESSAGEML_TAG:
627+
return new Subscript(parent);
628+
629+
case Superscript.MESSAGEML_TAG:
630+
return new Superscript(parent);
631+
620632
default:
621633
throw new InvalidInputException("Invalid MessageML content at element \"" + tag + "\"");
622634
}
@@ -780,6 +792,9 @@ private Element createElementFromDiv(org.w3c.dom.Element element, Element parent
780792
} else if (containsAttribute(elementClass, PersonSelector.MESSAGEML_TAG)) {
781793
removeAttribute(element, CLASS_ATTR, PersonSelector.MESSAGEML_TAG);
782794
return new PersonSelector(parent, FormatEnum.PRESENTATIONML);
795+
} else if (containsAttribute(elementClass, RoomSelector.MESSAGEML_TAG)) {
796+
removeAttribute(element, CLASS_ATTR, RoomSelector.MESSAGEML_TAG);
797+
return new RoomSelector(parent, FormatEnum.PRESENTATIONML);
783798
} else if (containsAttribute(elementClass, DateSelector.MESSAGEML_TAG)) {
784799
removeAttribute(element, CLASS_ATTR, DateSelector.MESSAGEML_TAG);
785800
return new DateSelector(parent, FormatEnum.PRESENTATIONML);

src/main/java/org/symphonyoss/symphony/messageml/bi/BiFields.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public enum BiFields {
1717
TIMEZONE_PICKER("timezonepicker", BiEventType.MESSAGEML_ELEMENT_SENT),
1818
DATE_SELECTOR("dateselector", BiEventType.MESSAGEML_ELEMENT_SENT),
1919
PERSON_SELECTOR("personselector", BiEventType.MESSAGEML_ELEMENT_SENT),
20+
ROOM_SELECTOR("roomselector", BiEventType.MESSAGEML_ELEMENT_SENT),
2021
SELECT("dropdownmenu", BiEventType.MESSAGEML_ELEMENT_SENT),
2122
CHIME("chimes", BiEventType.MESSAGEML_MESSAGE_SENT, "0"),
2223
CODE("codes", BiEventType.MESSAGEML_MESSAGE_SENT, "0"),

src/main/java/org/symphonyoss/symphony/messageml/elements/Button.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ public class Button extends Element {
4545
public static final String ACTION_TYPE = "action";
4646
public static final String CANCEL_TYPE = "cancel";
4747
public static final String RESET_TYPE = "reset";
48-
48+
public static final String MML_ICON_ATTR = "icon";
49+
public static final String ICON_ATTR = "data-icon";
4950
private static final Set<String> VALID_CLASSES = new HashSet<>(Arrays.asList("primary", "secondary", "tertiary", "destructive",
50-
"primary-destructive", "secondary-destructive")); // primary-destructive, secondary-destructive are deprecated
51+
"primary-destructive", "secondary-destructive", "primary-link", "destructive-link"));
52+
// primary-destructive, secondary-destructive are deprecated
5153
private static final Set<String> VALID_TYPES = new HashSet<>(Arrays.asList(ACTION_TYPE, RESET_TYPE, CANCEL_TYPE));
5254

5355
public Button(Element parent, FormatEnum format) {
@@ -65,6 +67,9 @@ public void buildAttribute(MessageMLParser parser, Node item) throws InvalidInpu
6567
setAttribute(item.getNodeName(), getStringAttribute(item));
6668
break;
6769
// The button can a have tooltips but is not a tooltipable element because it dont generate the span with tooltip
70+
case MML_ICON_ATTR:
71+
setAttribute(ICON_ATTR, getStringAttribute(item));
72+
break;
6873
case CLASS_ATTR:
6974
if (getStringAttribute(item).contains("-destructive")) {
7075
logger.info("Button class cannot be a destructive one, replacing it accordingly.");

src/main/java/org/symphonyoss/symphony/messageml/elements/Checkbox.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ public void validate() throws InvalidInputException {
3939
assertAttributeValue(CHECKED_ATTR, Arrays.asList(Boolean.TRUE.toString(), Boolean.FALSE.toString()));
4040
}
4141

42+
if (getAttribute(DISABLED_ATTR) != null) {
43+
assertAttributeValue(DISABLED_ATTR,
44+
Arrays.asList(Boolean.TRUE.toString(), Boolean.FALSE.toString()));
45+
}
46+
47+
if (getAttribute(READONLY_ATTR) != null) {
48+
assertAttributeValue(READONLY_ATTR,
49+
Arrays.asList(Boolean.TRUE.toString(), Boolean.FALSE.toString()));
50+
}
51+
4252
if (!getChildren().isEmpty()) {
4353
assertContentModel(Arrays.asList(TextNode.class, Bold.class, Italic.class));
4454
}
@@ -54,6 +64,8 @@ protected void buildAttribute(MessageMLParser parser,
5464
case VALUE_ATTR:
5565
case CHECKED_ATTR:
5666
case LABEL:
67+
case DISABLED_ATTR:
68+
case READONLY_ATTR:
5769
setAttribute(item.getNodeName(), getStringAttribute(item));
5870
break;
5971
case ID_ATTR:

src/main/java/org/symphonyoss/symphony/messageml/elements/Code.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ public class Code extends Element {
4646
private static final int MARKDOWN_DELIMITER_INDENT = 0;
4747

4848
private static final List<String> SUPPORTED_LANGUAGES = Arrays.asList(
49-
"plaintext", "c", "cpp", "csharp", "css", "html", "java", "js", "jsx", "php", "python", "r", "typescript", "tsx"
49+
"plaintext", "c", "cpp", "csharp", "css", "html", "java", "js", "jsx", "php", "python", "r",
50+
"typescript", "tsx", "markdown", "json", "scala", "shell", "yaml"
5051
);
5152

5253
public Code(Element parent) {

src/main/java/org/symphonyoss/symphony/messageml/elements/DatePicker.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public class DatePicker extends FormElement implements LabelableElement, Tooltip
4545
private static final String PRESENTATIONML_DISABLED_DATE_ATTR = "data-disabled-date";
4646
private static final String PRESENTATIONML_HIGHLIGHTED_DATE_ATTR = "data-highlighted-date";
4747
private static final String PRESENTATIONML_FORMAT_ATTR = "data-format";
48+
protected static final String DISABLED_ATTR = "disabled";
49+
protected static final String READONLY_ATTR = "readonly";
4850

4951
private static final String DATE_FORMAT_ALLOWED = "^[0-9Mdy\\/. -:]+$";
5052

@@ -63,6 +65,8 @@ protected void buildAttribute(MessageMLParser parser, Node item) throws InvalidI
6365
case MAX_ATTR:
6466
case LABEL:
6567
case TITLE:
68+
case DISABLED_ATTR:
69+
case READONLY_ATTR:
6670
setAttribute(item.getNodeName(), getStringAttribute(item));
6771
break;
6872
case DISABLED_DATE_ATTR:
@@ -108,6 +112,12 @@ public void validate() throws InvalidInputException {
108112
if (getAttribute(MAX_ATTR) != null) {
109113
assertDateFormat(MAX_ATTR, DateTimeFormatter.ISO_DATE);
110114
}
115+
if (getAttribute(DISABLED_ATTR) != null) {
116+
assertAttributeValue(DISABLED_ATTR, Arrays.asList("true", "false"));
117+
}
118+
if (getAttribute(READONLY_ATTR) != null) {
119+
assertAttributeValue(READONLY_ATTR, Arrays.asList("true", "false"));
120+
}
111121
assertJsonDatesRange(DISABLED_DATE_ATTR);
112122
assertJsonDatesRange(HIGHLIGHTED_DATE_ATTR);
113123

@@ -177,6 +187,12 @@ private Map<String, Object> buildDataPickerInputAttributes() {
177187
if (getAttribute(FORMAT_ATTR) != null) {
178188
presentationAttrs.put(PRESENTATIONML_FORMAT_ATTR, getAttribute(FORMAT_ATTR));
179189
}
190+
if (getAttribute(DISABLED_ATTR) != null) {
191+
presentationAttrs.put(DISABLED_ATTR, getAttribute(DISABLED_ATTR));
192+
}
193+
if (getAttribute(READONLY_ATTR) != null) {
194+
presentationAttrs.put(READONLY_ATTR, getAttribute(READONLY_ATTR));
195+
}
180196
// PresentationML compatibility
181197
if (getAttribute(PRESENTATIONML_DISABLED_DATE_ATTR) != null) {
182198
presentationAttrs.put(PRESENTATIONML_DISABLED_DATE_ATTR, getAttribute(PRESENTATIONML_DISABLED_DATE_ATTR));
@@ -187,7 +203,6 @@ private Map<String, Object> buildDataPickerInputAttributes() {
187203
if (getAttribute(PRESENTATIONML_FORMAT_ATTR) != null) {
188204
presentationAttrs.put(PRESENTATIONML_FORMAT_ATTR, getAttribute(PRESENTATIONML_FORMAT_ATTR));
189205
}
190-
191206
return presentationAttrs;
192207
}
193208

src/main/java/org/symphonyoss/symphony/messageml/elements/Element.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ public abstract class Element {
8181

8282
private static final List<Class<? extends Element>> PHRASING_TYPES =
8383
Arrays.asList(TextNode.class, Link.class, Chime.class, Bold.class, Italic.class, Image.class,
84-
LineBreak.class, Span.class, Emoji.class, HashTag.class, CashTag.class, Mention.class);
84+
LineBreak.class, Span.class, Emoji.class, HashTag.class, CashTag.class, Mention.class,
85+
Subscript.class, Superscript.class);
8586

8687
private static final List<Class<? extends Element>> PHRASING_OR_PREFORMATTED_TYPES = new ArrayList<Class<? extends Element>>() {{
8788
addAll(PHRASING_TYPES);

src/main/java/org/symphonyoss/symphony/messageml/elements/GroupedElement.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public abstract class GroupedElement extends FormElement {
2929
protected static final String VALUE_ATTR = "value";
3030
protected static final String CHECKED_ATTR = "checked";
3131
protected static final String FOR_ATTR = "for";
32+
protected static final String DISABLED_ATTR = "disabled";
33+
protected static final String READONLY_ATTR = "readonly";
34+
3235

3336
public GroupedElement(Element parent, String messageMLTag,
3437
FormatEnum format) {
@@ -188,6 +191,15 @@ protected Map<String, String> buildGroupedElementInputAttributes(String id) {
188191
} else {
189192
presentationAttrs.put(VALUE_ATTR, PRESENTATIONML_DEFAULT_VALUE);
190193
}
194+
195+
if (getAttribute(DISABLED_ATTR) != null) {
196+
presentationAttrs.put(DISABLED_ATTR, getAttribute(DISABLED_ATTR));
197+
}
198+
199+
if (getAttribute(READONLY_ATTR) != null) {
200+
presentationAttrs.put(READONLY_ATTR, getAttribute(READONLY_ATTR));
201+
}
202+
191203
return presentationAttrs;
192204
}
193205

src/main/java/org/symphonyoss/symphony/messageml/elements/Radio.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ public void validate() throws InvalidInputException {
6767
assertAttributeValue(CHECKED_ATTR, Arrays.asList(Boolean.TRUE.toString(), Boolean.FALSE.toString()));
6868
}
6969

70+
if (getAttribute(DISABLED_ATTR) != null) {
71+
assertAttributeValue(DISABLED_ATTR,
72+
Arrays.asList(Boolean.TRUE.toString(), Boolean.FALSE.toString()));
73+
}
74+
75+
if (getAttribute(READONLY_ATTR) != null) {
76+
assertAttributeValue(READONLY_ATTR,
77+
Arrays.asList(Boolean.TRUE.toString(), Boolean.FALSE.toString()));
78+
}
79+
7080
if (!getChildren().isEmpty()) {
7181
assertContentModel(Arrays.asList(TextNode.class, Bold.class, Italic.class));
7282
}
@@ -80,6 +90,8 @@ protected void buildAttribute(MessageMLParser parser,
8090
case NAME_ATTR:
8191
case VALUE_ATTR:
8292
case LABEL:
93+
case DISABLED_ATTR:
94+
case READONLY_ATTR:
8395
setAttribute(item.getNodeName(), getStringAttribute(item));
8496
break;
8597
case ID_ATTR:

0 commit comments

Comments
 (0)