Browse Source

TreeNode editor | plain edit nefunkční

export_seznamu_prednasek
Kateřina Č 4 years ago
parent
commit
988388e9aa
  1. 46
      vue_frontend/src/components/TextNode.vue

46
vue_frontend/src/components/TextNode.vue

@ -5,17 +5,19 @@
<div v-else class="textnode"> <div v-else class="textnode">
<!--pre>TextNode {{item}} {{typeof(item)}}</pre--> <!--pre>TextNode {{item}} {{typeof(item)}}</pre-->
<div v-if="editorShow"> <div v-if="editorShow">
<component v-bind:is="editorComponent" :editor="editor" v-model="currentText" :config="editorConfig"></component>
<button v-on:click="plainEditShow=!plainEditShow">Editovat HTML</button>
<div v-if="plainEditShow"> <div v-if="plainEditShow">
<textarea id="textarea" v-model="currentText" rows="8" cols="50"></textarea> <textarea id="textarea" v-model="currentText" rows="8" cols="50"></textarea>
</div> </div>
<div v-else>
<component v-bind:is="editorComponent" :editor="editor" v-model="currentText" :config="editorConfig"></component>
<div>
<button v-on:click="plainEditShow=!plainEditShow">Editovat HTML</button>
<button v-on:click="saveText">Uložit</button> <button v-on:click="saveText">Uložit</button>
<button v-on:click="currentText = originalText;editorShow=!editorShow;">Zahodit úpravy</button> <button v-on:click="currentText = originalText;editorShow=!editorShow;">Zahodit úpravy</button>
</div> </div>
<div v-else v-bind:class="changedObject"> <div v-else v-bind:class="changedObject">
@ -28,8 +30,7 @@
<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 {
@ -39,14 +40,6 @@ 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,
@ -61,15 +54,6 @@ 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: {
@ -82,7 +66,6 @@ export default {
}, },
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 = "";
@ -91,28 +74,11 @@ export default {
} 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…
Cancel
Save