aboutsummaryrefslogtreecommitdiff
path: root/front-end/src/views/Blog/ckeditor
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2023-12-16 02:40:03 -0500
committerLibravatar vnugent <public@vaughnnugent.com>2023-12-16 02:40:03 -0500
commit0d25abab798c005266a1c0b4eeba957d232d4328 (patch)
tree427bd36e33fcd4960e3a2bc7d73b77dc7779b214 /front-end/src/views/Blog/ckeditor
parent4b8ae76132d2342f40cec703b3d5145ea075c451 (diff)
move blog admin state to pinia store plugin
Diffstat (limited to 'front-end/src/views/Blog/ckeditor')
-rw-r--r--front-end/src/views/Blog/ckeditor/Editor.vue15
-rw-r--r--front-end/src/views/Blog/ckeditor/uploadAdapter.ts4
2 files changed, 8 insertions, 11 deletions
diff --git a/front-end/src/views/Blog/ckeditor/Editor.vue b/front-end/src/views/Blog/ckeditor/Editor.vue
index 5bbf1cb..e1ee2ce 100644
--- a/front-end/src/views/Blog/ckeditor/Editor.vue
+++ b/front-end/src/views/Blog/ckeditor/Editor.vue
@@ -76,18 +76,19 @@ import { tryOnMounted } from '@vueuse/shared';
import { apiCall } from '@vnuge/vnlib.browser';
import { Popover, PopoverButton, PopoverPanel, Switch } from '@headlessui/vue'
import { Converter } from 'showdown'
-import { BlogState } from '../blog-api'
import { useCkConfig } from './build.ts'
import { useUploadAdapter } from './uploadAdapter';
import ContentSearch from '../components/ContentSearch.vue';
+import { useStore } from '../../../store';
const emit = defineEmits(['change', 'load', 'mode-change'])
const props = defineProps<{
- blog: BlogState,
podcastMode: boolean
}>()
+const store = useStore()
+
let editor = {}
const propRefs = toRefs(props)
//Init new shodown converter
@@ -135,13 +136,9 @@ tryOnMounted(() => defer(() =>
//Load the editor once the component is mounted
apiCall(async ({ toaster }) => {
- //Entry script creates promise that resolves when the editor script is loaded
- if(window.editorLoadResult){
- //Wait for the editor script to load
- await (window.editorLoadResult as Promise<boolean>)
- }
+ await store.waitForEditor()
- if (!window['CKEDITOR']) {
+ if ('CKEDITOR' in window === false) {
toaster.general.error({
title: 'Script Error',
text: 'The CKEditor script failed to load, check script permissions.'
@@ -155,7 +152,7 @@ tryOnMounted(() => defer(() =>
//Init the ck config
const config = useCkConfig([
//Add the upload adapter
- useUploadAdapter(props.blog.content, apiCall, toaster.general)
+ useUploadAdapter(store.content, apiCall, toaster.general)
]);
//Init editor when loading is complete
diff --git a/front-end/src/views/Blog/ckeditor/uploadAdapter.ts b/front-end/src/views/Blog/ckeditor/uploadAdapter.ts
index 1c22842..74918b9 100644
--- a/front-end/src/views/Blog/ckeditor/uploadAdapter.ts
+++ b/front-end/src/views/Blog/ckeditor/uploadAdapter.ts
@@ -13,12 +13,12 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
-import { ComputedContent } from "@vnuge/cmnext-admin";
import { IToaster } from "@vnuge/vnlib.browser";
import { isNil } from "lodash-es";
import type { AxiosRequestConfig } from "axios";
import type { Editor } from "@ckeditor/ckeditor5-core";
import type { UploadAdapter, UploadResponse, FileLoader } from '@ckeditor/ckeditor5-upload'
+import { ContentStore } from "../../../store/cmnextAdminPlugin";
export type ApiCall = (callback: (data: any) => Promise<any>) => Promise<any>;
export type CKEditorPlugin = (editor: Editor) => void;
@@ -29,7 +29,7 @@ export type CKEditorPlugin = (editor: Editor) => void;
* @param apiCall A callback function that wraps the api call
* @returns A CKEditor plugin initializer
*/
-export const useUploadAdapter = (content: ComputedContent, apiCall: ApiCall, toaster?: IToaster): CKEditorPlugin =>{
+export const useUploadAdapter = (content: ContentStore, apiCall: ApiCall, toaster?: IToaster): CKEditorPlugin =>{
const createUploadAdapter = (loader: FileLoader): UploadAdapter => {