Commit 43cbb3c1 authored by Jeremy Fischer's avatar Jeremy Fischer
Browse files

Complete feature Markdown editor

parent 10f491a6
......@@ -692,7 +692,7 @@ if (declare_load("appclient") !== TRUE)
var titleCard = document.createElement("div");
titleCard.className = "card";
titleCard.setAttribute("style","max-height: 23em");
titleCard.innerHTML = '<div style="color: black;" id="currentNodeDescPreview"></div><div style="visibility: hidden;" id="currentNodeDescEditorWrapper"><button>Save Changes</button><textarea id="currentNodeDescEditor"></textarea></div>';
titleCard.innerHTML = '<div class="card-content black-text"><a onclick="node_edit_property_title_desc(this)" class="right btn-floating waves-effect waves-light red"><i class="material-icons">create</i></a><div style="transform: scale(0.5); transform-origin: top left; width: 200%; height: 250%; overflow: hidden; position: relative; top: -9%;" id="currentNodeDescPreview"></div></div><div style="visibility: hidden; position: absolute; overflow: hidden; height: 100%; top: 0em;" id="currentNodeDescEditorWrapper"><textarea id="currentNodeDescEditor"></textarea></div>';
flow.appendChild(titleCard);
//Normal State Card:
......@@ -843,7 +843,23 @@ if (declare_load("appclient") !== TRUE)
}
currentDetailNodeEditor = new SimpleMDE({"element": document.getElementById("currentNodeDescEditor"),
initialValue: descText,
toolbar: ["bold","italic","strikethrough","heading","heading-smaller","heading-bigger","code","quote","table","unordered-list","ordered-list","link","image","horizontal-rule","|","preview","side-by-side","fullscreen","guide"]
toolbar: [
{
name: "customSave",
action: function customFunction(editor){
node_edit_property_title_desc_done();
},
className: "fa fa-save",
title: "Commit Changes",
},
{
name: "customDiscard",
action: function customFunction(editor){
nodeDetail(currentDetailNode);
},
className: "fa fa-remove",
title: "Discard Changes",
}, "|","bold","italic","strikethrough","heading","heading-smaller","heading-bigger","code","quote","table","unordered-list","ordered-list","link","image","horizontal-rule","|","preview","side-by-side","fullscreen","guide"]
});
console.log(currentDetailNodeEditor);
document.getElementById("currentNodeDescPreview").innerHTML = currentDetailNodeEditor.options.previewRender(descText);
......@@ -969,29 +985,16 @@ if (declare_load("appclient") !== TRUE)
function node_edit_property_title_desc(object){
var inputName = document.createElement("input");
inputName.setAttribute("type","text");
inputName.setAttribute("value",object.parentElement.childNodes[1].innerText);
object.parentElement.childNodes[1].innerHTML = "";
object.parentElement.childNodes[1].appendChild(inputName);
var inputDescription = document.createElement("textarea");
inputDescription.setAttribute("type","text");
inputDescription.setAttribute("rows","30");
inputDescription.innerText = nodeTree[currentDetailNode]["description"];
object.parentElement.childNodes[2].innerHTML = "";
object.parentElement.childNodes[2].appendChild(inputDescription);
object.childNodes[0].innerText="save";
object.setAttribute("onclick","node_edit_property_title_desc_done(this)");
}
function node_edit_property_title_desc_done(object){
object.childNodes[0].innerText="create";
object.setAttribute("onclick","node_edit_property_title_desc(this)");
console.log(object.parentElement.childNodes[1].childNodes[0].value);
console.log(object.parentElement.childNodes[2].childNodes[0].value);
object.parentElement.style.visibility = "hidden";
console.log(sync_get("?setNodeData&node="+currentDetailNode+"&name="+encodeURIComponent(object.parentElement.childNodes[1].childNodes[0].value)+"&description="+encodeURIComponent(object.parentElement.childNodes[2].childNodes[0].value)));
getNews();
object.parentElement.parentElement.childNodes[0].style.visibility = "hidden";
object.parentElement.parentElement.childNodes[1].style.visibility = "visible";
}
function node_edit_property_title_desc_done(){
var title = currentDetailNodeEditor.value().split("\n")[0].replace("#","").trim();
if(title == "") title = undefined;
var description = currentDetailNodeEditor.value();
async_post("?setNodeData","node="+currentDetailNode+"&name="+encodeURIComponent(title)+"&description="+encodeURIComponent(description), function(){
getNews();
});
}
function node_edit_property_tp(object){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment