From cce0406db54ca51df586b43ead3d3f8e9e0ead9a Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 25 Oct 2022 19:01:26 +0200 Subject: [PATCH] Improve comments Closes #1171 Signed-off-by: Thomas Citharel --- js/src/assets/oruga-tailwindcss.css | 2 +- js/src/components/Comment/CommentTree.vue | 19 +- js/src/components/Comment/EventComment.vue | 421 ++++++------------ .../Editor/RichEditorKeyboardSubmit.ts | 22 + js/src/components/TextEditor.vue | 10 +- js/src/composition/apollo/config.ts | 2 +- js/src/i18n/en_US.json | 2 +- js/src/i18n/fr_FR.json | 2 +- 8 files changed, 183 insertions(+), 297 deletions(-) create mode 100644 js/src/components/Editor/RichEditorKeyboardSubmit.ts diff --git a/js/src/assets/oruga-tailwindcss.css b/js/src/assets/oruga-tailwindcss.css index e0e9830f..502d6741 100644 --- a/js/src/assets/oruga-tailwindcss.css +++ b/js/src/assets/oruga-tailwindcss.css @@ -142,7 +142,7 @@ body { } .dropdown-item-active { - @apply bg-white text-black; + @apply bg-white dark:bg-zinc-700 dark:text-zinc-100 text-black; } .dropdown-button { @apply inline-flex gap-1; diff --git a/js/src/components/Comment/CommentTree.vue b/js/src/components/Comment/CommentTree.vue index 22d73c1b..320c00b3 100644 --- a/js/src/components/Comment/CommentTree.vue +++ b/js/src/components/Comment/CommentTree.vue @@ -1,10 +1,9 @@ - diff --git a/js/src/components/Editor/RichEditorKeyboardSubmit.ts b/js/src/components/Editor/RichEditorKeyboardSubmit.ts new file mode 100644 index 00000000..e0c8d4b6 --- /dev/null +++ b/js/src/components/Editor/RichEditorKeyboardSubmit.ts @@ -0,0 +1,22 @@ +import { Extension } from "@tiptap/vue-3"; + +export interface RichEditorKeyboardSubmitOptions { + submit: () => void; +} + +export default Extension.create({ + name: "RichEditorKeyboardSubmit", + addOptions() { + return { + submit: () => ({}), + }; + }, + addKeyboardShortcuts() { + return { + "Ctrl-Enter": () => { + this.options.submit(); + return true; + }, + }; + }, +}); diff --git a/js/src/components/TextEditor.vue b/js/src/components/TextEditor.vue index b29980d2..365a779c 100644 --- a/js/src/components/TextEditor.vue +++ b/js/src/components/TextEditor.vue @@ -208,6 +208,7 @@ import Gapcursor from "@tiptap/extension-gapcursor"; import History from "@tiptap/extension-history"; import { IActor, IPerson, usernameWithDomain } from "../types/actor"; import CustomImage from "./Editor/Image"; +import RichEditorKeyboardSubmit from "./Editor/RichEditorKeyboardSubmit"; import { UPLOAD_MEDIA } from "../graphql/upload"; import { listenFileUpload } from "../utils/upload"; import Mention from "@tiptap/extension-mention"; @@ -252,7 +253,7 @@ const props = withDefaults( } ); -const emit = defineEmits(["update:modelValue"]); +const emit = defineEmits(["update:modelValue", "submit"]); const isDescriptionMode = computed((): boolean => { return props.mode === "description" || isBasicMode.value; @@ -297,7 +298,7 @@ const editor = useEditor({ "aria-label": props.ariaLabel ?? "", role: "textbox", class: - "prose dark:prose-invert prose-sm sm:prose lg:prose-lg xl:prose-xl m-5 focus:outline-none !max-w-full", + "prose dark:prose-invert prose-sm lg:prose-lg xl:prose-xl bg-zinc-50 dark:bg-zinc-700 focus:outline-none !max-w-full", }, transformPastedHTML: transformPastedHTML, }, @@ -323,6 +324,9 @@ const editor = useEditor({ Link.configure({ HTMLAttributes: { target: "_blank", rel: "noopener noreferrer ugc" }, }), + RichEditorKeyboardSubmit.configure({ + submit: () => emit("submit"), + }), ], injectCSS: false, content: props.modelValue, @@ -480,9 +484,7 @@ onBeforeUnmount(() => { div.ProseMirror { min-height: 2.5rem; box-shadow: inset 0 1px 2px rgba(10, 10, 10, 0.1); - background-color: white; border-radius: 4px; - color: #363636; border: 1px solid #dbdbdb; padding: 12px 6px; diff --git a/js/src/composition/apollo/config.ts b/js/src/composition/apollo/config.ts index c26bda72..77bced04 100644 --- a/js/src/composition/apollo/config.ts +++ b/js/src/composition/apollo/config.ts @@ -61,7 +61,7 @@ export function useAnonymousReportsConfig() { }>(ANONYMOUS_REPORTS_CONFIG, undefined, { fetchPolicy: "cache-only" }); const anonymousReportsConfig = computed( - () => configResult.value?.config?.anonymous?.participation + () => configResult.value?.config?.anonymous?.reports ); return { anonymousReportsConfig, error, loading }; } diff --git a/js/src/i18n/en_US.json b/js/src/i18n/en_US.json index 9f2adc7e..bb8bd868 100644 --- a/js/src/i18n/en_US.json +++ b/js/src/i18n/en_US.json @@ -52,7 +52,7 @@ "Close": "Close", "Closed": "Closed", "Comment deleted": "Comment deleted", - "Comment from @{username} reported": "Comment from @{username} reported", + "Comment from {'@'}{username} reported": "Comment from {'@'}{username} reported", "Comments": "Comments", "Confirm my participation": "Confirm my participation", "Confirm my particpation": "Confirm my particpation", diff --git a/js/src/i18n/fr_FR.json b/js/src/i18n/fr_FR.json index f1f0d5f2..b4db3e01 100644 --- a/js/src/i18n/fr_FR.json +++ b/js/src/i18n/fr_FR.json @@ -192,7 +192,7 @@ "Closed": "Fermé", "Comment body": "Corps du commentaire", "Comment deleted": "Commentaire supprimé", - "Comment from @{username} reported": "Commentaire de @{username} signalé", + "Comment from {'@'}{username} reported": "Commentaire de {'@'}{username} signalé", "Comment text can't be empty": "Le texte du commentaire ne peut être vide", "Comments": "Commentaires", "Comments are closed for everybody else.": "Les commentaires sont fermés pour tou·te·s les autres.",