Merge remote-tracking branch 'origin/develop' into release/1.1.7-beta

This commit is contained in:
JackLian 2023-04-26 11:24:48 +08:00
commit 723f4cdf79
18 changed files with 90 additions and 62 deletions

View File

@ -95,6 +95,17 @@ common.utils.startTransaction(() => {
}, IPublicEnumTransitionType.repaint); }, IPublicEnumTransitionType.repaint);
``` ```
#### getConvertedExtraKey
props key 转化工具
```typescript
getConvertedExtraKey(key: string): string
```
**@since v1.0.17**
#### createIntl #### createIntl
i18n 相关工具 i18n 相关工具
```typescript ```typescript

View File

@ -17,6 +17,8 @@ import {
IPublicTypePluginDeclaration, IPublicTypePluginDeclaration,
IPublicApiCanvas, IPublicApiCanvas,
IPublicApiWorkspace, IPublicApiWorkspace,
IPublicEnumPluginRegisterLevel,
IPublicModelWindow,
} from '@alilc/lowcode-types'; } from '@alilc/lowcode-types';
import { import {
IPluginContextOptions, IPluginContextOptions,
@ -41,6 +43,8 @@ export default class PluginContext implements
pluginEvent: IPublicApiEvent; pluginEvent: IPublicApiEvent;
canvas: IPublicApiCanvas; canvas: IPublicApiCanvas;
workspace: IPublicApiWorkspace; workspace: IPublicApiWorkspace;
registerLevel: IPublicEnumPluginRegisterLevel;
editorWindow: IPublicModelWindow;
constructor( constructor(
options: IPluginContextOptions, options: IPluginContextOptions,

View File

@ -40,6 +40,7 @@ export class TreeMaster {
const { workspace } = this.pluginContext; const { workspace } = this.pluginContext;
this.initEvent(); this.initEvent();
if (pluginContext.registerLevel === IPublicEnumPluginRegisterLevel.Workspace) { if (pluginContext.registerLevel === IPublicEnumPluginRegisterLevel.Workspace) {
this.setPluginContext(workspace.window?.currentEditorView);
workspace.onWindowRendererReady(() => { workspace.onWindowRendererReady(() => {
this.setPluginContext(workspace.window?.currentEditorView); this.setPluginContext(workspace.window?.currentEditorView);
let dispose: IPublicTypeDisposable | undefined; let dispose: IPublicTypeDisposable | undefined;
@ -60,7 +61,7 @@ export class TreeMaster {
} }
} }
private setPluginContext(pluginContext: IPublicModelPluginContext | undefined) { private setPluginContext(pluginContext: IPublicModelPluginContext | undefined | null) {
if (!pluginContext) { if (!pluginContext) {
return; return;
} }

View File

@ -6,6 +6,34 @@ import { TreeMaster } from './controllers/tree-master';
import { PaneController } from './controllers/pane-controller'; import { PaneController } from './controllers/pane-controller';
import { useState } from 'react'; import { useState } from 'react';
export function OutlinePaneContext(props: {
treeMaster?: TreeMaster;
pluginContext: IPublicModelPluginContext;
options: any;
paneName: string;
hideFilter?: boolean;
}) {
const treeMaster = props.treeMaster || new TreeMaster(props.pluginContext, props.options);
const [masterPaneController, setMasterPaneController] = useState(new PaneController(props.paneName || MasterPaneName, treeMaster));
treeMaster.onPluginContextChange(() => {
setMasterPaneController(new PaneController(props.paneName || MasterPaneName, treeMaster));
});
return (
<Pane
treeMaster={treeMaster}
controller={masterPaneController}
key={masterPaneController.id}
hideFilter={props.hideFilter}
{...props}
/>
);
}
export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => { export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
const { skeleton, config, canvas, project } = ctx; const { skeleton, config, canvas, project } = ctx;
@ -19,7 +47,6 @@ export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
backupPane: false, backupPane: false,
}; };
const treeMaster = new TreeMaster(ctx, options); const treeMaster = new TreeMaster(ctx, options);
let backupPaneController: PaneController | null = null;
return { return {
async init() { async init() {
skeleton.add({ skeleton.add({
@ -33,22 +60,7 @@ export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
icon: IconOutline, icon: IconOutline,
description: treeMaster.pluginContext.intlNode('Outline Tree'), description: treeMaster.pluginContext.intlNode('Outline Tree'),
}, },
content: function Context(props: any) { content: OutlinePaneContext,
const [masterPaneController, setMasterPaneController] = useState(new PaneController(MasterPaneName, treeMaster));
treeMaster.onPluginContextChange(() => {
setMasterPaneController(new PaneController(MasterPaneName, treeMaster));
});
return (
<Pane
config={config}
treeMaster={treeMaster}
controller={masterPaneController}
key={masterPaneController.id}
{...props}
/>
);
},
}, },
panelProps: { panelProps: {
area: isInFloatArea ? 'leftFloatArea' : 'leftFixedArea', area: isInFloatArea ? 'leftFloatArea' : 'leftFixedArea',
@ -57,6 +69,8 @@ export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
}, },
contentProps: { contentProps: {
treeTitleExtra: config.get('treeTitleExtra'), treeTitleExtra: config.get('treeTitleExtra'),
treeMaster,
paneName: MasterPaneName,
}, },
}); });
@ -67,15 +81,10 @@ export const OutlinePlugin = (ctx: IPublicModelPluginContext, options: any) => {
props: { props: {
hiddenWhenInit: true, hiddenWhenInit: true,
}, },
content: (props: any) => { content: OutlinePaneContext,
backupPaneController = new PaneController(BackupPaneName, treeMaster); contentProps: {
return ( paneName: BackupPaneName,
<Pane treeMaster,
treeMaster={treeMaster}
controller={backupPaneController}
{...props}
/>
);
}, },
}); });

View File

@ -51,7 +51,6 @@ export default class Filter extends PureComponent<{
return ( return (
<div className="lc-outline-filter"> <div className="lc-outline-filter">
{/* @ts-ignore */}
<Search <Search
hasClear hasClear
shape="simple" shape="simple"
@ -60,7 +59,6 @@ export default class Filter extends PureComponent<{
value={keywords} value={keywords}
onChange={this.handleSearchChange} onChange={this.handleSearchChange}
/> />
{/* @ts-ignore */}
<Balloon <Balloon
v2 v2
align="br" align="br"
@ -72,7 +70,6 @@ export default class Filter extends PureComponent<{
</div> </div>
)} )}
> >
{/* @ts-ignore */}
<Checkbox <Checkbox
checked={checkAll} checked={checkAll}
indeterminate={indeterminate} indeterminate={indeterminate}
@ -80,9 +77,7 @@ export default class Filter extends PureComponent<{
> >
{this.props.tree.pluginContext.intlNode('Check All')} {this.props.tree.pluginContext.intlNode('Check All')}
</Checkbox> </Checkbox>
{/* @ts-ignore */}
<Divider /> <Divider />
{/* @ts-ignore */}
<Checkbox.Group <Checkbox.Group
value={filterOps} value={filterOps}
direction="ver" direction="ver"

View File

@ -9,9 +9,9 @@ import { Tree } from '../controllers/tree';
import { IPublicTypeDisposable } from '@alilc/lowcode-types'; import { IPublicTypeDisposable } from '@alilc/lowcode-types';
export class Pane extends PureComponent<{ export class Pane extends PureComponent<{
config: any;
treeMaster: TreeMaster; treeMaster: TreeMaster;
controller: PaneController; controller: PaneController;
hideFilter?: boolean;
}, { }, {
tree: Tree | null; tree: Tree | null;
}> { }> {
@ -26,6 +26,11 @@ export class Pane extends PureComponent<{
this.state = { this.state = {
tree: treeMaster.currentTree, tree: treeMaster.currentTree,
}; };
this.dispose = this.props.treeMaster.pluginContext?.project?.onSimulatorRendererReady(() => {
this.setState({
tree: this.props.treeMaster.currentTree,
});
});
} }
componentWillUnmount() { componentWillUnmount() {
@ -33,14 +38,6 @@ export class Pane extends PureComponent<{
this.dispose && this.dispose(); this.dispose && this.dispose();
} }
componentDidMount() {
this.dispose = this.props.treeMaster.pluginContext.project.onSimulatorRendererReady(() => {
this.setState({
tree: this.props.treeMaster.currentTree,
});
});
}
render() { render() {
const tree = this.state.tree; const tree = this.state.tree;
@ -48,7 +45,6 @@ export class Pane extends PureComponent<{
return ( return (
<div className="lc-outline-pane"> <div className="lc-outline-pane">
<p className="lc-outline-notice"> <p className="lc-outline-notice">
{/* @ts-ignore */}
<Loading <Loading
style={{ style={{
display: 'block', display: 'block',
@ -63,8 +59,8 @@ export class Pane extends PureComponent<{
return ( return (
<div className="lc-outline-pane"> <div className="lc-outline-pane">
<Filter tree={tree} /> { !this.props.hideFilter && <Filter tree={tree} /> }
<div ref={(shell) => this.controller.mount(shell)} className="lc-outline-tree-container"> <div ref={(shell) => this.controller.mount(shell)} className={`lc-outline-tree-container ${ this.props.hideFilter ? 'lc-hidden-outline-filter' : '' }`}>
<TreeView key={tree.id} tree={tree} /> <TreeView key={tree.id} tree={tree} />
</div> </div>
</div> </div>

View File

@ -14,10 +14,14 @@
overflow: auto; overflow: auto;
} }
> .lc-outline-tree-container.lc-hidden-outline-filter {
top: 0;
}
> .lc-outline-filter { > .lc-outline-filter {
padding: 12px 16px; padding: 12px 16px;
display: flex; display: flex;
align-items: center; align-items: stretch;
justify-content: right; justify-content: right;
.lc-outline-filter-search-input { .lc-outline-filter-search-input {
@ -27,7 +31,6 @@
.lc-outline-filter-icon { .lc-outline-filter-icon {
background: #ebecf0; background: #ebecf0;
border: 1px solid #c4c6cf; border: 1px solid #c4c6cf;
height: 28px;
display: flex; display: flex;
align-items: center; align-items: center;
border-radius: 0 2px 2px 0; border-radius: 0 2px 2px 0;

View File

@ -83,7 +83,6 @@ beforeEach(() => {
}); });
component = renderer.create( component = renderer.create(
// @ts-ignore
<Div _leaf={DivNode}> <Div _leaf={DivNode}>
<Text _leaf={TextNode} content="content"></Text> <Text _leaf={TextNode} content="content"></Text>
</Div> </Div>
@ -238,7 +237,6 @@ describe('mini unit render', () => {
nodeMap.set(textSchema.id, TextNode); nodeMap.set(textSchema.id, TextNode);
component = renderer.create( component = renderer.create(
// @ts-ignore
<MiniRenderDiv _leaf={MiniRenderDivNode}> <MiniRenderDiv _leaf={MiniRenderDivNode}>
<Text _leaf={TextNode} content="content"></Text> <Text _leaf={TextNode} content="content"></Text>
</MiniRenderDiv> </MiniRenderDiv>
@ -285,7 +283,6 @@ describe('mini unit render', () => {
nodeMap.set(textSchema.id, TextNode); nodeMap.set(textSchema.id, TextNode);
renderer.create( renderer.create(
// @ts-ignore
<div> <div>
<Text _leaf={TextNode} content="content"></Text> <Text _leaf={TextNode} content="content"></Text>
</div> </div>
@ -309,7 +306,6 @@ describe('mini unit render', () => {
}); });
renderer.create( renderer.create(
// @ts-ignore
<div> <div>
<Text _leaf={TextNode} content="content"></Text> <Text _leaf={TextNode} content="content"></Text>
</div> </div>
@ -388,7 +384,6 @@ describe('mini unit render', () => {
}; };
const component = renderer.create( const component = renderer.create(
// @ts-ignore
<MiniRenderDiv _leaf={MiniRenderDivNode}> <MiniRenderDiv _leaf={MiniRenderDivNode}>
<Text _leaf={TextNode} content="content"></Text> <Text _leaf={TextNode} content="content"></Text>
</MiniRenderDiv> </MiniRenderDiv>
@ -428,7 +423,6 @@ describe('mini unit render', () => {
nodeMap.set(miniRenderSchema.id, MiniRenderDivNode); nodeMap.set(miniRenderSchema.id, MiniRenderDivNode);
component = renderer.create( component = renderer.create(
// @ts-ignore
<MiniRenderDiv _leaf={MiniRenderDivNode}> <MiniRenderDiv _leaf={MiniRenderDivNode}>
<Text _leaf={TextNode} content="content"></Text> <Text _leaf={TextNode} content="content"></Text>
</MiniRenderDiv> </MiniRenderDiv>
@ -491,7 +485,6 @@ describe('onVisibleChange', () => {
describe('children', () => { describe('children', () => {
it('this.props.children is array', () => { it('this.props.children is array', () => {
const component = renderer.create( const component = renderer.create(
// @ts-ignore
<Div _leaf={DivNode}> <Div _leaf={DivNode}>
<Text _leaf={TextNode} content="content"></Text> <Text _leaf={TextNode} content="content"></Text>
<Text _leaf={TextNode} content="content"></Text> <Text _leaf={TextNode} content="content"></Text>

View File

@ -79,7 +79,6 @@ describe('Base Render methods', () => {
// const originalUtils = jest.requireActual('../../src/utils'); // const originalUtils = jest.requireActual('../../src/utils');
// mockParseExpression.mockImplementation(originalUtils.parseExpression); // mockParseExpression.mockImplementation(originalUtils.parseExpression);
const component = TestRenderer.create( const component = TestRenderer.create(
// @ts-ignore
<RendererClass <RendererClass
__schema={mockSchema} __schema={mockSchema}
components={components as any} components={components as any}

View File

@ -13,7 +13,6 @@ function getComp(schema, comp = null, others = {}): Promise<{
}> { }> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const component = renderer.create( const component = renderer.create(
// @ts-ignore
<Renderer <Renderer
schema={schema} schema={schema}
components={components as any} components={components as any}
@ -48,7 +47,6 @@ afterEach(() => {
describe('Base Render', () => { describe('Base Render', () => {
it('renderComp', () => { it('renderComp', () => {
const content = ( const content = (
// @ts-ignore
<Renderer <Renderer
schema={schema as any} schema={schema as any}
components={components as any} components={components as any}

View File

@ -25,6 +25,10 @@ export class Resource implements IPublicModelResource {
return this[resourceSymbol].resourceType.name; return this[resourceSymbol].resourceType.name;
} }
get config() {
return this[resourceSymbol].config;
}
get type() { get type() {
return this[resourceSymbol].resourceType.type; return this[resourceSymbol].resourceType.type;
} }

View File

@ -44,7 +44,10 @@ export class Window implements IPublicModelWindow {
} }
get currentEditorView() { get currentEditorView() {
return new EditorView(this[windowSymbol].editorView).toProxy() as any; if (this[windowSymbol].editorView) {
return new EditorView(this[windowSymbol].editorView).toProxy() as any;
}
return null;
} }
get editorViews() { get editorViews() {

View File

@ -18,6 +18,10 @@ export interface IBaseModelResource<
get children(): Resource[]; get children(): Resource[];
get viewName(): string | undefined; get viewName(): string | undefined;
get config(): {
disableBehaviors?: ('copy' | 'remove')[];
} | undefined;
} }
export type IPublicModelResource = IBaseModelResource<IPublicModelResource>; export type IPublicModelResource = IBaseModelResource<IPublicModelResource>;

View File

@ -23,7 +23,7 @@ export interface IPublicModelWindow<
* *
* @since v1.1.7 * @since v1.1.7
*/ */
currentEditorView: IPublicModelEditorView; currentEditorView: IPublicModelEditorView | null;
/** /**
* *

View File

@ -24,6 +24,10 @@ export interface IPublicResourceData {
/** 资源子元素 */ /** 资源子元素 */
children?: IPublicResourceData[]; children?: IPublicResourceData[];
config?: {
disableBehaviors?: ('copy' | 'remove')[];
};
} }
export type IPublicResourceList = IPublicResourceData[]; export type IPublicResourceList = IPublicResourceData[];

View File

@ -101,7 +101,7 @@ export class BasicContext implements IBasicContext {
preference: IPluginPreferenceMananger; preference: IPluginPreferenceMananger;
workspace: IWorkspace; workspace: IWorkspace;
constructor(innerWorkspace: IWorkspace, viewName: string, registerLevel: IPublicEnumPluginRegisterLevel, public editorWindow?: IEditorWindow) { constructor(innerWorkspace: IWorkspace, viewName: string, readonly registerLevel: IPublicEnumPluginRegisterLevel, public editorWindow?: IEditorWindow) {
const editor = new Editor(viewName, true); const editor = new Editor(viewName, true);
const innerSkeleton = new InnerSkeleton(editor, viewName); const innerSkeleton = new InnerSkeleton(editor, viewName);

View File

@ -74,6 +74,10 @@ export class Resource implements IResource {
return this.resourceData?.children?.map(d => new Resource(d, this.workspace.getResourceType(d.resourceName || this.resourceType.name), this.workspace)) || []; return this.resourceData?.children?.map(d => new Resource(d, this.workspace.getResourceType(d.resourceName || this.resourceType.name), this.workspace)) || [];
} }
get config() {
return this.resourceData.config;
}
constructor(readonly resourceData: IPublicResourceData, readonly resourceType: IResourceType, readonly workspace: IWorkspace) { constructor(readonly resourceData: IPublicResourceData, readonly resourceType: IResourceType, readonly workspace: IWorkspace) {
this.context = new BasicContext(workspace, `resource-${resourceData.resourceName || resourceType.name}`, IPublicEnumPluginRegisterLevel.Resource); this.context = new BasicContext(workspace, `resource-${resourceData.resourceName || resourceType.name}`, IPublicEnumPluginRegisterLevel.Resource);
this.resourceTypeInstance = resourceType.resourceTypeModel(this.context.innerPlugins._getLowCodePluginContext({ this.resourceTypeInstance = resourceType.resourceTypeModel(this.context.innerPlugins._getLowCodePluginContext({

View File

@ -192,8 +192,8 @@ export class Workspace implements IWorkspace {
this.emitChangeWindow(); this.emitChangeWindow();
} }
removeEditorWindow(resourceName: string) { removeEditorWindow(resourceName: string, title: string) {
const index = this.windows.findIndex(d => (d.resource?.name === resourceName && d.title)); const index = this.windows.findIndex(d => (d.resource?.name === resourceName && d.title === title));
this.remove(index); this.remove(index);
} }