Browse Source

add word-counter

visuddhinanda 1 year ago
parent
commit
9561410309
1 changed files with 16 additions and 0 deletions
  1. 16 0
      dashboard/src/components/article/TypeArticleReaderToolbar.tsx

+ 16 - 0
dashboard/src/components/article/TypeArticleReaderToolbar.tsx

@@ -6,6 +6,7 @@ import {
   EditOutlined,
   EditOutlined,
   FileOutlined,
   FileOutlined,
   CopyOutlined,
   CopyOutlined,
+  InfoCircleOutlined,
 } from "@ant-design/icons";
 } from "@ant-design/icons";
 
 
 import { useAppSelector } from "../../hooks";
 import { useAppSelector } from "../../hooks";
@@ -18,6 +19,7 @@ import AnthologiesAtArticle from "./AnthologiesAtArticle";
 import { TRole } from "../api/Auth";
 import { TRole } from "../api/Auth";
 import { useIntl } from "react-intl";
 import { useIntl } from "react-intl";
 import { TabIcon } from "../../assets/icon";
 import { TabIcon } from "../../assets/icon";
+import WordCount from "./WordCount";
 
 
 interface IWidget {
 interface IWidget {
   articleId?: string;
   articleId?: string;
@@ -41,6 +43,7 @@ const TypeArticleReaderToolbarWidget = ({
   const user = useAppSelector(currentUser);
   const user = useAppSelector(currentUser);
   const [addToAnthologyOpen, setAddToAnthologyOpen] = useState(false);
   const [addToAnthologyOpen, setAddToAnthologyOpen] = useState(false);
   const [tplOpen, setTplOpen] = useState(false);
   const [tplOpen, setTplOpen] = useState(false);
+  const [wordCountOpen, setWordCountOpen] = useState(false);
 
 
   const editable = role === "owner" || role === "manager" || role === "editor";
   const editable = role === "owner" || role === "manager" || role === "editor";
 
 
@@ -131,6 +134,11 @@ const TypeArticleReaderToolbarWidget = ({
                   icon: <CopyOutlined />,
                   icon: <CopyOutlined />,
                   disabled: user ? false : true,
                   disabled: user ? false : true,
                 },
                 },
+                {
+                  label: "字数统计",
+                  key: "word-count",
+                  icon: <InfoCircleOutlined />,
+                },
               ],
               ],
               onClick: ({ key }) => {
               onClick: ({ key }) => {
                 console.log(`Click on item ${key}`);
                 console.log(`Click on item ${key}`);
@@ -151,6 +159,9 @@ const TypeArticleReaderToolbarWidget = ({
                   case "tpl":
                   case "tpl":
                     setTplOpen(true);
                     setTplOpen(true);
                     break;
                     break;
+                  case "word-count":
+                    setWordCountOpen(true);
+                    break;
                   case "edit":
                   case "edit":
                     if (typeof onEdit !== "undefined") {
                     if (typeof onEdit !== "undefined") {
                       onEdit();
                       onEdit();
@@ -185,6 +196,11 @@ const TypeArticleReaderToolbarWidget = ({
         open={tplOpen}
         open={tplOpen}
         onOpenChange={(visible: boolean) => setTplOpen(visible)}
         onOpenChange={(visible: boolean) => setTplOpen(visible)}
       />
       />
+      <WordCount
+        open={wordCountOpen}
+        articleId={articleId}
+        onClose={() => setWordCountOpen(false)}
+      />
     </div>
     </div>
   );
   );
 };
 };