Browse Source

Use desktop default to open urls in electron

master
hanayashiki 4 years ago
parent
commit
d835284e5d
  1. 4
      src/global.d.ts
  2. 9
      src/lib/richtextprocessor.ts

4
src/global.d.ts vendored

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

9
src/lib/richtextprocessor.ts

@ -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;

Loading…
Cancel
Save