mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-19 22:58:15 +00:00
Merge remote-tracking branch 'origin/develop' into release/1.1.7-beta
This commit is contained in:
commit
42795947f8
@ -7,6 +7,8 @@ import {
|
|||||||
import { isNode } from '@alilc/lowcode-utils';
|
import { isNode } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
export interface IActiveTracker extends Omit< IPublicModelActiveTracker, 'track' | 'onChange' > {
|
export interface IActiveTracker extends Omit< IPublicModelActiveTracker, 'track' | 'onChange' > {
|
||||||
|
_target: ActiveTarget | INode;
|
||||||
|
|
||||||
track(originalTarget: ActiveTarget | INode): void;
|
track(originalTarget: ActiveTarget | INode): void;
|
||||||
|
|
||||||
onChange(fn: (target: ActiveTarget) => void): () => void;
|
onChange(fn: (target: ActiveTarget) => void): () => void;
|
||||||
@ -17,10 +19,10 @@ export interface ActiveTarget extends Omit< IPublicTypeActiveTarget, 'node' > {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class ActiveTracker implements IActiveTracker {
|
export class ActiveTracker implements IActiveTracker {
|
||||||
private emitter: IEventBus = createModuleEventBus('ActiveTracker');
|
|
||||||
|
|
||||||
@obx.ref private _target?: ActiveTarget | INode;
|
@obx.ref private _target?: ActiveTarget | INode;
|
||||||
|
|
||||||
|
private emitter: IEventBus = createModuleEventBus('ActiveTracker');
|
||||||
|
|
||||||
track(originalTarget: ActiveTarget | INode) {
|
track(originalTarget: ActiveTarget | INode) {
|
||||||
let target = originalTarget;
|
let target = originalTarget;
|
||||||
if (isNode(originalTarget)) {
|
if (isNode(originalTarget)) {
|
||||||
|
|||||||
@ -90,13 +90,7 @@ export class TreeMaster {
|
|||||||
private initEvent() {
|
private initEvent() {
|
||||||
let startTime: any;
|
let startTime: any;
|
||||||
const { event, project, canvas } = this.pluginContext;
|
const { event, project, canvas } = this.pluginContext;
|
||||||
this.disposeEvents = [
|
const setExpandByActiveTracker = (target: IPublicTypeActiveTarget) => {
|
||||||
canvas.dragon?.onDragstart(() => {
|
|
||||||
startTime = Date.now() / 1000;
|
|
||||||
// needs?
|
|
||||||
this.toVision();
|
|
||||||
}),
|
|
||||||
canvas.activeTracker?.onChange((target: IPublicTypeActiveTarget) => {
|
|
||||||
const { node, detail } = target;
|
const { node, detail } = target;
|
||||||
const tree = this.currentTree;
|
const tree = this.currentTree;
|
||||||
if (!tree/* || node.document !== tree.document */) {
|
if (!tree/* || node.document !== tree.document */) {
|
||||||
@ -111,7 +105,14 @@ export class TreeMaster {
|
|||||||
this.boards.forEach((board) => {
|
this.boards.forEach((board) => {
|
||||||
board.scrollToNode(treeNode, detail);
|
board.scrollToNode(treeNode, detail);
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
this.disposeEvents = [
|
||||||
|
canvas.dragon?.onDragstart(() => {
|
||||||
|
startTime = Date.now() / 1000;
|
||||||
|
// needs?
|
||||||
|
this.toVision();
|
||||||
}),
|
}),
|
||||||
|
canvas.activeTracker?.onChange(setExpandByActiveTracker),
|
||||||
canvas.dragon?.onDragend(() => {
|
canvas.dragon?.onDragend(() => {
|
||||||
const endTime: any = Date.now() / 1000;
|
const endTime: any = Date.now() / 1000;
|
||||||
const nodes = project.currentDocument?.selection?.getNodes();
|
const nodes = project.currentDocument?.selection?.getNodes();
|
||||||
@ -135,6 +136,9 @@ export class TreeMaster {
|
|||||||
this.treeMap.delete(id);
|
this.treeMap.delete(id);
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
|
if (canvas.activeTracker?.target) {
|
||||||
|
setExpandByActiveTracker(canvas.activeTracker?.target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private toVision() {
|
private toVision() {
|
||||||
|
|||||||
@ -12,6 +12,16 @@ export class ActiveTracker implements IPublicModelActiveTracker {
|
|||||||
this[activeTrackerSymbol] = innerTracker;
|
this[activeTrackerSymbol] = innerTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get target() {
|
||||||
|
const { node: innerNode, detail, instance } = this[activeTrackerSymbol]._target;
|
||||||
|
const publicNode = ShellNode.create(innerNode);
|
||||||
|
return {
|
||||||
|
node: publicNode!,
|
||||||
|
detail,
|
||||||
|
instance,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
onChange(fn: (target: IPublicTypeActiveTarget) => void): () => void {
|
onChange(fn: (target: IPublicTypeActiveTarget) => void): () => void {
|
||||||
if (!fn) {
|
if (!fn) {
|
||||||
return () => {};
|
return () => {};
|
||||||
|
|||||||
@ -2,6 +2,12 @@ import { IPublicTypeActiveTarget } from '../type';
|
|||||||
import { IPublicModelNode } from './node';
|
import { IPublicModelNode } from './node';
|
||||||
|
|
||||||
export interface IPublicModelActiveTracker {
|
export interface IPublicModelActiveTracker {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.1.7
|
||||||
|
*/
|
||||||
|
target: IPublicTypeActiveTarget;
|
||||||
|
|
||||||
onChange(fn: (target: IPublicTypeActiveTarget) => void): () => void;
|
onChange(fn: (target: IPublicTypeActiveTarget) => void): () => void;
|
||||||
|
|
||||||
track(node: IPublicModelNode): void;
|
track(node: IPublicModelNode): void;
|
||||||
|
|||||||
@ -70,9 +70,7 @@ export class Resource implements IResource {
|
|||||||
return this.context.innerSkeleton;
|
return this.context.innerSkeleton;
|
||||||
}
|
}
|
||||||
|
|
||||||
get children(): IResource[] {
|
children: IResource[];
|
||||||
return this.resourceData?.children?.map(d => new Resource(d, this.workspace.getResourceType(d.resourceName || this.resourceType.name), this.workspace)) || [];
|
|
||||||
}
|
|
||||||
|
|
||||||
get config() {
|
get config() {
|
||||||
return this.resourceData.config;
|
return this.resourceData.config;
|
||||||
@ -92,6 +90,7 @@ export class Resource implements IResource {
|
|||||||
if (!resourceType) {
|
if (!resourceType) {
|
||||||
logger.error(`resourceType[${resourceType}] is unValid.`);
|
logger.error(`resourceType[${resourceType}] is unValid.`);
|
||||||
}
|
}
|
||||||
|
this.children = this.resourceData?.children?.map(d => new Resource(d, this.workspace.getResourceType(d.resourceName || this.resourceType.name), this.workspace)) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
|||||||
@ -51,9 +51,6 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
this.title = config.title;
|
this.title = config.title;
|
||||||
this.icon = resource.icon;
|
this.icon = resource.icon;
|
||||||
this.sleep = config.sleep;
|
this.sleep = config.sleep;
|
||||||
if (!config.sleep) {
|
|
||||||
this.init();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async importSchema(schema: any) {
|
async importSchema(schema: any) {
|
||||||
@ -155,6 +152,8 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.editorView.setActivate(true);
|
||||||
|
|
||||||
if (!ignoreEmit) {
|
if (!ignoreEmit) {
|
||||||
this.emitter.emit('window.change.view.type', name);
|
this.emitter.emit('window.change.view.type', name);
|
||||||
|
|
||||||
@ -162,7 +161,6 @@ export class EditorWindow implements IEditorWindow {
|
|||||||
this.workspace.emitChangeActiveEditorView();
|
this.workspace.emitChangeActiveEditorView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.editorView.setActivate(true);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
get project() {
|
get project() {
|
||||||
|
|||||||
@ -115,7 +115,7 @@ export class Workspace implements IWorkspace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initWindow() {
|
async initWindow() {
|
||||||
if (!this.defaultResourceType || this.enableAutoOpenFirstWindow === false) {
|
if (!this.defaultResourceType || this.enableAutoOpenFirstWindow === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -127,6 +127,7 @@ export class Workspace implements IWorkspace {
|
|||||||
this.window = new EditorWindow(resource, this, {
|
this.window = new EditorWindow(resource, this, {
|
||||||
title: resource.title,
|
title: resource.title,
|
||||||
});
|
});
|
||||||
|
await this.window.init();
|
||||||
this.editorWindowMap.set(this.window.id, this.window);
|
this.editorWindowMap.set(this.window.id, this.window);
|
||||||
this.windows = [...this.windows, this.window];
|
this.windows = [...this.windows, this.window];
|
||||||
this.emitChangeWindow();
|
this.emitChangeWindow();
|
||||||
@ -196,6 +197,9 @@ export class Workspace implements IWorkspace {
|
|||||||
this.windows.splice(index, 1);
|
this.windows.splice(index, 1);
|
||||||
if (this.window === window) {
|
if (this.window === window) {
|
||||||
this.window = this.windows[index] || this.windows[index + 1] || this.windows[index - 1];
|
this.window = this.windows[index] || this.windows[index + 1] || this.windows[index - 1];
|
||||||
|
if (this.window.sleep) {
|
||||||
|
this.window.init();
|
||||||
|
}
|
||||||
this.emitChangeActiveWindow();
|
this.emitChangeActiveWindow();
|
||||||
}
|
}
|
||||||
this.emitChangeWindow();
|
this.emitChangeWindow();
|
||||||
@ -206,10 +210,13 @@ export class Workspace implements IWorkspace {
|
|||||||
this.remove(index);
|
this.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
openEditorWindowById(id: string) {
|
async openEditorWindowById(id: string) {
|
||||||
const window = this.editorWindowMap.get(id);
|
const window = this.editorWindowMap.get(id);
|
||||||
if (window) {
|
if (window) {
|
||||||
this.window = window;
|
this.window = window;
|
||||||
|
if (window.sleep) {
|
||||||
|
await window.init();
|
||||||
|
}
|
||||||
this.emitChangeActiveWindow();
|
this.emitChangeActiveWindow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,6 +259,7 @@ export class Workspace implements IWorkspace {
|
|||||||
this.editorWindowMap.set(window.id, window);
|
this.editorWindowMap.set(window.id, window);
|
||||||
if (!sleep) {
|
if (!sleep) {
|
||||||
this.window = window;
|
this.window = window;
|
||||||
|
await this.window.init();
|
||||||
}
|
}
|
||||||
this.emitChangeWindow();
|
this.emitChangeWindow();
|
||||||
this.emitChangeActiveWindow();
|
this.emitChangeActiveWindow();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user