@theia/core 1.22.0-next.6 → 1.22.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.
Files changed (257) hide show
  1. package/README.in.md +12 -5
  2. package/README.md +43 -35
  3. package/electron-shared/@electron/remote/index.d.ts +1 -0
  4. package/electron-shared/@electron/remote/index.js +1 -0
  5. package/electron-shared/@electron/remote/main/index.d.ts +1 -0
  6. package/electron-shared/@electron/remote/main/index.js +1 -0
  7. package/electron-shared/electron/index.d.ts +2 -0
  8. package/electron-shared/electron/index.js +1 -0
  9. package/electron-shared/electron-store/index.d.ts +2 -0
  10. package/electron-shared/electron-store/index.js +1 -0
  11. package/electron-shared/fix-path/index.d.ts +2 -0
  12. package/electron-shared/fix-path/index.js +1 -0
  13. package/electron-shared/native-keymap/index.d.ts +1 -0
  14. package/electron-shared/native-keymap/index.js +1 -0
  15. package/lib/browser/common-frontend-contribution.js +2 -2
  16. package/lib/browser/common-frontend-contribution.js.map +1 -1
  17. package/lib/browser/context-key-service.d.ts +46 -3
  18. package/lib/browser/context-key-service.d.ts.map +1 -1
  19. package/lib/browser/context-key-service.js +24 -5
  20. package/lib/browser/context-key-service.js.map +1 -1
  21. package/lib/browser/context-menu-renderer.d.ts +7 -0
  22. package/lib/browser/context-menu-renderer.d.ts.map +1 -1
  23. package/lib/browser/context-menu-renderer.js +4 -1
  24. package/lib/browser/context-menu-renderer.js.map +1 -1
  25. package/lib/browser/dialogs.d.ts +1 -0
  26. package/lib/browser/dialogs.d.ts.map +1 -1
  27. package/lib/browser/dialogs.js +5 -2
  28. package/lib/browser/dialogs.js.map +1 -1
  29. package/lib/browser/external-uri-service.d.ts +12 -13
  30. package/lib/browser/external-uri-service.d.ts.map +1 -1
  31. package/lib/browser/external-uri-service.js +22 -12
  32. package/lib/browser/external-uri-service.js.map +1 -1
  33. package/lib/browser/frontend-application-module.js +1 -1
  34. package/lib/browser/frontend-application-module.js.map +1 -1
  35. package/lib/browser/frontend-application.d.ts +6 -0
  36. package/lib/browser/frontend-application.d.ts.map +1 -1
  37. package/lib/browser/frontend-application.js.map +1 -1
  38. package/lib/browser/index.d.ts +0 -1
  39. package/lib/browser/index.d.ts.map +1 -1
  40. package/lib/browser/index.js +0 -1
  41. package/lib/browser/index.js.map +1 -1
  42. package/lib/browser/keybinding.d.ts +5 -2
  43. package/lib/browser/keybinding.d.ts.map +1 -1
  44. package/lib/browser/keybinding.js +8 -5
  45. package/lib/browser/keybinding.js.map +1 -1
  46. package/lib/browser/keybinding.spec.js +1 -1
  47. package/lib/browser/keybinding.spec.js.map +1 -1
  48. package/lib/browser/menu/browser-menu-plugin.js +1 -1
  49. package/lib/browser/menu/browser-menu-plugin.js.map +1 -1
  50. package/lib/browser/navigatable-types.d.ts +1 -0
  51. package/lib/browser/navigatable-types.d.ts.map +1 -1
  52. package/lib/browser/navigatable-types.js +6 -0
  53. package/lib/browser/navigatable-types.js.map +1 -1
  54. package/lib/browser/preferences/preference-contribution.d.ts.map +1 -1
  55. package/lib/browser/preferences/preference-contribution.js +3 -3
  56. package/lib/browser/preferences/preference-contribution.js.map +1 -1
  57. package/lib/browser/quick-input/quick-command-service.js +1 -1
  58. package/lib/browser/quick-input/quick-command-service.js.map +1 -1
  59. package/lib/browser/quick-input/quick-view-service.js +1 -1
  60. package/lib/browser/quick-input/quick-view-service.js.map +1 -1
  61. package/lib/browser/resource-context-key.js +1 -1
  62. package/lib/browser/resource-context-key.js.map +1 -1
  63. package/lib/browser/shell/application-shell.d.ts.map +1 -1
  64. package/lib/browser/shell/application-shell.js +14 -11
  65. package/lib/browser/shell/application-shell.js.map +1 -1
  66. package/lib/browser/shell/sidebar-bottom-menu-widget.d.ts.map +1 -1
  67. package/lib/browser/shell/sidebar-bottom-menu-widget.js +1 -0
  68. package/lib/browser/shell/sidebar-bottom-menu-widget.js.map +1 -1
  69. package/lib/browser/shell/sidebar-menu-widget.d.ts +10 -0
  70. package/lib/browser/shell/sidebar-menu-widget.d.ts.map +1 -1
  71. package/lib/browser/shell/sidebar-menu-widget.js +26 -1
  72. package/lib/browser/shell/sidebar-menu-widget.js.map +1 -1
  73. package/lib/browser/shell/tab-bar-toolbar.js +1 -1
  74. package/lib/browser/shell/tab-bar-toolbar.js.map +1 -1
  75. package/lib/browser/tree/tree-view-welcome-widget.js +1 -1
  76. package/lib/browser/tree/tree-view-welcome-widget.js.map +1 -1
  77. package/lib/browser/tree/tree-widget-selection.d.ts +1 -1
  78. package/lib/browser/tree/tree-widget-selection.d.ts.map +1 -1
  79. package/lib/browser/window/default-window-service.d.ts.map +1 -1
  80. package/lib/browser/window/default-window-service.js +1 -0
  81. package/lib/browser/window/default-window-service.js.map +1 -1
  82. package/lib/common/command.d.ts +7 -0
  83. package/lib/common/command.d.ts.map +1 -1
  84. package/lib/common/command.js +15 -0
  85. package/lib/common/command.js.map +1 -1
  86. package/lib/common/json-schema.d.ts +1 -0
  87. package/lib/common/json-schema.d.ts.map +1 -1
  88. package/lib/common/keybinding.d.ts +14 -1
  89. package/lib/common/keybinding.d.ts.map +1 -1
  90. package/lib/common/keybinding.js +14 -2
  91. package/lib/common/keybinding.js.map +1 -1
  92. package/lib/common/path.d.ts +10 -0
  93. package/lib/common/path.d.ts.map +1 -1
  94. package/lib/common/path.js +23 -0
  95. package/lib/common/path.js.map +1 -1
  96. package/lib/common/path.spec.js +10 -0
  97. package/lib/common/path.spec.js.map +1 -1
  98. package/lib/common/uri.d.ts +4 -0
  99. package/lib/common/uri.d.ts.map +1 -1
  100. package/lib/common/uri.js +9 -0
  101. package/lib/common/uri.js.map +1 -1
  102. package/lib/common/uri.spec.js +11 -0
  103. package/lib/common/uri.spec.js.map +1 -1
  104. package/lib/electron-browser/keyboard/electron-keyboard-layout-change-notifier.js +1 -1
  105. package/lib/electron-browser/keyboard/electron-keyboard-layout-change-notifier.js.map +1 -1
  106. package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts +1 -1
  107. package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts.map +1 -1
  108. package/lib/electron-browser/menu/electron-context-menu-renderer.js +4 -2
  109. package/lib/electron-browser/menu/electron-context-menu-renderer.js.map +1 -1
  110. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +1 -1
  111. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
  112. package/lib/electron-browser/menu/electron-main-menu-factory.js +20 -16
  113. package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
  114. package/lib/electron-browser/menu/electron-menu-contribution.d.ts +1 -1
  115. package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
  116. package/lib/electron-browser/menu/electron-menu-contribution.js +9 -8
  117. package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
  118. package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts.map +1 -1
  119. package/lib/electron-browser/messaging/electron-ipc-connection-provider.js +1 -1
  120. package/lib/electron-browser/messaging/electron-ipc-connection-provider.js.map +1 -1
  121. package/lib/electron-browser/token/electron-token-frontend-module.js +2 -2
  122. package/lib/electron-browser/token/electron-token-frontend-module.js.map +1 -1
  123. package/lib/electron-browser/window/electron-window-service.d.ts.map +1 -1
  124. package/lib/electron-browser/window/electron-window-service.js +3 -2
  125. package/lib/electron-browser/window/electron-window-service.js.map +1 -1
  126. package/lib/electron-main/electron-main-application.d.ts +4 -2
  127. package/lib/electron-main/electron-main-application.d.ts.map +1 -1
  128. package/lib/electron-main/electron-main-application.js +31 -8
  129. package/lib/electron-main/electron-main-application.js.map +1 -1
  130. package/lib/electron-main/electron-main-window-service-impl.js +1 -1
  131. package/lib/electron-main/electron-main-window-service-impl.js.map +1 -1
  132. package/lib/electron-main/electron-native-keymap.d.ts.map +1 -1
  133. package/lib/electron-main/electron-native-keymap.js +2 -2
  134. package/lib/electron-main/electron-native-keymap.js.map +1 -1
  135. package/lib/electron-main/electron-security-token-service.js +1 -1
  136. package/lib/electron-main/electron-security-token-service.js.map +1 -1
  137. package/lib/electron-main/messaging/electron-messaging-contribution.d.ts +1 -1
  138. package/lib/electron-main/messaging/electron-messaging-contribution.d.ts.map +1 -1
  139. package/lib/electron-main/messaging/electron-messaging-contribution.js +1 -1
  140. package/lib/electron-main/messaging/electron-messaging-contribution.js.map +1 -1
  141. package/lib/electron-node/keyboard/electron-keyboard-layout-provider.js +1 -1
  142. package/lib/electron-node/keyboard/electron-keyboard-layout-provider.js.map +1 -1
  143. package/package.json +50 -41
  144. package/shared/@phosphor/{algorithm.d.ts → algorithm/index.d.ts} +0 -0
  145. package/shared/@phosphor/{algorithm.js → algorithm/index.js} +0 -0
  146. package/shared/@phosphor/{commands.d.ts → commands/index.d.ts} +0 -0
  147. package/shared/@phosphor/{commands.js → commands/index.js} +0 -0
  148. package/shared/@phosphor/{coreutils.d.ts → coreutils/index.d.ts} +0 -0
  149. package/shared/@phosphor/{coreutils.js → coreutils/index.js} +0 -0
  150. package/shared/@phosphor/{domutils.d.ts → domutils/index.d.ts} +0 -0
  151. package/shared/@phosphor/{domutils.js → domutils/index.js} +0 -0
  152. package/shared/@phosphor/{dragdrop.d.ts → dragdrop/index.d.ts} +0 -0
  153. package/shared/@phosphor/{dragdrop.js → dragdrop/index.js} +0 -0
  154. package/shared/@phosphor/{messaging.d.ts → messaging/index.d.ts} +0 -0
  155. package/shared/@phosphor/{messaging.js → messaging/index.js} +0 -0
  156. package/shared/@phosphor/{properties.d.ts → properties/index.d.ts} +0 -0
  157. package/shared/@phosphor/{properties.js → properties/index.js} +0 -0
  158. package/shared/@phosphor/{signaling.d.ts → signaling/index.d.ts} +0 -0
  159. package/shared/@phosphor/{signaling.js → signaling/index.js} +0 -0
  160. package/shared/@phosphor/{virtualdom.d.ts → virtualdom/index.d.ts} +0 -0
  161. package/shared/@phosphor/{virtualdom.js → virtualdom/index.js} +0 -0
  162. package/shared/@phosphor/{widgets.d.ts → widgets/index.d.ts} +0 -0
  163. package/shared/@phosphor/{widgets.js → widgets/index.js} +0 -0
  164. package/shared/@theia/application-package/lib/{api.d.ts → api/index.d.ts} +0 -0
  165. package/shared/@theia/application-package/lib/{api.js → api/index.js} +0 -0
  166. package/shared/@theia/application-package/lib/{environment.d.ts → environment/index.d.ts} +0 -0
  167. package/shared/@theia/application-package/lib/{environment.js → environment/index.js} +0 -0
  168. package/shared/ajv/index.d.ts +2 -0
  169. package/shared/ajv/index.js +1 -0
  170. package/shared/{dompurify.d.ts → dompurify/index.d.ts} +0 -0
  171. package/shared/{dompurify.js → dompurify/index.js} +0 -0
  172. package/shared/{express.d.ts → express/index.d.ts} +0 -0
  173. package/shared/{express.js → express/index.js} +0 -0
  174. package/shared/{fs-extra.d.ts → fs-extra/index.d.ts} +0 -0
  175. package/shared/{fs-extra.js → fs-extra/index.js} +0 -0
  176. package/shared/{fuzzy.d.ts → fuzzy/index.d.ts} +0 -0
  177. package/shared/{fuzzy.js → fuzzy/index.js} +0 -0
  178. package/shared/{inversify.d.ts → inversify/index.d.ts} +0 -0
  179. package/shared/{inversify.js → inversify/index.js} +0 -0
  180. package/shared/{lodash.debounce.d.ts → lodash.debounce/index.d.ts} +0 -0
  181. package/shared/{lodash.debounce.js → lodash.debounce/index.js} +0 -0
  182. package/shared/{lodash.throttle.d.ts → lodash.throttle/index.d.ts} +0 -0
  183. package/shared/{lodash.throttle.js → lodash.throttle/index.js} +0 -0
  184. package/shared/markdown-it/index.d.ts +2 -0
  185. package/shared/markdown-it/index.js +1 -0
  186. package/shared/markdown-it.d.ts +2 -0
  187. package/shared/markdown-it.js +1 -0
  188. package/shared/{nsfw.d.ts → nsfw/index.d.ts} +0 -0
  189. package/shared/{nsfw.js → nsfw/index.js} +0 -0
  190. package/shared/{react.d.ts → react/index.d.ts} +0 -0
  191. package/shared/{react.js → react/index.js} +0 -0
  192. package/shared/{react-dom.d.ts → react-dom/index.d.ts} +0 -0
  193. package/shared/{react-dom.js → react-dom/index.js} +0 -0
  194. package/shared/{react-virtualized.d.ts → react-virtualized/index.d.ts} +0 -0
  195. package/shared/{react-virtualized.js → react-virtualized/index.js} +0 -0
  196. package/shared/{vscode-languageserver-protocol.d.ts → vscode-languageserver-protocol/index.d.ts} +0 -0
  197. package/shared/{vscode-languageserver-protocol.js → vscode-languageserver-protocol/index.js} +0 -0
  198. package/shared/vscode-languageserver-types/index.d.ts +1 -0
  199. package/shared/vscode-languageserver-types/index.js +1 -0
  200. package/shared/{vscode-uri.d.ts → vscode-uri/index.d.ts} +0 -0
  201. package/shared/{vscode-uri.js → vscode-uri/index.js} +0 -0
  202. package/shared/{vscode-ws-jsonrpc.d.ts → vscode-ws-jsonrpc/index.d.ts} +0 -0
  203. package/shared/{vscode-ws-jsonrpc.js → vscode-ws-jsonrpc/index.js} +0 -0
  204. package/shared/{ws.d.ts → ws/index.d.ts} +0 -0
  205. package/shared/{ws.js → ws/index.js} +0 -0
  206. package/shared/{yargs.d.ts → yargs/index.d.ts} +0 -0
  207. package/shared/{yargs.js → yargs/index.js} +0 -0
  208. package/src/browser/common-frontend-contribution.ts +1 -1
  209. package/src/browser/context-key-service.ts +60 -2
  210. package/src/browser/context-menu-renderer.ts +15 -5
  211. package/src/browser/dialogs.ts +6 -2
  212. package/src/browser/external-uri-service.ts +31 -16
  213. package/src/browser/frontend-application-module.ts +2 -2
  214. package/src/browser/frontend-application.ts +6 -0
  215. package/src/browser/index.ts +0 -1
  216. package/src/browser/keybinding.spec.ts +2 -2
  217. package/src/browser/keybinding.ts +7 -4
  218. package/src/browser/navigatable-types.ts +5 -0
  219. package/src/browser/preferences/preference-contribution.ts +3 -3
  220. package/src/browser/shell/application-shell.ts +13 -10
  221. package/src/browser/shell/sidebar-bottom-menu-widget.tsx +1 -0
  222. package/src/browser/shell/sidebar-menu-widget.tsx +34 -1
  223. package/src/browser/tree/tree-widget-selection.ts +1 -1
  224. package/src/browser/window/default-window-service.ts +1 -0
  225. package/src/common/command.ts +18 -0
  226. package/src/common/json-schema.ts +1 -0
  227. package/src/common/keybinding.ts +22 -2
  228. package/src/common/path.spec.ts +12 -0
  229. package/src/common/path.ts +24 -0
  230. package/src/common/uri.spec.ts +13 -0
  231. package/src/common/uri.ts +10 -0
  232. package/src/electron-browser/keyboard/electron-keyboard-layout-change-notifier.ts +1 -1
  233. package/src/electron-browser/menu/electron-context-menu-renderer.ts +4 -2
  234. package/src/electron-browser/menu/electron-main-menu-factory.ts +23 -20
  235. package/src/electron-browser/menu/electron-menu-contribution.ts +9 -8
  236. package/src/electron-browser/messaging/electron-ipc-connection-provider.ts +1 -1
  237. package/src/electron-browser/token/electron-token-frontend-module.ts +2 -2
  238. package/src/electron-browser/window/electron-window-service.ts +3 -2
  239. package/src/electron-main/electron-main-application.ts +33 -9
  240. package/src/electron-main/electron-main-window-service-impl.ts +1 -1
  241. package/src/electron-main/electron-native-keymap.ts +2 -2
  242. package/src/electron-main/electron-security-token-service.ts +1 -1
  243. package/src/electron-main/messaging/electron-messaging-contribution.ts +1 -1
  244. package/src/electron-node/keyboard/electron-keyboard-layout-provider.ts +1 -1
  245. package/lib/browser/markdown-renderer.d.ts +0 -33
  246. package/lib/browser/markdown-renderer.d.ts.map +0 -1
  247. package/lib/browser/markdown-renderer.js +0 -72
  248. package/lib/browser/markdown-renderer.js.map +0 -1
  249. package/lib/browser/markdown-renderer.spec.d.ts +0 -17
  250. package/lib/browser/markdown-renderer.spec.d.ts.map +0 -1
  251. package/lib/browser/markdown-renderer.spec.js +0 -71
  252. package/lib/browser/markdown-renderer.spec.js.map +0 -1
  253. package/shared/electron.d.ts +0 -2
  254. package/shared/electron.js +0 -1
  255. package/shared/index.js +0 -111
  256. package/src/browser/markdown-renderer.spec.ts +0 -78
  257. package/src/browser/markdown-renderer.ts +0 -76
