roosterjs 9.40.0 → 9.41.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.
@@ -92,16 +92,27 @@ var BridgePlugin = /** @class */ (function () {
92
92
  * @param target Target node that triggered a ContextMenu event
93
93
  * @returns An array of context menu items, or null means no items needed
94
94
  */
95
- BridgePlugin.prototype.getContextMenuItems = function (target) {
95
+ BridgePlugin.prototype.getContextMenuItems = function (target, event) {
96
96
  var allItems = [];
97
97
  this.contextMenuProviders.forEach(function (provider) {
98
- var _a;
99
- var items = (_a = provider.getContextMenuItems(target)) !== null && _a !== void 0 ? _a : [];
100
- if ((items === null || items === void 0 ? void 0 : items.length) > 0) {
101
- if (allItems.length > 0) {
102
- allItems.push(null);
98
+ var _a, _b;
99
+ if (isMixedPluginProvider(provider)) {
100
+ var items = (_a = provider.getContextMenuItems(target, event)) !== null && _a !== void 0 ? _a : [];
101
+ if ((items === null || items === void 0 ? void 0 : items.length) > 0) {
102
+ if (allItems.length > 0) {
103
+ allItems.push(null);
104
+ }
105
+ allItems.push.apply(allItems, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(items), false));
106
+ }
107
+ }
108
+ else {
109
+ var items = (_b = provider.getContextMenuItems(target)) !== null && _b !== void 0 ? _b : [];
110
+ if ((items === null || items === void 0 ? void 0 : items.length) > 0) {
111
+ if (allItems.length > 0) {
112
+ allItems.push(null);
113
+ }
114
+ allItems.push.apply(allItems, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(items), false));
103
115
  }
104
- allItems.push.apply(allItems, (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)(items), false));
105
116
  }
106
117
  });
107
118
  return allItems;
@@ -149,6 +160,14 @@ var BridgePlugin = /** @class */ (function () {
149
160
  return BridgePlugin;
150
161
  }());
151
162
  exports.BridgePlugin = BridgePlugin;
163
+ /**
164
+ * Check if a provider is a V9 context menu provider
165
+ * @param provider The provider to check
166
+ * @returns True if the provider is a V9 context menu provider, false otherwise
167
+ */
168
+ function isMixedPluginProvider(provider) {
169
+ return isMixedPlugin(provider);
170
+ }
152
171
  /**
153
172
  * @internal Export for test only. This function is only used for compatibility from older build
154
173
 
@@ -1452,6 +1471,15 @@ var KnownAnnounceStringsNewToOld = {
1452
1471
  announceListItemBullet: 2 /* AnnounceListItemBullet */,
1453
1472
  announceListItemNumbering: 1 /* AnnounceListItemNumbering */,
1454
1473
  announceOnFocusLastCell: 3 /* AnnounceOnFocusLastCell */,
1474
+ // New formatting announce strings don't exist in the old system
1475
+ announceBoldOn: undefined,
1476
+ announceBoldOff: undefined,
1477
+ announceItalicOn: undefined,
1478
+ announceItalicOff: undefined,
1479
+ announceUnderlineOn: undefined,
1480
+ announceUnderlineOff: undefined,
1481
+ selected: undefined,
1482
+ unselected: undefined,
1455
1483
  };
1456
1484
  var EntityOperationOldToNew = (_c = {},
1457
1485
  _c[0 /* NewEntity */] = 'newEntity',
@@ -1889,15 +1917,22 @@ function announceDataOldToNew(data) {
1889
1917
  : undefined;
1890
1918
  }
1891
1919
  function announceDataNewToOld(data) {
1892
- return data
1893
- ? {
1894
- defaultStrings: data.defaultStrings
1895
- ? KnownAnnounceStringsNewToOld[data.defaultStrings]
1896
- : undefined,
1897
- formatStrings: data.formatStrings,
1898
- text: data.text,
1899
- }
1920
+ if (!data) {
1921
+ return undefined;
1922
+ }
1923
+ var oldDefaultStrings = data.defaultStrings
1924
+ ? KnownAnnounceStringsNewToOld[data.defaultStrings]
1900
1925
  : undefined;
1926
+ // If the new announce string doesn't exist in the old system (undefined), return undefined for the whole announce data
1927
+ // This means formatting announcements won't be available in the legacy editor adapter
1928
+ if (data.defaultStrings && oldDefaultStrings === undefined) {
1929
+ return undefined;
1930
+ }
1931
+ return {
1932
+ defaultStrings: oldDefaultStrings,
1933
+ formatStrings: data.formatStrings,
1934
+ text: data.text,
1935
+ };
1901
1936
  }
1902
1937
 
1903
1938