Skip to content

Commit a645af7

Browse files
liujupingJackLian
authored andcommitted
feat: support PanelDock icon pointer cursor is always pointer
1 parent 21f74f0 commit a645af7

File tree

10 files changed

+61
-45
lines changed

10 files changed

+61
-45
lines changed

packages/designer/src/designer/dragon.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ function isDragEvent(e: any): e is DragEvent {
9595
return e?.type?.startsWith('drag');
9696
}
9797

98-
export interface IDragon extends IPublicModelDragon<INode> {
98+
export interface IDragon extends IPublicModelDragon<
99+
INode,
100+
ILocateEvent
101+
> {
99102
emitter: IEventBus;
100103
}
101104

packages/designer/src/plugin/plugin-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
IPublicTypePluginMeta,
1818
IPublicTypePluginRegisterOptions,
1919
} from '@alilc/lowcode-types';
20+
import PluginContext from './plugin-context';
2021

2122
export type PluginPreference = Map<string, Record<string, IPublicTypePreferenceValueType>>;
2223

@@ -81,6 +82,7 @@ export interface ILowCodePluginManagerCore {
8182
delete(pluginName: string): any;
8283
setDisabled(pluginName: string, flag: boolean): void;
8384
dispose(): void;
85+
_getLowCodePluginContext (options: IPluginContextOptions): PluginContext;
8486
}
8587

8688
export type ILowCodePluginManager = ILowCodePluginManagerCore & ILowCodePluginManagerPluginAccessor;

packages/editor-core/src/widgets/tip/tip-container.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@ export class TipContainer extends Component {
2626
}
2727

2828
render() {
29-
ReactDOM.createPortal(
29+
return ReactDOM.createPortal(
3030
<div className="lc-tips-container">
3131
<TipItem />
3232
</div>,
3333
document.querySelector('body')!,
3434
);
35-
36-
return null;
3735
}
3836
}