package/src/common/uri.ts CHANGED
@@ -78,6 +78,16 @@ export default class URI {
78
78
  return this.withPath(this.path.join(path.toString()));
79
79
  }
80
80
 
81
+ /**
82
+ * @returns a new, absolute URI if one can be computed from the path segments passed in.
83
+ */
84
+ resolveToAbsolute(...pathSegments: Array<string | Path>): URI | undefined {
85
+ const absolutePath = this.path.resolve(...pathSegments.map(path => path.toString()));
86
+ if (absolutePath) {
87
+ return this.withPath(absolutePath);
88
+ }
89
+ }
90
+
81
91
  /**
82
92
  * return a new URI replacing the current with the given scheme
83
93
  */
@@ -14,8 +14,8 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
+ import { ipcRenderer } from '@theia/electron/shared/electron';
17
18
  import { postConstruct, injectable } from 'inversify';
18
- import { ipcRenderer } from '../../../shared/electron';
19
19
  import { KeyboardLayoutChangeNotifier, NativeKeyboardLayout } from '../../common/keyboard/keyboard-layout-provider';
20
20
  import { Emitter, Event } from '../../common/event';
21
21
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  /* eslint-disable @typescript-eslint/no-explicit-any */
18
18
 
19
- import * as electron from '../../../shared/electron';
19
+ import * as electron from '../../../electron-shared/electron';
20
20
  import { inject, injectable, postConstruct } from 'inversify';
