TextNode | Correct merge of PlainEdit and image upload.
This commit is contained in:
parent
2361f0f6ed
commit
45922ac599
1 changed files with 38 additions and 3 deletions
|
@ -33,7 +33,8 @@
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
import ClassicEditor from '@ckeditor/ckeditor5-build-classic'
|
//import ClassicEditor from '@ckeditor/ckeditor5-build-classic'
|
||||||
|
import ClassicEditor from 'ckeditor5-build-classic-simple-upload-adapter-image-resize';
|
||||||
import CKEditor from '@ckeditor/ckeditor5-vue';
|
import CKEditor from '@ckeditor/ckeditor5-vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -43,9 +44,18 @@ export default {
|
||||||
editor: ClassicEditor,
|
editor: ClassicEditor,
|
||||||
editorData: '<p>Content of the editor.</p>',
|
editorData: '<p>Content of the editor.</p>',
|
||||||
editorConfig: {
|
editorConfig: {
|
||||||
|
extraPlugins: ['SimpleUploadAdapter'],
|
||||||
|
simpleUpload: {
|
||||||
|
uploadUrl: "/temp/image_upload/",
|
||||||
|
headers: {
|
||||||
|
"test":"testh"
|
||||||
|
},
|
||||||
|
withCredentials: true
|
||||||
|
}
|
||||||
// The configuration of the editor.
|
// The configuration of the editor.
|
||||||
},
|
},
|
||||||
editorShow: false,
|
editorShow: false,
|
||||||
|
plainEditShow: false,
|
||||||
editorComponent: CKEditor.component,
|
editorComponent: CKEditor.component,
|
||||||
currentText: "",// this.item.node.text.na_web,
|
currentText: "",// this.item.node.text.na_web,
|
||||||
originalText: "",// this.item.node.text.na_web,
|
originalText: "",// this.item.node.text.na_web,
|
||||||
|
@ -57,31 +67,56 @@ export default {
|
||||||
return {
|
return {
|
||||||
changed: this.currentText !== this.originalText,
|
changed: this.currentText !== this.originalText,
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
textId: function () {
|
||||||
|
console.log(this.create);
|
||||||
|
console.log(this.node.text.id);
|
||||||
|
if (this.create){
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
return this.node.text.id;
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
item: Object,
|
item: Object,
|
||||||
editorShow: Boolean,
|
editorShow: Boolean,
|
||||||
plainEditShow: Boolean,
|
|
||||||
create: Boolean,
|
create: Boolean,
|
||||||
where: String,
|
where: String,
|
||||||
refnode: Object
|
refnode: Object
|
||||||
},
|
},
|
||||||
mounted: function() {
|
mounted: function() {
|
||||||
//console.log("mounted");
|
//console.log("mounted");
|
||||||
|
this.editorConfig.simpleUpload.headers['X-CSRFToken'] = this.getCookie('csrftoken');
|
||||||
if (this.create){
|
if (this.create){
|
||||||
this.currentText = "";
|
this.currentText = "";
|
||||||
this.originalText = "";
|
this.originalText = "";
|
||||||
this.editorShow = true;
|
this.editorShow = true;
|
||||||
this.plainEditShow = false;
|
|
||||||
} else {
|
} else {
|
||||||
this.currentText = this.item.node.text.na_web;
|
this.currentText = this.item.node.text.na_web;
|
||||||
this.originalText = this.item.node.text.na_web;
|
this.originalText = this.item.node.text.na_web;
|
||||||
|
this.editorConfig.simpleUpload.headers.textId = this.item.node.text.id;
|
||||||
|
|
||||||
}
|
}
|
||||||
//this.getText();
|
//this.getText();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getCookie: function (name){
|
||||||
|
var cookieValue = null;
|
||||||
|
if (document.cookie && document.cookie != '') {
|
||||||
|
var cookies = document.cookie.split(';');
|
||||||
|
for (var i = 0; i < cookies.length; i++) {
|
||||||
|
var cookie = cookies[i].trim();
|
||||||
|
// Does this cookie string begin with the name we want?
|
||||||
|
|
||||||
|
if (cookie.substring(0, name.length + 1) == (name + '=')) {
|
||||||
|
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cookieValue;
|
||||||
|
},
|
||||||
getText: function() {
|
getText: function() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
console.log(this.item);
|
console.log(this.item);
|
||||||
|
|
Loading…
Reference in a new issue