Skip to content

Commit

Permalink
Merge branch 'feature-1.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
gtopia committed Sep 24, 2020
2 parents 8e0abd1 + 8de4944 commit f329ccf
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 26 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppfish",
"version": "1.7.6",
"version": "1.7.7-beta.1",
"description": "fish design ui components",
"scripts": {
"precommit": "lint-staged",
Expand All @@ -9,7 +9,7 @@
"start": "npm-run-all --parallel test:watch open:site lint:watch",
"build": "npm-run-all --parallel build:site build:dist build:others",
"build:dist": "rimraf dist && babel-node tools/buildDist.js",
"build:others": "tools/buildOthers.sh",
"build:others": "sh tools/buildOthers.sh",
"stylelint": "stylelint \"source/**/*.less\" --fix",
"lint": "esw webpack.config.* source tools",
"lint:watch": "npm run lint -- --watch",
Expand All @@ -27,8 +27,8 @@
"analyze": "babel-node ./tools/analyzeBundle.js",
"open:site": "babel-node --max-old-space-size=4096 tools/openSite.js",
"build:site": "babel-node --max-old-space-size=4096 tools/buildSite.js",
"prepublish:site": "tools/prepare.sh",
"publish:site": "tools/release.sh"
"prepublish:site": "sh tools/prepare.sh",
"publish:site": "sh tools/release.sh"
},
"engines": {
"node": ">=6.11.5"
Expand All @@ -55,7 +55,7 @@
"mini-store": "^2.0.0",
"omit.js": "^1.0.0",
"query-string": "^4.2.2",
"quill": "1.3.6",
"quill": "1.3.7",
"raf": "^3.4.0",
"rc-animate": "^2.4.4",
"rc-trigger": "^2.5.4",
Expand Down Expand Up @@ -144,7 +144,7 @@
"lint-staged": "^5.0.0",
"loader-utils": "^1.1.0",
"lottie-web": "^5.5.2",
"marked": "^0.6.2",
"marked": "1.1.1",
"mkdirp": "^0.5.1",
"npm-run-all": "3.0.0",
"nprogress": "^0.2.0",
Expand Down
11 changes: 11 additions & 0 deletions site/docs/upgradeNotes/1.7/1.7.7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## ppfish 版本升级说明

### 1.7.7-alpha.3
- TreeSelect
- 🎊 新增doCheckChildInSearch API,用于在搜索出部分子节点情况下,只回传这些子节点的value。

### 1.7.7-beta.1
- 🔨 依赖包quill、marked安全性升级
- RichEditor
- 🔨 设置align、direction时,默认用内联样式控制,不再使用class
- 🔨 API `getHTML``getRawHTML` 安全性提升,过滤满足 `/javascript\s*:/ig` 匹配的字符,减少xss攻击
16 changes: 16 additions & 0 deletions site/docs/upgradeNotes/版本升级说明.md
Original file line number Diff line number Diff line change
Expand Up @@ -1052,3 +1052,19 @@
## 1.7.6
- RichEditor
- 🐛 修复自定义粘贴图片或其他文件时,无法粘贴非文件内容的问题

---
`2020.8.10`

## 1.7.7-alpha.3
- TreeSelect
- 🎊 新增doCheckChildInSearch API,用于在搜索出部分子节点情况下,只回传这些子节点的value。

---
`2020.9.24`

## 1.7.7-beta.1
- 🔨 依赖包quill、marked安全性升级
- RichEditor
- 🔨 设置align、direction时,默认用内联样式控制,不再使用class
- 🔨 API `getHTML``getRawHTML` 安全性提升,过滤满足 `/javascript\s*:/ig` 匹配的字符,减少xss攻击
8 changes: 5 additions & 3 deletions site/docs/zh-CN/treeSelect.md
Original file line number Diff line number Diff line change
Expand Up @@ -754,9 +754,9 @@
state = {
value: [],
treeData: [
{ title: 'Node1', key: 'k1', value: 'n1' },
{ title: 'Node2', key: 'k2', value: 'n2' },
{ title: 'Node3', key: 'k3', value: 'n3', isLeaf: true }
{ title: 'Node1', key: 'k1', value: 'k1',childCount:3 },
{ title: 'Node2', key: 'k2', value: 'k2',childCount:6 },
{ title: 'Node3', key: 'k3', value: 'k3', isLeaf: true }
]
}

Expand Down Expand Up @@ -825,6 +825,7 @@

render() {
const tProps = {
doCheckChildInSearch:true,
showSearch: true,
treeData: this.state.treeData,
value: this.state.value,
Expand Down Expand Up @@ -1075,6 +1076,7 @@
| className | 容器类名 | String | - |
| defaultValue | 指定默认选中的条目 | String \| Array< String > | - |
| disabled | 是否禁用 | Boolean | false |
| doCheckChildInSearch | 只搜索出部分节点情况下,是否只传这些子节点的ID | Boolean | false |
| dropdownClassName | 下拉菜单的 className 属性 | String | - |
| dropdownMatchSelectWidth | 下拉菜单和选择器同宽 | Boolean | true |
| dropdownStyle | 下拉菜单的样式 | Object | - |
Expand Down
5 changes: 3 additions & 2 deletions site/locales/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
misc: {
'guide': '指南',
'component': '组件',
'component': 'Web组件',
'patterns': '规范',
'home': '首页',
'spec': '设计语言',
Expand All @@ -11,6 +11,7 @@ export default {
'business': '业务组件',
'feedback': '反馈建议',
'demo': '演示环境',
'version': 'v1.7.6'
'mobileComponent': 'Mobile组件',
'version': 'v1.7.7'
}
};
3 changes: 3 additions & 0 deletions site/pages/common/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ export default class Layout extends React.Component {
<li className="nav-item">
<Link to="/components">{this.getLocale('misc.component')}</Link>
</li>
<li className="nav-item">
<a href="//nsfi.github.io/fishd-mobile-site/index.html#/zh-CN/components" target="_blank">{this.getLocale('misc.mobileComponent')}</a>
</li>
<li className="nav-item">
<a href="//nsfi.github.io/ppfish-demo" target="_blank">{this.getLocale('misc.demo')}</a>
</li>
Expand Down
2 changes: 2 additions & 0 deletions source/components/RichEditor/src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Quill.register(CustomSizeBlot);
Quill.register(VideoBlot);
Quill.register('modules/imageDrop', ImageDrop, true);
Quill.register('modules/fileDrop', FileDrop, true);
Quill.register(Quill.import('attributors/style/align'), true);
Quill.register(Quill.import('attributors/style/direction'), true);

const getImageSize = function(url, callback) {
let newImage;
Expand Down
10 changes: 8 additions & 2 deletions source/components/RichEditor/src/quill/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ function formatOutputHTML(value) {
return value.replace(/(<[^&<>]+)(contenteditable\s*=\s*['"]\w*['"])([^&<>]*>)/gi, '$1$3');
}

function xssFilter(value) {
if (!value) return value;

return value.replace(/javascript\s*:/ig, '');
}

let QuillMixin = {
/**
Creates an editor on the given element. The editor will
Expand All @@ -21,8 +27,8 @@ let QuillMixin = {
let editor = new Quill($el, config), _this = this;

// 添加与 unprivilegedEditor 相同的方法
editor.getHTML = function(){ return formatOutputHTML(editor.root.innerHTML); };
editor.getRawHTML = function(){ return editor.root.innerHTML; };
editor.getHTML = function(){ return xssFilter(formatOutputHTML(editor.root.innerHTML)); };
editor.getRawHTML = function(){ return xssFilter(editor.root.innerHTML); };
editor.isEmptyContents = function(){ return _this.isEmptyContents(editor); };

if (config.tabIndex !== undefined) {
Expand Down
7 changes: 4 additions & 3 deletions source/components/TreeSelect/rcTree/Tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Tree extends React.Component {
selectable: PropTypes.bool,
disabled: PropTypes.bool,
multiple: PropTypes.bool,
doCheckChildInSearch: PropTypes.bool,
checkable: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.node,
Expand Down Expand Up @@ -170,7 +171,7 @@ class Tree extends React.Component {
if (checkedKeyEntity) {
let { checkedKeys = [], halfCheckedKeys = [] } = checkedKeyEntity;

if (!props.checkStrictly) {
if (!props.checkStrictly||props.doCheckChildInSearch) {
const conductKeys = conductCheck(checkedKeys, true, keyEntities,
null, props.loadData, props.loadedKeys);
checkedKeys = conductKeys.checkedKeys;
Expand Down Expand Up @@ -465,7 +466,7 @@ class Tree extends React.Component {
halfCheckedKeys: oriHalfCheckedKeys,
loadedKeys
} = this.state;
const { checkStrictly, onCheck, loadData } = this.props;
const { checkStrictly, onCheck, loadData,doCheckChildInSearch } = this.props;
const { props: { eventKey } } = treeNode;

// Prepare trigger arguments
Expand All @@ -477,7 +478,7 @@ class Tree extends React.Component {
nativeEvent: e.nativeEvent,
};

if (checkStrictly) {
if (checkStrictly&&!doCheckChildInSearch) {
const checkedKeys = checked ? arrAdd(oriCheckedKeys, eventKey) : arrDel(oriCheckedKeys, eventKey);
const halfCheckedKeys = arrDel(oriHalfCheckedKeys, eventKey);
checkedObj = { checked: checkedKeys, halfChecked: halfCheckedKeys };
Expand Down
2 changes: 1 addition & 1 deletion source/components/TreeSelect/rcTree/TreeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class TreeNode extends React.Component {
className={classNames(
`${prefixCls}-checkbox`,
checked && `${prefixCls}-checkbox-checked`,
!checked && halfChecked && `${prefixCls}-checkbox-indeterminate`,
halfChecked && `${prefixCls}-checkbox-indeterminate`,
(disabled || disableCheckbox) && `${prefixCls}-checkbox-disabled`,
)}
onClick={this.onCheck}
Expand Down
22 changes: 15 additions & 7 deletions source/components/TreeSelect/rcTree/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,14 @@ export function convertDataToTree(treeData, processer) {

const { processProps = internalProcessProps } = processer || {};
const list = Array.isArray(treeData) ? treeData : [treeData];
return list.map(({ children, ...props }, index) => {
return list.map((item, index) => {
const { children, ...props }=item;
const childrenNodes = convertDataToTree(children, processer);

if(item.childCount===undefined){
item.childCount=-1;//表示用户未给此数据源赋值,不能执行半选判断逻辑
}
return (
<TreeNode key={props.key} {...processProps(props)}>
<TreeNode key={props.key} _data={item} {...processProps(props)}>
{childrenNodes}
</TreeNode>
);
Expand Down Expand Up @@ -275,7 +278,6 @@ export function conductCheck(keyList, isCheck, keyEntities, status, loadData, lo
(checkStatus.halfCheckedKeys || []).forEach((key) => {
halfCheckedKeys[key] = true;
});

// Conduct up
function conductUp(key) {
if (checkedKeys[key] === isCheck) return;
Expand All @@ -290,14 +292,16 @@ export function conductCheck(keyList, isCheck, keyEntities, status, loadData, lo
// Check child node checked status
let everyChildChecked = true;
let someChildChecked = false; // Child checked or half checked

let checkedNum=0;
(children || [])
.filter(child => !isCheckDisabled(child.node))
.forEach((child) => {
let childKey = child.key;
const childChecked = checkedKeys[childKey];
const childHalfChecked = halfCheckedKeys[childKey];

if(childChecked){
checkedNum++;
}
if (childChecked || childHalfChecked) someChildChecked = true;
if (
// 取消勾选
Expand All @@ -312,7 +316,11 @@ export function conductCheck(keyList, isCheck, keyEntities, status, loadData, lo

// Update checked status
if (isCheck) {
checkedKeys[key] = everyChildChecked;
if(node.props._data&&node.props._data.childCount!=undefined){
checkedKeys[key] = everyChildChecked && checkedNum>=node.props._data.childCount;
}else{
checkedKeys[key] = everyChildChecked;
}
} else {
checkedKeys[key] = false;
}
Expand Down
5 changes: 4 additions & 1 deletion source/components/TreeSelect/rcTreeSelect/Base/BasePopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class BasePopup extends React.Component {
PropTypes.bool,
PropTypes.node,
]),
doCheckChildInSearch: PropTypes.bool,
treeCheckStrictly: PropTypes.bool,
treeDefaultExpandAll: PropTypes.bool,
treeDefaultExpandedKeys: PropTypes.array,
Expand Down Expand Up @@ -173,7 +174,8 @@ class BasePopup extends React.Component {
renderSearch,
renderResetItem,
autoExpandParent,
icon
icon,
doCheckChildInSearch
} = this.props;
const { rcTreeSelect: {
onPopupKeyDown,
Expand Down Expand Up @@ -213,6 +215,7 @@ class BasePopup extends React.Component {
} else {
$tree = (
<Tree
doCheckChildInSearch={doCheckChildInSearch}
autoExpandParent={autoExpandParent}
prefixCls={`${prefixCls}-tree`}
className={classNames(!showIcon && `${prefixCls}-tree-icon-hide`)}
Expand Down
3 changes: 2 additions & 1 deletion source/components/TreeSelect/rcTreeSelect/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Select extends React.Component {
editable: PropTypes.bool,
esc: PropTypes.bool,
required: PropTypes.bool,

doCheckChildInSearch: PropTypes.bool,
defaultOpen: PropTypes.bool,
defaultValue: valueProp,

Expand Down Expand Up @@ -1095,6 +1095,7 @@ class Select extends React.Component {
focused,
dropdownPrefixCls: `${prefixCls}-dropdown`,
ariaId: this.ariaId,
doCheckChildInSearch:this.props.doCheckChildInSearch
};

if (!isMultiple) {
Expand Down

0 comments on commit f329ccf

Please sign in to comment.