fix: fixed focusNodeSelector configuration not taking effect

This commit is contained in:
liujuping 2022-10-13 15:48:14 +08:00 committed by 林熠
parent ca7972c9a7
commit 9beae9c326
2 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { computed, makeObservable, obx, action, runWithGlobalEventOff, wrapWithEventSwitch } from '@alilc/lowcode-editor-core'; import { makeObservable, obx, engineConfig, action, runWithGlobalEventOff, wrapWithEventSwitch } from '@alilc/lowcode-editor-core';
import { NodeData, isJSExpression, isDOMText, NodeSchema, isNodeSchema, RootSchema, PageSchema, ComponentsMap } from '@alilc/lowcode-types'; import { NodeData, isJSExpression, isDOMText, NodeSchema, isNodeSchema, RootSchema, PageSchema, ComponentsMap } from '@alilc/lowcode-types';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { Project } from '../project'; import { Project } from '../project';
@ -87,7 +87,7 @@ export class DocumentModel {
if (this._drillDownNode) { if (this._drillDownNode) {
return this._drillDownNode; return this._drillDownNode;
} }
const selector = this.designer.editor?.get<((rootNode: RootNode) => Node) | null>('focusNodeSelector'); const selector = engineConfig.get('focusNodeSelector');
if (selector && typeof selector === 'function') { if (selector && typeof selector === 'function') {
return selector(this.rootNode!); return selector(this.rootNode!);
} }

View File

@ -141,6 +141,10 @@ const VALID_ENGINE_OPTIONS = {
type: 'boolean', type: 'boolean',
description: '当开启组件未找到严格模式时,渲染模块不会默认给一个容器组件', description: '当开启组件未找到严格模式时,渲染模块不会默认给一个容器组件',
}, },
focusNodeSelector: {
type: 'function',
description: '配置指定节点为根组件',
},
}; };
export interface EngineOptions { export interface EngineOptions {
/** /**
@ -268,6 +272,11 @@ export interface EngineOptions {
* *
*/ */
enableStrictNotFoundMode?: boolean; enableStrictNotFoundMode?: boolean;
/**
*
*/
focusNodeSelector?: (rootNode: Node) => Node;
} }
const getStrictModeValue = (engineOptions: EngineOptions, defaultValue: boolean): boolean => { const getStrictModeValue = (engineOptions: EngineOptions, defaultValue: boolean): boolean => {