import React, { useEffect } from 'react'; import * as ProLayout from '../src/index'; import { Balloon } from '@alifd/next'; import hoistNonReactStatic from 'hoist-non-react-statics'; import { getDefaultBlockCellSchema, getDefaultBlockSchema } from './common/const'; import { performRowColSideEffects } from './common/auto-row-col-side-effects'; import { initSingletonDivider } from './common/divider'; import './index.scss'; const { Tooltip } = Balloon; const { Page, Block, BlockCell, BlockCellItem, P, Text, PageHeader, PageFooter, PageContent, PageNav, PageAside, Row, Col, RowColContainer, ProCard, } = ProLayout; const FUSION_UI_VIEW_PREFIX = 'pro-layout-view'; const AddSection = ({ onClick }) => { return (
添加内容区域
); }; const PageView = (props) => { const { children, _leaf, ...others } = props; const isTab = _leaf.getProps().getPropValue('isTab'); const addNewSection = () => { _leaf.insertAfter(getDefaultBlockSchema()); }; return ( {children} {!isTab && } ); }; const BlockView = (props) => { const { children, _leaf, ...others } = props; const addNewBlockCell = () => { const blockCellSchema = getDefaultBlockCellSchema(); if (_leaf.parent.componentName === 'Slot') { blockCellSchema.props.colSpan = 1; } const newNode = _leaf.document.createNode(blockCellSchema); _leaf.insertAfter(newNode); newNode.select(); }; useEffect(() => { initSingletonDivider(); }, []); return ( <> {children}
} > 添加区块 ); }; const BlockCellView = (props) => { const { children, _leaf, ...others } = props; let divider = null; // 在没有 children 并且宽度符合要求的情况下 const originColSpan = _leaf.schema.props.colSpan; // if (!_leaf.exportSchema().children && originColSpan > 2) { if (originColSpan > 2) { divider = (
); } return ( {children} {/* {divider} */} ); }; const BlockCellItemView = (props) => { return ; }; const TextView = (props) => { return ; }; const PView = (props) => { return

; }; const PageHeaderView = (props) => { return ; }; const PageFooterView = (props) => { return ; }; const PageContentView = (props) => { const { children, _leaf, ...others } = props; const addNewSection = () => { _leaf.insertAfter(getDefaultBlockSchema()); }; return ( {children} ); }; const PageNavView = (props) => { return ; }; const PageAsideView = (props) => { return ; }; const RowView = (props) => { const { children, ...rest } = props; return ( <> {children} ); }; const ColView = (props) => { const { _leaf, children, ...rest } = props; return ( <> {children} ); }; const RowColContainerView = (props) => { const { _leaf, children, ...rest } = props; useEffect(() => { initSingletonDivider(); performRowColSideEffects((window.parent as any).AliLowCodeEngine); }, []); return ( <> {children} ); }; hoistNonReactStatic(PageView, Page); hoistNonReactStatic(BlockView, Block); hoistNonReactStatic(BlockCellView, BlockCell); hoistNonReactStatic(BlockCellItemView, BlockCellItem); hoistNonReactStatic(TextView, Text); hoistNonReactStatic(PView, P); hoistNonReactStatic(RowView, Row); hoistNonReactStatic(ColView, Col); hoistNonReactStatic(RowColContainerView, RowColContainer); hoistNonReactStatic(PageHeaderView, PageHeader); hoistNonReactStatic(PageFooterView, PageFooter); hoistNonReactStatic(PageContentView, PageContent); hoistNonReactStatic(PageAsideView, PageAside); hoistNonReactStatic(PageNavView, PageNav); export { PageView as Page, BlockView as Block, BlockCellView as BlockCell, BlockCellItemView as BlockCellItem, TextView as Text, PView as P, RowView as Row, ColView as Col, RowColContainerView as RowColContainer, PageHeaderView as PageHeader, PageFooterView as PageFooter, PageContentView as PageContent, PageAsideView as PageAside, PageNavView as PageNav, ProCard, };