packages/editor-core/src/widgets/title/index.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, isValidElement, ReactNode } from 'react';
22
import classNames from 'classnames';
3-
import { createIcon, isI18nData } from '@alilc/lowcode-utils';
4-
import { IPublicTypeTitleContent, IPublicTypeI18nData } from '@alilc/lowcode-types';
3+
import { createIcon, isI18nData, isTitleConfig } from '@alilc/lowcode-utils';
4+
import { IPublicTypeTitleContent, IPublicTypeI18nData, IPublicTypeTitleConfig } from '@alilc/lowcode-types';
55
import { intl } from '../../intl';
66
import { Tip } from '../tip';
77
import './title.less';
@@ -88,42 +88,49 @@ export class Title extends Component<{
8888

8989
render() {
9090
// eslint-disable-next-line prefer-const
91-
let { title, className } = this.props;
91+
const { title, className } = this.props;
92+
let _title: IPublicTypeTitleConfig;
9293
if (title == null) {
9394
return null;
9495
}
9596
if (isValidElement(title)) {
9697
return title;
9798
}
9899
if (typeof title === 'string' || isI18nData(title)) {
99-
title = { label: title };
100+
_title = { label: title };
101+
} else if (isTitleConfig(title)) {
102+
_title = title;
103+
} else {
104+
_title = {
105+
label: title,
106+
};
100107
}
101108

102-
const icon = title.icon ? createIcon(title.icon, { size: 20 }) : null;
109+
const icon = _title.icon ? createIcon(_title.icon, { size: 20 }) : null;
103110

104111
let tip: any = null;
105-
if (title.tip) {
106-
if (isValidElement(title.tip) && title.tip.type === Tip) {
107-
tip = title.tip;
112+
if (_title.tip) {
113+
if (isValidElement(_title.tip) && _title.tip.type === Tip) {
114+
tip = _title.tip;
108115
} else {
109116
const tipProps =
110-
typeof title.tip === 'object' && !(isValidElement(title.tip) || isI18nData(title.tip))
111-
? title.tip
112-
: { children: title.tip };
117+
typeof _title.tip === 'object' && !(isValidElement(_title.tip) || isI18nData(_title.tip))
118+
? _title.tip
119+
: { children: _title.tip };
113120
tip = <Tip {...tipProps} />;
114121
}
115122
}
116123

117124
return (
118125
<span
119-
className={classNames('lc-title', className, title.className, {
126+
className={classNames('lc-title', className, _title.className, {
120127
'has-tip': !!tip,
121-
'only-icon': !title.label,
128+
'only-icon': !_title.label,
122129
})}
123130
onClick={this.handleClick}
124131
>
125132
{icon ? <b className="lc-title-icon">{icon}</b> : null}
126-
{this.renderLabel(title.label)}
133+
{this.renderLabel(_title.label)}
127134
{tip}
128135
</span>
129136
);

packages/editor-skeleton/src/components/widget-views/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ function HelpTip({ tip }: any) {
4747

4848
@observer
4949
export class PanelDockView extends Component<DockProps & { dock: PanelDock }> {
50+
private lastActived = false;
51+
5052
componentDidMount() {
5153
this.checkActived();
5254
}
@@ -55,8 +57,6 @@ export class PanelDockView extends Component<DockProps & { dock: PanelDock }> {
5557
this.checkActived();
5658
}
5759

58-
private lastActived = false;
59-
6060
checkActived() {
6161
const { dock } = this.props;
6262
if (dock.actived !== this.lastActived) {
@@ -134,7 +134,7 @@ export class DraggableLineView extends Component<{ panel: Panel }> {
134134
// 默认 关闭,通过配置开启
135135
const enableDrag = this.props.panel.config.props?.enableDrag;
136136
const isRightArea = this.props.panel.config?.area === 'rightArea';
137-
if (isRightArea || !enableDrag || this.props.panel?.parent.name === 'leftFixedArea') {
137+
if (isRightArea || !enableDrag || this.props.panel?.parent?.name === 'leftFixedArea') {
138138
return null;
139139
}
140140
return (
@@ -159,6 +159,8 @@ export class DraggableLineView extends Component<{ panel: Panel }> {
159159

160160
@observer
161161
export class TitledPanelView extends Component<{ panel: Panel; area?: string }> {
162+
private lastVisible = false;
163+
162164
componentDidMount() {
163165
this.checkVisible();
164166
}
@@ -167,8 +169,6 @@ export class TitledPanelView extends Component<{ panel: Panel; area?: string }>
167169
this.checkVisible();
168170
}
169171

170-
private lastVisible = false;
171-
172172
checkVisible() {
173173
const { panel } = this.props;
174174
const currentVisible = panel.inited && panel.visible;
@@ -218,6 +218,8 @@ export class PanelView extends Component<{
218218
hideOperationRow?: boolean;
219219
hideDragLine?: boolean;
220220
}> {
221+
private lastVisible = false;
222+
221223
componentDidMount() {
222224
this.checkVisible();
223225
}
@@ -226,8 +228,6 @@ export class PanelView extends Component<{
226228
this.checkVisible();
227229
}
228230

229-
private lastVisible = false;
230-
231231
checkVisible() {
232232
const { panel } = this.props;
233233
const currentVisible = panel.inited && panel.visible;
@@ -331,6 +331,9 @@ class PanelTitle extends Component<{ panel: Panel; className?: string }> {
331331

332332
@observer
333333
export class WidgetView extends Component<{ widget: IWidget }> {
334+
private lastVisible = false;
335+
private lastDisabled: boolean | undefined = false;
336+
334337
componentDidMount() {
335338
this.checkVisible();
336339
this.checkDisabled();
@@ -341,9 +344,6 @@ export class WidgetView extends Component<{ widget: IWidget }> {
341344
this.checkDisabled();
342345
}
343346

344-
private lastVisible = false;
345-
private lastDisabled = false;
346-
347347
checkVisible() {
348348
const { widget } = this.props;
349349
const currentVisible = widget.visible;

packages/editor-skeleton/src/layouts/workbench.less

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,8 @@ body {
323323
display: flex;
324324
align-items: center;
325325
justify-content: center;
326+
cursor: pointer;
326327

327-
&.has-tip {
328-
cursor: pointer;
329-
}
330328
&.actived {
331329
color: #0079f2;
332330
}

packages/shell/src/model/dragon.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import {
2+
IDragon,
23
ILocateEvent as InnerLocateEvent,
4+
INode,
35
} from '@alilc/lowcode-designer';
46
import { dragonSymbol, nodeSymbol } from '../symbols';
57
import LocateEvent from './locate-event';
@@ -11,18 +13,19 @@ import {
1113
IPublicModelDragObject,
1214
IPublicTypeDragNodeDataObject,
1315
IPublicModelNode,
16+
IPublicTypeDragObject,
1417
} from '@alilc/lowcode-types';
1518

1619
export const innerDragonSymbol = Symbol('innerDragonSymbol');
1720

1821
export class Dragon implements IPublicModelDragon {
19-
private readonly [innerDragonSymbol]: IPublicModelDragon;
22+
private readonly [innerDragonSymbol]: IDragon;
2023

21-
constructor(innerDragon: IPublicModelDragon, readonly workspaceMode: boolean) {
24+
constructor(innerDragon: IDragon, readonly workspaceMode: boolean) {
2225
this[innerDragonSymbol] = innerDragon;
2326
}
2427

25-
get [dragonSymbol](): any {
28+
get [dragonSymbol](): IDragon {
2629
if (this.workspaceMode) {
2730
return this[innerDragonSymbol];
2831
}
@@ -38,7 +41,7 @@ export class Dragon implements IPublicModelDragon {
3841
}
3942

4043
static create(
41-
dragon: IPublicModelDragon | null,
44+
dragon: IDragon | null,
4245
workspaceMode: boolean,
4346
): IPublicModelDragon | null {
4447
if (!dragon) {
@@ -102,11 +105,13 @@ export class Dragon implements IPublicModelDragon {
102105
* @param dragObject 拖拽对象
103106
* @param boostEvent 拖拽初始时事件
104107
*/
105-
boost(dragObject: DragObject, boostEvent: MouseEvent | DragEvent, fromRglNode?: Node | IPublicModelNode): void {
108+
boost(dragObject: IPublicTypeDragObject, boostEvent: MouseEvent | DragEvent, fromRglNode?: IPublicModelNode & {
109+
[nodeSymbol]: INode;
110+
}): void {
106111
return this[dragonSymbol].boost({
107112
...dragObject,
108113
nodes: dragObject.nodes.map((node: any) => node[nodeSymbol]),
109-
}, boostEvent, fromRglNode);
114+
}, boostEvent, fromRglNode?.[nodeSymbol]);
110115
}
111116

112117
/**

packages/shell/src/model/locate-event.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { ILocateEvent as InnerLocateEvent } from '@alilc/lowcode-designer';
1+
import { ILocateEvent } from '@alilc/lowcode-designer';
22
import { locateEventSymbol } from '../symbols';
33
import { DragObject } from './drag-object';
44
import { IPublicModelLocateEvent, IPublicModelDragObject } from '@alilc/lowcode-types';
55

66
export default class LocateEvent implements IPublicModelLocateEvent {
7-
private readonly [locateEventSymbol]: InnerLocateEvent;
7+
private readonly [locateEventSymbol]: ILocateEvent;
88

9-
constructor(locateEvent: InnerLocateEvent) {
9+
constructor(locateEvent: ILocateEvent) {
1010
this[locateEventSymbol] = locateEvent;
1111
}
1212

13-
static create(locateEvent: InnerLocateEvent): IPublicModelLocateEvent | null {
13+
static create(locateEvent: ILocateEvent): IPublicModelLocateEvent | null {
1414
if (!locateEvent) {
1515
return null;
1616
}

packages/types/src/shell/model/dragon.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { IPublicTypeDragNodeDataObject, IPublicTypeDragObject } from '../type';
33
import { IPublicModelDragObject, IPublicModelLocateEvent, IPublicModelNode } from './';
44

55
export interface IPublicModelDragon<
6-
Node = IPublicModelNode
6+
Node = IPublicModelNode,
7+
LocateEvent = IPublicModelLocateEvent
78
> {
89

910
/**
@@ -18,15 +19,15 @@ export interface IPublicModelDragon<
1819
* @param func
1920
* @returns
2021
*/
21-
onDragstart(func: (e: IPublicModelLocateEvent) => any): () => void;
22+
onDragstart(func: (e: LocateEvent) => any): () => void;
2223

2324
/**
2425
* 绑定 drag 事件
2526
* bind a callback function which will be called on dragging
2627
* @param func
2728
* @returns
2829
*/
29-
onDrag(func: (e: IPublicModelLocateEvent) => any): () => void;
30+
onDrag(func: (e: LocateEvent) => any): () => void;
3031

3132
/**
3233
* 绑定 dragend 事件

packages/workspace/src/resource.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ export class Resource implements IResource {
7373

7474
constructor(readonly resourceData: IPublicResourceData, readonly resourceType: IResourceType, readonly workspace: IWorkspace) {
7575
this.context = new BasicContext(workspace, `resource-${resourceData.resourceName || resourceType.name}`);
76-
this.resourceTypeInstance = resourceType.resourceTypeModel(this.context.innerPlugins._getLowCodePluginContext(), this.options);
76+
this.resourceTypeInstance = resourceType.resourceTypeModel(this.context.innerPlugins._getLowCodePluginContext({
77+
pluginName: '',
78+
}), this.options);
7779
this.init();
7880
if (this.resourceTypeInstance.editorViews) {
7981
this.resourceTypeInstance.editorViews.forEach((d: any) => {

0 commit comments

Comments
 (0)