Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Cloudbase Extension Cms
Commits
b3335bf1
Commit
b3335bf1
authored
4 years ago
by
cwuyiqing
Browse files
Options
Download
Email Patches
Plain Diff
feat: 富文本支持输入链接插入图片
parent
16684c4f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
package.json
+1
-1
package.json
packages/admin/src/components/Fields/Connect.tsx
+1
-1
packages/admin/src/components/Fields/Connect.tsx
packages/admin/src/components/Fields/RichText.tsx
+53
-18
packages/admin/src/components/Fields/RichText.tsx
sam.yml
+6
-7
sam.yml
with
61 additions
and
27 deletions
+61
-27
package.json
+
1
-
1
View file @
b3335bf1
{
"name"
:
"cloudbase-cms"
,
"version"
:
"2.5.
0
"
,
"version"
:
"2.5.
1
"
,
"private"
:
true
,
"scripts"
:
{
"dev"
:
"lerna run dev"
,
...
...
This diff is collapsed.
Click to expand it.
packages/admin/src/components/Fields/Connect.tsx
+
1
-
1
View file @
b3335bf1
...
...
@@ -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
]
}
...
...
This diff is collapsed.
Click to expand it.
packages/admin/src/components/Fields/RichText.tsx
+
53
-
18
View file @
b3335bf1
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
=
{
()
=>
set
V
isible
(
true
)
}
/>
<
FileImageTwoTone
className
=
"bfi-list"
onClick
=
{
()
=>
set
State
({
v
isible
:
true
}
)
}
/>
</
button
>
<
Modal
centered
closable
=
{
true
}
visible
=
{
visible
}
footer
=
{
null
}
onCancel
=
{
()
=>
set
V
isible
(
false
)
}
onCancel
=
{
()
=>
set
State
({
v
isible
:
false
}
)
}
>
<
p
>
输入链接插入图片
</
p
>
<
div
className
=
"w-full flex"
>
<
Input
className
=
"flex-auto"
value
=
{
inputUrl
}
placeholder
=
"输入图片地址"
onChange
=
{
(
e
)
=>
setState
({
inputUrl
:
e
.
target
.
value
})
}
/>
<
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
)
=>
{
set
Percent
(
percent
)
set
State
({
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
)
...
...
This diff is collapsed.
Click to expand it.
sam.yml
+
6
-
7
View file @
b3335bf1
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://
0241c2720afb459d9c8bf1a00608b16
7.zip
CodeUri
:
extension://
1d48f635fc174a65a5668169205243c
7.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
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help