←Apice e pedice con Alloy Editor
23/04/19 9.00
In un precedente articolo vi ho mostrato come fare ad aggiungere i pulsanti per l'allineamento del testo all'interno di Alloy Editor; sfruttando lo stesso principio vi mostrerò ora come aggiungere i pulsanti per trasformare il testo in apice e pedice.
Non vi allego immagini nè vi spiegherò la teoria, ma vi farò vedere solamente il codice finale; se siete curiori leggete il precedente articolo.
@Component(property = {
"editor.name=alloyeditor",
"javax.portlet.name=" + JournalPortletKeys.JOURNAL,
"service.ranking:Integer=100"
}, service = EditorConfigContributor.class)
public class TextAlignmentEditorConfigContributor
extends BaseEditorConfigContributor {
@Override
public void populateConfigJSONObject(
JSONObject jsonObject, Map<String, Object> inputEditorTaglibAttributes,
ThemeDisplay themeDisplay,
RequestBackedPortletURLFactory requestBackedPortletURLFactory) {
JSONObject toolbars = jsonObject.getJSONObject("toolbars");
if (toolbars != null) {
JSONObject toolbarStyles = toolbars.getJSONObject("styles");
if (toolbarStyles != null) {
JSONArray selections = toolbarStyles.getJSONArray("selections");
if (selections != null) {
for (int i = 0; i < selections.length(); i++) {
JSONObject selection = selections.getJSONObject(i);
if (selection.has("name") &&
selection.getString("name").equals("text")) {
JSONArray buttons = selection.getJSONArray("buttons");
if (buttons != null) {
buttons.put("superscript");
buttons.put("subscript");
}
break;
}
}
}
}
}
}
}