Skip to content

Commit

Permalink
feat: 升级marked;修复richEditor placeholder展示问题;richEditor文件前缀现在固定展示为File…
Browse files Browse the repository at this point in the history
…;修复繁体语言包中链接文案为空的问题
  • Loading branch information
SummerOverture committed Apr 20, 2021
1 parent 245ff4b commit 4fafd80
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"lint-staged": "^5.0.0",
"loader-utils": "^1.1.0",
"lottie-web": "^5.5.2",
"marked": "1.1.1",
"marked": "^2.0.0",
"mkdirp": "^0.5.1",
"npm-run-all": "3.0.0",
"nprogress": "^0.2.0",
Expand Down
57 changes: 56 additions & 1 deletion site/docs/zh-CN/configProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,61 @@ export default () => (
content: 'some messages...some messages...',
});
}

getFileUrl = (files, callback) => {
if (!(files && files.length)) return;

// 根据file.type过滤掉拖入/粘贴的非文件内容
// ...

this.setState({
loading: true
});

// 模拟上传文件至服务器并设置URL的异步过程
setTimeout(() => {
let filesInfo = [
{
name: '普通文件.doc',
type: 'other',
url: "//ysf.qiyukf.net/3df2280d2319678a091138b0bbba82fe"
},
{
name: '普通文件.pdf',
type: 'other',
url: "//ysf.qiyukf.net/3df2280d2319678a091138b0bbba82fe"
},
{
type: 'image',
src: "//ysf.qiyukf.net/3df2280d2319678a091138b0bbba82fe",
// 添加其他可选属性
width: 200,
height: 100,
alt: 'image alt',
title: 'image title',
'data-test': 'test-image'
},
{
type: 'video',
src: "//www.runoob.com/try/demo_source/mov_bbb.mp4",
// 添加其他可选属性
width: 300,
'data-test': 'test-video'
},
{
name: '普通文件.txt',
type: 'other',
url: "//ysf.qiyukf.net/3df2280d2319678a091138b0bbba82fe"
}
];
callback(filesInfo);

this.setState({
loading: false
});
}, 1000);
}

render() {
const {currentLocale} = this.state;
const ConfigProvider = Config.Provider;
Expand Down Expand Up @@ -127,7 +182,7 @@ export default () => (
showTime={true}
/>
</Row>
<RichEditor />
<RichEditor fileDrop customDropFile={this.getFileUrl} />
</ConfigProvider>
</div>
)
Expand Down
1 change: 1 addition & 0 deletions source/components/Locale/en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ const LocaleValue: LocaleProperties = {
bold: 'Bold',
temporarilyNoData: 'No data',
enterKeyWordPlease: 'Please enter the keywords',
placeholder: 'Please enter content',
justOkText: 'OK',
accessLink: 'Access the link',
edit: 'Edit',
Expand Down
1 change: 1 addition & 0 deletions source/components/Locale/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const localeValues: LocaleProperties = {
bold: '粗体',
temporarilyNoData: '暂无数据',
enterKeyWordPlease: '请输入关键字',
placeholder: '请输入内容',
justOkText: '知道了',
accessLink: '访问链接',
edit: '编辑',
Expand Down
9 changes: 5 additions & 4 deletions source/components/Locale/zh_TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ const localeValues: LocaleProperties = {
defaultOptionTitle: '默認展示數據項',
okText: '確定',
cancelText: '取消',
accessLink: '訪問鏈接',
edit: '編輯',
deleteText: '删除',
},
Modal: {
okText: '確定',
Expand Down Expand Up @@ -110,7 +107,11 @@ const localeValues: LocaleProperties = {
bold: '粗體',
temporarilyNoData: '暫無數據',
enterKeyWordPlease: '請輸入關鍵字',
justOkText: '知道了'
placeholder: '請輸入內容',
justOkText: '知道了',
accessLink: '訪問鏈接',
edit: '編輯',
deleteText: '删除',
},
Spin: {
loading: '加載中'
Expand Down
14 changes: 12 additions & 2 deletions source/components/RichEditor/src/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class RichEditor extends Component<RichEditorProps, RichEditorState> {
customInsertValue: {},
insertImageTip: true,
insertVideoTip: true,
placeholder: true,
placeholder: '',
prefixCls: "fishd-richeditor",
popoverPlacement: "top",
tooltipPlacement: "bottom",
Expand Down Expand Up @@ -446,6 +446,9 @@ class RichEditor extends Component<RichEditorProps, RichEditorState> {
}
);
this.changePseudoElementText();
setTimeout(() => {
this.changeEditorPlaceholder();
}, 10);
/* eslint-enable react/no-did-mount-set-state */
}

Expand All @@ -460,6 +463,7 @@ class RichEditor extends Component<RichEditorProps, RichEditorState> {
});
}
this.changePseudoElementText();
this.changeEditorPlaceholder();
/* eslint-enable react/no-did-update-set-state */
}

Expand Down Expand Up @@ -1224,6 +1228,12 @@ class RichEditor extends Component<RichEditorProps, RichEditorState> {
elAccessLink && elAccessLink.setAttribute('data-before-content',accessLink);
}

// 变更编辑器placeholder
changeEditorPlaceholder = () => {
const root = this.getEditor()?.root;
root && root.setAttribute('data-placeholder', this.props.placeholder || this.Locale.placeholder);
}

render() {
const {
loading,
Expand Down Expand Up @@ -1430,7 +1440,7 @@ class RichEditor extends Component<RichEditorProps, RichEditorState> {
bounds={this.editorCtner}
className={"editor-body"}
modules={moduleOpts}
placeholder={Locale.placeholder}
// placeholder={Locale.placeholder}
onChange={this.handleChange}
onSelectionChange={this.handleSelectionChange}
/>
Expand Down
6 changes: 1 addition & 5 deletions source/components/RichEditor/src/modules/fileDrop.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { getRuntimeLocale } from '../../../Config/Locale/Provider';
import { LocaleProperties } from '../../../Locale';

export interface quill{
root: HTMLElement,
getSelection: Function,
Expand Down Expand Up @@ -117,8 +114,7 @@ export default class FileDrop {
listFormat.list = curFormat.list;
}

const runtimeLocale: LocaleProperties['RichEditor'] = getRuntimeLocale('RichEditor');
let displayFileName = runtimeLocale.file + fileInfo.name,
let displayFileName = '[File] ' + fileInfo.name,
delta = [
{
insert: displayFileName,
Expand Down

0 comments on commit 4fafd80

Please sign in to comment.