Sfoglia il codice sorgente

文章翻译支持wbw

visuddhinanda 3 anni fa
parent
commit
8cb390801c

+ 0 - 1
dashboard/src/components/template/MdView.tsx

@@ -6,7 +6,6 @@ interface IWidget {
   convertor?: TCodeConvertor;
 }
 const Widget = ({ html, wordWidget = false, convertor }: IWidget) => {
-  console.log("word", wordWidget);
   const jsx = XmlToReact(html, wordWidget, convertor);
   return <>{jsx}</>;
 };

+ 2 - 3
dashboard/src/components/template/SentEdit.tsx

@@ -5,9 +5,8 @@ import { IChannel } from "../channel/Channel";
 import SentContent from "./SentEdit/SentContent";
 import SentMenu from "./SentEdit/SentMenu";
 import SentTab from "./SentEdit/SentTab";
-import { suggestion } from "../../reducers/suggestion";
 
-interface ISuggestiongCount {
+interface ISuggestionCount {
   suggestion?: number;
   qa?: number;
 }
@@ -21,7 +20,7 @@ export interface ISentence {
   editor: IUser;
   channel: IChannel;
   updateAt: string;
-  suggestionCount?: ISuggestiongCount;
+  suggestionCount?: ISuggestionCount;
 }
 
 export interface IWidgetSentEditInner {

+ 6 - 1
dashboard/src/components/template/SentEdit/SentContent.tsx

@@ -1,5 +1,6 @@
 import { ISentence } from "../SentEdit";
 import SentCell from "./SentCell";
+import { WbwSentCtl } from "../WbwSent";
 interface IWidgetSentContent {
   origin?: ISentence[];
   translation?: ISentence[];
@@ -14,7 +15,11 @@ const Widget = ({
     <div style={{ display: "flex", flexDirection: layout }}>
       <div style={{ flex: "5", color: "#9f3a01" }}>
         {origin?.map((item, id) => {
-          return <SentCell key={id} data={item} wordWidget={true} />;
+          if (item.channel.type === "wbw") {
+            return <WbwSentCtl key={id} data={JSON.parse(item.content)} />;
+          } else {
+            return <SentCell key={id} data={item} wordWidget={true} />;
+          }
         })}
       </div>
       <div style={{ flex: "5" }}>

+ 2 - 1
dashboard/src/components/template/Wbw/WbwPali.tsx

@@ -56,6 +56,7 @@ const Widget = ({ data, onSave }: IWidget) => {
   ) : (
     <></>
   );
+  const classPali = data.style?.value === "note" ? "wbw_note" : "pali";
   return (
     <div className="pali_shell">
       <Popover
@@ -66,7 +67,7 @@ const Widget = ({ data, onSave }: IWidget) => {
         onOpenChange={handleClickChange}
       >
         <span
-          className="pali"
+          className={classPali}
           style={{ backgroundColor: paliColor, padding: 4, borderRadius: 5 }}
         >
           {data.word.value}

+ 8 - 1
dashboard/src/components/template/Wbw/WbwWord.tsx

@@ -53,6 +53,7 @@ export interface IWbw {
   meaning?: WbwElement2;
   type?: WbwElement;
   grammar?: WbwElement;
+  style?: WbwElement;
   case?: WbwElement2;
   parent?: WbwElement;
   factors?: WbwElement;
@@ -94,8 +95,14 @@ const Widget = ({
   const color = wordData.bookMarkColor
     ? bookMarkColor[wordData.bookMarkColor.value]
     : "unset";
+  const wbwCtl = wordData.type?.value === ".ctl." ? "wbw_ctl" : "";
+  const wbwAnchor = wordData.grammar?.value === ".a." ? "wbw_anchor" : "";
+
   return (
-    <div className={`wbw_word ${display}`} style={styleWbw}>
+    <div
+      className={`wbw_word ${display} ${wbwCtl} ${wbwAnchor} `}
+      style={styleWbw}
+    >
       <WbwPali
         data={wordData}
         onSave={(e: IWbw) => {

+ 10 - 1
dashboard/src/components/template/Wbw/wbw.css

@@ -3,6 +3,13 @@
   padding-right: 0;
   max-width: 60vw;
 }
+.wbw_ctl {
+  display: none;
+}
+.wbw_anchor {
+  display: none;
+}
+
 .wbw_split {
   visibility: hidden;
 }
@@ -22,12 +29,14 @@
 .inline .pali {
   color: brown;
 }
+.wbw_note {
+  color: blue;
+}
 .block .wbw_body {
   padding-right: 0.5em;
   padding-top: 0.2em;
 }
 .wbw_word_item {
-  min-width: 3em;
   padding: 0;
   cursor: pointer;
 }

+ 1 - 1
dashboard/src/components/template/WbwSent.tsx

@@ -6,7 +6,7 @@ interface IWidget {
   display?: "block" | "inline";
   fields?: IWbwFields;
 }
-export const WbwSentCtl = ({ data, display, fields }: IWidget) => {
+export const WbwSentCtl = ({ data, display = "inline", fields }: IWidget) => {
   const [wordData, setWordData] = useState(data);
 
   return (