Use desktop default to open urls in electron

This commit is contained in:
hanayashiki 2021-05-06 19:08:16 -07:00
parent 89683503f8
commit d835284e5d
3 changed files with 13 additions and 2 deletions

4
src/global.d.ts vendored
View File

@ -5,3 +5,7 @@ declare module 'worker-loader!*' {
export default WebpackWorker; export default WebpackWorker;
} }
declare const electronHelpers: {
openExternal(url): void;
} | undefined;

View File

@ -557,7 +557,14 @@ namespace RichTextProcessor {
const currentContext = url[0] === '#'; const currentContext = url[0] === '#';
insertPart(entity, `<a class="anchor-url" href="${encodeEntities(url)}"${currentContext ? '' : ' target="_blank" rel="noopener noreferrer"'}${masked ? 'onclick="showMaskedAlert(this)"' : ''}>`, '</a>'); const href = (currentContext || typeof electronHelpers === 'undefined')
? encodeEntities(url)
: `javascript:electronHelpers.openExternal('${encodeEntities(url)}');`;
const target = (currentContext || typeof electronHelpers !== 'undefined')
? '' : ' target="_blank" rel="noopener noreferrer"';
insertPart(entity, `<a class="anchor-url" href="${href}"${target}${masked ? 'onclick="showMaskedAlert(this)"' : ''}>`, '</a>');
} }
break; break;

2
src/types.d.ts vendored
View File

@ -82,4 +82,4 @@ export type ConnectionStatusChange = {
isFileNetworker: boolean, isFileNetworker: boolean,
isFileDownload: boolean, isFileDownload: boolean,
isFileUpload: boolean isFileUpload: boolean
}; };