Skip to content

Commit

Permalink
Merge pull request #43 from hidao80/develop
Browse files Browse the repository at this point in the history
fix: リンクをクリックしたときに、デフォルトブラウザで開く
  • Loading branch information
hidao80 committed Jul 13, 2018
2 parents 5aedf38 + 5551984 commit 930d4ba
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
1. npmをインストール (<https://nodejs.org/ja/>)
1. npmを以下の手順で [npm v6.0.0](https://nodejs.org/ja/) 以上にアップデート
```sh
## for macOS and Linux
## for macOS and Linux
sudo npm i -g npm
## for Windows

## for Windows
npm i -g npm
```
1. リポジトリのインストール
Expand Down
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*jshint esversion:6*/
const electron = require('electron');
const {shell} = require('electron');
let app = electron.app;
let BrowserWindow = electron.BrowserWindow;

Expand All @@ -10,6 +11,11 @@ app.on('ready', () => {
// Electronに表示するhtmlを絶対パスで指定(相対パスだと動かない)
mainWindow.loadURL('file://' + __dirname + '/index.html');

mainWindow.webContents.on('new-window', (event, url) => {
event.preventDefault();
shell.openExternal(url);
});

// ChromiumのDevツールを開く
//mainWindow.webContents.openDevTools();

Expand Down
8 changes: 6 additions & 2 deletions src/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ function rendaring() {
highlight: (str, lang) => {
var filename = '';
if (lang && lang.indexOf(':') > 1) {
var sp = lang.split(':')
var sp = lang.split(':');
lang = sp[0];
filename = sp[1];
}

var header;
if (filename) {
header = "<div class='code-lang'><span class='bold'>" + filename + "</span></div>"
header = "<div class='code-lang'><span class='bold'>" + filename + "</span></div>";
} else {
header = "";
}
Expand All @@ -71,6 +71,10 @@ function rendaring() {
}).enable(['table', 'strikethrough']).use(require('markdown-it-checkbox')) ;
const md = $("#tsumiqiita-editor").value;
$("#preview").innerHTML = it.render(withoutTags(md));

var myDivEl = document.getElementById("preview");
var anchorsInMyDiv = myDivEl.querySelectorAll("a");
anchorsInMyDiv.forEach( s => s.setAttribute( "target", "_blank" ) );
}

function openMarkdownFile(path) {
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tsumiqiita",
"version": "1.6.0",
"version": "1.7.0",
"description": "MarkdownファイルをQiitaに投稿するelectron製デスクトップアプリです。",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit 930d4ba

Please sign in to comment.