mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-11 18:42:56 +00:00
fix: change autorun params to IPublicModelSettingField
This commit is contained in:
parent
aafd57cae2
commit
4f7a0b984c
@ -17,6 +17,8 @@ const jestConfig = {
|
||||
// testMatch: ['(/tests?/.*(test))\\.[jt]s$'],
|
||||
// testMatch: ['**/document/node/node.add.test.ts'],
|
||||
// testMatch: ['**/setting-field.test.ts'],
|
||||
// testMatch: ['**/node.test.ts'],
|
||||
// testMatch: ['**/builtin-hotkey.test.ts'],
|
||||
transformIgnorePatterns: [
|
||||
`/node_modules/(?!${esModules})/`,
|
||||
],
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import { isValidElement } from 'react';
|
||||
import { IPublicTypeFieldConfig, IPublicTypeSetterConfig } from '@alilc/lowcode-types';
|
||||
import { isSetterConfig, isDynamicSetter } from '@alilc/lowcode-utils';
|
||||
import { SettingField } from './setting-field';
|
||||
import { ISettingField } from './setting-field';
|
||||
|
||||
function getHotterFromSetter(setter) {
|
||||
return setter && (setter.Hotter || (setter.type && setter.type.Hotter)) || []; // eslint-disable-line
|
||||
@ -35,7 +35,7 @@ export class Transducer {
|
||||
|
||||
context: any;
|
||||
|
||||
constructor(context: SettingField, config: { setter: IPublicTypeFieldConfig['setter'] }) {
|
||||
constructor(context: ISettingField, config: { setter: IPublicTypeFieldConfig['setter'] }) {
|
||||
let { setter } = config;
|
||||
|
||||
// 1. validElement
|
||||
|
||||
@ -30,7 +30,6 @@ import type { IExclusiveGroup } from './exclusive-group';
|
||||
import { includeSlot, removeSlot } from '../../utils/slot';
|
||||
import { foreachReverse } from '../../utils/tree';
|
||||
import { NodeRemoveOptions, EDITOR_EVENT } from '../../types';
|
||||
import { Prop as ShellProp } from '@alilc/lowcode-shell';
|
||||
|
||||
export interface NodeStatus {
|
||||
locking: boolean;
|
||||
@ -432,7 +431,7 @@ export class Node<Schema extends IPublicTypeNodeSchema = IPublicTypeNodeSchema>
|
||||
}
|
||||
this.autoruns = autoruns.map((item) => {
|
||||
return autorun(() => {
|
||||
item.autorun(ShellProp.create(this.props.get(item.name, true))!);
|
||||
item.autorun(this.props.getNode().settingEntry.get(item.name)?.internalToShellField());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,8 +1,13 @@
|
||||
// @ts-nocheck
|
||||
import '../../fixtures/window';
|
||||
import { set } from '../../utils';
|
||||
import { Editor } from '@alilc/lowcode-editor-core';
|
||||
import {
|
||||
Editor,
|
||||
globalContext,
|
||||
Setters as InnerSetters,
|
||||
} from '@alilc/lowcode-editor-core';
|
||||
import { Project } from '../../../src/project/project';
|
||||
import { Workspace as InnerWorkspace } from '@alilc/lowcode-workspace';
|
||||
import { DocumentModel } from '../../../src/document/document-model';
|
||||
import {
|
||||
isRootNode,
|
||||
@ -23,6 +28,7 @@ import rootContentMetadata from '../../fixtures/component-metadata/root-content'
|
||||
import rootFooterMetadata from '../../fixtures/component-metadata/root-footer';
|
||||
import { shellModelFactory } from '../../../../engine/src/modules/shell-model-factory';
|
||||
import { isNode } from '@alilc/lowcode-utils';
|
||||
import { Setters } from '@alilc/lowcode-shell';
|
||||
|
||||
describe('Node 方法测试', () => {
|
||||
let editor: Editor;
|
||||
@ -35,6 +41,9 @@ describe('Node 方法测试', () => {
|
||||
designer = new Designer({ editor, shellModelFactory });
|
||||
project = designer.project;
|
||||
doc = new DocumentModel(project, formSchema);
|
||||
editor.set('setters', new Setters(new InnerSetters()));
|
||||
!globalContext.has(Editor) && globalContext.register(editor, Editor);
|
||||
!globalContext.has('workspace') && globalContext.register(new InnerWorkspace(), 'workspace');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@ -176,10 +176,9 @@ function getSuitablePlaceForNode(targetNode: IPublicModelNode, node: IPublicMode
|
||||
if (node?.componentMeta?.isModal) {
|
||||
return { container: focusNode, ref };
|
||||
}
|
||||
const canDropInFn = document.checkNesting;
|
||||
|
||||
if (!ref && focusNode && targetNode.contains(focusNode)) {
|
||||
if (canDropInFn(focusNode, dragNodeObject)) {
|
||||
if (document.checkNesting(focusNode, dragNodeObject)) {
|
||||
return { container: focusNode };
|
||||
}
|
||||
|
||||
@ -191,7 +190,7 @@ function getSuitablePlaceForNode(targetNode: IPublicModelNode, node: IPublicMode
|
||||
if (!c.isContainerNode) {
|
||||
return false;
|
||||
}
|
||||
if (canDropInFn(c, dragNodeObject)) {
|
||||
if (document.checkNesting(c, dragNodeObject)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -201,7 +200,7 @@ function getSuitablePlaceForNode(targetNode: IPublicModelNode, node: IPublicMode
|
||||
return { container: dropElement, ref };
|
||||
}
|
||||
|
||||
if (canDropInFn(targetNode, dragNodeObject)) {
|
||||
if (document.checkNesting(targetNode, dragNodeObject)) {
|
||||
return { container: targetNode, ref };
|
||||
}
|
||||
|
||||
@ -209,7 +208,7 @@ function getSuitablePlaceForNode(targetNode: IPublicModelNode, node: IPublicMode
|
||||
}
|
||||
|
||||
if (targetNode.isContainerNode) {
|
||||
if (canDropInFn(targetNode, dragNodeObject)) {
|
||||
if (document.checkNesting(targetNode, dragNodeObject)) {
|
||||
return { container: targetNode, ref };
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { MouseEvent } from 'react';
|
||||
import { IPublicTypePropType, IPublicTypeComponentAction } from './';
|
||||
import { IPublicModelNode, IPublicModelProp, IPublicModelSettingField } from '../model';
|
||||
import { IPublicModelNode, IPublicModelSettingField } from '../model';
|
||||
|
||||
/**
|
||||
* 嵌套控制函数
|
||||
@ -102,7 +102,7 @@ export interface IPublicTypeFilterItem {
|
||||
}
|
||||
export interface IPublicTypeAutorunItem {
|
||||
name: string;
|
||||
autorun: (prop: IPublicModelProp) => any;
|
||||
autorun: (target: IPublicModelSettingField | null) => any;
|
||||
}
|
||||
|
||||
// thinkof Array
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user