Open platform to collect and prioritize feedback
More functionality
Matt Roberts57b245fd7ae9
diff --git a/public/assets/images/heroicons-bulletlist.svg b/public/assets/images/heroicons-bulletlist.svgnew file mode 100644index 000000000..7ed341cbd--- /dev/null+++ b/public/assets/images/heroicons-bulletlist.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">+ <path stroke-linecap="round" stroke-linejoin="round" d="M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0ZM3.75 12h.007v.008H3.75V12Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm-.375 5.25h.007v.008H3.75v-.008Zm.375 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Z" />+</svg>diff --git a/public/assets/images/heroicons-code.svg b/public/assets/images/heroicons-code.svgnew file mode 100644index 000000000..5bdc48c51--- /dev/null+++ b/public/assets/images/heroicons-code.svg@@ -0,0 +1,3 @@+<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">+ <path stroke-linecap="round" stroke-linejoin="round" d="M17.25 6.75 22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3-4.5 16.5" />+</svg>diff --git a/public/assets/images/heroicons-orderedlist.svg b/public/assets/images/heroicons-orderedlist.svgnew file mode 100644index 000000000..b05903e6f--- /dev/null+++ b/public/assets/images/heroicons-orderedlist.svg@@ -0,0 +1,4 @@+<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">+ <path stroke-linecap="round" stroke-linejoin="round" d="M8.242 5.992h12m-12 6.003H20.24m-12 5.999h12M4.117 7.495v-3.75H2.99m1.125 3.75H2.99m1.125 0H5.24m-1.92 2.577a1.125 1.125 0 1 1 1.591 1.59l-1.83 1.83h2.16M2.99 15.745h1.125a1.125 1.125 0 0 1 0 2.25H3.74m0-.002h.375a1.125 1.125 0 0 1 0 2.25H2.99" />+</svg>+diff --git a/public/components/common/Markdown.scss b/public/components/common/Markdown.scssindex 5cb976355..dd12a483e 100644--- a/public/components/common/Markdown.scss+++ b/public/components/common/Markdown.scss@@ -1,6 +1,7 @@@import "~@fider/assets/styles/variables.scss";-.c-markdown {+.c-markdown,+.tiptap {overflow-wrap: break-word;word-break: break-word;@@ -42,8 +43,8 @@}pre {- overflow-x: scroll;- padding: 16px;+ overflow-x: auto;+ padding: spacing(2);line-height: 1.45;background-color: get("colors.gray.200");border-radius: 4px;diff --git a/public/components/common/form/CommentEditor2.tsx b/public/components/common/form/CommentEditor2.tsxindex 96225c761..f6bedecbe 100644--- a/public/components/common/form/CommentEditor2.tsx+++ b/public/components/common/form/CommentEditor2.tsx@@ -15,6 +15,9 @@ import IconH3 from "@fider/assets/images/heroicons-h3.svg"import IconItalic from "@fider/assets/images/heroicons-italic.svg"import IconBold from "@fider/assets/images/heroicons-bold.svg"import IconStrike from "@fider/assets/images/heroicons-strike.svg"+import IconCode from "@fider/assets/images/heroicons-code.svg"+import IconOrderedList from "@fider/assets/images/heroicons-orderedlist.svg"+import IconBulletList from "@fider/assets/images/heroicons-bulletlist.svg"import { Icon } from "@fider/components"import suggestion from "./suggestion"@@ -71,6 +74,30 @@ const MenuBar = ({ editor }: { editor: Editor | null }) => {><Icon sprite={IconStrike} /></button>+ <button+ type="button"+ title="BulletList"+ onClick={() => editor.chain().focus().toggleBulletList().run()}+ className={`c-editor-button ${editor.isActive("bulletList") ? "is-active" : ""}`}+ >+ <Icon sprite={IconBulletList} />+ </button>+ <button+ type="button"+ title="OrderedList"+ onClick={() => editor.chain().focus().toggleOrderedList().run()}+ className={`c-editor-button ${editor.isActive("orderedList") ? "is-active" : ""}`}+ >+ <Icon sprite={IconOrderedList} />+ </button>+ <button+ type="button"+ title="Code"+ onClick={() => editor.chain().focus().toggleCodeBlock().run()}+ className={`c-editor-button ${editor.isActive("codeBlock") ? "is-active" : ""}`}+ >+ <Icon sprite={IconCode} />+ </button></div></div>)@@ -85,11 +112,9 @@ interface CommentEditorProps2 {const Tiptap: React.FunctionComponent<CommentEditorProps2> = (props) => {const updated = ({ editor }: { editor: Editor; transaction: any }): void => {const markdown = editor.storage.markdown.getMarkdown()- console.log(markdown)props.onChange && props.onChange(markdown)}const initialValue = props.initialValue ?? ""- console.log(initialValue)const extensions = [StarterKit,@@ -105,17 +130,11 @@ const Tiptap: React.FunctionComponent<CommentEditorProps2> = (props) => {Placeholder.configure({placeholder: props.placeholder ?? "Write your comment here...",}),- // CustomMarkdown,- // Mention.configure({- // HTMLAttributes: {- // class: "mention",- // },- // suggestion,]const editor = useEditor({extensions,- // content: initialValue,+ content: initialValue,onUpdate: updated,editorProps: {attributes: {@@ -132,6 +151,8 @@ const Tiptap: React.FunctionComponent<CommentEditorProps2> = (props) => {)}-const MemoizedTiptap = React.memo(Tiptap)+const MemoizedTiptap = React.memo(Tiptap, (prevProps, nextProps) => {+ return prevProps.placeholder === nextProps.placeholder+})export default MemoizedTiptapdiff --git a/public/pages/ShowPost/components/CommentInput.tsx b/public/pages/ShowPost/components/CommentInput.tsxindex 6c302adc9..21f4fc73e 100644--- a/public/pages/ShowPost/components/CommentInput.tsx+++ b/public/pages/ShowPost/components/CommentInput.tsx@@ -1,4 +1,4 @@-import React, { useState } from "react"+import React, { useCallback, useState } from "react"import { Post, ImageUpload } from "@fider/models"import { Avatar, UserName, Button, Form, MultiImageUploader } from "@fider/components"@@ -66,10 +66,9 @@ export const CommentInput = (props: CommentInputProps) => {const hasContent = true- function commentChanged2(value: string): void {- // setContent(value)+ const commentChanged = useCallback((value: string): void => {cache.session.set(getCacheKey(), value)- }+ }, [])return (<>@@ -90,7 +89,7 @@ export const CommentInput = (props: CommentInputProps) => {placeholder={i18n._("showpost.commentinput.placeholder", { message: "Leave a comment" })}/> */}<MemoizedTiptap- onChange={commentChanged2}+ onChange={commentChanged}initialValue={getContentFromCache()}placeholder={i18n._("showpost.commentinput.placeholder", { message: "Leave a comment" })}/>