Browse Source

Merge pull request #18 from hanayashiki/master

Use desktop default to open urls in electron
master
Eduard Kuzmenko 4 years ago committed by GitHub
parent
commit
b766c152e1
  1. 4
      src/global.d.ts
  2. 9
      src/lib/richtextprocessor.ts
  3. 2
      src/types.d.ts

4
src/global.d.ts vendored

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

9
src/lib/richtextprocessor.ts

@ -557,7 +557,14 @@ namespace RichTextProcessor { @@ -557,7 +557,14 @@ namespace RichTextProcessor {
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;

2
src/types.d.ts vendored

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

Loading…
Cancel
Save