This commit is contained in:
yehuozhili
2021-07-11 23:52:15 +08:00
parent fd981cadfd
commit 2ee2c3fb50
2 changed files with 50 additions and 3 deletions

View File

@@ -2,4 +2,44 @@
title: 右键菜单
sTitle: dooringx-lib插件开发
order: 15
---
---
右键菜单可以进行自定义:
```js
// 自定义右键
const contextMenuState = config.getContextMenuState();
const unmountContextMenu = contextMenuState.unmountContextMenu;
const commander = config.getCommanderRegister();
const ContextMenu = () => {
const handleclick = () => {
unmountContextMenu();
};
return (
<div
style={{
left: contextMenuState.left,
top: contextMenuState.top,
position: 'fixed',
background: 'rgb(24, 23, 23)',
}}
>
<div
style={{ width: '100%' }}
onClick={() => {
commander.exec('redo');
handleclick();
}}
>
<Button>自定义</Button>
</div>
</div>
);
};
contextMenuState.contextMenu = <ContextMenu></ContextMenu>;
```
先拿到contextMenuStatecontextMenuState上有个unmountContextMenu是关闭右键菜单方法。
所以在点击后需要调用关闭。
同时上面的left和top是右键的位置。

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili
* @Date: 2021-01-31 20:44:16
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-11 13:35:16
* @LastEditTime: 2021-07-11 23:11:14
* @FilePath: \dooringx\packages\dooringx-lib\README.md
-->
@@ -15,4 +15,11 @@
- 0.1.7 修改预览特殊条件显示删除console
- 0.1.6 调整初始缩放,画布初始比例,增加回正画布功能。
- 0.1.5 删除未作按钮增加fixed配置
- 0.1.4 基础功能
- 0.1.4 基础功能
## todo
1、制作标尺
2、重构命令传递config。
3、重构拖拽优化性能与config传递。