21
21
  import {
22
22
  ContextMenuRenderer, RenderContextMenuOptions, ContextMenuAccess, FrontendApplicationContribution, CommonCommands, coordinateFromAnchor, PreferenceService
@@ -105,8 +105,10 @@ export class ElectronContextMenuRenderer extends BrowserContextMenuRenderer {
105
105
  const menu = this.electronMenuFactory.createElectronContextMenu(menuPath, args);
106
106
  const { x, y } = coordinateFromAnchor(anchor);
107
107
  const zoom = electron.webFrame.getZoomFactor();
108
+ // TODO: Remove the offset once Electron fixes https://github.com/electron/electron/issues/31641
109
+ const offset = process.platform === 'win32' ? 0 : 2;
108
110
  // x and y values must be Ints or else there is a conversion error
109
- menu.popup({ x: Math.round(x * zoom), y: Math.round(y * zoom) });
111
+ menu.popup({ x: Math.round(x * zoom) + offset, y: Math.round(y * zoom) + offset });
110
112
  // native context menu stops the event loop, so there is no keyboard events
111
113
  this.context.resetAltPressed();
112
114
  if (onHide) {
@@ -16,7 +16,7 @@
16
16
 
17
17
  /* eslint-disable @typescript-eslint/no-explicit-any */
18
18
 
19
- import * as electron from '../../../shared/electron';
19
+ import * as electronRemote from '../../../electron-shared/@electron/remote';
20
20
  import { inject, injectable } from 'inversify';
21
21
  import {
22
22
  CommandRegistry, isOSX, ActionMenuNode, CompositeMenuNode,
@@ -56,7 +56,7 @@ export type ElectronMenuItemRole = ('undo' | 'redo' | 'cut' | 'copy' | 'paste' |
56
56
  @injectable()
57
57
  export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
58
58
 
59
- protected _menu: Electron.Menu | undefined;
59
+ protected _menu?: Electron.Menu;
60
60
  protected _toggledCommands: Set<string> = new Set();
61
61
 
62
62
  constructor(
@@ -73,9 +73,12 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
73
73
  }
74
74
  if (this._menu) {
75
75
  for (const item of this._toggledCommands) {
76
- this._menu.getMenuItemById(item).checked = this.commandRegistry.isToggled(item);
76
+ const menuItem = this._menu.getMenuItemById(item);
77
+ if (menuItem) {
78
+ menuItem.checked = this.commandRegistry.isToggled(item);
79
+ }
77
80
  }
78
- electron.remote.getCurrentWindow().setMenu(this._menu);
81
+ electronRemote.getCurrentWindow().setMenu(this._menu);
79
82
  }
80
83
  }, 10)
81
84
  );
@@ -88,10 +91,10 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
88
91
  await this.preferencesService.ready;
89
92
  if (isOSX) {
90
93
  const createdMenuBar = this.createElectronMenuBar();
91
- electron.remote.Menu.setApplicationMenu(createdMenuBar);
94
+ electronRemote.Menu.setApplicationMenu(createdMenuBar);
92
95
  } else if (this.preferencesService.get('window.titleBarStyle') === 'native') {
93
96
  const createdMenuBar = this.createElectronMenuBar();
94
- electron.remote.getCurrentWindow().setMenu(createdMenuBar);
97
+ electronRemote.getCurrentWindow().setMenu(createdMenuBar);
95
98
  }
96
99
  }
97
100
 
@@ -104,7 +107,10 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
104
107
  if (isOSX) {
105
108
  template.unshift(this.createOSXMenu());
106
109
  }
107
- const menu = electron.remote.Menu.buildFromTemplate(template);
110
+ const menu = electronRemote.Menu.buildFromTemplate(template);
111
+ if (!menu) {
112
+ throw new Error('menu is null');
113
+ }
108
114
  this._menu = menu;
109
115
  return this._menu;
110
116
  }
