|
@@ -1,10 +1,4 @@
|
|
|
-import React, {
|
|
|
- useCallback,
|
|
|
- useEffect,
|
|
|
- useMemo,
|
|
|
- useRef,
|
|
|
- useState,
|
|
|
-} from "react";
|
|
|
+import React, { useCallback, useMemo, useRef, useState } from "react";
|
|
|
import styles from "./index.module.scss";
|
|
|
|
|
|
// 引入编辑器组件
|
|
@@ -63,46 +57,6 @@ function ZRichTexts({ check, dirCode, isLook, myUrl }: Props, ref: any) {
|
|
|
// 当前上传 图片 视频的索引
|
|
|
const nowIndexRef = useRef(0);
|
|
|
|
|
|
- const addDomFu = useCallback((index: number) => {
|
|
|
- setTimeout(() => {
|
|
|
- const domAll = document.querySelectorAll(".bf-controlbar");
|
|
|
- const dom = domAll[index];
|
|
|
-
|
|
|
- const div = document.createElement("div");
|
|
|
- div.className = "upImgBox";
|
|
|
- div.innerHTML = "上传图片/视频";
|
|
|
- div.onclick = () => {
|
|
|
- myInput.current?.click();
|
|
|
- };
|
|
|
- dom.appendChild(div);
|
|
|
- }, 20);
|
|
|
- }, []);
|
|
|
-
|
|
|
- // 为富文本添加 上传图片/视频 的dom
|
|
|
- useEffect(() => {
|
|
|
- addDomFu(sectionArr.length - 1);
|
|
|
- // 新增的富文本 也要初始化数据
|
|
|
- }, [addDomFu, sectionArr.length]);
|
|
|
-
|
|
|
- // useEffect(() => {
|
|
|
- // const controlbarDom = document.querySelectorAll(".txtBox .bf-controlbar ");
|
|
|
- // const contentDom = document.querySelectorAll(".txtBox .bf-content ");
|
|
|
- // if (controlbarDom) {
|
|
|
- // controlbarDom.forEach((v: any) => {
|
|
|
- // v.style.display = isLook ? "none" : "block";
|
|
|
- // });
|
|
|
- // contentDom.forEach((v: any) => {
|
|
|
- // v.style.height = isLook ? "100%" : "";
|
|
|
- // });
|
|
|
- // }
|
|
|
- // }, [isLook]);
|
|
|
-
|
|
|
- // 编辑器文本
|
|
|
- // const [editorValue, setEditorValue] = useState<any[]>(
|
|
|
- // // 初始内容
|
|
|
- // [BraftEditor.createEditorState("")]
|
|
|
- // );
|
|
|
-
|
|
|
// 判断 富文本是否为空
|
|
|
const isTxtFlag = useMemo(() => {
|
|
|
let flag = false;
|
|
@@ -135,7 +89,7 @@ function ZRichTexts({ check, dirCode, isLook, myUrl }: Props, ref: any) {
|
|
|
|
|
|
const myInput = useRef<HTMLInputElement>(null);
|
|
|
|
|
|
- // 上传图片
|
|
|
+ // 上传图片、视频
|
|
|
const handeUpPhoto = useCallback(
|
|
|
async (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
if (e.target.files) {
|
|
@@ -149,18 +103,19 @@ function ZRichTexts({ check, dirCode, isLook, myUrl }: Props, ref: any) {
|
|
|
|
|
|
const isVideoFlag = filesInfo.name.endsWith(".mp4");
|
|
|
|
|
|
+ if (isVideoFlag) {
|
|
|
+ // 上传视频
|
|
|
+ size = 500;
|
|
|
+ txt = "视频只支持mp4格式!";
|
|
|
+ txt2 = "视频最大支持500M!";
|
|
|
+ }
|
|
|
+
|
|
|
// 校验格式
|
|
|
if (!type.includes(filesInfo.type)) {
|
|
|
e.target.value = "";
|
|
|
- if (isVideoFlag) {
|
|
|
- // 上传视频
|
|
|
- size = 500;
|
|
|
- txt = "视频只支持mp4格式!";
|
|
|
- txt2 = "视频最大支持500M!";
|
|
|
- }
|
|
|
-
|
|
|
return MessageFu.warning(txt);
|
|
|
}
|
|
|
+
|
|
|
// 校验大小
|
|
|
if (filesInfo.size > size * 1024 * 1024) {
|
|
|
e.target.value = "";
|
|
@@ -323,7 +278,9 @@ function ZRichTexts({ check, dirCode, isLook, myUrl }: Props, ref: any) {
|
|
|
onChange={(e) => handeUpPhoto(e)}
|
|
|
/>
|
|
|
|
|
|
- <div className="formRightZW">
|
|
|
+ <div
|
|
|
+ className={classNames("formRightZW", isLook ? "formRightZWLook" : "")}
|
|
|
+ >
|
|
|
<Checkbox
|
|
|
checked={isSection}
|
|
|
onChange={(e) => setIsSection(e.target.checked)}
|
|
@@ -332,22 +289,35 @@ function ZRichTexts({ check, dirCode, isLook, myUrl }: Props, ref: any) {
|
|
|
</Checkbox>
|
|
|
|
|
|
{isSection ? (
|
|
|
- <Button type="primary" onClick={addSectionFu}>
|
|
|
+ <Button hidden={isLook} type="primary" onClick={addSectionFu}>
|
|
|
新增章节
|
|
|
</Button>
|
|
|
) : (
|
|
|
- <ZupAudio
|
|
|
- fileInfo={sectionArr[0].fileInfo}
|
|
|
- upDataFu={(info) => upSectionFu(info, 0)}
|
|
|
- delFu={() => delSectionFu(0)}
|
|
|
- dirCode={dirCode}
|
|
|
- myUrl="cms/event/upload"
|
|
|
- isLook={isLook}
|
|
|
- />
|
|
|
+ <div className="formRightZWRR">
|
|
|
+ <ZupAudio
|
|
|
+ fileInfo={sectionArr[0].fileInfo}
|
|
|
+ upDataFu={(info) => upSectionFu(info, 0)}
|
|
|
+ delFu={() => delSectionFu(0)}
|
|
|
+ dirCode={dirCode}
|
|
|
+ myUrl="cms/event/upload"
|
|
|
+ isLook={isLook}
|
|
|
+ />
|
|
|
+
|
|
|
+ <div hidden={isLook} style={{ marginLeft: 20 }}>
|
|
|
+ <Button
|
|
|
+ onClick={() => {
|
|
|
+ nowIndexRef.current = 0;
|
|
|
+ myInput.current?.click();
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 上传图片/视频
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
)}
|
|
|
</div>
|
|
|
|
|
|
- <div className="txtBox">
|
|
|
+ <div className={classNames("txtBox", isLook ? "txtBoxLook" : "")}>
|
|
|
{sectionArr.map((item, index) => (
|
|
|
<div
|
|
|
className={classNames(
|
|
@@ -356,7 +326,6 @@ function ZRichTexts({ check, dirCode, isLook, myUrl }: Props, ref: any) {
|
|
|
)}
|
|
|
key={item.id}
|
|
|
hidden={!isSection && index > 0}
|
|
|
- onMouseOver={() => (nowIndexRef.current = index)}
|
|
|
>
|
|
|
{/* 顶部 */}
|
|
|
<div className="zztxtRow1" hidden={!isSection && index === 0}>
|
|
@@ -365,17 +334,28 @@ function ZRichTexts({ check, dirCode, isLook, myUrl }: Props, ref: any) {
|
|
|
<div className="zztxtRow1_1_2">
|
|
|
标题:
|
|
|
<Input
|
|
|
+ readOnly={isLook}
|
|
|
value={item.name}
|
|
|
placeholder="请输入内容"
|
|
|
maxLength={30}
|
|
|
showCount
|
|
|
- style={{ width: 500 }}
|
|
|
+ style={{ width: 400 }}
|
|
|
onChange={(e) => {
|
|
|
const arr = [...sectionArr];
|
|
|
arr[index].name = e.target.value.replace(/\s+/g, "");
|
|
|
setSectionArr(arr);
|
|
|
}}
|
|
|
/>
|
|
|
+  
|
|
|
+ <Button
|
|
|
+ hidden={isLook}
|
|
|
+ onClick={() => {
|
|
|
+ nowIndexRef.current = index;
|
|
|
+ myInput.current?.click();
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ 上传图片/视频
|
|
|
+ </Button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div className="zztxtRow1_2">
|
|
@@ -389,6 +369,7 @@ function ZRichTexts({ check, dirCode, isLook, myUrl }: Props, ref: any) {
|
|
|
/>
|
|
|
 
|
|
|
<div
|
|
|
+ hidden={isLook}
|
|
|
className={classNames(
|
|
|
"zztxtRow1_2Icon",
|
|
|
index === 0 ? "zztxtRow1_2IconNo" : ""
|
|
@@ -399,6 +380,7 @@ function ZRichTexts({ check, dirCode, isLook, myUrl }: Props, ref: any) {
|
|
|
</div>
|
|
|
 
|
|
|
<div
|
|
|
+ hidden={isLook}
|
|
|
className={classNames(
|
|
|
"zztxtRow1_2Icon",
|
|
|
index === sectionArr.length - 1 ? "zztxtRow1_2IconNo" : ""
|
|
@@ -408,11 +390,13 @@ function ZRichTexts({ check, dirCode, isLook, myUrl }: Props, ref: any) {
|
|
|
<ArrowDownOutlined title="下移" />
|
|
|
</div>
|
|
|
 
|
|
|
- <MyPopconfirm
|
|
|
- txtK="删除"
|
|
|
- onConfirm={() => delSectionAllFu(item.id)}
|
|
|
- Dom={<DeleteOutlined title="删除" className="ZTbox2X" />}
|
|
|
- />
|
|
|
+ {isLook ? null : (
|
|
|
+ <MyPopconfirm
|
|
|
+ txtK="删除"
|
|
|
+ onConfirm={() => delSectionAllFu(item.id)}
|
|
|
+ Dom={<DeleteOutlined title="删除" className="ZTbox2X" />}
|
|
|
+ />
|
|
|
+ )}
|
|
|
</div>
|
|
|
</div>
|
|
|
{/* 主体 */}
|