Skip to content

Commit a38ca2f

Browse files
committed
Merge branch 'master' into dev
2 parents c812d0f + dcf56c1 commit a38ca2f

File tree

5 files changed

+59
-3
lines changed

5 files changed

+59
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Typography will respect the editables configuration correctly instead of just the default configuration.
2+

build/changelog/mappings/2.0.10.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"version": "2.0.10",
3+
"date": "12.03.2025",
4+
"changeLogEntryFileNames": [
5+
"12557.SUP-18149.bugfix"
6+
],
7+
"genericProperties": {}
8+
}

build/changelog/mappings/2.1.6.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"version": "2.1.6",
3+
"date": "12.03.2025",
4+
"changeLogEntryFileNames": [],
5+
"genericProperties": {}
6+
}

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>org.alohaeditor</groupId>
55
<artifactId>alohaeditor</artifactId>
6-
<version>2.1.6-SNAPSHOT</version>
6+
<version>2.1.7-SNAPSHOT</version>
77
<packaging>jar</packaging>
88
<name>Aloha Editor</name>
99
<url>http://aloha-editor.org</url>

src/plugins/common/format/lib/format-plugin.js

+42-2
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,8 @@ define('format/format-plugin', [
757757
},
758758

759759
activeTypography: null,
760+
formatOptions: [],
761+
typographyOptions: [],
760762

761763
/**
762764
* Initialize the plugin and set initialize flag on true
@@ -881,6 +883,32 @@ define('format/format-plugin', [
881883
button.handle.show();
882884
}
883885
});
886+
887+
plugin.typographyOptions = Object.entries(plugin.buttonConfig).map(function(entry) {
888+
var name = entry[0];
889+
var elemConfig = entry[1];
890+
891+
// Ignore non-typography elements
892+
if (!elemConfig.typography) {
893+
return null;
894+
}
895+
896+
// Skip elements which aren't allowed
897+
if (!ContentRules.isAllowed(editable, name) || !config.includes(name)) {
898+
return null;
899+
}
900+
901+
return name;
902+
}).filter(function(value) {
903+
return value != null;
904+
});
905+
906+
// We need at least two options, otherwise the button/selection wouldn't make sense
907+
if (plugin.typographyOptions.length <= 1) {
908+
plugin.typographyButton.hide();
909+
} else {
910+
plugin.typographyButton.show();
911+
}
884912
},
885913

886914
/**
@@ -922,7 +950,12 @@ define('format/format-plugin', [
922950
iconOnly: false,
923951

924952
click: function () {
925-
var data = Dropdown.openDynamicDropdown(plugin.typographyButton.name, plugin._createTypographyContext());
953+
var context = plugin._createTypographyContext();
954+
if (context == null) {
955+
return;
956+
}
957+
958+
var data = Dropdown.openDynamicDropdown(plugin.typographyButton.name, context);
926959
if (!data) {
927960
return;
928961
}
@@ -968,7 +1001,7 @@ define('format/format-plugin', [
9681001
},
9691002

9701003
_createTypographyContext: function () {
971-
var latestOptions = (plugin.config || []).map(function (nodeName) {
1004+
var latestOptions = (plugin.typographyOptions || []).map(function (nodeName) {
9721005
var settings = plugin.buttonConfig[nodeName];
9731006

9741007
// If there's no settings, we have to ignore it
@@ -992,6 +1025,13 @@ define('format/format-plugin', [
9921025
return option != null;
9931026
});
9941027

1028+
// In case there's only one option, and we already have it selected,
1029+
// then we can skip opening the context all together, as the user can't
1030+
// change it to something else anyways.
1031+
if (latestOptions.length === 1 && latestOptions[0].id === plugin.activeTypography) {
1032+
return null;
1033+
}
1034+
9951035
return {
9961036
type: 'select-menu',
9971037
options: {

0 commit comments

Comments
 (0)