Got this error after uploading the image to my firebase server. the image is uploaded but the return request seem to be broken?
Uncaught (in promise) TypeError: Cannot read property 'default' of undefined
at Object.callback (imageuploadediting.js:242)
at Model._runPendingChanges (model.js:836)
at Model.enqueueChange (model.js:233)
at imageuploadediting.js:239
π Provide detailed reproduction steps (if any)
Press on image uploaded
Click on image you want to upload
When image is uploaded on the server, the error appear.
βοΈ Expected result
Image uploaded without any error onto my own firebase server.
β Actual result
Image uploaded WITH return error onto own firebase server.
π Other details
code:
import React, { Component, Fragment, useEffect, useContext, useState } from 'react';
import FBStorage from '../../firebase/storage';
import { UserContext } from "../../firebase/user";
import CKEditor from '@ckeditor/ckeditor5-react';
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor.js';
import Alignment from '@ckeditor/ckeditor5-alignment/src/alignment.js';
import Autoformat from '@ckeditor/ckeditor5-autoformat/src/autoformat.js';
import SimpleUploadAdapter from '@ckeditor/ckeditor5-upload/src/adapters/simpleuploadadapter';
import BlockQuote from '@ckeditor/ckeditor5-block-quote/src/blockquote.js';
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold.js';
import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials.js';
import Heading from '@ckeditor/ckeditor5-heading/src/heading.js';
import Image from '@ckeditor/ckeditor5-image/src/image.js';
import ImageCaption from '@ckeditor/ckeditor5-image/src/imagecaption.js';
import ImageResize from '@ckeditor/ckeditor5-image/src/imageresize.js';
import ImageStyle from '@ckeditor/ckeditor5-image/src/imagestyle.js';
import ImageToolbar from '@ckeditor/ckeditor5-image/src/imagetoolbar.js';
import ImageUpload from '@ckeditor/ckeditor5-image/src/imageupload.js';
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic.js';
import Link from '@ckeditor/ckeditor5-link/src/link.js';
import PasteFromOffice from '@ckeditor/ckeditor5-paste-from-office/src/pastefromoffice';
import TextTransformation from '@ckeditor/ckeditor5-typing/src/texttransformation.js';
const TEditor = ({onEditorStateChange, defaultValue}) => {
const { currentUser } = useContext(UserContext);
const [editorConfig , setEditorConfig] = useState(null);
useEffect(()=> {
loadSettting()
}, [])
const loadSettting = async () => {
const token = await currentUser.getIdToken()
console.log(token)
setEditorConfig({
plugins: [
Alignment,
Autoformat,
SimpleUploadAdapter,
BlockQuote,
Bold,
Essentials,
Heading,
Image,
ImageCaption,
ImageResize,
ImageStyle,
ImageToolbar,
ImageUpload,
Italic,
Link,
PasteFromOffice,
TextTransformation
],
toolbar: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'|',
'imageUpload',
'blockQuote',
'undo',
'redo'
],
language: 'en',
image: {
toolbar: [
'imageTextAlternative',
'imageStyle:full',
'imageStyle:side'
]
},
simpleUpload: {
// The URL that the images are uploaded to.
uploadUrl: 'https://firebasestorage.googleapis.com/v0/b/bucketname.appspot.com/o/images',
// Enable the XMLHttpRequest.withCredentials property.
withCredentials: false,
// Headers sent along with the XMLHttpRequest to the upload server.
headers: {
Authorization: 'Bearer ' + token
},
}
})
};
const onChange = (event, editor ) => {
const data = editor.getData();
console.log( data );
onEditorStateChange(data)
};
const onBlur = (event, editor) => {
console.log( 'Blur.', editor );
};
const onFocus = (event, editor) => {
// editor.config.simpleUpload.headers.Authorization = 'Bearer ' + idToken
console.log( 'Focus.', editor );
};
const onInit = (editor) => {
// editor
// You can store the "editor" and use when it is needed.
console.log( 'Editor is ready to use!', editor );
// editor.config.simpleUpload.headers.Authorization = 'Bearer ' + idToken
// ClassicEditor.builtinPlugins.map( plugin => console.log(plugin.pluginName) );
// editor.setEditorConfig()
};
return (
<div className="editor">
{/* <h2>Using CKEditor 5 build in React</h2> */}
{ editorConfig ?
<CKEditor
editor={ClassicEditor}
config={editorConfig}
data={defaultValue ? defaultValue : ""}
onInit={onInit}
onChange={onChange}
onBlur={onBlur}
onFocus={onFocus}
/>
: "loading"
}
</div>
);
}
export default TEditor;
Hi, we haven't tested the editor with Firebase, however, I can see that you use the simple upload adapter. Please, make sure that your back-end returns a correct response object.
Got this error after uploading the image to my firebase server. the image is uploaded but the return request seem to be broken?
π Provide detailed reproduction steps (if any)
βοΈ Expected result
Image uploaded without any error onto my own firebase server.
β Actual result
Image uploaded WITH return error onto own firebase server.
π Other details
code:
package.json