|
@@ -5,9 +5,9 @@ const contentComponent = Vue.component('content-block', {
|
|
template: '<div ref="bloxcomponent" class="blox-editor" :class="newblock">' +
|
|
template: '<div ref="bloxcomponent" class="blox-editor" :class="newblock">' +
|
|
'<div v-if="newblock" class="newblock-info">Choose a content-type <button class="newblock-close" @click.prevent="closeNewBlock($event)">close</button></div>' +
|
|
'<div v-if="newblock" class="newblock-info">Choose a content-type <button class="newblock-close" @click.prevent="closeNewBlock($event)">close</button></div>' +
|
|
'<div class="blox-wrapper" :class="{ editactive: edit }">' +
|
|
'<div class="blox-wrapper" :class="{ editactive: edit }">' +
|
|
- '<div class="sideaction" v-if="body">' +
|
|
|
|
- '<button class="add" :disabled="disabled" :title="$t(\'add content-block\')" @click.prevent="addNewBlock($event)"><svg class="icon icon-plus"><use xlink:href="#icon-plus"></use></svg></button>' +
|
|
|
|
- '<button class="delete" :disabled="disabled" :title="$t(\'delete content-block\')" @click.prevent="deleteBlock($event)"><svg class="icon icon-close"><use xlink:href="#icon-close"></use></svg></button>' +
|
|
|
|
|
|
+ '<div class="sideaction" slot="header" v-if="body">' +
|
|
|
|
+ '<button class="add" :disabled="disabled" :title="$t(\'add content-block\')" @mousedown.prevent="disableSort()" @click.prevent="addNewBlock($event)"><svg class="icon icon-plus"><use xlink:href="#icon-plus"></use></svg></button>' +
|
|
|
|
+ '<button class="delete" :disabled="disabled" :title="$t(\'delete content-block\')" @mousedown.prevent="disableSort()" @click.prevent="deleteBlock($event)"><svg class="icon icon-close"><use xlink:href="#icon-close"></use></svg></button>' +
|
|
'</div>' +
|
|
'</div>' +
|
|
'<div class="background-helper" @keyup.enter="submitBlock" @click="getData">' +
|
|
'<div class="background-helper" @keyup.enter="submitBlock" @click="getData">' +
|
|
'<div class="component" ref="component">' +
|
|
'<div class="component" ref="component">' +
|
|
@@ -40,6 +40,10 @@ const contentComponent = Vue.component('content-block', {
|
|
eventBus.$on('closeComponents', this.closeComponents);
|
|
eventBus.$on('closeComponents', this.closeComponents);
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ disableSort: function(event)
|
|
|
|
+ {
|
|
|
|
+ this.$root.$data.sortdisabled = true;
|
|
|
|
+ },
|
|
addNewBlock: function(event)
|
|
addNewBlock: function(event)
|
|
{
|
|
{
|
|
/* we have to get from dom because block-data might not be set when user clicked on add button before opened the component */
|
|
/* we have to get from dom because block-data might not be set when user clicked on add button before opened the component */
|
|
@@ -76,27 +80,17 @@ const contentComponent = Vue.component('content-block', {
|
|
updateMarkdown: function($event)
|
|
updateMarkdown: function($event)
|
|
{
|
|
{
|
|
this.compmarkdown = $event;
|
|
this.compmarkdown = $event;
|
|
- this.$nextTick(function () {
|
|
|
|
- this.$refs.preview.style.minHeight = this.$refs.component.offsetHeight + 'px';
|
|
|
|
- });
|
|
|
|
|
|
+ this.setComponentSize();
|
|
},
|
|
},
|
|
- switchToEditMode: function()
|
|
|
|
|
|
+ setComponentSize: function()
|
|
{
|
|
{
|
|
- if(this.edit){ return; }
|
|
|
|
- eventBus.$emit('closeComponents');
|
|
|
|
- self = this;
|
|
|
|
- self.$root.$data.freeze = true; /* freeze the data */
|
|
|
|
- self.$root.$data.sortdisabled = true; /* disable sorting */
|
|
|
|
- this.preview = 'hidden'; /* hide the html-preview */
|
|
|
|
- this.edit = true; /* show the edit-mode */
|
|
|
|
- this.compmarkdown = self.$root.$data.blockMarkdown; /* get markdown data */
|
|
|
|
- this.componentType = self.$root.$data.blockType; /* get block-type of element */
|
|
|
|
if(this.componentType == 'image-component')
|
|
if(this.componentType == 'image-component')
|
|
{
|
|
{
|
|
|
|
+ myself = this;
|
|
setTimeout(function(){
|
|
setTimeout(function(){
|
|
- self.$nextTick(function ()
|
|
|
|
|
|
+ myself.$nextTick(function ()
|
|
{
|
|
{
|
|
- self.$refs.preview.style.minHeight = self.$refs.component.offsetHeight + 'px';
|
|
|
|
|
|
+ myself.$refs.preview.style.minHeight = myself.$refs.component.offsetHeight + 'px';
|
|
});
|
|
});
|
|
}, 200);
|
|
}, 200);
|
|
}
|
|
}
|
|
@@ -104,10 +98,23 @@ const contentComponent = Vue.component('content-block', {
|
|
{
|
|
{
|
|
this.$nextTick(function ()
|
|
this.$nextTick(function ()
|
|
{
|
|
{
|
|
- this.$refs.preview.style.minHeight = self.$refs.component.offsetHeight + 'px';
|
|
|
|
|
|
+ this.$refs.preview.style.minHeight = this.$refs.component.offsetHeight + 'px';
|
|
});
|
|
});
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ switchToEditMode: function()
|
|
|
|
+ {
|
|
|
|
+ if(this.edit){ return; }
|
|
|
|
+ eventBus.$emit('closeComponents');
|
|
|
|
+ self = this;
|
|
|
|
+ self.$root.$data.freeze = true; /* freeze the data */
|
|
|
|
+ self.$root.$data.sortdisabled = true; /* disable sorting */
|
|
|
|
+ this.preview = 'hidden'; /* hide the html-preview */
|
|
|
|
+ this.edit = true; /* show the edit-mode */
|
|
|
|
+ this.compmarkdown = self.$root.$data.blockMarkdown; /* get markdown data */
|
|
|
|
+ this.componentType = self.$root.$data.blockType; /* get block-type of element */
|
|
|
|
+ this.setComponentSize();
|
|
|
|
+ },
|
|
closeComponents: function()
|
|
closeComponents: function()
|
|
{
|
|
{
|
|
this.preview = 'visible';
|
|
this.preview = 'visible';
|
|
@@ -216,7 +223,8 @@ const contentComponent = Vue.component('content-block', {
|
|
{
|
|
{
|
|
var compmarkdown = this.compmarkdown.split('\n\n').join('\n');
|
|
var compmarkdown = this.compmarkdown.split('\n\n').join('\n');
|
|
}
|
|
}
|
|
-*/ var compmarkdown = this.compmarkdown;
|
|
|
|
|
|
+*/
|
|
|
|
+ var compmarkdown = this.compmarkdown;
|
|
|
|
|
|
var params = {
|
|
var params = {
|
|
'url': document.getElementById("path").value,
|
|
'url': document.getElementById("path").value,
|
|
@@ -228,13 +236,33 @@ const contentComponent = Vue.component('content-block', {
|
|
|
|
|
|
if(this.componentType == 'image-component' && self.$root.$data.file)
|
|
if(this.componentType == 'image-component' && self.$root.$data.file)
|
|
{
|
|
{
|
|
- var url = self.$root.$data.root + '/api/v1/image';
|
|
|
|
|
|
+ var url = self.$root.$data.root + '/api/v1/image';
|
|
var method = 'PUT';
|
|
var method = 'PUT';
|
|
|
|
+ params.new = false;
|
|
|
|
+ if(self.$root.$data.newblock || self.$root.$data.blockId == 99999)
|
|
|
|
+ {
|
|
|
|
+ params.new = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else if(this.componentType == 'video-component')
|
|
else if(this.componentType == 'video-component')
|
|
{
|
|
{
|
|
- var url = self.$root.$data.root + '/api/v1/video';
|
|
|
|
- var method = 'POST';
|
|
|
|
|
|
+ var url = self.$root.$data.root + '/api/v1/video';
|
|
|
|
+ var method = 'POST';
|
|
|
|
+ params.new = false;
|
|
|
|
+ if(self.$root.$data.newblock || self.$root.$data.blockId == 99999)
|
|
|
|
+ {
|
|
|
|
+ params.new = true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if(this.componentType == 'file-component')
|
|
|
|
+ {
|
|
|
|
+ var url = self.$root.$data.root + '/api/v1/file';
|
|
|
|
+ var method = 'PUT';
|
|
|
|
+ params.new = false;
|
|
|
|
+ if(self.$root.$data.newblock || self.$root.$data.blockId == 99999)
|
|
|
|
+ {
|
|
|
|
+ params.new = true;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
else if(self.$root.$data.newblock || self.$root.$data.blockId == 99999)
|
|
else if(self.$root.$data.newblock || self.$root.$data.blockId == 99999)
|
|
{
|
|
{
|
|
@@ -246,7 +274,7 @@ const contentComponent = Vue.component('content-block', {
|
|
var url = self.$root.$data.root + '/api/v1/block';
|
|
var url = self.$root.$data.root + '/api/v1/block';
|
|
var method = 'PUT';
|
|
var method = 'PUT';
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
sendJson(function(response, httpStatus)
|
|
sendJson(function(response, httpStatus)
|
|
{
|
|
{
|
|
if(httpStatus == 400)
|
|
if(httpStatus == 400)
|
|
@@ -1180,12 +1208,21 @@ const videoComponent = Vue.component('video-component', {
|
|
},
|
|
},
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+
|
|
const imageComponent = Vue.component('image-component', {
|
|
const imageComponent = Vue.component('image-component', {
|
|
props: ['compmarkdown', 'disabled'],
|
|
props: ['compmarkdown', 'disabled'],
|
|
template: '<div class="dropbox">' +
|
|
template: '<div class="dropbox">' +
|
|
'<input type="hidden" ref="markdown" :value="compmarkdown" :disabled="disabled" @input="updatemarkdown" />' +
|
|
'<input type="hidden" ref="markdown" :value="compmarkdown" :disabled="disabled" @input="updatemarkdown" />' +
|
|
- '<input type="file" name="image" accept="image/*" class="input-file" @change="onFileChange( $event )" /> ' +
|
|
|
|
- '<p>{{ $t(\'drag a picture or click to select\') }}</p>' +
|
|
|
|
|
|
+ '<div class="imageupload">' +
|
|
|
|
+ '<input type="file" name="image" accept="image/*" class="input-file" @change="onFileChange( $event )" /> ' +
|
|
|
|
+ '<p><svg class="icon icon-upload baseline"><use xlink:href="#icon-upload"></use></svg> {{ $t(\'drag a picture or click to select\') }}</p>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<button class="imageselect" @click.prevent="openmedialib()"><svg class="icon icon-image baseline"><use xlink:href="#icon-image"></use></svg> select from medialib</button>' +
|
|
|
|
+ '<transition name="fade-editor">' +
|
|
|
|
+ '<div v-if="showmedialib" class="modalWindow">' +
|
|
|
|
+ '<medialib parentcomponent="images"></medialib>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</transition>' +
|
|
'<div class="contenttype"><svg class="icon icon-image"><use xlink:href="#icon-image"></use></svg></div>' +
|
|
'<div class="contenttype"><svg class="icon icon-image"><use xlink:href="#icon-image"></use></svg></div>' +
|
|
'<img class="uploadPreview" :src="imgpreview" />' +
|
|
'<img class="uploadPreview" :src="imgpreview" />' +
|
|
'<div v-if="load" class="loadwrapper"><span class="load"></span></div>' +
|
|
'<div v-if="load" class="loadwrapper"><span class="load"></span></div>' +
|
|
@@ -1201,6 +1238,7 @@ const imageComponent = Vue.component('image-component', {
|
|
return {
|
|
return {
|
|
maxsize: 5, // megabyte
|
|
maxsize: 5, // megabyte
|
|
imgpreview: false,
|
|
imgpreview: false,
|
|
|
|
+ showmedialib: false,
|
|
load: false,
|
|
load: false,
|
|
imgmeta: false,
|
|
imgmeta: false,
|
|
imgalt: '',
|
|
imgalt: '',
|
|
@@ -1209,7 +1247,7 @@ const imageComponent = Vue.component('image-component', {
|
|
imglink: '',
|
|
imglink: '',
|
|
imgclass: 'center',
|
|
imgclass: 'center',
|
|
imgid: '',
|
|
imgid: '',
|
|
- imgfile: 'imgplchldr',
|
|
|
|
|
|
+ imgfile: '',
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted: function(){
|
|
mounted: function(){
|
|
@@ -1280,6 +1318,10 @@ const imageComponent = Vue.component('image-component', {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
|
|
+ openmedialib: function()
|
|
|
|
+ {
|
|
|
|
+ this.showmedialib = true;
|
|
|
|
+ },
|
|
isChecked: function(classname)
|
|
isChecked: function(classname)
|
|
{
|
|
{
|
|
if(this.imgclass == classname)
|
|
if(this.imgclass == classname)
|
|
@@ -1372,7 +1414,7 @@ const imageComponent = Vue.component('image-component', {
|
|
errors = 'Maximum size of image caption is 140 characters';
|
|
errors = 'Maximum size of image caption is 140 characters';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if(errors)
|
|
if(errors)
|
|
{
|
|
{
|
|
this.$parent.freezePage();
|
|
this.$parent.freezePage();
|
|
@@ -1402,17 +1444,17 @@ const imageComponent = Vue.component('image-component', {
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- self = this;
|
|
|
|
- this.$parent.freezePage();
|
|
|
|
- this.$root.$data.file = true;
|
|
|
|
- this.load = true;
|
|
|
|
|
|
+ self = this;
|
|
|
|
|
|
|
|
+ self.$parent.freezePage();
|
|
|
|
+ self.$root.$data.file = true;
|
|
|
|
+ self.load = true;
|
|
|
|
+
|
|
let reader = new FileReader();
|
|
let reader = new FileReader();
|
|
reader.readAsDataURL(imageFile);
|
|
reader.readAsDataURL(imageFile);
|
|
reader.onload = function(e) {
|
|
reader.onload = function(e) {
|
|
|
|
+
|
|
self.imgpreview = e.target.result;
|
|
self.imgpreview = e.target.result;
|
|
- self.$emit('updatedMarkdown', '');
|
|
|
|
-
|
|
|
|
|
|
|
|
/* load image to server */
|
|
/* load image to server */
|
|
var url = self.$root.$data.root + '/api/v1/image';
|
|
var url = self.$root.$data.root + '/api/v1/image';
|
|
@@ -1420,22 +1462,23 @@ const imageComponent = Vue.component('image-component', {
|
|
var params = {
|
|
var params = {
|
|
'url': document.getElementById("path").value,
|
|
'url': document.getElementById("path").value,
|
|
'image': e.target.result,
|
|
'image': e.target.result,
|
|
|
|
+ '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';
|
|
var method = 'POST';
|
|
-
|
|
|
|
|
|
+
|
|
sendJson(function(response, httpStatus)
|
|
sendJson(function(response, httpStatus)
|
|
- {
|
|
|
|
|
|
+ {
|
|
if(httpStatus == 400)
|
|
if(httpStatus == 400)
|
|
{
|
|
{
|
|
- self.$parent.activatePage();
|
|
|
|
|
|
+ self.activatePage();
|
|
}
|
|
}
|
|
if(response)
|
|
if(response)
|
|
{
|
|
{
|
|
- self.$parent.activatePage();
|
|
|
|
self.load = false;
|
|
self.load = false;
|
|
|
|
+ self.$parent.activatePage();
|
|
|
|
|
|
var result = JSON.parse(response);
|
|
var result = JSON.parse(response);
|
|
|
|
|
|
@@ -1446,6 +1489,200 @@ const imageComponent = Vue.component('image-component', {
|
|
else
|
|
else
|
|
{
|
|
{
|
|
self.imgmeta = true;
|
|
self.imgmeta = true;
|
|
|
|
+ self.imgfile = result.name;
|
|
|
|
+ self.$emit('updatedMarkdown', '');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }, method, url, params);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+const fileComponent = Vue.component('file-component', {
|
|
|
|
+ props: ['compmarkdown', 'disabled'],
|
|
|
|
+ template: '<div class="dropbox">' +
|
|
|
|
+ '<input type="hidden" ref="markdown" :value="compmarkdown" :disabled="disabled" @input="updatemarkdown" />' +
|
|
|
|
+ '<div class="imageupload">' +
|
|
|
|
+ '<input type="file" accept="*" name="file" class="input-file" @change="onFileChange( $event )" /> ' +
|
|
|
|
+ '<p><svg class="icon icon-upload baseline"><use xlink:href="#icon-upload"></use></svg> {{ $t(\'upload file\') }}</p>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<button class="imageselect" @click.prevent="openmedialib()"><svg class="icon icon-paperclip baseline"><use xlink:href="#icon-paperclip"></use></svg> select from medialib</button>' +
|
|
|
|
+ '<transition name="fade-editor">' +
|
|
|
|
+ '<div v-if="showmedialib" class="modalWindow">' +
|
|
|
|
+ '<medialib parentcomponent="files"></medialib>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</transition>' +
|
|
|
|
+ '<div class="contenttype"><svg class="icon icon-paperclip"><use xlink:href="#icon-paperclip"></use></svg></div>' +
|
|
|
|
+ '<div v-if="load" class="loadwrapper"><span class="load"></span></div>' +
|
|
|
|
+ '<div class="imgmeta relative" v-if="filemeta">' +
|
|
|
|
+ '<label for="filetitle">{{ $t(\'Title\') }}: </label>' +
|
|
|
|
+ '<input name="filetitle" type="text" placeholder="Add a title for the download-link" v-model="filetitle" @input="createmarkdown" max="64" />' +
|
|
|
|
+ '<input title="fileid" type="hidden" placeholder="id" v-model="fileid" @input="createmarkdown" max="140" />' +
|
|
|
|
+ '</div></div>',
|
|
|
|
+ data: function(){
|
|
|
|
+ return {
|
|
|
|
+ maxsize: 5, // megabyte
|
|
|
|
+ showmedialib: false,
|
|
|
|
+ load: false,
|
|
|
|
+ filemeta: false,
|
|
|
|
+ filetitle: '',
|
|
|
|
+ fileextension: '',
|
|
|
|
+ fileurl: '',
|
|
|
|
+ fileid: ''
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ mounted: function(){
|
|
|
|
+
|
|
|
|
+ this.$refs.markdown.focus();
|
|
|
|
+
|
|
|
|
+ if(this.compmarkdown)
|
|
|
|
+ {
|
|
|
|
+ this.filemeta = true;
|
|
|
|
+
|
|
|
|
+ var filemarkdown = this.compmarkdown;
|
|
|
|
+
|
|
|
|
+ var filetitle = filemarkdown.match(/\[.*?\]/);
|
|
|
|
+ if(filetitle)
|
|
|
|
+ {
|
|
|
|
+ filemarkdown = filemarkdown.replace(filetitle[0],'');
|
|
|
|
+ this.filetitle = filetitle[0].slice(1,-1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var fileattr = filemarkdown.match(/\{.*?\}/);
|
|
|
|
+ var fileextension = filemarkdown.match(/file-(.*)?\}/);
|
|
|
|
+ if(fileattr && fileextension)
|
|
|
|
+ {
|
|
|
|
+ filemarkdown = filemarkdown.replace(fileattr[0],'');
|
|
|
|
+ this.fileextension = fileextension[1].trim();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var fileurl = filemarkdown.match(/\(.*?\)/g);
|
|
|
|
+ if(fileurl)
|
|
|
|
+ {
|
|
|
|
+ filemarkdown = filemarkdown.replace(fileurl[0],'');
|
|
|
|
+ this.fileurl = fileurl[0].slice(1,-1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ openmedialib: function()
|
|
|
|
+ {
|
|
|
|
+ this.showmedialib = true;
|
|
|
|
+ },
|
|
|
|
+ isChecked: function(classname)
|
|
|
|
+ {
|
|
|
|
+ if(this.fileclass == classname)
|
|
|
|
+ {
|
|
|
|
+ return ' checked';
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ updatemarkdown: function(event)
|
|
|
|
+ {
|
|
|
|
+ this.$emit('updatedMarkdown', event.target.value);
|
|
|
|
+ },
|
|
|
|
+ createmarkdown: function()
|
|
|
|
+ {
|
|
|
|
+ var errors = false;
|
|
|
|
+
|
|
|
|
+ if(this.filetitle.length < 101)
|
|
|
|
+ {
|
|
|
|
+ filemarkdown = '[' + this.filetitle + ']';
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ errors = 'Maximum size of file-text is 100 characters';
|
|
|
|
+ filemarkdown = '[]';
|
|
|
|
+ }
|
|
|
|
+ if(this.fileurl != '')
|
|
|
|
+ {
|
|
|
|
+ if(this.fileurl.length < 101)
|
|
|
|
+ {
|
|
|
|
+ filemarkdown = '[' + this.filetitle + '](' + this.fileurl + ')';
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ errors = 'Maximum size of file link is 100 characters';
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(this.fileextension != '')
|
|
|
|
+ {
|
|
|
|
+ filemarkdown = filemarkdown + '{.tm-download file-' + this.fileextension + '}';
|
|
|
|
+ }
|
|
|
|
+ if(errors)
|
|
|
|
+ {
|
|
|
|
+ this.$parent.freezePage();
|
|
|
|
+ publishController.errors.message = errors;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ publishController.errors.message = false;
|
|
|
|
+ this.$parent.activatePage();
|
|
|
|
+ this.$emit('updatedMarkdown', filemarkdown);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ onFileChange: function( e )
|
|
|
|
+ {
|
|
|
|
+ if(e.target.files.length > 0)
|
|
|
|
+ {
|
|
|
|
+ let uploadedFile = e.target.files[0];
|
|
|
|
+ let size = uploadedFile.size / 1024 / 1024;
|
|
|
|
+
|
|
|
|
+ if (size > this.maxsize)
|
|
|
|
+ {
|
|
|
|
+ publishController.errors.message = "The maximal size of a file is " + this.maxsize + " MB";
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ self = this;
|
|
|
|
+
|
|
|
|
+ self.$parent.freezePage();
|
|
|
|
+ self.$root.$data.file = true;
|
|
|
|
+ self.load = true;
|
|
|
|
+
|
|
|
|
+ let reader = new FileReader();
|
|
|
|
+ reader.readAsDataURL(uploadedFile);
|
|
|
|
+ reader.onload = function(e) {
|
|
|
|
+
|
|
|
|
+ /* load file to server */
|
|
|
|
+ var url = self.$root.$data.root + '/api/v1/file';
|
|
|
|
+
|
|
|
|
+ var params = {
|
|
|
|
+ 'url': document.getElementById("path").value,
|
|
|
|
+ 'file': e.target.result,
|
|
|
|
+ 'name': uploadedFile.name,
|
|
|
|
+ 'csrf_name': document.getElementById("csrf_name").value,
|
|
|
|
+ 'csrf_value': document.getElementById("csrf_value").value,
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ var method = 'POST';
|
|
|
|
+
|
|
|
|
+ sendJson(function(response, httpStatus)
|
|
|
|
+ {
|
|
|
|
+ if(httpStatus == 400)
|
|
|
|
+ {
|
|
|
|
+ self.activatePage();
|
|
|
|
+ }
|
|
|
|
+ if(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);
|
|
}, method, url, params);
|
|
@@ -1456,6 +1693,493 @@ const imageComponent = Vue.component('image-component', {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
|
|
|
|
|
|
+const medialib = Vue.component('medialib', {
|
|
|
|
+ props: ['parentcomponent'],
|
|
|
|
+ template: '<div class="medialib">' +
|
|
|
|
+ '<div class="mt3">' +
|
|
|
|
+ '<div class="w-30 dib v-top ph4 pv3">' +
|
|
|
|
+ '<button class="f6 link br0 ba ph3 pv2 mb2 w-100 dim white bn bg-tm-red" @click.prevent="closemedialib()">{{ $t(\'close library\') }}</button>' +
|
|
|
|
+ '<div class="w-100 relative">' +
|
|
|
|
+ '<div><input v-model="search" class="w-100 border-box pa2 mb3 br0 ba b--light-silver"><svg class="icon icon-search absolute top-1 right-1 pa1 gray"><use xlink:href="#icon-search"></use></svg></div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<button @click.prevent="showImages()" class="link br0 ba ph3 pv2 mv2 mr1" :class="isImagesActive()">Images</button>' +
|
|
|
|
+ '<button @click.prevent="showFiles()" class="link br0 ba ph3 pv2 mv2 ml1" :class="isFilesActive()">Files</button>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<div class="w-70 dib v-top center">' +
|
|
|
|
+ '<div v-if="errors" class="w-95 mv3 white bg-tm-red tc f5 lh-copy pa3">{{errors}}</div>' +
|
|
|
|
+ '<transition-group name="list">' +
|
|
|
|
+ '<div class="w-29 ma3 dib v-top bg-white shadow-tm overflow-hidden" v-for="(image, index) in filteredImages" :key="image.name" v-if="showimages">' +
|
|
|
|
+ '<a href="#" @click.prevent="selectImage(image)" :style="getBackgroundImage(image)" class="link mw5 dt hide-child cover bg-center">' +
|
|
|
|
+ '<span class="white dtc v-mid center w-100 h-100 child bg-black-80 pa5"><svg class="icon icon-check baseline"><use xlink:href="#icon-check"></use></svg> click to select</span>' +
|
|
|
|
+ '</a>' +
|
|
|
|
+ '<div>' +
|
|
|
|
+ '<div class="w-70 dib v-top pl3 pv3 f6 truncate"><strong>{{ image.name }}</strong></div>' +
|
|
|
|
+ '<button @click.prevent="showImageDetails(image,index)" class="w-15 center dib link bn v-mid pv3 bg-white hover-bg-tm-green hover-white"><svg class="icon icon-info baseline"><use xlink:href="#icon-info"></use></svg></button>' +
|
|
|
|
+ '<button @click.prevent="deleteImage(image,index)" class="w-15 center dib link bn v-mid pv3 bg-white hover-bg-tm-red hover-white"><svg class="icon icon-trash-o baseline"><use xlink:href="#icon-trash-o"></use></svg></button>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</transition-group>' +
|
|
|
|
+ '<div class="w-95 dib v-top bg-white mv3 relative" v-if="showimagedetails">' +
|
|
|
|
+ '<div class="flex flex-wrap item-start">' +
|
|
|
|
+ '<div class="w-50">' +
|
|
|
|
+ '<div class="w6 h6 bg-black-40 dtc v-mid bg-chess">' +
|
|
|
|
+ '<img :src="imagedetaildata.src_live" class="mw6 max-h6 dt center">' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<div class="w-50 pa3 lh-copy f7 relative">' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">Name</div><div class="b">{{ imagedetaildata.name}}</div>' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">URL</div><div class="b">{{ imagedetaildata.src_live}}</div>' +
|
|
|
|
+ '<div class="flex flex-wrap item-start">' +
|
|
|
|
+ '<div class="w-50">' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">Size</div><div class="b">{{ getSize(imagedetaildata.bytes) }}</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<div class="w-50">' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">Dimensions</div><div class="b">{{ imagedetaildata.width }}x{{ imagedetaildata.height }} px</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<div class="w-50">' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">Type</div><div class="b">{{ imagedetaildata.type }}</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<div class="w-50">' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">Date</div><div class="b">{{ getDate(imagedetaildata.timestamp) }}</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<div class="absolute w-90 bottom-0 flex justify-between">' +
|
|
|
|
+ '<button @click.prevent="selectImage(imagedetaildata)" class="w-50 mr1 pa2 link bn bg-light-gray hover-bg-tm-green hover-white"><svg class="icon icon-check baseline"><use xlink:href="#icon-check"></use></svg> select</button>' +
|
|
|
|
+ '<button @click.prevent="deleteImage(imagedetaildata, detailindex)" class="w-50 ml1 pa2 link bn bg-light-gray hover-bg-tm-red hover-white"><svg class="icon icon-trash-o baseline"><use xlink:href="#icon-trash-o"></use></svg> delete</button>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<button class="f7 link br0 ba ph3 pv2 dim white bn bg-tm-red absolute top-0 right-0" @click.prevent="showImages()">close details</button>' +
|
|
|
|
+ '<div class="pa3">' +
|
|
|
|
+ '<h4>Image used in:</h4>' +
|
|
|
|
+ '<ul class="ma0 pa0" v-if="imagedetaildata.pages && imagedetaildata.pages.length > 0">' +
|
|
|
|
+ '<li class="list pa1" v-for="page in imagedetaildata.pages">' +
|
|
|
|
+ '<a class="link tm-red" :href="baseurl + page">{{ page }}</a>' +
|
|
|
|
+ '</li>' +
|
|
|
|
+ '</ul>' +
|
|
|
|
+ '<div v-else>No pages found.</div>'+
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<transition-group name="list">' +
|
|
|
|
+ '<div class="w-29 ma3 dib v-top bg-white shadow-tm overflow-hidden" v-for="(file, index) in filteredFiles" :key="file.name" v-if="showfiles">' +
|
|
|
|
+ '<a href="#" @click.prevent="selectFile(file)" class="w-100 link cover bg-tm-green bg-center relative dt">' +
|
|
|
|
+ '<div class="absolute w-100 tc white f1 top-3 h0 ttu" v-html="file.info.extension"></div>' +
|
|
|
|
+ '<div class="link dt hide-child w-100">' +
|
|
|
|
+ '<span class="white dtc v-top center w-100 h-100 child pt6 pb3 tc"><svg class="icon icon-check baseline"><use xlink:href="#icon-check"></use></svg> click to select</span>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</a>' +
|
|
|
|
+ '<div>' +
|
|
|
|
+ '<div class="w-70 dib v-top pl3 pv3 f6 truncate"><strong>{{ file.name }}</strong></div>' +
|
|
|
|
+ '<button @click.prevent="showFileDetails(file,index)" class="w-15 center dib link bn v-mid pv3 bg-white hover-bg-tm-green hover-white"><svg class="icon icon-info baseline"><use xlink:href="#icon-info"></use></svg></button>' +
|
|
|
|
+ '<button @click.prevent="deleteFile(file,index)" class="w-15 center dib link bn v-mid pv3 bg-white hover-bg-tm-red hover-white"><svg class="icon icon-trash-o baseline"><use xlink:href="#icon-trash-o"></use></svg></button>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</transition-group>' +
|
|
|
|
+ '<div class="w-95 dib v-top bg-white mv3 relative" v-if="showfiledetails">' +
|
|
|
|
+ '<div class="flex flex-wrap item-start">' +
|
|
|
|
+ '<div class="w-50">' +
|
|
|
|
+ '<div class="w6 h6 bg-black-40 dtc v-mid bg-tm-green tc">' +
|
|
|
|
+ '<div class="w-100 dt center white f1 ttu">{{ filedetaildata.info.extension }}</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<div class="w-50 pa3 lh-copy f7 relative">' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">Name</div><div class="b">{{ filedetaildata.name}}</div>' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">URL</div><div class="b">{{ filedetaildata.url}}</div>' +
|
|
|
|
+ '<div class="flex flex-wrap item-start">' +
|
|
|
|
+ '<div class="w-50">' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">Size</div><div class="b">{{ getSize(filedetaildata.bytes) }}</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<div class="w-50">' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">Type</div><div class="b">{{ filedetaildata.info.extension }}</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<div class="w-50">' +
|
|
|
|
+ '<div class="black-30 mt3 mb1">Date</div><div class="b">{{ getDate(filedetaildata.timestamp) }}</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<div class="absolute w-90 bottom-0 flex justify-between">' +
|
|
|
|
+ '<button @click.prevent="selectFile(filedetaildata)" class="w-50 mr1 pa2 link bn bg-light-gray hover-bg-tm-green hover-white"><svg class="icon icon-check baseline"><use xlink:href="#icon-check"></use></svg> select</button>' +
|
|
|
|
+ '<button @click.prevent="deleteFile(filedetaildata, detailindex)" class="w-50 ml1 pa2 link bn bg-light-gray hover-bg-tm-red hover-white"><svg class="icon icon-trash-o baseline"><use xlink:href="#icon-trash-o"></use></svg> delete</button>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '<button class="f7 link br0 ba ph3 pv2 dim white bn bg-tm-red absolute top-0 right-0" @click.prevent="showFiles()">close details</button>' +
|
|
|
|
+ '<div class="pa3">' +
|
|
|
|
+ '<h4>File used in:</h4>' +
|
|
|
|
+ '<ul class="ma0 pa0" v-if="filedetaildata.pages && filedetaildata.pages.length > 0">' +
|
|
|
|
+ '<li class="list pa1" v-for="page in filedetaildata.pages">' +
|
|
|
|
+ '<a class="link tm-red" :href="baseurl + page">{{ page }}</a>' +
|
|
|
|
+ '</li>' +
|
|
|
|
+ '</ul>' +
|
|
|
|
+ '<div v-else>No pages found.</div>'+
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>' +
|
|
|
|
+ '</div>',
|
|
|
|
+ data: function(){
|
|
|
|
+ return {
|
|
|
|
+ imagedata: false,
|
|
|
|
+ showimages: true,
|
|
|
|
+ imagedetaildata: false,
|
|
|
|
+ showimagedetails: false,
|
|
|
|
+ filedata: false,
|
|
|
|
+ showfiles: false,
|
|
|
|
+ filedetaildata: false,
|
|
|
|
+ showfiledetails: false,
|
|
|
|
+ detailindex: false,
|
|
|
|
+ load: false,
|
|
|
|
+ baseurl: false,
|
|
|
|
+ search: '',
|
|
|
|
+ errors: false,
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ mounted: function(){
|
|
|
|
+
|
|
|
|
+ if(this.parentcomponent == 'files')
|
|
|
|
+ {
|
|
|
|
+ this.showFiles();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.errors = false;
|
|
|
|
+ var self = this;
|
|
|
|
+
|
|
|
|
+ myaxios.get('/api/v1/medialib/images',{
|
|
|
|
+ params: {
|
|
|
|
+ 'url': document.getElementById("path").value,
|
|
|
|
+ 'csrf_name': document.getElementById("csrf_name").value,
|
|
|
|
+ 'csrf_value': document.getElementById("csrf_value").value,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .then(function (response)
|
|
|
|
+ {
|
|
|
|
+ self.imagedata = response.data.images;
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ if(error.response)
|
|
|
|
+ {
|
|
|
|
+ self.errors = error.response.data.errors;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ computed: {
|
|
|
|
+ filteredImages() {
|
|
|
|
+
|
|
|
|
+ var searchimages = this.search;
|
|
|
|
+ var filteredImages = {};
|
|
|
|
+ var images = this.imagedata;
|
|
|
|
+ Object.keys(images).forEach(function(key) {
|
|
|
|
+ var searchindex = key + ' ' + images[key].name;
|
|
|
|
+ if(searchindex.toLowerCase().indexOf(searchimages.toLowerCase()) !== -1)
|
|
|
|
+ {
|
|
|
|
+ filteredImages[key] = images[key];
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return filteredImages;
|
|
|
|
+ },
|
|
|
|
+ filteredFiles() {
|
|
|
|
+
|
|
|
|
+ var searchfiles = this.search;
|
|
|
|
+ var filteredFiles = {};
|
|
|
|
+ var files = this.filedata;
|
|
|
|
+ Object.keys(files).forEach(function(key) {
|
|
|
|
+ var searchindex = key + ' ' + files[key].name;
|
|
|
|
+ if(searchindex.toLowerCase().indexOf(searchfiles.toLowerCase()) !== -1)
|
|
|
|
+ {
|
|
|
|
+ filteredFiles[key] = files[key];
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ return filteredFiles;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ methods: {
|
|
|
|
+ isImagesActive: function()
|
|
|
|
+ {
|
|
|
|
+ if(this.showimages)
|
|
|
|
+ {
|
|
|
|
+ return 'bg-tm-green white';
|
|
|
|
+ }
|
|
|
|
+ return 'bg-light-gray black';
|
|
|
|
+ },
|
|
|
|
+ isFilesActive: function()
|
|
|
|
+ {
|
|
|
|
+ if(this.showfiles)
|
|
|
|
+ {
|
|
|
|
+ return 'bg-tm-green white';
|
|
|
|
+ }
|
|
|
|
+ return 'bg-light-gray black';
|
|
|
|
+ },
|
|
|
|
+ closemedialib: function()
|
|
|
|
+ {
|
|
|
|
+ this.$parent.showmedialib = false;
|
|
|
|
+ },
|
|
|
|
+ getBackgroundImage: function(image)
|
|
|
|
+ {
|
|
|
|
+ return 'background-image: url(' + image.src_thumb + ');width:250px';
|
|
|
|
+ },
|
|
|
|
+ showImages: function()
|
|
|
|
+ {
|
|
|
|
+ this.errors = false;
|
|
|
|
+ this.showimages = true;
|
|
|
|
+ this.showfiles = false;
|
|
|
|
+ this.showimagedetails = false;
|
|
|
|
+ this.showfiledetails = false;
|
|
|
|
+ this.imagedetaildata = false;
|
|
|
|
+ this.detailindex = false;
|
|
|
|
+ },
|
|
|
|
+ showFiles: function()
|
|
|
|
+ {
|
|
|
|
+ this.showimages = false;
|
|
|
|
+ this.showfiles = true;
|
|
|
|
+ this.showimagedetails = false;
|
|
|
|
+ this.showfiledetails = false;
|
|
|
|
+ this.imagedetaildata = false;
|
|
|
|
+ this.filedetaildata = false;
|
|
|
|
+ this.detailindex = false;
|
|
|
|
+
|
|
|
|
+ if(!this.files)
|
|
|
|
+ {
|
|
|
|
+ this.errors = false;
|
|
|
|
+ var filesself = this;
|
|
|
|
+
|
|
|
|
+ myaxios.get('/api/v1/medialib/files',{
|
|
|
|
+ params: {
|
|
|
|
+ 'url': document.getElementById("path").value,
|
|
|
|
+ 'csrf_name': document.getElementById("csrf_name").value,
|
|
|
|
+ 'csrf_value': document.getElementById("csrf_value").value,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .then(function (response)
|
|
|
|
+ {
|
|
|
|
+ filesself.filedata = response.data.files;
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ if(error.response)
|
|
|
|
+ {
|
|
|
|
+ filesself.errors = error.response.data.errors;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ showImageDetails: function(image,index)
|
|
|
|
+ {
|
|
|
|
+ this.errors = false;
|
|
|
|
+ this.showimages = false;
|
|
|
|
+ this.showfiles = false;
|
|
|
|
+ this.showimagedetails = true;
|
|
|
|
+ this.detailindex = index;
|
|
|
|
+ this.baseurl = myaxios.defaults.baseURL + '/tm/content/visual';
|
|
|
|
+
|
|
|
|
+ var imageself = this;
|
|
|
|
+
|
|
|
|
+ myaxios.get('/api/v1/image',{
|
|
|
|
+ params: {
|
|
|
|
+ 'url': document.getElementById("path").value,
|
|
|
|
+ 'name': image.name,
|
|
|
|
+ 'csrf_name': document.getElementById("csrf_name").value,
|
|
|
|
+ 'csrf_value': document.getElementById("csrf_value").value,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .then(function (response)
|
|
|
|
+ {
|
|
|
|
+ imageself.imagedetaildata = response.data.image;
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ if(error.response)
|
|
|
|
+ {
|
|
|
|
+ imageself.errors = error.response.data.errors;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ showFileDetails: function(file,index)
|
|
|
|
+ {
|
|
|
|
+ this.errors = false;
|
|
|
|
+ this.showimages = false;
|
|
|
|
+ this.showfiles = false;
|
|
|
|
+ this.showimagedetails = false;
|
|
|
|
+ this.showfiledetails = true;
|
|
|
|
+ this.detailindex = index;
|
|
|
|
+
|
|
|
|
+ this.baseurl = myaxios.defaults.baseURL + '/tm/content/visual';
|
|
|
|
+
|
|
|
|
+ var fileself = this;
|
|
|
|
+
|
|
|
|
+ myaxios.get('/api/v1/file',{
|
|
|
|
+ params: {
|
|
|
|
+ 'url': document.getElementById("path").value,
|
|
|
|
+ 'name': file.name,
|
|
|
|
+ 'csrf_name': document.getElementById("csrf_name").value,
|
|
|
|
+ 'csrf_value': document.getElementById("csrf_value").value,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .then(function (response)
|
|
|
|
+ {
|
|
|
|
+ fileself.filedetaildata = response.data.file;
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ if(error.response)
|
|
|
|
+ {
|
|
|
|
+ fileself.errors = error.response.data.errors;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ selectImage: function(image)
|
|
|
|
+ {
|
|
|
|
+ this.showImages();
|
|
|
|
+
|
|
|
|
+ if(this.parentcomponent == 'images')
|
|
|
|
+ {
|
|
|
|
+ var imgmarkdown = {target: {value: '' }};
|
|
|
|
+
|
|
|
|
+ this.$parent.imgfile = image.src_live;
|
|
|
|
+ this.$parent.imgpreview = image.src_live;
|
|
|
|
+ this.$parent.imgmeta = true;
|
|
|
|
+
|
|
|
|
+ this.$parent.showmedialib = false;
|
|
|
|
+
|
|
|
|
+ this.$parent.updatemarkdown(imgmarkdown);
|
|
|
|
+ }
|
|
|
|
+ if(this.parentcomponent == 'files')
|
|
|
|
+ {
|
|
|
|
+ var filemarkdown = {target: {value: '[' + image.name + '](' + image.src_live +'){.tm-download}' }};
|
|
|
|
+
|
|
|
|
+ this.$parent.filemeta = true;
|
|
|
|
+ this.$parent.filetitle = image.name;
|
|
|
|
+
|
|
|
|
+ this.$parent.showmedialib = false;
|
|
|
|
+
|
|
|
|
+ this.$parent.updatemarkdown(filemarkdown);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ selectFile: function(file)
|
|
|
|
+ {
|
|
|
|
+ /* if image component is open */
|
|
|
|
+ if(this.parentcomponent == 'images')
|
|
|
|
+ {
|
|
|
|
+ var imgextensions = ['png','jpg', 'jpeg', 'gif', 'svg'];
|
|
|
|
+ if(imgextensions.indexOf(file.info.extension) == -1)
|
|
|
|
+ {
|
|
|
|
+ this.errors = "you cannot insert a file into an image component";
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ var imgmarkdown = {target: {value: '' }};
|
|
|
|
+
|
|
|
|
+ this.$parent.imgfile = file.url;
|
|
|
|
+ this.$parent.imgpreview = file.url;
|
|
|
|
+ this.$parent.imgmeta = true;
|
|
|
|
+
|
|
|
|
+ this.$parent.showmedialib = false;
|
|
|
|
+
|
|
|
|
+ this.$parent.updatemarkdown(imgmarkdown);
|
|
|
|
+ }
|
|
|
|
+ if(this.parentcomponent == 'files')
|
|
|
|
+ {
|
|
|
|
+ var filemarkdown = {target: {value: '['+ file.name +']('+ file.url +'){.tm-download file-' + file.info.extension + '}' }};
|
|
|
|
+
|
|
|
|
+ this.$parent.showmedialib = false;
|
|
|
|
+
|
|
|
|
+ this.$parent.filemeta = true;
|
|
|
|
+ this.$parent.filetitle = file.info.filename + ' (' + file.info.extension.toUpperCase() + ')';
|
|
|
|
+
|
|
|
|
+ this.$parent.updatemarkdown(filemarkdown);
|
|
|
|
+ }
|
|
|
|
+ this.showFiles();
|
|
|
|
+ },
|
|
|
|
+ removeImage: function(index)
|
|
|
|
+ {
|
|
|
|
+ this.imagedata.splice(index,1);
|
|
|
|
+ },
|
|
|
|
+ removeFile: function(index)
|
|
|
|
+ {
|
|
|
|
+ this.filedata.splice(index,1);
|
|
|
|
+ },
|
|
|
|
+ deleteImage: function(image, index)
|
|
|
|
+ {
|
|
|
|
+ imageself = this;
|
|
|
|
+
|
|
|
|
+ myaxios.delete('/api/v1/image',{
|
|
|
|
+ data: {
|
|
|
|
+ 'url': document.getElementById("path").value,
|
|
|
|
+ 'name': image.name,
|
|
|
|
+ 'index': index,
|
|
|
|
+ 'csrf_name': document.getElementById("csrf_name").value,
|
|
|
|
+ 'csrf_value': document.getElementById("csrf_value").value,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .then(function (response)
|
|
|
|
+ {
|
|
|
|
+ imageself.showImages();
|
|
|
|
+ imageself.removeImage(index);
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ if(error.response)
|
|
|
|
+ {
|
|
|
|
+ imageself.errors = error.response.data.errors;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ deleteFile: function(file, index)
|
|
|
|
+ {
|
|
|
|
+ fileself = this;
|
|
|
|
+
|
|
|
|
+ myaxios.delete('/api/v1/file',{
|
|
|
|
+ data: {
|
|
|
|
+ 'url': document.getElementById("path").value,
|
|
|
|
+ 'name': file.name,
|
|
|
|
+ 'index': index,
|
|
|
|
+ 'csrf_name': document.getElementById("csrf_name").value,
|
|
|
|
+ 'csrf_value': document.getElementById("csrf_value").value,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .then(function (response)
|
|
|
|
+ {
|
|
|
|
+ fileself.showFiles();
|
|
|
|
+ fileself.removeFile(index);
|
|
|
|
+ })
|
|
|
|
+ .catch(function (error)
|
|
|
|
+ {
|
|
|
|
+ if(error.response)
|
|
|
|
+ {
|
|
|
|
+ fileself.errors = error.response.data.errors;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ getDate(timestamp)
|
|
|
|
+ {
|
|
|
|
+ date = new Date(timestamp * 1000);
|
|
|
|
+
|
|
|
|
+ datevalues = {
|
|
|
|
+ 'year': date.getFullYear(),
|
|
|
|
+ 'month': date.getMonth()+1,
|
|
|
|
+ 'day': date.getDate(),
|
|
|
|
+ 'hour': date.getHours(),
|
|
|
|
+ 'minute': date.getMinutes(),
|
|
|
|
+ 'second': date.getSeconds(),
|
|
|
|
+ };
|
|
|
|
+ return datevalues.year + '-' + datevalues.month + '-' + datevalues.day;
|
|
|
|
+ },
|
|
|
|
+ getSize(bytes)
|
|
|
|
+ {
|
|
|
|
+ var i = Math.floor(Math.log(bytes) / Math.log(1024)),
|
|
|
|
+ sizes = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
|
|
+
|
|
|
|
+ return (bytes / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + sizes[i];
|
|
|
|
+ },
|
|
|
|
+ isChecked: function(classname)
|
|
|
|
+ {
|
|
|
|
+ if(this.imgclass == classname)
|
|
|
|
+ {
|
|
|
|
+ return ' checked';
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ },
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+
|
|
let activeFormats = [];
|
|
let activeFormats = [];
|
|
|
|
|
|
for(var i = 0; i < formatConfig.length; i++)
|
|
for(var i = 0; i < formatConfig.length; i++)
|
|
@@ -1576,11 +2300,13 @@ let editor = new Vue({
|
|
}, method, url, params);
|
|
}, method, url, params);
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- onStart: function(evt)
|
|
|
|
|
|
+ onStart: function()
|
|
{
|
|
{
|
|
|
|
+
|
|
},
|
|
},
|
|
moveBlock: function(evt)
|
|
moveBlock: function(evt)
|
|
{
|
|
{
|
|
|
|
+
|
|
var params = {
|
|
var params = {
|
|
'url': document.getElementById("path").value,
|
|
'url': document.getElementById("path").value,
|
|
'old_index': evt.oldIndex,
|
|
'old_index': evt.oldIndex,
|