update 0.3.0
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-05-15 12:49:28
|
* @Date: 2021-05-15 12:49:28
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-07-10 19:08:25
|
* @LastEditTime: 2021-07-12 20:19:38
|
||||||
* @FilePath: \dooringx\packages\dooringx-example\src\pages\index.tsx
|
* @FilePath: \dooringx\packages\dooringx-example\src\pages\index.tsx
|
||||||
*/
|
*/
|
||||||
import {
|
import {
|
||||||
@@ -33,7 +33,7 @@ export default function IndexPage() {
|
|||||||
const [state] = useStoreState(config, subscribeFn, everyFn);
|
const [state] = useStoreState(config, subscribeFn, everyFn);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div {...innerContainerDragUp()}>
|
<div {...innerContainerDragUp(config)}>
|
||||||
<div style={{ height: HeaderHeight }}>
|
<div style={{ height: HeaderHeight }}>
|
||||||
head
|
head
|
||||||
<button
|
<button
|
||||||
@@ -64,11 +64,11 @@ export default function IndexPage() {
|
|||||||
<LeftConfig config={config}></LeftConfig>
|
<LeftConfig config={config}></LeftConfig>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ContainerWrapper>
|
<ContainerWrapper config={config}>
|
||||||
<>
|
<>
|
||||||
<Control
|
<Control
|
||||||
config={config}
|
config={config}
|
||||||
style={{ position: 'fixed', bottom: '60px', right: '450px' }}
|
style={{ position: 'fixed', bottom: '60px', right: '450px', zIndex: 100 }}
|
||||||
></Control>
|
></Control>
|
||||||
<Container state={state} config={config} context="edit"></Container>
|
<Container state={state} config={config} context="edit"></Container>
|
||||||
</>
|
</>
|
||||||
|
@@ -2,13 +2,18 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-01-31 20:44:16
|
* @Date: 2021-01-31 20:44:16
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-07-12 15:22:17
|
* @LastEditTime: 2021-07-12 21:00:48
|
||||||
* @FilePath: \dooringx\packages\dooringx-lib\README.md
|
* @FilePath: \dooringx\packages\dooringx-lib\README.md
|
||||||
-->
|
-->
|
||||||
|
|
||||||
## Dooringx-lib
|
## Dooringx-lib
|
||||||
## changelog
|
## changelog
|
||||||
|
|
||||||
|
- 0.3.0
|
||||||
|
1、增加标尺,ContainerWrapper需要传递config才可使用。
|
||||||
|
2、修改容器最小拖动667。修复画布缩放下拖拽时与鼠标距离不一致。
|
||||||
|
3、innerContainerDragUp需要传递config。
|
||||||
|
|
||||||
- 0.2.0 commander的传递进行修改,可以获得config了,commander不再从index中导出 ,需要使用时从config中获取。增加左侧类名,方便自定义。
|
- 0.2.0 commander的传递进行修改,可以获得config了,commander不再从index中导出 ,需要使用时从config中获取。增加左侧类名,方便自定义。
|
||||||
- 0.1.10 修改eslint依赖推荐
|
- 0.1.10 修改eslint依赖推荐
|
||||||
- 0.1.9 增加全局body设置
|
- 0.1.9 增加全局body设置
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "0.2.0",
|
"version": "0.3.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
|
@@ -61,8 +61,8 @@ function Blocks(props: PropsWithChildren<BlockProps>) {
|
|||||||
|
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
const innerDragData = useMemo(() => {
|
const innerDragData = useMemo(() => {
|
||||||
return { ...innerDrag(props.data, ref) };
|
return { ...innerDrag(props.data, ref, props.config) };
|
||||||
}, [props.data]);
|
}, [props.data, props.config]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fn = () => {
|
const fn = () => {
|
||||||
@@ -133,7 +133,7 @@ function Blocks(props: PropsWithChildren<BlockProps>) {
|
|||||||
{...innerDragData}
|
{...innerDragData}
|
||||||
onContextMenu={(e) => {
|
onContextMenu={(e) => {
|
||||||
if (props.data.name !== 'modalMask') {
|
if (props.data.name !== 'modalMask') {
|
||||||
contextMenuEvent(e, ref);
|
contextMenuEvent(e, ref, props.config);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@@ -2,7 +2,6 @@ import { containerDragResolve } from '../core/crossDrag';
|
|||||||
import { containerFocusRemove } from '../core/focusHandler';
|
import { containerFocusRemove } from '../core/focusHandler';
|
||||||
import { innerContainerDrag } from '../core/innerDrag';
|
import { innerContainerDrag } from '../core/innerDrag';
|
||||||
import { NormalMarkLineRender } from '../core/markline';
|
import { NormalMarkLineRender } from '../core/markline';
|
||||||
import { scaleState } from '../core/scale/state';
|
|
||||||
import { IStoreData } from '../core/store/storetype';
|
import { IStoreData } from '../core/store/storetype';
|
||||||
import { wrapperMoveState } from './wrapperMove/event';
|
import { wrapperMoveState } from './wrapperMove/event';
|
||||||
import { CSSProperties, PropsWithChildren, useMemo } from 'react';
|
import { CSSProperties, PropsWithChildren, useMemo } from 'react';
|
||||||
@@ -22,14 +21,14 @@ interface ContainerProps {
|
|||||||
}
|
}
|
||||||
function Container(props: PropsWithChildren<ContainerProps>) {
|
function Container(props: PropsWithChildren<ContainerProps>) {
|
||||||
const { editContainerStyle, previewContainerStyle } = props;
|
const { editContainerStyle, previewContainerStyle } = props;
|
||||||
|
const scaleState = props.config.getScaleState();
|
||||||
const transform = useMemo(() => {
|
const transform = useMemo(() => {
|
||||||
if (props.context === 'edit') {
|
if (props.context === 'edit') {
|
||||||
return `scale(${scaleState.value}) translate(${wrapperMoveState.needX}px, ${wrapperMoveState.needY}px)`;
|
return `scale(${scaleState.value}) translate(${wrapperMoveState.needX}px, ${wrapperMoveState.needY}px)`;
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}, [props.context]);
|
}, [props.context, scaleState]);
|
||||||
|
|
||||||
const bgColor = () => {
|
const bgColor = () => {
|
||||||
const isEdit = props.config.getStoreChanger().isEdit();
|
const isEdit = props.config.getStoreChanger().isEdit();
|
||||||
@@ -63,11 +62,13 @@ function Container(props: PropsWithChildren<ContainerProps>) {
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
...editContainerStyle,
|
...editContainerStyle,
|
||||||
}}
|
}}
|
||||||
{...(props.context === 'edit' ? containerDragResolve : null)}
|
{...(props.context === 'edit' ? containerDragResolve(props.config) : null)}
|
||||||
{...(props.context === 'edit' ? innerContainerDrag() : null)}
|
{...(props.context === 'edit' ? innerContainerDrag(props.config) : null)}
|
||||||
{...(props.context === 'edit' ? containerFocusRemove() : null)}
|
{...(props.context === 'edit' ? containerFocusRemove(props.config) : null)}
|
||||||
>
|
>
|
||||||
{props.context === 'edit' && <NormalMarkLineRender></NormalMarkLineRender>}
|
{props.context === 'edit' && (
|
||||||
|
<NormalMarkLineRender config={props.config}></NormalMarkLineRender>
|
||||||
|
)}
|
||||||
{props.state.block.map((v) => {
|
{props.state.block.map((v) => {
|
||||||
return (
|
return (
|
||||||
<Blocks
|
<Blocks
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-02-04 10:32:45
|
* @Date: 2021-02-04 10:32:45
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-07-12 15:21:27
|
* @LastEditTime: 2021-07-12 17:12:35
|
||||||
* @FilePath: \dooringx\packages\dooringx-lib\src\components\leftConfig.tsx
|
* @FilePath: \dooringx\packages\dooringx-lib\src\components\leftConfig.tsx
|
||||||
*/
|
*/
|
||||||
import React, { ReactNode, useEffect, useMemo, useState } from 'react';
|
import React, { ReactNode, useEffect, useMemo, useState } from 'react';
|
||||||
@@ -144,8 +144,8 @@ function LeftConfig(props: LeftConfigProps) {
|
|||||||
}
|
}
|
||||||
}, [menuSelect, props.config, leftMapRenderListCategory, search]);
|
}, [menuSelect, props.config, leftMapRenderListCategory, search]);
|
||||||
|
|
||||||
const [isCollapse, setCollapse] = useState(false);
|
const [isCollapse, setCollapse] = useState(props.config.getCollapse());
|
||||||
const [renderCollapse, setRenderCollaspe] = useState(false);
|
const [renderCollapse, setRenderCollaspe] = useState(props.config.getCollapse());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ display: 'flex', height: '100%' }}>
|
<div style={{ display: 'flex', height: '100%' }}>
|
||||||
@@ -164,11 +164,15 @@ function LeftConfig(props: LeftConfigProps) {
|
|||||||
setCollapse((pre) => {
|
setCollapse((pre) => {
|
||||||
if (pre) {
|
if (pre) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
props.config.collapsed = false;
|
||||||
setRenderCollaspe(false);
|
setRenderCollaspe(false);
|
||||||
|
props.config.getStore().forceUpdate();
|
||||||
}, 300);
|
}, 300);
|
||||||
return !pre;
|
return !pre;
|
||||||
} else {
|
} else {
|
||||||
|
props.config.collapsed = true;
|
||||||
setRenderCollaspe(true);
|
setRenderCollaspe(true);
|
||||||
|
props.config.getStore().forceUpdate();
|
||||||
return !pre;
|
return !pre;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -2,12 +2,11 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-14 05:42:13
|
* @Date: 2021-03-14 05:42:13
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-07-10 16:06:33
|
* @LastEditTime: 2021-07-12 20:36:30
|
||||||
* @FilePath: \DooringV2\packages\dooringx-lib\src\components\rightConfig.tsx
|
* @FilePath: \dooringx\packages\dooringx-lib\src\components\rightConfig.tsx
|
||||||
*/
|
*/
|
||||||
import { CreateOptionsRes } from '../core/components/formTypes';
|
import { CreateOptionsRes } from '../core/components/formTypes';
|
||||||
import { IBlockType, IStoreData } from '../core/store/storetype';
|
import { IBlockType, IStoreData } from '../core/store/storetype';
|
||||||
import { store } from '../runtime/store';
|
|
||||||
import { PropsWithChildren, useEffect, useMemo, useState } from 'react';
|
import { PropsWithChildren, useEffect, useMemo, useState } from 'react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Tabs, Input, Row, Col, Checkbox } from 'antd';
|
import { Tabs, Input, Row, Col, Checkbox } from 'antd';
|
||||||
@@ -33,6 +32,9 @@ function RightConfig(props: PropsWithChildren<RightConfigProps>) {
|
|||||||
const rightMapRenderListCategory = useMemo(() => {
|
const rightMapRenderListCategory = useMemo(() => {
|
||||||
return props.config.getConfig().rightRenderListCategory;
|
return props.config.getConfig().rightRenderListCategory;
|
||||||
}, [props.config]);
|
}, [props.config]);
|
||||||
|
|
||||||
|
const store = props.config.getStore();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fn = () => {
|
const fn = () => {
|
||||||
let item: IBlockType | undefined;
|
let item: IBlockType | undefined;
|
||||||
@@ -52,7 +54,7 @@ function RightConfig(props: PropsWithChildren<RightConfigProps>) {
|
|||||||
return () => {
|
return () => {
|
||||||
unregist();
|
unregist();
|
||||||
};
|
};
|
||||||
}, []);
|
}, [store]);
|
||||||
const render = useMemo(() => {
|
const render = useMemo(() => {
|
||||||
return (type: string, current: IBlockType) => {
|
return (type: string, current: IBlockType) => {
|
||||||
const fn = () => props.config.getComponentRegister().getComp(current.name);
|
const fn = () => props.config.getComponentRegister().getComp(current.name);
|
||||||
|
@@ -2,13 +2,13 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-02-21 22:17:29
|
* @Date: 2021-02-21 22:17:29
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-04-05 18:24:27
|
* @LastEditTime: 2021-07-12 20:33:14
|
||||||
* @FilePath: \dooringv2\src\components\wrapperMove\event.ts
|
* @FilePath: \dooringx\packages\dooringx-lib\src\components\wrapperMove\event.ts
|
||||||
*/
|
*/
|
||||||
import { store } from '../../runtime/store';
|
|
||||||
import { RefObject } from 'react';
|
import { RefObject } from 'react';
|
||||||
import { containerResizer } from '../../core/resizeHandler/containerResizer';
|
import { containerResizer } from '../../core/resizeHandler/containerResizer';
|
||||||
import { contextMenuState } from '../../core/contextMenu';
|
import { contextMenuState } from '../../core/contextMenu';
|
||||||
|
import UserConfig from '../../config';
|
||||||
|
|
||||||
export interface WrapperMoveStateProps {
|
export interface WrapperMoveStateProps {
|
||||||
isDrag: boolean;
|
isDrag: boolean;
|
||||||
@@ -28,7 +28,9 @@ export const wrapperMoveState: WrapperMoveStateProps = {
|
|||||||
ref: null,
|
ref: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const wrapperEvent = (ref: RefObject<HTMLDivElement>) => {
|
export const wrapperEvent = (ref: RefObject<HTMLDivElement>, config: UserConfig) => {
|
||||||
|
const scale = config.getScaleState().value;
|
||||||
|
const store = config.getStore();
|
||||||
return {
|
return {
|
||||||
onMouseDown: (e: React.MouseEvent) => {
|
onMouseDown: (e: React.MouseEvent) => {
|
||||||
// e.preventDefault();// 不能使用preventDefault 否则弹窗输入框焦点无法触发
|
// e.preventDefault();// 不能使用preventDefault 否则弹窗输入框焦点无法触发
|
||||||
@@ -49,10 +51,11 @@ export const wrapperEvent = (ref: RefObject<HTMLDivElement>) => {
|
|||||||
if (wrapperMoveState.isDrag) {
|
if (wrapperMoveState.isDrag) {
|
||||||
const diffX = e.clientX - wrapperMoveState.startX;
|
const diffX = e.clientX - wrapperMoveState.startX;
|
||||||
const diffY = e.clientY - wrapperMoveState.startY;
|
const diffY = e.clientY - wrapperMoveState.startY;
|
||||||
wrapperMoveState.needX = wrapperMoveState.needX + diffX;
|
wrapperMoveState.needX = wrapperMoveState.needX + diffX / scale;
|
||||||
wrapperMoveState.needY = wrapperMoveState.needY + diffY;
|
wrapperMoveState.needY = wrapperMoveState.needY + diffY / scale;
|
||||||
wrapperMoveState.startX = e.clientX;
|
wrapperMoveState.startX = e.clientX;
|
||||||
wrapperMoveState.startY = e.clientY;
|
wrapperMoveState.startY = e.clientY;
|
||||||
|
|
||||||
store.forceUpdate();
|
store.forceUpdate();
|
||||||
}
|
}
|
||||||
containerResizer.onMouseMove(e);
|
containerResizer.onMouseMove(e);
|
||||||
|
@@ -2,15 +2,18 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-14 04:29:09
|
* @Date: 2021-03-14 04:29:09
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-07-12 15:24:29
|
* @LastEditTime: 2021-07-12 19:47:39
|
||||||
* @FilePath: \dooringx\packages\dooringx-lib\src\components\wrapperMove\index.tsx
|
* @FilePath: \dooringx\packages\dooringx-lib\src\components\wrapperMove\index.tsx
|
||||||
*/
|
*/
|
||||||
import { AllHTMLAttributes, CSSProperties, PropsWithChildren, useRef } from 'react';
|
import { AllHTMLAttributes, CSSProperties, PropsWithChildren, useRef } from 'react';
|
||||||
import { wrapperEvent } from './event';
|
import { wrapperEvent } from './event';
|
||||||
import { onWheelEvent } from '../../core/scale';
|
import { onWheelEvent } from '../../core/scale';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import Ticker from './ticker';
|
||||||
|
import UserConfig from '../../config';
|
||||||
|
|
||||||
export interface ContainerWrapperProps extends AllHTMLAttributes<HTMLDivElement> {
|
export interface ContainerWrapperProps extends AllHTMLAttributes<HTMLDivElement> {
|
||||||
|
config: UserConfig;
|
||||||
classNames?: string;
|
classNames?: string;
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
}
|
}
|
||||||
@@ -33,11 +36,12 @@ function ContainerWrapper(props: PropsWithChildren<ContainerWrapperProps>) {
|
|||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
...style,
|
...style,
|
||||||
}}
|
}}
|
||||||
{...wrapperEvent(ref)}
|
{...wrapperEvent(ref, props.config)}
|
||||||
{...onWheelEvent}
|
{...onWheelEvent(props.config)}
|
||||||
{...rest}
|
{...rest}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
<Ticker config={props.config}></Ticker>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
147
packages/dooringx-lib/src/components/wrapperMove/ticker.tsx
Normal file
147
packages/dooringx-lib/src/components/wrapperMove/ticker.tsx
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
/*
|
||||||
|
* @Author: yehuozhili
|
||||||
|
* @Date: 2021-07-12 15:54:35
|
||||||
|
* @LastEditors: yehuozhili
|
||||||
|
* @LastEditTime: 2021-07-12 19:21:35
|
||||||
|
* @FilePath: \dooringx\packages\dooringx-lib\src\components\wrapperMove\ticker.tsx
|
||||||
|
*/
|
||||||
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
|
import UserConfig from '../../config';
|
||||||
|
|
||||||
|
const width = '20px';
|
||||||
|
const indent = 50;
|
||||||
|
|
||||||
|
function Ticker(props: { config: UserConfig }) {
|
||||||
|
const topRef = useRef<HTMLDivElement>(null);
|
||||||
|
const leftRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [topRender, setTopRender] = useState(0);
|
||||||
|
const [leftRender, setLeftRender] = useState(0);
|
||||||
|
|
||||||
|
const scale = props.config.getScaleState().value;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
|
if (topRef.current) {
|
||||||
|
const width = topRef.current.getBoundingClientRect().width;
|
||||||
|
const renderWidth = Math.ceil(width / 10 / scale);
|
||||||
|
setTopRender(renderWidth);
|
||||||
|
}
|
||||||
|
// left可以不用放,但为了更新统一
|
||||||
|
if (leftRef.current) {
|
||||||
|
const height = leftRef.current.getBoundingClientRect().height;
|
||||||
|
const renderHeight = Math.ceil(height / 10 / scale);
|
||||||
|
setLeftRender(renderHeight);
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
};
|
||||||
|
}, [props.config, props.config.collapsed, scale]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<div
|
||||||
|
ref={topRef}
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: 0,
|
||||||
|
left: indent,
|
||||||
|
width: '100%',
|
||||||
|
height: width,
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{Array(topRender)
|
||||||
|
.fill(1)
|
||||||
|
.map((_, i) => {
|
||||||
|
if (i % 10 === 0) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
style={{
|
||||||
|
background: 'rgb(204, 204, 204)',
|
||||||
|
width: '1px',
|
||||||
|
height: '12px',
|
||||||
|
position: 'relative',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: '20px',
|
||||||
|
fontSize: '10px',
|
||||||
|
left: '-2px',
|
||||||
|
userSelect: 'none',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{i}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
style={{ background: 'rgb(204, 204, 204)', width: '1px', height: '6px' }}
|
||||||
|
></div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
ref={leftRef}
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: indent,
|
||||||
|
left: 0,
|
||||||
|
width: width,
|
||||||
|
height: '100%',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
flexDirection: 'column',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{Array(leftRender)
|
||||||
|
.fill(1)
|
||||||
|
.map((_, i) => {
|
||||||
|
if (i % 10 === 0) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
style={{
|
||||||
|
background: 'rgb(204, 204, 204)',
|
||||||
|
width: '12px',
|
||||||
|
height: '1px',
|
||||||
|
position: 'relative',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
left: '20px',
|
||||||
|
fontSize: '10px',
|
||||||
|
top: '-2px',
|
||||||
|
userSelect: 'none',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{i}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={i}
|
||||||
|
style={{ background: 'rgb(204, 204, 204)', width: '6px', height: '1px' }}
|
||||||
|
></div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Ticker;
|
@@ -2,7 +2,7 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-02-25 21:16:58
|
* @Date: 2021-02-25 21:16:58
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-07-12 14:49:32
|
* @LastEditTime: 2021-07-12 16:49:46
|
||||||
* @FilePath: \dooringx\packages\dooringx-lib\src\config\index.tsx
|
* @FilePath: \dooringx\packages\dooringx-lib\src\config\index.tsx
|
||||||
*/
|
*/
|
||||||
import { IBlockType, IStoreData } from '../core/store/storetype';
|
import { IBlockType, IStoreData } from '../core/store/storetype';
|
||||||
@@ -321,6 +321,7 @@ export class UserConfig {
|
|||||||
public eventCenter: EventCenter;
|
public eventCenter: EventCenter;
|
||||||
public dataCenter: DataCenter;
|
public dataCenter: DataCenter;
|
||||||
public scaleState = scaleState;
|
public scaleState = scaleState;
|
||||||
|
public collapsed = false;
|
||||||
constructor(initConfig?: Partial<InitConfig>) {
|
constructor(initConfig?: Partial<InitConfig>) {
|
||||||
const mergeConfig = userConfigMerge(defaultConfig, initConfig);
|
const mergeConfig = userConfigMerge(defaultConfig, initConfig);
|
||||||
this.initConfig = mergeConfig;
|
this.initConfig = mergeConfig;
|
||||||
@@ -370,6 +371,10 @@ export class UserConfig {
|
|||||||
this.toRegist();
|
this.toRegist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getCollapse() {
|
||||||
|
return this.collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
getStoreJSON() {
|
getStoreJSON() {
|
||||||
return JSON.stringify(this.store.getData());
|
return JSON.stringify(this.store.getData());
|
||||||
}
|
}
|
||||||
|
@@ -2,14 +2,14 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-14 04:29:09
|
* @Date: 2021-03-14 04:29:09
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-07-05 22:46:15
|
* @LastEditTime: 2021-07-12 20:31:47
|
||||||
* @FilePath: \DooringV2\packages\dooring-v2-lib\src\core\contextMenu\index.tsx
|
* @FilePath: \dooringx\packages\dooringx-lib\src\core\contextMenu\index.tsx
|
||||||
*/
|
*/
|
||||||
import { Button } from 'antd';
|
import { Button } from 'antd';
|
||||||
import React, { RefObject, useState } from 'react';
|
import React, { RefObject, useState } from 'react';
|
||||||
import { ReactElement } from 'react';
|
import { ReactElement } from 'react';
|
||||||
import ReactDOM, { unmountComponentAtNode } from 'react-dom';
|
import ReactDOM, { unmountComponentAtNode } from 'react-dom';
|
||||||
import { scaleState } from '../scale/state';
|
import UserConfig from '../../config';
|
||||||
import { isMac } from '../utils';
|
import { isMac } from '../utils';
|
||||||
|
|
||||||
const ContextMenu = () => {
|
const ContextMenu = () => {
|
||||||
@@ -68,9 +68,11 @@ export const contextMenuState: ContextMenuStateProps = {
|
|||||||
|
|
||||||
export function contextMenuEvent(
|
export function contextMenuEvent(
|
||||||
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
||||||
ref: RefObject<HTMLDivElement>
|
ref: RefObject<HTMLDivElement>,
|
||||||
|
userConfig: UserConfig
|
||||||
) {
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
const scaleState = userConfig.getScaleState();
|
||||||
contextMenuState.unmountContextMenu();
|
contextMenuState.unmountContextMenu();
|
||||||
const config: MutationObserverInit = {
|
const config: MutationObserverInit = {
|
||||||
attributes: true,
|
attributes: true,
|
||||||
|
@@ -2,15 +2,14 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-14 04:29:09
|
* @Date: 2021-03-14 04:29:09
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-07-10 18:34:40
|
* @LastEditTime: 2021-07-12 20:11:56
|
||||||
* @FilePath: \dooringx\packages\dooringx-lib\src\core\crossDrag\index.ts
|
* @FilePath: \dooringx\packages\dooringx-lib\src\core\crossDrag\index.ts
|
||||||
*/
|
*/
|
||||||
import { store } from '../../runtime/store';
|
|
||||||
import { componentRegister } from '../../runtime';
|
|
||||||
import { DragEvent, ReactNode } from 'react';
|
import { DragEvent, ReactNode } from 'react';
|
||||||
import { createBlock } from '../components/createBlock';
|
import { createBlock } from '../components/createBlock';
|
||||||
import { IBlockType } from '../store/storetype';
|
import { IBlockType } from '../store/storetype';
|
||||||
import { deepCopy } from '../utils';
|
import { deepCopy } from '../utils';
|
||||||
|
import UserConfig from '../../config';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -43,42 +42,46 @@ export const dragEventResolve = function (item: LeftRegistComponentMapItem) {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const containerDragResolve = {
|
export const containerDragResolve = (config: UserConfig) => {
|
||||||
onDragStart: () => {},
|
const store = config.getStore();
|
||||||
onDragOver: (e: DragEvent<HTMLDivElement>) => {
|
const componentRegister = config.getComponentRegister();
|
||||||
e.preventDefault();
|
return {
|
||||||
},
|
onDragStart: () => {},
|
||||||
onDrop: (e: DragEvent<HTMLDivElement>) => {
|
onDragOver: (e: DragEvent<HTMLDivElement>) => {
|
||||||
const offsetX = e.nativeEvent.offsetX;
|
e.preventDefault();
|
||||||
const offestY = e.nativeEvent.offsetY;
|
},
|
||||||
//drop后修改store,
|
onDrop: (e: DragEvent<HTMLDivElement>) => {
|
||||||
if (currentDrag) {
|
const offsetX = e.nativeEvent.offsetX;
|
||||||
// 还需要拿到注册的组件状态
|
const offestY = e.nativeEvent.offsetY;
|
||||||
const origin = componentRegister.getComp(currentDrag.component);
|
//drop后修改store,
|
||||||
if (!origin) {
|
if (currentDrag) {
|
||||||
console.log(currentDrag.component, 'wait the chunk pull compeletely and retry');
|
// 还需要拿到注册的组件状态
|
||||||
return;
|
const origin = componentRegister.getComp(currentDrag.component);
|
||||||
}
|
if (!origin) {
|
||||||
const target = e.target as HTMLElement;
|
console.log(currentDrag.component, 'wait the chunk pull compeletely and retry');
|
||||||
let newblock: IBlockType;
|
return;
|
||||||
if (!origin.needPosition) {
|
|
||||||
newblock = createBlock(
|
|
||||||
origin.initData.top ?? offestY,
|
|
||||||
origin.initData.left ?? offsetX,
|
|
||||||
origin
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
if (target.id !== 'yh-container') {
|
|
||||||
newblock = createBlock(offestY + target.offsetTop, offsetX + target.offsetLeft, origin);
|
|
||||||
} else {
|
|
||||||
newblock = createBlock(offestY, offsetX, origin);
|
|
||||||
}
|
}
|
||||||
|
const target = e.target as HTMLElement;
|
||||||
|
let newblock: IBlockType;
|
||||||
|
if (!origin.needPosition) {
|
||||||
|
newblock = createBlock(
|
||||||
|
origin.initData.top ?? offestY,
|
||||||
|
origin.initData.left ?? offsetX,
|
||||||
|
origin
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (target.id !== 'yh-container') {
|
||||||
|
newblock = createBlock(offestY + target.offsetTop, offsetX + target.offsetLeft, origin);
|
||||||
|
} else {
|
||||||
|
newblock = createBlock(offestY, offsetX, origin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const data = deepCopy(store.getData());
|
||||||
|
data.block.push(newblock);
|
||||||
|
store.setData({ ...data });
|
||||||
}
|
}
|
||||||
const data = deepCopy(store.getData());
|
currentDrag = null;
|
||||||
data.block.push(newblock);
|
},
|
||||||
store.setData({ ...data });
|
onDragEnd: () => {},
|
||||||
}
|
};
|
||||||
currentDrag = null;
|
|
||||||
},
|
|
||||||
onDragEnd: () => {},
|
|
||||||
};
|
};
|
||||||
|
@@ -2,18 +2,19 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-14 04:29:09
|
* @Date: 2021-03-14 04:29:09
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-03-14 12:10:16
|
* @LastEditTime: 2021-07-12 20:48:04
|
||||||
* @FilePath: \dooring-v2\src\core\focusHandler\index.tsx
|
* @FilePath: \dooringx\packages\dooringx-lib\src\core\focusHandler\index.tsx
|
||||||
*/
|
*/
|
||||||
import { store } from '../../runtime/store';
|
|
||||||
import { innerDragState } from '../innerDrag/state';
|
import { innerDragState } from '../innerDrag/state';
|
||||||
import { IBlockType } from '../store/storetype';
|
import { IBlockType } from '../store/storetype';
|
||||||
import { deepCopy } from '../utils';
|
import { deepCopy } from '../utils';
|
||||||
import { selectRangeMouseDown } from '../selectRange';
|
import { selectRangeMouseDown } from '../selectRange';
|
||||||
import { unmountContextMenu } from '../contextMenu';
|
import { unmountContextMenu } from '../contextMenu';
|
||||||
import { focusState } from './state';
|
import { focusState } from './state';
|
||||||
|
import UserConfig from '../../config';
|
||||||
|
|
||||||
export function containerFocusRemove() {
|
export function containerFocusRemove(config: UserConfig) {
|
||||||
|
const store = config.getStore();
|
||||||
const onMouseDown = (e: React.MouseEvent) => {
|
const onMouseDown = (e: React.MouseEvent) => {
|
||||||
const clonedata = deepCopy(store.getData());
|
const clonedata = deepCopy(store.getData());
|
||||||
const newBlock = clonedata.block.map((v: IBlockType) => {
|
const newBlock = clonedata.block.map((v: IBlockType) => {
|
||||||
@@ -23,7 +24,7 @@ export function containerFocusRemove() {
|
|||||||
focusState.blocks = [];
|
focusState.blocks = [];
|
||||||
store.setData({ ...clonedata, block: newBlock });
|
store.setData({ ...clonedata, block: newBlock });
|
||||||
if (!innerDragState.item) {
|
if (!innerDragState.item) {
|
||||||
selectRangeMouseDown(e);
|
selectRangeMouseDown(e, config);
|
||||||
}
|
}
|
||||||
unmountContextMenu();
|
unmountContextMenu();
|
||||||
};
|
};
|
||||||
@@ -32,7 +33,8 @@ export function containerFocusRemove() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function blockFocus(e: React.MouseEvent, item: IBlockType) {
|
export function blockFocus(e: React.MouseEvent, item: IBlockType, config: UserConfig) {
|
||||||
|
const store = config.getStore();
|
||||||
const clonedata = deepCopy(store.getData());
|
const clonedata = deepCopy(store.getData());
|
||||||
if (e.shiftKey) {
|
if (e.shiftKey) {
|
||||||
const newBlock = clonedata.block.map((v: IBlockType) => {
|
const newBlock = clonedata.block.map((v: IBlockType) => {
|
||||||
|
@@ -1,26 +1,30 @@
|
|||||||
import { store } from '../../runtime/store';
|
|
||||||
import { RefObject } from 'react';
|
import { RefObject } from 'react';
|
||||||
import { blockFocus, containerFocusRemove } from '../focusHandler';
|
import { blockFocus, containerFocusRemove } from '../focusHandler';
|
||||||
import { marklineConfig } from '../markline/marklineConfig';
|
import { marklineConfig } from '../markline/marklineConfig';
|
||||||
import { resizerMouseMove, resizerMouseUp } from '../resizeHandler';
|
import { resizerMouseMove, resizerMouseUp } from '../resizeHandler';
|
||||||
import { scaleState } from '../scale/state';
|
|
||||||
import { selectRangeMouseMove, selectData, selectRangeMouseUp } from '../selectRange';
|
import { selectRangeMouseMove, selectData, selectRangeMouseUp } from '../selectRange';
|
||||||
import { IBlockType } from '../store/storetype';
|
import { IBlockType } from '../store/storetype';
|
||||||
import { deepCopy, isMac } from '../utils';
|
import { deepCopy, isMac } from '../utils';
|
||||||
import { wrapperMoveMouseUp } from '../../components/wrapperMove/event';
|
import { wrapperMoveMouseUp } from '../../components/wrapperMove/event';
|
||||||
import { contextMenuState } from '../contextMenu';
|
import { contextMenuState } from '../contextMenu';
|
||||||
import { innerDragState } from './state';
|
import { innerDragState } from './state';
|
||||||
|
import UserConfig from '../../config';
|
||||||
|
|
||||||
export const innerDrag = function (item: IBlockType, ref: RefObject<HTMLDivElement>) {
|
export const innerDrag = function (
|
||||||
|
item: IBlockType,
|
||||||
|
ref: RefObject<HTMLDivElement>,
|
||||||
|
config: UserConfig
|
||||||
|
) {
|
||||||
|
const store = config.getStore();
|
||||||
return {
|
return {
|
||||||
onMouseDown: (e: React.MouseEvent) => {
|
onMouseDown: (e: React.MouseEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (!item.canDrag) {
|
if (!item.canDrag) {
|
||||||
containerFocusRemove().onMouseDown(e);
|
containerFocusRemove(config).onMouseDown(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
blockFocus(e, item);
|
blockFocus(e, item, config);
|
||||||
if (item.id && innerDragState.lastClick && item.id !== innerDragState.lastClick.id) {
|
if (item.id && innerDragState.lastClick && item.id !== innerDragState.lastClick.id) {
|
||||||
contextMenuState.unmountContextMenu();
|
contextMenuState.unmountContextMenu();
|
||||||
}
|
}
|
||||||
@@ -43,8 +47,10 @@ export const innerDrag = function (item: IBlockType, ref: RefObject<HTMLDivEleme
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const innerContainerDrag = function () {
|
export const innerContainerDrag = function (config: UserConfig) {
|
||||||
let lastblock: null | IBlockType;
|
let lastblock: null | IBlockType;
|
||||||
|
const store = config.getStore();
|
||||||
|
const scaleState = config.getScaleState();
|
||||||
const onMouseMove = (e: React.MouseEvent) => {
|
const onMouseMove = (e: React.MouseEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (isMac() && contextMenuState.state) {
|
if (isMac() && contextMenuState.state) {
|
||||||
@@ -96,7 +102,8 @@ export const innerContainerDrag = function () {
|
|||||||
onMouseMove,
|
onMouseMove,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
export const innerContainerDragUp = function () {
|
export const innerContainerDragUp = function (config: UserConfig) {
|
||||||
|
const store = config.getStore();
|
||||||
const onMouseUp = (e: React.MouseEvent) => {
|
const onMouseUp = (e: React.MouseEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
wrapperMoveMouseUp();
|
wrapperMoveMouseUp();
|
||||||
|
@@ -2,22 +2,23 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-14 04:29:09
|
* @Date: 2021-03-14 04:29:09
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-03-14 11:49:50
|
* @LastEditTime: 2021-07-12 20:56:02
|
||||||
* @FilePath: \dooring-v2\src\core\markline\calcRender.ts
|
* @FilePath: \dooringx\packages\dooringx-lib\src\core\markline\calcRender.ts
|
||||||
*/
|
*/
|
||||||
import { store } from '../../runtime/store';
|
|
||||||
import { innerDragState } from '../innerDrag/state';
|
import { innerDragState } from '../innerDrag/state';
|
||||||
import { scaleState } from '../scale/state';
|
|
||||||
import { grideModeRender, gridModeDisplay } from './gridMode';
|
import { grideModeRender, gridModeDisplay } from './gridMode';
|
||||||
import { switchMarklineDisplay } from './normalMode';
|
import { switchMarklineDisplay } from './normalMode';
|
||||||
import { resizeCurrentCalculate } from './resizeMarkline';
|
import { resizeCurrentCalculate } from './resizeMarkline';
|
||||||
import { marklineConfig } from './marklineConfig';
|
import { marklineConfig } from './marklineConfig';
|
||||||
|
import UserConfig from '../../config';
|
||||||
export interface LinesTypes {
|
export interface LinesTypes {
|
||||||
x: number[];
|
x: number[];
|
||||||
y: number[];
|
y: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function marklineCalRender() {
|
export function marklineCalRender(config: UserConfig) {
|
||||||
|
const store = config.getStore();
|
||||||
|
const scaleState = config.getScaleState();
|
||||||
//focus可能好几个,做对比的是拖拽那个
|
//focus可能好几个,做对比的是拖拽那个
|
||||||
const lines: LinesTypes = { x: [], y: [] };
|
const lines: LinesTypes = { x: [], y: [] };
|
||||||
if (innerDragState.item?.position === 'static' || innerDragState.item?.position === 'relative') {
|
if (innerDragState.item?.position === 'static' || innerDragState.item?.position === 'relative') {
|
||||||
@@ -65,15 +66,15 @@ export function marklineCalRender() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (marklineConfig.mode === 'grid' && marklineConfig.isAbsorb) {
|
if (marklineConfig.mode === 'grid' && marklineConfig.isAbsorb) {
|
||||||
gridModeDisplay(left, top, focus);
|
gridModeDisplay(left, top, focus, config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (marklineConfig.mode === 'grid') {
|
if (marklineConfig.mode === 'grid') {
|
||||||
grideModeRender(lines);
|
grideModeRender(lines, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
resizeCurrentCalculate(lines);
|
resizeCurrentCalculate(lines, config);
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
@@ -2,17 +2,18 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-14 04:29:09
|
* @Date: 2021-03-14 04:29:09
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-03-14 11:49:43
|
* @LastEditTime: 2021-07-12 20:56:19
|
||||||
* @FilePath: \dooring-v2\src\core\markline\gridMode.ts
|
* @FilePath: \dooringx\packages\dooringx-lib\src\core\markline\gridMode.ts
|
||||||
*/
|
*/
|
||||||
import { store } from '../../runtime/store';
|
import UserConfig from '../../config';
|
||||||
import { IBlockType } from '../store/storetype';
|
import { IBlockType } from '../store/storetype';
|
||||||
import { deepCopy } from '../utils';
|
import { deepCopy } from '../utils';
|
||||||
import { LinesTypes } from './calcRender';
|
import { LinesTypes } from './calcRender';
|
||||||
import { marklineConfig } from './marklineConfig';
|
import { marklineConfig } from './marklineConfig';
|
||||||
export function gridModeDisplay(left: number, top: number, focus: IBlockType) {
|
export function gridModeDisplay(left: number, top: number, focus: IBlockType, config: UserConfig) {
|
||||||
// 有吸附走吸附,只吸top和left,宽高不需要
|
// 有吸附走吸附,只吸top和left,宽高不需要
|
||||||
// 无吸附拖拽时显示所有网格。
|
// 无吸附拖拽时显示所有网格。
|
||||||
|
const store = config.getStore();
|
||||||
const container = store.getData().container;
|
const container = store.getData().container;
|
||||||
const containerWidth = container.width;
|
const containerWidth = container.width;
|
||||||
const containerHeight = container.height;
|
const containerHeight = container.height;
|
||||||
@@ -55,7 +56,8 @@ export const lastGridStatus: lastGridStatusProps = {
|
|||||||
lastLine: { x: [], y: [] },
|
lastLine: { x: [], y: [] },
|
||||||
};
|
};
|
||||||
|
|
||||||
export function grideModeRender(lines: LinesTypes) {
|
export function grideModeRender(lines: LinesTypes, config: UserConfig) {
|
||||||
|
const store = config.getStore();
|
||||||
const container = store.getData().container;
|
const container = store.getData().container;
|
||||||
const containerWidth = container.width;
|
const containerWidth = container.width;
|
||||||
const containerHeight = container.height;
|
const containerHeight = container.height;
|
||||||
|
@@ -2,11 +2,12 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-14 04:29:09
|
* @Date: 2021-03-14 04:29:09
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-03-14 11:45:22
|
* @LastEditTime: 2021-07-12 20:59:27
|
||||||
* @FilePath: \dooring-v2\src\core\markline\index.tsx
|
* @FilePath: \dooringx\packages\dooringx-lib\src\core\markline\index.tsx
|
||||||
*/
|
*/
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
|
import UserConfig from '../../config';
|
||||||
import { IBlockType } from '../store/storetype';
|
import { IBlockType } from '../store/storetype';
|
||||||
import { marklineCalRender } from './calcRender';
|
import { marklineCalRender } from './calcRender';
|
||||||
|
|
||||||
@@ -62,8 +63,8 @@ export function MarklineY(props: any) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function NormalMarkLineRender() {
|
export function NormalMarkLineRender(props: { config: UserConfig }) {
|
||||||
const lines = marklineCalRender();
|
const lines = marklineCalRender(props.config);
|
||||||
const render = useMemo(() => {
|
const render = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@@ -2,21 +2,22 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-02-18 11:52:38
|
* @Date: 2021-02-18 11:52:38
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-03-14 11:49:58
|
* @LastEditTime: 2021-07-12 20:54:50
|
||||||
* @FilePath: \dooring-v2\src\core\markline\resizeMarkline.ts
|
* @FilePath: \dooringx\packages\dooringx-lib\src\core\markline\resizeMarkline.ts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { store } from '../../runtime/store';
|
|
||||||
import { resizeState } from '../resizeHandler';
|
import { resizeState } from '../resizeHandler';
|
||||||
import { scaleState } from '../scale/state';
|
|
||||||
import { LinesTypes } from './calcRender';
|
import { LinesTypes } from './calcRender';
|
||||||
import { switchMarklineResizeDisplay } from './normalMode';
|
import { switchMarklineResizeDisplay } from './normalMode';
|
||||||
import { marklineConfig } from './marklineConfig';
|
import { marklineConfig } from './marklineConfig';
|
||||||
|
import UserConfig from '../../config';
|
||||||
|
|
||||||
export function resizeCurrentCalculate(lines: LinesTypes) {
|
export function resizeCurrentCalculate(lines: LinesTypes, config: UserConfig) {
|
||||||
const id = resizeState.item?.id;
|
const id = resizeState.item?.id;
|
||||||
|
|
||||||
if (resizeState.ref?.current && id) {
|
if (resizeState.ref?.current && id) {
|
||||||
|
const store = config.getStore();
|
||||||
|
const scaleState = config.getScaleState();
|
||||||
const newblock = store.getData().block;
|
const newblock = store.getData().block;
|
||||||
const unfocus = newblock.filter((v) => v.id !== id);
|
const unfocus = newblock.filter((v) => v.id !== id);
|
||||||
const { width, height } = resizeState.ref.current.getBoundingClientRect();
|
const { width, height } = resizeState.ref.current.getBoundingClientRect();
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-09 15:19:36
|
* @Date: 2021-03-09 15:19:36
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-03-14 04:52:57
|
* @LastEditTime: 2021-07-12 19:25:09
|
||||||
* @FilePath: \dooring-v2\src\core\resizeHandler\containerResizer.ts
|
* @FilePath: \dooringx\packages\dooringx-lib\src\core\resizeHandler\containerResizer.ts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { store } from '../../runtime/store';
|
import { store } from '../../runtime/store';
|
||||||
@@ -15,6 +15,7 @@ export const containerState = {
|
|||||||
isDrag: false,
|
isDrag: false,
|
||||||
startY: 0,
|
startY: 0,
|
||||||
startIndex: 0,
|
startIndex: 0,
|
||||||
|
minHeight: 667,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const containerResizer = {
|
export const containerResizer = {
|
||||||
@@ -29,7 +30,8 @@ export const containerResizer = {
|
|||||||
const diff = ((e.clientY - containerState.startY) / scale) * 2;
|
const diff = ((e.clientY - containerState.startY) / scale) * 2;
|
||||||
const clonedata: IStoreData = deepCopy(store.getData());
|
const clonedata: IStoreData = deepCopy(store.getData());
|
||||||
const height = clonedata.container.height;
|
const height = clonedata.container.height;
|
||||||
let tmpHeight = height + diff < 600 ? 600 : height + diff;
|
let tmpHeight =
|
||||||
|
height + diff < containerState.minHeight ? containerState.minHeight : height + diff;
|
||||||
clonedata.container.height = tmpHeight;
|
clonedata.container.height = tmpHeight;
|
||||||
store.setData(clonedata);
|
store.setData(clonedata);
|
||||||
containerState.startY = e.clientY;
|
containerState.startY = e.clientY;
|
||||||
|
@@ -2,40 +2,44 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-14 04:29:09
|
* @Date: 2021-03-14 04:29:09
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-04-05 22:18:43
|
* @LastEditTime: 2021-07-12 20:04:17
|
||||||
* @FilePath: \dooringv2\src\core\scale\index.ts
|
* @FilePath: \dooringx\packages\dooringx-lib\src\core\scale\index.ts
|
||||||
*/
|
*/
|
||||||
import { store } from '../../runtime/store';
|
import UserConfig from '../../config';
|
||||||
import Store from '../store';
|
|
||||||
import { scaleCancelFn } from './cancel';
|
import { scaleCancelFn } from './cancel';
|
||||||
import { scaleState } from './state';
|
|
||||||
|
|
||||||
export const onWheelEvent = {
|
export const onWheelEvent = (config: UserConfig) => {
|
||||||
onWheel: (e: React.WheelEvent<HTMLDivElement>) => {
|
const store = config.getStore();
|
||||||
const dom = document.querySelector('.ant-modal-mask');
|
const scale = config.getScaleState();
|
||||||
if (dom) {
|
return {
|
||||||
//出现弹窗禁止滚动
|
onWheel: (e: React.WheelEvent<HTMLDivElement>) => {
|
||||||
return;
|
const dom = document.querySelector('.ant-modal-mask');
|
||||||
}
|
if (dom) {
|
||||||
if (e.deltaY > 0) {
|
//出现弹窗禁止滚动
|
||||||
scaleCancelFn();
|
return;
|
||||||
if (scaleState.value < scaleState.maxValue) {
|
|
||||||
scaleState.value = scaleState.value + 0.1;
|
|
||||||
store.forceUpdate();
|
|
||||||
}
|
}
|
||||||
} else {
|
if (e.deltaY > 0) {
|
||||||
scaleCancelFn();
|
scaleCancelFn();
|
||||||
//往上滚缩小
|
if (scale.value < scale.maxValue) {
|
||||||
if (scaleState.value > scaleState.minValue) {
|
scale.value = scale.value + 0.1;
|
||||||
scaleState.value = scaleState.value - 0.1;
|
store.forceUpdate();
|
||||||
store.forceUpdate();
|
}
|
||||||
|
} else {
|
||||||
|
scaleCancelFn();
|
||||||
|
//往上滚缩小
|
||||||
|
if (scale.value > scale.minValue) {
|
||||||
|
scale.value = scale.value - 0.1;
|
||||||
|
store.forceUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
},
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const scaleFn = {
|
export const scaleFn = {
|
||||||
increase(number: number = 0.1, store: Store) {
|
increase(number: number = 0.1, config: UserConfig) {
|
||||||
|
const store = config.getStore();
|
||||||
|
const scaleState = config.getScaleState();
|
||||||
if (scaleState.value < scaleState.maxValue) {
|
if (scaleState.value < scaleState.maxValue) {
|
||||||
scaleCancelFn();
|
scaleCancelFn();
|
||||||
scaleState.value = scaleState.value + number;
|
scaleState.value = scaleState.value + number;
|
||||||
@@ -43,7 +47,9 @@ export const scaleFn = {
|
|||||||
}
|
}
|
||||||
return scaleState.value;
|
return scaleState.value;
|
||||||
},
|
},
|
||||||
decrease(number: number = 0.1, store: Store) {
|
decrease(number: number = 0.1, config: UserConfig) {
|
||||||
|
const store = config.getStore();
|
||||||
|
const scaleState = config.getScaleState();
|
||||||
scaleCancelFn();
|
scaleCancelFn();
|
||||||
if (scaleState.value > scaleState.minValue) {
|
if (scaleState.value > scaleState.minValue) {
|
||||||
scaleState.value = scaleState.value - number;
|
scaleState.value = scaleState.value - number;
|
||||||
|
@@ -1,9 +1,8 @@
|
|||||||
import { store } from '../../runtime/store';
|
|
||||||
import { IStoreData } from '../store/storetype';
|
import { IStoreData } from '../store/storetype';
|
||||||
import { deepCopy } from '../utils';
|
import { deepCopy } from '../utils';
|
||||||
import { focusState } from '../focusHandler/state';
|
import { focusState } from '../focusHandler/state';
|
||||||
import { scaleState } from '../scale/state';
|
|
||||||
import style from '../../index.less';
|
import style from '../../index.less';
|
||||||
|
import UserConfig from '../../config';
|
||||||
export interface SelectDataProps {
|
export interface SelectDataProps {
|
||||||
selectDiv: HTMLDivElement | null;
|
selectDiv: HTMLDivElement | null;
|
||||||
posx: number;
|
posx: number;
|
||||||
@@ -20,7 +19,7 @@ export const selectData: SelectDataProps = {
|
|||||||
startY: 0,
|
startY: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
export function selectRangeMouseDown(e: React.MouseEvent) {
|
export function selectRangeMouseDown(e: React.MouseEvent, config: UserConfig) {
|
||||||
if (!selectData.selectDiv) {
|
if (!selectData.selectDiv) {
|
||||||
selectData.selectDiv = document.createElement('div');
|
selectData.selectDiv = document.createElement('div');
|
||||||
}
|
}
|
||||||
@@ -34,7 +33,7 @@ export function selectRangeMouseDown(e: React.MouseEvent) {
|
|||||||
selectData.selectDiv.style.top = e.clientY + 'px';
|
selectData.selectDiv.style.top = e.clientY + 'px';
|
||||||
selectData.selectDiv.style.position = 'fixed';
|
selectData.selectDiv.style.position = 'fixed';
|
||||||
document.body.appendChild(selectData.selectDiv);
|
document.body.appendChild(selectData.selectDiv);
|
||||||
selectData.selectDiv.onmouseup = (e) => selectRangeMouseUp(e);
|
selectData.selectDiv.onmouseup = (e) => selectRangeMouseUp(e, config);
|
||||||
selectData.selectDiv.onmousemove = (e) => selectRangeMouseMove(e);
|
selectData.selectDiv.onmousemove = (e) => selectRangeMouseMove(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,10 +51,11 @@ function typeGuard(e: React.MouseEvent | MouseEvent): e is React.MouseEvent {
|
|||||||
return !(e instanceof Event);
|
return !(e instanceof Event);
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectFocus(left: number, top: number, width: number, height: number) {
|
function selectFocus(left: number, top: number, width: number, height: number, config: UserConfig) {
|
||||||
if (width === 0 || height === 0) {
|
if (width === 0 || height === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const store = config.getStore();
|
||||||
const clonedata: IStoreData = deepCopy(store.getData());
|
const clonedata: IStoreData = deepCopy(store.getData());
|
||||||
const blocks = clonedata.block;
|
const blocks = clonedata.block;
|
||||||
let change = false;
|
let change = false;
|
||||||
@@ -75,13 +75,14 @@ function selectFocus(left: number, top: number, width: number, height: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function selectRangeMouseUp(e: React.MouseEvent | MouseEvent) {
|
export function selectRangeMouseUp(e: React.MouseEvent | MouseEvent, config: UserConfig) {
|
||||||
if (selectData.selectDiv) {
|
if (selectData.selectDiv) {
|
||||||
// 这里需要判定区域
|
// 这里需要判定区域
|
||||||
// 如果是react触发 ,left和top就是起始值和终止值的最小值
|
// 如果是react触发 ,left和top就是起始值和终止值的最小值
|
||||||
// 如果是原生触发,left和top是起始点减去其宽高
|
// 如果是原生触发,left和top是起始点减去其宽高
|
||||||
let left = 0;
|
let left = 0;
|
||||||
let top = 0;
|
let top = 0;
|
||||||
|
const scaleState = config.getScaleState();
|
||||||
const { width, height } = selectData.selectDiv.getBoundingClientRect();
|
const { width, height } = selectData.selectDiv.getBoundingClientRect();
|
||||||
const scale = scaleState.value;
|
const scale = scaleState.value;
|
||||||
const wwidth = width / scale;
|
const wwidth = width / scale;
|
||||||
@@ -93,7 +94,7 @@ export function selectRangeMouseUp(e: React.MouseEvent | MouseEvent) {
|
|||||||
left = selectData.startX - wwidth;
|
left = selectData.startX - wwidth;
|
||||||
top = selectData.startY - wheight;
|
top = selectData.startY - wheight;
|
||||||
}
|
}
|
||||||
selectFocus(left, top, wwidth, wheight);
|
selectFocus(left, top, wwidth, wheight, config);
|
||||||
selectData.selectDiv.parentNode!.removeChild(selectData.selectDiv);
|
selectData.selectDiv.parentNode!.removeChild(selectData.selectDiv);
|
||||||
selectData.selectDiv = null;
|
selectData.selectDiv = null;
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
* @Author: yehuozhili
|
* @Author: yehuozhili
|
||||||
* @Date: 2021-03-14 05:35:15
|
* @Date: 2021-03-14 05:35:15
|
||||||
* @LastEditors: yehuozhili
|
* @LastEditors: yehuozhili
|
||||||
* @LastEditTime: 2021-07-12 14:48:38
|
* @LastEditTime: 2021-07-12 15:52:06
|
||||||
* @FilePath: \dooringx\packages\dooringx-lib\src\hooks\index.ts
|
* @FilePath: \dooringx\packages\dooringx-lib\src\hooks\index.ts
|
||||||
*/
|
*/
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
@@ -94,6 +94,6 @@ export function useDynamicAddEventCenter(
|
|||||||
eventCenter.manualUpdateMap(eventName, displayName);
|
eventCenter.manualUpdateMap(eventName, displayName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [eventCenter, props.data.eventMap, props.data.id, props.store]);
|
}, [displayName, eventCenter, eventName, props.data.eventMap, props.data.id, props.store]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user