GeezerVison is showing github.com — feat: support PanelDock icon pointer cursor is always pointer · bruceywave/lowcode-engine@a645af7
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/designer/dragon.ts +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -95,7 +95,10 @@ function isDragEvent(e: any): e is DragEvent { | 95 | 95 | return e?.type?.startsWith('drag'); | 96 | 96 | } | 97 | 97 |
| 98 | | -export interface IDragon extends IPublicModelDragon<INode> { | | 98 | +export interface IDragon extends IPublicModelDragon< | | 99 | + INode, | | 100 | + ILocateEvent | | 101 | +> { | 99 | 102 | emitter: IEventBus; | 100 | 103 | } | 101 | 104 |
| |
Collapse file Copy file name to clipboardExpand all lines: packages/designer/src/plugin/plugin-types.ts +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,6 +17,7 @@ import { | 17 | 17 | IPublicTypePluginMeta, | 18 | 18 | IPublicTypePluginRegisterOptions, | 19 | 19 | } from '@alilc/lowcode-types'; | | 20 | +import PluginContext from './plugin-context'; | 20 | 21 |
| 21 | 22 | export type PluginPreference = Map<string, Record<string, IPublicTypePreferenceValueType>>; | 22 | 23 |
| @@ -81,6 +82,7 @@ export interface ILowCodePluginManagerCore { | 81 | 82 | delete(pluginName: string): any; | 82 | 83 | setDisabled(pluginName: string, flag: boolean): void; | 83 | 84 | dispose(): void; | | 85 | + _getLowCodePluginContext (options: IPluginContextOptions): PluginContext; | 84 | 86 | } | 85 | 87 |
| 86 | 88 | export type ILowCodePluginManager = ILowCodePluginManagerCore & ILowCodePluginManagerPluginAccessor; | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-core/src/widgets/tip/tip-container.tsx +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -26,13 +26,11 @@ export class TipContainer extends Component { | 26 | 26 | } | 27 | 27 |
| 28 | 28 | render() { | 29 | | - ReactDOM.createPortal( | | 29 | + return ReactDOM.createPortal( | 30 | 30 | <div className="lc-tips-container"> | 31 | 31 | <TipItem /> | 32 | 32 | </div>, | 33 | 33 | document.querySelector('body')!, | 34 | 34 | ); | 35 | | - | 36 | | - return null; | 37 | 35 | } | 38 | 36 | } |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-core/src/widgets/title/index.tsx +21-14Lines changed: 21 additions & 14 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { Component, isValidElement, ReactNode } from 'react'; | 2 | 2 | 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'; | 5 | 5 | import { intl } from '../../intl'; | 6 | 6 | import { Tip } from '../tip'; | 7 | 7 | import './title.less'; | @@ -88,42 +88,49 @@ export class Title extends Component<{ | 88 | 88 |
| 89 | 89 | render() { | 90 | 90 | // eslint-disable-next-line prefer-const | 91 | | - let { title, className } = this.props; | | 91 | + const { title, className } = this.props; | | 92 | + let _title: IPublicTypeTitleConfig; | 92 | 93 | if (title == null) { | 93 | 94 | return null; | 94 | 95 | } | 95 | 96 | if (isValidElement(title)) { | 96 | 97 | return title; | 97 | 98 | } | 98 | 99 | 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 | + }; | 100 | 107 | } | 101 | 108 |
| 102 | | - const icon = title.icon ? createIcon(title.icon, { size: 20 }) : null; | | 109 | + const icon = _title.icon ? createIcon(_title.icon, { size: 20 }) : null; | 103 | 110 |
| 104 | 111 | 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; | 108 | 115 | } else { | 109 | 116 | 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 }; | 113 | 120 | tip = <Tip {...tipProps} />; | 114 | 121 | } | 115 | 122 | } | 116 | 123 |
| 117 | 124 | return ( | 118 | 125 | <span | 119 | | - className={classNames('lc-title', className, title.className, { | | 126 | + className={classNames('lc-title', className, _title.className, { | 120 | 127 | 'has-tip': !!tip, | 121 | | - 'only-icon': !title.label, | | 128 | + 'only-icon': !_title.label, | 122 | 129 | })} | 123 | 130 | onClick={this.handleClick} | 124 | 131 | > | 125 | 132 | {icon ? <b className="lc-title-icon">{icon}</b> : null} | 126 | | - {this.renderLabel(title.label)} | | 133 | + {this.renderLabel(_title.label)} | 127 | 134 | {tip} | 128 | 135 | </span> | 129 | 136 | ); | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/components/widget-views/index.tsx +10-10Lines changed: 10 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -47,6 +47,8 @@ function HelpTip({ tip }: any) { | 47 | 47 |
| 48 | 48 | @observer | 49 | 49 | export class PanelDockView extends Component<DockProps & { dock: PanelDock }> { | | 50 | + private lastActived = false; | | 51 | + | 50 | 52 | componentDidMount() { | 51 | 53 | this.checkActived(); | 52 | 54 | } | @@ -55,8 +57,6 @@ export class PanelDockView extends Component<DockProps & { dock: PanelDock }> { | 55 | 57 | this.checkActived(); | 56 | 58 | } | 57 | 59 |
| 58 | | - private lastActived = false; | 59 | | - | 60 | 60 | checkActived() { | 61 | 61 | const { dock } = this.props; | 62 | 62 | if (dock.actived !== this.lastActived) { | @@ -134,7 +134,7 @@ export class DraggableLineView extends Component<{ panel: Panel }> { | 134 | 134 | // 默认 关闭,通过配置开启 | 135 | 135 | const enableDrag = this.props.panel.config.props?.enableDrag; | 136 | 136 | 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') { | 138 | 138 | return null; | 139 | 139 | } | 140 | 140 | return ( | @@ -159,6 +159,8 @@ export class DraggableLineView extends Component<{ panel: Panel }> { | 159 | 159 |
| 160 | 160 | @observer | 161 | 161 | export class TitledPanelView extends Component<{ panel: Panel; area?: string }> { | | 162 | + private lastVisible = false; | | 163 | + | 162 | 164 | componentDidMount() { | 163 | 165 | this.checkVisible(); | 164 | 166 | } | @@ -167,8 +169,6 @@ export class TitledPanelView extends Component<{ panel: Panel; area?: string }> | 167 | 169 | this.checkVisible(); | 168 | 170 | } | 169 | 171 |
| 170 | | - private lastVisible = false; | 171 | | - | 172 | 172 | checkVisible() { | 173 | 173 | const { panel } = this.props; | 174 | 174 | const currentVisible = panel.inited && panel.visible; | @@ -218,6 +218,8 @@ export class PanelView extends Component<{ | 218 | 218 | hideOperationRow?: boolean; | 219 | 219 | hideDragLine?: boolean; | 220 | 220 | }> { | | 221 | + private lastVisible = false; | | 222 | + | 221 | 223 | componentDidMount() { | 222 | 224 | this.checkVisible(); | 223 | 225 | } | @@ -226,8 +228,6 @@ export class PanelView extends Component<{ | 226 | 228 | this.checkVisible(); | 227 | 229 | } | 228 | 230 |
| 229 | | - private lastVisible = false; | 230 | | - | 231 | 231 | checkVisible() { | 232 | 232 | const { panel } = this.props; | 233 | 233 | const currentVisible = panel.inited && panel.visible; | @@ -331,6 +331,9 @@ class PanelTitle extends Component<{ panel: Panel; className?: string }> { | 331 | 331 |
| 332 | 332 | @observer | 333 | 333 | export class WidgetView extends Component<{ widget: IWidget }> { | | 334 | + private lastVisible = false; | | 335 | + private lastDisabled: boolean | undefined = false; | | 336 | + | 334 | 337 | componentDidMount() { | 335 | 338 | this.checkVisible(); | 336 | 339 | this.checkDisabled(); | @@ -341,9 +344,6 @@ export class WidgetView extends Component<{ widget: IWidget }> { | 341 | 344 | this.checkDisabled(); | 342 | 345 | } | 343 | 346 |
| 344 | | - private lastVisible = false; | 345 | | - private lastDisabled = false; | 346 | | - | 347 | 347 | checkVisible() { | 348 | 348 | const { widget } = this.props; | 349 | 349 | const currentVisible = widget.visible; | |
Collapse file Copy file name to clipboardExpand all lines: packages/editor-skeleton/src/layouts/workbench.less +1-3Lines changed: 1 addition & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -323,10 +323,8 @@ body { | 323 | 323 | display: flex; | 324 | 324 | align-items: center; | 325 | 325 | justify-content: center; | | 326 | + cursor: pointer; | 326 | 327 |
| 327 | | - &.has-tip { | 328 | | - cursor: pointer; | 329 | | - } | 330 | 328 | &.actived { | 331 | 329 | color: #0079f2; | 332 | 330 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/model/dragon.ts +11-6Lines changed: 11 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import { | | 2 | + IDragon, | 2 | 3 | ILocateEvent as InnerLocateEvent, | | 4 | + INode, | 3 | 5 | } from '@alilc/lowcode-designer'; | 4 | 6 | import { dragonSymbol, nodeSymbol } from '../symbols'; | 5 | 7 | import LocateEvent from './locate-event'; | @@ -11,18 +13,19 @@ import { | 11 | 13 | IPublicModelDragObject, | 12 | 14 | IPublicTypeDragNodeDataObject, | 13 | 15 | IPublicModelNode, | | 16 | + IPublicTypeDragObject, | 14 | 17 | } from '@alilc/lowcode-types'; | 15 | 18 |
| 16 | 19 | export const innerDragonSymbol = Symbol('innerDragonSymbol'); | 17 | 20 |
| 18 | 21 | export class Dragon implements IPublicModelDragon { | 19 | | - private readonly [innerDragonSymbol]: IPublicModelDragon; | | 22 | + private readonly [innerDragonSymbol]: IDragon; | 20 | 23 |
| 21 | | - constructor(innerDragon: IPublicModelDragon, readonly workspaceMode: boolean) { | | 24 | + constructor(innerDragon: IDragon, readonly workspaceMode: boolean) { | 22 | 25 | this[innerDragonSymbol] = innerDragon; | 23 | 26 | } | 24 | 27 |
| 25 | | - get [dragonSymbol](): any { | | 28 | + get [dragonSymbol](): IDragon { | 26 | 29 | if (this.workspaceMode) { | 27 | 30 | return this[innerDragonSymbol]; | 28 | 31 | } | @@ -38,7 +41,7 @@ export class Dragon implements IPublicModelDragon { | 38 | 41 | } | 39 | 42 |
| 40 | 43 | static create( | 41 | | - dragon: IPublicModelDragon | null, | | 44 | + dragon: IDragon | null, | 42 | 45 | workspaceMode: boolean, | 43 | 46 | ): IPublicModelDragon | null { | 44 | 47 | if (!dragon) { | @@ -102,11 +105,13 @@ export class Dragon implements IPublicModelDragon { | 102 | 105 | * @param dragObject 拖拽对象 | 103 | 106 | * @param boostEvent 拖拽初始时事件 | 104 | 107 | */ | 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 { | 106 | 111 | return this[dragonSymbol].boost({ | 107 | 112 | ...dragObject, | 108 | 113 | nodes: dragObject.nodes.map((node: any) => node[nodeSymbol]), | 109 | | - }, boostEvent, fromRglNode); | | 114 | + }, boostEvent, fromRglNode?.[nodeSymbol]); | 110 | 115 | } | 111 | 116 |
| 112 | 117 | /** | |
Collapse file Copy file name to clipboardExpand all lines: packages/shell/src/model/locate-event.ts +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -import { ILocateEvent as InnerLocateEvent } from '@alilc/lowcode-designer'; | | 1 | +import { ILocateEvent } from '@alilc/lowcode-designer'; | 2 | 2 | import { locateEventSymbol } from '../symbols'; | 3 | 3 | import { DragObject } from './drag-object'; | 4 | 4 | import { IPublicModelLocateEvent, IPublicModelDragObject } from '@alilc/lowcode-types'; | 5 | 5 |
| 6 | 6 | export default class LocateEvent implements IPublicModelLocateEvent { | 7 | | - private readonly [locateEventSymbol]: InnerLocateEvent; | | 7 | + private readonly [locateEventSymbol]: ILocateEvent; | 8 | 8 |
| 9 | | - constructor(locateEvent: InnerLocateEvent) { | | 9 | + constructor(locateEvent: ILocateEvent) { | 10 | 10 | this[locateEventSymbol] = locateEvent; | 11 | 11 | } | 12 | 12 |
| 13 | | - static create(locateEvent: InnerLocateEvent): IPublicModelLocateEvent | null { | | 13 | + static create(locateEvent: ILocateEvent): IPublicModelLocateEvent | null { | 14 | 14 | if (!locateEvent) { | 15 | 15 | return null; | 16 | 16 | } | |
Collapse file Copy file name to clipboardExpand all lines: packages/types/src/shell/model/dragon.ts +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3,7 +3,8 @@ import { IPublicTypeDragNodeDataObject, IPublicTypeDragObject } from '../type'; | 3 | 3 | import { IPublicModelDragObject, IPublicModelLocateEvent, IPublicModelNode } from './'; | 4 | 4 |
| 5 | 5 | export interface IPublicModelDragon< | 6 | | - Node = IPublicModelNode | | 6 | + Node = IPublicModelNode, | | 7 | + LocateEvent = IPublicModelLocateEvent | 7 | 8 | > { | 8 | 9 |
| 9 | 10 | /** | @@ -18,15 +19,15 @@ export interface IPublicModelDragon< | 18 | 19 | * @param func | 19 | 20 | * @returns | 20 | 21 | */ | 21 | | - onDragstart(func: (e: IPublicModelLocateEvent) => any): () => void; | | 22 | + onDragstart(func: (e: LocateEvent) => any): () => void; | 22 | 23 |
| 23 | 24 | /** | 24 | 25 | * 绑定 drag 事件 | 25 | 26 | * bind a callback function which will be called on dragging | 26 | 27 | * @param func | 27 | 28 | * @returns | 28 | 29 | */ | 29 | | - onDrag(func: (e: IPublicModelLocateEvent) => any): () => void; | | 30 | + onDrag(func: (e: LocateEvent) => any): () => void; | 30 | 31 |
| 31 | 32 | /** | 32 | 33 | * 绑定 dragend 事件 | |
Collapse file Copy file name to clipboardExpand all lines: packages/workspace/src/resource.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -73,7 +73,9 @@ export class Resource implements IResource { | 73 | 73 |
| 74 | 74 | constructor(readonly resourceData: IPublicResourceData, readonly resourceType: IResourceType, readonly workspace: IWorkspace) { | 75 | 75 | 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); | 77 | 79 | this.init(); | 78 | 80 | if (this.resourceTypeInstance.editorViews) { | 79 | 81 | this.resourceTypeInstance.editorViews.forEach((d: any) => { | |
|