diff --git a/CHANGELOG.md b/CHANGELOG.md index bc93286..04336a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ ## changelog +## 0.7.2 + +修复锁定组件影响,锁定中无法拖拽,缩放,旋转。 + +## 0.7.1 + +修复锁定组件无法选中解锁。 + + ## 0.7.0 已支持组件旋转! diff --git a/packages/dooringx-doc/src/changelog/1.1.md b/packages/dooringx-doc/src/changelog/1.1.md index b54e960..3218b42 100644 --- a/packages/dooringx-doc/src/changelog/1.1.md +++ b/packages/dooringx-doc/src/changelog/1.1.md @@ -6,6 +6,15 @@ order: 1 ## changelog +## 0.7.2 + +修复锁定组件影响,锁定中无法拖拽,缩放,旋转。 + +## 0.7.1 + +修复锁定组件无法选中解锁。 + + ## 0.7.0 已支持组件旋转! diff --git a/packages/dooringx-example/src/layouts/index.tsx b/packages/dooringx-example/src/layouts/index.tsx index 2d4694d..f8d0dba 100644 --- a/packages/dooringx-example/src/layouts/index.tsx +++ b/packages/dooringx-example/src/layouts/index.tsx @@ -2,7 +2,7 @@ * @Author: yehuozhili * @Date: 2021-07-07 14:51:17 * @LastEditors: yehuozhili - * @LastEditTime: 2021-07-13 19:55:15 + * @LastEditTime: 2021-07-27 16:24:29 * @FilePath: \dooringx\packages\dooringx-example\src\layouts\index.tsx */ import { Button } from 'antd'; @@ -47,6 +47,24 @@ const ContextMenu = () => { > +
{ + commander.exec('lock'); + handleclick(); + }} + > + +
+
{ + commander.exec('unlock'); + handleclick(); + }} + > + +
); }; diff --git a/packages/dooringx-example/src/plugin/commands/lock.ts b/packages/dooringx-example/src/plugin/commands/lock.ts new file mode 100644 index 0000000..21e414d --- /dev/null +++ b/packages/dooringx-example/src/plugin/commands/lock.ts @@ -0,0 +1,27 @@ +/* + * @Author: yehuozhili + * @Date: 2021-07-27 16:19:58 + * @LastEditors: yehuozhili + * @LastEditTime: 2021-07-27 16:19:59 + * @FilePath: \dooringx\packages\dooringx-example\src\plugin\commands\lock.ts + */ +import deepcopy from 'deepcopy'; +import { CommanderItemFactory } from 'dooringx-lib'; +import { IStoreData } from 'dooringx-lib/dist/core/store/storetype'; + +const lock = new CommanderItemFactory( + 'lock', + '', + (store) => { + const clonedata: IStoreData = deepcopy(store.getData()); + clonedata.block.forEach((v) => { + if (v.focus) { + v.canDrag = false; + } + }); + store.setData(clonedata); + }, + '锁定' +); + +export default lock; diff --git a/packages/dooringx-example/src/plugin/commands/unlock.ts b/packages/dooringx-example/src/plugin/commands/unlock.ts new file mode 100644 index 0000000..7ee3552 --- /dev/null +++ b/packages/dooringx-example/src/plugin/commands/unlock.ts @@ -0,0 +1,27 @@ +/* + * @Author: yehuozhili + * @Date: 2021-07-27 16:20:04 + * @LastEditors: yehuozhili + * @LastEditTime: 2021-07-27 16:20:20 + * @FilePath: \dooringx\packages\dooringx-example\src\plugin\commands\unlock.ts + */ +import deepcopy from 'deepcopy'; +import { CommanderItemFactory } from 'dooringx-lib'; +import { IStoreData } from 'dooringx-lib/dist/core/store/storetype'; + +const unlock = new CommanderItemFactory( + 'unlock', + '', + (store) => { + const clonedata: IStoreData = deepcopy(store.getData()); + clonedata.block.forEach((v) => { + if (v.focus) { + v.canDrag = true; + } + }); + store.setData(clonedata); + }, + '解锁' +); + +export default unlock; diff --git a/packages/dooringx-lib/package.json b/packages/dooringx-lib/package.json index 95c1f08..5026673 100644 --- a/packages/dooringx-lib/package.json +++ b/packages/dooringx-lib/package.json @@ -1,5 +1,5 @@ { - "version": "0.7.0", + "version": "0.7.2", "license": "MIT", "main": "dist/index.js", "module": "dist/dooringx-lib.esm.js", diff --git a/packages/dooringx-lib/src/core/innerDrag/index.ts b/packages/dooringx-lib/src/core/innerDrag/index.ts index ecb4a6a..d7f6922 100644 --- a/packages/dooringx-lib/src/core/innerDrag/index.ts +++ b/packages/dooringx-lib/src/core/innerDrag/index.ts @@ -1,5 +1,5 @@ import { RefObject } from 'react'; -import { blockFocus, containerFocusRemove } from '../focusHandler'; +import { blockFocus } from '../focusHandler'; import { marklineConfig } from '../markline/marklineConfig'; import { resizerMouseMove, resizerMouseUp } from '../resizeHandler'; import { selectRangeMouseMove, selectData, selectRangeMouseUp } from '../selectRange'; @@ -22,14 +22,16 @@ export const innerDrag = function ( onMouseDown: (e: React.MouseEvent) => { //e.preventDefault(); e.stopPropagation(); - if (!item.canDrag) { - containerFocusRemove(config).onMouseDown(e); - return; - } - blockFocus(e, item, config); + if (item.id && innerDragState.lastClick && item.id !== innerDragState.lastClick.id) { contextMenuState.unmountContextMenu(); } + //candrag给选中,不给拖 + blockFocus(e, item, config); + if (!item.canDrag) { + //containerFocusRemove(config).onMouseDown(e); + return; + } innerDragState.lastClick = item; if (item.position === 'static') { diff --git a/packages/dooringx-lib/src/core/resizeHandler/index.tsx b/packages/dooringx-lib/src/core/resizeHandler/index.tsx index b06ac36..ef3576e 100644 --- a/packages/dooringx-lib/src/core/resizeHandler/index.tsx +++ b/packages/dooringx-lib/src/core/resizeHandler/index.tsx @@ -185,7 +185,7 @@ export function BlockResizer(props: BlockResizerProps) { const rotate = props.data.rotate.value; const cursorMap = getCursor(rotate); const render = useMemo(() => { - if (props.data.focus && props.data.resize) { + if (props.data.focus && props.data.resize && props.data.canDrag) { return ( <> {directionArr.map((v) => { diff --git a/packages/dooringx-lib/src/core/rotateHandler/index.tsx b/packages/dooringx-lib/src/core/rotateHandler/index.tsx index e1bb09b..06b1d58 100644 --- a/packages/dooringx-lib/src/core/rotateHandler/index.tsx +++ b/packages/dooringx-lib/src/core/rotateHandler/index.tsx @@ -2,7 +2,7 @@ * @Author: yehuozhili * @Date: 2021-07-21 20:51:58 * @LastEditors: yehuozhili - * @LastEditTime: 2021-07-27 14:53:15 + * @LastEditTime: 2021-07-27 16:32:30 * @FilePath: \dooringx\packages\dooringx-lib\src\core\rotateHandler\index.tsx */ import React from 'react'; @@ -90,7 +90,7 @@ interface RotateResizerProps { } export function RotateResizer(props: RotateResizerProps) { const render = useMemo(() => { - if (props.data.focus && props.data.rotate.canRotate) { + if (props.data.focus && props.data.rotate.canRotate && props.data.canDrag) { return (
{