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