mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
chore: fix conflicts
This commit is contained in:
parent
22aa77610a
commit
b4dbbdbe02
@ -11,6 +11,7 @@ import {
|
||||
import { ISimulatorHost } from '../../simulator';
|
||||
import { ParentalNode } from '../../document';
|
||||
import './insertion.less';
|
||||
import { NodeData, NodeSchema } from '@ali/lowcode-types';
|
||||
|
||||
interface InsertionData {
|
||||
edge?: DOMRect;
|
||||
@ -18,6 +19,7 @@ interface InsertionData {
|
||||
vertical?: boolean;
|
||||
nearRect?: Rect;
|
||||
coverRect?: DOMRect;
|
||||
nearNode?: NodeData;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,6 +43,7 @@ function processChildrenDetail(sim: ISimulatorHost, container: ParentalNode, det
|
||||
if (detail.near) {
|
||||
const { node, pos, rect, align } = detail.near;
|
||||
ret.nearRect = rect || sim.computeRect(node);
|
||||
ret.nearNode = node;
|
||||
if (pos === 'replace') {
|
||||
// FIXME: ret.nearRect mybe null
|
||||
ret.coverRect = ret.nearRect;
|
||||
@ -82,6 +85,7 @@ function processChildrenDetail(sim: ISimulatorHost, container: ParentalNode, det
|
||||
ret.insertType = 'after';
|
||||
}
|
||||
ret.vertical = isVertical(ret.nearRect);
|
||||
ret.nearNode = nearNode;
|
||||
} else {
|
||||
ret.insertType = 'cover';
|
||||
ret.coverRect = edge;
|
||||
@ -122,14 +126,13 @@ export class InsertionView extends Component<{ host: BuiltinSimulatorHost }> {
|
||||
if (!loc) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 如果是个绝对定位容器,不需要渲染插入标记
|
||||
if (loc.target.componentMeta.getMetadata().experimental?.isAbsoluteLayoutContainer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { scale, scrollX, scrollY } = host.viewport;
|
||||
const { edge, insertType, coverRect, nearRect, vertical } = processDetail(loc);
|
||||
const { edge, insertType, coverRect, nearRect, vertical, nearNode } = processDetail(loc);
|
||||
|
||||
if (!edge) {
|
||||
return null;
|
||||
@ -162,6 +165,9 @@ export class InsertionView extends Component<{ host: BuiltinSimulatorHost }> {
|
||||
y = ((insertType === 'before' ? nearRect.top : nearRect.bottom) + scrollY) * scale;
|
||||
style.width = nearRect.width * scale;
|
||||
}
|
||||
if (y === 0 && (nearNode as NodeSchema)?.componentMeta?.isTopFixed) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
style.transform = `translate3d(${x}px, ${y}px, 0)`;
|
||||
|
||||
|
||||
@ -113,6 +113,12 @@ export class ComponentMeta {
|
||||
return this._liveTextEditing;
|
||||
}
|
||||
|
||||
private _isTopFixed?: boolean;
|
||||
|
||||
get isTopFixed() {
|
||||
return this._isTopFixed;
|
||||
}
|
||||
|
||||
private parentWhitelist?: NestingFilter | null;
|
||||
|
||||
private childWhitelist?: NestingFilter | null;
|
||||
@ -195,6 +201,12 @@ export class ComponentMeta {
|
||||
collectLiveTextEditing(this.configure);
|
||||
this._liveTextEditing = liveTextEditing.length > 0 ? liveTextEditing : undefined;
|
||||
|
||||
const isTopFiexd = this._transformedMetadata.experimental?.isTopFixed;
|
||||
|
||||
if (isTopFiexd) {
|
||||
this._isTopFixed = isTopFiexd;
|
||||
}
|
||||
|
||||
const { configure = {} } = this._transformedMetadata;
|
||||
this._acceptable = false;
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import { Node, insertChildren, insertChild, isNode, RootNode, ParentalNode } fro
|
||||
import { Selection } from './selection';
|
||||
import { History } from './history';
|
||||
import { TransformStage, ModalNodesManager } from './node';
|
||||
import { uniqueId } from '@ali/lowcode-utils';
|
||||
import { uniqueId, isPlainObject } from '@ali/lowcode-utils';
|
||||
|
||||
export type GetDataType<T, NodeType> = T extends undefined
|
||||
? NodeType extends {
|
||||
@ -350,7 +350,18 @@ export class DocumentModel {
|
||||
}
|
||||
|
||||
export(stage: TransformStage = TransformStage.Serilize) {
|
||||
return this.rootNode?.export(stage);
|
||||
// 置顶只作用于 Page 的第一级子节点,目前还用不到里层的置顶;如果后面有需要可以考虑将这段写到 node-children 中的 export
|
||||
const currentSchema = this.rootNode?.export(stage);
|
||||
if (Array.isArray(currentSchema?.children) && currentSchema?.children.length > 0) {
|
||||
const FixedTopNodeIndex = currentSchema.children
|
||||
.filter(i => isPlainObject(i))
|
||||
.findIndex((i => (i as NodeSchema).props?.__isTopFixed__));
|
||||
if (FixedTopNodeIndex > 0) {
|
||||
const FixedTopNode = currentSchema.children.splice(FixedTopNodeIndex, 1);
|
||||
currentSchema.children.unshift(FixedTopNode[0]);
|
||||
}
|
||||
}
|
||||
return currentSchema;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -172,6 +172,7 @@ export interface OldPrototypeConfig {
|
||||
onResizeEnd?: (e: MouseEvent, triggerDirection: string, dragment: Node) => void;
|
||||
devMode?: string;
|
||||
schema?: ProjectSchema;
|
||||
isTopFixed?: boolean;
|
||||
}
|
||||
|
||||
export interface ISetterConfig {
|
||||
@ -622,6 +623,7 @@ export function upgradeMetadata(oldConfig: OldPrototypeConfig) {
|
||||
onResizeEnd, // onResizeEnd
|
||||
devMode,
|
||||
schema,
|
||||
isTopFixed,
|
||||
} = oldConfig;
|
||||
|
||||
const meta: any = {
|
||||
@ -728,6 +730,9 @@ export function upgradeMetadata(oldConfig: OldPrototypeConfig) {
|
||||
if (view) {
|
||||
experimental.view = view;
|
||||
}
|
||||
if (isTopFixed) {
|
||||
experimental.isTopFixed = isTopFixed;
|
||||
}
|
||||
if (transducers) {
|
||||
// Array<{ toStatic, toNative }>
|
||||
// ? only twice
|
||||
|
||||
@ -20,6 +20,7 @@ import {
|
||||
removeEmptyPropsReducer,
|
||||
initNodeReducer,
|
||||
liveLifecycleReducer,
|
||||
nodeTopFixedReducer,
|
||||
} from './props-reducers';
|
||||
|
||||
export const editor = new Editor();
|
||||
@ -65,6 +66,9 @@ designer.addPropsReducer(deepValueParser, TransformStage.Render);
|
||||
designer.addPropsReducer(removeEmptyPropsReducer, TransformStage.Render);
|
||||
designer.addPropsReducer(removeEmptyPropsReducer, TransformStage.Save);
|
||||
|
||||
designer.addPropsReducer(nodeTopFixedReducer, TransformStage.Render);
|
||||
designer.addPropsReducer(nodeTopFixedReducer, TransformStage.Save);
|
||||
|
||||
skeleton.add({
|
||||
area: 'mainArea',
|
||||
name: 'designer',
|
||||
|
||||
@ -5,3 +5,4 @@ export * from './live-lifecycle-reducer';
|
||||
export * from './remove-empty-prop-reducer';
|
||||
export * from './style-reducer';
|
||||
export * from './upgrade-reducer';
|
||||
export * from './node-top-fixed-reducer';
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
import { Node } from '@ali/lowcode-designer';
|
||||
|
||||
export function nodeTopFixedReducer(props: any, node: Node) {
|
||||
if (node.componentMeta.isTopFixed) {
|
||||
return {
|
||||
...props,
|
||||
// experimental prop value
|
||||
__isTopFixed__: true,
|
||||
};
|
||||
}
|
||||
return props;
|
||||
}
|
||||
@ -54,5 +54,5 @@
|
||||
"publishConfig": {
|
||||
"registry": "http://registry.npm.alibaba-inc.com"
|
||||
},
|
||||
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-react-renderer@0.13.1-13/build/index.html"
|
||||
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-react-renderer@0.13.1-15/build/index.html"
|
||||
}
|
||||
|
||||
@ -89,6 +89,7 @@ export interface Experimental {
|
||||
// 纯文本编辑:如果 children 内容是
|
||||
// 文本编辑:配置
|
||||
liveTextEditing?: LiveTextEditingConfig[];
|
||||
isTopFixed?: boolean;
|
||||
}
|
||||
|
||||
// thinkof Array
|
||||
|
||||
@ -21,6 +21,7 @@ export interface NodeSchema {
|
||||
ignore?: boolean;
|
||||
locked?: boolean;
|
||||
hidden?: boolean;
|
||||
isTopFixed?: boolean;
|
||||
}
|
||||
|
||||
export type PropsMap = CompositeObject;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user