Skip to content

Commit

Permalink
ckeditor image uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
mrTimofey committed Feb 2, 2020
1 parent 59cffa6 commit 0f472dd
Show file tree
Hide file tree
Showing 62 changed files with 71 additions and 69 deletions.
8 changes: 1 addition & 7 deletions src/ckeditor-config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
/* eslint-disable camelcase */
export default {
ckfinder: {
uploadUrl: '/api/upload',
options: {
resourceType: 'Images',
},
},
heading: {
options: [
{ model: 'paragraph', title: 'Абзац', view: 'p' },
Expand Down Expand Up @@ -42,7 +36,7 @@ export default {
'outdent',
'|',
'mediaEmbed',
'CKFinder',
'imageUpload',
'|',
'undo',
'redo',
Expand Down
12 changes: 10 additions & 2 deletions src/components/fields/wysiwyg.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script>
import ckeConfig from 'src/ckeditor-config';
import { mapGetters } from 'vuex';
import { getApiToken } from 'src/http';
function loadCKEditor() {
return import(/* webpackChunkName: 'ckeditor5/editor' */ 'src/lib/ckeditor5/ckeditor').then(module => module.default);
Expand Down Expand Up @@ -43,11 +44,18 @@
loadCKEditor(),
loadLanguage(this.locale).catch(() => loadLanguage(this.fallbackLocale)),
]).then(([ClassicEditor, language]) => {
ClassicEditor.create(this.$refs.textarea, {
const config = {
language,
...ckeConfig,
...this.config,
}).then(editor => {
};
if (!config.simpleUpload) config.simpleUpload = {};
if (!config.simpleUpload.uploadUrl) config.simpleUpload.uploadUrl = apiRootPath + 'wysiwyg/images/upload';
if (!config.simpleUpload.headers) config.simpleUpload.headers = {};
if (!config.simpleUpload.headers.Authorization) config.simpleUpload.headers = {
Authorization: 'Bearer ' + getApiToken(),
};
ClassicEditor.create(this.$refs.textarea, config).then(editor => {
editor.setData(this.value || '');
editor.model.document.on('change:data', this.onChange);
editor.editing.view.document.on('focus', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/ckeditor5/ckeditor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/lib/ckeditor5/translations/af.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/lib/ckeditor5/translations/ar.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/lib/ckeditor5/translations/ast.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0f472dd

Please sign in to comment.