@sapui5/sap.ui.richtexteditor 1.138.0 → 1.140.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/sap/ui/richtexteditor/.library +1 -1
- package/src/sap/ui/richtexteditor/RTESplitButton.js +1 -1
- package/src/sap/ui/richtexteditor/RichTextEditorRenderer.js +0 -3
- package/src/sap/ui/richtexteditor/ToolbarWrapper.js +73 -2
- package/src/sap/ui/richtexteditor/library.js +1 -1
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<vendor>SAP SE</vendor>
|
|
6
6
|
<copyright>SAPUI5
|
|
7
7
|
* (c) Copyright 2025 SAP SE. All rights reserved.</copyright>
|
|
8
|
-
<version>1.
|
|
8
|
+
<version>1.140.0</version>
|
|
9
9
|
|
|
10
10
|
<documentation>A rich text editor (RTE) control. Requires installation of an additional rich text editor library.</documentation>
|
|
11
11
|
|
|
@@ -105,6 +105,7 @@ sap.ui.define([
|
|
|
105
105
|
this._oAccessibilityTexts = {};
|
|
106
106
|
this._sTextColor = EditorCommands.TextColor.defaultValue;
|
|
107
107
|
this._sBackgroundColor = EditorCommands.BackgroundColor.defaultValue;
|
|
108
|
+
this._oPreservedMergetagSelection = null;
|
|
108
109
|
};
|
|
109
110
|
|
|
110
111
|
ToolbarWrapper.prototype.onBeforeRendering = function () {
|
|
@@ -157,6 +158,7 @@ sap.ui.define([
|
|
|
157
158
|
this._sTextColor = null;
|
|
158
159
|
this._sBackgroundColor = null;
|
|
159
160
|
this._bLinkPrefixChecked = null;
|
|
161
|
+
this._oPreservedMergetagSelection = null;
|
|
160
162
|
};
|
|
161
163
|
|
|
162
164
|
/**
|
|
@@ -291,6 +293,17 @@ sap.ui.define([
|
|
|
291
293
|
editor.on('NodeChange', function () {
|
|
292
294
|
that._syncToolbarStates(this);
|
|
293
295
|
});
|
|
296
|
+
|
|
297
|
+
// When using mergetags plugin, the selection is lost when the user clicks on a toolbar action.
|
|
298
|
+
// This is a workaround to restore the last selection made by the user.
|
|
299
|
+
editor.on('SelectionChange', function() {
|
|
300
|
+
var oSelectionNode = this.selection.getNode();
|
|
301
|
+
if (oSelectionNode && oSelectionNode.classList && oSelectionNode.classList.contains('mce-mergetag')) {
|
|
302
|
+
that._oPreservedMergetagSelection = oSelectionNode;
|
|
303
|
+
} else {
|
|
304
|
+
that._oPreservedMergetagSelection = null;
|
|
305
|
+
}
|
|
306
|
+
});
|
|
294
307
|
};
|
|
295
308
|
|
|
296
309
|
return oConfig;
|
|
@@ -309,6 +322,7 @@ sap.ui.define([
|
|
|
309
322
|
// Prevent losing the focus to the overflow toolbar button after the menu popover is closed
|
|
310
323
|
setTimeout(function(){
|
|
311
324
|
if (bDefaultColor || this._getColor(sCommand).replace(/,\s/g, ',') !== sColor) {
|
|
325
|
+
this._restoreMergetagSelection();
|
|
312
326
|
this.getEditor().getNativeApi().execCommand(sCommandName, false, sColor);
|
|
313
327
|
}
|
|
314
328
|
}.bind(this), 0);
|
|
@@ -347,6 +361,7 @@ sap.ui.define([
|
|
|
347
361
|
var oEditorCommand, oControl, sEditorCommand,
|
|
348
362
|
oFormatter = oNativeEditor.formatter,
|
|
349
363
|
oResourceBundle = this._oResourceBundle,
|
|
364
|
+
that = this,
|
|
350
365
|
_syncTextAlign = function (oTextAlignCommand, oEditorFormatter, oControl) {
|
|
351
366
|
var sAlignCommand, sIconUri, oCommand;
|
|
352
367
|
|
|
@@ -390,6 +405,12 @@ sap.ui.define([
|
|
|
390
405
|
var sFontName, sCommandValue, sText, sItemId,
|
|
391
406
|
sFontNameCommandValue = oEditor.getDoc().queryCommandValue("FontName");
|
|
392
407
|
|
|
408
|
+
// Enhanced mergetag font family detection
|
|
409
|
+
if (that._oPreservedMergetagSelection) {
|
|
410
|
+
var oPreservedComputedStyle = oEditor.getDoc().defaultView.getComputedStyle(that._oPreservedMergetagSelection);
|
|
411
|
+
sFontNameCommandValue = oPreservedComputedStyle.fontFamily || sFontNameCommandValue;
|
|
412
|
+
}
|
|
413
|
+
|
|
393
414
|
// Synchronize the selected item of the Font Family Select with the applied font family style
|
|
394
415
|
for (sFontName in oFontFamilyCommand) {
|
|
395
416
|
if (!oFontFamilyCommand.hasOwnProperty(sFontName)) {
|
|
@@ -502,7 +523,8 @@ sap.ui.define([
|
|
|
502
523
|
*/
|
|
503
524
|
ToolbarWrapper.prototype._createButtonConfig = function (sCommand) {
|
|
504
525
|
var oCommand = EditorCommands[sCommand],
|
|
505
|
-
oRTE = this.getEditor()
|
|
526
|
+
oRTE = this.getEditor(),
|
|
527
|
+
that = this;
|
|
506
528
|
|
|
507
529
|
return {
|
|
508
530
|
id: this._getId(sCommand),
|
|
@@ -511,6 +533,7 @@ sap.ui.define([
|
|
|
511
533
|
text: this._oResourceBundle.getText(oCommand.bundleKey),
|
|
512
534
|
press: function () {
|
|
513
535
|
if (oRTE) {
|
|
536
|
+
that._restoreMergetagSelection();
|
|
514
537
|
oRTE.getNativeApi().execCommand(oCommand.command);
|
|
515
538
|
} else {
|
|
516
539
|
Log.warning("Cannot execute native command: " + oCommand.command);
|
|
@@ -727,6 +750,9 @@ sap.ui.define([
|
|
|
727
750
|
}
|
|
728
751
|
},
|
|
729
752
|
arrowPress: function () {
|
|
753
|
+
// Preserve mergetag selection before opening popover
|
|
754
|
+
that._preserveMergetagSelection();
|
|
755
|
+
|
|
730
756
|
oDialog = that.getAggregation("_custom" + sCommand + "Dialog");
|
|
731
757
|
|
|
732
758
|
this._getArrowButton()._activeButton();
|
|
@@ -1596,10 +1622,12 @@ sap.ui.define([
|
|
|
1596
1622
|
selectedItemId: this._getId("FontFamilyVerdana"),
|
|
1597
1623
|
items: this._createFontStyleSelectItems(),
|
|
1598
1624
|
change: function (oEvent) {
|
|
1625
|
+
that._preserveMergetagSelection();
|
|
1599
1626
|
var oItem;
|
|
1600
1627
|
|
|
1601
1628
|
if (oRTE) {
|
|
1602
1629
|
oItem = oEvent.getSource().getSelectedItem();
|
|
1630
|
+
that._restoreMergetagSelection();
|
|
1603
1631
|
oRTE.getNativeApi().execCommand('FontName', false, that._getFontStyleCommand(oItem.getText()));
|
|
1604
1632
|
} else {
|
|
1605
1633
|
Log.warning("Cannot execute native command: " + 'FontName');
|
|
@@ -1629,10 +1657,12 @@ sap.ui.define([
|
|
|
1629
1657
|
})
|
|
1630
1658
|
],
|
|
1631
1659
|
change: function (oEvent) {
|
|
1660
|
+
that._preserveMergetagSelection();
|
|
1632
1661
|
var oItem;
|
|
1633
1662
|
|
|
1634
1663
|
if (oRTE) {
|
|
1635
1664
|
oItem = oEvent.getSource().getSelectedItem();
|
|
1665
|
+
that._restoreMergetagSelection();
|
|
1636
1666
|
oRTE.getNativeApi().execCommand('FontSize', false, oItem.getText().replace(/\s/g, ""));
|
|
1637
1667
|
} else {
|
|
1638
1668
|
Log.warning("Cannot execute native command: " + 'FontSize');
|
|
@@ -1671,22 +1701,26 @@ sap.ui.define([
|
|
|
1671
1701
|
ToolbarWrapper.prototype._createTextAlignToolbarContent = function (bVisible) {
|
|
1672
1702
|
var oRTE = this.getEditor();
|
|
1673
1703
|
var bGroupVisible = oRTE ? oRTE.getShowGroupFontStyle() || bVisible : false;
|
|
1674
|
-
var that = this;
|
|
1675
1704
|
var bTextAlignLRight = oRTE._getTextDirection() === "rtl";
|
|
1676
1705
|
var iDefaultItemIndex = bTextAlignLRight ? 2 : 0;
|
|
1677
1706
|
var aMenuItems = this._createMenuButtonItems("TextAlign");
|
|
1707
|
+
var that = this;
|
|
1678
1708
|
|
|
1679
1709
|
return [
|
|
1680
1710
|
this._helper.createMenuButton(
|
|
1681
1711
|
this._getId("TextAlign"),
|
|
1682
1712
|
aMenuItems,
|
|
1683
1713
|
function (oEvent) {
|
|
1714
|
+
that._preserveMergetagSelection();
|
|
1684
1715
|
var oSelectedItem, oEditor, oSelectedItemIcon;
|
|
1716
|
+
var oPreservedNode = that._oPreservedMergetagSelection;
|
|
1685
1717
|
|
|
1686
1718
|
if (oRTE) {
|
|
1687
1719
|
oSelectedItem = oEvent.getParameter("item");
|
|
1688
1720
|
oEditor = oRTE.getNativeApi();
|
|
1689
1721
|
oSelectedItemIcon = oSelectedItem.getIcon();
|
|
1722
|
+
|
|
1723
|
+
that._restoreMergetagSelection();
|
|
1690
1724
|
if (oSelectedItemIcon === this.getParent().getIcon()) {
|
|
1691
1725
|
var sTextAlign = bTextAlignLRight ? "JustifyRight" : "JustifyLeft";
|
|
1692
1726
|
// Text Align commands in TinyMCE have a toggle behavior when you set a
|
|
@@ -1695,6 +1729,14 @@ sap.ui.define([
|
|
|
1695
1729
|
} else {
|
|
1696
1730
|
oEditor.execCommand('Justify' + that._findTextAlignCommandByIcon(oSelectedItemIcon));
|
|
1697
1731
|
}
|
|
1732
|
+
|
|
1733
|
+
// Restore mergetag selection after TinyMCE moves focus
|
|
1734
|
+
if (oPreservedNode && oPreservedNode.classList && oPreservedNode.classList.contains('mce-mergetag')) {
|
|
1735
|
+
// Prevent losing the focus to the overflow toolbar button after the menu popover is closed
|
|
1736
|
+
requestAnimationFrame(function() {
|
|
1737
|
+
oEditor.selection.select(oPreservedNode);
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1698
1740
|
} else {
|
|
1699
1741
|
Log.warning("Cannot execute native command: " + 'Justify');
|
|
1700
1742
|
}
|
|
@@ -1706,6 +1748,7 @@ sap.ui.define([
|
|
|
1706
1748
|
};
|
|
1707
1749
|
|
|
1708
1750
|
ToolbarWrapper.prototype._createFormatSelectToolbarContent = function (bVisible) {
|
|
1751
|
+
var that = this;
|
|
1709
1752
|
var oRTE = this.getEditor();
|
|
1710
1753
|
var oAccessibilityKeys = library.Accessibility;
|
|
1711
1754
|
var oInvisibleTextFormatBlock = this._helper.createInvisibleText({
|
|
@@ -1720,10 +1763,12 @@ sap.ui.define([
|
|
|
1720
1763
|
ariaLabelledBy: oInvisibleTextFormatBlock,
|
|
1721
1764
|
items: this._createFormatBlockItems(),
|
|
1722
1765
|
change: function (oEvent) {
|
|
1766
|
+
that._preserveMergetagSelection();
|
|
1723
1767
|
var oSelectedItem;
|
|
1724
1768
|
if (oRTE) {
|
|
1725
1769
|
oSelectedItem = oEvent.getSource().getSelectedItem();
|
|
1726
1770
|
if (oSelectedItem) {
|
|
1771
|
+
that._restoreMergetagSelection();
|
|
1727
1772
|
var currentFormatterCommand = oRTE.getAggregation("_toolbarWrapper")._getFormatBlockCommand(oSelectedItem.getText());
|
|
1728
1773
|
oRTE.getNativeApi().execCommand('FormatBlock', false, currentFormatterCommand);
|
|
1729
1774
|
}
|
|
@@ -2352,5 +2397,31 @@ sap.ui.define([
|
|
|
2352
2397
|
return Element.getElementById(oRTE.getId() + this.getId() + "-" + sButtonName);
|
|
2353
2398
|
};
|
|
2354
2399
|
|
|
2400
|
+
// When using mergetags plugin, the selection is lost when the user clicks on a toolbar action.
|
|
2401
|
+
// This is a workaround to restore the last selection made by the user.
|
|
2402
|
+
ToolbarWrapper.prototype._preserveMergetagSelection = function () {
|
|
2403
|
+
var oEditor = this.getEditor();
|
|
2404
|
+
if (!oEditor) {
|
|
2405
|
+
return;
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
var oSelectionNode = oEditor.getNativeApi().selection.getNode();
|
|
2409
|
+
|
|
2410
|
+
if (oSelectionNode && oSelectionNode.classList && oSelectionNode.classList.contains('mce-mergetag')) {
|
|
2411
|
+
this._oPreservedMergetagSelection = oSelectionNode;
|
|
2412
|
+
}
|
|
2413
|
+
};
|
|
2414
|
+
|
|
2415
|
+
ToolbarWrapper.prototype._restoreMergetagSelection = function () {
|
|
2416
|
+
if (this._oPreservedMergetagSelection) {
|
|
2417
|
+
var oEditor = this.getEditor();
|
|
2418
|
+
if (oEditor) {
|
|
2419
|
+
var oNativeEditor = oEditor.getNativeApi();
|
|
2420
|
+
oNativeEditor.selection.select(this._oPreservedMergetagSelection);
|
|
2421
|
+
}
|
|
2422
|
+
this._oPreservedMergetagSelection = null;
|
|
2423
|
+
}
|
|
2424
|
+
};
|
|
2425
|
+
|
|
2355
2426
|
return ToolbarWrapper;
|
|
2356
2427
|
});
|