HostExtensionServices.ts 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. //
  2. // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. import * as EditorUI from "../ui/EditorUI";
  23. import MainFrame = require("../ui/frames/MainFrame");
  24. import InspectorFrame = require("../ui/frames/inspector/InspectorFrame");
  25. import ModalOps = require("../ui/modal/ModalOps");
  26. import ResourceOps = require("../resources/ResourceOps");
  27. /**
  28. * Generic registry for storing Editor Extension Services
  29. */
  30. export class ServicesProvider<T extends Editor.Extensions.ServiceEventListener> implements Editor.Extensions.ServicesProvider<T> {
  31. registeredServices: T[] = [];
  32. /**
  33. * Adds a service to the registered services list for this type of service
  34. * @param {T} service the service to register
  35. */
  36. register(service: T) {
  37. this.registeredServices.push(service);
  38. }
  39. unregister(service: T) {
  40. var index = this.registeredServices.indexOf(service, 0);
  41. if (index > -1) {
  42. this.registeredServices.splice(index, 1);
  43. }
  44. }
  45. }
  46. export interface ServiceEventSubscriber {
  47. /**
  48. * Allow this service registry to subscribe to events that it is interested in
  49. * @param {Atomic.UIWidget} topLevelWindow The top level window that will be receiving these events
  50. */
  51. subscribeToEvents(topLevelWindow: Atomic.UIWidget);
  52. }
  53. /**
  54. * Registry for service extensions that are concerned about project events
  55. */
  56. export class ProjectServicesProvider extends ServicesProvider<Editor.HostExtensions.ProjectServicesEventListener> implements Editor.HostExtensions.ProjectServicesProvider {
  57. constructor() {
  58. super();
  59. }
  60. /**
  61. * Allow this service registry to subscribe to events that it is interested in
  62. * @param {Atomic.UIWidget} topLevelWindow The top level window that will be receiving these events
  63. */
  64. subscribeToEvents(eventDispatcher: Editor.Extensions.EventDispatcher) {
  65. eventDispatcher.subscribeToEvent(Editor.LoadProjectNotificationEvent((ev) => this.projectLoaded(ev)));
  66. eventDispatcher.subscribeToEvent(Editor.EditorCloseProjectEvent((ev) => this.projectUnloaded(ev)));
  67. eventDispatcher.subscribeToEvent(Editor.EditorPlayRequestEvent(() => this.playerStarted()));
  68. }
  69. /**
  70. * Called when the project is unloaded
  71. * @param {[type]} data Event info from the project unloaded event
  72. */
  73. projectUnloaded(data) {
  74. // Need to use a for loop for length down to 0 because extensions *could* delete themselves from the list on projectUnloaded
  75. for (let i = this.registeredServices.length - 1; i >= 0; i--) {
  76. let service = this.registeredServices[i];
  77. // Notify services that the project has been unloaded
  78. try {
  79. if (service.projectUnloaded) {
  80. service.projectUnloaded();
  81. }
  82. } catch (e) {
  83. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e} \n\n ${e.stack}`);
  84. }
  85. };
  86. }
  87. /**
  88. * Called when the project is loaded
  89. * @param {[type]} data Event info from the project unloaded event
  90. */
  91. projectLoaded(ev: Editor.EditorLoadProjectEvent) {
  92. // Need to use a for loop and don't cache the length because the list of services *may* change while processing. Extensions could be appended to the end
  93. for (let i = 0; i < this.registeredServices.length; i++) {
  94. let service = this.registeredServices[i];
  95. try {
  96. // Notify services that the project has just been loaded
  97. if (service.projectLoaded) {
  98. service.projectLoaded(ev);
  99. }
  100. } catch (e) {
  101. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  102. }
  103. };
  104. }
  105. playerStarted() {
  106. this.registeredServices.forEach((service) => {
  107. try {
  108. // Notify services that the project has just been loaded
  109. if (service.playerStarted) {
  110. service.playerStarted();
  111. }
  112. } catch (e) {
  113. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}\n \n ${e.stack}`);
  114. }
  115. });
  116. }
  117. /**
  118. * Return a preference value or the provided default from the user settings file
  119. * @param {string} extensionName name of the extension the preference lives under
  120. * @param {string} preferenceName name of the preference to retrieve
  121. * @param {number | boolean | string} defaultValue value to return if pref doesn't exist
  122. * @return {number|boolean|string}
  123. */
  124. getUserPreference(settingsGroup: string, preferenceName: string, defaultValue?: number): number;
  125. getUserPreference(settingsGroup: string, preferenceName: string, defaultValue?: string): string;
  126. getUserPreference(settingsGroup: string, preferenceName: string, defaultValue?: boolean): boolean;
  127. getUserPreference(extensionName: string, preferenceName: string, defaultValue?: any): any {
  128. return EditorUI.getEditor().getUserPreference(extensionName, preferenceName, defaultValue);
  129. }
  130. /**
  131. * Sets a user preference value in the user settings file
  132. * @param {string} extensionName name of the extension the preference lives under
  133. * @param {string} preferenceName name of the preference to set
  134. * @param {number | boolean | string} value value to set
  135. */
  136. setUserPreference(extensionName: string, preferenceName: string, value: number | boolean | string) {
  137. EditorUI.getEditor().setUserPreference(extensionName, preferenceName, value);
  138. }
  139. /**
  140. * Sets a group of user preference values in the user settings file located in the project. Elements in the
  141. * group will merge in with existing group preferences. Use this method if setting a bunch of settings
  142. * at once.
  143. * @param {string} extensionName name of the group the preference lives under
  144. * @param {string} groupPreferenceValues an object literal containing all of the preferences for the group.
  145. */
  146. setUserPreferenceGroup(extensionName: string, groupPreferenceValues: Object) {
  147. EditorUI.getEditor().setUserPreferenceGroup(extensionName, groupPreferenceValues);
  148. }
  149. }
  150. /**
  151. * Registry for service extensions that are concerned about Resources
  152. */
  153. export class ResourceServicesProvider extends ServicesProvider<Editor.HostExtensions.ResourceServicesEventListener> implements Editor.HostExtensions.ResourceServicesProvider {
  154. constructor() {
  155. super();
  156. }
  157. /**
  158. * Allow this service registry to subscribe to events that it is interested in
  159. * @param {Atomic.UIWidget} topLevelWindow The top level window that will be receiving these events
  160. */
  161. subscribeToEvents(eventDispatcher: Editor.Extensions.EventDispatcher) {
  162. eventDispatcher.subscribeToEvent(Editor.EditorSaveResourceNotificationEvent((ev) => this.saveResource(ev)));
  163. eventDispatcher.subscribeToEvent(Editor.EditorDeleteResourceNotificationEvent((ev) => this.deleteResource(ev)));
  164. eventDispatcher.subscribeToEvent(Editor.EditorRenameResourceNotificationEvent((ev) => this.renameResource(ev)));
  165. eventDispatcher.subscribeToEvent(Editor.EditorEditResourceEvent((ev) => this.editResource(ev)));
  166. }
  167. /**
  168. * Called after a resource has been saved
  169. * @param {Editor.EditorEvents.SaveResourceEvent} ev
  170. */
  171. saveResource(ev: Editor.EditorSaveResourceEvent) {
  172. // run through and find any services that can handle this.
  173. this.registeredServices.forEach((service) => {
  174. try {
  175. // Verify that the service contains the appropriate methods and that it can save
  176. if (service.save) {
  177. service.save(ev);
  178. }
  179. } catch (e) {
  180. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  181. }
  182. });
  183. }
  184. /**
  185. * Called when a resource has been deleted
  186. */
  187. deleteResource(ev: Editor.EditorDeleteResourceEvent) {
  188. this.registeredServices.forEach((service) => {
  189. try {
  190. // Verify that the service contains the appropriate methods and that it can delete
  191. if (service.delete) {
  192. service.delete(ev);
  193. }
  194. } catch (e) {
  195. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  196. }
  197. });
  198. }
  199. /**
  200. * Called when a resource has been renamed
  201. * @param ev
  202. */
  203. renameResource(ev: Editor.EditorRenameResourceNotificationEvent) {
  204. this.registeredServices.forEach((service) => {
  205. try {
  206. // Verify that the service contains the appropriate methods and that it can handle the rename
  207. if (service.rename) {
  208. service.rename(ev);
  209. }
  210. } catch (e) {
  211. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  212. }
  213. });
  214. }
  215. /**
  216. * Called when a resource is about to be edited
  217. * @param {Editor.EditorEvents.EditResourceEvent} ev
  218. */
  219. editResource(ev: Editor.EditorEditResourceEvent) {
  220. this.registeredServices.forEach((service) => {
  221. try {
  222. // Verify that the service contains the appropriate methods and that it can handle the edit
  223. if (service.edit) {
  224. service.edit(ev);
  225. }
  226. } catch (e) {
  227. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  228. }
  229. });
  230. }
  231. /**
  232. * Create New Material
  233. * @param {string} resourcePath
  234. * @param {string} materialName
  235. * @param {boolean} reportError
  236. */
  237. createMaterial(resourcePath: string, materialName: string, reportError: boolean): boolean {
  238. return ResourceOps.CreateNewMaterial(resourcePath, materialName, reportError);
  239. }
  240. }
  241. /**
  242. * Registry for service extensions that are concerned about Scenes
  243. */
  244. export class SceneServicesProvider extends ServicesProvider<Editor.HostExtensions.SceneServicesEventListener> implements Editor.HostExtensions.SceneServicesProvider {
  245. constructor() {
  246. super();
  247. }
  248. /**
  249. * Allow this service registry to subscribe to events that it is interested in
  250. * @param {Atomic.UIWidget} topLevelWindow The top level window that will be receiving these events
  251. */
  252. subscribeToEvents(eventDispatcher: Editor.Extensions.EventDispatcher) {
  253. eventDispatcher.subscribeToEvent(Editor.EditorActiveSceneEditorChangeEvent((ev) => this.activeSceneEditorChange(ev)));
  254. eventDispatcher.subscribeToEvent(Editor.EditorSceneClosedEvent((ev) => this.sceneClosed(ev)));
  255. }
  256. /**
  257. * Called after an active scene editor change
  258. * @param {Editor.EditorEvents.ActiveSceneEditorChangeEvent} ev
  259. */
  260. activeSceneEditorChange(ev: Editor.EditorActiveSceneEditorChangeEvent) {
  261. // run through and find any services that can handle this.
  262. this.registeredServices.forEach((service) => {
  263. try {
  264. // Verify that the service contains the appropriate methods and that it can save
  265. if (service.activeSceneEditorChanged) {
  266. service.activeSceneEditorChanged(ev);
  267. }
  268. } catch (e) {
  269. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  270. }
  271. });
  272. }
  273. /**
  274. * Called after a scene is closed
  275. * @param {Editor.EditorEvents.SceneClosedEvent} ev
  276. */
  277. sceneClosed(ev: Editor.EditorSceneClosedEvent) {
  278. // run through and find any services that can handle this.
  279. this.registeredServices.forEach((service) => {
  280. try {
  281. // Verify that the service contains the appropriate methods and that it can save
  282. if (service.editorSceneClosed) {
  283. service.editorSceneClosed(ev);
  284. }
  285. } catch (e) {
  286. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  287. }
  288. });
  289. }
  290. }
  291. /**
  292. * Registry for service extensions that are concerned about and need access to parts of the editor user interface
  293. * Note: we may want to move this out into it's own file since it has a bunch of editor dependencies
  294. */
  295. export class UIServicesProvider extends ServicesProvider<Editor.HostExtensions.UIServicesEventListener> implements Editor.HostExtensions.UIServicesProvider {
  296. constructor() {
  297. super();
  298. }
  299. private mainFrame: MainFrame = null;
  300. private inspectorFrame: InspectorFrame = null;
  301. private modalOps: ModalOps;
  302. init(mainFrame: MainFrame, modalOps: ModalOps) {
  303. // Only set these once
  304. if (this.mainFrame == null) {
  305. this.mainFrame = mainFrame;
  306. this.inspectorFrame = this.mainFrame.inspectorframe;
  307. }
  308. if (this.modalOps == null) {
  309. this.modalOps = modalOps;
  310. }
  311. }
  312. /**
  313. * Adds a new menu to the plugin menu
  314. * @param {string} id
  315. * @param {any} items
  316. * @return {Atomic.UIMenuItemSource}
  317. */
  318. createPluginMenuItemSource(id: string, items: any): Atomic.UIMenuItemSource {
  319. return this.mainFrame.menu.createPluginMenuItemSource(id, items);
  320. }
  321. /**
  322. * Removes a previously added menu from the plugin menu
  323. * @param {string} id
  324. */
  325. removePluginMenuItemSource(id: string) {
  326. this.mainFrame.menu.removePluginMenuItemSource(id);
  327. }
  328. /**
  329. * Returns the currently active resource editor or null
  330. * @return {Editor.ResourceEditor}
  331. */
  332. getCurrentResourceEditor(): Editor.ResourceEditor {
  333. return this.mainFrame.resourceframe.currentResourceEditor;
  334. }
  335. /**
  336. * Adds a new menu to the hierarchy context menu
  337. * @param {string} id
  338. * @param {any} items
  339. * @return {Atomic.UIMenuItemSource}
  340. */
  341. createHierarchyContextMenuItemSource(id: string, items: any): Atomic.UIMenuItemSource {
  342. return this.mainFrame.hierarchyFrame.menu.createPluginItemSource(id, items);
  343. }
  344. /**
  345. * Removes a previously added menu from the hierarchy context menu
  346. * @param {string} id
  347. */
  348. removeHierarchyContextMenuItemSource(id: string) {
  349. this.mainFrame.hierarchyFrame.menu.removePluginItemSource(id);
  350. }
  351. /**
  352. * Adds a new menu to the project context menu
  353. * @param {string} id
  354. * @param {any} items
  355. * @return {Atomic.UIMenuItemSource}
  356. */
  357. createProjectContextMenuItemSource(id: string, items: any): Atomic.UIMenuItemSource {
  358. return this.mainFrame.projectframe.menu.createPluginItemSource(id, items);
  359. }
  360. /**
  361. * Removes a previously added menu from the project context menu
  362. * @param {string} id
  363. */
  364. removeProjectContextMenuItemSource(id: string) {
  365. this.mainFrame.projectframe.menu.removePluginItemSource(id);
  366. }
  367. /**
  368. * Refreshes the hierarchy frame
  369. */
  370. refreshHierarchyFrame() {
  371. this.mainFrame.hierarchyFrame.populate();
  372. }
  373. /**
  374. * Loads Custom Inspector Widget
  375. * @param {Atomic.UIWidget} customInspector
  376. */
  377. loadCustomInspector(customInspector: Atomic.UIWidget) {
  378. if (this.inspectorFrame) {
  379. this.inspectorFrame.loadCustomInspectorWidget(customInspector);
  380. }
  381. }
  382. /**
  383. * Disaplays a modal window
  384. * @param {Editor.Modal.ModalWindow} window
  385. */
  386. showModalWindow(windowText: string, uifilename: string, handleWidgetEventCB: (ev: Atomic.UIWidgetEvent) => void): Editor.Modal.ExtensionWindow {
  387. return this.modalOps.showExtensionWindow(windowText, uifilename, handleWidgetEventCB);
  388. }
  389. /**
  390. * Disaplays a modal error window
  391. * @param {string} windowText
  392. * @param {string} message
  393. */
  394. showModalError(windowText: string, message: string) {
  395. return this.modalOps.showError(windowText, message);
  396. }
  397. /**
  398. * Displays a resource slection window
  399. * @param {string} windowText
  400. * @param {string} importerType
  401. * @param {string} resourceType
  402. * @param {function} callback
  403. * @param {any} retObject
  404. * @param {any} args
  405. */
  406. showResourceSelection(windowText: string, importerType: string, resourceType: string, callback: (retObject: any, args: any) => void, args: any = undefined) {
  407. this.modalOps.showResourceSelection(windowText, importerType, resourceType, callback);
  408. }
  409. /**
  410. * Will register a custom editor for a particular file type.
  411. * @param {Editor.Extensions.ResourceEditorBuilder} editorBuilder
  412. */
  413. registerCustomEditor(editorBuilder: Editor.Extensions.ResourceEditorBuilder) {
  414. this.mainFrame.resourceframe.resourceEditorProvider.registerCustomEditor(editorBuilder);
  415. }
  416. /**
  417. * Will unregister a previously registered editor builder
  418. * @param {Editor.Extensions.ResourceEditorBuilder} editorBuilder
  419. */
  420. unregisterCustomEditor(editorBuilder: Editor.Extensions.ResourceEditorBuilder) {
  421. this.mainFrame.resourceframe.resourceEditorProvider.unregisterCustomEditor(editorBuilder);
  422. }
  423. /**
  424. * Called when a menu item has been clicked
  425. * @param {string} refId
  426. * @type {boolean} return true if handled
  427. */
  428. menuItemClicked(refid: string): boolean {
  429. // run through and find any services that can handle this.
  430. return this.registeredServices.some((service) => {
  431. try {
  432. // Verify that the service contains the appropriate methods and that it can handle it
  433. if (service.menuItemClicked) {
  434. if (service.menuItemClicked(refid)) {
  435. return true;
  436. }
  437. }
  438. } catch (e) {
  439. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  440. }
  441. });
  442. }
  443. /**
  444. * Called when a context menu item in the hierarchy pane has been clicked
  445. * @param {Atomic.Node} node
  446. * @param {string} refId
  447. * @type {boolean} return true if handled
  448. */
  449. hierarchyContextItemClicked(node: Atomic.Node, refid: string): boolean {
  450. if (!node)
  451. return false;
  452. // run through and find any services that can handle this.
  453. return this.registeredServices.some((service) => {
  454. try {
  455. // Verify that the service contains the appropriate methods and that it can handle it
  456. if (service.hierarchyContextItemClicked) {
  457. if (service.hierarchyContextItemClicked(node, refid)) {
  458. return true;
  459. }
  460. }
  461. } catch (e) {
  462. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  463. }
  464. });
  465. }
  466. /**
  467. * Called when a context menu item in the hierarchy pane has been clicked
  468. * @param {ToolCore.Asset} asset
  469. * @param {string} refId
  470. * @type {boolean} return true if handled
  471. */
  472. projectContextItemClicked(asset: ToolCore.Asset, refid: string): boolean {
  473. if (!asset)
  474. return false;
  475. // run through and find any services that can handle this.
  476. return this.registeredServices.some((service) => {
  477. try {
  478. // Verify that the service contains the appropriate methods and that it can handle it
  479. if (service.projectContextItemClicked) {
  480. if (service.projectContextItemClicked(asset, refid)) {
  481. return true;
  482. }
  483. }
  484. } catch (e) {
  485. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  486. }
  487. });
  488. }
  489. /**
  490. * Called when a project asset in the hierarchy pane has been clicked
  491. * @param {ToolCore.Asset} asset
  492. * @type {boolean} return true if handled
  493. */
  494. projectAssetClicked(asset: ToolCore.Asset):boolean {
  495. if (!asset) {
  496. return false;
  497. }
  498. // run through and find any services that can handle this.
  499. return this.registeredServices.some((service) => {
  500. try {
  501. // Verify that the service contains the appropriate methods and that it can handle it
  502. if (service.projectAssetClicked) {
  503. if (service.projectAssetClicked(asset)) {
  504. return true;
  505. }
  506. }
  507. } catch (e) {
  508. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  509. }
  510. });
  511. }
  512. /**
  513. * Hooks into web messages coming in from web views
  514. * @param {[String|Object]} data
  515. */
  516. handleWebMessage(data: WebView.WebMessageEvent) {
  517. let messageType;
  518. let messageObject;
  519. try {
  520. messageObject = JSON.parse(data.request);
  521. messageType = messageObject.message;
  522. } catch (e) {
  523. // not JSON, we are just getting a notification message of some sort
  524. messageType = data.request;
  525. }
  526. // run through and find any services that can handle this.
  527. this.registeredServices.forEach((service) => {
  528. try {
  529. // Verify that the service contains the appropriate methods and that it can save
  530. if (service.handleWebMessage) {
  531. service.handleWebMessage(messageType, messageObject);
  532. }
  533. } catch (e) {
  534. EditorUI.showModalError("Extension Error", `Error detected in extension ${service.name}:\n${e}\n\n ${e.stack}`);
  535. }
  536. });
  537. }
  538. /**
  539. * Allow this service registry to subscribe to events that it is interested in
  540. * @param {Atomic.UIWidget} topLevelWindow The top level window that will be receiving these events
  541. */
  542. subscribeToEvents(eventDispatcher: Editor.Extensions.EventDispatcher) {
  543. // Placeholder for when UI events published by the editor need to be listened for
  544. eventDispatcher.subscribeToEvent(WebView.WebMessageEvent((ev) => this.handleWebMessage(ev)));
  545. }
  546. }