This commit is contained in:
Henrique Dias
2017-01-15 11:47:52 +00:00
parent 3c574d2848
commit fbbf79d757
5 changed files with 94 additions and 55 deletions
+1 -1
View File
@@ -266,7 +266,7 @@ function openEvent(event) {
if(selectedItems.length) {
link = document.getElementById(selectedItems[0]).dataset.url + link;
} else {
link = window.location + link;
link = window.location.pathname + link;
}
window.open(link);
+19 -1
View File
@@ -22,6 +22,17 @@ editor.textareaAutoGrow = function () {
window.addEventListener('resize', addAutoGrow)
}
editor.toggleSourceEditor = function (event) {
event.preventDefault();
if(document.querySelector('[data-kind="content-only"]')) {
window.location = window.location.pathname + "?visual=true"
return;
}
window.location = window.location.pathname + "?visual=false"
}
function deleteFrontMatterItem(event) {
event.preventDefault();
document.getElementById(this.dataset.delete).remove();
@@ -163,11 +174,18 @@ document.addEventListener("DOMContentLoaded", (event) => {
if(!document.getElementById('editor')) return;
editor.textareaAutoGrow();
templates.arrayItem = document.getElementById("array-item-template");
templates.base = document.getElementById('base-template');
templates.objectItem = document.getElementById("object-item-template");
templates.temporary = document.getElementById('temporary-template');
buttons.save = document.querySelector('#save');
buttons.editSource = document.querySelector('#edit-source');
if(buttons.editSource) {
buttons.editSource.addEventListener('click', editor.toggleSourceEditor)
}
let container = document.getElementById('editor'),
kind = container.dataset.kind;
@@ -255,4 +273,4 @@ document.addEventListener("DOMContentLoaded", (event) => {
});
return false;
});
});
+8 -1
View File
@@ -67,9 +67,16 @@
<div class="actions{{ if .IsDir }} disabled{{ end }}" id="file-only">
{{- if and (not .IsDir) (.User.AllowEdit) }}
{{- if .Editor}}
{{- if eq .Data.Mode "markdown" }}
<div class="action" id="preview" onclick="notImplemented(event);">
<i class="material-icons">remove_red_eye</i>
<i class="material-icons" title="Preview">remove_red_eye</i>
</div>
{{- end }}
{{- if eq .Data.Visual true }}
<div class="action" id="edit-source">
<i class="material-icons" title="Toggle edit source">code</i>
</div>
{{- end }}
{{- end }}