Skip to content

Commit

Permalink
fix: 修复自由布局错误和不能拖拽的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
光弘 committed Oct 12, 2023
1 parent 42ee2b9 commit a4c7576
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions lowcode/metas/fixed-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const config: IPublicTypeComponentMetadata = {
style: true,
loop: false,
},
advanced: {}
},
icon: 'https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_table.png',
snippets: [],
Expand Down
1 change: 1 addition & 0 deletions lowcode/metas/fixed-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const config: IPublicTypeComponentMetadata = {
style: true,
loop: false,
},
advanced: {}
},
experimental: {
callbacks: {},
Expand Down
14 changes: 7 additions & 7 deletions lowcode/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ const FixedContainerView = (props: IFixedContainerViewProps) => {
const { _leaf, children, items = [], ...others } = props;

// hack engine for mousedown
if (_leaf.parent) {
_leaf.parent.isRGLContainer = true;
if (_leaf?.parent) {
_leaf.parent.isRGLContainerNode = true;
}

// const enableMouseEventPropagationInCanvas = useRef();
Expand All @@ -389,22 +389,22 @@ const FixedContainerView = (props: IFixedContainerViewProps) => {
movehook.current =
_leaf?.componentMeta?.getMetadata().configure.advanced?.callbacks?.onMoveHook;
// TODO: 不一定能设置上
if (_leaf.componentMeta?.getMetadata()?.configure.advanced?.callbacks?.onMoveHook) {
if (_leaf?.componentMeta?.getMetadata()?.configure.advanced?.callbacks?.onMoveHook) {
_leaf.componentMeta.getMetadata().configure.advanced!.callbacks!.onMoveHook = () => false;
}
setDraging(true);
};
const onDragEnd = (uiData: DraggableData, idx: number) => {
// window.parent.AliLowCodeEngine.editorCabin.engineConfig.config.enableMouseEventPropagationInCanvas = enableMouseEventPropagationInCanvas.current;
// // TODO: 不一定能设置上
if (_leaf.componentMeta?.getMetadata()?.configure.advanced?.callbacks?.onMoveHook) {
if (_leaf?.componentMeta?.getMetadata()?.configure.advanced?.callbacks?.onMoveHook) {
_leaf.componentMeta.getMetadata().configure.advanced!.callbacks!.onMoveHook =
movehook.current;
}

// 有节点增加
const newItems = [..._leaf.schema.children].map((child, index) => {
const item = items.find((i) => i.primaryKey === child.id) || {
const newItems = (_leaf?.schema.children ? Array.isArray(_leaf?.schema.children) ? _leaf?.schema.children : [_leaf?.schema.children] : []).map((child, index) => {
const item = items.find((i: any) => i.primaryKey === child.id) || {
primaryKey: child.id,
top: 0,
left: 0,
Expand All @@ -419,7 +419,7 @@ const FixedContainerView = (props: IFixedContainerViewProps) => {
return item;
});

_leaf.setPropValue('items', newItems);
_leaf?.setPropValue('items', newItems);
setDraging(false);
};

Expand Down
3 changes: 3 additions & 0 deletions src/cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ const Cell: ForwardRefRenderFunction<HTMLDivElement, CellProps> = (props, ref) =
// 父级元素处理 autoFit 的相关布局
autoFit,
gap,
__designMode,
componentId,
_componentName,
...others
} = props;
const { prefix } = useContext<LayoutContextProps>(Context);
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export interface CellProps extends BaseProps {
* 孩子节点
*/
children?: ReactNode;
[prop: string]: any;
}

/**
Expand Down

0 comments on commit a4c7576

Please sign in to comment.