@@ -116,7 +122,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
116
122
  createElectronContextMenu(menuPath: MenuPath, args?: any[]): Electron.Menu {
117
123
  const menuModel = this.menuProvider.getMenu(menuPath);
118
124
  const template = this.fillMenuTemplate([], menuModel, args, { showDisabled: false });
119
- return electron.remote.Menu.buildFromTemplate(template);
125
+ return electronRemote.Menu.buildFromTemplate(template);
120
126
  }
121
127
 
122
128
  protected fillMenuTemplate(items: Electron.MenuItemConstructorOptions[],
@@ -184,15 +190,9 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
184
190
 
185
191
  const bindings = this.keybindingRegistry.getKeybindingsForCommand(commandId);
186
192
 
187
- let accelerator;
193
+ const accelerator = bindings[0] && this.acceleratorFor(bindings[0]);
188
194
 
189
- /* Only consider the first keybinding. */
190
- if (bindings.length > 0) {
191
- const binding = bindings[0];
192
- accelerator = this.acceleratorFor(binding);
193
- }
194
-
195
- const menuItem = {
195
+ const menuItem: Electron.MenuItemConstructorOptions = {
196
196
  id: node.id,
197
197
  label: node.label,
198
198
  type: this.commandRegistry.getToggledHandler(commandId, ...args) ? 'checkbox' : 'normal',
@@ -201,7 +201,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
201
201
  visible: true,
202
202
  accelerator,
203
203
  click: () => this.execute(commandId, args)
204
- } as Electron.MenuItemConstructorOptions;
204
+ };
205
205
 
206
206
  if (isOSX) {
207
207
  const role = this.roleFor(node.id);
@@ -241,7 +241,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
241
241
  }
242
242
 
243
243
  const keyCode = bindingKeySequence[0];
244
- return this.keybindingRegistry.acceleratorForKeyCode(keyCode, '+');
244
+ return this.keybindingRegistry.acceleratorForKeyCode(keyCode, '+', true);
245
245
  }
