mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
Merge branch 'release/1.0.60' of gitlab.alibaba-inc.com:ali-lowcode/ali-lowcode-engine into release/0.16.4
This commit is contained in:
commit
54ad6273fb
@ -1,3 +1,6 @@
|
||||
module.exports = {
|
||||
extends: 'stylelint-config-ali',
|
||||
rules: {
|
||||
"selector-max-id": 2
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import { Component, Fragment, PureComponent } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { computed, observer, Title } from '@ali/lowcode-editor-core';
|
||||
import { BuiltinSimulatorHost } from '../host';
|
||||
import { TitleContent } from '@ali/lowcode-types';
|
||||
import { getClosestNode } from '@ali/lowcode-utils';
|
||||
|
||||
import { BuiltinSimulatorHost } from '../host';
|
||||
|
||||
|
||||
export class BorderDetectingInstance extends PureComponent<{
|
||||
title: TitleContent;
|
||||
@ -10,9 +13,10 @@ export class BorderDetectingInstance extends PureComponent<{
|
||||
scale: number;
|
||||
scrollX: number;
|
||||
scrollY: number;
|
||||
isLocked?: boolean;
|
||||
}> {
|
||||
render() {
|
||||
const { title, rect, scale, scrollX, scrollY } = this.props;
|
||||
const { title, rect, scale, scrollX, scrollY, isLocked } = this.props;
|
||||
if (!rect) {
|
||||
return null;
|
||||
}
|
||||
@ -32,6 +36,9 @@ export class BorderDetectingInstance extends PureComponent<{
|
||||
return (
|
||||
<div className={className} style={style}>
|
||||
<Title title={title} className="lc-borders-title" />
|
||||
{
|
||||
isLocked ? (<Title title="已锁定" className="lc-borders-status" />) : null
|
||||
}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@ -74,12 +81,33 @@ export class BorderDetecting extends Component<{ host: BuiltinSimulatorHost }> {
|
||||
const { host } = this.props;
|
||||
const { current } = this;
|
||||
|
||||
|
||||
const canHoverHook = current?.componentMeta.getMetadata()?.experimental?.callbacks?.onHoverHook;
|
||||
const canHover = (canHoverHook && typeof canHoverHook === 'function') ? canHoverHook(current) : true;
|
||||
|
||||
|
||||
if (!canHover || !current || host.viewport.scrolling || host.liveEditing.editing) {
|
||||
return null;
|
||||
}
|
||||
const lockedNode = getClosestNode(current, (n) => {
|
||||
return n?.getExtraProp('isLocked')?.getValue() === true;
|
||||
});
|
||||
if (lockedNode && lockedNode.getId() !== current.getId()) {
|
||||
// return null;
|
||||
// 选中父节锁定的节点
|
||||
return (
|
||||
<BorderDetectingInstance
|
||||
key="line-h"
|
||||
title={current.title}
|
||||
scale={this.scale}
|
||||
scrollX={this.scrollX}
|
||||
scrollY={this.scrollY}
|
||||
// @ts-ignore
|
||||
rect={host.computeComponentInstanceRect(host.getComponentInstances(lockedNode)[0], lockedNode.componentMeta.rootSelector)}
|
||||
isLocked={lockedNode?.getId() !== current.getId()}
|
||||
/>
|
||||
);
|
||||
}
|
||||
const instances = host.getComponentInstances(current);
|
||||
if (!instances || instances.length < 1) {
|
||||
return null;
|
||||
|
||||
@ -11,10 +11,13 @@
|
||||
will-change: transform, width, height;
|
||||
overflow: visible;
|
||||
& > &-title {
|
||||
position: absolute;
|
||||
color: var(--color-brand-light);
|
||||
top: 0;
|
||||
left: 0;
|
||||
transform: translateY(-100%);
|
||||
font-weight: lighter;
|
||||
}
|
||||
& > &-status {
|
||||
margin-left: 5px;
|
||||
color: #3c3c3c;
|
||||
transform: translateY(-100%);
|
||||
font-weight: lighter;
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ import {
|
||||
isFormEvent,
|
||||
hasOwnProperty,
|
||||
UtilsMetadata,
|
||||
getClosestNode,
|
||||
} from '@ali/lowcode-utils';
|
||||
import {
|
||||
DragObjectType,
|
||||
@ -463,7 +464,7 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
}
|
||||
|
||||
setupRendererChannel() {
|
||||
const editor = this.designer.editor;
|
||||
const { editor } = this.designer;
|
||||
editor.on('node.innerProp.change', ({ node, prop, oldValue, newValue }) => {
|
||||
// 在 Node 初始化阶段的属性变更都跳过
|
||||
if (!node.isInited) return;
|
||||
@ -1205,7 +1206,11 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
|
||||
}
|
||||
const dropContainer = this.getDropContainer(e);
|
||||
const canDropIn = dropContainer?.container?.componentMeta?.prototype?.options?.canDropIn;
|
||||
|
||||
const lockedNode = getClosestNode(dropContainer?.container as Node, (node) => {
|
||||
return node?.getExtraProp('isLocked')?.getValue() === true;
|
||||
});
|
||||
// const isLocked = dropContainer?.container?.getExtraProp('isLocked')?.getValue();
|
||||
if (lockedNode) return null;
|
||||
if (
|
||||
!dropContainer ||
|
||||
canDropIn === false ||
|
||||
@ -1277,8 +1282,7 @@ 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;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { getClosestNode } from '@ali/lowcode-utils';
|
||||
import { Node } from '../../document';
|
||||
|
||||
/**
|
||||
@ -13,8 +14,14 @@ export const getClosestClickableNode = (
|
||||
// 执行 onClickHook 来判断当前节点是否可点击
|
||||
while (node) {
|
||||
const onClickHook = node.componentMeta?.getMetadata()?.experimental?.callbacks?.onClickHook;
|
||||
const canClick =
|
||||
const lockedNode = getClosestNode(node, (n) => {
|
||||
return n?.getExtraProp('isLocked')?.getValue() === true;
|
||||
});
|
||||
let canClick =
|
||||
onClickHook && typeof onClickHook === 'function' ? onClickHook(event, node) : true;
|
||||
if (lockedNode && lockedNode.getId() !== node.getId()) {
|
||||
canClick = false;
|
||||
}
|
||||
if (canClick) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { ReactElement } from 'react';
|
||||
import {
|
||||
ComponentMetadata,
|
||||
NpmInfo,
|
||||
@ -12,18 +13,13 @@ import {
|
||||
LiveTextEditingConfig,
|
||||
FieldConfig,
|
||||
} from '@ali/lowcode-types';
|
||||
import { computed } from '@ali/lowcode-editor-core';
|
||||
import { computed, engineConfig } from '@ali/lowcode-editor-core';
|
||||
import EventEmitter from 'events';
|
||||
|
||||
import { isNode, Node, ParentalNode } from './document';
|
||||
import { Designer } from './designer';
|
||||
import { intlNode } from './locale';
|
||||
import { IconContainer } from './icons/container';
|
||||
import { IconPage } from './icons/page';
|
||||
import { IconComponent } from './icons/component';
|
||||
import { IconRemove } from './icons/remove';
|
||||
import { IconClone } from './icons/clone';
|
||||
import { ReactElement } from 'react';
|
||||
import { IconHidden } from './icons/hidden';
|
||||
import EventEmitter from 'events';
|
||||
import { IconLock, IconUnlock, IconContainer, IconPage, IconComponent, IconRemove, IconClone, IconHidden } from './icons';
|
||||
|
||||
function ensureAList(list?: string | string[]): string[] | null {
|
||||
if (!list) {
|
||||
@ -148,6 +144,7 @@ export class ComponentMeta {
|
||||
// if _title is TitleConfig get _title.icon
|
||||
return (
|
||||
this._transformedMetadata?.icon ||
|
||||
// eslint-disable-next-line
|
||||
(this.componentName === 'Page' ? IconPage : this.isContainer ? IconContainer : IconComponent)
|
||||
);
|
||||
}
|
||||
@ -262,7 +259,7 @@ export class ComponentMeta {
|
||||
// eslint-disable-next-line prefer-const
|
||||
let { disableBehaviors, actions } = this._transformedMetadata?.configure.component || {};
|
||||
const disabled =
|
||||
ensureAList(disableBehaviors) || (this.isRootComponent(false) ? ['copy', 'remove'] : null);
|
||||
ensureAList(disableBehaviors) || (this.isRootComponent(false) ? ['copy', 'remove', 'lock', 'unlock'] : null);
|
||||
actions = builtinComponentActions.concat(
|
||||
this.designer.getGlobalComponentActions() || [],
|
||||
actions || [],
|
||||
@ -471,6 +468,36 @@ const builtinComponentActions: ComponentAction[] = [
|
||||
},
|
||||
important: true,
|
||||
},
|
||||
{
|
||||
name: 'lock',
|
||||
content: {
|
||||
icon: IconUnlock, // 解锁icon
|
||||
title: intlNode('lock'),
|
||||
action(node: Node) {
|
||||
node.getExtraProp('isLocked', true)?.setValue(true);
|
||||
},
|
||||
},
|
||||
condition: (node: Node) => {
|
||||
const isLocked = node.getExtraProp('isLocked')?.getValue();
|
||||
return (engineConfig.get('enableCanvasLock', false) && node.isContainer() && isLocked !== true);
|
||||
},
|
||||
important: true,
|
||||
},
|
||||
{
|
||||
name: 'unlock',
|
||||
content: {
|
||||
icon: IconLock, // 锁定icon
|
||||
title: intlNode('unlock'),
|
||||
action(node: Node) {
|
||||
node.getExtraProp('isLocked', true)?.setValue(false);
|
||||
},
|
||||
},
|
||||
condition: (node: Node) => {
|
||||
const isLocked = node.getExtraProp('isLocked')?.getValue();
|
||||
return (engineConfig.get('enableCanvasLock', false) && node.isContainer() && isLocked === true);
|
||||
},
|
||||
important: true,
|
||||
},
|
||||
];
|
||||
|
||||
export function removeBuiltinComponentAction(name: string) {
|
||||
@ -484,11 +511,11 @@ export function addBuiltinComponentAction(action: ComponentAction) {
|
||||
}
|
||||
|
||||
export function modifyBuiltinComponentAction(
|
||||
actionName,
|
||||
actionName: string,
|
||||
handle: (action: ComponentAction) => void,
|
||||
) {
|
||||
const builtinAction = builtinComponentActions.find((action) => action.name === actionName);
|
||||
if (builtinAction) {
|
||||
handle(builtinAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
packages/designer/src/icons/index.ts
Normal file
10
packages/designer/src/icons/index.ts
Normal file
@ -0,0 +1,10 @@
|
||||
export * from './lock';
|
||||
export * from './hidden';
|
||||
export * from './remove';
|
||||
export * from './setting';
|
||||
export * from './component';
|
||||
export * from './clone';
|
||||
export * from './page';
|
||||
export * from './container';
|
||||
export * from './unlock';
|
||||
|
||||
11
packages/designer/src/icons/lock.tsx
Normal file
11
packages/designer/src/icons/lock.tsx
Normal file
@ -0,0 +1,11 @@
|
||||
import { SVGIcon, IconProps } from '@ali/lowcode-utils';
|
||||
|
||||
export function IconLock(props: IconProps) {
|
||||
return (
|
||||
<SVGIcon viewBox="0 0 1024 1024" {...props}>
|
||||
<path d="M704 480v-160c0-105.6-86.4-192-192-192s-192 86.4-192 192v160H160v416h704V480h-160z m-320-160c0-70.4 57.6-128 128-128s128 57.6 128 128v160h-256v-160z m416 512H224v-288h576v288z" fill="#ffffff" p-id="2680" />
|
||||
<path d="M480 768h64v-160h-64z" fill="#ffffff" p-id="2681" />
|
||||
</SVGIcon>
|
||||
);
|
||||
}
|
||||
IconLock.displayName = 'IconLock';
|
||||
11
packages/designer/src/icons/unlock.tsx
Normal file
11
packages/designer/src/icons/unlock.tsx
Normal file
@ -0,0 +1,11 @@
|
||||
import { SVGIcon, IconProps } from '@ali/lowcode-utils';
|
||||
|
||||
export function IconUnlock(props: IconProps) {
|
||||
return (
|
||||
<SVGIcon viewBox="0 0 1024 1024" {...props}>
|
||||
<path d="M384 480v-160c0-70.4 57.6-128 128-128s128 57.6 128 128v64h64v-64c0-105.6-86.4-192-192-192s-192 86.4-192 192v160H160v416h704V480H384z m416 352H224v-288h576v288z" fill="#ffffff" p-id="2813" />
|
||||
<path d="M416 736h192v-64h-192z" fill="#ffffff" p-id="2814" />
|
||||
</SVGIcon>
|
||||
);
|
||||
}
|
||||
IconUnlock.displayName = 'IconUnlock';
|
||||
@ -2,6 +2,8 @@
|
||||
"copy": "Copy",
|
||||
"remove": "Remove",
|
||||
"hide": "Hide",
|
||||
"lock": "Lock",
|
||||
"unlock": "Unlock",
|
||||
"Condition Group": "Condition Group",
|
||||
"No opened document": "No opened document, open some document to editing"
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
"copy": "复制",
|
||||
"remove": "删除",
|
||||
"hide": "隐藏",
|
||||
"lock": "锁定",
|
||||
"unlock": "解锁",
|
||||
"Condition Group": "条件组",
|
||||
"No opened document": "没有打开的页面,请选择页面打开编辑"
|
||||
}
|
||||
|
||||
@ -51,6 +51,10 @@ export interface EngineOptions {
|
||||
* 禁止默认的设置器,默认值:false
|
||||
*/
|
||||
disableDefaultSetters: boolean;
|
||||
/**
|
||||
* 打开画布的锁定操作,默认值:false
|
||||
*/
|
||||
enableCanvasLock: boolean;
|
||||
/**
|
||||
* Vision-polyfill settings
|
||||
*/
|
||||
|
||||
@ -118,6 +118,7 @@ export class SettingsPrimaryPane extends Component<{ editor: Editor; config: any
|
||||
|
||||
render() {
|
||||
const { settings } = this.main;
|
||||
const editor = globalContext.get(Editor);
|
||||
if (!settings) {
|
||||
// 未选中节点,提示选中 或者 显示根节点设置
|
||||
return (
|
||||
@ -140,7 +141,7 @@ export class SettingsPrimaryPane extends Component<{ editor: Editor; config: any
|
||||
}
|
||||
|
||||
if (!settings.isSameComponent) {
|
||||
// todo: future support 获取设置项交集编辑
|
||||
// TODO: future support 获取设置项交集编辑
|
||||
return (
|
||||
<div className="lc-settings-main">
|
||||
<div className="lc-settings-notice">
|
||||
@ -179,7 +180,19 @@ export class SettingsPrimaryPane extends Component<{ editor: Editor; config: any
|
||||
matched = true;
|
||||
}
|
||||
return (
|
||||
<Tab.Item className="lc-settings-tab-item" title={<Title title={field.title} />} key={field.name}>
|
||||
<Tab.Item
|
||||
className="lc-settings-tab-item"
|
||||
title={<Title title={field.title} />}
|
||||
key={field.name}
|
||||
onClick={
|
||||
() => {
|
||||
editor?.emit('skeleton.settingsPane.change', {
|
||||
name: field.name,
|
||||
title: field.title,
|
||||
});
|
||||
}
|
||||
}
|
||||
>
|
||||
<SkeletonContext.Consumer>
|
||||
{(skeleton) => {
|
||||
if (skeleton) {
|
||||
|
||||
@ -178,7 +178,6 @@ export async function init(container?: Element, options?: EngineOptions) {
|
||||
}
|
||||
}
|
||||
engineContainer.id = 'engine';
|
||||
|
||||
engineConfig.setConfig(engineOptions as any);
|
||||
|
||||
await plugins.init();
|
||||
|
||||
2
packages/plugin-outline-pane/src/icons/index.ts
Normal file
2
packages/plugin-outline-pane/src/icons/index.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export * from './lock';
|
||||
export * from './unlock';
|
||||
@ -12,6 +12,7 @@ export default class TreeNode {
|
||||
* 是否可以展开
|
||||
*/
|
||||
@computed get expandable(): boolean {
|
||||
if (this.locked) return false;
|
||||
return this.hasChildren() || this.hasSlots() || this.dropDetail?.index != null;
|
||||
}
|
||||
|
||||
@ -86,14 +87,14 @@ export default class TreeNode {
|
||||
}
|
||||
|
||||
@computed get locked(): boolean {
|
||||
return this.node.getExtraProp('locked', false)?.getValue() === true;
|
||||
return this.node.getExtraProp('isLocked', false)?.getValue() === true;
|
||||
}
|
||||
|
||||
setLocked(flag: boolean) {
|
||||
if (flag) {
|
||||
this.node.getExtraProp('locked', true)?.setValue(true);
|
||||
this.node.getExtraProp('isLocked', true)?.setValue(true);
|
||||
} else {
|
||||
this.node.getExtraProp('locked', false)?.remove();
|
||||
this.node.getExtraProp('isLocked', false)?.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,7 +141,7 @@ export default class TreeNode {
|
||||
return this.node.componentMeta.icon;
|
||||
}
|
||||
|
||||
@computed get parent() {
|
||||
@computed get parent(): TreeNode | null {
|
||||
const { parent } = this.node;
|
||||
if (parent) {
|
||||
return this.tree.getTreeNode(parent);
|
||||
|
||||
@ -12,7 +12,9 @@ export class Tree {
|
||||
|
||||
constructor(document: DocumentModel) {
|
||||
this.document = document;
|
||||
this.root = this.getTreeNode(document.rootNode);
|
||||
if (document.rootNode) {
|
||||
this.root = this.getTreeNode(document.rootNode);
|
||||
}
|
||||
this.id = document.id;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import { Component, KeyboardEvent, FocusEvent, Fragment } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { observer, Title, Tip, globalContext, Editor } from '@ali/lowcode-editor-core';
|
||||
import { createIcon } from '@ali/lowcode-utils';
|
||||
|
||||
import { IconArrowRight } from '../icons/arrow-right';
|
||||
import { IconEyeClose } from '../icons/eye-close';
|
||||
import { intl, intlNode } from '../locale';
|
||||
@ -10,7 +12,8 @@ import { IconCond } from '../icons/cond';
|
||||
import { IconLoop } from '../icons/loop';
|
||||
import { IconRadioActive } from '../icons/radio-active';
|
||||
import { IconRadio } from '../icons/radio';
|
||||
import { createIcon } from '@ali/lowcode-utils';
|
||||
import { IconLock, IconUnlock } from '../icons';
|
||||
|
||||
|
||||
function emitOutlineEvent(type: string, treeNode: TreeNode, rest?: Record<string, unknown>) {
|
||||
const editor = globalContext.get(Editor);
|
||||
@ -83,6 +86,7 @@ export default class TreeTitle extends Component<{
|
||||
const isCNode = !treeNode.isRoot();
|
||||
const { node } = treeNode;
|
||||
const isNodeParent = node.isParental();
|
||||
const isContainer = node.isContainer();
|
||||
let style: any;
|
||||
if (isCNode) {
|
||||
const { depth } = treeNode;
|
||||
@ -164,34 +168,34 @@ export default class TreeTitle extends Component<{
|
||||
)}
|
||||
</div>
|
||||
{isCNode && isNodeParent && !isModal && <HideBtn treeNode={treeNode} />}
|
||||
{/* isCNode && isNodeParent && <LockBtn treeNode={treeNode} /> */}
|
||||
{isContainer && isCNode && isNodeParent && <LockBtn treeNode={treeNode} />}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// @observer
|
||||
// class LockBtn extends Component<{ treeNode: TreeNode }> {
|
||||
// shouldComponentUpdate() {
|
||||
// return false;
|
||||
// }
|
||||
@observer
|
||||
class LockBtn extends Component<{ treeNode: TreeNode }> {
|
||||
shouldComponentUpdate() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// render() {
|
||||
// const { treeNode } = this.props;
|
||||
// return (
|
||||
// <div
|
||||
// className="tree-node-lock-btn"
|
||||
// onClick={(e) => {
|
||||
// e.stopPropagation();
|
||||
// treeNode.setLocked(!treeNode.locked);
|
||||
// }}
|
||||
// >
|
||||
// {treeNode.locked ? <IconLock /> : <IconUnlock />}
|
||||
// <Tip>{treeNode.locked ? intl('Unlock') : intl('Lock')}</Tip>
|
||||
// </div>
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
render() {
|
||||
const { treeNode } = this.props;
|
||||
return (
|
||||
<div
|
||||
className="tree-node-lock-btn"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
treeNode.setLocked(!treeNode.locked);
|
||||
}}
|
||||
>
|
||||
{treeNode.locked ? <IconLock /> : <IconUnlock />}
|
||||
<Tip>{treeNode.locked ? intl('Unlock') : intl('Lock')}</Tip>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@observer
|
||||
class HideBtn extends Component<{ treeNode: TreeNode }> {
|
||||
@ -217,6 +221,7 @@ class HideBtn extends Component<{ treeNode: TreeNode }> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@observer
|
||||
class ExpandBtn extends Component<{ treeNode: TreeNode }> {
|
||||
shouldComponentUpdate() {
|
||||
|
||||
@ -55,6 +55,6 @@
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npm.alibaba-inc.com"
|
||||
},
|
||||
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-rax-simulator-renderer@1.0.55/build/index.html",
|
||||
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-rax-simulator-renderer@1.0.58/build/index.html",
|
||||
"gitHead": "3bfd7df92985ec6c9d2ccb8ba95d7b0829fa2b1d"
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
import { ReactInstance, Fragment, Component, createElement } from 'react';
|
||||
import { Router, Route, Switch } from 'react-router';
|
||||
import cn from 'classnames';
|
||||
import { Node } from '@ali/lowcode-designer';
|
||||
import LowCodeRenderer from '@ali/lowcode-react-renderer';
|
||||
import { ReactInstance, Fragment, Component, createElement } from 'react';
|
||||
import { observer } from '@recore/obx-react';
|
||||
import { isFromVC } from '@ali/lowcode-utils';
|
||||
import { isFromVC, getClosestNode } from '@ali/lowcode-utils';
|
||||
import { SimulatorRendererContainer, DocumentInstance } from './renderer';
|
||||
import { Router, Route, Switch } from 'react-router';
|
||||
|
||||
import './renderer.less';
|
||||
|
||||
const DEFAULT_SIMULATOR_LOCALE = 'zh-CN';
|
||||
@ -171,9 +173,16 @@ class Renderer extends Component<{
|
||||
(children == null || (Array.isArray(children) && !children.length)) &&
|
||||
(!viewProps.style || Object.keys(viewProps.style).length === 0)
|
||||
) {
|
||||
let defaultPlaceholder = '拖拽组件或模板到这里';
|
||||
const lockedNode = getClosestNode(leaf, (node) => {
|
||||
return node?.getExtraProp('isLocked')?.getValue() === true;
|
||||
});
|
||||
if (lockedNode) {
|
||||
defaultPlaceholder = '锁定元素及子元素无法编辑';
|
||||
}
|
||||
children = (
|
||||
<div className="lc-container-placeholder" style={viewProps.placeholderStyle}>
|
||||
{viewProps.placeholder || '拖拽组件或模板到这里'}
|
||||
<div className={cn('lc-container-placeholder', { 'lc-container-locked': !!lockedNode })} style={viewProps.placeholderStyle}>
|
||||
{viewProps.placeholder || defaultPlaceholder}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -65,6 +65,10 @@ html.engine-cursor-ew-resize, html.engine-cursor-ew-resize * {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 14px;
|
||||
|
||||
&.lc-container-locked {
|
||||
background: #eccfcf;
|
||||
}
|
||||
}
|
||||
|
||||
body.engine-document {
|
||||
@ -87,3 +91,5 @@ body.engine-document {
|
||||
#app {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -22,6 +22,7 @@ export interface NodeSchema {
|
||||
loop?: CompositeValue; // 循环数据
|
||||
loopArgs?: [string, string]; // 循环迭代对象、索引名称 ["item", "index"]
|
||||
children?: NodeData | NodeData[]; // 子节点
|
||||
isLocked?: boolean; // 是否锁定
|
||||
|
||||
// ------- future support -----
|
||||
conditionGroup?: string;
|
||||
|
||||
@ -22,3 +22,4 @@ export * from './build-components';
|
||||
export * from './appHelper';
|
||||
export * from './misc';
|
||||
export * from './schema';
|
||||
export * from './node-helper';
|
||||
|
||||
14
packages/utils/src/node-helper.ts
Normal file
14
packages/utils/src/node-helper.ts
Normal file
@ -0,0 +1,14 @@
|
||||
// 仅使用类型
|
||||
import { Node } from '@ali/lowcode-designer';
|
||||
|
||||
export const getClosestNode = (node: Node, until: (node: Node) => boolean): Node | undefined => {
|
||||
if (!node) {
|
||||
return undefined;
|
||||
}
|
||||
if (until(node)) {
|
||||
return node;
|
||||
} else {
|
||||
// @ts-ignore
|
||||
return getClosestNode(node.getParent(), until);
|
||||
}
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user