Skip to content

Commit 53207cf

Browse files
committed
Add tinymce editor
1 parent d55430c commit 53207cf

File tree

5 files changed

+473
-48
lines changed

5 files changed

+473
-48
lines changed

assets/vue/components/documents/FormNewDocument.vue

Lines changed: 66 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
11
<template>
2-
<q-form>
3-
<q-input
4-
id="item_title"
5-
v-model="item.title"
6-
:error="v$.item.title.$error"
7-
:error-message="titleErrors"
8-
:placeholder="$t('Title')"
9-
@input="v$.item.title.$touch()"
10-
@blur="v$.item.title.$touch()"
11-
/>
12-
13-
<editor
14-
id="item_content"
15-
v-if="(item.resourceNode && item.resourceNode.resourceFile && item.resourceNode.resourceFile.text) || item.newDocument"
16-
v-model="item.contentFile"
17-
:error-message="contentFileErrors"
18-
required
19-
:init="{
2+
<q-form>
3+
<q-input
4+
id="item_title"
5+
v-model="item.title"
6+
:error="v$.item.title.$error"
7+
:error-message="titleErrors"
8+
:placeholder="$t('Title')"
9+
@input="v$.item.title.$touch()"
10+
@blur="v$.item.title.$touch()"
11+
/>
12+
13+
<editor
14+
id="item_content"
15+
v-if="(item.resourceNode && item.resourceNode.resourceFile && item.resourceNode.resourceFile.text) || item.newDocument"
16+
v-model="item.contentFile"
17+
:error-message="contentFileErrors"
18+
required
19+
:init="{
2020
skin_url: '/build/libs/tinymce/skins/ui/oxide',
2121
content_css: '/build/libs/tinymce/skins/content/default/content.css',
22-
branding:false,
22+
branding: false,
23+
relative_urls: false,
2324
height: 500,
2425
toolbar_mode: 'sliding',
2526
file_picker_callback : browser,
2627
/*file_picker_callback: function(callback, value, meta) {
27-
// Provide file and text for the link dialog
28-
if (meta.filetype == 'file') {
29-
callback('mypage.html', {text: 'My text'});
30-
}
31-
32-
// Provide image and alt text for the image dialog
33-
if (meta.filetype == 'image') {
34-
callback('myimage.jpg', {alt: 'My alt text'});
35-
}
36-
37-
// Provide alternative source and posted for the media dialog
38-
if (meta.filetype == 'media') {
39-
callback('movie.mp4', {source2: 'alt.ogg', poster: 'image.jpg'});
40-
}
41-
},*/
42-
/*images_upload_handler: (blobInfo, success, failure) => {
43-
const img = 'data:image/jpeg;base64,' + blobInfo.base64();
44-
//console.log(img);
45-
success(img);
46-
},*/
28+
// Provide file and text for the link dialog
29+
if (meta.filetype == 'file') {
30+
callback('mypage.html', {text: 'My text'});
31+
}
32+
33+
// Provide image and alt text for the image dialog
34+
if (meta.filetype == 'image') {
35+
callback('myimage.jpg', {alt: 'My alt text'});
36+
}
37+
38+
// Provide alternative source and posted for the media dialog
39+
if (meta.filetype == 'media') {
40+
callback('movie.mp4', {source2: 'alt.ogg', poster: 'image.jpg'});
41+
}
42+
},*/
43+
/*images_upload_handler: (blobInfo, success, failure) => {
44+
const img = 'data:image/jpeg;base64,' + blobInfo.base64();
45+
//console.log(img);
46+
success(img);
47+
},*/
4748
//menubar: true,
4849
autosave_ask_before_unload: true,
4950
plugins: [
@@ -54,11 +55,10 @@
5455
toolbar: 'undo redo | bold italic underline strikethrough | fontselect fontsizeselect formatselect | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | pagebreak | charmap emoticons | fullscreen preview save print | insertfile image media template link anchor code codesample | ltr rtl',
5556
}
5657
"
57-
/>
58-
59-
<!-- For extra content-->
60-
<slot></slot>
61-
</q-form>
58+
/>
59+
<!-- For extra content-->
60+
<slot></slot>
61+
</q-form>
6262
</template>
6363

6464
<script>
@@ -67,6 +67,7 @@ import useVuelidate from '@vuelidate/core';
6767
import { required } from '@vuelidate/validators';
6868
//import UploadAdapter from './UploadAdapter';
6969
import Editor from '../Editor'
70+
import {useRouter} from "vue-router";
7071
7172
export default {
7273
name: 'DocumentsForm',
@@ -132,8 +133,28 @@ export default {
132133
},
133134
methods: {
134135
browser (callback, value, meta) {
136+
let url = '/resources/document/4/manager?cid=1&sid=0&gid=0';
137+
if (meta.filetype === 'image') {
138+
url = url + "&type=images";
139+
} else {
140+
url = url + "&type=files";
141+
}
142+
143+
console.log(url);
144+
145+
window.addEventListener('message', function (event) {
146+
var data = event.data;
147+
if (data.url) {
148+
url = data.url;
149+
console.log(meta); // {filetype: "image", fieldname: "src"}
150+
callback(url);
151+
152+
}
153+
});
154+
155+
135156
tinymce.activeEditor.windowManager.openUrl({
136-
url: '/',// use an absolute path!
157+
url: url,// use an absolute path!
137158
title: 'file manager',
138159
/*width: 900,
139160
height: 450,

assets/vue/router/documents.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ export default {
1010
path: '',
1111
component: () => import('../views/documents/List.vue')
1212
},
13+
{
14+
name: 'DocumentManager',
15+
path: 'manager',
16+
component: () => import('../views/documents/DocumentManager.vue'),
17+
meta: {
18+
layout: 'Empty'
19+
}
20+
},
1321
{
1422
name: 'DocumentsCreate',
1523
path: 'new',

assets/vue/router/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ const router = createRouter({
4242
path: '/courses', name: 'MyCourses', component: MyCourseList,
4343
meta: {requiresAuth: true},
4444
},
45-
4645
{
4746
path: '/sessions', name: 'MySessions', component: MySessionList,
4847
meta: {requiresAuth: true},

0 commit comments

Comments
 (0)