feat: 增加 Node#lock 接口, 并且支持禁止锁定的节点的编辑操作

This commit is contained in:
lihao.ylh 2021-08-05 14:59:35 +08:00
parent c88f254e71
commit e051c3f0d7
4 changed files with 31 additions and 3 deletions

View File

@ -54,6 +54,10 @@ export class SettingTopEntry implements SettingEntry {
return this.nodes.length === 1;
}
get isLocked(): boolean {
return this.first.isLocked;
}
/**
*
*/

View File

@ -44,7 +44,7 @@ import { NodeRemoveOptions } from '../../types';
* conditionGroup use for condition, for exclusive
* title display on outline
* ignored ignore this node will not publish to render, but will store
* isLocked can not select/hover/ item on canvas but can control on outline
* isLocked can not select/hover/ item on canvas and outline
* hidden not visible on canvas
* slotArgs like loopArgs, for slot node
*
@ -374,6 +374,20 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
}
}
/**
*
*/
lock(flag = true) {
this.setExtraProp('isLocked', flag);
}
/**
*
*/
get isLocked(): boolean {
return !!this.getExtraProp('isLocked', false)?.getValue();
}
/**
*
*/

View File

@ -123,7 +123,7 @@ export class SettingsPrimaryPane extends Component<{ editor: Editor; config: any
render() {
const { settings } = this.main;
const editor = globalContext.get(Editor);
const editor = globalContext.get('editor');
if (!settings) {
// 未选中节点,提示选中 或者 显示根节点设置
return (
@ -135,6 +135,16 @@ export class SettingsPrimaryPane extends Component<{ editor: Editor; config: any
);
}
if (settings.isLocked) {
return (
<div className="lc-settings-main">
<div className="lc-settings-notice">
<p></p>
</div>
</div>
);
}
if (Array.isArray(settings.items) && settings.items.length === 0) {
return (
<div className="lc-settings-main">

View File

@ -175,7 +175,7 @@ plugins.register((ctx: ILowCodePluginContext) => {
},
};
});
export async function init(container?: Element, options?: EngineOptions) {
export async function init(container?: HTMLElement, options?: EngineOptions) {
let engineOptions = null;
let engineContainer = null;
if (isPlainObject(container)) {