246
246
 
247
247
  protected roleFor(id: string): ElectronMenuItemRole | undefined {
@@ -279,8 +279,11 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
279
279
  if (this.commandRegistry.isEnabled(command, ...args)) {
280
280
  await this.commandRegistry.executeCommand(command, ...args);
281
281
  if (this._menu && this.commandRegistry.isVisible(command, ...args)) {
282
- this._menu.getMenuItemById(command).checked = this.commandRegistry.isToggled(command, ...args);
283
- electron.remote.getCurrentWindow().setMenu(this._menu);
282
+ const item = this._menu.getMenuItemById(command);
283
+ if (item) {
284
+ item.checked = this.commandRegistry.isToggled(command, ...args);
285
+ electronRemote.getCurrentWindow().setMenu(this._menu);
286
+ }
284
287
  }
285
288
  }
286
289
  } catch {
@@ -14,7 +14,8 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import * as electron from '../../../shared/electron';
17
+ import * as electron from '../../../electron-shared/electron';
18
+ import * as electronRemote from '../../../electron-shared/@electron/remote';
18
19
  import { inject, injectable } from 'inversify';
19
20
  import {
20
21
  Command, CommandContribution, CommandRegistry,
@@ -104,7 +105,7 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
104
105
  // OSX: Recreate the menus when changing windows.
105
106
  // OSX only has one menu bar for all windows, so we need to swap
106
107
  // between them as the user switches windows.
107
- electron.remote.getCurrentWindow().on('focus', () => this.setMenu(app));
108
+ electronRemote.getCurrentWindow().on('focus', () => this.setMenu(app));
108
109
  }
109
110
  // Make sure the application menu is complete, once the frontend application is ready.
110
111
  // https://github.com/theia-ide/theia/issues/5100
@@ -136,11 +137,11 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
136
137
  electron.ipcRenderer.send(RequestTitleBarStyle);
137
138
  this.preferenceService.ready.then(() => {
138
139
  this.setMenu(app);
139
- electron.remote.getCurrentWindow().setMenuBarVisibility(['classic', 'visible'].includes(this.preferenceService.get('window.menuBarVisibility', 'classic')));
140
+ electronRemote.getCurrentWindow().setMenuBarVisibility(['classic', 'visible'].includes(this.preferenceService.get('window.menuBarVisibility', 'classic')));
140
141
  });
141
142
  this.preferenceService.onPreferenceChanged(change => {
142
143
  if (change.preferenceName === 'window.titleBarStyle') {
143
- if (this.titleBarStyleChangeFlag && this.titleBarStyle !== change.newValue && electron.remote.getCurrentWindow().isFocused()) {
144
+ if (this.titleBarStyleChangeFlag && this.titleBarStyle !== change.newValue && electronRemote.getCurrentWindow().isFocused()) {
144
145
  electron.ipcRenderer.send(TitleBarStyleChanged, change.newValue);
145
146
  this.handleRequiredRestart();
146
147
  }
@@ -177,9 +178,9 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
177
178
  }
178
179
 
179
180
  protected setMenu(app: FrontendApplication, electronMenu: electron.Menu | null = this.factory.createElectronMenuBar(),
180
- electronWindow: electron.BrowserWindow = electron.remote.getCurrentWindow()): void {
181
+ electronWindow: electron.BrowserWindow = electronRemote.getCurrentWindow()): void {
181
182
  if (isOSX) {
182
- electron.remote.Menu.setApplicationMenu(electronMenu);
183
+ electronRemote.Menu.setApplicationMenu(electronMenu);
183
184
  } else {
184
185
  this.hideTopPanel(app);
185
186
  if (this.titleBarStyle === 'custom' && !this.menuBar) {
@@ -252,11 +253,11 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
252
253
 
253
254
  registerCommands(registry: CommandRegistry): void {
254
255
 
255
- const currentWindow = electron.remote.getCurrentWindow();
256
+ const currentWindow = electronRemote.getCurrentWindow();
256
257
 
257
258
  registry.registerCommand(ElectronCommands.TOGGLE_DEVELOPER_TOOLS, {
258
259
  execute: () => {
259
- const webContent = electron.remote.getCurrentWebContents();
260
+ const webContent = electronRemote.getCurrentWebContents();
260
261
  if (!webContent.isDevToolsOpened()) {
261
262
  webContent.openDevTools();
262
263
  } else {
@@ -14,8 +14,8 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
+ import { Event as ElectronEvent, ipcRenderer } from '@theia/electron/shared/electron';
17
18
  import { injectable, interfaces } from 'inversify';
18
- import { Event as ElectronEvent, ipcRenderer } from '../../../shared/electron';
19
19
  import { JsonRpcProxy } from '../../common/messaging';
20
20
  import { WebSocketChannel } from '../../common/messaging/web-socket-channel';
21
21
  import { AbstractConnectionProvider } from '../../common/messaging/abstract-connection-provider';
@@ -14,10 +14,10 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import * as electron from '../../../shared/electron';
17
+ import * as electronRemote from '../../../electron-shared/@electron/remote';
18
18
  import { ContainerModule } from 'inversify';
19
19
  import { ElectronSecurityToken } from '../../electron-common/electron-token';
20
20
 
21
21
  export default new ContainerModule(bind => {
22
- bind(ElectronSecurityToken).toConstantValue(electron.remote.getGlobal(ElectronSecurityToken));
22
+ bind(ElectronSecurityToken).toConstantValue(electronRemote.getGlobal(ElectronSecurityToken));
23
23
  });
@@ -14,8 +14,9 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
+ import * as electronRemote from '../../../electron-shared/@electron/remote';
17
18
  import { injectable, inject, postConstruct } from 'inversify';
18
- import * as electron from '../../../shared/electron';
19
+ import * as electron from '../../../electron-shared/electron';
19
20
  import { NewWindowOptions } from '../../common/window';
20
21
  import { DefaultWindowService } from '../../browser/window/default-window-service';
21
22
  import { ElectronMainWindowService } from '../../electron-common/electron-main-window-service';
@@ -85,7 +86,7 @@ export class ElectronWindowService extends DefaultWindowService {
85
86
  */
86
87
  protected updateWindowZoomLevel(): void {
87
88
  const preferredZoomLevel = this.electronWindowPreferences['window.zoomLevel'];
88
- const webContents = electron.remote.getCurrentWindow().webContents;
89
+ const webContents = electronRemote.getCurrentWindow().webContents;
89
90
  if (webContents.getZoomLevel() !== preferredZoomLevel) {
90
91
  webContents.setZoomLevel(preferredZoomLevel);
91
92
  }
@@ -15,7 +15,8 @@
15
15
  ********************************************************************************/
16
16
 
17
17
  import { inject, injectable, named } from 'inversify';
18
- import { screen, globalShortcut, ipcMain, app, BrowserWindow, BrowserWindowConstructorOptions, Event as ElectronEvent } from '../../shared/electron';
18
+ import * as electronRemoteMain from '../../electron-shared/@electron/remote/main';
19
+ import { screen, globalShortcut, ipcMain, app, BrowserWindow, BrowserWindowConstructorOptions, Event as ElectronEvent } from '../../electron-shared/electron';
19
20
  import * as path from 'path';
20
21
  import { Argv } from 'yargs';
21
22
  import { AddressInfo } from 'net';
@@ -190,7 +191,9 @@ export class ElectronMainApplication {
190
191
  @inject(ElectronSecurityToken)
191
192
  protected readonly electronSecurityToken: ElectronSecurityToken;
192
193
 
193
- protected readonly electronStore = new Storage();
194
+ protected readonly electronStore = new Storage<{
195
+ windowstate?: TheiaBrowserWindowOptions
196
+ }>();
194
197
 
195
198
  protected readonly _backendPort = new Deferred<number>();
196
199
  readonly backendPort = this._backendPort.promise;
@@ -266,6 +269,7 @@ export class ElectronMainApplication {
266
269
  this.attachGlobalShortcuts(electronWindow);
267
270
  this.restoreMaximizedState(electronWindow, options);
268
271
  this.attachCloseListeners(electronWindow, options);
272
+ electronRemoteMain.enable(electronWindow.webContents);
269
273
  return electronWindow;
270
274
  }
271
275
 
@@ -304,6 +308,8 @@ export class ElectronMainApplication {
304
308
  minWidth: 200,
305
309
  minHeight: 120,
306
310
  webPreferences: {
311
+ // `global` is undefined when `true`.
312
+ contextIsolation: false,
307
313
  // https://github.com/eclipse-theia/theia/issues/2018
308
314
  nodeIntegration: true,
309
315
  // Setting the following option to `true` causes some features to break, somehow.
@@ -487,7 +493,14 @@ export class ElectronMainApplication {
487
493
 
488
494
  protected async handleStopRequest(electronWindow: BrowserWindow, onSafeCallback: () => unknown, reason: StopReason): Promise<void> {
489
495
  // Only confirm close to windows that have loaded our front end.
490
- const safeToClose = !electronWindow.webContents.getURL().includes(this.globals.THEIA_FRONTEND_HTML_PATH) || await this.checkSafeToStop(electronWindow, reason);
496
+ let currentUrl = electronWindow.webContents.getURL();
497
+ let frontendUri = this.globals.THEIA_FRONTEND_HTML_PATH;
498
+ // Since our resolved frontend HTML path might contain backward slashes on Windows, we normalize everything first.
499
+ if (isWindows) {
500
+ currentUrl = currentUrl.replace(/\\/g, '/');
501
+ frontendUri = frontendUri.replace(/\\/g, '/');
502
+ }
503
+ const safeToClose = !currentUrl.includes(frontendUri) || await this.checkSafeToStop(electronWindow, reason);
491
504
  if (safeToClose) {
492
505
  onSafeCallback();
493
506
  }
@@ -582,7 +595,12 @@ export class ElectronMainApplication {
582
595
 
583
596
  ipcMain.on(TitleBarStyleChanged, ({ sender }, titleBarStyle: string) => {
584
597
  this.useNativeWindowFrame = titleBarStyle === 'native';
585
- this.saveWindowState(BrowserWindow.fromId(sender.id));
598
+ const browserWindow = BrowserWindow.fromId(sender.id);
599
+ if (browserWindow) {
600
+ this.saveWindowState(browserWindow);
601
+ } else {
602
+ console.warn(`no BrowserWindow with id: ${sender.id}`);
603
+ }
586
604
  });
587
605
 
588
606
  ipcMain.on(Restart, ({ sender }) => {
@@ -619,8 +637,11 @@ export class ElectronMainApplication {
619
637
 
620
638
  protected restart(id: number): void {
621
639
  this.restarting = true;
622
- const window = BrowserWindow.fromId(id);
623
- window.on('closed', async () => {
640
+ const browserWindow = BrowserWindow.fromId(id);
641
+ if (!browserWindow) {
642
+ throw new Error(`no BrowserWindow with id: ${id}`);
643
+ }
644
+ browserWindow.on('closed', async () => {
624
645
  await this.launch({
625
646
  secondInstance: false,
626
647
  argv: this.processArgv.getProcessArgvWithoutBin(process.argv),
@@ -628,12 +649,15 @@ export class ElectronMainApplication {
628
649
  });
629
650
  this.restarting = false;
630
651
  });
631
- this.handleStopRequest(window, () => this.doCloseWindow(window), StopReason.Restart);
652
+ this.handleStopRequest(browserWindow, () => this.doCloseWindow(browserWindow), StopReason.Restart);
632
653
  }
633
654
 
634
655
  protected async handleReload(event: Electron.IpcMainEvent): Promise<void> {
635
- const window = BrowserWindow.fromId(event.sender.id);
636
- this.reload(window);
656
+ const browserWindow = BrowserWindow.fromId(event.sender.id);
657
+ if (!browserWindow) {
658
+ throw new Error(`no BrowserWindow with id: ${event.sender.id}`);
659
+ }
660
+ this.reload(browserWindow);
637
661
  }
638
662
 
639
663
  protected reload(electronWindow: BrowserWindow): void {
@@ -14,7 +14,7 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { shell } from '../../shared/electron';
17
+ import { shell } from '@theia/electron/shared/electron';
18
18
  import { injectable, inject } from 'inversify';
19
19
  import { ElectronMainWindowService } from '../electron-common/electron-main-window-service';
20
20
  import { ElectronMainApplication } from './electron-main-application';
@@ -14,10 +14,10 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { webContents } from '../../shared/electron';
17
+ import { webContents } from '@theia/electron/shared/electron';
18
+ import * as nativeKeymap from '@theia/electron/shared/native-keymap';
18
19
  import { injectable } from 'inversify';
19
20
  import { ElectronMainApplication, ElectronMainApplicationContribution } from './electron-main-application';
20
- import * as nativeKeymap from '@theia/electron/native-keymap';
21
21
 
22
22
  @injectable()
23
23
  export class ElectronNativeKeymap implements ElectronMainApplicationContribution {
@@ -14,7 +14,7 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { session } from '../../shared/electron';
17
+ import { session } from '@theia/electron/shared/electron';
18
18
  import { inject, injectable } from 'inversify';
19
19
  import { ElectronSecurityToken } from '../electron-common/electron-token';
20
20
 
@@ -14,7 +14,7 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { IpcMainEvent, ipcMain, WebContents } from '../../../shared/electron';
17
+ import { IpcMainEvent, ipcMain, WebContents } from '@theia/electron/shared/electron';
18
18
  import { inject, injectable, named, postConstruct } from 'inversify';
19
19
  import { MessageConnection } from 'vscode-ws-jsonrpc';
20
20
  import { createWebSocketConnection } from 'vscode-ws-jsonrpc/lib/socket/connection';
@@ -14,7 +14,7 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import * as nativeKeymap from '@theia/electron/native-keymap';
17
+ import * as nativeKeymap from '@theia/electron/shared/native-keymap';
18
18
  import { injectable } from 'inversify';
19
19
  import { KeyboardLayoutProvider, NativeKeyboardLayout } from '../../common/keyboard/keyboard-layout-provider';
20
20
 
@@ -1,33 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (C) 2021 TypeFox and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
- import * as markdownit from 'markdown-it';
17
- export declare class MarkdownRenderer {
18
- protected engine: markdownit;
19
- protected callbacks: Map<string, ((element: Element) => Element | void)[]>;
20
- constructor(engine?: markdownit);
21
- /**
22
- * Adds a modification callback that is applied to every element with the specified tag after rendering to HTML.
23
- *
24
- * @param tag The tag that this modification applies to.
25
- * @param callback The modification to apply on every selected rendered element. Can either modify the element in place or return a new element.
26
- */
27
- modify<K extends keyof HTMLElementTagNameMap>(tag: K, callback: (element: HTMLElementTagNameMap[K]) => Element | void): MarkdownRenderer;
28
- render(markdown: string): HTMLElement;
29
- renderInline(markdown: string): HTMLElement;
30
- protected renderInternal(renderedHtml: string): HTMLElement;
31
- protected sanitizeHtml(html: string): HTMLElement;
32
- }
33
- //# sourceMappingURL=markdown-renderer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown-renderer.d.ts","sourceRoot":"","sources":["../../src/browser/markdown-renderer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAGlF,OAAO,KAAK,UAAU,MAAM,aAAa,CAAC;AAE1C,qBAAa,gBAAgB;IAEzB,SAAS,CAAC,MAAM,EAAE,UAAU,CAAC;IAC7B,SAAS,CAAC,SAAS,yBAA8B,OAAO,KAAK,OAAO,GAAG,IAAI,KAAO;gBAEtE,MAAM,CAAC,EAAE,UAAU;IAI/B;;;;;OAKG;IACH,MAAM,CAAC,CAAC,SAAS,MAAM,qBAAqB,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,IAAI,GAAG,gBAAgB;IASxI,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW;IAIrC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,WAAW;IAI3C,SAAS,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW;IAmB3D,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW;CAKpD"}
@@ -1,72 +0,0 @@
1
- "use strict";
2
- /********************************************************************************
3
- * Copyright (C) 2021 TypeFox and others.
4
- *
5
- * This program and the accompanying materials are made available under the
6
- * terms of the Eclipse Public License v. 2.0 which is available at
7
- * http://www.eclipse.org/legal/epl-2.0.
8
- *
9
- * This Source Code may also be made available under the following Secondary
10
- * Licenses when the conditions for such availability set forth in the Eclipse
11
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- * with the GNU Classpath Exception which is available at
13
- * https://www.gnu.org/software/classpath/license.html.
14
- *
15
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- ********************************************************************************/
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.MarkdownRenderer = void 0;
19
- const DOMPurify = require("dompurify");
20
- const markdownit = require("markdown-it");
21
- class MarkdownRenderer {
22
- constructor(engine) {
23
- this.callbacks = new Map();
24
- this.engine = engine !== null && engine !== void 0 ? engine : markdownit();
25
- }
26
- /**
27
- * Adds a modification callback that is applied to every element with the specified tag after rendering to HTML.
28
- *
29
- * @param tag The tag that this modification applies to.
30
- * @param callback The modification to apply on every selected rendered element. Can either modify the element in place or return a new element.
31
- */
32
- modify(tag, callback) {
33
- if (this.callbacks.has(tag)) {
34
- this.callbacks.get(tag).push(callback);
35
- }
36
- else {
37
- this.callbacks.set(tag, [callback]);
38
- }
39
- return this;
40
- }
41
- render(markdown) {
42
- return this.renderInternal(this.engine.render(markdown));
43
- }
44
- renderInline(markdown) {
45
- return this.renderInternal(this.engine.renderInline(markdown));
46
- }
47
- renderInternal(renderedHtml) {
48
- const div = this.sanitizeHtml(renderedHtml);
49
- for (const [tag, calls] of this.callbacks) {
50
- for (const callback of calls) {
51
- const elements = Array.from(div.getElementsByTagName(tag));
52
- for (const element of elements) {
53
- const result = callback(element);
54
- if (result) {
55
- const parent = element.parentElement;
56
- if (parent) {
57
- parent.replaceChild(result, element);
58
- }
59
- }
60
- }
61
- }
62
- }
63
- return div;
64
- }
65
- sanitizeHtml(html) {
66
- const div = document.createElement('div');
67
- div.innerHTML = DOMPurify.sanitize(html);
68
- return div;
69
- }
70
- }
71
- exports.MarkdownRenderer = MarkdownRenderer;
72
- //# sourceMappingURL=markdown-renderer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown-renderer.js","sourceRoot":"","sources":["../../src/browser/markdown-renderer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAElF,uCAAuC;AACvC,0CAA0C;AAE1C,MAAa,gBAAgB;IAKzB,YAAY,MAAmB;QAFrB,cAAS,GAAG,IAAI,GAAG,EAAoD,CAAC;QAG9E,IAAI,CAAC,MAAM,GAAG,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,UAAU,EAAE,CAAC;IACzC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAwC,GAAM,EAAE,QAA+D;QACjH,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACzB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC3C;aAAM;YACH,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;SACvC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,QAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,YAAY,CAAC,QAAgB;QACzB,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IACnE,CAAC;IAES,cAAc,CAAC,YAAoB;QACzC,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE;YACvC,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE;gBAC1B,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC3D,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;oBAC5B,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;oBACjC,IAAI,MAAM,EAAE;wBACR,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;wBACrC,IAAI,MAAM,EAAE;4BACR,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;yBACxC;qBACJ;iBACJ;aACJ;SACJ;QACD,OAAO,GAAG,CAAC;IACf,CAAC;IAES,YAAY,CAAC,IAAY;QAC/B,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1C,GAAG,CAAC,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,GAAG,CAAC;IACf,CAAC;CACJ;AAxDD,4CAwDC"}
@@ -1,17 +0,0 @@
1
- /********************************************************************************
2
- * Copyright (C) 2021 TypeFox and others.
3
- *
4
- * This program and the accompanying materials are made available under the
5
- * terms of the Eclipse Public License v. 2.0 which is available at
6
- * http://www.eclipse.org/legal/epl-2.0.
7
- *
8
- * This Source Code may also be made available under the following Secondary
9
- * Licenses when the conditions for such availability set forth in the Eclipse
10
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- * with the GNU Classpath Exception which is available at
12
- * https://www.gnu.org/software/classpath/license.html.
13
- *
14
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
- ********************************************************************************/
16
- export {};
17
- //# sourceMappingURL=markdown-renderer.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"markdown-renderer.spec.d.ts","sourceRoot":"","sources":["../../src/browser/markdown-renderer.spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF"}
@@ -1,71 +0,0 @@
1
- "use strict";
2
- /********************************************************************************
3
- * Copyright (C) 2021 TypeFox and others.
4
- *
5
- * This program and the accompanying materials are made available under the
6
- * terms of the Eclipse Public License v. 2.0 which is available at
7
- * http://www.eclipse.org/legal/epl-2.0.
8
- *
9
- * This Source Code may also be made available under the following Secondary
10
- * Licenses when the conditions for such availability set forth in the Eclipse
11
- * Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- * with the GNU Classpath Exception which is available at
13
- * https://www.gnu.org/software/classpath/license.html.
14
- *
15
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- ********************************************************************************/
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const jsdom_1 = require("../browser/test/jsdom");
19
- let disableJSDOM = jsdom_1.enableJSDOM();
20
- const chai_1 = require("chai");
21
- const markdownit = require("markdown-it");
22
- const markdown_renderer_1 = require("./markdown-renderer");
23
- disableJSDOM();
24
- describe('MarkdownRenderer', () => {
25
- before(() => disableJSDOM = jsdom_1.enableJSDOM());
26
- after(() => disableJSDOM());
27
- it('Should render markdown', () => {
28
- const markdownRenderer = new markdown_renderer_1.MarkdownRenderer();
29
- const result = markdownRenderer.renderInline('[title](link)').innerHTML;
30
- chai_1.expect(result).to.be.equal('<a href="link">title</a>');
31
- });
32
- it('Should accept and use custom engine', () => {
33
- const engine = markdownit();
34
- const originalTextRenderer = engine.renderer.rules.text;
35
- engine.renderer.rules.text = (tokens, idx, options, env, self) => `[${originalTextRenderer(tokens, idx, options, env, self)}]`;
36
- const markdownRenderer = new markdown_renderer_1.MarkdownRenderer(engine);
37
- const result = markdownRenderer.renderInline('text').innerHTML;
38
- chai_1.expect(result).to.be.equal('[text]');
39
- });
40
- it('Should modify rendered markdown in place', () => {
41
- const markdownRenderer = new markdown_renderer_1.MarkdownRenderer().modify('a', a => {
42
- a.href = 'something-else';
43
- });
44
- const result = markdownRenderer.renderInline('[title](link)').innerHTML;
45
- chai_1.expect(result).to.be.equal('<a href="something-else">title</a>');
46
- });
47
- it('Should modify descendants of children', () => {
48
- const markdownRenderer = new markdown_renderer_1.MarkdownRenderer().modify('em', em => {
49
- const strong = document.createElement('strong');
50
- // eslint-disable-next-line no-unsanitized/property
51
- strong.innerHTML = em.innerHTML;
52
- return strong;
53
- });
54
- const result = markdownRenderer.render('**bold *bold and italic***').innerHTML;
55
- chai_1.expect(result).to.be.equal('<p><strong>bold <strong>bold and italic</strong></strong></p>\n');
56
- });
57
- it('Should modify descendants of children after previous modification', () => {
58
- const markdownRenderer = new markdown_renderer_1.MarkdownRenderer().modify('em', em => {
59
- const strong = document.createElement('strong');
60
- // eslint-disable-next-line no-unsanitized/property
61
- strong.innerHTML = em.innerHTML;
62
- return strong;
63
- }).modify('strong', strong => {
64
- const textNode = strong.childNodes.item(0);
65
- textNode.textContent = `changed_${textNode.textContent}`;
66
- });
67
- const result = markdownRenderer.render('**bold *bold and italic***').innerHTML;
68
- chai_1.expect(result).to.be.equal('<p><strong>changed_bold <strong>changed_bold and italic</strong></strong></p>\n');
69
- });
70
- });
71
- //# sourceMappingURL=markdown-renderer.spec.js.map