Commit b3335bf1 authored by cwuyiqing's avatar cwuyiqing
Browse files

feat: 富文本支持输入链接插入图片

parent 16684c4f
Showing with 61 additions and 27 deletions
+61 -27
{
"name": "cloudbase-cms",
"version": "2.5.0",
"version": "2.5.1",
"private": true,
"scripts": {
"dev": "lerna run dev",
......
......@@ -165,7 +165,7 @@ const getConnectFieldDisplayText = (doc: any, schemas: Schema[], field: SchemaFi
// 关联的字段,又是一个关联类型,则展示关联字段关联的字段
if (connectedFieldInfo?.connectResource) {
return doc[connectField]?.[connectedFieldInfo.connectField]
return doc[connectField]?.[connectedFieldInfo.connectField] || '-'
} else {
return doc[connectField]
}
......
import { Upload, Progress, message, Modal } from 'antd'
import { Upload, Progress, message, Modal, Input, Space, Button } from 'antd'
import React, { useEffect, useState } from 'react'
import { InboxOutlined, FileImageTwoTone } from '@ant-design/icons'
import { ContentUtils } from 'braft-utils'
import BraftEditor, { ExtendControlType } from 'braft-editor'
import { uploadFile, getTempFileURL } from '@/utils'
import 'braft-editor/dist/index.css'
import { useSetState } from 'react-use'
const { Dragger } = Upload
......@@ -55,48 +56,82 @@ const RichText: React.FC<{ value?: any; id: number; onChange?: (...args: any) =>
)
}
interface IUploadState {
fileList: any[]
percent: number
visible: boolean
uploading: boolean
inputUrl: string
}
export const CustomUploader: React.FC<{
onChange?: (v: string) => void
}> = (props) => {
let { onChange = () => {} } = props
const [fileList, setFileList] = useState<any[]>()
const [percent, setPercent] = useState(0)
const [uploading, setUploading] = useState(false)
const [visible, setVisible] = useState(false)
const [{ fileList, percent, visible, uploading, inputUrl }, setState] = useSetState<IUploadState>(
{
fileList: [],
percent: 0,
visible: false,
uploading: false,
inputUrl: '',
}
)
return (
<>
<button type="button" data-title="媒体上传" className="control-item button">
<FileImageTwoTone className="bfi-list" onClick={() => setVisible(true)} />
<FileImageTwoTone className="bfi-list" onClick={() => setState({ visible: true })} />
</button>
<Modal
centered
closable={true}
visible={visible}
footer={null}
onCancel={() => setVisible(false)}
onCancel={() => setState({ visible: false })}
>
<p>输入链接插入图片</p>
<div className="w-full flex">
<Input
className="flex-auto"
value={inputUrl}
placeholder="输入图片地址"
onChange={(e) => setState({ inputUrl: e.target.value })}
/>
&nbsp;
<Button
type="primary"
onClick={() => {
onChange(inputUrl)
setState({ visible: false })
}}
>
确认
</Button>
</div>
<p className="mt-5">或拖拽上传插入图片</p>
<Dragger
fileList={fileList}
listType="picture"
beforeUpload={(file) => {
setUploading(true)
setPercent(0)
setState({ uploading: true, percent: 0 })
uploadFileAndGetUrl(file, (percent) => {
setPercent(percent)
setState({ percent })
})
.then(({ url, fileId }) => {
onChange(url)
setFileList([
{
uid: fileId,
name: file.name,
status: 'done',
},
])
setState({
visible: false,
fileList: [
{
uid: fileId,
name: file.name,
status: 'done',
},
],
})
message.success(`上传图片成功`)
setVisible(false)
})
.catch((e) => {
console.log(e)
......
TCBSAMFormatVersion: "2020-10-20"
Name: tcb-ext-cms
SpecVersion: v1beta
Version: 2.5.0
Version: 2.5.1
License: Apache-2.0
Category: CloudApp
DisplayName: CMS内容管理系统
......@@ -19,15 +19,14 @@ IconUrl: https://main.qcloudimg.com/raw/f87b49914efe502722f9aa128f5d8865/hello_w
IntroUrl: https://docs.cloudbase.net/cms/intro.html
# 更新日志
ChangeLog:
- Title: 2.5.0
- Title: 2.5.1
Content:
- 支持关联嵌套
- 性能优化,提升接口加载速度
- 支持按创建时间、更新时间排序
- 支持隐藏创建时间、更新时间
- 修复隐藏字段在编辑界面显示的问题
- 修复多个 Markdown 字段只展示一个编辑的问题
- 修复图片上传存储异常的问题
- 修复多个 Markdown 字段只展示一个编辑的问题
Author:
AuthorName: TCB
Email: cloudbase@tencent.com
......@@ -45,7 +44,7 @@ Resources:
Type: CloudBase::Function
Properties:
FunctionName: tcb-ext-cms-service
CodeUri: extension://e731e1624b4e4d24954ec207a0f399b5.zip
CodeUri: extension://706eeee1e672485bbb97252150767a90.zip
InstallDependency: true
Description: 提供 CMS 管理服务,所有对内容的操作和管理都会经过此函数调用,内容操作会根据用户权限来进行数据库操作
MemorySize: 256
......@@ -62,7 +61,7 @@ Resources:
Type: CloudBase::Function
Properties:
FunctionName: tcb-ext-cms-init
CodeUri: extension://0241c2720afb459d9c8bf1a00608b167.zip
CodeUri: extension://1d48f635fc174a65a5668169205243c7.zip
InstallDependency: true
Description: 提供初始化应用功能,安装扩展后,会通过该函数来进行静态资源的部署和密码的生成和设置,修改账号密码或者部署路径等扩展参数都会再次执行该函数来进行更新
MemorySize: 256
......@@ -82,7 +81,7 @@ Resources:
Type: CloudBase::Function
Properties:
FunctionName: tcb-ext-cms-api
CodeUri: extension://9c74210f66264444a0d21d5b491726f3.zip
CodeUri: extension://3c5ef8f640d4464dac892306253ea608.zip
InstallDependency: true
Description: 提供 CMS RESTful API 访问能力,所有 RESTful API 请求都会经过此函数调用
MemorySize: 256
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment