This commit is contained in:
hufeixiong
2021-07-12 15:32:21 +08:00
parent 0df7aff097
commit 740d3661d2
12 changed files with 49 additions and 34 deletions

View File

@@ -204,6 +204,6 @@ export default undo;
metakey与Controlkey相同写Control即可。
目前第三个参数只能获得store后续需要修改下。
目前第三个参数只能获得store后续需要修改下。 0.2.0 版本第二个参数可以获得config同时commander不从index中导出需要使用时从config中获取。
最后个参数是展示名。

View File

@@ -2,8 +2,8 @@
* @Author: yehuozhili
* @Date: 2021-07-07 11:11:52
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-07 20:18:39
* @FilePath: \visual-editor\.umirc.ts
* @LastEditTime: 2021-07-12 13:58:33
* @FilePath: \dooringx\packages\dooringx-example\.umirc.ts
*/
import { defineConfig } from 'umi';

View File

@@ -2,13 +2,14 @@
* @Author: yehuozhili
* @Date: 2021-01-31 20:44:16
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-11 23:11:14
* @LastEditTime: 2021-07-12 15:22:17
* @FilePath: \dooringx\packages\dooringx-lib\README.md
-->
## Dooringx-lib
## changelog
- 0.2.0 commander的传递进行修改可以获得config了commander不再从index中导出 需要使用时从config中获取。增加左侧类名方便自定义。
- 0.1.10 修改eslint依赖推荐
- 0.1.9 增加全局body设置
- 0.1.8 增加弹窗设置移除modalContainer
@@ -21,5 +22,4 @@
## todo
1、制作标尺
2、重构命令,传递config。
3、重构拖拽优化性能与config传递。
2、重构拖拽,优化性能与config传递

View File

@@ -1,5 +1,5 @@
{
"version": "0.1.10",
"version": "0.2.0",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili
* @Date: 2021-02-04 10:32:45
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-11 13:34:00
* @LastEditTime: 2021-07-12 15:21:27
* @FilePath: \dooringx\packages\dooringx-lib\src\components\leftConfig.tsx
*/
import React, { ReactNode, useEffect, useMemo, useState } from 'react';
@@ -44,6 +44,7 @@ function LeftConfig(props: LeftConfigProps) {
setLeftRender(
<div className={`${styles.leftco} yh-leftcomp`}>
<div
className="yh-left-top-wrapper"
style={{
display: 'flex',
justifyContent: 'center',
@@ -69,6 +70,7 @@ function LeftConfig(props: LeftConfigProps) {
{leftMapRenderListCategory[parseInt(menuSelect, 10)].displayName}
</div>
<Input
className="yh-left-top-input"
style={{
borderRadius: '40px',
}}
@@ -91,8 +93,12 @@ function LeftConfig(props: LeftConfigProps) {
return prev;
}, [])
.map((v, index) => (
<div className={styles.coitem} key={index} {...dragEventResolve(v)}>
<div className={styles.redbox}>
<div
className={`${styles.coitem} yh-left-item-wrap`}
key={index}
{...dragEventResolve(v)}
>
<div className={`${styles.redbox} yh-left-item-img-wrap`}>
{v.imgCustom ? v.imgCustom : <img src={v.img} alt="component"></img>}
</div>
@@ -110,8 +116,12 @@ function LeftConfig(props: LeftConfigProps) {
))}
{(!search || search === '') &&
cache.map((v, index) => (
<div className={styles.coitem} key={index} {...dragEventResolve(v)}>
<div className={styles.redbox}>
<div
className={`${styles.coitem} yh-left-item-wrap`}
key={index}
{...dragEventResolve(v)}
>
<div className={`${styles.redbox} yh-left-item-img-wrap`}>
{v.imgCustom ? v.imgCustom : <img src={v.img} alt="component"></img>}
</div>
<div

View File

@@ -2,8 +2,8 @@
* @Author: yehuozhili
* @Date: 2021-03-14 04:29:09
* @LastEditors: yehuozhili
* @LastEditTime: 2021-03-14 04:58:51
* @FilePath: \dooring-v2\src\core\wrapperMove\index.tsx
* @LastEditTime: 2021-07-12 15:24:29
* @FilePath: \dooringx\packages\dooringx-lib\src\components\wrapperMove\index.tsx
*/
import { AllHTMLAttributes, CSSProperties, PropsWithChildren, useRef } from 'react';
import { wrapperEvent } from './event';
@@ -20,7 +20,7 @@ function ContainerWrapper(props: PropsWithChildren<ContainerWrapperProps>) {
const ref = useRef<HTMLDivElement>(null);
return (
<div
className={`ant-menu ${classNames}`}
className={`ant-menu ${classNames ? classNames : ''}`}
ref={ref}
style={{
backgroundColor: '#f0f0f0',

View File

@@ -2,12 +2,12 @@
* @Author: yehuozhili
* @Date: 2021-02-25 21:16:58
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-10 21:22:42
* @LastEditTime: 2021-07-12 14:49:32
* @FilePath: \dooringx\packages\dooringx-lib\src\config\index.tsx
*/
import { IBlockType, IStoreData } from '../core/store/storetype';
import { store } from '../runtime/store';
import { formRegister, componentRegister, commander, storeChanger } from '../runtime';
import { formRegister, componentRegister, storeChanger } from '../runtime';
import { ComponentClass, FunctionComponent, ReactNode } from 'react';
import { ComponentItemFactory } from '../core/components/abstract';
import { marklineConfig } from '../core/markline/marklineConfig';
@@ -23,6 +23,7 @@ import { createModal, unmountMap } from '../components/modalRender';
import { scaleState } from '../core/scale/state';
import { CommanderItemFactory } from '../core/command/abstract';
import MmodalMask from '../core/components/defaultFormComponents/modalMask';
import CommanderWrapper from '../core/command';
// 组件部分
@@ -313,7 +314,7 @@ export class UserConfig {
public componentCache = {};
public asyncComponentUrlMap = {} as AsyncCacheComponentType;
public marklineConfig = marklineConfig;
public commanderRegister = commander;
public commanderRegister: CommanderWrapper;
public contextMenuState = contextMenuState;
public formRegister = formRegister;
public storeChanger = storeChanger;
@@ -323,6 +324,7 @@ export class UserConfig {
constructor(initConfig?: Partial<InitConfig>) {
const mergeConfig = userConfigMerge(defaultConfig, initConfig);
this.initConfig = mergeConfig;
this.commanderRegister = new CommanderWrapper(store, {}, this);
this.eventCenter = new EventCenter({}, mergeConfig.initFunctionMap);
this.dataCenter = new DataCenter(mergeConfig.initDataCenterMap);
this.init();

View File

@@ -2,9 +2,10 @@
* @Author: yehuozhili
* @Date: 2021-03-14 04:29:09
* @LastEditors: yehuozhili
* @LastEditTime: 2021-03-14 04:39:43
* @FilePath: \dooring-v2\src\core\command\commanderType.ts
* @LastEditTime: 2021-07-12 14:52:12
* @FilePath: \dooringx\packages\dooringx-lib\src\core\command\commanderType.ts
*/
import UserConfig from '../../config';
import Store from '../store';
export interface CommanderItem {
@@ -12,6 +13,6 @@ export interface CommanderItem {
display: string;
name: string;
keyboard: string;
excute: (store: Store, options?: any) => void;
excute: (store: Store, config: UserConfig, options?: Record<string, any>) => void;
destroy: () => void;
}

View File

@@ -2,15 +2,20 @@
* @Author: yehuozhili
* @Date: 2021-03-14 04:29:09
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-08 20:42:15
* @FilePath: \DooringV2\packages\dooringx-lib\src\core\command\index.ts
* @LastEditTime: 2021-07-12 14:52:28
* @FilePath: \dooringx\packages\dooringx-lib\src\core\command\index.ts
*/
import UserConfig from '../../config';
import Store from '../store';
import { CommanderItem } from './commanderType';
import { keycodeFilter } from './keycode';
class CommanderWrapper {
constructor(public store: Store, public commandMap: Record<string, CommanderItem> = {}) {}
constructor(
public store: Store,
public commandMap: Record<string, CommanderItem> = {},
public config: UserConfig
) {}
getList() {
return this.commandMap;
}
@@ -55,7 +60,7 @@ class CommanderWrapper {
}
const keyname = keyString.join('+');
if (current.keyboard === keyname) {
current.excute(this.store);
current.excute(this.store, this.config);
e.stopPropagation();
e.preventDefault();
}
@@ -78,7 +83,7 @@ class CommanderWrapper {
console.error(`${name} commander not found`);
return;
}
this.commandMap[name].excute(this.store, options);
this.commandMap[name].excute(this.store, this.config, options);
}
}
export default CommanderWrapper;

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili
* @Date: 2021-03-14 05:35:15
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-10 17:46:26
* @LastEditTime: 2021-07-12 14:48:38
* @FilePath: \dooringx\packages\dooringx-lib\src\hooks\index.ts
*/
import { useEffect, useMemo, useState } from 'react';

View File

@@ -2,8 +2,8 @@
* @Author: yehuozhili
* @Date: 2021-03-14 04:22:18
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-07 03:38:44
* @FilePath: \dooringv2\packages\dooringx-lib\src\index.tsx
* @LastEditTime: 2021-07-12 14:43:28
* @FilePath: \dooringx\packages\dooringx-lib\src\index.tsx
*/
// 初始化store用
@@ -27,7 +27,7 @@ export { innerContainerDragUp } from './core/innerDrag';
// 用于修改store
export { store } from './runtime/store';
// 用于获取运行中的实例
export { commander, componentRegister, formRegister, storeChanger } from './runtime';
export { componentRegister, formRegister, storeChanger } from './runtime';
export { unmountContextMenu } from './core/contextMenu';

View File

@@ -2,15 +2,12 @@
* @Author: yehuozhili
* @Date: 2021-03-14 04:33:52
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-10 18:18:15
* @LastEditTime: 2021-07-12 14:43:03
* @FilePath: \dooringx\packages\dooringx-lib\src\runtime\index.ts
*/
import CommanderWrapper from '../core/command';
import ComponentRegister from '../core/components';
import { FormComponentRegister } from '../core/components/formComponentRegister';
import { StoreChanger } from '../core/storeChanger';
import { store } from './store';
export const commander = new CommanderWrapper(store);
export const componentRegister = new ComponentRegister();
export const formRegister = new FormComponentRegister();
export const storeChanger = new StoreChanger();