mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-04 17:27:09 +00:00
chore: lint fixed
This commit is contained in:
parent
6b8d0c13bc
commit
764e841336
2
.gitignore
vendored
2
.gitignore
vendored
@ -110,4 +110,4 @@ typings/
|
||||
codealike.json
|
||||
.node
|
||||
|
||||
.must.config.js
|
||||
.must.config.js
|
||||
|
||||
@ -1,23 +1,18 @@
|
||||
import stylistic from '@stylistic/eslint-plugin';
|
||||
import tseslint from 'typescript-eslint'
|
||||
import tseslint from 'typescript-eslint';
|
||||
import js from '@eslint/js';
|
||||
import react from 'eslint-plugin-react'
|
||||
import react from 'eslint-plugin-react';
|
||||
import reactHooks from 'eslint-plugin-react-hooks';
|
||||
import reactRefresh from 'eslint-plugin-react-refresh';
|
||||
import globals from 'globals'
|
||||
import globals from 'globals';
|
||||
|
||||
export default tseslint.config({
|
||||
files: ['packages/*/src/**/*.{ts?(x),js?(x)}'],
|
||||
ignores: ["**/*.test.ts"],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
],
|
||||
files: ['packages/*/{src,__tests__}/**/*.{ts?(x),js?(x)}'],
|
||||
ignores: ['**/*.test.ts'],
|
||||
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||
plugins: {
|
||||
'@stylistic': stylistic,
|
||||
react,
|
||||
'react-hooks': reactHooks,
|
||||
'react-refresh': reactRefresh
|
||||
},
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
@ -28,18 +23,22 @@ export default tseslint.config({
|
||||
globals: {
|
||||
...globals.browser,
|
||||
...globals.nodeBuiltin,
|
||||
...globals.jest
|
||||
...globals.jest,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'@stylistic/indent': ['error', 2],
|
||||
'@stylistic/indent-binary-ops': ['error', 2],
|
||||
'@stylistic/max-len': ['error', { tabWidth: 2, "ignoreStrings": true }],
|
||||
'@stylistic/max-len': ['error', { code: 100, tabWidth: 2, ignoreStrings: true, ignoreComments: true }],
|
||||
'@stylistic/no-tabs': 'error',
|
||||
'@stylistic/quotes': ['error', 'single'],
|
||||
'@stylistic/jsx-pascal-case': [2],
|
||||
'@stylistic/jsx-indent': [2, 2, { checkAttributes: true, indentLogicalExpressions: true }],
|
||||
'@stylistic/semi': ['error', 'always'],
|
||||
'@stylistic/eol-last': ['error', 'always'],
|
||||
'@stylistic/jsx-quotes': ['error', 'prefer-double'],
|
||||
|
||||
"@typescript-eslint/ban-ts-comment": ["error", { 'ts-expect-error': 'allow-with-description' }],
|
||||
|
||||
'react/jsx-no-undef': 'error',
|
||||
'react/jsx-uses-vars': 'error',
|
||||
@ -50,7 +49,5 @@ export default tseslint.config({
|
||||
|
||||
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
|
||||
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies
|
||||
|
||||
'react-refresh/only-export-components': 'warn',
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"playground": "pnpm --filter playground dev",
|
||||
"test": "pnpm -r test",
|
||||
"build": "node ./scripts/build.js",
|
||||
"test": "vitest",
|
||||
"clean": "rimraf ./packages/*/dist",
|
||||
"clean:lib": "rimraf ./node_modules ./packages/*/node_modules",
|
||||
"lint": "eslint . --cache",
|
||||
@ -35,7 +35,6 @@
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-react": "^7.34.1",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.6",
|
||||
"globals": "^15.0.0",
|
||||
"husky": "^9.0.11",
|
||||
"less": "^4.2.0",
|
||||
|
||||
@ -11,6 +11,10 @@
|
||||
"import": "./dist/low-code-designer.js",
|
||||
"require": "./dist/low-code-designer.cjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./dist/": {
|
||||
"import": "./dist/",
|
||||
"require": "./dist/"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
|
||||
@ -50,8 +50,8 @@ function getTitle(title: string | IPublicTypeI18nData | ReactElement) {
|
||||
export class BorderContainer extends Component<{
|
||||
host: BuiltinSimulatorHost;
|
||||
}, {
|
||||
target?: INode;
|
||||
}> {
|
||||
target?: INode;
|
||||
}> {
|
||||
state = {} as any;
|
||||
|
||||
@computed get scale() {
|
||||
@ -70,7 +70,7 @@ export class BorderContainer extends Component<{
|
||||
const { host } = this.props;
|
||||
|
||||
host.designer.editor.eventBus.on('designer.dropLocation.change', (loc: DropLocation) => {
|
||||
let { target } = this.state;
|
||||
const { target } = this.state;
|
||||
if (target === loc?.target) return;
|
||||
this.setState({
|
||||
target: loc?.target,
|
||||
|
||||
@ -34,4 +34,4 @@ export class BemTools extends Component<{ host: BuiltinSimulatorHost }> {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,4 +34,4 @@ export class BemToolsManager {
|
||||
getAllBemTools() {
|
||||
return this.toolsContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1225,9 +1225,9 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
const childrenCanMove =
|
||||
onChildMoveHook && parentContainerNode && typeof onChildMoveHook === 'function'
|
||||
? onChildMoveHook(
|
||||
node!.internalToShellNode(),
|
||||
(parentContainerNode as any).internalToShellNode(),
|
||||
)
|
||||
node!.internalToShellNode(),
|
||||
(parentContainerNode as any).internalToShellNode(),
|
||||
)
|
||||
: true;
|
||||
|
||||
return canMove && childrenCanMove;
|
||||
@ -1313,9 +1313,9 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
const inst = instances
|
||||
? instances.length > 1
|
||||
? instances.find(
|
||||
(_inst) =>
|
||||
this.getClosestNodeInstance(_inst, container.id)?.instance === containerInstance,
|
||||
)
|
||||
(_inst) =>
|
||||
this.getClosestNodeInstance(_inst, container.id)?.instance === containerInstance,
|
||||
)
|
||||
: instances[0]
|
||||
: null;
|
||||
const rect = inst
|
||||
|
||||
@ -197,8 +197,8 @@ export class LiveEditing {
|
||||
|
||||
export type SpecificRule = (target: EditingTarget) =>
|
||||
| (IPublicTypeLiveTextEditingConfig & {
|
||||
propElement?: HTMLElement;
|
||||
})
|
||||
propElement?: HTMLElement;
|
||||
})
|
||||
| null;
|
||||
|
||||
export interface SaveHandler {
|
||||
|
||||
@ -81,19 +81,19 @@ export default class InstanceNodeSelector extends React.Component<IProps, IState
|
||||
|
||||
onMouseOver =
|
||||
(node: INode) =>
|
||||
(_: any, flag = true) => {
|
||||
if (node && typeof node.hover === 'function') {
|
||||
node.hover(flag);
|
||||
}
|
||||
};
|
||||
(_: any, flag = true) => {
|
||||
if (node && typeof node.hover === 'function') {
|
||||
node.hover(flag);
|
||||
}
|
||||
};
|
||||
|
||||
onMouseOut =
|
||||
(node: INode) =>
|
||||
(_: any, flag = false) => {
|
||||
if (node && typeof node.hover === 'function') {
|
||||
node.hover(flag);
|
||||
}
|
||||
};
|
||||
(_: any, flag = false) => {
|
||||
if (node && typeof node.hover === 'function') {
|
||||
node.hover(flag);
|
||||
}
|
||||
};
|
||||
|
||||
renderNodes = () => {
|
||||
const nodes = this.state.parentNodes;
|
||||
|
||||
@ -160,4 +160,4 @@ export class ComponentActions {
|
||||
getRegisteredMetadataTransducers(): IPublicTypeMetadataTransducer[] {
|
||||
return this.metadataTransducers;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -226,10 +226,10 @@ export class ComponentMeta implements IComponentMeta {
|
||||
this._title =
|
||||
typeof title === 'string'
|
||||
? {
|
||||
type: 'i18n',
|
||||
'en-US': this.componentName,
|
||||
'zh-CN': title,
|
||||
}
|
||||
type: 'i18n',
|
||||
'en-US': this.componentName,
|
||||
'zh-CN': title,
|
||||
}
|
||||
: title;
|
||||
}
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ export class GlobalContextMenuActions {
|
||||
event.preventDefault();
|
||||
|
||||
const actions: IPublicTypeContextMenuAction[] = [];
|
||||
let contextMenu: ContextMenuActions = this.contextMenuActionsMap.values().next().value;
|
||||
const contextMenu: ContextMenuActions = this.contextMenuActionsMap.values().next().value;
|
||||
this.contextMenuActionsMap.forEach((contextMenu) => {
|
||||
actions.push(...contextMenu.actions);
|
||||
});
|
||||
|
||||
@ -55,9 +55,9 @@ export interface DesignerProps {
|
||||
onDragstart?: (e: IPublicModelLocateEvent) => void;
|
||||
onDrag?: (e: IPublicModelLocateEvent) => void;
|
||||
onDragend?: (
|
||||
e: { dragObject: IPublicModelDragObject; copy: boolean },
|
||||
loc?: DropLocation,
|
||||
) => void;
|
||||
e: { dragObject: IPublicModelDragObject; copy: boolean },
|
||||
loc?: DropLocation,
|
||||
) => void;
|
||||
}
|
||||
|
||||
export class Designer {
|
||||
@ -406,8 +406,8 @@ export class Designer {
|
||||
|
||||
if (components) {
|
||||
// 合并 assets
|
||||
let assets = this.editor.get('assets') || {};
|
||||
let newAssets = mergeAssets(assets, incrementalAssets);
|
||||
const assets = this.editor.get('assets') || {};
|
||||
const newAssets = mergeAssets(assets, incrementalAssets);
|
||||
// 对于 assets 存在需要二次网络下载的过程,必须 await 等待结束之后,再进行事件触发
|
||||
await this.editor.set('assets', newAssets);
|
||||
}
|
||||
|
||||
@ -37,10 +37,10 @@ function getSettingFieldCollectorKey(
|
||||
// @ts-ignore
|
||||
export interface ISettingField
|
||||
extends ISettingPropEntry,
|
||||
Omit<
|
||||
IBaseModelSettingField<ISettingTopEntry, ISettingField, IComponentMeta, INode>,
|
||||
Omit<
|
||||
IBaseModelSettingField<ISettingTopEntry, ISettingField, IComponentMeta, INode>,
|
||||
'setValue' | 'key' | 'node'
|
||||
> {
|
||||
> {
|
||||
readonly isSettingField: true;
|
||||
|
||||
readonly isRequired: boolean;
|
||||
|
||||
@ -21,7 +21,7 @@ function generateSessionId(nodes: INode[]) {
|
||||
|
||||
export interface ISettingTopEntry
|
||||
extends ISettingEntry,
|
||||
IPublicModelSettingTopEntry<INode, ISettingField> {
|
||||
IPublicModelSettingTopEntry<INode, ISettingField> {
|
||||
readonly top: ISettingTopEntry;
|
||||
|
||||
readonly parent: ISettingTopEntry;
|
||||
|
||||
@ -11,9 +11,9 @@ function getHotterFromSetter(setter: any) {
|
||||
function getTransducerFromSetter(setter: any) {
|
||||
return (
|
||||
(setter &&
|
||||
(setter.transducer ||
|
||||
setter.Transducer ||
|
||||
(setter.type && (setter.type.transducer || setter.type.Transducer)))) ||
|
||||
(setter.transducer ||
|
||||
setter.Transducer ||
|
||||
(setter.type && (setter.type.transducer || setter.type.Transducer)))) ||
|
||||
null
|
||||
); // eslint-disable-line
|
||||
}
|
||||
|
||||
@ -46,14 +46,14 @@ import { EDITOR_EVENT } from '../types';
|
||||
|
||||
export type GetDataType<T, NodeType> = T extends undefined
|
||||
? NodeType extends {
|
||||
schema: infer R;
|
||||
}
|
||||
schema: infer R;
|
||||
}
|
||||
? R
|
||||
: any
|
||||
: T;
|
||||
|
||||
export class DocumentModel
|
||||
implements
|
||||
implements
|
||||
Omit<
|
||||
IPublicModelDocumentModel<
|
||||
ISelection,
|
||||
|
||||
@ -41,10 +41,10 @@ export class History<T = IPublicTypeNodeSchema> implements IHistory {
|
||||
private timeGap: number = 1000;
|
||||
|
||||
constructor(
|
||||
dataFn: () => T | null,
|
||||
private redoer: (data: T) => void,
|
||||
private document?: IDocumentModel,
|
||||
) {
|
||||
dataFn: () => T | null,
|
||||
private redoer: (data: T) => void,
|
||||
private document?: IDocumentModel,
|
||||
) {
|
||||
this.session = new Session(0, null, this.timeGap);
|
||||
this.records = [this.session];
|
||||
|
||||
|
||||
@ -11,10 +11,10 @@ export interface IOnChangeOptions {
|
||||
}
|
||||
|
||||
export class NodeChildren implements Omit<IPublicModelNodeChildren<INode>,
|
||||
'importSchema' |
|
||||
'exportSchema' |
|
||||
'isEmpty' |
|
||||
'notEmpty'
|
||||
'importSchema' |
|
||||
'exportSchema' |
|
||||
'isEmpty' |
|
||||
'notEmpty'
|
||||
> {
|
||||
@obx.shallow children: INode[];
|
||||
|
||||
@ -46,9 +46,9 @@ export class NodeChildren implements Omit<IPublicModelNodeChildren<INode>,
|
||||
}
|
||||
|
||||
constructor(
|
||||
readonly owner: INode,
|
||||
data: IPublicTypeNodeData | IPublicTypeNodeData[],
|
||||
) {
|
||||
readonly owner: INode,
|
||||
data: IPublicTypeNodeData | IPublicTypeNodeData[],
|
||||
) {
|
||||
makeObservable(this);
|
||||
this.children = (Array.isArray(data) ? data : [data]).filter(child => !!child).map((child) => {
|
||||
return this.owner.document?.createNode(child);
|
||||
@ -469,4 +469,4 @@ export class NodeChildren implements Omit<IPublicModelNodeChildren<INode>,
|
||||
}
|
||||
}
|
||||
|
||||
export interface INodeChildren extends NodeChildren {}
|
||||
export interface INodeChildren extends NodeChildren {}
|
||||
|
||||
@ -97,7 +97,7 @@ export interface IBaseNode extends Node {}
|
||||
* hidden
|
||||
*/
|
||||
export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
implements
|
||||
implements
|
||||
Omit<
|
||||
IBaseModelNode<
|
||||
IDocumentModel,
|
||||
@ -191,7 +191,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
}
|
||||
|
||||
@computed get title(): string | IPublicTypeI18nData | ReactElement {
|
||||
let t = this.getExtraProp('title');
|
||||
const t = this.getExtraProp('title');
|
||||
// TODO: 暂时走不到这个分支
|
||||
// if (!t && this.componentMeta.descriptor) {
|
||||
// t = this.getProp(this.componentMeta.descriptor, false);
|
||||
@ -325,17 +325,17 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
@action
|
||||
private initBuiltinProps() {
|
||||
this.props.has(getConvertedExtraKey('hidden')) ||
|
||||
this.props.add(false, getConvertedExtraKey('hidden'));
|
||||
this.props.add(false, getConvertedExtraKey('hidden'));
|
||||
this.props.has(getConvertedExtraKey('title')) ||
|
||||
this.props.add('', getConvertedExtraKey('title'));
|
||||
this.props.add('', getConvertedExtraKey('title'));
|
||||
this.props.has(getConvertedExtraKey('isLocked')) ||
|
||||
this.props.add(false, getConvertedExtraKey('isLocked'));
|
||||
this.props.add(false, getConvertedExtraKey('isLocked'));
|
||||
this.props.has(getConvertedExtraKey('condition')) ||
|
||||
this.props.add(true, getConvertedExtraKey('condition'));
|
||||
this.props.add(true, getConvertedExtraKey('condition'));
|
||||
this.props.has(getConvertedExtraKey('conditionGroup')) ||
|
||||
this.props.add('', getConvertedExtraKey('conditionGroup'));
|
||||
this.props.add('', getConvertedExtraKey('conditionGroup'));
|
||||
this.props.has(getConvertedExtraKey('loop')) ||
|
||||
this.props.add(undefined, getConvertedExtraKey('loop'));
|
||||
this.props.add(undefined, getConvertedExtraKey('loop'));
|
||||
}
|
||||
|
||||
@action
|
||||
@ -1164,7 +1164,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
const isRGLContainerNode = this.isRGLContainer;
|
||||
const isRGLNode = this.getParent()?.isRGLContainer as boolean;
|
||||
const isRGL = isRGLContainerNode || (isRGLNode && (!isContainerNode || !isEmptyNode));
|
||||
let rglNode = isRGLContainerNode ? this : isRGL ? this?.getParent() : null;
|
||||
const rglNode = isRGLContainerNode ? this : isRGL ? this?.getParent() : null;
|
||||
return { isContainerNode, isEmptyNode, isRGLContainerNode, isRGLNode, isRGL, rglNode };
|
||||
}
|
||||
|
||||
|
||||
@ -646,7 +646,7 @@ export class Prop implements IProp, IPropParent {
|
||||
}
|
||||
}
|
||||
const prop = isProp(value) ? value : new Prop(this, value, key);
|
||||
let items = this._items! || [];
|
||||
const items = this._items! || [];
|
||||
if (this.type === 'list') {
|
||||
if (!isValidArrayIndex(key)) {
|
||||
return null;
|
||||
|
||||
@ -138,13 +138,13 @@ export class Props implements Omit<IBaseModelProps<IProp>, | 'getExtraProp' | 'g
|
||||
if (this.items.length < 1) {
|
||||
return {};
|
||||
}
|
||||
let allProps = {} as any;
|
||||
const allProps = {} as any;
|
||||
let props: any = {};
|
||||
const extras: any = {};
|
||||
if (this.type === 'list') {
|
||||
props = [];
|
||||
this.items.forEach((item) => {
|
||||
let value = item.export(stage);
|
||||
const value = item.export(stage);
|
||||
let name = item.key as string;
|
||||
if (name && typeof name === 'string' && name.startsWith(EXTRA_KEY_PREFIX)) {
|
||||
name = getOriginalExtraKey(name);
|
||||
@ -159,9 +159,9 @@ export class Props implements Omit<IBaseModelProps<IProp>, | 'getExtraProp' | 'g
|
||||
});
|
||||
} else {
|
||||
this.items.forEach((item) => {
|
||||
let name = item.key as string;
|
||||
const name = item.key as string;
|
||||
if (name == null || item.isUnset() || item.isVirtual()) return;
|
||||
let value = item.export(stage);
|
||||
const value = item.export(stage);
|
||||
if (value != null) {
|
||||
allProps[name] = value;
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ function propertyNameRequiresQuotes(propertyName: string) {
|
||||
}
|
||||
|
||||
function quoteString(str: string, { doubleQuote }: any) {
|
||||
return doubleQuote ? `"${str.replace(/"/gu, '\\"')}"` : `'${str.replace(/'/gu, "\\'")}'`;
|
||||
return doubleQuote ? `"${str.replace(/"/gu, '\\"')}"` : `'${str.replace(/'/gu, '\\\'')}'`;
|
||||
}
|
||||
|
||||
export function valueToSource(
|
||||
@ -96,12 +96,12 @@ export function valueToSource(
|
||||
|
||||
const itemsStayOnTheSameLine = value.every(
|
||||
item => typeof item === 'object' &&
|
||||
item &&
|
||||
!(item instanceof Date) &&
|
||||
!(item instanceof Map) &&
|
||||
!(item instanceof RegExp) &&
|
||||
!(item instanceof Set) &&
|
||||
(Object.keys(item).length || value.length === 1),
|
||||
item &&
|
||||
!(item instanceof Date) &&
|
||||
!(item instanceof Map) &&
|
||||
!(item instanceof RegExp) &&
|
||||
!(item instanceof Set) &&
|
||||
(Object.keys(item).length || value.length === 1),
|
||||
);
|
||||
|
||||
let previousIndex: number | null = null;
|
||||
|
||||
@ -52,9 +52,9 @@ export default class PluginContext implements
|
||||
command: IPublicApiCommand;
|
||||
|
||||
constructor(
|
||||
options: IPluginContextOptions,
|
||||
contextApiAssembler: ILowCodePluginContextApiAssembler,
|
||||
) {
|
||||
options: IPluginContextOptions,
|
||||
contextApiAssembler: ILowCodePluginContextApiAssembler,
|
||||
) {
|
||||
const { pluginName = 'anonymous', meta = {} } = options;
|
||||
contextApiAssembler.assembleApis(this, pluginName, meta);
|
||||
this.pluginEvent = createModuleEventBus(pluginName, 200);
|
||||
@ -71,7 +71,7 @@ export default class PluginContext implements
|
||||
const getPreferenceValue = (
|
||||
key: string,
|
||||
defaultValue?: IPublicTypePreferenceValueType,
|
||||
): IPublicTypePreferenceValueType | undefined => {
|
||||
): IPublicTypePreferenceValueType | undefined => {
|
||||
if (!isValidPreferenceKey(key, preferenceDeclaration)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@ -16,24 +16,24 @@ import { ISimulatorHost } from '../simulator';
|
||||
export interface IProject extends Omit<IBaseApiProject<
|
||||
IDocumentModel
|
||||
>,
|
||||
'simulatorHost' |
|
||||
'importSchema' |
|
||||
'exportSchema' |
|
||||
'openDocument' |
|
||||
'getDocumentById' |
|
||||
'getCurrentDocument' |
|
||||
'addPropsTransducer' |
|
||||
'onRemoveDocument' |
|
||||
'onChangeDocument' |
|
||||
'onSimulatorHostReady' |
|
||||
'onSimulatorRendererReady' |
|
||||
'setI18n' |
|
||||
'setConfig' |
|
||||
'currentDocument' |
|
||||
'selection' |
|
||||
'documents' |
|
||||
'createDocument' |
|
||||
'getDocumentByFileName'
|
||||
'simulatorHost' |
|
||||
'importSchema' |
|
||||
'exportSchema' |
|
||||
'openDocument' |
|
||||
'getDocumentById' |
|
||||
'getCurrentDocument' |
|
||||
'addPropsTransducer' |
|
||||
'onRemoveDocument' |
|
||||
'onChangeDocument' |
|
||||
'onSimulatorHostReady' |
|
||||
'onSimulatorRendererReady' |
|
||||
'setI18n' |
|
||||
'setConfig' |
|
||||
'currentDocument' |
|
||||
'selection' |
|
||||
'documents' |
|
||||
'createDocument' |
|
||||
'getDocumentByFileName'
|
||||
> {
|
||||
|
||||
get designer(): IDesigner;
|
||||
|
||||
@ -17,4 +17,4 @@ export enum EDITOR_EVENT {
|
||||
NODE_VISIBLE_CHANGE = 'node.visible.change',
|
||||
}
|
||||
|
||||
export type Utils = typeof utils;
|
||||
export type Utils = typeof utils;
|
||||
|
||||
@ -34,7 +34,7 @@ export function normalizeTriggers(triggers: string[]) {
|
||||
/**
|
||||
* make a handler that listen all sensors:document, avoid frame lost
|
||||
*/
|
||||
export function makeEventsHandler(
|
||||
export function makeEventsHandler(
|
||||
boostEvent: MouseEvent | DragEvent,
|
||||
sensors: ISimulatorHost[],
|
||||
): (fn: (sdoc: Document) => void) => void {
|
||||
@ -53,4 +53,4 @@ export function normalizeTriggers(triggers: string[]) {
|
||||
return (handle: (sdoc: Document) => void) => {
|
||||
docs.forEach((doc) => handle(doc));
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
0
packages/editor-core/__tests__/command.spec.ts
Normal file
0
packages/editor-core/__tests__/command.spec.ts
Normal file
@ -11,6 +11,10 @@
|
||||
".": {
|
||||
"import": "./dist/low-code-editor-core.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./dist/": {
|
||||
"import": "./dist/",
|
||||
"require": "./dist/"
|
||||
}
|
||||
},
|
||||
"sideEffects": [
|
||||
|
||||
@ -115,4 +115,4 @@ export class Setters implements ISetters {
|
||||
|
||||
return createContent(setter, props);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,9 +202,9 @@ export class Editor extends EventEmitter implements IEditor {
|
||||
Array.isArray(d)
|
||||
? setArrayAssets(d, exportName, subName)
|
||||
: setAssetsComponent(d, {
|
||||
exportName,
|
||||
subName,
|
||||
});
|
||||
exportName,
|
||||
subName,
|
||||
});
|
||||
});
|
||||
}
|
||||
if ((window as any)[exportName]) {
|
||||
|
||||
@ -106,4 +106,4 @@ export const createModuleEventBus = (moduleName: string, maxListeners?: number):
|
||||
emitter.setMaxListeners(maxListeners);
|
||||
}
|
||||
return new EventBus(emitter, moduleName);
|
||||
};
|
||||
};
|
||||
|
||||
@ -75,7 +75,7 @@ const KEYCODE_MAP: KeyMap = {
|
||||
219: '[',
|
||||
220: '\\',
|
||||
221: ']',
|
||||
222: "'",
|
||||
222: '\'',
|
||||
};
|
||||
|
||||
const SHIFT_MAP: CtrlKeyMap = {
|
||||
@ -93,7 +93,7 @@ const SHIFT_MAP: CtrlKeyMap = {
|
||||
_: '-',
|
||||
'+': '=',
|
||||
':': ';',
|
||||
'"': "'",
|
||||
'"': '\'',
|
||||
'<': ',',
|
||||
'>': '.',
|
||||
'?': '/',
|
||||
|
||||
@ -61,7 +61,7 @@ class GlobalLocale {
|
||||
}
|
||||
if (!result) {
|
||||
// store 2: config from window
|
||||
let localeFromConfig: string = getConfig('locale');
|
||||
const localeFromConfig: string = getConfig('locale');
|
||||
if (localeFromConfig) {
|
||||
result = languageMap[localeFromConfig] || localeFromConfig.replace('_', '-');
|
||||
logger.debug(`getting locale from config: ${result}`);
|
||||
@ -147,6 +147,6 @@ function hasLocalStorage(obj: any): obj is WindowLocalStorage {
|
||||
return obj.localStorage;
|
||||
}
|
||||
|
||||
let globalLocale = new GlobalLocale();
|
||||
const globalLocale = new GlobalLocale();
|
||||
|
||||
export { globalLocale };
|
||||
|
||||
@ -27,4 +27,4 @@ export function wrapWithEventSwitch(fn: ListenerFunc): ListenerFunc {
|
||||
return (...args: any[]) => {
|
||||
if (isGlobalEventOn()) fn(...args);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,4 +52,4 @@ export default class Preference implements IPublicModelPreference {
|
||||
|
||||
return !(result === undefined || result === null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,4 +37,4 @@ export function HelpTip({
|
||||
<Tip direction={direction}>{help.content}</Tip>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ export class Title extends Component<IPublicTypeTitleProps> {
|
||||
}
|
||||
|
||||
renderLabel = (label: string | IPublicTypeI18nData | ReactNode) => {
|
||||
let { match, keywords } = this.props;
|
||||
const { match, keywords } = this.props;
|
||||
|
||||
if (!label) {
|
||||
return null;
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
import { defineProject } from 'vitest/config'
|
||||
|
||||
export default defineProject({
|
||||
test: {}
|
||||
})
|
||||
@ -11,6 +11,10 @@
|
||||
"import": "./dist/low-code-editor-skeleton.js",
|
||||
"require": "./dist/low-code-editor-skeleton.cjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./dist/": {
|
||||
"import": "./dist/",
|
||||
"require": "./dist/"
|
||||
}
|
||||
},
|
||||
"sideEffects": [
|
||||
|
||||
@ -139,8 +139,8 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
|
||||
const { setter } = this.field;
|
||||
let setterProps:
|
||||
| ({
|
||||
setters?: (ReactNode | string)[];
|
||||
} & Record<string, unknown>)
|
||||
setters?: (ReactNode | string)[];
|
||||
} & Record<string, unknown>)
|
||||
| IPublicTypeDynamicProps = {};
|
||||
let setterType: any;
|
||||
let initialValue: any = null;
|
||||
@ -251,8 +251,8 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
|
||||
|
||||
const value = this.value;
|
||||
|
||||
let onChangeAPI = extraProps?.onChange;
|
||||
let stageName = this.stageName;
|
||||
const onChangeAPI = extraProps?.onChange;
|
||||
const stageName = this.stageName;
|
||||
|
||||
return createField(
|
||||
{
|
||||
@ -269,47 +269,47 @@ class SettingFieldView extends Component<SettingFieldViewProps, SettingFieldView
|
||||
...extraProps,
|
||||
},
|
||||
!stageName &&
|
||||
this.setters?.createSetterContent(setterType, {
|
||||
...shallowIntl(setterProps),
|
||||
forceInline: extraProps.forceInline,
|
||||
key: field.id,
|
||||
// === injection
|
||||
prop: field.internalToShellField(), // for compatible vision
|
||||
selected: field.top?.getNode()?.internalToShellNode(),
|
||||
field: field.internalToShellField(),
|
||||
// === IO
|
||||
value, // reaction point
|
||||
initialValue,
|
||||
onChange: (value: any) => {
|
||||
this.setState({
|
||||
fromOnChange: true,
|
||||
// eslint-disable-next-line react/no-unused-state
|
||||
value,
|
||||
});
|
||||
field.setValue(value, true);
|
||||
if (onChangeAPI) onChangeAPI(value, field.internalToShellField());
|
||||
},
|
||||
onInitial: () => {
|
||||
if (initialValue == null) {
|
||||
return;
|
||||
}
|
||||
const value =
|
||||
this.setters?.createSetterContent(setterType, {
|
||||
...shallowIntl(setterProps),
|
||||
forceInline: extraProps.forceInline,
|
||||
key: field.id,
|
||||
// === injection
|
||||
prop: field.internalToShellField(), // for compatible vision
|
||||
selected: field.top?.getNode()?.internalToShellNode(),
|
||||
field: field.internalToShellField(),
|
||||
// === IO
|
||||
value, // reaction point
|
||||
initialValue,
|
||||
onChange: (value: any) => {
|
||||
this.setState({
|
||||
fromOnChange: true,
|
||||
// eslint-disable-next-line react/no-unused-state
|
||||
value,
|
||||
});
|
||||
field.setValue(value, true);
|
||||
if (onChangeAPI) onChangeAPI(value, field.internalToShellField());
|
||||
},
|
||||
onInitial: () => {
|
||||
if (initialValue == null) {
|
||||
return;
|
||||
}
|
||||
const value =
|
||||
typeof initialValue === 'function'
|
||||
? initialValue(field.internalToShellField())
|
||||
: initialValue;
|
||||
this.setState({
|
||||
// eslint-disable-next-line react/no-unused-state
|
||||
value,
|
||||
});
|
||||
field.setValue(value, true);
|
||||
},
|
||||
this.setState({
|
||||
// eslint-disable-next-line react/no-unused-state
|
||||
value,
|
||||
});
|
||||
field.setValue(value, true);
|
||||
},
|
||||
|
||||
removeProp: () => {
|
||||
if (field.name) {
|
||||
field.parent.clearPropValue(field.name);
|
||||
}
|
||||
},
|
||||
}),
|
||||
removeProp: () => {
|
||||
if (field.name) {
|
||||
field.parent.clearPropValue(field.name);
|
||||
}
|
||||
},
|
||||
}),
|
||||
extraProps.forceInline ? 'plain' : extraProps.display,
|
||||
);
|
||||
}
|
||||
|
||||
@ -104,29 +104,29 @@ export class SettingsPrimaryPane extends Component<
|
||||
l === 2
|
||||
? {}
|
||||
: {
|
||||
onMouseOver: hoverNode.bind(null, _node, true),
|
||||
onMouseOut: hoverNode.bind(null, _node, false),
|
||||
onClick: () => {
|
||||
if (!_node) {
|
||||
return;
|
||||
}
|
||||
selectNode.call(null, _node);
|
||||
const getName = (node: any) => {
|
||||
const npm = node?.componentMeta?.npm;
|
||||
return (
|
||||
[npm?.package, npm?.componentName].filter((item) => !!item).join('-') ||
|
||||
node?.componentMeta?.componentName ||
|
||||
''
|
||||
);
|
||||
};
|
||||
const selected = getName(current);
|
||||
const target = getName(_node);
|
||||
editor?.eventBus.emit('skeleton.settingsPane.Breadcrumb', {
|
||||
selected,
|
||||
target,
|
||||
});
|
||||
},
|
||||
};
|
||||
onMouseOver: hoverNode.bind(null, _node, true),
|
||||
onMouseOut: hoverNode.bind(null, _node, false),
|
||||
onClick: () => {
|
||||
if (!_node) {
|
||||
return;
|
||||
}
|
||||
selectNode.call(null, _node);
|
||||
const getName = (node: any) => {
|
||||
const npm = node?.componentMeta?.npm;
|
||||
return (
|
||||
[npm?.package, npm?.componentName].filter((item) => !!item).join('-') ||
|
||||
node?.componentMeta?.componentName ||
|
||||
''
|
||||
);
|
||||
};
|
||||
const selected = getName(current);
|
||||
const target = getName(_node);
|
||||
editor?.eventBus.emit('skeleton.settingsPane.Breadcrumb', {
|
||||
selected,
|
||||
target,
|
||||
});
|
||||
},
|
||||
};
|
||||
items.unshift(
|
||||
<Breadcrumb.Item {...props} key={node.id}>
|
||||
<Title title={node.title} />
|
||||
|
||||
@ -5,9 +5,9 @@ function getHotterFromSetter(setter: any) {
|
||||
function getTransducerFromSetter(setter: any) {
|
||||
return (
|
||||
(setter &&
|
||||
(setter.transducer ||
|
||||
setter.Transducer ||
|
||||
(setter.type && (setter.type.transducer || setter.type.Transducer)))) ||
|
||||
(setter.transducer ||
|
||||
setter.Transducer ||
|
||||
(setter.type && (setter.type.transducer || setter.type.Transducer)))) ||
|
||||
null
|
||||
); // eslint-disable-line
|
||||
}
|
||||
|
||||
@ -8,4 +8,4 @@ export function IconArrow(props: IconProps) {
|
||||
</SVGIcon>
|
||||
);
|
||||
}
|
||||
IconArrow.displayName = 'Arrow';
|
||||
IconArrow.displayName = 'Arrow';
|
||||
|
||||
@ -8,4 +8,4 @@ export function IconExit(props: IconProps) {
|
||||
</SVGIcon>
|
||||
);
|
||||
}
|
||||
IconExit.displayName = 'Exit';
|
||||
IconExit.displayName = 'Exit';
|
||||
|
||||
@ -4,4 +4,4 @@ export { default as LeftFixedPane } from './left-fixed-pane';
|
||||
export { default as MainArea } from './main-area';
|
||||
export { default as BottomArea } from './bottom-area';
|
||||
export { default as TopArea } from './top-area';
|
||||
export { default as SubTopArea } from './sub-top-area';
|
||||
export { default as SubTopArea } from './sub-top-area';
|
||||
|
||||
@ -52,7 +52,7 @@ class Contents extends Component<{ area: Area; itemClassName?: string }> {
|
||||
right.push(content);
|
||||
}
|
||||
});
|
||||
let children = [];
|
||||
const children = [];
|
||||
if (left && left.length) {
|
||||
children.push(
|
||||
<div className="lc-workspace-sub-top-area-left lc-sub-top-area-left">{left}</div>,
|
||||
|
||||
@ -47,23 +47,23 @@ export enum SkeletonEvents {
|
||||
export interface ISkeleton extends Skeleton {}
|
||||
|
||||
export class Skeleton implements Omit<IPublicApiSkeleton,
|
||||
'showPanel' |
|
||||
'hidePanel' |
|
||||
'showWidget' |
|
||||
'enableWidget' |
|
||||
'hideWidget' |
|
||||
'disableWidget' |
|
||||
'showArea' |
|
||||
'onShowPanel' |
|
||||
'onHidePanel' |
|
||||
'onShowWidget' |
|
||||
'onHideWidget' |
|
||||
'remove' |
|
||||
'hideArea' |
|
||||
'add' |
|
||||
'getAreaItems' |
|
||||
'onDisableWidget' |
|
||||
'onEnableWidget'
|
||||
'showPanel' |
|
||||
'hidePanel' |
|
||||
'showWidget' |
|
||||
'enableWidget' |
|
||||
'hideWidget' |
|
||||
'disableWidget' |
|
||||
'showArea' |
|
||||
'onShowPanel' |
|
||||
'onHidePanel' |
|
||||
'onShowWidget' |
|
||||
'onHideWidget' |
|
||||
'remove' |
|
||||
'hideArea' |
|
||||
'add' |
|
||||
'getAreaItems' |
|
||||
'onDisableWidget' |
|
||||
'onEnableWidget'
|
||||
> {
|
||||
private panels = new Map<string, Panel>();
|
||||
|
||||
@ -425,7 +425,10 @@ export class Skeleton implements Omit<IPublicApiSkeleton,
|
||||
return this.configTransducers;
|
||||
}
|
||||
|
||||
add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>): IWidget | Widget | Panel | Stage | Dock | PanelDock | undefined {
|
||||
add(
|
||||
config: IPublicTypeSkeletonConfig,
|
||||
extraConfig?: Record<string, any>
|
||||
): IWidget | Widget | Panel | Stage | Dock | PanelDock | undefined {
|
||||
const registeredTransducers = this.getRegisteredConfigTransducers();
|
||||
|
||||
const parsedConfig = registeredTransducers.reduce((prevConfig, current) => {
|
||||
|
||||
@ -221,23 +221,23 @@ export default function (
|
||||
setValue(field: IPublicModelSettingField, eventData) {
|
||||
const { eventDataList, eventList } = eventData;
|
||||
Array.isArray(eventList) &&
|
||||
eventList.map((item) => {
|
||||
field.parent.clearPropValue(item.name);
|
||||
return item;
|
||||
});
|
||||
eventList.map((item) => {
|
||||
field.parent.clearPropValue(item.name);
|
||||
return item;
|
||||
});
|
||||
Array.isArray(eventDataList) &&
|
||||
eventDataList.map((item) => {
|
||||
field.parent.setPropValue(item.name, {
|
||||
type: 'JSFunction',
|
||||
// 需要传下入参
|
||||
value: `function(){return this.${
|
||||
item.relatedEventName
|
||||
}.apply(this,Array.prototype.slice.call(arguments).concat([${
|
||||
item.paramStr ? item.paramStr : ''
|
||||
}])) }`,
|
||||
});
|
||||
return item;
|
||||
eventDataList.map((item) => {
|
||||
field.parent.setPropValue(item.name, {
|
||||
type: 'JSFunction',
|
||||
// 需要传下入参
|
||||
value: `function(){return this.${
|
||||
item.relatedEventName
|
||||
}.apply(this,Array.prototype.slice.call(arguments).concat([${
|
||||
item.paramStr ? item.paramStr : ''
|
||||
}])) }`,
|
||||
});
|
||||
return item;
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
@ -20,7 +20,7 @@ function transformStringToFunction(str: string) {
|
||||
if (leadingFnNameRe.test(str) && !leadingFnRe.test(str)) {
|
||||
str = `function ${str}`;
|
||||
}
|
||||
let fnBody = `
|
||||
const fnBody = `
|
||||
return function() {
|
||||
const self = this;
|
||||
try {
|
||||
|
||||
@ -3,4 +3,4 @@ export * from './panel';
|
||||
export * from './panel-dock';
|
||||
export * from './dock';
|
||||
export * from './widget';
|
||||
export * from './stage';
|
||||
export * from './stage';
|
||||
|
||||
@ -11,6 +11,10 @@
|
||||
"import": "./dist/ali-low-code-engine.js",
|
||||
"require": "./dist/ali-low-code-engine.cjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"./dist/": {
|
||||
"import": "./dist/",
|
||||
"require": "./dist/"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { createElement } from 'react';
|
||||
import { createRoot, type Root } from 'react-dom/client';
|
||||
import { isPlainObject } from '@alilc/lowcode-utils';
|
||||
import {
|
||||
globalContext,
|
||||
Editor,
|
||||
@ -28,16 +29,13 @@ import {
|
||||
PluginPreference,
|
||||
IDesigner,
|
||||
} from '@alilc/lowcode-designer';
|
||||
import {
|
||||
Skeleton as InnerSkeleton,
|
||||
registerDefaults,
|
||||
} from '@alilc/lowcode-editor-skeleton';
|
||||
import { Skeleton as InnerSkeleton, registerDefaults } from '@alilc/lowcode-editor-skeleton';
|
||||
|
||||
import {
|
||||
Workspace as InnerWorkspace,
|
||||
Workbench as WorkSpaceWorkbench,
|
||||
IWorkspace,
|
||||
} from './workspace';
|
||||
|
||||
import {
|
||||
Hotkey,
|
||||
Project,
|
||||
@ -54,10 +52,10 @@ import {
|
||||
CommonUI,
|
||||
Command,
|
||||
} from './shell';
|
||||
import { isPlainObject } from '@alilc/lowcode-utils';
|
||||
import './modules/live-editing';
|
||||
import * as classes from './modules/classes';
|
||||
import symbols from './modules/symbols';
|
||||
|
||||
import { componentMetaParser } from './inner-plugins/component-meta-parser';
|
||||
import { setterRegistry } from './inner-plugins/setter-registry';
|
||||
import { defaultPanelRegistry } from './inner-plugins/default-panel-registry';
|
||||
@ -66,13 +64,19 @@ import { builtinHotkey } from './inner-plugins/builtin-hotkey';
|
||||
import { defaultContextMenu } from './inner-plugins/default-context-menu';
|
||||
import { CommandPlugin } from '@alilc/lowcode-plugin-command';
|
||||
import { OutlinePlugin } from '@alilc/lowcode-plugin-outline-pane';
|
||||
import { version } from '../package.json'
|
||||
import { version } from '../package.json';
|
||||
|
||||
import '@alilc/lowcode-editor-skeleton/dist/style.css';
|
||||
|
||||
export * from './modules/skeleton-types';
|
||||
export * from './modules/designer-types';
|
||||
export * from './modules/lowcode-types';
|
||||
|
||||
async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins: IPublicApiPlugins): Promise<IPublicTypeDisposable> {
|
||||
async function registryInnerPlugin(
|
||||
designer: IDesigner,
|
||||
editor: IEditor,
|
||||
plugins: IPublicApiPlugins
|
||||
): Promise<IPublicTypeDisposable> {
|
||||
// 注册一批内置插件
|
||||
const componentMetaParserPlugin = componentMetaParser(designer);
|
||||
const defaultPanelRegistryPlugin = defaultPanelRegistry(editor);
|
||||
@ -97,9 +101,13 @@ async function registryInnerPlugin(designer: IDesigner, editor: IEditor, plugins
|
||||
};
|
||||
}
|
||||
|
||||
const innerWorkspace: IWorkspace = new InnerWorkspace(registryInnerPlugin, shellModelFactory);
|
||||
const innerWorkspace: IWorkspace = new InnerWorkspace(
|
||||
registryInnerPlugin,
|
||||
shellModelFactory
|
||||
);
|
||||
const workspace: IPublicApiWorkspace = new Workspace(innerWorkspace);
|
||||
const editor = new Editor();
|
||||
|
||||
globalContext.register(editor, Editor);
|
||||
globalContext.register(editor, 'editor');
|
||||
globalContext.register(innerWorkspace, 'workspace');
|
||||
@ -121,24 +129,30 @@ const skeleton = new Skeleton(innerSkeleton, 'any', false);
|
||||
const innerSetters = new InnerSetters();
|
||||
const setters = new Setters(innerSetters);
|
||||
const innerCommand = new InnerCommand();
|
||||
const command = new Command(innerCommand, engineContext as IPublicModelPluginContext);
|
||||
|
||||
const command = new Command(
|
||||
innerCommand,
|
||||
engineContext as IPublicModelPluginContext
|
||||
);
|
||||
const material = new Material(editor);
|
||||
const commonUI = new CommonUI(editor);
|
||||
|
||||
editor.set('project', project);
|
||||
editor.set('setters' as any, setters);
|
||||
editor.set('material', material);
|
||||
editor.set('innerHotkey', innerHotkey);
|
||||
|
||||
const config = new Config(engineConfig);
|
||||
const event = new Event(commonEvent, { prefix: 'common' });
|
||||
const logger = new Logger({ level: 'warn', bizName: 'common' });
|
||||
const common = new Common(editor, innerSkeleton);
|
||||
const canvas = new Canvas(editor);
|
||||
let plugins: Plugins;
|
||||
|
||||
const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
assembleApis: (context: ILowCodePluginContextPrivate, pluginName: string, meta: IPublicTypePluginMeta) => {
|
||||
assembleApis: (
|
||||
context: ILowCodePluginContextPrivate,
|
||||
pluginName: string,
|
||||
meta: IPublicTypePluginMeta
|
||||
) => {
|
||||
context.hotkey = hotkey;
|
||||
context.project = project;
|
||||
context.skeleton = new Skeleton(innerSkeleton, pluginName, false);
|
||||
@ -154,9 +168,10 @@ const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {
|
||||
context.logger = new Logger({ level: 'warn', bizName: `plugin:${pluginName}` });
|
||||
context.workspace = workspace;
|
||||
context.commonUI = commonUI;
|
||||
context.command = new Command(innerCommand, context as IPublicModelPluginContext, {
|
||||
commandScope,
|
||||
});
|
||||
context.command = new Command(
|
||||
innerCommand, context as IPublicModelPluginContext, {
|
||||
commandScope,
|
||||
});
|
||||
context.registerLevel = IPublicEnumPluginRegisterLevel.Default;
|
||||
context.isPluginRegisteredInWorkspace = false;
|
||||
editor.set('pluginContext', context);
|
||||
@ -164,7 +179,7 @@ const pluginContextApiAssembler: ILowCodePluginContextApiAssembler = {
|
||||
};
|
||||
|
||||
const innerPlugins = new LowCodePluginManager(pluginContextApiAssembler);
|
||||
plugins = new Plugins(innerPlugins).toProxy();
|
||||
const plugins = new Plugins(innerPlugins).toProxy();
|
||||
editor.set('innerPlugins' as any, innerPlugins);
|
||||
editor.set('plugins' as any, plugins);
|
||||
|
||||
@ -198,19 +213,25 @@ export {
|
||||
commonUI,
|
||||
command,
|
||||
};
|
||||
|
||||
|
||||
// declare this is open-source version
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export const isOpenSource = true;
|
||||
engineConfig.set('isOpenSource', isOpenSource);
|
||||
|
||||
engineConfig.set('ENGINE_VERSION', version);
|
||||
export { version };
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export const __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
||||
symbols,
|
||||
classes,
|
||||
};
|
||||
engineConfig.set('isOpenSource', isOpenSource);
|
||||
|
||||
// container which will host LowCodeEngine DOM
|
||||
let engineContainer: HTMLElement;
|
||||
|
||||
export { version }
|
||||
engineConfig.set('ENGINE_VERSION', version);
|
||||
|
||||
const pluginPromise = registryInnerPlugin(designer, editor, plugins);
|
||||
|
||||
@ -219,10 +240,14 @@ let root: Root | undefined;
|
||||
export async function init(
|
||||
container?: HTMLElement,
|
||||
options?: IPublicTypeEngineOptions,
|
||||
pluginPreference?: PluginPreference,
|
||||
) {
|
||||
pluginPreference?: PluginPreference
|
||||
) {
|
||||
await destroy();
|
||||
|
||||
// container which will host LowCodeEngine DOM
|
||||
let engineContainer: HTMLElement;
|
||||
let engineOptions = null;
|
||||
|
||||
if (isPlainObject(container)) {
|
||||
engineOptions = container;
|
||||
engineContainer = document.createElement('div');
|
||||
@ -237,6 +262,7 @@ export async function init(
|
||||
document.body.appendChild(engineContainer);
|
||||
}
|
||||
}
|
||||
|
||||
engineConfig.setEngineOptions(engineOptions as any);
|
||||
|
||||
const { Workbench } = common.skeletonCabin;
|
||||
@ -245,15 +271,15 @@ export async function init(
|
||||
disposeFun && disposeFun();
|
||||
|
||||
if (!root) {
|
||||
root = createRoot(
|
||||
engineContainer,
|
||||
root = createRoot(engineContainer);
|
||||
root.render(
|
||||
createElement(WorkSpaceWorkbench, {
|
||||
workspace: innerWorkspace,
|
||||
// skeleton: workspace.skeleton,
|
||||
className: 'engine-main',
|
||||
topAreaItemClassName: 'engine-actionitem',
|
||||
})
|
||||
);
|
||||
root.render(createElement(WorkSpaceWorkbench, {
|
||||
workspace: innerWorkspace,
|
||||
// skeleton: workspace.skeleton,
|
||||
className: 'engine-main',
|
||||
topAreaItemClassName: 'engine-actionitem',
|
||||
}))
|
||||
}
|
||||
|
||||
innerWorkspace.enableAutoOpenFirstWindow = engineConfig.get('enableAutoOpenFirstWindow', true);
|
||||
@ -267,12 +293,14 @@ export async function init(
|
||||
await plugins.init(pluginPreference as any);
|
||||
|
||||
if (!root) {
|
||||
root = createRoot(engineContainer)
|
||||
root.render(createElement(Workbench, {
|
||||
skeleton: innerSkeleton,
|
||||
className: 'engine-main',
|
||||
topAreaItemClassName: 'engine-actionitem',
|
||||
}))
|
||||
root = createRoot(engineContainer);
|
||||
root.render(
|
||||
createElement(Workbench, {
|
||||
skeleton: innerSkeleton,
|
||||
className: 'engine-main',
|
||||
topAreaItemClassName: 'engine-actionitem',
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -280,7 +308,9 @@ export async function destroy() {
|
||||
// remove all documents
|
||||
const { documents } = project;
|
||||
if (Array.isArray(documents) && documents.length > 0) {
|
||||
documents.forEach(((doc: IPublicModelDocumentModel) => project.removeDocument(doc)));
|
||||
documents.forEach(
|
||||
(doc: IPublicModelDocumentModel) => project.removeDocument(doc)
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: delete plugins except for core plugins
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { version } from './engine-core';
|
||||
|
||||
export * from './engine-core';
|
||||
|
||||
console.log(
|
||||
`%c AliLowCodeEngine %c v${version} `,
|
||||
'padding: 2px 1px; border-radius: 3px 0 0 3px; color: #fff; background: #606060; font-weight: bold;',
|
||||
|
||||
@ -328,7 +328,7 @@ export const builtinHotkey = (ctx: IPublicModelPluginContext) => {
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
let canAddComponentsTree = componentsTree.filter((node: IPublicModelNode) => {
|
||||
const canAddComponentsTree = componentsTree.filter((node: IPublicModelNode) => {
|
||||
const dragNodeObject: IPublicTypeDragNodeObject = {
|
||||
type: IPublicEnumDragObjectType.Node,
|
||||
nodes: [node],
|
||||
|
||||
@ -129,7 +129,7 @@ export const defaultContextMenu = (ctx: IPublicModelPluginContext) => {
|
||||
return;
|
||||
}
|
||||
if (parent) {
|
||||
let canAddNodes = nodeSchema.filter((nodeSchema: IPublicTypeNodeSchema) => {
|
||||
const canAddNodes = nodeSchema.filter((nodeSchema: IPublicTypeNodeSchema) => {
|
||||
const dragNodeObject: IPublicTypeDragNodeDataObject = {
|
||||
type: IPublicEnumDragObjectType.NodeData,
|
||||
data: nodeSchema,
|
||||
@ -177,7 +177,7 @@ export const defaultContextMenu = (ctx: IPublicModelPluginContext) => {
|
||||
if (nodeSchema.length === 0) {
|
||||
return;
|
||||
}
|
||||
let canAddNodes = nodeSchema.filter((nodeSchema: IPublicTypeNodeSchema) => {
|
||||
const canAddNodes = nodeSchema.filter((nodeSchema: IPublicTypeNodeSchema) => {
|
||||
const dragNodeObject: IPublicTypeDragNodeDataObject = {
|
||||
type: IPublicEnumDragObjectType.NodeData,
|
||||
data: nodeSchema,
|
||||
|
||||
@ -6,11 +6,13 @@ export const setterRegistry = (ctx: IPublicModelPluginContext) => {
|
||||
init() {
|
||||
const { config } = ctx;
|
||||
if (config.get('disableDefaultSetters')) return;
|
||||
// todo: 互相依赖
|
||||
|
||||
// const builtinSetters = require('@alilc/lowcode-engine-ext')?.setters;
|
||||
// if (builtinSetters) {
|
||||
// ctx.setters.registerSetter(builtinSetters);
|
||||
// }
|
||||
// @ts-expect-error: todo remove
|
||||
const builtinSetters = window.AliLowCodeEngineExt?.setters;
|
||||
if (builtinSetters) {
|
||||
ctx.setters.registerSetter(builtinSetters);
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
2
packages/engine/src/module.d.ts
vendored
2
packages/engine/src/module.d.ts
vendored
@ -1 +1 @@
|
||||
declare module 'ric-shim';
|
||||
declare module 'ric-shim';
|
||||
|
||||
@ -13,4 +13,3 @@ export {
|
||||
SkeletonItem,
|
||||
} from '../shell';
|
||||
export { Node as InnerNode } from '@alilc/lowcode-designer';
|
||||
|
||||
|
||||
@ -8,4 +8,4 @@ export type SaveHandler = designerCabin.SaveHandler;
|
||||
export type ComponentMeta = designerCabin.ComponentMeta;
|
||||
export type SettingField = designerCabin.SettingField;
|
||||
export type ILowCodePluginManager = designerCabin.ILowCodePluginManager;
|
||||
export type PluginPreference = designerCabin.PluginPreference;
|
||||
export type PluginPreference = designerCabin.PluginPreference;
|
||||
|
||||
@ -1 +1 @@
|
||||
export type { IPublicTypeNodeSchema } from '@alilc/lowcode-types';
|
||||
export type { IPublicTypeNodeSchema } from '@alilc/lowcode-types';
|
||||
|
||||
@ -18,4 +18,4 @@ class ShellModelFactory implements IShellModelFactory {
|
||||
}
|
||||
}
|
||||
|
||||
export const shellModelFactory = new ShellModelFactory();
|
||||
export const shellModelFactory = new ShellModelFactory();
|
||||
|
||||
@ -465,4 +465,4 @@ export class Common implements IPublicApiCommon {
|
||||
TransformStage: InnerTransitionStage,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,13 +26,6 @@ export class Hotkey implements IPublicApiHotkey {
|
||||
return this[hotkeySymbol].callBacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
get callBacks() {
|
||||
return this.callbacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定快捷键
|
||||
* @param combos 快捷键,格式如:['command + s'] 、['ctrl + shift + s'] 等
|
||||
@ -41,10 +34,10 @@ export class Hotkey implements IPublicApiHotkey {
|
||||
* @returns
|
||||
*/
|
||||
bind(
|
||||
combos: string[] | string,
|
||||
callback: IPublicTypeHotkeyCallback,
|
||||
action?: string,
|
||||
): IPublicTypeDisposable {
|
||||
combos: string[] | string,
|
||||
callback: IPublicTypeHotkeyCallback,
|
||||
action?: string,
|
||||
): IPublicTypeDisposable {
|
||||
this[hotkeySymbol].bind(combos, callback, action);
|
||||
return () => {
|
||||
this[hotkeySymbol].unbind(combos, callback, action);
|
||||
@ -58,4 +51,4 @@ export class Hotkey implements IPublicApiHotkey {
|
||||
mount(window: Window) {
|
||||
return this[hotkeySymbol].mount(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,4 +45,4 @@ export class Logger implements IPublicApiLogger {
|
||||
log(...args: any | any[]): void {
|
||||
this[innerLoggerSymbol].log(...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ export class Material implements IPublicApiMaterial {
|
||||
getComponentMetasMap(): Map<string, IPublicModelComponentMeta> {
|
||||
const map = new Map<string, IPublicModelComponentMeta>();
|
||||
const originalMap = this[designerSymbol].getComponentMetasMap();
|
||||
for (let componentName of originalMap.keys()) {
|
||||
for (const componentName of originalMap.keys()) {
|
||||
map.set(componentName, this.getComponentMeta(componentName)!);
|
||||
}
|
||||
return map;
|
||||
|
||||
@ -44,8 +44,8 @@ export class Plugins implements IPublicApiPlugins {
|
||||
}
|
||||
|
||||
getPluginPreference(
|
||||
pluginName: string,
|
||||
): Record<string, IPublicTypePreferenceValueType> | null | undefined {
|
||||
pluginName: string,
|
||||
): Record<string, IPublicTypePreferenceValueType> | null | undefined {
|
||||
return this[pluginsSymbol].getPluginPreference(pluginName);
|
||||
}
|
||||
|
||||
|
||||
@ -164,9 +164,9 @@ export class Project implements IPublicApiProject {
|
||||
* @param stage
|
||||
*/
|
||||
addPropsTransducer(
|
||||
transducer: IPublicTypePropsTransducer,
|
||||
stage: IPublicEnumTransformStage,
|
||||
): void {
|
||||
transducer: IPublicTypePropsTransducer,
|
||||
stage: IPublicEnumTransformStage,
|
||||
): void {
|
||||
this[projectSymbol].designer.addPropsReducer(transducer, stage);
|
||||
}
|
||||
|
||||
@ -177,9 +177,9 @@ export class Project implements IPublicApiProject {
|
||||
*/
|
||||
onRemoveDocument(fn: (data: { id: string}) => void): IPublicTypeDisposable {
|
||||
return this[editorSymbol].eventBus.on(
|
||||
'designer.document.remove',
|
||||
(data: { id: string }) => fn(data),
|
||||
);
|
||||
'designer.document.remove',
|
||||
(data: { id: string }) => fn(data),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -33,10 +33,10 @@ export class Skeleton implements IPublicApiSkeleton {
|
||||
}
|
||||
|
||||
constructor(
|
||||
skeleton: ISkeleton,
|
||||
pluginName: string,
|
||||
readonly workspaceMode: boolean = false,
|
||||
) {
|
||||
skeleton: ISkeleton,
|
||||
pluginName: string,
|
||||
readonly workspaceMode: boolean = false,
|
||||
) {
|
||||
this[innerSkeletonSymbol] = skeleton;
|
||||
this.pluginName = pluginName;
|
||||
}
|
||||
|
||||
@ -69,4 +69,4 @@ ContextMenu.create = (pluginContext: IPublicModelPluginContext, menus: IPublicTy
|
||||
return createContextMenu(children, {
|
||||
event,
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@ -47,4 +47,4 @@ export class ActiveTracker implements IPublicModelActiveTracker {
|
||||
track(node: IPublicModelNode) {
|
||||
this[activeTrackerSymbol].track((node as any)[nodeSymbol]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,9 +14,9 @@ export class Clipboard implements IPublicModelClipboard {
|
||||
}
|
||||
|
||||
waitPasteData(
|
||||
keyboardEvent: KeyboardEvent,
|
||||
cb: (data: any, clipboardEvent: ClipboardEvent) => void,
|
||||
): void {
|
||||
keyboardEvent: KeyboardEvent,
|
||||
cb: (data: any, clipboardEvent: ClipboardEvent) => void,
|
||||
): void {
|
||||
this[clipboardSymbol].waitPasteData(keyboardEvent, cb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,14 +130,14 @@ export class ComponentMeta implements IPublicModelComponentMeta {
|
||||
* @returns
|
||||
*/
|
||||
checkNestingDown(
|
||||
my: IPublicModelNode | IPublicTypeNodeData,
|
||||
target: IPublicTypeNodeSchema | IPublicModelNode | IPublicTypeNodeSchema[],
|
||||
) {
|
||||
my: IPublicModelNode | IPublicTypeNodeData,
|
||||
target: IPublicTypeNodeSchema | IPublicModelNode | IPublicTypeNodeSchema[],
|
||||
) {
|
||||
const curNode = (my as any)?.isNode ? (my as any)[nodeSymbol] : my;
|
||||
return this[componentMetaSymbol].checkNestingDown(
|
||||
curNode as any,
|
||||
(target as any)[nodeSymbol] || target,
|
||||
);
|
||||
curNode as any,
|
||||
(target as any)[nodeSymbol] || target,
|
||||
);
|
||||
}
|
||||
|
||||
refreshMetadata(): void {
|
||||
|
||||
@ -60,4 +60,4 @@ export class Detecting implements IPublicModelDetecting {
|
||||
};
|
||||
return this[detectingSymbol].onDetectingChange(innerFn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,8 +111,8 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
this._focusNode = node;
|
||||
this[editorSymbol].eventBus.emit(
|
||||
'shell.document.focusNodeChanged',
|
||||
{ document: this, focusNode: node },
|
||||
);
|
||||
{ document: this, focusNode: node },
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,7 +121,7 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
*/
|
||||
get nodesMap(): Map<string, IPublicModelNode> {
|
||||
const map = new Map<string, IPublicModelNode>();
|
||||
for (let id of this[documentSymbol].nodesMap.keys()) {
|
||||
for (const id of this[documentSymbol].nodesMap.keys()) {
|
||||
map.set(id, this.getNodeById(id)!);
|
||||
}
|
||||
return map;
|
||||
@ -227,14 +227,14 @@ export class DocumentModel implements IPublicModelDocumentModel {
|
||||
* @returns boolean 是否可以放置
|
||||
*/
|
||||
checkNesting(
|
||||
dropTarget: IPublicModelNode,
|
||||
dragObject: IPublicTypeDragNodeObject | IPublicTypeDragNodeDataObject,
|
||||
): boolean {
|
||||
let innerDragObject = dragObject;
|
||||
dropTarget: IPublicModelNode,
|
||||
dragObject: IPublicTypeDragNodeObject | IPublicTypeDragNodeDataObject,
|
||||
): boolean {
|
||||
const innerDragObject = dragObject;
|
||||
if (isDragNodeObject(dragObject)) {
|
||||
innerDragObject.nodes = innerDragObject.nodes?.map(
|
||||
(node: IPublicModelNode) => ((node as any)[nodeSymbol] || node),
|
||||
);
|
||||
(node: IPublicModelNode) => ((node as any)[nodeSymbol] || node),
|
||||
);
|
||||
}
|
||||
return this[documentSymbol].checkNesting(
|
||||
((dropTarget as any)[nodeSymbol] || dropTarget) as any,
|
||||
|
||||
@ -31,4 +31,4 @@ export class DragObject implements IPublicModelDragObject {
|
||||
get data(): IPublicTypeNodeSchema | IPublicTypeNodeSchema[] {
|
||||
return (this[dragObjectSymbol] as IPublicTypeDragNodeDataObject).data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,9 +41,9 @@ export class Dragon implements IPublicModelDragon {
|
||||
}
|
||||
|
||||
static create(
|
||||
dragon: IDragon | null,
|
||||
workspaceMode: boolean,
|
||||
): IPublicModelDragon | null {
|
||||
dragon: IDragon | null,
|
||||
workspaceMode: boolean,
|
||||
): IPublicModelDragon | null {
|
||||
if (!dragon) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -48,4 +48,4 @@ export default class LocateEvent implements IPublicModelLocateEvent {
|
||||
get dragObject(): IPublicModelDragObject | null {
|
||||
return DragObject.create(this[locateEventSymbol].dragObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ export class ModalNodesManager implements IPublicModelModalNodesManager {
|
||||
* 设置指定节点为不可见态
|
||||
* @param node Node
|
||||
*/
|
||||
setInvisible(node: IPublicModelNode): void {
|
||||
setInvisible(node: IPublicModelNode): void {
|
||||
this[modalNodesManagerSymbol].setInvisible((node as any)[nodeSymbol]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,9 +518,9 @@ export class Node implements IPublicModelNode {
|
||||
* @returns
|
||||
*/
|
||||
exportSchema(
|
||||
stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Render,
|
||||
options?: any,
|
||||
): IPublicTypeNodeSchema {
|
||||
stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Render,
|
||||
options?: any,
|
||||
): IPublicTypeNodeSchema {
|
||||
return this[nodeSymbol].export(stage, options);
|
||||
}
|
||||
|
||||
@ -531,15 +531,15 @@ export class Node implements IPublicModelNode {
|
||||
* @param useMutator
|
||||
*/
|
||||
insertBefore(
|
||||
node: IPublicModelNode,
|
||||
ref?: IPublicModelNode | undefined,
|
||||
useMutator?: boolean,
|
||||
): void {
|
||||
node: IPublicModelNode,
|
||||
ref?: IPublicModelNode | undefined,
|
||||
useMutator?: boolean,
|
||||
): void {
|
||||
this[nodeSymbol].insertBefore(
|
||||
(node as any)[nodeSymbol] || node,
|
||||
(ref as any)?.[nodeSymbol],
|
||||
useMutator,
|
||||
);
|
||||
(node as any)[nodeSymbol] || node,
|
||||
(ref as any)?.[nodeSymbol],
|
||||
useMutator,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -549,15 +549,15 @@ export class Node implements IPublicModelNode {
|
||||
* @param useMutator
|
||||
*/
|
||||
insertAfter(
|
||||
node: IPublicModelNode,
|
||||
ref?: IPublicModelNode | undefined,
|
||||
useMutator?: boolean,
|
||||
): void {
|
||||
node: IPublicModelNode,
|
||||
ref?: IPublicModelNode | undefined,
|
||||
useMutator?: boolean,
|
||||
): void {
|
||||
this[nodeSymbol].insertAfter(
|
||||
(node as any)[nodeSymbol] || node,
|
||||
(ref as any)?.[nodeSymbol],
|
||||
useMutator,
|
||||
);
|
||||
(node as any)[nodeSymbol] || node,
|
||||
(ref as any)?.[nodeSymbol],
|
||||
useMutator,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -91,4 +91,4 @@ export class Prop implements IPublicModelProp {
|
||||
exportSchema(stage: IPublicEnumTransformStage = IPublicEnumTransformStage.Render) {
|
||||
return this[propSymbol].export(stage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,4 +115,4 @@ export class Props implements IPublicModelProps {
|
||||
add(value: IPublicTypeCompositeValue, key?: string | number | undefined): any {
|
||||
return this[propsSymbol].add(value, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,4 +52,4 @@ export class Resource implements IPublicModelResource {
|
||||
get viewName() {
|
||||
return this[resourceSymbol].viewName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,4 +59,4 @@ export class SettingTopEntry implements IPublicModelSettingTopEntry {
|
||||
clearPropValue(propName: string | number) {
|
||||
this[settingTopEntrySymbol].clearPropValue(propName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,4 +20,4 @@ export class SimulatorRender implements IPublicModelSimulatorRender {
|
||||
rerender() {
|
||||
return this[simulatorRenderSymbol].rerender();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,4 +36,4 @@ export class SkeletonItem implements IPublicModelSkeletonItem {
|
||||
toggle() {
|
||||
this[skeletonItemSymbol].toggle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -40,4 +40,4 @@ export const conditionGroupSymbol = Symbol('conditionGroup');
|
||||
export const editorViewSymbol = Symbol('editorView');
|
||||
export const pluginContextSymbol = Symbol('pluginContext');
|
||||
export const skeletonItemSymbol = Symbol('skeletonItem');
|
||||
export const commandSymbol = Symbol('command');
|
||||
export const commandSymbol = Symbol('command');
|
||||
|
||||
@ -56,7 +56,7 @@ import { IEditorWindow } from '../window';
|
||||
export interface IBasicContext extends BasicContext {}
|
||||
|
||||
export class BasicContext
|
||||
implements
|
||||
implements
|
||||
Omit<
|
||||
IPublicModelPluginContext,
|
||||
'workspace' | 'commonUI' | 'command' | 'isPluginRegisteredInWorkspace' | 'editorWindow'
|
||||
|
||||
@ -15,9 +15,9 @@ export class Workbench extends Component<{
|
||||
className?: string;
|
||||
topAreaItemClassName?: string;
|
||||
}, {
|
||||
workspaceEmptyComponent: any;
|
||||
theme?: string;
|
||||
}> {
|
||||
workspaceEmptyComponent: any;
|
||||
theme?: string;
|
||||
}> {
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
const { config, components, workspace } = this.props;
|
||||
|
||||
@ -13,4 +13,4 @@ export class ResourceType implements Omit<IPublicTypeResourceType, 'resourceName
|
||||
get type() {
|
||||
return this.resourceTypeModel.resourceType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -106,4 +106,4 @@ export class Resource implements IBaseModelResource<IResource> {
|
||||
getEditorView(name: string) {
|
||||
return this.editorViewMap.get(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,4 +33,4 @@ export class ResourceView extends PureComponent<{
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,4 +36,4 @@ export class WindowView extends PureComponent<{
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -234,4 +234,4 @@ export class EditorWindow implements Omit<IPublicModelWindow<IResource>, 'change
|
||||
get innerPlugins() {
|
||||
return this.editorView?.innerPlugins;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -333,4 +333,4 @@ export class Workspace implements Omit<IPublicApiWorkspace<
|
||||
}
|
||||
}
|
||||
|
||||
export interface IWorkspace extends Workspace {}
|
||||
export interface IWorkspace extends Workspace {}
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
import { defineConfig } from 'vitest/config'
|
||||
import { defineProject } from 'vitest/config'
|
||||
|
||||
export default defineConfig({
|
||||
test: {
|
||||
include: ['tests/*.spec.ts'],
|
||||
environment: 'jsdom'
|
||||
}
|
||||
export default defineProject({
|
||||
test: {}
|
||||
})
|
||||
|
||||
@ -22,4 +22,4 @@ CommandPlugin.meta = {
|
||||
commandScope: 'common',
|
||||
};
|
||||
|
||||
export default CommandPlugin;
|
||||
export default CommandPlugin;
|
||||
|
||||
@ -195,7 +195,7 @@ export class PaneController implements IPublicModelSensor, ITreeBoard, IPublicTy
|
||||
if (
|
||||
originLoc &&
|
||||
((pos && pos === 'unchanged') ||
|
||||
(irect && globalY >= irect.top && globalY <= irect.bottom)) &&
|
||||
(irect && globalY >= irect.top && globalY <= irect.bottom)) &&
|
||||
dragObject
|
||||
) {
|
||||
const loc = originLoc.clone(e);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user