Created
June 3, 2015 15:06
-
-
Save anonymous/c41a2631f07736d1bebb to your computer and use it in GitHub Desktop.
mdpreview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var app = require('app'); | |
var BrowserWindow = require('browser-window'); | |
var Menu = require('menu'); | |
var mainWindow = null; | |
app.on('window-all-closed', function() { | |
if (process.platform != 'darwin') | |
app.quit(); | |
}); | |
app.on('ready', function() { | |
createApplicationMenu(); | |
openWindow(); | |
}); | |
var openWindow = function(){ | |
mainWindow = new BrowserWindow({width: 800, height: 600}); | |
mainWindow.loadUrl('file://' + __dirname + '/index.html'); | |
mainWindow.on('closed', function() { | |
mainWindow = null; | |
}); | |
} | |
var createApplicationMenu = function() { | |
var menuTemplate = [ | |
{ | |
label: 'Mdpreview', | |
submenu: [ | |
{ | |
label: 'Quit', | |
accelerator: 'Ctrl+Q', | |
click: function () {app.quit();} | |
} | |
] | |
}, { | |
label: 'View', | |
submenu: [ | |
{ | |
label: 'Reload', | |
accelerator: 'Ctrl+R', | |
click: function() { | |
BrowserWindow.getFocusedWindow().reloadIgnoringCache(); | |
} | |
}, | |
{ | |
label: 'Toggle DevTools', | |
accelerator: 'Alt+Ctrl+I', | |
click: function() { | |
BrowserWindow.getFocusedWindow().toggleDevTools(); | |
} | |
} | |
] | |
} | |
]; | |
var menu = Menu.buildFromTemplate(menuTemplate); | |
Menu.setApplicationMenu(menu) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var remote = require('remote'); | |
var Menu = remote.require('menu'); | |
var MenuItem = remote.require('menu-item'); | |
var menu = new Menu(); | |
menu.append(new MenuItem({ | |
label: 'ping', | |
click: function() { | |
console.log('ping'); | |
} | |
})); | |
menu.append(new MenuItem({ | |
type: 'separator' | |
})); | |
menu.append(new MenuItem({ | |
label: 'pong', | |
type: 'checkbox', checked: true, | |
click: function() { | |
console.log('pong'); | |
} | |
})); | |
window.addEventListener('contextmenu', function (e) { | |
e.preventDefault(); | |
menu.popup(remote.getCurrentWindow()); | |
}, false); | |
angular.module('mdPreview', ['ngSanitize']) | |
.controller('MainController', function ($scope) { | |
$scope.preview = function(){ | |
if ($scope.md == undefined ) { | |
return ''; | |
} else { | |
return marked($scope.md); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html ng-app="mdPreview"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Sample Markdown Preview</title> | |
<script src="bower_components/angular/angular.js"></script> | |
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script> | |
<script src="bower_components/marked/lib/marked.js"></script> | |
<script src="context.js"></script> | |
</head> | |
<body ng-controller="MainController"> | |
<h2>Electron hello the world</h2> | |
<textarea ng-model="md" rows="4" cols="50"></textarea> | |
<!-- <div>{{md}}</div> --> | |
<div ng-bind-html="preview()"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment