mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-06-02 21:50:47 +00:00
Merge branch 'develop' into release/1.1.0-beta
This commit is contained in:
commit
fc896df066
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: cavas - 画布 API
|
title: canvas - 画布 API
|
||||||
sidebar_position: 12
|
sidebar_position: 12
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -17,30 +17,25 @@ sidebar_position: 12
|
|||||||
|
|
||||||
获取拖拽操作对象的实例
|
获取拖拽操作对象的实例
|
||||||
|
|
||||||
```typescript
|
`@type {IPublicModelDragon | null}`
|
||||||
/**
|
|
||||||
* 获取拖拽操作对象的实例
|
|
||||||
* get dragon instance, you can use this to obtain draging related abilities and lifecycle hooks
|
相关类型:[IPublicModelDragon](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/dragon.ts)
|
||||||
* @since v1.1.0
|
|
||||||
*/
|
|
||||||
get dragon(): IPublicModelDragon | null;
|
|
||||||
```
|
|
||||||
关联模型 [IPublicModelDragon](./model/dragon)
|
|
||||||
|
|
||||||
### activeTracker
|
### activeTracker
|
||||||
|
|
||||||
获取活动追踪器实例
|
获取活动追踪器实例
|
||||||
|
|
||||||
```typescript
|
`@type {IPublicModelActiveTracker | null}`
|
||||||
/**
|
|
||||||
* 获取活动追踪器实例
|
相关类型:[IPublicModelActiveTracker](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/active-tracker.ts)
|
||||||
* get activeTracker instance, which is a singleton running in engine.
|
|
||||||
* it tracks document`s current focusing node/node[], and notify it`s subscribers that when
|
### isInLiveEditing
|
||||||
* focusing node/node[] changed.
|
|
||||||
* @since v1.1.0
|
是否处于 LiveEditing 状态
|
||||||
*/
|
|
||||||
get activeTracker(): IPublicModelActiveTracker | null;
|
`@type {boolean}`
|
||||||
```
|
|
||||||
|
|
||||||
## 方法
|
## 方法
|
||||||
|
|
||||||
@ -83,4 +78,4 @@ createScroller(scrollable: IPublicModelScrollable): IPublicModelScroller;
|
|||||||
* @since v1.1.0
|
* @since v1.1.0
|
||||||
*/
|
*/
|
||||||
createScrollTarget(shell: HTMLDivElement): IPublicModelScrollTarget;
|
createScrollTarget(shell: HTMLDivElement): IPublicModelScrollTarget;
|
||||||
```
|
```
|
||||||
|
|||||||
@ -17,7 +17,7 @@ sidebar_position: 13
|
|||||||
|
|
||||||
拖拽放置位置目标
|
拖拽放置位置目标
|
||||||
|
|
||||||
`@type {IPublicModelNode}`
|
`@type {IPublicModelNode | null}`
|
||||||
|
|
||||||
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
|
相关类型:[IPublicModelNode](https://github.com/alibaba/lowcode-engine/blob/main/packages/types/src/shell/model/node.ts)
|
||||||
|
|
||||||
|
|||||||
@ -6,16 +6,22 @@ import {
|
|||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import { isNode } from '@alilc/lowcode-utils';
|
import { isNode } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
export interface IActiveTracker extends Omit< IPublicModelActiveTracker, 'track' > {
|
export interface IActiveTracker extends Omit< IPublicModelActiveTracker, 'track' | 'onChange' > {
|
||||||
track(originalTarget: IPublicTypeActiveTarget | INode): void;
|
track(originalTarget: ActiveTarget | INode): void;
|
||||||
|
|
||||||
|
onChange(fn: (target: ActiveTarget) => void): () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ActiveTarget extends Omit< IPublicTypeActiveTarget, 'node' > {
|
||||||
|
node: INode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ActiveTracker implements IActiveTracker {
|
export class ActiveTracker implements IActiveTracker {
|
||||||
private emitter: IEventBus = createModuleEventBus('ActiveTracker');
|
private emitter: IEventBus = createModuleEventBus('ActiveTracker');
|
||||||
|
|
||||||
@obx.ref private _target?: IPublicTypeActiveTarget | INode;
|
@obx.ref private _target?: ActiveTarget | INode;
|
||||||
|
|
||||||
track(originalTarget: IPublicTypeActiveTarget | INode) {
|
track(originalTarget: ActiveTarget | INode) {
|
||||||
let target = originalTarget;
|
let target = originalTarget;
|
||||||
if (isNode(originalTarget)) {
|
if (isNode(originalTarget)) {
|
||||||
target = { node: originalTarget as INode };
|
target = { node: originalTarget as INode };
|
||||||
@ -25,11 +31,11 @@ export class ActiveTracker implements IActiveTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get currentNode() {
|
get currentNode() {
|
||||||
return (this._target as IPublicTypeActiveTarget)?.node;
|
return (this._target as ActiveTarget)?.node;
|
||||||
}
|
}
|
||||||
|
|
||||||
get detail() {
|
get detail() {
|
||||||
return (this._target as IPublicTypeActiveTarget)?.detail;
|
return (this._target as ActiveTarget)?.detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,10 +47,10 @@ export class ActiveTracker implements IActiveTracker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get instance() {
|
get instance() {
|
||||||
return (this._target as IPublicTypeActiveTarget)?.instance;
|
return (this._target as ActiveTarget)?.instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
onChange(fn: (target: IPublicTypeActiveTarget) => void): () => void {
|
onChange(fn: (target: ActiveTarget) => void): () => void {
|
||||||
this.emitter.addListener('change', fn);
|
this.emitter.addListener('change', fn);
|
||||||
return () => {
|
return () => {
|
||||||
this.emitter.removeListener('change', fn);
|
this.emitter.removeListener('change', fn);
|
||||||
|
|||||||
@ -7,9 +7,9 @@ import {
|
|||||||
IPublicTypeRect,
|
IPublicTypeRect,
|
||||||
IPublicTypeLocationDetail,
|
IPublicTypeLocationDetail,
|
||||||
IPublicTypeLocationData,
|
IPublicTypeLocationData,
|
||||||
|
IPublicModelLocateEvent,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
|
|
||||||
|
|
||||||
export interface Point {
|
export interface Point {
|
||||||
clientX: number;
|
clientX: number;
|
||||||
clientY: number;
|
clientY: number;
|
||||||
@ -99,11 +99,15 @@ function isDocument(elem: any): elem is Document {
|
|||||||
export function getWindow(elem: Element | Document): Window {
|
export function getWindow(elem: Element | Document): Window {
|
||||||
return (isDocument(elem) ? elem : elem.ownerDocument!).defaultView!;
|
return (isDocument(elem) ? elem : elem.ownerDocument!).defaultView!;
|
||||||
}
|
}
|
||||||
export interface IDropLocation extends IPublicModelDropLocation {
|
export interface IDropLocation extends Omit< IPublicModelDropLocation, 'target' | 'clone' > {
|
||||||
|
|
||||||
readonly source: string;
|
readonly source: string;
|
||||||
|
|
||||||
|
get target(): INode;
|
||||||
|
|
||||||
get document(): IPublicModelDocumentModel;
|
get document(): IPublicModelDocumentModel;
|
||||||
|
|
||||||
|
clone(event: IPublicModelLocateEvent): IDropLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DropLocation implements IDropLocation {
|
export class DropLocation implements IDropLocation {
|
||||||
@ -126,7 +130,7 @@ export class DropLocation implements IDropLocation {
|
|||||||
this.event = event;
|
this.event = event;
|
||||||
}
|
}
|
||||||
|
|
||||||
clone(event: ILocateEvent): DropLocation {
|
clone(event: ILocateEvent): IDropLocation {
|
||||||
return new DropLocation({
|
return new DropLocation({
|
||||||
target: this.target,
|
target: this.target,
|
||||||
detail: this.detail,
|
detail: this.detail,
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
import { IPublicModelSettingTarget } from '@alilc/lowcode-types';
|
import { IPublicModelSettingTarget } from '@alilc/lowcode-types';
|
||||||
import { ComponentMeta } from '../../component-meta';
|
import { IComponentMeta } from '../../component-meta';
|
||||||
import { Designer } from '../designer';
|
import { Designer } from '../designer';
|
||||||
import { Node } from '../../document';
|
import { INode } from '../../document';
|
||||||
|
|
||||||
export interface SettingEntry extends IPublicModelSettingTarget {
|
export interface SettingEntry extends IPublicModelSettingTarget {
|
||||||
readonly nodes: Node[];
|
readonly nodes: INode[];
|
||||||
readonly componentMeta: ComponentMeta | null;
|
readonly componentMeta: IComponentMeta | null;
|
||||||
readonly designer: Designer;
|
readonly designer: Designer;
|
||||||
|
|
||||||
// 顶端
|
// 顶端
|
||||||
|
|||||||
@ -2,8 +2,8 @@ import { obx, computed, makeObservable, runInAction, IEventBus, createModuleEven
|
|||||||
import { GlobalEvent, IPublicModelEditor, IPublicTypeSetValueOptions } from '@alilc/lowcode-types';
|
import { GlobalEvent, IPublicModelEditor, IPublicTypeSetValueOptions } from '@alilc/lowcode-types';
|
||||||
import { uniqueId, isJSExpression, isSettingField } from '@alilc/lowcode-utils';
|
import { uniqueId, isJSExpression, isSettingField } from '@alilc/lowcode-utils';
|
||||||
import { SettingEntry } from './setting-entry';
|
import { SettingEntry } from './setting-entry';
|
||||||
import { Node } from '../../document';
|
import { INode } from '../../document';
|
||||||
import { ComponentMeta } from '../../component-meta';
|
import { IComponentMeta } from '../../component-meta';
|
||||||
import { Designer } from '../designer';
|
import { Designer } from '../designer';
|
||||||
import { Setters } from '@alilc/lowcode-shell';
|
import { Setters } from '@alilc/lowcode-shell';
|
||||||
|
|
||||||
@ -19,9 +19,9 @@ export class SettingPropEntry implements SettingEntry {
|
|||||||
|
|
||||||
readonly setters: Setters;
|
readonly setters: Setters;
|
||||||
|
|
||||||
readonly nodes: Node[];
|
readonly nodes: INode[];
|
||||||
|
|
||||||
readonly componentMeta: ComponentMeta | null;
|
readonly componentMeta: IComponentMeta | null;
|
||||||
|
|
||||||
readonly designer: Designer;
|
readonly designer: Designer;
|
||||||
|
|
||||||
|
|||||||
@ -11,12 +11,14 @@ export const UNSET = Symbol.for('unset');
|
|||||||
// eslint-disable-next-line no-redeclare
|
// eslint-disable-next-line no-redeclare
|
||||||
export type UNSET = typeof UNSET;
|
export type UNSET = typeof UNSET;
|
||||||
|
|
||||||
export interface IProp extends Omit<IPublicModelProp, 'exportSchema' | 'node'> {
|
export interface IProp extends Omit<IPublicModelProp, 'exportSchema' | 'node' | 'slotNode' > {
|
||||||
|
|
||||||
readonly props: Props;
|
readonly props: Props;
|
||||||
|
|
||||||
readonly owner: INode;
|
readonly owner: INode;
|
||||||
|
|
||||||
|
get slotNode(): INode | null;
|
||||||
|
|
||||||
delete(prop: Prop): void;
|
delete(prop: Prop): void;
|
||||||
|
|
||||||
export(stage: IPublicEnumTransformStage): IPublicTypeCompositeValue;
|
export(stage: IPublicEnumTransformStage): IPublicTypeCompositeValue;
|
||||||
@ -113,8 +115,8 @@ export class Prop implements IProp, IPropParent {
|
|||||||
|
|
||||||
private _slotNode?: INode;
|
private _slotNode?: INode;
|
||||||
|
|
||||||
get slotNode(): INode | undefined | null {
|
get slotNode(): INode | null {
|
||||||
return this._slotNode;
|
return this._slotNode || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@obx.shallow private _items: Prop[] | null = null;
|
@obx.shallow private _items: Prop[] | null = null;
|
||||||
|
|||||||
@ -7,11 +7,11 @@ import {
|
|||||||
import { Designer } from '../../src/designer/designer';
|
import { Designer } from '../../src/designer/designer';
|
||||||
import formSchema from '../fixtures/schema/form';
|
import formSchema from '../fixtures/schema/form';
|
||||||
import { fireEvent } from '@testing-library/react';
|
import { fireEvent } from '@testing-library/react';
|
||||||
import { isInLiveEditing, builtinHotkey } from '../../../engine/src/inner-plugins/builtin-hotkey';
|
import { builtinHotkey } from '../../../engine/src/inner-plugins/builtin-hotkey';
|
||||||
import { shellModelFactory } from '../../../engine/src/modules/shell-model-factory';
|
import { shellModelFactory } from '../../../engine/src/modules/shell-model-factory';
|
||||||
import { ILowCodePluginContextPrivate, LowCodePluginManager } from '@alilc/lowcode-designer';
|
import { ILowCodePluginContextPrivate, LowCodePluginManager } from '@alilc/lowcode-designer';
|
||||||
import { IPublicApiPlugins } from '@alilc/lowcode-types';
|
import { IPublicApiPlugins } from '@alilc/lowcode-types';
|
||||||
import { Logger, Project } from '@alilc/lowcode-shell';
|
import { Logger, Project, Canvas } from '@alilc/lowcode-shell';
|
||||||
import { Workspace } from '@alilc/lowcode-workspace';
|
import { Workspace } from '@alilc/lowcode-workspace';
|
||||||
|
|
||||||
const editor = new Editor();
|
const editor = new Editor();
|
||||||
@ -19,12 +19,6 @@ const workspace = new Workspace();
|
|||||||
|
|
||||||
let designer: Designer;
|
let designer: Designer;
|
||||||
|
|
||||||
describe('error scenarios', () => {
|
|
||||||
it('edtior not registered', () => {
|
|
||||||
expect(isInLiveEditing()).toBeUndefined();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// keyCode 对应表:https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
|
// keyCode 对应表:https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
|
||||||
// hotkey 模块底层用的 keyCode,所以还不能用 key / code 测试
|
// hotkey 模块底层用的 keyCode,所以还不能用 key / code 测试
|
||||||
describe('快捷键测试', () => {
|
describe('快捷键测试', () => {
|
||||||
@ -40,6 +34,7 @@ describe('快捷键测试', () => {
|
|||||||
context.hotkey = hotkey;
|
context.hotkey = hotkey;
|
||||||
context.logger = logger;
|
context.logger = logger;
|
||||||
context.project = project;
|
context.project = project;
|
||||||
|
context.canvas = new Canvas(editor);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
pluginManager = new LowCodePluginManager(contextApiAssembler).toProxy();
|
pluginManager = new LowCodePluginManager(contextApiAssembler).toProxy();
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
import { Editor, globalContext } from '@alilc/lowcode-editor-core';
|
|
||||||
import { isFormEvent } from '@alilc/lowcode-utils';
|
import { isFormEvent } from '@alilc/lowcode-utils';
|
||||||
import {
|
import {
|
||||||
focusing,
|
focusing,
|
||||||
@ -12,23 +11,9 @@ import {
|
|||||||
IPublicModelNode,
|
IPublicModelNode,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import symbols from '../modules/symbols';
|
import symbols from '../modules/symbols';
|
||||||
|
|
||||||
const { nodeSymbol, documentSymbol } = symbols;
|
const { nodeSymbol, documentSymbol } = symbols;
|
||||||
|
|
||||||
export function isInLiveEditing() {
|
|
||||||
const workspace = globalContext.has('workspace') && globalContext.get('workspace');
|
|
||||||
if (workspace?.isActive) {
|
|
||||||
return Boolean(
|
|
||||||
workspace.window.editor.get('designer')?.project?.simulator?.liveEditing?.editing,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (globalContext.has(Editor)) {
|
|
||||||
return Boolean(
|
|
||||||
globalContext.get(Editor).get('designer')?.project?.simulator?.liveEditing?.editing,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
function getNextForSelect(next: IPublicModelNode | null, head?: any, parent?: IPublicModelNode | null): any {
|
function getNextForSelect(next: IPublicModelNode | null, head?: any, parent?: IPublicModelNode | null): any {
|
||||||
if (next) {
|
if (next) {
|
||||||
@ -95,12 +80,12 @@ function getPrevForSelect(prev: IPublicModelNode | null, head?: any, parent?: IP
|
|||||||
export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
||||||
return {
|
return {
|
||||||
init() {
|
init() {
|
||||||
const { hotkey, project, logger } = ctx;
|
const { hotkey, project, logger, canvas } = ctx;
|
||||||
// hotkey binding
|
// hotkey binding
|
||||||
hotkey.bind(['backspace', 'del'], (e: KeyboardEvent, action) => {
|
hotkey.bind(['backspace', 'del'], (e: KeyboardEvent, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
|
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// TODO: use focus-tracker
|
// TODO: use focus-tracker
|
||||||
@ -124,7 +109,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
|||||||
hotkey.bind('escape', (e: KeyboardEvent, action) => {
|
hotkey.bind('escape', (e: KeyboardEvent, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
// const currentFocus = focusing.current;
|
// const currentFocus = focusing.current;
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const sel = focusing.focusDesigner?.currentDocument?.selection;
|
const sel = focusing.focusDesigner?.currentDocument?.selection;
|
||||||
@ -140,7 +125,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
|||||||
// command + c copy command + x cut
|
// command + c copy command + x cut
|
||||||
hotkey.bind(['command+c', 'ctrl+c', 'command+x', 'ctrl+x'], (e, action) => {
|
hotkey.bind(['command+c', 'ctrl+c', 'command+x', 'ctrl+x'], (e, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
@ -179,10 +164,9 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
|||||||
// command + v paste
|
// command + v paste
|
||||||
hotkey.bind(['command+v', 'ctrl+v'], (e, action) => {
|
hotkey.bind(['command+v', 'ctrl+v'], (e, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isInLiveEditing()) return;
|
|
||||||
// TODO
|
// TODO
|
||||||
const designer = focusing.focusDesigner;
|
const designer = focusing.focusDesigner;
|
||||||
const doc = project?.currentDocument;
|
const doc = project?.currentDocument;
|
||||||
@ -212,7 +196,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
|||||||
// command + z undo
|
// command + z undo
|
||||||
hotkey.bind(['command+z', 'ctrl+z'], (e, action) => {
|
hotkey.bind(['command+z', 'ctrl+z'], (e, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const history = project.currentDocument?.history;
|
const history = project.currentDocument?.history;
|
||||||
@ -230,7 +214,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
|||||||
// command + shift + z redo
|
// command + shift + z redo
|
||||||
hotkey.bind(['command+y', 'ctrl+y', 'command+shift+z'], (e, action) => {
|
hotkey.bind(['command+y', 'ctrl+y', 'command+shift+z'], (e, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const history = project.currentDocument?.history;
|
const history = project.currentDocument?.history;
|
||||||
@ -247,7 +231,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
|||||||
// sibling selection
|
// sibling selection
|
||||||
hotkey.bind(['left', 'right'], (e, action) => {
|
hotkey.bind(['left', 'right'], (e, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
@ -266,7 +250,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
|||||||
|
|
||||||
hotkey.bind(['up', 'down'], (e, action) => {
|
hotkey.bind(['up', 'down'], (e, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
@ -291,7 +275,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
|||||||
|
|
||||||
hotkey.bind(['option+left', 'option+right'], (e, action) => {
|
hotkey.bind(['option+left', 'option+right'], (e, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
@ -325,7 +309,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
|||||||
|
|
||||||
hotkey.bind(['option+up'], (e, action) => {
|
hotkey.bind(['option+up'], (e, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const doc = project.currentDocument;
|
const doc = project.currentDocument;
|
||||||
@ -367,7 +351,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
|||||||
|
|
||||||
hotkey.bind(['option+down'], (e, action) => {
|
hotkey.bind(['option+down'], (e, action) => {
|
||||||
logger.info(`action ${action} is triggered`);
|
logger.info(`action ${action} is triggered`);
|
||||||
if (isInLiveEditing()) {
|
if (canvas.isInLiveEditing) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const doc = project.getCurrentDocument();
|
const doc = project.getCurrentDocument();
|
||||||
|
|||||||
@ -36,6 +36,10 @@ export class Canvas implements IPublicApiCanvas {
|
|||||||
return activeTracker;
|
return activeTracker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isInLiveEditing(): boolean {
|
||||||
|
return Boolean(this[editorSymbol].get('designer')?.project?.simulator?.liveEditing?.editing);
|
||||||
|
}
|
||||||
|
|
||||||
constructor(editor: IPublicModelEditor, readonly workspaceMode: boolean = false) {
|
constructor(editor: IPublicModelEditor, readonly workspaceMode: boolean = false) {
|
||||||
this[editorSymbol] = editor;
|
this[editorSymbol] = editor;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { IPublicModelActiveTracker, IPublicModelNode, IPublicTypeActiveTarget } from '@alilc/lowcode-types';
|
import { IPublicModelActiveTracker, IPublicModelNode, IPublicTypeActiveTarget } from '@alilc/lowcode-types';
|
||||||
import { IActiveTracker as InnerActiveTracker, INode as InnerNode } from '@alilc/lowcode-designer';
|
import { IActiveTracker as InnerActiveTracker, ActiveTarget } from '@alilc/lowcode-designer';
|
||||||
import { Node as ShellNode } from './node';
|
import { Node as ShellNode } from './node';
|
||||||
import { nodeSymbol } from '../symbols';
|
import { nodeSymbol } from '../symbols';
|
||||||
|
|
||||||
@ -16,9 +16,9 @@ export class ActiveTracker implements IPublicModelActiveTracker {
|
|||||||
if (!fn) {
|
if (!fn) {
|
||||||
return () => {};
|
return () => {};
|
||||||
}
|
}
|
||||||
return this[activeTrackerSymbol].onChange((t: IPublicTypeActiveTarget) => {
|
return this[activeTrackerSymbol].onChange((t: ActiveTarget) => {
|
||||||
const { node: innerNode, detail, instance } = t;
|
const { node: innerNode, detail, instance } = t;
|
||||||
const publicNode = ShellNode.create(innerNode as InnerNode);
|
const publicNode = ShellNode.create(innerNode);
|
||||||
const publicActiveTarget = {
|
const publicActiveTarget = {
|
||||||
node: publicNode!,
|
node: publicNode!,
|
||||||
detail,
|
detail,
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import {
|
|||||||
IDropLocation as InnerDropLocation,
|
IDropLocation as InnerDropLocation,
|
||||||
} from '@alilc/lowcode-designer';
|
} from '@alilc/lowcode-designer';
|
||||||
import { dropLocationSymbol } from '../symbols';
|
import { dropLocationSymbol } from '../symbols';
|
||||||
import { Node } from './node';
|
import { Node as ShellNode } from './node';
|
||||||
import { IPublicModelDropLocation, IPublicTypeLocationDetail, IPublicModelLocateEvent } from '@alilc/lowcode-types';
|
import { IPublicModelDropLocation, IPublicTypeLocationDetail, IPublicModelLocateEvent } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export class DropLocation implements IPublicModelDropLocation {
|
export class DropLocation implements IPublicModelDropLocation {
|
||||||
@ -20,7 +20,7 @@ export class DropLocation implements IPublicModelDropLocation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get target() {
|
get target() {
|
||||||
return Node.create(this[dropLocationSymbol].target);
|
return ShellNode.create(this[dropLocationSymbol].target);
|
||||||
}
|
}
|
||||||
|
|
||||||
get detail(): IPublicTypeLocationDetail {
|
get detail(): IPublicTypeLocationDetail {
|
||||||
|
|||||||
@ -335,6 +335,7 @@ export class Node implements IPublicModelNode {
|
|||||||
}
|
}
|
||||||
const shellNode = new Node(node);
|
const shellNode = new Node(node);
|
||||||
// @ts-ignore 挂载 shell node 实例
|
// @ts-ignore 挂载 shell node 实例
|
||||||
|
// eslint-disable-next-line no-param-reassign
|
||||||
node[shellNodeSymbol] = shellNode;
|
node[shellNodeSymbol] = shellNode;
|
||||||
return shellNode;
|
return shellNode;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
import { IPublicModelResource } from '@alilc/lowcode-types';
|
import { IPublicModelResource } from '@alilc/lowcode-types';
|
||||||
import { Resource as InnerResource } from '@alilc/lowcode-workspace';
|
import { Resource as InnerResource } from '@alilc/lowcode-workspace';
|
||||||
import { resourceSymbol } from '../symbols';
|
import { resourceSymbol } from '../symbols';
|
||||||
import { ResourceType } from './resource-type';
|
|
||||||
|
|
||||||
export class Resource implements IPublicModelResource {
|
export class Resource implements IPublicModelResource {
|
||||||
readonly [resourceSymbol]: InnerResource;
|
readonly [resourceSymbol]: InnerResource;
|
||||||
|
|||||||
@ -12,9 +12,9 @@ import {
|
|||||||
IPublicTypeSetValueOptions,
|
IPublicTypeSetValueOptions,
|
||||||
} from '@alilc/lowcode-types';
|
} from '@alilc/lowcode-types';
|
||||||
import { settingPropEntrySymbol } from '../symbols';
|
import { settingPropEntrySymbol } from '../symbols';
|
||||||
import { Node } from './node';
|
import { Node as ShellNode } from './node';
|
||||||
import { SettingTopEntry } from './setting-top-entry';
|
import { SettingTopEntry as ShellSettingTopEntry } from './setting-top-entry';
|
||||||
import { ComponentMeta } from './component-meta';
|
import { ComponentMeta as ShellComponentMeta } from './component-meta';
|
||||||
import { isCustomView } from '@alilc/lowcode-utils';
|
import { isCustomView } from '@alilc/lowcode-utils';
|
||||||
|
|
||||||
export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
||||||
@ -92,14 +92,14 @@ export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get props(): IPublicModelSettingTopEntry {
|
get props(): IPublicModelSettingTopEntry {
|
||||||
return SettingTopEntry.create(this[settingPropEntrySymbol].props);
|
return ShellSettingTopEntry.create(this[settingPropEntrySymbol].props);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设置属性对应的节点实例
|
* 获取设置属性对应的节点实例
|
||||||
*/
|
*/
|
||||||
get node(): IPublicModelNode | null {
|
get node(): IPublicModelNode | null {
|
||||||
return Node.create(this[settingPropEntrySymbol].getNode());
|
return ShellNode.create(this[settingPropEntrySymbol].getNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,7 +113,7 @@ export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
|||||||
* 获取顶级设置属性
|
* 获取顶级设置属性
|
||||||
*/
|
*/
|
||||||
get top(): IPublicModelSettingTopEntry {
|
get top(): IPublicModelSettingTopEntry {
|
||||||
return SettingTopEntry.create(this[settingPropEntrySymbol].top);
|
return ShellSettingTopEntry.create(this[settingPropEntrySymbol].top);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,7 +127,7 @@ export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
|||||||
* componentMeta
|
* componentMeta
|
||||||
*/
|
*/
|
||||||
get componentMeta(): IPublicModelComponentMeta | null {
|
get componentMeta(): IPublicModelComponentMeta | null {
|
||||||
return ComponentMeta.create(this[settingPropEntrySymbol].componentMeta);
|
return ShellComponentMeta.create(this[settingPropEntrySymbol].componentMeta);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -233,7 +233,7 @@ export class SettingPropEntry implements IPublicModelSettingPropEntry {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getProps(): IPublicModelSettingTopEntry {
|
getProps(): IPublicModelSettingTopEntry {
|
||||||
return SettingTopEntry.create(this[settingPropEntrySymbol].getProps() as SettingEntry) as any;
|
return ShellSettingTopEntry.create(this[settingPropEntrySymbol].getProps() as SettingEntry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { SettingEntry } from '@alilc/lowcode-designer';
|
import { SettingEntry } from '@alilc/lowcode-designer';
|
||||||
import { settingTopEntrySymbol } from '../symbols';
|
import { settingTopEntrySymbol } from '../symbols';
|
||||||
import { Node } from './node';
|
import { Node as ShellNode } from './node';
|
||||||
import { SettingPropEntry } from './setting-prop-entry';
|
import { SettingPropEntry as ShellSettingPropEntry } from './setting-prop-entry';
|
||||||
import { IPublicModelSettingTopEntry, IPublicModelNode, IPublicModelSettingPropEntry } from '@alilc/lowcode-types';
|
import { IPublicModelSettingTopEntry, IPublicModelNode, IPublicModelSettingPropEntry } from '@alilc/lowcode-types';
|
||||||
|
|
||||||
export class SettingTopEntry implements IPublicModelSettingTopEntry {
|
export class SettingTopEntry implements IPublicModelSettingTopEntry {
|
||||||
@ -19,7 +19,7 @@ export class SettingTopEntry implements IPublicModelSettingTopEntry {
|
|||||||
* 返回所属的节点实例
|
* 返回所属的节点实例
|
||||||
*/
|
*/
|
||||||
get node(): IPublicModelNode | null {
|
get node(): IPublicModelNode | null {
|
||||||
return Node.create(this[settingTopEntrySymbol].getNode());
|
return ShellNode.create(this[settingTopEntrySymbol].getNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +28,7 @@ export class SettingTopEntry implements IPublicModelSettingTopEntry {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
get(propName: string | number): IPublicModelSettingPropEntry {
|
get(propName: string | number): IPublicModelSettingPropEntry {
|
||||||
return SettingPropEntry.create(this[settingTopEntrySymbol].get(propName) as any);
|
return ShellSettingPropEntry.create(this[settingTopEntrySymbol].get(propName) as any);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { windowSymbol } from '../symbols';
|
import { windowSymbol } from '../symbols';
|
||||||
import { IPublicModelResource, IPublicModelWindow } from '@alilc/lowcode-types';
|
import { IPublicModelResource, IPublicModelWindow } from '@alilc/lowcode-types';
|
||||||
import { EditorWindow } from '@alilc/lowcode-workspace';
|
import { EditorWindow } from '@alilc/lowcode-workspace';
|
||||||
import { Resource } from './resource';
|
import { Resource as ShellResource } from './resource';
|
||||||
|
|
||||||
export class Window implements IPublicModelWindow {
|
export class Window implements IPublicModelWindow {
|
||||||
private readonly [windowSymbol]: EditorWindow;
|
private readonly [windowSymbol]: EditorWindow;
|
||||||
@ -19,7 +19,7 @@ export class Window implements IPublicModelWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get resource(): IPublicModelResource {
|
get resource(): IPublicModelResource {
|
||||||
return new Resource(this[windowSymbol].resource);
|
return new ShellResource(this[windowSymbol].resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(editorWindow: EditorWindow) {
|
constructor(editorWindow: EditorWindow) {
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
import { IPublicModelDragon, IPublicModelDropLocation, IPublicModelScrollTarget, IPublicModelScrollable, IPublicModelScroller, IPublicModelActiveTracker } from '../model';
|
import { IPublicModelDragon, IPublicModelDropLocation, IPublicModelScrollTarget, IPublicModelScrollable, IPublicModelScroller, IPublicModelActiveTracker } from '../model';
|
||||||
import { IPublicTypeLocationData } from '../type';
|
import { IPublicTypeLocationData } from '../type';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since v1.1.0
|
||||||
|
*/
|
||||||
export interface IPublicApiCanvas {
|
export interface IPublicApiCanvas {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创一个滚动控制器 Scroller,赋予一个视图滚动的基本能力,
|
* 创一个滚动控制器 Scroller,赋予一个视图滚动的基本能力,
|
||||||
* a Scroller is a controller that gives a view (IPublicModelScrollable) the ability scrolling
|
* a Scroller is a controller that gives a view (IPublicModelScrollable) the ability scrolling
|
||||||
@ -45,4 +47,11 @@ export interface IPublicApiCanvas {
|
|||||||
* @since v1.1.0
|
* @since v1.1.0
|
||||||
*/
|
*/
|
||||||
get activeTracker(): IPublicModelActiveTracker | null;
|
get activeTracker(): IPublicModelActiveTracker | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否处于 LiveEditing 状态
|
||||||
|
* check if canvas is in liveEditing state
|
||||||
|
* @since v1.1.0
|
||||||
|
*/
|
||||||
|
get isInLiveEditing(): boolean;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,7 @@ export interface IPublicModelDropLocation {
|
|||||||
* 拖拽位置目标
|
* 拖拽位置目标
|
||||||
* get target of dropLocation
|
* get target of dropLocation
|
||||||
*/
|
*/
|
||||||
get target(): IPublicModelNode;
|
get target(): IPublicModelNode | null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拖拽放置位置详情
|
* 拖拽放置位置详情
|
||||||
|
|||||||
@ -1,4 +1,10 @@
|
|||||||
|
/**
|
||||||
export function isJSFunction(x: any): boolean {
|
* 内部版本 的 { type: 'JSExpression', source: '', value: '', extType: 'function' } 能力上等同于 JSFunction
|
||||||
return typeof x === 'object' && x && x.type === 'JSFunction';
|
*/
|
||||||
|
export function isInnerJsFunction(data: any) {
|
||||||
|
return data && data.type === 'JSExpression' && data.extType === 'function';
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isJSFunction(data: any): boolean {
|
||||||
|
return typeof data === 'object' && data && data.type === 'JSFunction' || isInnerJsFunction(data);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user