|
@@ -31,7 +31,6 @@ const contentComponent = Vue.component('content-block', {
|
|
compmarkdown: '',
|
|
compmarkdown: '',
|
|
componentType: '',
|
|
componentType: '',
|
|
disabled: false,
|
|
disabled: false,
|
|
-//fix load: false,
|
|
|
|
newblock: false,
|
|
newblock: false,
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -312,6 +311,7 @@ const contentComponent = Vue.component('content-block', {
|
|
var method = 'PUT';
|
|
var method = 'PUT';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
sendJson(function(response, httpStatus)
|
|
sendJson(function(response, httpStatus)
|
|
{
|
|
{
|
|
if(httpStatus == 400)
|
|
if(httpStatus == 400)
|
|
@@ -415,56 +415,41 @@ const contentComponent = Vue.component('content-block', {
|
|
var bloxid = bloxeditor.getElementsByClassName('blox')[0].dataset.id;
|
|
var bloxid = bloxeditor.getElementsByClassName('blox')[0].dataset.id;
|
|
|
|
|
|
var self = this;
|
|
var self = this;
|
|
-
|
|
|
|
- var url = self.$root.$data.root + '/api/v1/block';
|
|
|
|
-
|
|
|
|
- var params = {
|
|
|
|
- 'url': document.getElementById("path").value,
|
|
|
|
- 'block_id': bloxid,
|
|
|
|
- 'csrf_name': document.getElementById("csrf_name").value,
|
|
|
|
- 'csrf_value': document.getElementById("csrf_value").value,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- var method = 'DELETE';
|
|
|
|
-
|
|
|
|
- sendJson(function(response, httpStatus)
|
|
|
|
- {
|
|
|
|
- if(httpStatus == 400)
|
|
|
|
|
|
+
|
|
|
|
+ myaxios.delete('/api/v1/block',{
|
|
|
|
+ data: {
|
|
|
|
+ 'url': document.getElementById("path").value,
|
|
|
|
+ 'block_id': bloxid,
|
|
|
|
+ 'csrf_name': document.getElementById("csrf_name").value,
|
|
|
|
+ 'csrf_value': document.getElementById("csrf_value").value,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .then(function (response)
|
|
|
|
+ {
|
|
|
|
+ self.$root.$data.unsafed = false;
|
|
|
|
+ self.activatePage();
|
|
|
|
+ self.switchToPreviewMode();
|
|
|
|
+ self.$root.$data.html.splice(bloxid,1);
|
|
|
|
+ self.$root.$data.markdown.splice(bloxid,1);
|
|
|
|
+ self.$root.$data.blockMarkdown = '';
|
|
|
|
+ self.$root.$data.blockType = '';
|
|
|
|
+
|
|
|
|
+ /* update the table of content if in result */
|
|
|
|
+ if(response.data.toc)
|
|
{
|
|
{
|
|
- self.$root.$data.unsafed = false;
|
|
|
|
- self.activatePage();
|
|
|
|
- publishController.errors.message = "Looks like you are logged out. Please login and try again.";
|
|
|
|
|
|
+ self.$root.$data.html.splice(response.data.toc.id, 1, response.data.toc);
|
|
}
|
|
}
|
|
- if(response)
|
|
|
|
- {
|
|
|
|
- self.$root.$data.unsafed = false;
|
|
|
|
- self.activatePage();
|
|
|
|
-
|
|
|
|
- var result = JSON.parse(response);
|
|
|
|
-
|
|
|
|
- if(result.errors)
|
|
|
|
- {
|
|
|
|
- publishController.errors.message = result.errors.message;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- self.switchToPreviewMode();
|
|
|
|
- self.$root.$data.html.splice(bloxid,1);
|
|
|
|
- self.$root.$data.markdown.splice(bloxid,1);
|
|
|
|
- self.$root.$data.blockMarkdown = '';
|
|
|
|
- self.$root.$data.blockType = '';
|
|
|
|
-
|
|
|
|
- /* update the table of content if in result */
|
|
|
|
- if(result.toc)
|
|
|
|
- {
|
|
|
|
- self.$root.$data.html.splice(result.toc.id, 1, result.toc);
|
|
|
|
- }
|
|
|
|
|
|
|
|
- /* update the navigation and mark navigation item as modified */
|
|
|
|
- navi.getNavi();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }, method, url, params);
|
|
|
|
|
|
+ /* update the navigation and mark navigation item as modified */
|
|
|
|
+ navi.getNavi();
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ if(error.response)
|
|
|
|
+ {
|
|
|
|
+ publishController.errors.message = error.response.data.errors.message;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
})
|
|
@@ -1612,45 +1597,36 @@ const imageComponent = Vue.component('image-component', {
|
|
|
|
|
|
self.imgpreview = e.target.result;
|
|
self.imgpreview = e.target.result;
|
|
|
|
|
|
- /* load image to server */
|
|
|
|
- var url = self.$root.$data.root + '/api/v1/image';
|
|
|
|
-
|
|
|
|
- var params = {
|
|
|
|
|
|
+ myaxios.post('/api/v1/image',{
|
|
'url': document.getElementById("path").value,
|
|
'url': document.getElementById("path").value,
|
|
'image': e.target.result,
|
|
'image': e.target.result,
|
|
'name': imageFile.name,
|
|
'name': imageFile.name,
|
|
'csrf_name': document.getElementById("csrf_name").value,
|
|
'csrf_name': document.getElementById("csrf_name").value,
|
|
'csrf_value': document.getElementById("csrf_value").value,
|
|
'csrf_value': document.getElementById("csrf_value").value,
|
|
- };
|
|
|
|
-
|
|
|
|
- var method = 'POST';
|
|
|
|
-
|
|
|
|
- sendJson(function(response, httpStatus)
|
|
|
|
- {
|
|
|
|
|
|
+ })
|
|
|
|
+ .then(function (response) {
|
|
|
|
+
|
|
|
|
+ self.load = false;
|
|
|
|
+ self.$parent.activatePage();
|
|
|
|
+
|
|
|
|
+ self.imgmeta = true;
|
|
|
|
+ self.imgfile = response.data.name;
|
|
|
|
+ self.$emit('updatedMarkdown', '');
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ /*
|
|
if(httpStatus == 400)
|
|
if(httpStatus == 400)
|
|
{
|
|
{
|
|
self.activatePage();
|
|
self.activatePage();
|
|
publishController.errors.message = "Looks like you are logged out. Please login and try again.";
|
|
publishController.errors.message = "Looks like you are logged out. Please login and try again.";
|
|
}
|
|
}
|
|
- if(response)
|
|
|
|
- {
|
|
|
|
- self.load = false;
|
|
|
|
- self.$parent.activatePage();
|
|
|
|
-
|
|
|
|
- var result = JSON.parse(response);
|
|
|
|
-
|
|
|
|
- if(result.errors)
|
|
|
|
- {
|
|
|
|
- publishController.errors.message = result.errors;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- self.imgmeta = true;
|
|
|
|
- self.imgfile = result.name;
|
|
|
|
- self.$emit('updatedMarkdown', '');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }, method, url, params);
|
|
|
|
|
|
+ */
|
|
|
|
+ if(error.response.data.errors.message)
|
|
|
|
+ {
|
|
|
|
+ publishController.errors.message = error.response.data.errors.message;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1803,47 +1779,30 @@ const fileComponent = Vue.component('file-component', {
|
|
reader.readAsDataURL(uploadedFile);
|
|
reader.readAsDataURL(uploadedFile);
|
|
reader.onload = function(e) {
|
|
reader.onload = function(e) {
|
|
|
|
|
|
- /* load file to server */
|
|
|
|
- var url = self.$root.$data.root + '/api/v1/file';
|
|
|
|
-
|
|
|
|
- var params = {
|
|
|
|
|
|
+ myaxios.post('/api/v1/file',{
|
|
'url': document.getElementById("path").value,
|
|
'url': document.getElementById("path").value,
|
|
'file': e.target.result,
|
|
'file': e.target.result,
|
|
'name': uploadedFile.name,
|
|
'name': uploadedFile.name,
|
|
'csrf_name': document.getElementById("csrf_name").value,
|
|
'csrf_name': document.getElementById("csrf_name").value,
|
|
'csrf_value': document.getElementById("csrf_value").value,
|
|
'csrf_value': document.getElementById("csrf_value").value,
|
|
- };
|
|
|
|
-
|
|
|
|
- var method = 'POST';
|
|
|
|
-
|
|
|
|
- sendJson(function(response, httpStatus)
|
|
|
|
- {
|
|
|
|
- if(httpStatus == 400)
|
|
|
|
- {
|
|
|
|
- self.activatePage();
|
|
|
|
- publishController.errors.message = "Looks like you are logged out. Please login and try again.";
|
|
|
|
- }
|
|
|
|
- if(response)
|
|
|
|
- {
|
|
|
|
- self.load = false;
|
|
|
|
- self.$parent.activatePage();
|
|
|
|
|
|
+ })
|
|
|
|
+ .then(function (response) {
|
|
|
|
+ self.load = false;
|
|
|
|
+ self.$parent.activatePage();
|
|
|
|
|
|
- var result = JSON.parse(response);
|
|
|
|
-
|
|
|
|
- if(result.errors)
|
|
|
|
- {
|
|
|
|
- publishController.errors.message = result.errors;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- self.filemeta = true;
|
|
|
|
- self.filetitle = result.info.title;
|
|
|
|
- self.fileextension = result.info.extension;
|
|
|
|
- self.fileurl = result.info.url;
|
|
|
|
- self.createmarkdown();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }, method, url, params);
|
|
|
|
|
|
+ self.filemeta = true;
|
|
|
|
+ self.filetitle = response.data.info.title;
|
|
|
|
+ self.fileextension = response.data.info.extension;
|
|
|
|
+ self.fileurl = response.data.info.url;
|
|
|
|
+ self.createmarkdown();
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ if(error.response.data.errors.message)
|
|
|
|
+ {
|
|
|
|
+ publishController.errors.message = error.response.data.errors.message;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1890,82 +1849,63 @@ let editor = new Vue({
|
|
|
|
|
|
publishController.visual = true;
|
|
publishController.visual = true;
|
|
|
|
|
|
- var self = this;
|
|
|
|
-
|
|
|
|
- var url = this.root + '/api/v1/article/html';
|
|
|
|
-
|
|
|
|
- var params = {
|
|
|
|
|
|
+ var self = this;
|
|
|
|
+
|
|
|
|
+ myaxios.post('/api/v1/article/html',{
|
|
'url': document.getElementById("path").value,
|
|
'url': document.getElementById("path").value,
|
|
'csrf_name': document.getElementById("csrf_name").value,
|
|
'csrf_name': document.getElementById("csrf_name").value,
|
|
'csrf_value': document.getElementById("csrf_value").value,
|
|
'csrf_value': document.getElementById("csrf_value").value,
|
|
- };
|
|
|
|
-
|
|
|
|
- var method = 'POST';
|
|
|
|
-
|
|
|
|
- sendJson(function(response, httpStatus)
|
|
|
|
- {
|
|
|
|
- if(httpStatus == 400)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
- if(response)
|
|
|
|
- {
|
|
|
|
- var result = JSON.parse(response);
|
|
|
|
-
|
|
|
|
- if(result.errors)
|
|
|
|
- {
|
|
|
|
- self.errors.title = result.errors;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- var contenthtml = result.data;
|
|
|
|
- self.title = contenthtml[0];
|
|
|
|
- self.html = contenthtml;
|
|
|
|
- var initialcontent = document.getElementById("initial-content");
|
|
|
|
- initialcontent.parentNode.removeChild(initialcontent);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }, method, url, params);
|
|
|
|
-
|
|
|
|
- var url = this.root + '/api/v1/article/markdown';
|
|
|
|
-
|
|
|
|
- sendJson(function(response, httpStatus)
|
|
|
|
- {
|
|
|
|
- if(httpStatus == 400)
|
|
|
|
- {
|
|
|
|
- }
|
|
|
|
- if(response)
|
|
|
|
- {
|
|
|
|
- var result = JSON.parse(response);
|
|
|
|
-
|
|
|
|
- if(result.errors)
|
|
|
|
- {
|
|
|
|
- self.errors.title = result.errors;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- self.markdown = result.data;
|
|
|
|
-
|
|
|
|
- /* activate math plugin */
|
|
|
|
|
|
+ })
|
|
|
|
+ .then(function (response) {
|
|
|
|
+
|
|
|
|
+ var contenthtml = response.data.data;
|
|
|
|
+ self.title = contenthtml[0];
|
|
|
|
+ self.html = contenthtml;
|
|
|
|
+ var initialcontent = document.getElementById("initial-content");
|
|
|
|
+
|
|
|
|
+ initialcontent.parentNode.removeChild(initialcontent);
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ if(error.response)
|
|
|
|
+ {
|
|
|
|
+ self.errors.title = error.response.errors;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ myaxios.post('/api/v1/article/markdown',{
|
|
|
|
+ 'url': document.getElementById("path").value,
|
|
|
|
+ 'csrf_name': document.getElementById("csrf_name").value,
|
|
|
|
+ 'csrf_value': document.getElementById("csrf_value").value,
|
|
|
|
+ })
|
|
|
|
+ .then(function (response) {
|
|
|
|
+
|
|
|
|
+ self.markdown = response.data.data;
|
|
|
|
|
|
- if (typeof renderMathInElement === "function") {
|
|
|
|
- self.$nextTick(function () {
|
|
|
|
- renderMathInElement(document.getElementById("blox"));
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ /* activate math plugin */
|
|
|
|
+ if (typeof renderMathInElement === "function") {
|
|
|
|
+ self.$nextTick(function () {
|
|
|
|
+ renderMathInElement(document.getElementById("blox"));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
|
|
- /* check for youtube videos */
|
|
|
|
- if (typeof typemillUtilities !== "undefined")
|
|
|
|
- {
|
|
|
|
- setTimeout(function(){
|
|
|
|
- self.$nextTick(function ()
|
|
|
|
- {
|
|
|
|
- typemillUtilities.start();
|
|
|
|
- });
|
|
|
|
- }, 200);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ /* check for youtube videos */
|
|
|
|
+ if (typeof typemillUtilities !== "undefined") {
|
|
|
|
+ setTimeout(function(){
|
|
|
|
+ self.$nextTick(function () {
|
|
|
|
+ typemillUtilities.start();
|
|
|
|
+ });
|
|
|
|
+ }, 200);
|
|
}
|
|
}
|
|
- }, method, url, params);
|
|
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ if(error.response)
|
|
|
|
+ {
|
|
|
|
+ self.errors.title = error.response.errors;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
onStart: function()
|
|
onStart: function()
|
|
@@ -1974,60 +1914,51 @@ let editor = new Vue({
|
|
},
|
|
},
|
|
moveBlock: function(evt)
|
|
moveBlock: function(evt)
|
|
{
|
|
{
|
|
|
|
+ publishController.errors.message = false;
|
|
|
|
+
|
|
|
|
+ var self = this;
|
|
|
|
|
|
- var params = {
|
|
|
|
|
|
+ myaxios.put('/api/v1/moveblock',{
|
|
'url': document.getElementById("path").value,
|
|
'url': document.getElementById("path").value,
|
|
'old_index': evt.oldIndex,
|
|
'old_index': evt.oldIndex,
|
|
'new_index': evt.newIndex,
|
|
'new_index': evt.newIndex,
|
|
'csrf_name': document.getElementById("csrf_name").value,
|
|
'csrf_name': document.getElementById("csrf_name").value,
|
|
'csrf_value': document.getElementById("csrf_value").value,
|
|
'csrf_value': document.getElementById("csrf_value").value,
|
|
- };
|
|
|
|
- publishController.errors.message = false;
|
|
|
|
|
|
+ })
|
|
|
|
+ .then(function (response) {
|
|
|
|
+
|
|
|
|
+ self.freeze = false;
|
|
|
|
+
|
|
|
|
+ self.markdown = response.data.markdown;
|
|
|
|
+ self.blockMarkdown = '';
|
|
|
|
+ self.blockType = '';
|
|
|
|
|
|
- var url = this.root + '/api/v1/moveblock';
|
|
|
|
- var self = this;
|
|
|
|
-
|
|
|
|
- var method = 'PUT';
|
|
|
|
-
|
|
|
|
- sendJson(function(response, httpStatus)
|
|
|
|
- {
|
|
|
|
- if(httpStatus == 400)
|
|
|
|
|
|
+ if(response.data.toc)
|
|
{
|
|
{
|
|
|
|
+ self.html.splice(response.data.toc.id, 1, response.data.toc);
|
|
}
|
|
}
|
|
- if(response)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- var result = JSON.parse(response);
|
|
|
|
-
|
|
|
|
- if(result.errors)
|
|
|
|
- {
|
|
|
|
- publishController.errors.message = result.errors;
|
|
|
|
- publishController.publishDisabled = false;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- self.freeze = false;
|
|
|
|
-
|
|
|
|
- self.markdown = result.markdown;
|
|
|
|
- self.blockMarkdown = '';
|
|
|
|
- self.blockType = '';
|
|
|
|
-
|
|
|
|
- if(result.toc)
|
|
|
|
- {
|
|
|
|
- self.html.splice(result.toc.id, 1, result.toc);
|
|
|
|
- }
|
|
|
|
|
|
|
|
- publishController.publishDisabled = false;
|
|
|
|
- publishController.publishResult = "";
|
|
|
|
-
|
|
|
|
- /* update the navigation and mark navigation item as modified */
|
|
|
|
- navi.getNavi();
|
|
|
|
-
|
|
|
|
- /* update the math if plugin is there */
|
|
|
|
- self.checkMath(params.new_index+1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }, method, url, params);
|
|
|
|
|
|
+ publishController.publishDisabled = false;
|
|
|
|
+ publishController.publishResult = "";
|
|
|
|
+
|
|
|
|
+ /* update the navigation and mark navigation item as modified */
|
|
|
|
+ navi.getNavi();
|
|
|
|
+
|
|
|
|
+ /* update the math if plugin is there */
|
|
|
|
+ self.checkMath(params.new_index+1);
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ publishController.publishDisabled = false;
|
|
|
|
+ if(error.response.data.message)
|
|
|
|
+ {
|
|
|
|
+ publishController.errors.message = error.response.data.message;
|
|
|
|
+ }
|
|
|
|
+ if(error.response.data.errors.message)
|
|
|
|
+ {
|
|
|
|
+ publishController.errors.message = error.response.data.errors.message;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
},
|
|
},
|
|
setData: function(event, blocktype, body)
|
|
setData: function(event, blocktype, body)
|
|
{
|
|
{
|