remove markdown refs, cleanup

This commit is contained in:
Mo Bitar
2017-02-15 13:20:17 -06:00
parent 979b5eb2a8
commit 8f077245fa
7 changed files with 28 additions and 137 deletions

View File

@@ -86,7 +86,6 @@ module.exports = function(grunt) {
'vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.js', 'vendor/assets/bower_components/angular-ui-router/release/angular-ui-router.js',
'vendor/assets/bower_components/lodash/dist/lodash.min.js', 'vendor/assets/bower_components/lodash/dist/lodash.min.js',
'vendor/assets/bower_components/restangular/dist/restangular.js', 'vendor/assets/bower_components/restangular/dist/restangular.js',
'vendor/assets/bower_components/marked/lib/marked.js',
'vendor/assets/javascripts/crypto/*.js' 'vendor/assets/javascripts/crypto/*.js'
], ],
dest: 'vendor/assets/javascripts/lib.js', dest: 'vendor/assets/javascripts/lib.js',

View File

@@ -29,6 +29,11 @@ angular.module('app.frontend')
} }
}; };
window.addEventListener('keydown', handler);
scope.$on('$destroy', function(){
window.removeEventListener('keydown', handler);
})
scope.$watch('ctrl.note', function(note, oldNote){ scope.$watch('ctrl.note', function(note, oldNote){
if(note) { if(note) {
ctrl.setNote(note, oldNote); ctrl.setNote(note, oldNote);
@@ -39,7 +44,7 @@ angular.module('app.frontend')
} }
} }
}) })
.controller('EditorCtrl', function ($sce, $timeout, authManager, markdownRenderer, $rootScope, extensionManager, syncManager, modelManager) { .controller('EditorCtrl', function ($sce, $timeout, authManager, $rootScope, extensionManager, syncManager, modelManager) {
window.addEventListener("message", function(){ window.addEventListener("message", function(){
console.log("App received message:", event); console.log("App received message:", event);
@@ -56,7 +61,6 @@ angular.module('app.frontend')
}.bind(this), false); }.bind(this), false);
this.setNote = function(note, oldNote) { this.setNote = function(note, oldNote) {
this.editorMode = 'edit';
this.showExtensions = false; this.showExtensions = false;
this.showMenu = false; this.showMenu = false;
this.loadTagsString(); this.loadTagsString();
@@ -107,15 +111,12 @@ angular.module('app.frontend')
return extensionManager.extensionsInContextOfItem(this.note).length > 0; return extensionManager.extensionsInContextOfItem(this.note).length > 0;
} }
this.onPreviewDoubleClick = function() {
this.editorMode = 'edit';
this.focusEditor(100);
}
this.focusEditor = function(delay) { this.focusEditor = function(delay) {
setTimeout(function(){ setTimeout(function(){
var element = document.getElementById("note-text-editor"); var element = document.getElementById("note-text-editor");
element.focus(); if(element) {
element.focus();
}
}, delay) }, delay)
} }
@@ -129,10 +130,6 @@ angular.module('app.frontend')
this.showMenu = false; this.showMenu = false;
} }
this.renderedContent = function() {
return markdownRenderer.renderHtml(markdownRenderer.renderedContentForText(this.note.safeText()));
}
var statusTimeout; var statusTimeout;
this.saveNote = function($event) { this.saveNote = function($event) {
@@ -192,7 +189,6 @@ angular.module('app.frontend')
} }
this.onContentFocus = function() { this.onContentFocus = function() {
this.showSampler = false;
$rootScope.$broadcast("editorFocused"); $rootScope.$broadcast("editorFocused");
} }
@@ -203,12 +199,7 @@ angular.module('app.frontend')
this.toggleFullScreen = function() { this.toggleFullScreen = function() {
this.fullscreen = !this.fullscreen; this.fullscreen = !this.fullscreen;
if(this.fullscreen) { if(this.fullscreen) {
if(this.editorMode == 'edit') { this.focusEditor(0);
// refocus
this.focusEditor(0);
}
} else {
} }
} }
@@ -216,15 +207,6 @@ angular.module('app.frontend')
this.showMenu = false; this.showMenu = false;
} }
this.toggleMarkdown = function() {
if(this.editorMode == 'preview') {
this.editorMode = 'edit';
this.focusEditor(0);
} else {
this.editorMode = 'preview';
}
}
this.deleteNote = function() { this.deleteNote = function() {
if(confirm("Are you sure you want to delete this note?")) { if(confirm("Are you sure you want to delete this note?")) {
this.remove()(this.note); this.remove()(this.note);
@@ -232,11 +214,6 @@ angular.module('app.frontend')
} }
} }
this.clickedEditNote = function() {
this.editorMode = 'edit';
this.focusEditor(100);
}
/* Tags */ /* Tags */
this.loadTagsString = function() { this.loadTagsString = function() {

View File

@@ -1,21 +0,0 @@
angular.module('app.frontend')
.service('markdownRenderer', function ($sce) {
marked.setOptions({
breaks: true,
sanitize: true
});
this.renderedContentForText = function(text) {
if(!text || text.length == 0) {
return "";
}
return marked(text);
}
this.renderHtml = function(html_code) {
return $sce.trustAsHtml(html_code);
};
});

View File

@@ -13,19 +13,17 @@
.section-title-bar { .section-title-bar {
border-bottom: none !important; border-bottom: none !important;
&.fullscreen { // &.fullscreen {
opacity: 0.0; // opacity: 0.0;
-webkit-transition: all 300ms ease-in-out; // -webkit-transition: all 300ms ease-in-out;
-moz-transition: all 300ms ease-in-out; // -moz-transition: all 300ms ease-in-out;
-ms-transition: all 300ms ease-in-out; // -ms-transition: all 300ms ease-in-out;
-o-transition: all 300ms ease-in-out; // -o-transition: all 300ms ease-in-out;
transition: all 300ms ease-in-out; // transition: all 300ms ease-in-out;
//
&:hover { // &:hover {
opacity: 1.0; // opacity: 1.0;
} // }
// z-index: -1;
} }
} }
@@ -44,6 +42,10 @@
width: 100%; width: 100%;
padding-right: 10px; padding-right: 10px;
&.fullscreen {
position: relative;
}
> .title { > .title {
font-size: 18px; font-size: 18px;
font-weight: bold; font-weight: bold;
@@ -93,15 +95,6 @@
} }
} }
.fullscreen-ghost-bar {
position: absolute;
width: 20%;
height: 200px;
z-index: 100;
}
.editor-content { .editor-content {
max-height: 100%; max-height: 100%;
@@ -119,19 +112,6 @@
padding-top: 0px; padding-top: 0px;
} }
.sampler-container {
margin-top: 10px;
padding: 15px;
padding-top: 17px;
font-size: 17px;
// opacity: 0.5;
}
.sampler {
// opacity: 0.5;
color: rgba(black, 0.3);
}
.editable { .editable {
font-family: monospace; font-family: monospace;
max-height: 100%; max-height: 100%;
@@ -147,44 +127,9 @@
&.fullscreen { &.fullscreen {
padding: 85px 10%; padding: 85px 10%;
max-width: 1200px; max-width: 1200px;
display: inline-block;; display: inline-block;
} }
} }
.preview {
// font-family: monospace;
max-height: 100%;
height: 100%;
line-height: 23px;
overflow-y: scroll;
padding: 0px 15px;
text-align: left;
&.fullscreen {
padding: 85px 10%;
max-width: 1200px;
display: inline-block;;
}
}
}
}
.markdown {
margin-left: 15px;
float: right;
text-align: right;
right: 0;
}
ol {
list-style-type: decimal;
list-style-position: inside;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
-webkit-padding-start: 0px;
} }
.nav-tabs { .nav-tabs {

View File

@@ -42,7 +42,3 @@ $dark-gray: #2e2e2e;
display: inline-block; display: inline-block;
margin-left: 2px; margin-left: 2px;
} }
.icon-markdown:before {
content: "\e901";
}

View File

@@ -21,9 +21,6 @@
%li{"ng-click" => "ctrl.selectedMenuItem(); ctrl.toggleFullScreen()"} %li{"ng-click" => "ctrl.selectedMenuItem(); ctrl.toggleFullScreen()"}
.text Toggle Fullscreen .text Toggle Fullscreen
.shortcut Cmd + O .shortcut Cmd + O
%li{"ng-click" => "ctrl.selectedMenuItem(); ctrl.toggleMarkdown()"}
.text Toggle Markdown Preview
.shortcut Cmd + M
%li{"ng-click" => "ctrl.deleteNote()"} %li{"ng-click" => "ctrl.deleteNote()"}
.text Delete .text Delete
@@ -45,6 +42,5 @@
.editor-content{"ng-class" => "{'fullscreen' : ctrl.fullscreen }"} .editor-content{"ng-class" => "{'fullscreen' : ctrl.fullscreen }"}
%iframe#editor-iframe{"ng-if" => "ctrl.customEditor", "ng-src" => "{{ctrl.customEditor.url | trusted}}", "frameBorder" => "0", "style" => "width: 100%; height: 100%; z-index: 1000; float: left;"} %iframe#editor-iframe{"ng-if" => "ctrl.customEditor", "ng-src" => "{{ctrl.customEditor.url | trusted}}", "frameBorder" => "0", "style" => "width: 100%; height: 100%; z-index: 1000; float: left;"}
%textarea.editable#note-text-editor{"ng-if" => "!ctrl.customEditor", "ng-class" => "{'fullscreen' : ctrl.fullscreen }", "ng-show" => "ctrl.editorMode == 'edit'", "ng-model" => "ctrl.note.text", %textarea.editable#note-text-editor{"ng-if" => "!ctrl.customEditor", "ng-class" => "{'fullscreen' : ctrl.fullscreen }", "ng-model" => "ctrl.note.text",
"ng-change" => "ctrl.contentChanged()", "ng-click" => "ctrl.clickedTextArea()", "ng-focus" => "ctrl.onContentFocus()"} "ng-change" => "ctrl.contentChanged()", "ng-click" => "ctrl.clickedTextArea()", "ng-focus" => "ctrl.onContentFocus()"}
.preview{"ng-class" => "{'fullscreen' : ctrl.fullscreen }", "ng-if" => "ctrl.editorMode == 'preview'", "ng-bind-html" => "ctrl.renderedContent()", "ng-dblclick" => "ctrl.onPreviewDoubleClick()"}

View File

@@ -9,8 +9,7 @@
"dependencies": { "dependencies": {
"angular": "1.6.1", "angular": "1.6.1",
"angular-ui-router": "^0.3.2", "angular-ui-router": "^0.3.2",
"restangular": "^1.6.1", "restangular": "^1.6.1"
"marked": "0.3.6"
}, },
"resolutions": { "resolutions": {
"angular": "1.6.1" "angular": "1.6.1"