visuddhinanda 2 vuotta sitten
vanhempi
sitoutus
6fb0207008
1 muutettua tiedostoa jossa 30 lisäystä ja 5 poistoa
  1. 30 5
      dashboard/src/components/template/Wbw/WbwWord.tsx

+ 30 - 5
dashboard/src/components/template/Wbw/WbwWord.tsx

@@ -18,6 +18,7 @@ import WbwPara from "./WbwPara";
 import WbwPage from "./WbwPage";
 import WbwPage from "./WbwPage";
 import WbwRelationAdd from "./WbwRelationAdd";
 import WbwRelationAdd from "./WbwRelationAdd";
 import { ArticleMode } from "../../article/Article";
 import { ArticleMode } from "../../article/Article";
+import WbwReal from "./WbwReal";
 
 
 export type TFieldName =
 export type TFieldName =
   | "word"
   | "word"
@@ -43,10 +44,11 @@ export interface IWbwField {
   value: string;
   value: string;
 }
 }
 
 
-enum WbwStatus {
+export enum WbwStatus {
   initiate = 0,
   initiate = 0,
   auto = 3,
   auto = 3,
-  manual = 5,
+  apply = 5,
+  manual = 7,
 }
 }
 export interface WbwElement<R> {
 export interface WbwElement<R> {
   value: R;
   value: R;
@@ -80,6 +82,7 @@ export interface IWbw {
   hasComment?: boolean;
   hasComment?: boolean;
 }
 }
 export interface IWbwFields {
 export interface IWbwFields {
+  real?: boolean;
   meaning?: boolean;
   meaning?: boolean;
   factors?: boolean;
   factors?: boolean;
   factorMeaning?: boolean;
   factorMeaning?: boolean;
@@ -100,7 +103,13 @@ const WbwWordWidget = ({
   data,
   data,
   display = "block",
   display = "block",
   mode = "edit",
   mode = "edit",
-  fields = { meaning: true, factors: true, factorMeaning: true, case: true },
+  fields = {
+    real: false,
+    meaning: true,
+    factors: true,
+    factorMeaning: true,
+    case: true,
+  },
   wordDark = false,
   wordDark = false,
   onChange,
   onChange,
   onSplit,
   onSplit,
@@ -121,7 +130,7 @@ const WbwWordWidget = ({
     : "unset";
     : "unset";
   const wbwCtl = wordData.type?.value === ".ctl." ? "wbw_ctl" : "";
   const wbwCtl = wordData.type?.value === ".ctl." ? "wbw_ctl" : "";
   const wbwAnchor = wordData.grammar?.value === ".a." ? "wbw_anchor" : "";
   const wbwAnchor = wordData.grammar?.value === ".a." ? "wbw_anchor" : "";
-  const wbwDark = wordDark ? "dark" : undefined;
+  const wbwDark = wordDark ? "dark" : "";
 
 
   const styleWbw: React.CSSProperties = {
   const styleWbw: React.CSSProperties = {
     display: display === "block" ? "block" : "flex",
     display: display === "block" ? "block" : "flex",
@@ -211,6 +220,22 @@ const WbwWordWidget = ({
             background: `linear-gradient(90deg, rgba(255, 255, 255, 0), ${color})`,
             background: `linear-gradient(90deg, rgba(255, 255, 255, 0), ${color})`,
           }}
           }}
         >
         >
+          {fieldDisplay?.real ? (
+            <WbwReal
+              key="real"
+              data={wordData}
+              display={display}
+              onChange={(e: string) => {
+                console.log("meaning change", e);
+                const newData: IWbw = JSON.parse(JSON.stringify(wordData));
+                newData.meaning = { value: e, status: 5 };
+                setWordData(newData);
+                if (typeof onChange !== "undefined") {
+                  onChange(newData);
+                }
+              }}
+            />
+          ) : undefined}
           {fieldDisplay?.meaning ? (
           {fieldDisplay?.meaning ? (
             <WbwMeaning
             <WbwMeaning
               key="meaning"
               key="meaning"
@@ -220,7 +245,7 @@ const WbwWordWidget = ({
               onChange={(e: string) => {
               onChange={(e: string) => {
                 console.log("meaning change", e);
                 console.log("meaning change", e);
                 const newData: IWbw = JSON.parse(JSON.stringify(wordData));
                 const newData: IWbw = JSON.parse(JSON.stringify(wordData));
-                newData.meaning = { value: e, status: 5 };
+                newData.meaning = { value: e, status: WbwStatus.manual };
                 setWordData(newData);
                 setWordData(newData);
                 if (typeof onChange !== "undefined") {
                 if (typeof onChange !== "undefined") {
                   onChange(newData);
                   onChange(newData);