{"id":79998,"date":"2024-10-13T12:23:55","date_gmt":"2024-10-13T08:53:55","guid":{"rendered":"https:\/\/nabfollower.com\/blog\/using-react-ckeditor-5-with-djangodrf-4kp6\/"},"modified":"2024-10-13T12:23:55","modified_gmt":"2024-10-13T08:53:55","slug":"using-react-ckeditor-5-with-djangodrf-4kp6","status":"publish","type":"post","link":"https:\/\/nabfollower.com\/blog\/using-react-ckeditor-5-with-djangodrf-4kp6\/","title":{"rendered":"\u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 React CKEditor 5 \u0628\u0627 \u062c\u0646\u06af\u0648 (DRF)"},"content":{"rendered":"<p>Summarize this content to 400 words in Persian Lang \u0645\u06cc \u062e\u0648\u0627\u0633\u062a\u0645 \u0628\u0627 \u0634\u0645\u0627 \u062f\u0631 \u0645\u06cc\u0627\u0646 \u0628\u06af\u0630\u0627\u0631\u0645 \u06a9\u0647 \u0686\u06af\u0648\u0646\u0647 \u0627\u06cc\u0646 \u0645\u0634\u06a9\u0644 CKEditor \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0627\u062f\u0645 \u06a9\u0647 \u0645\u062f\u062a \u0647\u0627\u0633\u062a \u062f\u0631 \u06cc\u06a9\u06cc \u0627\u0632 \u067e\u0631\u0648\u0698\u0647 \u0647\u0627\u06cc\u0645 \u0631\u0648\u06cc \u0622\u0646 \u06a9\u0627\u0631 \u0645\u06cc \u06a9\u0631\u062f\u0645 \u0648 \u062f\u0631 \u0646\u0647\u0627\u06cc\u062a \u0645\u0648\u0641\u0642 \u0628\u0647 \u062d\u0644 \u0622\u0646 \u0634\u062f\u0645. \u0635\u0627\u062f\u0642\u0627\u0646\u0647 \u0628\u06af\u0648\u06cc\u0645\u060c \u0645\u0646 \u0646\u062a\u0648\u0627\u0646\u0633\u062a\u0645 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u06a9\u0627\u0641\u06cc \u06cc\u0627 \u0648\u0628\u0644\u0627\u06af \u062e\u0648\u0628\u06cc \u062f\u0631 \u0645\u0648\u0631\u062f \u0627\u06cc\u0646 \u0645\u0648\u0636\u0648\u0639 \u067e\u06cc\u062f\u0627 \u06a9\u0646\u0645. \u0628\u0647 \u0647\u0645\u06cc\u0646 \u062f\u0644\u06cc\u0644 \u0628\u0647 \u0641\u06a9\u0631 \u0627\u0641\u062a\u0627\u062f\u0645 \u06a9\u0647 \u06cc\u06a9 \u0648\u0628\u0644\u0627\u06af \u06a9\u0648\u0686\u06a9 \u0628\u0646\u0648\u06cc\u0633\u0645 \u06a9\u0647 \u0628\u0631\u0627\u06cc \u0634\u0645\u0627 \u0645\u0641\u0635\u0644 \u0648 \u0622\u0633\u0627\u0646 \u0628\u0627\u0634\u062f.<\/p>\n<p>\u0628\u0647 \u0637\u0648\u0631 \u0645\u0639\u0645\u0648\u0644\u060c \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0622\u0646 \u0686\u0646\u062f\u0627\u0646 \u062f\u0634\u0648\u0627\u0631 \u0646\u06cc\u0633\u062a\u060c \u0627\u0645\u0627 \u0642\u0633\u0645\u062a \u0622\u067e\u0644\u0648\u062f \u062a\u0635\u0648\u06cc\u0631 \u06a9\u0645\u06cc \u0645\u0631\u0627 \u0622\u0632\u0627\u0631 \u062f\u0627\u062f. \u0627\u0632 \u0622\u0646\u062c\u0627\u06cc\u06cc \u06a9\u0647 \u0633\u0639\u06cc \u0645\u06cc \u06a9\u0631\u062f\u0645 \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0631\u0627 \u0627\u0632 \u0637\u0631\u06cc\u0642 API \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u0645\u060c \u0645\u062a\u0648\u062c\u0647 \u0634\u062f\u0645 \u06a9\u0647 \u0628\u0627\u06cc\u062f \u06a9\u0645\u06cc \u0628\u0627 \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0628\u0627\u0632\u06cc \u06a9\u0646\u0645.<\/p>\n<p>\u067e\u0633 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u0628\u0628\u06cc\u0646\u06cc\u0645 \u0686\u06af\u0648\u0646\u0647 \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0627\u062f\u0645.<\/p>\n<p>\u067e\u06cc\u06a9\u0631\u0628\u0646\u062f\u06cc \u062c\u0646\u06af\u0648:<\/p>\n<p>\u0627\u0628\u062a\u062f\u0627 \u0628\u0627\u06cc\u062f \u0641\u0631\u06cc\u0645\u0648\u0631\u06a9 django rest \u0631\u0627 \u062f\u0627\u0646\u0644\u0648\u062f \u06a9\u0646\u06cc\u0645:<\/p>\n<p>pip install djangorestframework<\/p>\n<p>#settings.py<br \/>\nINSTALLED_APPS = [<br \/>\n    &#8230;<br \/>\n    &#8220;rest_framework&#8221;,<br \/>\n    &#8220;rest_framework.authtoken&#8221;,<br \/>\n]\n<p>REST_FRAMEWORK = {<br \/>\n    &#8216;DEFAULT_AUTHENTICATION_CLASSES&#8217;: [<br \/>\n        &#8216;rest_framework.authentication.TokenAuthentication&#8217;,<br \/>\n        &#8216;rest_framework.authentication.BasicAuthentication&#8217;,<br \/>\n    ]\n}<\/p>\n<p>\u0627\u0632 \u0622\u0646\u062c\u0627\u06cc\u06cc \u06a9\u0647 \u0645\u0627 \u0627\u0632 CKEditor \u062f\u0631 React \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u06a9\u0646\u06cc\u0645\u060c \u0628\u06cc\u0627\u06cc\u06cc\u062f \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0644\u0627\u0632\u0645 \u0631\u0627 \u0628\u0631\u0627\u06cc \u062c\u0644\u0648\u06af\u06cc\u0631\u06cc \u0627\u0632 \u062e\u0637\u0627\u0647\u0627\u06cc CORS \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u0645.<\/p>\n<p>pip install django-cors-headers<\/p>\n<p>#settings.py<br \/>\nINSTALLED_APPS = [<br \/>\n    &#8230;,<br \/>\n    &#8220;corsheaders&#8221;,<br \/>\n    &#8230;,<br \/>\n]\n<p>MIDDLEWARE = [<br \/>\n    &#8230;,<br \/>\n    &#8220;corsheaders.middleware.CorsMiddleware&#8221;,<br \/>\n    &#8220;django.middleware.common.CommonMiddleware&#8221;,<br \/>\n    &#8230;,<br \/>\n]\n<p>#localhost:5173 my react app url<br \/>\nCSRF_TRUSTED_ORIGINS = [&#8220;http:\/\/localhost:5173&#8221;]\nCORS_ORIGIN_WHITELIST = [<br \/>\n    &#8220;http:\/\/localhost:5173&#8221;,<br \/>\n]\nCORS_ORIGIN_ALLOW_ALL = False<br \/>\nCORS_ALLOW_CREDENTIALS = True<br \/>\nCORS_ALLOW_METHODS = [<br \/>\n    &#8220;DELETE&#8221;,<br \/>\n    &#8220;GET&#8221;,<br \/>\n    &#8220;OPTIONS&#8221;,<br \/>\n    &#8220;PATCH&#8221;,<br \/>\n    &#8220;POST&#8221;,<br \/>\n    &#8220;PUT&#8221;,<br \/>\n]\n<p>CORS_ALLOW_HEADERS = [<br \/>\n    &#8220;accept&#8221;,<br \/>\n    &#8220;accept-encoding&#8221;,<br \/>\n    &#8220;authorization&#8221;,<br \/>\n    &#8220;content-type&#8221;,<br \/>\n    &#8220;dnt&#8221;,<br \/>\n    &#8220;origin&#8221;,<br \/>\n    &#8220;user-agent&#8221;,<br \/>\n    &#8220;x-csrftoken&#8221;,<br \/>\n    &#8220;x-requested-with&#8221;,<br \/>\n    &#8220;token&#8221;,<br \/>\n]\n<p>\u062d\u0627\u0644\u0627 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0644\u0627\u0632\u0645 \u0631\u0627 \u0628\u0631\u0627\u06cc CKEditor \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u0645. \u0647\u0645 \u0628\u0631\u0627\u06cc \u0639\u0645\u0644\u06a9\u0631\u062f \u06a9\u0627\u0631\u0628\u0631 \u0648 \u0647\u0645 \u0628\u0631\u0627\u06cc \u062a\u0648\u0633\u0639\u0647 \u062f\u0647\u0646\u062f\u0647\u060c \u0645\u0646 \u0645\u06cc \u062e\u0648\u0627\u0633\u062a\u0645 \u0627\u0632 CKEditor \u062f\u0631 \u062e\u0648\u062f \u062c\u0646\u06af\u0648 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u0645. \u062a\u0646\u0638\u06cc\u0645\u0627\u062a\u06cc \u06a9\u0647 \u0645\u0627 \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0627\u062f\u06cc\u0645 \u0628\u0631\u0627\u06cc \u062a\u0639\u06cc\u06cc\u0646 \u0645\u0633\u06cc\u0631 \u0632\u0645\u0627\u0646\u06cc \u0627\u0633\u062a \u06a9\u0647 \u06a9\u0627\u0631\u0628\u0631 \u062a\u0635\u0648\u06cc\u0631\u06cc \u0631\u0627 \u062f\u0631 \u0633\u0645\u062a React \u0622\u067e\u0644\u0648\u062f \u0645\u06cc \u06a9\u0646\u062f \u0648 \u0627\u0637\u0645\u06cc\u0646\u0627\u0646 \u062d\u0627\u0635\u0644 \u0645\u06cc \u06a9\u0646\u062f \u06a9\u0647 \u062c\u0646\u06af\u0648 \u0627\u06cc\u0646 \u0627\u062c\u0627\u0632\u0647 \u0631\u0627 \u0645\u06cc \u062f\u0647\u062f.<\/p>\n<p>#settings.py<br \/>\nINSTALLED_APPS = [<br \/>\n    &#8230;,<br \/>\n    &#8220;ckeditor&#8221;,<br \/>\n    &#8220;ckeditor_uploader&#8221;,<br \/>\n    &#8230;,<br \/>\n]\n<p>CKEDITOR_UPLOAD_PATH = &#8220;uploads\/&#8221;<br \/>\nCKEDITOR_IMAGE_BACKEND = &#8220;pillow&#8221;<br \/>\nCKEDITOR_STORAGE_BACKEND = &#8216;django.core.files.storage.FileSystemStorage&#8217;<br \/>\nCKEDITOR_CONFIGS = {<br \/>\n    &#8220;default&#8221;: {<br \/>\n        &#8220;filebrowserImageUploadUrl&#8221;: &#8220;\/ckeditor\/upload\/&#8221;,<br \/>\n    },<br \/>\n}<\/p>\n<p>#urls.py:<br \/>\nfrom django.urls import path, include<br \/>\nfrom django.conf import settings<br \/>\nfrom django.conf.urls.static import static<\/p>\n<p>urlpatterns = [<br \/>\n    path(&#8220;ckeditor\/upload\/&#8221;, uploadFile, name=&#8221;ckeditor_upload&#8221;),<br \/>\n    path(&#8220;ckeditor\/&#8221;, include(&#8220;ckeditor_uploader.urls&#8221;)),<br \/>\n]\n<p>urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)<br \/>\nurlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)<\/p>\n<p>\u0645\u0627 \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u062e\u0648\u062f \u0631\u0627 \u062f\u0631 \u062c\u0646\u06af\u0648 \u0628\u0647 \u067e\u0627\u06cc\u0627\u0646 \u0631\u0633\u0627\u0646\u062f\u06cc\u0645\u060c \u0627\u06a9\u0646\u0648\u0646 \u0628\u0647 \u0642\u0633\u0645\u062a \u0627\u0635\u0644\u06cc \u06cc\u0639\u0646\u06cc React \u0645\u06cc \u0631\u0648\u06cc\u0645.<\/p>\n<p>\u0627\u0628\u062a\u062f\u0627 \u0627\u062c\u0627\u0632\u0647 \u062f\u0647\u06cc\u062f CKEditor-u \u0631\u0627 \u062f\u0631 \u067e\u0631\u0648\u0698\u0647 \u062e\u0648\u062f \u0642\u0631\u0627\u0631 \u062f\u0647\u06cc\u0645.<\/p>\n<p>npm install &#8211;save @ckeditor\/ckeditor5-react @ckeditor\/ckeditor5-build-classic<\/p>\n<p>\/\/ AddBlog.jsx<br \/>\nimport React, { Component } from &#8216;react&#8217;;<br \/>\nimport { CKEditor } from &#8216;@ckeditor\/ckeditor5-react&#8217;;<br \/>\nimport ClassicEditor from &#8216;@ckeditor\/ckeditor5-build-classic&#8217;;<\/p>\n<p>\u062e\u0648\u0628\u060c \u0645\u0627 \u062f\u0631 \u0648\u0627\u0642\u0639 \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u0645 \u0627\u0632 CKEditor \u0628\u0627 \u0627\u06cc\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u0645\u060c \u0627\u0645\u0627 \u0628\u0631\u0627\u06cc \u0622\u067e\u0644\u0648\u062f \u062a\u0635\u0627\u0648\u06cc\u0631 \u0628\u0627\u06cc\u062f \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\u06cc \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u0645.<\/p>\n<p>\u0627\u0628\u062a\u062f\u0627 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u06cc\u06a9 \u06a9\u0627\u0645\u067e\u0648\u0646\u0646\u062a \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u0645 \u0648 \u06a9\u062f\u0647\u0627\u06cc \u0644\u0627\u0632\u0645 \u0631\u0627 \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u0628\u0646\u0648\u06cc\u0633\u06cc\u0645.<\/p>\n<p>\/\/ components\/CustomUploadAdapter.jsx<br \/>\nclass CustomUploadAdapter {<br \/>\n  constructor(loader) {<br \/>\n    this.loader = loader;<br \/>\n    this.url=&#8221;http:\/\/127.0.0.1:8000\/ckeditor\/upload\/&#8221;; \/\/ Here we define the path we specified in django<br \/>\n  }<\/p>\n<p>  upload() {<br \/>\n    return this.loader.file.then(file =&gt; new Promise((resolve, reject) =&gt; {<br \/>\n      const data = new FormData();<br \/>\n      data.append(&#8216;upload&#8217;, file);<\/p>\n<p>      const token = localStorage.getItem(&#8216;token&#8217;);<\/p>\n<p>      if (!token) {<br \/>\n        reject(&#8216;No token found. User must be logged in to upload images.&#8217;);<br \/>\n        return;<br \/>\n      }<br \/>\n      fetch(this.url, {<br \/>\n        method: &#8216;POST&#8217;,<br \/>\n        body: data,<br \/>\n        headers: {<br \/>\n          &#8220;Authorization&#8221;: `Token ${token}`<br \/>\n        },<\/p>\n<p>      })<br \/>\n        .then((response) =&gt; response.json())<br \/>\n        .then(response =&gt; {<br \/>\n          if (response.url) {<br \/>\n            resolve({<br \/>\n              default: response.url<br \/>\n            });<br \/>\n          } else {<br \/>\n            reject(response.error ? response.error.message : &#8216;An error occurred while uploading the file.&#8217;);<br \/>\n          }<br \/>\n        })<br \/>\n        .catch(error =&gt; {<br \/>\n          reject(&#8216;An error occurred while uploading the file: &#8216; + error.message);<br \/>\n        });<br \/>\n    }));<br \/>\n  }<\/p>\n<p>  abort() {<br \/>\n    console.log(&#8216;Wasted&#8230;&#8217;);<br \/>\n  }<br \/>\n}<\/p>\n<p>export default CustomUploadAdapter;<\/p>\n<p>\u0628\u062e\u0634 \u0645\u0647\u0645\u06cc \u0627\u0632 \u0627\u06cc\u0646 \u06a9\u062f \u06a9\u0647 \u0628\u0627\u06cc\u062f \u0628\u0647 \u0622\u0646 \u062a\u0648\u062c\u0647 \u06a9\u0646\u06cc\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0635\u062d\u06cc\u062d \u0627\u0632 \u062a\u0648\u06a9\u0646 \u06a9\u0627\u0631\u0628\u0631 \u0648\u0627\u0631\u062f \u0634\u062f\u0647 \u0648 \u0645\u0634\u062e\u0635 \u06a9\u0631\u062f\u0646 \u0635\u062d\u06cc\u062d \u0622\u0646 \u0627\u0633\u062a. \u0627\u0632 \u0622\u0646\u062c\u0627\u06cc\u06cc \u06a9\u0647 \u062f\u0631 \u0633\u0627\u06cc\u062a \u0645\u0646 \u0642\u0633\u0645\u062a \u0648\u0631\u0648\u062f \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f\u060c \u0627\u06cc\u0646 \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0628\u0631 \u0627\u0633\u0627\u0633 \u0622\u0646 \u0646\u0648\u0634\u062a\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a.<\/p>\n<p>\u0639\u0627\u0644\u06cc\u060c \u0627\u06a9\u0646\u0648\u0646 \u062f\u0631 \u0622\u062e\u0631\u06cc\u0646 \u0642\u0633\u0645\u062a \u0647\u0633\u062a\u06cc\u0645\u060c \u0627\u06a9\u0646\u0648\u0646 \u06a9\u0647 \u062a\u0645\u0627\u0645 \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0644\u0627\u0632\u0645 \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0627\u062f\u0647 \u0627\u06cc\u0645\u060c \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u0645 \u0635\u0641\u062d\u0647 AddBlog \u0631\u0627 \u0628\u0647 \u0637\u0648\u0631 \u06a9\u0627\u0645\u0644 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u06a9\u0646\u06cc\u0645.<\/p>\n<p>\/\/ AddBlog.jsx<br \/>\nimport React, { Component } from &#8216;react&#8217;;<br \/>\nimport { CKEditor } from &#8216;@ckeditor\/ckeditor5-react&#8217;;<br \/>\nimport ClassicEditor from &#8216;@ckeditor\/ckeditor5-build-classic&#8217;;<br \/>\nimport CustomUploadAdapter from &#8216;..\/components\/CustomUploadAdapter&#8217;; \/\/ Let&#8217;s show the path to the Adapter code we prepared.<\/p>\n<p>const AddBlogs = () =&gt; {<\/p>\n<p>  const handleChange = (e) =&gt; {<br \/>\n    const { name, value } = e.target;<br \/>\n    setBlogData(prevState =&gt; ({<br \/>\n      &#8230;prevState,<br \/>\n      [name]: value<br \/>\n    }));<br \/>\n  };<\/p>\n<p>  const handleCkeditorState = (language, _event, editor) =&gt; {<br \/>\n    const data = editor.getData();<br \/>\n    setBlogData(prevState =&gt; ({<br \/>\n      &#8230;prevState,<br \/>\n      [`${language}_content`]: data<br \/>\n    }));<br \/>\n  };<\/p>\n<p>  const handleContentBeforeLoad = (content) =&gt; {<br \/>\n    const backendBaseURL = &#8216;http:\/\/127.0.0.1:8000&#8217;;<br \/>\n    return content.replace(\/src=&#8221;\\\/media\\\/(.*?)&#8221;\/g, `src=&#8221;${backendBaseURL}\/media\/$1&#8243;`);<br \/>\n  };<\/p>\n<p>  const onEditorInit = (editor) =&gt; {<br \/>\n    editor.plugins.get(&#8216;FileRepository&#8217;).createUploadAdapter = (loader) =&gt; {<br \/>\n      return new CustomUploadAdapter(loader);<br \/>\n    };<br \/>\n  };<\/p>\n<p>  return (<br \/>\n    &lt;div className=&#8221;addblog&#8221;&gt;<br \/>\n      &lt;h2&gt;{id ? &#8216;Blog Update&#8217; : &#8216;Add new blog&#8217;}&lt;\/h2&gt;<br \/>\n      &lt;form onSubmit={handleSubmit}&gt;<br \/>\n        &lt;div&gt;<br \/>\n          &lt;label htmlFor=&#8221;en_content&#8221;&gt;En Content:&lt;\/label&gt;<br \/>\n          &lt;CKEditor<br \/>\n            editor={ClassicEditor}<br \/>\n            data={handleContentBeforeLoad(blogData.en_content)}<br \/>\n            onChange={(event, editor) =&gt; handleCkeditorState(&#8216;en&#8217;, event, editor)}<br \/>\n            onReady={onEditorInit}<br \/>\n            config={{<br \/>\n              extraPlugins: [CustomUploadAdapter],<br \/>\n              ckfinder: {<br \/>\n                uploadUrl: &#8216;http:\/\/127.0.0.1:8000\/ckeditor\/upload\/&#8217;<br \/>\n              }<br \/>\n            }}<br \/>\n          \/&gt;<br \/>\n        &lt;\/div&gt;<\/p>\n<p>        &lt;div className=&#8221;buttons&#8221;&gt;<br \/>\n          &lt;button id=&#8217;dashboard__submit__btn&#8217; type=&#8221;submit&#8221;&gt;{id ? &#8216;Update&#8217; : &#8216;Add&#8217;}&lt;\/button&gt;<br \/>\n          {id &amp;&amp; (<br \/>\n            &lt;button id=&#8217;dashboard__delete__btn&#8217; type=&#8221;button&#8221; onClick={handleDelete}&gt;&lt;i className=&#8221;fa-solid fa-trash&#8221;&gt;&lt;\/i&gt;&lt;\/button&gt;<br \/>\n          )}<br \/>\n        &lt;\/div&gt;<br \/>\n      &lt;\/form&gt;<br \/>\n    &lt;\/div&gt;<br \/>\n  );<br \/>\n}<\/p>\n<p>export default AddBlogs;<\/p>\n<p>\u0646\u062a\u06cc\u062c\u0647 \u06af\u06cc\u0631\u06cc<\/p>\n<p>\u0644\u0627\u0632\u0645 \u0646\u06cc\u0633\u062a \u0646\u06af\u0631\u0627\u0646 \u0622\u0646 \u0628\u0627\u0634\u06cc\u062f\u060c \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0647 \u0631\u0627\u062d\u062a\u06cc \u0622\u0646 \u0631\u0627 \u067e\u06cc\u062f\u0627 \u06a9\u0646\u06cc\u062f \u0648 \u067e\u0633 \u0627\u0632 \u062c\u0633\u062a\u062c\u0648\u06cc \u062f\u0642\u06cc\u0642 \u0622\u0646 \u0631\u0627 \u062a\u0639\u0645\u06cc\u0631 \u06a9\u0646\u06cc\u062f. \u062d\u062f\u0627\u06a9\u062b\u0631\u060c \u062f\u0631 \u0645\u0648\u0631\u062f \u0627\u06cc\u0646\u06a9\u0647 \u06a9\u062f\u0627\u0645 \u0646\u0633\u062e\u0647 \u0627\u0632 \u0627\u0628\u0632\u0627\u0631\u0647\u0627 \u0646\u0627\u0633\u0627\u0632\u06af\u0627\u0631 \u0647\u0633\u062a\u0646\u062f\u060c \u062e\u0637\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u062e\u0648\u0627\u0647\u06cc\u062f \u06a9\u0631\u062f.<\/p>\n<p>\u0642\u0628\u0644 \u0627\u0632 \u0631\u0641\u062a\u0646&#8230; \u0627\u06af\u0631 \u0633\u0648\u0627\u0644\u06cc\/\u067e\u06cc\u0634\u0646\u0647\u0627\u062f\/\u0641\u06a9\u0631\u06cc \u062f\u0627\u0631\u06cc\u062f\u060c \u06cc\u06a9 \u062e\u0637 \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0631\u0627\u06cc \u0645\u0646 \u0628\u06af\u0630\u0627\u0631\u06cc\u062f. \ud83d\udd8b\ufe0f<\/p>\n<p>\u0648 \u0627\u06af\u0631 \u0627\u0632 \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0644\u0630\u062a \u0628\u0631\u062f\u06cc\u062f\u060c \u0628\u0627 \u06cc\u06a9 \u0627\u06cc\u0645\u0648\u062c\u06cc \u0632\u06cc\u0628\u0627 (\ud83e\udd2f\u2764\ufe0f\u200d\ud83d\udd25) \u0628\u0647 \u0645\u0627 \u0628\u06af\u0648\u06cc\u06cc\u062f \u0686\u0647 \u0627\u062d\u0633\u0627\u0633\u06cc \u062f\u0627\u0634\u062a\u06cc\u062f \u0648 \u0641\u0631\u0627\u0645\u0648\u0634 \u0646\u06a9\u0646\u06cc\u062f \u06a9\u0647 \u0628\u0631\u0627\u06cc \u0628\u0647\u200c\u0631\u0648\u0632\u0631\u0633\u0627\u0646\u06cc\u200c\u0647\u0627\u06cc \u0628\u0639\u062f\u06cc \u062f\u0646\u0628\u0627\u0644 \u06a9\u0646\u06cc\u062f.<\/p>\n<p>\u0627\u06cc\u0646 \u0627\u0632 \u0645\u0646 \u0627\u0633\u062a. \u0628\u0647 \u0632\u0648\u062f\u06cc \u0635\u062d\u0628\u062a \u062e\u0648\u0627\u0647\u06cc\u0645 \u06a9\u0631\u062f!<\/p>\n<p>&#8211; TheHormat \u265f\ufe0f<\/p>\n<p>\u0645\u06cc \u062e\u0648\u0627\u0633\u062a\u0645 \u0628\u0627 \u0634\u0645\u0627 \u062f\u0631 \u0645\u06cc\u0627\u0646 \u0628\u06af\u0630\u0627\u0631\u0645 \u06a9\u0647 \u0686\u06af\u0648\u0646\u0647 \u0627\u06cc\u0646 \u0645\u0634\u06a9\u0644 CKEditor \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0627\u062f\u0645 \u06a9\u0647 \u0645\u062f\u062a \u0647\u0627\u0633\u062a \u062f\u0631 \u06cc\u06a9\u06cc \u0627\u0632 \u067e\u0631\u0648\u0698\u0647 \u0647\u0627\u06cc\u0645 \u0631\u0648\u06cc \u0622\u0646 \u06a9\u0627\u0631 \u0645\u06cc \u06a9\u0631\u062f\u0645 \u0648 \u062f\u0631 \u0646\u0647\u0627\u06cc\u062a \u0645\u0648\u0641\u0642 \u0628\u0647 \u062d\u0644 \u0622\u0646 \u0634\u062f\u0645. \u0635\u0627\u062f\u0642\u0627\u0646\u0647 \u0628\u06af\u0648\u06cc\u0645\u060c \u0645\u0646 \u0646\u062a\u0648\u0627\u0646\u0633\u062a\u0645 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u06a9\u0627\u0641\u06cc \u06cc\u0627 \u0648\u0628\u0644\u0627\u06af \u062e\u0648\u0628\u06cc \u062f\u0631 \u0645\u0648\u0631\u062f \u0627\u06cc\u0646 \u0645\u0648\u0636\u0648\u0639 \u067e\u06cc\u062f\u0627 \u06a9\u0646\u0645. \u0628\u0647 \u0647\u0645\u06cc\u0646 \u062f\u0644\u06cc\u0644 \u0628\u0647 \u0641\u06a9\u0631 \u0627\u0641\u062a\u0627\u062f\u0645 \u06a9\u0647 \u06cc\u06a9 \u0648\u0628\u0644\u0627\u06af \u06a9\u0648\u0686\u06a9 \u0628\u0646\u0648\u06cc\u0633\u0645 \u06a9\u0647 \u0628\u0631\u0627\u06cc \u0634\u0645\u0627 \u0645\u0641\u0635\u0644 \u0648 \u0622\u0633\u0627\u0646 \u0628\u0627\u0634\u062f.<\/p>\n<p>\u0628\u0647 \u0637\u0648\u0631 \u0645\u0639\u0645\u0648\u0644\u060c \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0622\u0646 \u0686\u0646\u062f\u0627\u0646 \u062f\u0634\u0648\u0627\u0631 \u0646\u06cc\u0633\u062a\u060c \u0627\u0645\u0627 \u0642\u0633\u0645\u062a \u0622\u067e\u0644\u0648\u062f \u062a\u0635\u0648\u06cc\u0631 \u06a9\u0645\u06cc \u0645\u0631\u0627 \u0622\u0632\u0627\u0631 \u062f\u0627\u062f. \u0627\u0632 \u0622\u0646\u062c\u0627\u06cc\u06cc \u06a9\u0647 \u0633\u0639\u06cc \u0645\u06cc \u06a9\u0631\u062f\u0645 \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0631\u0627 \u0627\u0632 \u0637\u0631\u06cc\u0642 API \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u0645\u060c \u0645\u062a\u0648\u062c\u0647 \u0634\u062f\u0645 \u06a9\u0647 \u0628\u0627\u06cc\u062f \u06a9\u0645\u06cc \u0628\u0627 \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0628\u0627\u0632\u06cc \u06a9\u0646\u0645.<\/p>\n<p>\u067e\u0633 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u0628\u0628\u06cc\u0646\u06cc\u0645 \u0686\u06af\u0648\u0646\u0647 \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0627\u062f\u0645.<\/p>\n<p><\/p>\n<p>\u067e\u06cc\u06a9\u0631\u0628\u0646\u062f\u06cc \u062c\u0646\u06af\u0648:<\/p>\n<ol>\n<li>\u0627\u0628\u062a\u062f\u0627 \u0628\u0627\u06cc\u062f \u0641\u0631\u06cc\u0645\u0648\u0631\u06a9 django rest \u0631\u0627 \u062f\u0627\u0646\u0644\u0648\u062f \u06a9\u0646\u06cc\u0645:<\/li>\n<\/ol>\n<p><code>pip install djangorestframework<\/code>\n<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>#settings.py\nINSTALLED_APPS = [\n    ...\n    \"rest_framework\",\n    \"rest_framework.authtoken\",\n]\n\nREST_FRAMEWORK = {\n    'DEFAULT_AUTHENTICATION_CLASSES': [\n        'rest_framework.authentication.TokenAuthentication',\n        'rest_framework.authentication.BasicAuthentication',\n    ]\n}\n<\/code><\/pre>\n<\/div>\n<ol>\n<li>\u0627\u0632 \u0622\u0646\u062c\u0627\u06cc\u06cc \u06a9\u0647 \u0645\u0627 \u0627\u0632 CKEditor \u062f\u0631 React \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0645\u06cc \u06a9\u0646\u06cc\u0645\u060c \u0628\u06cc\u0627\u06cc\u06cc\u062f \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0644\u0627\u0632\u0645 \u0631\u0627 \u0628\u0631\u0627\u06cc \u062c\u0644\u0648\u06af\u06cc\u0631\u06cc \u0627\u0632 \u062e\u0637\u0627\u0647\u0627\u06cc CORS \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u0645.<\/li>\n<\/ol>\n<p><code>pip install django-cors-headers<\/code>\n<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>#settings.py\nINSTALLED_APPS = [\n    ...,\n    \"corsheaders\",\n    ...,\n]\n\nMIDDLEWARE = [\n    ...,\n    \"corsheaders.middleware.CorsMiddleware\",\n    \"django.middleware.common.CommonMiddleware\",\n    ...,\n]\n\n#localhost:5173 my react app url\nCSRF_TRUSTED_ORIGINS = [\"http:\/\/localhost:5173\"]\nCORS_ORIGIN_WHITELIST = [\n    \"http:\/\/localhost:5173\",\n]\nCORS_ORIGIN_ALLOW_ALL = False\nCORS_ALLOW_CREDENTIALS = True\nCORS_ALLOW_METHODS = [\n    \"DELETE\",\n    \"GET\",\n    \"OPTIONS\",\n    \"PATCH\",\n    \"POST\",\n    \"PUT\",\n]\n\nCORS_ALLOW_HEADERS = [\n    \"accept\",\n    \"accept-encoding\",\n    \"authorization\",\n    \"content-type\",\n    \"dnt\",\n    \"origin\",\n    \"user-agent\",\n    \"x-csrftoken\",\n    \"x-requested-with\",\n    \"token\",\n]\n<\/code><\/pre>\n<\/div>\n<ol>\n<li>\u062d\u0627\u0644\u0627 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0644\u0627\u0632\u0645 \u0631\u0627 \u0628\u0631\u0627\u06cc CKEditor \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u0645. \u0647\u0645 \u0628\u0631\u0627\u06cc \u0639\u0645\u0644\u06a9\u0631\u062f \u06a9\u0627\u0631\u0628\u0631 \u0648 \u0647\u0645 \u0628\u0631\u0627\u06cc \u062a\u0648\u0633\u0639\u0647 \u062f\u0647\u0646\u062f\u0647\u060c \u0645\u0646 \u0645\u06cc \u062e\u0648\u0627\u0633\u062a\u0645 \u0627\u0632 CKEditor \u062f\u0631 \u062e\u0648\u062f \u062c\u0646\u06af\u0648 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u0645. \u062a\u0646\u0638\u06cc\u0645\u0627\u062a\u06cc \u06a9\u0647 \u0645\u0627 \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0627\u062f\u06cc\u0645 \u0628\u0631\u0627\u06cc \u062a\u0639\u06cc\u06cc\u0646 \u0645\u0633\u06cc\u0631 \u0632\u0645\u0627\u0646\u06cc \u0627\u0633\u062a \u06a9\u0647 \u06a9\u0627\u0631\u0628\u0631 \u062a\u0635\u0648\u06cc\u0631\u06cc \u0631\u0627 \u062f\u0631 \u0633\u0645\u062a React \u0622\u067e\u0644\u0648\u062f \u0645\u06cc \u06a9\u0646\u062f \u0648 \u0627\u0637\u0645\u06cc\u0646\u0627\u0646 \u062d\u0627\u0635\u0644 \u0645\u06cc \u06a9\u0646\u062f \u06a9\u0647 \u062c\u0646\u06af\u0648 \u0627\u06cc\u0646 \u0627\u062c\u0627\u0632\u0647 \u0631\u0627 \u0645\u06cc \u062f\u0647\u062f.\n<\/li>\n<\/ol>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>#settings.py\nINSTALLED_APPS = [\n    ...,\n    \"ckeditor\",\n    \"ckeditor_uploader\",\n    ...,\n]\n\nCKEDITOR_UPLOAD_PATH = \"uploads\/\"\nCKEDITOR_IMAGE_BACKEND = \"pillow\"\nCKEDITOR_STORAGE_BACKEND = 'django.core.files.storage.FileSystemStorage'\nCKEDITOR_CONFIGS = {\n    \"default\": {\n        \"filebrowserImageUploadUrl\": \"\/ckeditor\/upload\/\",\n    },\n}\n\n\n#urls.py:\nfrom django.urls import path, include\nfrom django.conf import settings\nfrom django.conf.urls.static import static\n\nurlpatterns = [\n    path(\"ckeditor\/upload\/\", uploadFile, name=\"ckeditor_upload\"),\n    path(\"ckeditor\/\", include(\"ckeditor_uploader.urls\")),\n]\n\n\nurlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\nurlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)\n<\/code><\/pre>\n<\/div>\n<p>\u0645\u0627 \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u062e\u0648\u062f \u0631\u0627 \u062f\u0631 \u062c\u0646\u06af\u0648 \u0628\u0647 \u067e\u0627\u06cc\u0627\u0646 \u0631\u0633\u0627\u0646\u062f\u06cc\u0645\u060c \u0627\u06a9\u0646\u0648\u0646 \u0628\u0647 \u0642\u0633\u0645\u062a \u0627\u0635\u0644\u06cc \u06cc\u0639\u0646\u06cc React \u0645\u06cc \u0631\u0648\u06cc\u0645.<\/p>\n<p>\u0627\u0628\u062a\u062f\u0627 \u0627\u062c\u0627\u0632\u0647 \u062f\u0647\u06cc\u062f CKEditor-u \u0631\u0627 \u062f\u0631 \u067e\u0631\u0648\u0698\u0647 \u062e\u0648\u062f \u0642\u0631\u0627\u0631 \u062f\u0647\u06cc\u0645.<\/p>\n<p><code>npm install --save @ckeditor\/ckeditor5-react @ckeditor\/ckeditor5-build-classic<\/code>\n<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\/\/ AddBlog.jsx\nimport React, { Component } from 'react';\nimport { CKEditor } from '@ckeditor\/ckeditor5-react';\nimport ClassicEditor from '@ckeditor\/ckeditor5-build-classic';\n<\/code><\/pre>\n<\/div>\n<p>\u062e\u0648\u0628\u060c \u0645\u0627 \u062f\u0631 \u0648\u0627\u0642\u0639 \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u0645 \u0627\u0632 CKEditor \u0628\u0627 \u0627\u06cc\u0646 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u06a9\u0646\u06cc\u0645\u060c \u0627\u0645\u0627 \u0628\u0631\u0627\u06cc \u0622\u067e\u0644\u0648\u062f \u062a\u0635\u0627\u0648\u06cc\u0631 \u0628\u0627\u06cc\u062f \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0628\u06cc\u0634\u062a\u0631\u06cc \u0627\u0646\u062c\u0627\u0645 \u062f\u0647\u06cc\u0645.<\/p>\n<p>\u0627\u0628\u062a\u062f\u0627 \u0628\u06cc\u0627\u06cc\u06cc\u062f \u06cc\u06a9 \u06a9\u0627\u0645\u067e\u0648\u0646\u0646\u062a \u0627\u06cc\u062c\u0627\u062f \u06a9\u0646\u06cc\u0645 \u0648 \u06a9\u062f\u0647\u0627\u06cc \u0644\u0627\u0632\u0645 \u0631\u0627 \u062f\u0631 \u0627\u06cc\u0646\u062c\u0627 \u0628\u0646\u0648\u06cc\u0633\u06cc\u0645.\n<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\/\/ components\/CustomUploadAdapter.jsx\nclass CustomUploadAdapter {\n  constructor(loader) {\n    this.loader = loader;\n    this.url=\"http:\/\/127.0.0.1:8000\/ckeditor\/upload\/\"; \/\/ Here we define the path we specified in django\n  }\n\n  upload() {\n    return this.loader.file.then(file =&gt; new Promise((resolve, reject) =&gt; {\n      const data = new FormData();\n      data.append('upload', file);\n\n      const token = localStorage.getItem('token');\n\n      if (!token) {\n        reject('No token found. User must be logged in to upload images.');\n        return;\n      }\n      fetch(this.url, {\n        method: 'POST',\n        body: data,\n        headers: {\n          \"Authorization\": `Token ${token}`\n        },\n\n      })\n        .then((response) =&gt; response.json())\n        .then(response =&gt; {\n          if (response.url) {\n            resolve({\n              default: response.url \n            });\n          } else {\n            reject(response.error ? response.error.message : 'An error occurred while uploading the file.');\n          }\n        })\n        .catch(error =&gt; {\n          reject('An error occurred while uploading the file: ' + error.message);\n        });\n    }));\n  }\n\n  abort() {\n    console.log('Wasted...');\n  }\n}\n\nexport default CustomUploadAdapter;\n<\/code><\/pre>\n<\/div>\n<p>\u0628\u062e\u0634 \u0645\u0647\u0645\u06cc \u0627\u0632 \u0627\u06cc\u0646 \u06a9\u062f \u06a9\u0647 \u0628\u0627\u06cc\u062f \u0628\u0647 \u0622\u0646 \u062a\u0648\u062c\u0647 \u06a9\u0646\u06cc\u062f \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0635\u062d\u06cc\u062d \u0627\u0632 \u062a\u0648\u06a9\u0646 \u06a9\u0627\u0631\u0628\u0631 \u0648\u0627\u0631\u062f \u0634\u062f\u0647 \u0648 \u0645\u0634\u062e\u0635 \u06a9\u0631\u062f\u0646 \u0635\u062d\u06cc\u062d \u0622\u0646 \u0627\u0633\u062a. \u0627\u0632 \u0622\u0646\u062c\u0627\u06cc\u06cc \u06a9\u0647 \u062f\u0631 \u0633\u0627\u06cc\u062a \u0645\u0646 \u0642\u0633\u0645\u062a \u0648\u0631\u0648\u062f \u0648\u062c\u0648\u062f \u062f\u0627\u0631\u062f\u060c \u0627\u06cc\u0646 \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0628\u0631 \u0627\u0633\u0627\u0633 \u0622\u0646 \u0646\u0648\u0634\u062a\u0647 \u0634\u062f\u0647 \u0627\u0633\u062a.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/media.dev.to\/dynamic\/image\/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto\/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6gxne0ole4x3iyh0bpj8.gif\" alt=\"\u06a9\u0645\u06cc \u0637\u0648\u0644\u0627\u0646\u06cc \u0628\u0647 \u0646\u0638\u0631 \u0645\u06cc \u0631\u0633\u06cc\u062f\u061f \u0622\u0631\u0647 \u0631\u0627\u0633\u062a \u0645\u06cc\u06af\u06cc \u0628\u0647 \u0646\u0638\u0631 \u0645\u0646 \u0647\u0645 \u0647\u0645\u06cc\u0646\u0637\u0648\u0631 \u0628\u0648\u062f :D\" width=\"498\" height=\"254\" title=\"\"><\/p>\n<p>\u0639\u0627\u0644\u06cc\u060c \u0627\u06a9\u0646\u0648\u0646 \u062f\u0631 \u0622\u062e\u0631\u06cc\u0646 \u0642\u0633\u0645\u062a \u0647\u0633\u062a\u06cc\u0645\u060c \u0627\u06a9\u0646\u0648\u0646 \u06a9\u0647 \u062a\u0645\u0627\u0645 \u062a\u0646\u0638\u06cc\u0645\u0627\u062a \u0644\u0627\u0632\u0645 \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0627\u062f\u0647 \u0627\u06cc\u0645\u060c \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u0645 \u0635\u0641\u062d\u0647 AddBlog \u0631\u0627 \u0628\u0647 \u0637\u0648\u0631 \u06a9\u0627\u0645\u0644 \u0648\u06cc\u0631\u0627\u06cc\u0634 \u06a9\u0646\u06cc\u0645.\n<\/p>\n<div class=\"highlight js-code-highlight\">\n<pre class=\"highlight plaintext\"><code>\/\/ AddBlog.jsx\nimport React, { Component } from 'react';\nimport { CKEditor } from '@ckeditor\/ckeditor5-react';\nimport ClassicEditor from '@ckeditor\/ckeditor5-build-classic';\nimport CustomUploadAdapter from '..\/components\/CustomUploadAdapter'; \/\/ Let's show the path to the Adapter code we prepared.\n\nconst AddBlogs = () =&gt; {\n\n  const handleChange = (e) =&gt; {\n    const { name, value } = e.target;\n    setBlogData(prevState =&gt; ({\n      ...prevState,\n      [name]: value\n    }));\n  };\n\n  const handleCkeditorState = (language, _event, editor) =&gt; {\n    const data = editor.getData();\n    setBlogData(prevState =&gt; ({\n      ...prevState,\n      [`${language}_content`]: data\n    }));\n  };\n\n  const handleContentBeforeLoad = (content) =&gt; {\n    const backendBaseURL = 'http:\/\/127.0.0.1:8000';\n    return content.replace(\/src=\"\\\/media\\\/(.*?)\"\/g, `src=\"${backendBaseURL}\/media\/$1\"`);\n  };\n\n  const onEditorInit = (editor) =&gt; {\n    editor.plugins.get('FileRepository').createUploadAdapter = (loader) =&gt; {\n      return new CustomUploadAdapter(loader);\n    };\n  };\n\n\n  return (\n    &lt;div className=\"addblog\"&gt;\n      &lt;h2&gt;{id ? 'Blog Update' : 'Add new blog'}&lt;\/h2&gt;\n      &lt;form onSubmit={handleSubmit}&gt;\n        &lt;div&gt;\n          &lt;label htmlFor=\"en_content\"&gt;En Content:&lt;\/label&gt; \n          &lt;CKEditor\n            editor={ClassicEditor}\n            data={handleContentBeforeLoad(blogData.en_content)}\n            onChange={(event, editor) =&gt; handleCkeditorState('en', event, editor)}\n            onReady={onEditorInit}\n            config={{\n              extraPlugins: [CustomUploadAdapter],\n              ckfinder: {\n                uploadUrl: 'http:\/\/127.0.0.1:8000\/ckeditor\/upload\/'\n              }\n            }}\n          \/&gt;\n        &lt;\/div&gt;\n\n        &lt;div className=\"buttons\"&gt;\n          &lt;button id='dashboard__submit__btn' type=\"submit\"&gt;{id ? 'Update' : 'Add'}&lt;\/button&gt;\n          {id &amp;&amp; (\n            &lt;button id='dashboard__delete__btn' type=\"button\" onClick={handleDelete}&gt;&lt;i className=\"fa-solid fa-trash\"&gt;&lt;\/i&gt;&lt;\/button&gt;\n          )}\n        &lt;\/div&gt;\n      &lt;\/form&gt;\n    &lt;\/div&gt;\n  );\n}\n\nexport default AddBlogs;\n<\/code><\/pre>\n<\/div>\n<p><strong>\u0646\u062a\u06cc\u062c\u0647 \u06af\u06cc\u0631\u06cc<\/strong><\/p>\n<p>\u0644\u0627\u0632\u0645 \u0646\u06cc\u0633\u062a \u0646\u06af\u0631\u0627\u0646 \u0622\u0646 \u0628\u0627\u0634\u06cc\u062f\u060c \u0645\u06cc \u062a\u0648\u0627\u0646\u06cc\u062f \u0628\u0647 \u0631\u0627\u062d\u062a\u06cc \u0622\u0646 \u0631\u0627 \u067e\u06cc\u062f\u0627 \u06a9\u0646\u06cc\u062f \u0648 \u067e\u0633 \u0627\u0632 \u062c\u0633\u062a\u062c\u0648\u06cc \u062f\u0642\u06cc\u0642 \u0622\u0646 \u0631\u0627 \u062a\u0639\u0645\u06cc\u0631 \u06a9\u0646\u06cc\u062f. \u062d\u062f\u0627\u06a9\u062b\u0631\u060c \u062f\u0631 \u0645\u0648\u0631\u062f \u0627\u06cc\u0646\u06a9\u0647 \u06a9\u062f\u0627\u0645 \u0646\u0633\u062e\u0647 \u0627\u0632 \u0627\u0628\u0632\u0627\u0631\u0647\u0627 \u0646\u0627\u0633\u0627\u0632\u06af\u0627\u0631 \u0647\u0633\u062a\u0646\u062f\u060c \u062e\u0637\u0627 \u062f\u0631\u06cc\u0627\u0641\u062a \u062e\u0648\u0627\u0647\u06cc\u062f \u06a9\u0631\u062f.<\/p>\n<p>\u0642\u0628\u0644 \u0627\u0632 \u0631\u0641\u062a\u0646&#8230; \u0627\u06af\u0631 \u0633\u0648\u0627\u0644\u06cc\/\u067e\u06cc\u0634\u0646\u0647\u0627\u062f\/\u0641\u06a9\u0631\u06cc \u062f\u0627\u0631\u06cc\u062f\u060c \u06cc\u06a9 \u062e\u0637 \u0632\u06cc\u0631 \u0631\u0627 \u0628\u0631\u0627\u06cc \u0645\u0646 \u0628\u06af\u0630\u0627\u0631\u06cc\u062f. \ud83d\udd8b\ufe0f<\/p>\n<p>\u0648 \u0627\u06af\u0631 \u0627\u0632 \u0627\u06cc\u0646 \u06a9\u0627\u0631 \u0644\u0630\u062a \u0628\u0631\u062f\u06cc\u062f\u060c \u0628\u0627 \u06cc\u06a9 \u0627\u06cc\u0645\u0648\u062c\u06cc \u0632\u06cc\u0628\u0627 (\ud83e\udd2f\u2764\ufe0f\u200d\ud83d\udd25) \u0628\u0647 \u0645\u0627 \u0628\u06af\u0648\u06cc\u06cc\u062f \u0686\u0647 \u0627\u062d\u0633\u0627\u0633\u06cc \u062f\u0627\u0634\u062a\u06cc\u062f \u0648 \u0641\u0631\u0627\u0645\u0648\u0634 \u0646\u06a9\u0646\u06cc\u062f \u06a9\u0647 \u0628\u0631\u0627\u06cc \u0628\u0647\u200c\u0631\u0648\u0632\u0631\u0633\u0627\u0646\u06cc\u200c\u0647\u0627\u06cc \u0628\u0639\u062f\u06cc \u062f\u0646\u0628\u0627\u0644 \u06a9\u0646\u06cc\u062f.<\/p>\n<p>\u0627\u06cc\u0646 \u0627\u0632 \u0645\u0646 \u0627\u0633\u062a. \u0628\u0647 \u0632\u0648\u062f\u06cc \u0635\u062d\u0628\u062a \u062e\u0648\u0627\u0647\u06cc\u0645 \u06a9\u0631\u062f!<\/p>\n<p>&#8211; TheHormat \u265f\ufe0f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summarize this content to 400 words in Persian Lang \u0645\u06cc \u062e\u0648\u0627\u0633\u062a\u0645 \u0628\u0627 \u0634\u0645\u0627 \u062f\u0631 \u0645\u06cc\u0627\u0646 \u0628\u06af\u0630\u0627\u0631\u0645 \u06a9\u0647 \u0686\u06af\u0648\u0646\u0647 \u0627\u06cc\u0646 \u0645\u0634\u06a9\u0644 CKEditor \u0631\u0627 \u0627\u0646\u062c\u0627\u0645 \u062f\u0627\u062f\u0645 \u06a9\u0647 \u0645\u062f\u062a \u0647\u0627\u0633\u062a \u062f\u0631 \u06cc\u06a9\u06cc \u0627\u0632 \u067e\u0631\u0648\u0698\u0647 \u0647\u0627\u06cc\u0645 \u0631\u0648\u06cc \u0622\u0646 \u06a9\u0627\u0631 \u0645\u06cc \u06a9\u0631\u062f\u0645 \u0648 \u062f\u0631 \u0646\u0647\u0627\u06cc\u062a \u0645\u0648\u0641\u0642 \u0628\u0647 \u062d\u0644 \u0622\u0646 \u0634\u062f\u0645. \u0635\u0627\u062f\u0642\u0627\u0646\u0647 \u0628\u06af\u0648\u06cc\u0645\u060c \u0645\u0646 \u0646\u062a\u0648\u0627\u0646\u0633\u062a\u0645 \u0627\u0637\u0644\u0627\u0639\u0627\u062a \u06a9\u0627\u0641\u06cc \u06cc\u0627 \u0648\u0628\u0644\u0627\u06af \u062e\u0648\u0628\u06cc \u062f\u0631 &hellip;<\/p>\n","protected":false},"author":2,"featured_media":79999,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[339],"tags":[],"class_list":["post-79998","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev"],"_links":{"self":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/79998","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/comments?post=79998"}],"version-history":[{"count":0,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/posts\/79998\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media\/79999"}],"wp:attachment":[{"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/media?parent=79998"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/categories?post=79998"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nabfollower.com\/blog\/wp-json\/wp\/v2\/tags?post=79998"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}