WIP Allow for comment content to be submitted to backend

This commit is contained in:
2025-02-06 16:07:40 +01:00
parent 9aac80d834
commit 4047d5fd5b
6 changed files with 41 additions and 27 deletions

View File

@@ -1,7 +1,7 @@
<template>
<div>
<div>
<comment-editor :isSimple="globalState.isSimple" @toggle="toggleEditorMode"></comment-editor>
<comment-editor :isSimple="globalState.isSimple" @toggle="toggleEditorMode" @change="handleChange"></comment-editor>
</div>
</div>
</template>
@@ -15,14 +15,23 @@ export default defineComponent({
components: { CommentEditor },
setup() {
const globalState = inject('globalState');
const fieldName = inject('fieldName')
const toggleEditorMode = () => {
globalState.isSimple = !globalState.isSimple;
localStorage.setItem('editorMode', globalState.isSimple ? 'simple' : 'rich');
};
const handleChange = (newContent) => {
const hiddenField = document.querySelector(`input[name="${fieldName}"]`);
if (hiddenField) {
hiddenField.value = newContent || '';
}
};
return {
globalState,
toggleEditorMode
toggleEditorMode,
handleChange
};
}
});