add web-link activation modifier
This commit is contained in:
parent
7d571cfdc2
commit
ffd4eb46e3
8 changed files with 33 additions and 3 deletions
|
|
@ -102,6 +102,7 @@ class TermGroup_ extends React.PureComponent<TermGroupProps> {
|
|||
selectionColor: this.props.selectionColor,
|
||||
quickEdit: this.props.quickEdit,
|
||||
webGLRenderer: this.props.webGLRenderer,
|
||||
webLinksActivationKey: this.props.webLinksActivationKey,
|
||||
macOptionSelectionMode: this.props.macOptionSelectionMode,
|
||||
disableLigatures: this.props.disableLigatures,
|
||||
uid
|
||||
|
|
|
|||
|
|
@ -148,13 +148,27 @@ export default class Term extends React.PureComponent<TermProps> {
|
|||
}
|
||||
Term.reportRenderer(props.uid, useWebGL ? 'WebGL' : 'Canvas');
|
||||
|
||||
const shallActivateWebLink = (event: Record<string, any> | undefined) => {
|
||||
return event && (!props.webLinksActivationKey || event[`${props.webLinksActivationKey}Key`]);
|
||||
};
|
||||
|
||||
this.term.attachCustomKeyEventHandler(this.keyboardHandler);
|
||||
this.term.loadAddon(this.fitAddon);
|
||||
this.term.loadAddon(this.searchAddon);
|
||||
this.term.loadAddon(
|
||||
new WebLinksAddon((event, uri) => {
|
||||
shell.openExternal(uri);
|
||||
})
|
||||
new WebLinksAddon(
|
||||
(event: MouseEvent | undefined, uri: string) => {
|
||||
if (shallActivateWebLink(event)) shell.openExternal(uri);
|
||||
},
|
||||
{
|
||||
// prevent default electron link handling to allow selection, e.g. via double-click
|
||||
willLinkActivate: (event: MouseEvent | undefined) => {
|
||||
event?.preventDefault();
|
||||
return shallActivateWebLink(event);
|
||||
},
|
||||
priority: Date.now()
|
||||
}
|
||||
)
|
||||
);
|
||||
this.term.open(this.termRef);
|
||||
if (useWebGL) {
|
||||
|
|
|
|||
|
|
@ -113,6 +113,7 @@ export default class Terms extends React.Component<TermsProps> {
|
|||
onContextMenu: this.props.onContextMenu,
|
||||
quickEdit: this.props.quickEdit,
|
||||
webGLRenderer: this.props.webGLRenderer,
|
||||
webLinksActivationKey: this.props.webLinksActivationKey,
|
||||
macOptionSelectionMode: this.props.macOptionSelectionMode,
|
||||
disableLigatures: this.props.disableLigatures,
|
||||
parentProps: this.props
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue