This commit is contained in:
yehuozhili
2021-07-11 13:56:35 +08:00
parent 7f7a839aef
commit fd981cadfd
5 changed files with 217 additions and 15 deletions

View File

@@ -1,5 +1,209 @@
--- ---
title: 命令开发 title: 命令
sTitle: dooringx-lib插件开发 sTitle: dooringx-lib插件开发
order: 14 order: 14
--- ---
## 命令的导入
命令对象导入到插件的initCommandModule里即可
```js
initCommandModule: commandModules,
```
## 命令的开发
命令需要导出一个CommanderItemFactory生成的对象。
```js
import { CommanderItemFactory } from 'dooringx-lib';
const undo = new CommanderItemFactory(
'redo',
'Control+Shift+z',
(store) => {
store.redo();
},
'重做'
);
export default undo;
```
第一个参数是注册名。
第二个参数是快捷键名快捷键映射是键盘事件key值
```js
Cancel: 3,
Help: 6,
Backspace: 8,
Tab: 9,
Clear: 12,
Enter: 13,
Shift: 16,
Control: 17,
Alt: 18,
Pause: 19,
CapsLock: 20,
Escape: 27,
Convert: 28,
NonConvert: 29,
Accept: 30,
ModeChange: 31,
' ': 32,
PageUp: 33,
PageDown: 34,
End: 35,
Home: 36,
ArrowLeft: 37,
ArrowUp: 38,
ArrowRight: 39,
ArrowDown: 40,
Select: 41,
Print: 42,
Execute: 43,
PrintScreen: 44,
Insert: 45,
Delete: 46,
0: 48,
')': 48,
1: 49,
'!': 49,
2: 50,
'@': 50,
3: 51,
'#': 51,
4: 52,
$: 52,
5: 53,
'%': 53,
6: 54,
'^': 54,
7: 55,
'&': 55,
8: 56,
'*': 56,
9: 57,
'(': 57,
a: 65,
A: 65,
b: 66,
B: 66,
c: 67,
C: 67,
d: 68,
D: 68,
e: 69,
E: 69,
f: 70,
F: 70,
g: 71,
G: 71,
h: 72,
H: 72,
i: 73,
I: 73,
j: 74,
J: 74,
k: 75,
K: 75,
l: 76,
L: 76,
m: 77,
M: 77,
n: 78,
N: 78,
o: 79,
O: 79,
p: 80,
P: 80,
q: 81,
Q: 81,
r: 82,
R: 82,
s: 83,
S: 83,
t: 84,
T: 84,
u: 85,
U: 85,
v: 86,
V: 86,
w: 87,
W: 87,
x: 88,
X: 88,
y: 89,
Y: 89,
z: 90,
Z: 90,
OS: 91,
ContextMenu: 93,
F1: 112,
F2: 113,
F3: 114,
F4: 115,
F5: 116,
F6: 117,
F7: 118,
F8: 119,
F9: 120,
F10: 121,
F11: 122,
F12: 123,
F13: 124,
F14: 125,
F15: 126,
F16: 127,
F17: 128,
F18: 129,
F19: 130,
F20: 131,
F21: 132,
F22: 133,
F23: 134,
F24: 135,
NumLock: 144,
ScrollLock: 145,
VolumeMute: 181,
VolumeDown: 182,
VolumeUp: 183,
';': 186,
':': 186,
'=': 187,
'+': 187,
',': 188,
'<': 188,
'-': 189,
_: 189,
'.': 190,
'>': 190,
'/': 191,
'?': 191,
'`': 192,
'~': 192,
'[': 219,
'{': 219,
'\\': 220,
'|': 220,
']': 221,
'}': 221,
"'": 222,
'"': 222,
Meta: 224,
AltGraph: 225,
Attn: 246,
CrSel: 247,
ExSel: 248,
EraseEof: 249,
Play: 250,
ZoomOut: 251,
```
26个英文字母是忽略大小写的一个命令目前只能注册一个快捷键。不需要注册快捷键则填空字符串即可。
metakey与Controlkey相同写Control即可。
目前第三个参数只能获得store后续需要修改下。
最后个参数是展示名。

View File

@@ -2,13 +2,14 @@
* @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-10 18:07:00 * @LastEditTime: 2021-07-11 13:35:16
* @FilePath: \dooringx\packages\dooringx-lib\README.md * @FilePath: \dooringx\packages\dooringx-lib\README.md
--> -->
## Dooringx-lib ## Dooringx-lib
## changelog ## changelog
- 0.1.10 修改eslint依赖推荐
- 0.1.9 增加全局body设置 - 0.1.9 增加全局body设置
- 0.1.8 增加弹窗设置移除modalContainer - 0.1.8 增加弹窗设置移除modalContainer
- 0.1.7 修改预览特殊条件显示删除console - 0.1.7 修改预览特殊条件显示删除console

View File

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

View File

@@ -101,12 +101,7 @@ function Blocks(props: PropsWithChildren<BlockProps>) {
}`; }`;
} }
return ''; return '';
}, [ }, [props.data.animate]);
props.data.animate.animate,
props.data.animate.delay,
// props.data.animate.duration,
props.data.animate.speed,
]);
const animateCount = useMemo(() => { const animateCount = useMemo(() => {
const animate = props.data.animate; const animate = props.data.animate;
@@ -114,7 +109,7 @@ function Blocks(props: PropsWithChildren<BlockProps>) {
return { animationIterationCount: animate.animationIterationCount }; return { animationIterationCount: animate.animationIterationCount };
} }
return { animationIterationCount: 1 }; return { animationIterationCount: 1 };
}, [props.data.animate.animationIterationCount]); }, [props.data.animate]);
const render = useMemo(() => { const render = useMemo(() => {
// 如果是编辑模式下,则需要包裹不能选中层,位移层,缩放控制层,平面移动层。 // 如果是编辑模式下,则需要包裹不能选中层,位移层,缩放控制层,平面移动层。
@@ -191,6 +186,8 @@ function Blocks(props: PropsWithChildren<BlockProps>) {
props.context, props.context,
props.data, props.data,
innerDragData, innerDragData,
animatecss,
animateCount,
previewState.top, previewState.top,
previewState.left, previewState.left,
previewState.width, previewState.width,

View File

@@ -2,8 +2,8 @@
* @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-10 15:47:34 * @LastEditTime: 2021-07-11 13:34:00
* @FilePath: \DooringV2\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';
import { Input, Menu } from 'antd'; import { Input, Menu } from 'antd';
@@ -93,7 +93,7 @@ function LeftConfig(props: LeftConfigProps) {
.map((v, index) => ( .map((v, index) => (
<div className={styles.coitem} key={index} {...dragEventResolve(v)}> <div className={styles.coitem} key={index} {...dragEventResolve(v)}>
<div className={styles.redbox}> <div className={styles.redbox}>
{v.imgCustom ? v.imgCustom : <img src={v.img}></img>} {v.imgCustom ? v.imgCustom : <img src={v.img} alt="component"></img>}
</div> </div>
<div <div
@@ -112,7 +112,7 @@ function LeftConfig(props: LeftConfigProps) {
cache.map((v, index) => ( cache.map((v, index) => (
<div className={styles.coitem} key={index} {...dragEventResolve(v)}> <div className={styles.coitem} key={index} {...dragEventResolve(v)}>
<div className={styles.redbox}> <div className={styles.redbox}>
{v.imgCustom ? v.imgCustom : <img src={v.img}></img>} {v.imgCustom ? v.imgCustom : <img src={v.img} alt="component"></img>}
</div> </div>
<div <div
style={{ style={{