roosterjs 9.16.0 → 9.18.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.
@@ -49,7 +49,12 @@ var BridgePlugin = /** @class */ (function () {
49
49
  */
50
50
  BridgePlugin.prototype.initialize = function (editor) {
51
51
  var outerEditor = this.onInitialize(this.createEditorCore(editor));
52
- this.legacyPlugins.forEach(function (plugin) { return plugin.initialize(outerEditor); });
52
+ this.legacyPlugins.forEach(function (plugin) {
53
+ plugin.initialize(outerEditor);
54
+ if (isMixedPlugin(plugin)) {
55
+ plugin.initializeV9(editor);
56
+ }
57
+ });
53
58
  };
54
59
  /**
55
60
  * Dispose this plugin
@@ -64,15 +69,15 @@ var BridgePlugin = /** @class */ (function () {
64
69
  return this.checkExclusivelyHandling && !!this.cacheGetExclusivelyHandlePlugin(event);
65
70
  };
66
71
  BridgePlugin.prototype.onPluginEvent = function (event) {
67
- var _a;
72
+ var _this = this;
68
73
  var oldEvent = this.cacheGetOldEvent(event);
69
74
  if (oldEvent) {
70
75
  var exclusivelyHandleEventPlugin = this.cacheGetExclusivelyHandlePlugin(event);
71
76
  if (exclusivelyHandleEventPlugin) {
72
- (_a = exclusivelyHandleEventPlugin.onPluginEvent) === null || _a === void 0 ? void 0 : _a.call(exclusivelyHandleEventPlugin, oldEvent);
77
+ this.handleEvent(exclusivelyHandleEventPlugin, oldEvent, event);
73
78
  }
74
79
  else {
75
- this.legacyPlugins.forEach(function (plugin) { var _a; return (_a = plugin.onPluginEvent) === null || _a === void 0 ? void 0 : _a.call(plugin, oldEvent); });
80
+ this.legacyPlugins.forEach(function (plugin) { return _this.handleEvent(plugin, oldEvent, event); });
76
81
  }
77
82
  Object.assign(event, (0, eventConverter_1.oldEventToNewEvent)(oldEvent, event));
78
83
  }
@@ -99,7 +104,7 @@ var BridgePlugin = /** @class */ (function () {
99
104
  BridgePlugin.prototype.cacheGetExclusivelyHandlePlugin = function (event) {
100
105
  var _this = this;
101
106
  return (0, roosterjs_content_model_dom_1.cacheGetEventData)(event, ExclusivelyHandleEventPluginKey, function (event) {
102
- var _a;
107
+ var _a, _b;
103
108
  var oldEvent = _this.cacheGetOldEvent(event);
104
109
  if (oldEvent) {
105
110
  for (var i = 0; i < _this.legacyPlugins.length; i++) {
@@ -107,6 +112,9 @@ var BridgePlugin = /** @class */ (function () {
107
112
  if ((_a = plugin.willHandleEventExclusively) === null || _a === void 0 ? void 0 : _a.call(plugin, oldEvent)) {
108
113
  return plugin;
109
114
  }
115
+ if (isMixedPlugin(plugin) && ((_b = plugin.willHandleEventExclusivelyV9) === null || _b === void 0 ? void 0 : _b.call(plugin, event))) {
116
+ return plugin;
117
+ }
110
118
  }
111
119
  }
112
120
  return null;
@@ -126,6 +134,13 @@ var BridgePlugin = /** @class */ (function () {
126
134
  contextMenuProviders: this.contextMenuProviders,
127
135
  };
128
136
  };
137
+ BridgePlugin.prototype.handleEvent = function (plugin, oldEvent, newEvent) {
138
+ var _a, _b;
139
+ (_a = plugin.onPluginEvent) === null || _a === void 0 ? void 0 : _a.call(plugin, oldEvent);
140
+ if (isMixedPlugin(plugin)) {
141
+ (_b = plugin.onPluginEventV9) === null || _b === void 0 ? void 0 : _b.call(plugin, newEvent);
142
+ }
143
+ };
129
144
  return BridgePlugin;
130
145
  }());
131
146
  exports.BridgePlugin = BridgePlugin;
@@ -141,6 +156,9 @@ function isContextMenuProvider(source) {
141
156
  var _a;
142
157
  return !!((_a = source) === null || _a === void 0 ? void 0 : _a.getContextMenuItems);
143
158
  }
159
+ function isMixedPlugin(plugin) {
160
+ return !!plugin.initializeV9;
161
+ }
144
162
 
145
163
 
146
164
  /***/ }),