Skip to content

Commit

Permalink
fix: Monaco editor links opened in blank window in electron (#4269)
Browse files Browse the repository at this point in the history
* disable ctrl + click open window in electron

* do not use hasOwnProperty

* cast window to any

Co-authored-by: Andy Brown <asbrown002@gmail.com>
  • Loading branch information
zhixzhan and a-b-r-o-w-n committed Sep 25, 2020
1 parent 69dd86d commit 1143ea0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Composer/packages/lib/code-editor/src/BaseEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { Diagnostic } from '@bfc/shared';
import { findErrors, combineSimpleMessage, findWarnings } from '@bfc/indexers';
import { CodeEditorSettings, assignDefined } from '@bfc/shared';

import { isElectron } from './utils';

const defaultOptions = {
scrollBeyondLastLine: false,
wordWrap: 'off',
Expand All @@ -32,6 +34,7 @@ const defaultOptions = {
renderLineHighlight: 'none',
formatOnType: true,
fixedOverflowWidgets: true,
links: isElectron() ? false : true, // disable in electron@8.2.4 before monaco editor can set target '_blank'
};

const styles = {
Expand Down
4 changes: 4 additions & 0 deletions Composer/packages/lib/code-editor/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
export function processSize(size) {
return !/^\d+$/.test(size) ? size : `${size}px`;
}

export function isElectron(): boolean {
return !(window as any).__IS_ELECTRON__;
}

0 comments on commit 1143ea0

Please sign in to comment.