mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-06 18:37:07 +00:00
Merge branch 'develop' into release/1.1.11-beta
This commit is contained in:
commit
84cb455fe9
@ -56,12 +56,13 @@ export function createSimulator(
|
|||||||
}
|
}
|
||||||
const id = asset.id ? ` data-id="${asset.id}"` : '';
|
const id = asset.id ? ` data-id="${asset.id}"` : '';
|
||||||
const lv = asset.level || level || AssetLevel.Environment;
|
const lv = asset.level || level || AssetLevel.Environment;
|
||||||
|
const scriptType = asset.scriptType ? ` type="${asset.scriptType}"` : '';
|
||||||
if (asset.type === AssetType.JSUrl) {
|
if (asset.type === AssetType.JSUrl) {
|
||||||
scripts[lv].push(
|
scripts[lv].push(
|
||||||
`<script src="${asset.content}"${id}></script>`,
|
`<script src="${asset.content}"${id}${scriptType}></script>`,
|
||||||
);
|
);
|
||||||
} else if (asset.type === AssetType.JSText) {
|
} else if (asset.type === AssetType.JSText) {
|
||||||
scripts[lv].push(`<script${id}>${asset.content}</script>`);
|
scripts[lv].push(`<script${id}${scriptType}>${asset.content}</script>`);
|
||||||
} else if (asset.type === AssetType.CSSUrl) {
|
} else if (asset.type === AssetType.CSSUrl) {
|
||||||
styles[lv].push(
|
styles[lv].push(
|
||||||
`<link rel="stylesheet" href="${asset.content}"${id} />`,
|
`<link rel="stylesheet" href="${asset.content}"${id} />`,
|
||||||
|
|||||||
@ -10,6 +10,14 @@ import {
|
|||||||
} from './icons';
|
} from './icons';
|
||||||
import { componentDefaults, legacyIssues } from './transducers';
|
import { componentDefaults, legacyIssues } from './transducers';
|
||||||
|
|
||||||
|
function deduplicateRef(node: IPublicModelNode | null | undefined) {
|
||||||
|
const currentRef = node?.getPropValue('ref');
|
||||||
|
if (currentRef) {
|
||||||
|
node?.setPropValue('ref', `${node.componentName.toLowerCase()}-${Math.random().toString(36).slice(2, 9)}`);
|
||||||
|
}
|
||||||
|
node?.children?.forEach(deduplicateRef);
|
||||||
|
}
|
||||||
|
|
||||||
export class ComponentActions {
|
export class ComponentActions {
|
||||||
private metadataTransducers: IPublicTypeMetadataTransducer[] = [];
|
private metadataTransducers: IPublicTypeMetadataTransducer[] = [];
|
||||||
|
|
||||||
@ -53,6 +61,7 @@ export class ComponentActions {
|
|||||||
const { document: doc, parent, index } = node;
|
const { document: doc, parent, index } = node;
|
||||||
if (parent) {
|
if (parent) {
|
||||||
const newNode = doc?.insertNode(parent, node, (index ?? 0) + 1, true);
|
const newNode = doc?.insertNode(parent, node, (index ?? 0) + 1, true);
|
||||||
|
deduplicateRef(newNode);
|
||||||
newNode?.select();
|
newNode?.select();
|
||||||
const { isRGL, rglNode } = node?.getRGL();
|
const { isRGL, rglNode } = node?.getRGL();
|
||||||
if (isRGL) {
|
if (isRGL) {
|
||||||
|
|||||||
@ -2,7 +2,12 @@ import { cloneEnumerableProperty } from '@alilc/lowcode-utils';
|
|||||||
import adapter from '../adapter';
|
import adapter from '../adapter';
|
||||||
import { IBaseRendererInstance, IRendererProps } from '../types';
|
import { IBaseRendererInstance, IRendererProps } from '../types';
|
||||||
|
|
||||||
function patchDidCatch(Comp: any, { baseRenderer }: { baseRenderer: IBaseRendererInstance }) {
|
interface Options {
|
||||||
|
baseRenderer: IBaseRendererInstance;
|
||||||
|
schema: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
function patchDidCatch(Comp: any, { baseRenderer }: Options) {
|
||||||
if (Comp.patchedCatch) {
|
if (Comp.patchedCatch) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -44,7 +49,9 @@ function patchDidCatch(Comp: any, { baseRenderer }: { baseRenderer: IBaseRendere
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function compWrapper(Comp: any, options: { baseRenderer: IBaseRendererInstance }) {
|
const cache = new Map();
|
||||||
|
|
||||||
|
export function compWrapper(Comp: any, options: Options) {
|
||||||
const { createElement, Component, forwardRef } = adapter.getRuntime();
|
const { createElement, Component, forwardRef } = adapter.getRuntime();
|
||||||
if (
|
if (
|
||||||
Comp?.prototype?.isReactComponent || // react
|
Comp?.prototype?.isReactComponent || // react
|
||||||
@ -54,6 +61,11 @@ export function compWrapper(Comp: any, options: { baseRenderer: IBaseRendererIns
|
|||||||
patchDidCatch(Comp, options);
|
patchDidCatch(Comp, options);
|
||||||
return Comp;
|
return Comp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cache.has(options.schema.id)) {
|
||||||
|
return cache.get(options.schema.id);
|
||||||
|
}
|
||||||
|
|
||||||
class Wrapper extends Component {
|
class Wrapper extends Component {
|
||||||
render() {
|
render() {
|
||||||
return createElement(Comp, { ...this.props, ref: this.props.forwardRef });
|
return createElement(Comp, { ...this.props, ref: this.props.forwardRef });
|
||||||
@ -63,10 +75,14 @@ export function compWrapper(Comp: any, options: { baseRenderer: IBaseRendererIns
|
|||||||
|
|
||||||
patchDidCatch(Wrapper, options);
|
patchDidCatch(Wrapper, options);
|
||||||
|
|
||||||
return cloneEnumerableProperty(
|
const WrapperComponent = cloneEnumerableProperty(
|
||||||
forwardRef((props: any, ref: any) => {
|
forwardRef((props: any, ref: any) => {
|
||||||
return createElement(Wrapper, { ...props, forwardRef: ref });
|
return createElement(Wrapper, { ...props, forwardRef: ref });
|
||||||
}),
|
}),
|
||||||
Comp,
|
Comp,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cache.set(options.schema.id, WrapperComponent);
|
||||||
|
|
||||||
|
return WrapperComponent;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -615,7 +615,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Comp = compWrapper(Comp, { baseRenderer: this });
|
Comp = compWrapper(Comp, { baseRenderer: this, schema });
|
||||||
components[schema.componentName] = Comp;
|
components[schema.componentName] = Comp;
|
||||||
|
|
||||||
otherProps.ref = (ref: any) => {
|
otherProps.ref = (ref: any) => {
|
||||||
|
|||||||
@ -38,6 +38,7 @@ export interface AssetItem {
|
|||||||
device?: string;
|
device?: string;
|
||||||
level?: AssetLevel;
|
level?: AssetLevel;
|
||||||
id?: string;
|
id?: string;
|
||||||
|
scriptType?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AssetList = Array<Asset | undefined | null>;
|
export type AssetList = Array<Asset | undefined | null>;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user