diff --git a/frontend/src/components/FullHeightPage.vue b/frontend/src/components/FullHeightPage.vue index 95138ccb1..54ccbbb3a 100644 --- a/frontend/src/components/FullHeightPage.vue +++ b/frontend/src/components/FullHeightPage.vue @@ -1,12 +1,16 @@ diff --git a/frontend/src/components/Markdown/Page.vue b/frontend/src/components/Markdown/Page.vue index 33db920b2..9b2bb871a 100644 --- a/frontend/src/components/Markdown/Page.vue +++ b/frontend/src/components/Markdown/Page.vue @@ -34,6 +34,11 @@ + + @@ -43,7 +48,7 @@ import { MarkdownEditorMode } from '#imports'; const props = defineProps(makeMarkdownProps()); const emit = defineEmits(makeMarkdownEmits()); -const { editorView, markdownToolbarAttrs, markdownPreviewAttrs, onIntersect, focus, blur } = useMarkdownEditor({ +const { editorView, markdownToolbarAttrs, markdownStatusbarAttrs, markdownPreviewAttrs, onIntersect, focus, blur } = useMarkdownEditor({ props: computed(() => props), emit, extensions: markdownEditorPageExtensions(), diff --git a/frontend/src/components/Markdown/Statusbar.vue b/frontend/src/components/Markdown/Statusbar.vue index 6cd46bc50..343696ba2 100644 --- a/frontend/src/components/Markdown/Statusbar.vue +++ b/frontend/src/components/Markdown/Statusbar.vue @@ -1,12 +1,23 @@ @@ -15,8 +26,9 @@ import type { EditorState } from 'reportcreator-markdown/editor'; const props = defineProps<{ editorState: EditorState; - fileUploadEnabled: boolean; - fileUploadInProgress: boolean; + uploadFiles?: (files: FileList) => Promise; + fileUploadInProgress?: boolean; + disabled?: boolean; }>(); const currentLineNumber = computed(() => props.editorState.doc.lineAt(props.editorState.selection.main.head).number); @@ -41,20 +53,43 @@ const wordCount = computed(() => { return count; }); +const fileInput = ref(); +async function onUploadFiles(event: InputEvent) { + const files = (event.target as HTMLInputElement).files; + if (!files || !props.uploadFiles) { return; } + try { + await props.uploadFiles(files); + } finally { + if (fileInput.value) { + fileInput.value.value = null; + } + } +} + diff --git a/frontend/src/composables/markdown.ts b/frontend/src/composables/markdown.ts index 8cdc2efc3..65f4dce3d 100644 --- a/frontend/src/composables/markdown.ts +++ b/frontend/src/composables/markdown.ts @@ -444,8 +444,9 @@ export function useMarkdownEditorBase(options: { 'onUpdate:markdownEditorMode': (val: MarkdownEditorMode) => options.emit('update:markdownEditorMode', val), })); const markdownStatusbarAttrs = computed(() => ({ + disabled: options.props.value.disabled || options.props.value.readonly, editorState: editorState.value!, - fileUploadEnabled: fileUploadEnabled.value, + uploadFiles: fileUploadEnabled.value ? uploadFiles : undefined, fileUploadInProgress: fileUploadInProgress.value, })); const markdownPreviewAttrs = computed(() => ({