vendor: amis 6.13.0 base (fork root)
3
packages/amis-editor/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
/coverage
|
||||
/lib
|
||||
/esm
|
||||
25
packages/amis-editor/examples/App.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import * as React from 'react';
|
||||
import {AlertComponent, ToastComponent, ContextMenu} from 'amis';
|
||||
// @ts-ignore
|
||||
import AMisSchemaEditor from './Editor';
|
||||
import {Link} from 'react-router-dom';
|
||||
export default class App extends React.PureComponent {
|
||||
render() {
|
||||
// 备注: 如果需要改用antd主题,还需要将index.html换成index-antd.html
|
||||
const curTheme = 'cxd'; // 默认使用cxd主题
|
||||
return (
|
||||
<div className="Editor-Demo">
|
||||
<div id="headerBar" className="Editor-header">
|
||||
<div className="Editor-title">
|
||||
amis 可视化编辑器
|
||||
<Link to="/basic">面板模版</Link>
|
||||
</div>
|
||||
</div>
|
||||
<AMisSchemaEditor theme={curTheme} />
|
||||
<ToastComponent theme={curTheme} />
|
||||
<AlertComponent theme={curTheme} />
|
||||
<ContextMenu theme={curTheme} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
853
packages/amis-editor/examples/Editor.tsx
Normal file
@@ -0,0 +1,853 @@
|
||||
/* eslint-disable */
|
||||
import * as React from 'react';
|
||||
import {
|
||||
Editor,
|
||||
ShortcutKey,
|
||||
BasePlugin,
|
||||
setThemeConfig,
|
||||
PluginEvent,
|
||||
GlobalVariableEventContext,
|
||||
GlobalVariablesEventContext
|
||||
} from '../src/index';
|
||||
import {Select, Renderer, uuid, Button} from 'amis';
|
||||
import {currentLocale} from 'i18n-runtime';
|
||||
import {Portal} from 'react-overlays';
|
||||
import {Icon} from './icons/index';
|
||||
import LayoutList from './layout/index';
|
||||
import {cxdData} from 'amis-theme-editor-helper';
|
||||
|
||||
// 测试组织属性配置面板的国际化,可以放开如下注释
|
||||
// import './renderer/InputTextI18n';
|
||||
// import './renderer/TextareaI18n';
|
||||
// import './utils/overwriteSchemaTpl';
|
||||
// const i18nEnabled = true;
|
||||
const i18nEnabled = false;
|
||||
setThemeConfig(cxdData);
|
||||
|
||||
const schema = {
|
||||
type: 'page',
|
||||
title: 'Simple Form Page',
|
||||
regions: ['body'],
|
||||
body: [
|
||||
{
|
||||
type: 'form',
|
||||
body: [
|
||||
{
|
||||
type: 'input-text',
|
||||
name: 'a',
|
||||
label: 'Text'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
const formSchema = {
|
||||
type: 'doc-entity',
|
||||
fields: []
|
||||
};
|
||||
|
||||
const schemas = [
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
'amisUser': {
|
||||
type: 'object',
|
||||
title: '用户信息',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
title: '用户ID'
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
title: '用户名'
|
||||
},
|
||||
email: {
|
||||
type: 'string',
|
||||
title: '邮箱'
|
||||
},
|
||||
nickName: {
|
||||
type: 'string',
|
||||
title: '昵称'
|
||||
},
|
||||
phone: {
|
||||
type: 'string',
|
||||
title: '手机号'
|
||||
},
|
||||
avatar: {
|
||||
type: 'string',
|
||||
title: '用户头像'
|
||||
}
|
||||
}
|
||||
},
|
||||
'amisApp': {
|
||||
type: 'object',
|
||||
title: '应用信息',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
title: '应用ID'
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
title: '应用名称'
|
||||
},
|
||||
logo: {
|
||||
type: 'string',
|
||||
title: '应用Logo'
|
||||
},
|
||||
env: {
|
||||
type: 'string',
|
||||
title: '当前运行环境'
|
||||
}
|
||||
}
|
||||
},
|
||||
'amisCompany': {
|
||||
type: 'object',
|
||||
title: '组织信息',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
title: '组织ID'
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
title: '组织名称'
|
||||
},
|
||||
logo: {
|
||||
type: 'string',
|
||||
title: '组织Logo'
|
||||
},
|
||||
key: {
|
||||
type: 'string',
|
||||
title: '组织标识'
|
||||
}
|
||||
}
|
||||
},
|
||||
'window:location': {
|
||||
type: 'object',
|
||||
title: '浏览器变量',
|
||||
properties: {
|
||||
href: {
|
||||
type: 'string',
|
||||
title: 'href'
|
||||
},
|
||||
origin: {
|
||||
type: 'string',
|
||||
title: 'origin'
|
||||
},
|
||||
protocol: {
|
||||
type: 'string',
|
||||
title: 'protocol'
|
||||
},
|
||||
host: {
|
||||
type: 'string',
|
||||
title: 'host'
|
||||
},
|
||||
hostname: {
|
||||
type: 'string',
|
||||
title: 'hostname'
|
||||
},
|
||||
port: {
|
||||
type: 'string',
|
||||
title: 'port'
|
||||
},
|
||||
pathname: {
|
||||
type: 'string',
|
||||
title: 'pathname'
|
||||
},
|
||||
search: {
|
||||
type: 'string',
|
||||
title: 'search'
|
||||
},
|
||||
hash: {
|
||||
type: 'string',
|
||||
title: 'hash'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
properties: {
|
||||
__query: {
|
||||
title: '页面入参',
|
||||
type: 'object',
|
||||
required: [],
|
||||
properties: {
|
||||
name: {
|
||||
type: 'string',
|
||||
title: '用户名'
|
||||
}
|
||||
}
|
||||
},
|
||||
__page: {
|
||||
title: '页面变量',
|
||||
type: 'object',
|
||||
required: [],
|
||||
properties: {
|
||||
num: {
|
||||
type: 'number',
|
||||
title: '数量'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
const variableSchemas = {
|
||||
type: 'object',
|
||||
$id: 'appVariables',
|
||||
properties: {
|
||||
ProductName: {
|
||||
type: 'string',
|
||||
title: '产品名称',
|
||||
default: '对象存储'
|
||||
},
|
||||
Banlance: {
|
||||
type: 'number',
|
||||
title: '账户余额',
|
||||
default: '0.00'
|
||||
},
|
||||
ProductNum: {
|
||||
type: 'integer',
|
||||
title: '产品数量',
|
||||
default: '0.00'
|
||||
},
|
||||
isOnline: {
|
||||
type: 'boolean',
|
||||
title: '是否线上环境',
|
||||
default: 'false'
|
||||
},
|
||||
ProductList: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
title: '产品名称'
|
||||
},
|
||||
title: '产品列表',
|
||||
default: '["BOS", "CFS", "PFS", "CloudFlow", "MongoDB"]'
|
||||
},
|
||||
PROFILE: {
|
||||
type: 'object',
|
||||
title: '个人信息',
|
||||
properties: {
|
||||
FirstName: {
|
||||
type: 'string',
|
||||
title: '名字'
|
||||
},
|
||||
Age: {
|
||||
type: 'integer',
|
||||
title: '年龄'
|
||||
},
|
||||
Address: {
|
||||
type: 'object',
|
||||
title: '地址',
|
||||
required: ['street', 'postcode'],
|
||||
properties: {
|
||||
street: {
|
||||
type: 'string',
|
||||
title: '街道名称'
|
||||
},
|
||||
postcode: {
|
||||
type: 'number',
|
||||
title: '邮编'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
default: {
|
||||
ProductName: 'BCC',
|
||||
Banlance: 1234.888,
|
||||
ProductNum: 10,
|
||||
isOnline: false,
|
||||
ProductList: ['BCC', 'BOS', 'VPC'],
|
||||
PROFILE: {
|
||||
FirstName: 'Amis',
|
||||
Age: 18,
|
||||
Address: {
|
||||
street: 'ShangDi',
|
||||
postcode: 100001
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const variableDefaultData = {
|
||||
appVariables: {
|
||||
ProductName: 'BCC',
|
||||
Banlance: 1234.888,
|
||||
ProductNum: 10,
|
||||
isOnline: false,
|
||||
ProductList: ['BCC', 'BOS', 'VPC'],
|
||||
PROFILE: {
|
||||
FirstName: 'Amis',
|
||||
Age: 18,
|
||||
Address: {
|
||||
street: 'ShangDi',
|
||||
postcode: 100001
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const variables: any = [
|
||||
{
|
||||
name: 'appVariables',
|
||||
title: '内存变量',
|
||||
parentId: 'root',
|
||||
order: 1,
|
||||
schema: variableSchemas
|
||||
}
|
||||
];
|
||||
|
||||
const EditorType = {
|
||||
EDITOR: 'editor',
|
||||
MOBILE: 'mobile',
|
||||
FORM: 'form'
|
||||
};
|
||||
|
||||
const editorLanguages = [
|
||||
{
|
||||
label: '简体中文',
|
||||
value: 'zh-CN'
|
||||
},
|
||||
{
|
||||
label: 'English',
|
||||
value: 'en-US'
|
||||
}
|
||||
];
|
||||
|
||||
const globalEvents = [
|
||||
{
|
||||
name: 'globalEventA',
|
||||
label: '全局事件A',
|
||||
description: '全局事件动作A',
|
||||
mapping: [
|
||||
{
|
||||
key: 'name',
|
||||
type: 'string'
|
||||
},
|
||||
{
|
||||
key: 'age',
|
||||
type: 'number'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'globalEventB',
|
||||
label: '全局事件B',
|
||||
description: '全局事件动作A',
|
||||
mapping: [
|
||||
{
|
||||
key: 'name',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
/**
|
||||
* 自定义渲染器示例
|
||||
*/
|
||||
// @Renderer({
|
||||
// type: 'my-renderer',
|
||||
// name: 'my-renderer'
|
||||
// })
|
||||
// export class MyRenderer extends React.Component {
|
||||
// static defaultProps = {
|
||||
// target: 'world'
|
||||
// };
|
||||
|
||||
// render() {
|
||||
// const {target, width, height} = this.props;
|
||||
|
||||
// return (
|
||||
// <p style={{width: width || 'auto', height: height || 'auto'}}>
|
||||
// Hello {target}!
|
||||
// </p>
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 自定义渲染器编辑插件
|
||||
*/
|
||||
class MyRendererPlugin extends BasePlugin {
|
||||
// 这里要跟对应的渲染器名字对应上
|
||||
// 注册渲染器的时候会要求指定渲染器名字
|
||||
rendererName = 'my-renderer';
|
||||
|
||||
// 暂时只支持这个,配置后会开启代码编辑器
|
||||
$schema = '/schemas/UnkownSchema.json';
|
||||
|
||||
// 用来配置名称和描述
|
||||
name = '自定义渲染器';
|
||||
description = '这只是个示例';
|
||||
|
||||
// tag,决定会在哪个 tab 下面显示的
|
||||
tags = ['自定义', '表单项'];
|
||||
|
||||
// 图标
|
||||
icon = 'fa fa-user';
|
||||
|
||||
// 用来生成预览图的
|
||||
previewSchema = {
|
||||
type: 'my-renderer',
|
||||
target: 'demo'
|
||||
};
|
||||
|
||||
// 拖入组件里面时的初始数据
|
||||
scaffold = {
|
||||
type: 'my-renderer',
|
||||
target: '233'
|
||||
};
|
||||
|
||||
// 右侧面板相关
|
||||
panelTitle = '自定义组件';
|
||||
panelBody = [
|
||||
{
|
||||
type: 'tabs',
|
||||
tabsMode: 'line',
|
||||
className: 'm-t-n-xs',
|
||||
contentClassName: 'no-border p-l-none p-r-none',
|
||||
tabs: [
|
||||
{
|
||||
title: '常规',
|
||||
body: [
|
||||
{
|
||||
name: 'target',
|
||||
label: 'Target',
|
||||
type: 'input-text'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
title: '外观',
|
||||
body: []
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// /**
|
||||
// * 配置了 panelControls 自动生成配置面板
|
||||
// * @param context
|
||||
// * @param panels
|
||||
// */
|
||||
// buildEditorPanel(context, panels) {
|
||||
// panels.push({
|
||||
// key: 'xxxx',
|
||||
// title: '设置',
|
||||
// render: () => {
|
||||
// return <div>面板内容</div>;
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// scaffoldForm = {
|
||||
// title: '标题',
|
||||
// body: [
|
||||
// {
|
||||
// name: 'target',
|
||||
// label: 'Target',
|
||||
// type: 'input-text'
|
||||
// }
|
||||
// ]
|
||||
// };
|
||||
|
||||
// onActive(event) {
|
||||
// const context = event.context;
|
||||
|
||||
// if (context.info?.plugin !== this || !context.node) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// const node = context.node;
|
||||
// node.setHeightMutable(true);
|
||||
// node.setWidthMutable(true);
|
||||
// }
|
||||
|
||||
// onWidthChangeStart(event) {
|
||||
// return this.onSizeChangeStart(event, 'horizontal');
|
||||
// }
|
||||
|
||||
// onHeightChangeStart(event) {
|
||||
// return this.onSizeChangeStart(event, 'vertical');
|
||||
// }
|
||||
|
||||
// onSizeChangeStart(event, direction = 'both') {
|
||||
// const context = event.context;
|
||||
// const node = context.node;
|
||||
// if (node.info?.plugin !== this) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// const resizer = context.resizer;
|
||||
// const dom = context.dom;
|
||||
// const frameRect = dom.parentElement.getBoundingClientRect();
|
||||
// const rect = dom.getBoundingClientRect();
|
||||
// const startX = context.nativeEvent.pageX;
|
||||
// const startY = context.nativeEvent.pageY;
|
||||
|
||||
// event.setData({
|
||||
// onMove: e => {
|
||||
// const dy = e.pageY - startY;
|
||||
// const dx = e.pageX - startX;
|
||||
// const height = Math.max(50, rect.height + dy);
|
||||
// const width = Math.max(100, Math.min(rect.width + dx, frameRect.width));
|
||||
// const state = {
|
||||
// width,
|
||||
// height
|
||||
// };
|
||||
|
||||
// if (direction === 'both') {
|
||||
// resizer.setAttribute('data-value', `${width}px x ${height}px`);
|
||||
// } else if (direction === 'vertical') {
|
||||
// resizer.setAttribute('data-value', `${height}px`);
|
||||
// delete state.width;
|
||||
// } else {
|
||||
// resizer.setAttribute('data-value', `${width}px`);
|
||||
// delete state.height;
|
||||
// }
|
||||
|
||||
// node.updateState(state);
|
||||
|
||||
// requestAnimationFrame(() => {
|
||||
// node.calculateHighlightBox();
|
||||
// });
|
||||
// },
|
||||
// onEnd: e => {
|
||||
// const dy = e.pageY - startY;
|
||||
// const dx = e.pageX - startX;
|
||||
// const height = Math.max(50, rect.height + dy);
|
||||
// const width = Math.max(100, Math.min(rect.width + dx, frameRect.width));
|
||||
// const state = {
|
||||
// width,
|
||||
// height
|
||||
// };
|
||||
|
||||
// if (direction === 'vertical') {
|
||||
// delete state.width;
|
||||
// } else if (direction === 'horizontal') {
|
||||
// delete state.height;
|
||||
// }
|
||||
|
||||
// resizer.removeAttribute('data-value');
|
||||
// node.updateSchema(state);
|
||||
// requestAnimationFrame(() => {
|
||||
// node.calculateHighlightBox();
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
popOverBody = [
|
||||
{
|
||||
name: 'target',
|
||||
label: 'Target',
|
||||
type: 'input-text'
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
LayoutList.push(MyRendererPlugin);
|
||||
|
||||
export default class AMisSchemaEditor extends React.Component<any, any> {
|
||||
state: any = {
|
||||
preview: localStorage.getItem('editting_preview') ? true : false,
|
||||
type: localStorage.getItem('editting_preview_type') || EditorType.EDITOR,
|
||||
schema: localStorage.getItem('editting_schema')
|
||||
? JSON.parse(localStorage.getItem('editting_schema')!)
|
||||
: schema,
|
||||
curLanguage: currentLocale() // 获取当前语料类型
|
||||
};
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
|
||||
if (i18nEnabled) {
|
||||
this.state = {
|
||||
...this.state,
|
||||
replaceText: {
|
||||
'i18n:1189fb5d-ac5b-4558-b363-068ce5decc99': uuid()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const type =
|
||||
localStorage.getItem('editting_preview_type') || EditorType.EDITOR;
|
||||
|
||||
this.state.schema = this.getSchema(type);
|
||||
}
|
||||
|
||||
getSchema(type: string) {
|
||||
if (type === EditorType.FORM) {
|
||||
const schema = localStorage.getItem('editting_schema_form');
|
||||
|
||||
if (schema) {
|
||||
return JSON.parse(schema);
|
||||
}
|
||||
return formSchema;
|
||||
}
|
||||
|
||||
const lsSchema = localStorage.getItem('editting_schema');
|
||||
|
||||
if (lsSchema) {
|
||||
return JSON.parse(lsSchema);
|
||||
}
|
||||
|
||||
return schema;
|
||||
}
|
||||
|
||||
handleChange = (value: any) => {
|
||||
const type = this.state.type;
|
||||
|
||||
if (type === EditorType.FORM) {
|
||||
localStorage.setItem('editting_schema_form', JSON.stringify(value));
|
||||
} else {
|
||||
localStorage.setItem('editting_schema', JSON.stringify(value));
|
||||
}
|
||||
|
||||
this.setState({
|
||||
schema: value
|
||||
});
|
||||
};
|
||||
|
||||
changeLocale(value: any) {
|
||||
localStorage.setItem('suda-i18n-locale', value);
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
onSave = () => {
|
||||
const curSchema = this.state.schema;
|
||||
localStorage.setItem('editting_schema', JSON.stringify(curSchema));
|
||||
};
|
||||
|
||||
handlePreviewChange = (preview: any) => {
|
||||
localStorage.setItem('editting_preview', preview ? 'true' : '');
|
||||
|
||||
this.setState({
|
||||
preview: !!preview
|
||||
});
|
||||
};
|
||||
|
||||
togglePreview = () => {
|
||||
this.handlePreviewChange(!this.state.preview);
|
||||
};
|
||||
|
||||
handleTypeChange = (editorType: any) => {
|
||||
const type = editorType || EditorType.EDITOR;
|
||||
localStorage.setItem('editting_preview_type', type);
|
||||
|
||||
this.setState({
|
||||
type: type,
|
||||
schema: this.getSchema(type)
|
||||
});
|
||||
};
|
||||
|
||||
clearCache = () => {
|
||||
localStorage.removeItem('editting_schema');
|
||||
this.setState({
|
||||
schema: schema
|
||||
});
|
||||
};
|
||||
|
||||
renderEditor() {
|
||||
const {theme} = this.props;
|
||||
const {preview, type, schema} = this.state;
|
||||
const isMobile = type === EditorType.MOBILE;
|
||||
const {replaceText} = this.state;
|
||||
|
||||
return (
|
||||
<Editor
|
||||
preview={preview}
|
||||
isMobile={isMobile}
|
||||
value={schema}
|
||||
schemas={schemas}
|
||||
variables={variables}
|
||||
onChange={this.handleChange}
|
||||
onPreview={this.handlePreviewChange}
|
||||
onSave={this.onSave}
|
||||
className="is-fixed"
|
||||
i18nEnabled={i18nEnabled}
|
||||
theme={theme || 'cxd'}
|
||||
showCustomRenderersPanel={true}
|
||||
plugins={LayoutList} // 存放常见布局组件
|
||||
$schemaUrl={`${location.protocol}//${location.host}/schema.json`}
|
||||
actionOptions={{
|
||||
showOldEntry: false,
|
||||
globalEventGetter: () => globalEvents
|
||||
}}
|
||||
onGlobalVariableInit={onGlobalVariableInit}
|
||||
onGlobalVariableSave={onGlobalVariableSave}
|
||||
onGlobalVariableDelete={onGlobalVariableDelete}
|
||||
amisEnv={
|
||||
{
|
||||
variable: {
|
||||
id: 'appVariables',
|
||||
namespace: 'appVariables',
|
||||
schema: variableSchemas,
|
||||
data: variableDefaultData
|
||||
},
|
||||
replaceText
|
||||
} as any
|
||||
}
|
||||
ctx={{
|
||||
__page: {
|
||||
num: 2
|
||||
},
|
||||
...variableDefaultData
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {preview, type, curLanguage} = this.state;
|
||||
return (
|
||||
<div className="Editor-inner">
|
||||
<Portal container={() => document.querySelector('#headerBar') as any}>
|
||||
<>
|
||||
<div className="Editor-view-mode-group-container">
|
||||
<div className="Editor-view-mode-group">
|
||||
<div
|
||||
className={`Editor-view-mode-btn ${
|
||||
type === EditorType.EDITOR ? 'is-active' : ''
|
||||
}`}
|
||||
onClick={() => {
|
||||
this.handleTypeChange(EditorType.EDITOR);
|
||||
}}
|
||||
>
|
||||
<Icon icon="pc-preview" title="PC模式" />
|
||||
</div>
|
||||
<div
|
||||
className={`Editor-view-mode-btn ${
|
||||
type === EditorType.MOBILE ? 'is-active' : ''
|
||||
}`}
|
||||
onClick={() => {
|
||||
this.handleTypeChange(EditorType.MOBILE);
|
||||
}}
|
||||
>
|
||||
<Icon icon="h5-preview" title="移动模式" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="Editor-header-actions">
|
||||
<ShortcutKey />
|
||||
{
|
||||
// @ts-ignore
|
||||
// vite编译时替换
|
||||
__editor_i18n ? (
|
||||
<Select
|
||||
className="margin-left-space "
|
||||
options={editorLanguages}
|
||||
value={curLanguage}
|
||||
clearable={false}
|
||||
onChange={(e: any) => this.changeLocale(e.value)}
|
||||
/>
|
||||
) : null
|
||||
}
|
||||
|
||||
{i18nEnabled && (
|
||||
<Button
|
||||
className="ml-2"
|
||||
level="info"
|
||||
onClick={() => {
|
||||
let _uuid = uuid();
|
||||
console.log('点击测试国际化按钮', _uuid);
|
||||
this.setState({
|
||||
appLocale: _uuid,
|
||||
replaceText: {
|
||||
'i18n:1189fb5d-ac5b-4558-b363-068ce5decc99': _uuid
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
切换语料内容
|
||||
</Button>
|
||||
)}
|
||||
|
||||
<div
|
||||
className={`header-action-btn ${preview ? 'primary' : ''}`}
|
||||
onClick={() => {
|
||||
this.togglePreview();
|
||||
}}
|
||||
>
|
||||
{preview ? '编辑' : '预览'}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
</Portal>
|
||||
|
||||
{this.renderEditor()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 通过 localstorage 存储全局变量
|
||||
// 实际场景肯定是后端存储到数据库里面
|
||||
// 可以参考这个利用这三个事件来实现全局变量的增删改查
|
||||
function getGlobalVariablesFromStorage(): Array<any> {
|
||||
const key = 'amis-editor-example-global-variable';
|
||||
let globalVariables = localStorage.getItem(key);
|
||||
let variables: Array<any> = [];
|
||||
|
||||
if (globalVariables) {
|
||||
variables = JSON.parse(globalVariables);
|
||||
}
|
||||
|
||||
return variables;
|
||||
}
|
||||
|
||||
function saveGlobalVariablesToStorage(variables: Array<any>) {
|
||||
const key = 'amis-editor-example-global-variable';
|
||||
localStorage.setItem(key, JSON.stringify(variables));
|
||||
}
|
||||
|
||||
function onGlobalVariableInit(event: PluginEvent<GlobalVariablesEventContext>) {
|
||||
event.setData(getGlobalVariablesFromStorage() || []);
|
||||
}
|
||||
|
||||
function onGlobalVariableSave(event: PluginEvent<GlobalVariableEventContext>) {
|
||||
const item = event.data;
|
||||
const variables = getGlobalVariablesFromStorage();
|
||||
const idx = item.id
|
||||
? variables.findIndex((it: any) => it.id === item.id)
|
||||
: -1;
|
||||
|
||||
if (idx === -1) {
|
||||
item.id = uuid();
|
||||
variables.push(item);
|
||||
} else {
|
||||
variables[idx] = item;
|
||||
}
|
||||
|
||||
saveGlobalVariablesToStorage(variables);
|
||||
}
|
||||
|
||||
function onGlobalVariableDelete(
|
||||
event: PluginEvent<GlobalVariableEventContext>
|
||||
) {
|
||||
const item = event.data;
|
||||
const variables = getGlobalVariablesFromStorage();
|
||||
const idx = item.id
|
||||
? variables.findIndex((it: any) => it.id === item.id)
|
||||
: -1;
|
||||
|
||||
if (idx === -1) {
|
||||
return;
|
||||
} else {
|
||||
variables.splice(idx, 1);
|
||||
}
|
||||
|
||||
saveGlobalVariablesToStorage(variables);
|
||||
}
|
||||
561
packages/amis-editor/examples/_corpus-i18n.scss
Normal file
@@ -0,0 +1,561 @@
|
||||
$ns: cxd-;
|
||||
|
||||
.#{$ns}InputI18n-container {
|
||||
.#{$ns}InputI18n-inner-container {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.#{$ns}InputI18n-addon-container {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
height: calc(100% - 2px);
|
||||
right: 1px;
|
||||
background: #f7f7f9;
|
||||
border-radius: 0px 3px 3px 0px;
|
||||
width: 30px;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--Form-input-borderColor) !important;
|
||||
background: #e6f0ff !important;
|
||||
}
|
||||
|
||||
.CorpusI18n-input-icon.icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
|
||||
.#{$ns}InputI18n-addon-active {
|
||||
background: #e6f0ff;
|
||||
color: var(--link-color);
|
||||
}
|
||||
|
||||
.#{$ns}InputI18n-fx-container {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
height: calc(100% - 2px);
|
||||
right: 1px;
|
||||
border-radius: 0px 3px 3px 0px;
|
||||
width: 30px;
|
||||
cursor: pointer;
|
||||
|
||||
.CorpusI18n-input-icon.icon {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-60%, -50%);
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.#{$ns}InputI18n-fx-active {
|
||||
color: var(--link-color);
|
||||
}
|
||||
|
||||
.#{$ns}InputI18n-overlay {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
bottom: 1px;
|
||||
right: 31px;
|
||||
width: calc(100% - 32px);
|
||||
height: calc(100% - 2px);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.#{$ns}InputI18n-multi-container {
|
||||
.#{$ns}InputBox {
|
||||
input {
|
||||
padding-right: 30px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.#{$ns}CorpusI18n {
|
||||
&-textarea {
|
||||
.#{$ns}Form-label {
|
||||
padding: var(--Form-input-paddingY) 0;
|
||||
.#{$ns}TplField {
|
||||
font-size: px2rem(12px);
|
||||
}
|
||||
}
|
||||
.#{$ns}Form-value {
|
||||
padding-right: 0;
|
||||
.#{$ns}TextareaControl-input {
|
||||
font-size: px2rem(12px);
|
||||
}
|
||||
}
|
||||
}
|
||||
&-static {
|
||||
.#{$ns}Form-label {
|
||||
padding-left: 0;
|
||||
.#{$ns}TplField {
|
||||
font-size: px2rem(12px);
|
||||
}
|
||||
}
|
||||
.#{$ns}Form-value {
|
||||
.#{$ns}PlainField {
|
||||
font-size: px2rem(12px);
|
||||
}
|
||||
}
|
||||
}
|
||||
.#{$ns}Panel {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.CorpusI18n-icon.icon {
|
||||
top: 0 !important;
|
||||
}
|
||||
|
||||
.#{$ns}FormulaPickerI18n {
|
||||
.#{$ns}Modal-header {
|
||||
font-weight: bold;
|
||||
}
|
||||
&-tab {
|
||||
padding: var(--gap-base) 0;
|
||||
.#{$ns}FormulaEditor-content .#{$ns}FormulaEditor-header {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.RichTextI18n {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
border: 1px solid var(--Form-input-borderColor);
|
||||
border-radius: var(--Form-input-borderRadius);
|
||||
background: var(--Form-input-bg);
|
||||
font-size: var(--Form-input-fontSize);
|
||||
&::placeholder {
|
||||
color: var(--Form-input-placeholderColor);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: var(--Form-input-onHover-borderColor);
|
||||
}
|
||||
|
||||
.fr-toolbar.fr-top {
|
||||
border-radius: var(--Form-input-borderRadius);
|
||||
}
|
||||
|
||||
&-editor {
|
||||
height: 100%;
|
||||
border-radius: var(--Form-input-borderRadius);
|
||||
overflow: auto;
|
||||
& > .CodeMirror {
|
||||
height: 100%;
|
||||
padding-bottom: 26px;
|
||||
.CodeMirror-lines {
|
||||
padding-bottom: 30px;
|
||||
}
|
||||
.CodeMirror-vscrollbar {
|
||||
margin-bottom: 26px;
|
||||
}
|
||||
|
||||
// 解决上下 pre标签中表达式浮层遮挡问题
|
||||
.CodeMirror-measure + div {
|
||||
z-index: inherit !important;
|
||||
}
|
||||
pre.CodeMirror-line,
|
||||
.CodeMirror pre.CodeMirror-line-like {
|
||||
z-index: initial;
|
||||
}
|
||||
}
|
||||
|
||||
.cm-expression {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
|
||||
.expression-popover {
|
||||
position: absolute;
|
||||
display: none;
|
||||
left: 0;
|
||||
bottom: -30px;
|
||||
transform: translate(calc(24px - 50%));
|
||||
font-size: 12px;
|
||||
width: max-content;
|
||||
color: #fff;
|
||||
border-radius: 4px;
|
||||
padding: 2px 8px;
|
||||
background: var(--Tooltip-bg--dark);
|
||||
border: none;
|
||||
box-shadow: var(--Tooltip-boxShadow--dark);
|
||||
z-index: 10;
|
||||
|
||||
.expression-popover-arrow {
|
||||
position: absolute;
|
||||
display: block;
|
||||
width: var(--Tooltip-arrow-width);
|
||||
height: var(--Tooltip-arrow-height);
|
||||
margin-left: calc(var(--Tooltip-arrow-width) * -1 / 2);
|
||||
left: 50%;
|
||||
top: calc(var(--Tooltip-arrow-height) * -1);
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
position: absolute;
|
||||
display: block;
|
||||
content: '';
|
||||
border-color: transparent;
|
||||
border-style: solid;
|
||||
border-width: 0 calc(var(--Tooltip-arrow-width) / 2)
|
||||
var(--Tooltip-arrow-height) calc(var(--Tooltip-arrow-width) / 2);
|
||||
}
|
||||
&::before {
|
||||
border-width: 0;
|
||||
}
|
||||
&::after {
|
||||
border-bottom-color: var(--Tooltip-arrow-color--dark);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.cm-expression-text {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
padding: 0 5px;
|
||||
border-radius: 3px;
|
||||
color: #fff;
|
||||
margin: 0 1px 1px;
|
||||
background: var(--button-primary-default-bg-color);
|
||||
cursor: pointer;
|
||||
width: 40px;
|
||||
overflow-x: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
|
||||
&:hover {
|
||||
background: var(--button-primary-hover-bg-color);
|
||||
& ~ .expression-popover {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-footer {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
background: #f7f7f9;
|
||||
bottom: 0px;
|
||||
height: 26px;
|
||||
margin: 0;
|
||||
border-radius: 0 0 4px 4px;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
align-items: center;
|
||||
> li {
|
||||
margin-right: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
&-fxIcon {
|
||||
> a {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-overlay {
|
||||
position: absolute;
|
||||
z-index: 5;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
width: calc(100% - 4px);
|
||||
height: calc(100% - 4px);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.RichTextI18n-enabled-container {
|
||||
padding-bottom: 20px;
|
||||
|
||||
.RichTextI18n-footer-fxIcon {
|
||||
.icon-corpus-i18n {
|
||||
color: var(--body-color);
|
||||
}
|
||||
}
|
||||
|
||||
.RichTextI18n-footer-matched-fxIcon {
|
||||
.icon-corpus-i18n {
|
||||
color: var(--link-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.TextareaI18n {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
border: 1px solid var(--Form-input-borderColor);
|
||||
border-radius: var(--Form-input-borderRadius);
|
||||
background: var(--Form-input-bg);
|
||||
font-size: var(--Form-input-fontSize);
|
||||
&::placeholder {
|
||||
color: var(--Form-input-placeholderColor);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: var(--Form-input-onHover-borderColor);
|
||||
}
|
||||
|
||||
.#{$ns}TextareaControl > textarea {
|
||||
border: none;
|
||||
}
|
||||
|
||||
&-footer {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
background: #f7f7f9;
|
||||
bottom: 0px;
|
||||
height: 26px;
|
||||
margin: 0;
|
||||
border-radius: 0 0 4px 4px;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
align-items: center;
|
||||
> li {
|
||||
margin-right: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
&-corpusIcon {
|
||||
> a {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&-overlay {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
left: 1px;
|
||||
width: calc(100% - 4px);
|
||||
height: calc(100% - 4px);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
.TextareaI18n-multi-container {
|
||||
padding-bottom: 26px;
|
||||
|
||||
.TextareaI18n-footer-corpusIcon {
|
||||
.icon-corpus-i18n {
|
||||
color: var(--body-color);
|
||||
}
|
||||
}
|
||||
|
||||
.TextareaI18n-footer-highlight-corpusIcon {
|
||||
.icon-corpus-i18n {
|
||||
color: var(--link-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.#{$ns}CorpusConfigDialog-container {
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.#{$ns}CorpusConfigDialog-confirm-dialog {
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
.#{$ns}CorpusConfigDialogBody {
|
||||
margin-bottom: 1rem;
|
||||
.corpus-keyword-searchbox {
|
||||
width: 20rem;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.operate-tip-container {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
|
||||
.create-tip,
|
||||
.update-tip {
|
||||
font-size: 12px;
|
||||
|
||||
.dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background-color: #28a745;
|
||||
display: block;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
left: -10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.Corpus-FormItem-container {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 10px;
|
||||
|
||||
.Corpus-FormItem-label {
|
||||
position: relative;
|
||||
top: 6px;
|
||||
width: 70px;
|
||||
margin-right: 10px;
|
||||
text-align: right;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
font-weight: 500px;
|
||||
}
|
||||
|
||||
.#{$ns}TextareaControl {
|
||||
width: 240px;
|
||||
}
|
||||
}
|
||||
|
||||
.CorpusTablePicker-container {
|
||||
.CorpusTablePicker-outer-container {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.CorpusTablePicker-inner-container {
|
||||
width: fit-content;
|
||||
min-width: 100%;
|
||||
}
|
||||
.CorpusTablePicker-Header-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #f7f8fa;
|
||||
padding: 10px 20px;
|
||||
padding-left: 40px;
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.CorpusTablePicker-Body-container {
|
||||
.CorpusTablePicker-BodyRow-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-bottom: 1px solid #f2f2f2;
|
||||
padding: 10px 20px;
|
||||
padding-left: 40px;
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
position: relative;
|
||||
|
||||
&:hover {
|
||||
background-color: #e6f0ff;
|
||||
}
|
||||
|
||||
.CorpusTablePicker-radio {
|
||||
position: absolute;
|
||||
left: 10px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
border: 1px solid #f2f2f2;
|
||||
}
|
||||
}
|
||||
|
||||
.CorpusTablePicker-BodyColumn-item {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
overflow: hidden;
|
||||
/*! autoprefixer: off */
|
||||
-webkit-box-orient: vertical;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
padding-right: 20px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.#{$ns}Pagination-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.CorpusDetailPanel-container {
|
||||
border: 1px solid #f7f8fa;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
font-size: 12px;
|
||||
margin-top: 16px;
|
||||
.CorpusDetailPanel-Header-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background-color: #f7f8fa;
|
||||
padding: 5px 20px;
|
||||
.CorpusDetailPanel-Header-title {
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.CorpusDetailPanel-Header-buttons-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
.#{$ns}Button {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.CorpusDetailPanel-Body-container {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
padding: 20px;
|
||||
padding-bottom: 0;
|
||||
|
||||
.CorpusDetailPanel-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
width: 50%;
|
||||
margin-bottom: 20px;
|
||||
|
||||
.CorpusDetailPanel-label {
|
||||
width: 80px;
|
||||
margin-right: 10px;
|
||||
font-weight: 500;
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
text-align: right;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.CorpusDetailPanel-textarea-label {
|
||||
position: relative;
|
||||
top: 8px;
|
||||
}
|
||||
|
||||
.CorpusDetailPanel-content {
|
||||
word-wrap: break-word;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.#{$ns}CorpusDetailPanel-textarea {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.#{$ns}CorpusDetailPanel-button-tooltip {
|
||||
z-index: 20000;
|
||||
}
|
||||
82
packages/amis-editor/examples/component/Doc.tsx
Normal file
@@ -0,0 +1,82 @@
|
||||
import React from 'react';
|
||||
import Markdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter';
|
||||
import {darcula} from 'react-syntax-highlighter/dist/esm/styles/prism';
|
||||
import {getSchemaTpl, tipedLabel} from 'amis-editor-core';
|
||||
import 'amis';
|
||||
import '../../src/index';
|
||||
import PanelPreview from './PanelPreview';
|
||||
export interface DocProps {
|
||||
children?: string | null | undefined;
|
||||
}
|
||||
|
||||
export function mdComment(fun: Function) {
|
||||
const txt = fun.toString();
|
||||
return txt;
|
||||
}
|
||||
|
||||
function str2schema(code: string) {
|
||||
const fn = new Function('getSchemaTpl', 'tipedLabel', `return [${code}]`);
|
||||
return fn.call(null, getSchemaTpl, tipedLabel);
|
||||
}
|
||||
|
||||
export default function Doc({children}: DocProps) {
|
||||
return (
|
||||
<div className="markdown">
|
||||
<div className="markdown-body">
|
||||
<Markdown
|
||||
children={children}
|
||||
remarkPlugins={[remarkGfm]}
|
||||
components={{
|
||||
pre(props) {
|
||||
if ((props.children as any)?.props?.className) {
|
||||
return <>{props.children}</>;
|
||||
}
|
||||
|
||||
return <code>{props.children}</code>;
|
||||
},
|
||||
code(props) {
|
||||
const {children, className, node, ref, ...rest} = props;
|
||||
const match = /language-(\w+)/.exec(className || '');
|
||||
|
||||
if (match?.[1] === 'schema') {
|
||||
const schema = str2schema(children as string);
|
||||
|
||||
return (
|
||||
<div className="schema-tpl-preview">
|
||||
<code>
|
||||
<SyntaxHighlighter
|
||||
{...rest}
|
||||
PreTag="div"
|
||||
children={String(children).replace(/\n$/, '')}
|
||||
language={'jsx'}
|
||||
style={darcula}
|
||||
/>
|
||||
</code>
|
||||
|
||||
<PanelPreview schema={schema} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return match ? (
|
||||
<SyntaxHighlighter
|
||||
{...rest}
|
||||
PreTag="div"
|
||||
children={String(children).replace(/\n$/, '')}
|
||||
language={match[1]}
|
||||
style={darcula}
|
||||
/>
|
||||
) : (
|
||||
<code {...rest} className={className}>
|
||||
{children}
|
||||
</code>
|
||||
);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
60
packages/amis-editor/examples/component/PanelPreview.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import {JsonView, render} from 'amis';
|
||||
import cx from 'classnames';
|
||||
import React from 'react';
|
||||
export interface PanelPreviewProps {
|
||||
schema: any;
|
||||
}
|
||||
|
||||
export default function (props: PanelPreviewProps) {
|
||||
const schema = React.useMemo(() => {
|
||||
return {
|
||||
type: 'form',
|
||||
mode: 'normal',
|
||||
wrapWithPanel: false,
|
||||
className: cx('config-form-content', 'ae-Settings-content'),
|
||||
wrapperComponent: 'div',
|
||||
body: Array.isArray(props.schema) ? props.schema : [props.schema],
|
||||
submitOnChange: true,
|
||||
submitOnInit: true
|
||||
};
|
||||
}, [JSON.stringify(props.schema)]);
|
||||
const [data, setData] = React.useState({});
|
||||
const onFinished = React.useCallback((data: any) => {
|
||||
setData(data);
|
||||
return false;
|
||||
}, []);
|
||||
const onJsonEdit = React.useCallback((e: any) => {
|
||||
setData(e.updated_src);
|
||||
}, []);
|
||||
const dom = React.useRef<HTMLDivElement | null>(null);
|
||||
// const popOverContainer = React.useCallback(() => {
|
||||
// return dom.current;
|
||||
// }, []);
|
||||
|
||||
return (
|
||||
<div className="PanelPreview" ref={dom}>
|
||||
<div className="AMISCSSWrapper editor-right-panel">
|
||||
{render(
|
||||
schema,
|
||||
{
|
||||
data: data,
|
||||
onFinished: onFinished
|
||||
// popOverContainer
|
||||
},
|
||||
{
|
||||
// theme: 'cxd' // 右侧属性配置面板固定使用cxd主题展示
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
<JsonView
|
||||
name={false}
|
||||
src={data}
|
||||
theme={'rjv-default'}
|
||||
enableClipboard={false}
|
||||
onEdit={onJsonEdit}
|
||||
onDelete={onJsonEdit}
|
||||
onAdd={onJsonEdit}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
1
packages/amis-editor/examples/icons/corpus-i18n.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="15" height="15" xmlns="http://www.w3.org/2000/svg"><g transform="translate(1 1)" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"><circle cx="6.5" cy="6.5" r="6.5"/><ellipse cx="6.5" cy="6.5" rx="6.5" ry="2.5"/><ellipse transform="rotate(-90 6.5 6.5)" cx="6.5" cy="6.5" rx="6.5" ry="2.5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 364 B |
1
packages/amis-editor/examples/icons/h5-preview.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><g fill="none"><path d="M0 0h16v16H0z"/><path d="M13 1.5a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H3a.5.5 0 0 1-.5-.5V2a.5.5 0 0 1 .5-.5Zm-.5 1h-9v11h9v-11ZM9 11.66a.5.5 0 0 1 .09.992L9 12.66H7a.5.5 0 0 1-.09-.992L7 11.66h2Z" fill="currentColor"/></g></svg>
|
||||
|
After Width: | Height: | Size: 311 B |
18
packages/amis-editor/examples/icons/index.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @file 内置 svg 图标
|
||||
*/
|
||||
|
||||
import {Icon, registerIcon} from 'amis';
|
||||
|
||||
// @ts-ignore
|
||||
import PCPreview from './pc-preview.svg';
|
||||
// @ts-ignore
|
||||
import H5Preview from './h5-preview.svg';
|
||||
registerIcon('pc-preview', PCPreview);
|
||||
registerIcon('h5-preview', H5Preview);
|
||||
|
||||
// @ts-ignore
|
||||
import CorpusI18n from './corpus-i18n.svg';
|
||||
registerIcon('corpus-i18n', CorpusI18n);
|
||||
|
||||
export {Icon};
|
||||
1
packages/amis-editor/examples/icons/pc-preview.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 17 16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M16.037 0h-16v16h16z"/><path d="M6.037 14a.5.5 0 0 1-.09-.992l.09-.008h1.5v-1.5h-5.5a.5.5 0 0 1-.5-.5V2.542a.5.5 0 0 1 .5-.5h12a.5.5 0 0 1 .5.5V11a.5.5 0 0 1-.5.5h-5.5V13h1.5a.5.5 0 0 1 .09.992l-.09.008h-4Zm7.5-10.959h-11V10.5h11V3.041Z" fill="currentColor"/></g></svg>
|
||||
|
After Width: | Height: | Size: 374 B |
40
packages/amis-editor/examples/layout/index.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
// 常见布局
|
||||
import Layout1_1 from './plugin/Layout1_1';
|
||||
import Layout1_2 from './plugin/Layout1_2';
|
||||
import Layout1_3 from './plugin/Layout1_3';
|
||||
import Layout1_1_v2 from './plugin/Layout1_1_v2';
|
||||
import Layout1_1_1 from './plugin/Layout1_1_1';
|
||||
import Layout1_2_3 from './plugin/Layout1_2_3';
|
||||
import Layout1_1_1_v2 from './plugin/Layout1_1_1_v2';
|
||||
import Layout1_2_v2 from './plugin/Layout1_2_v2';
|
||||
import Layout2_1_v2 from './plugin/Layout2_1_v2';
|
||||
import Layout1_2_v3 from './plugin/Layout1_2_v3';
|
||||
import Layout2_1_v3 from './plugin/Layout2_1_v3';
|
||||
import Layout1_2_v4 from './plugin/Layout1_2_v4';
|
||||
// import Layout_fixed_top from './plugin/Layout_fixed_top';
|
||||
// import Layout_fixed_bottom from './plugin/Layout_fixed_bottom';
|
||||
// import Layout_fixed from './plugin/Layout_fixed';
|
||||
import Layout_scroll_x from './plugin/Layout_scroll_x';
|
||||
import Layout_scroll_y from './plugin/Layout_scroll_y';
|
||||
|
||||
const LayoutList: Array<any> = [
|
||||
Layout1_1,
|
||||
Layout1_2,
|
||||
Layout1_3,
|
||||
Layout1_1_v2,
|
||||
Layout1_1_1,
|
||||
Layout1_2_3,
|
||||
Layout1_1_1_v2,
|
||||
Layout1_2_v2,
|
||||
Layout2_1_v2,
|
||||
Layout1_2_v3,
|
||||
Layout2_1_v3,
|
||||
Layout1_2_v4,
|
||||
// Layout_fixed_top,
|
||||
// Layout_fixed_bottom,
|
||||
// Layout_fixed,
|
||||
Layout_scroll_x,
|
||||
Layout_scroll_y
|
||||
];
|
||||
|
||||
export default LayoutList;
|
||||
42
packages/amis-editor/examples/layout/plugin/Layout1_1.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file Flex 常见布局 1:1 左右均分
|
||||
*/
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout1_1 extends FlexPluginBase {
|
||||
name = '左右均分';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-2cols-plugin';
|
||||
description = '常见布局:左右均分布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 200;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
}
|
||||
],
|
||||
alignItems: 'stretch'
|
||||
};
|
||||
}
|
||||
53
packages/amis-editor/examples/layout/plugin/Layout1_1_1.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @file Flex 常见布局 1:1:1 三栏均分
|
||||
*/
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout1_1_1 extends FlexPluginBase {
|
||||
name = '三栏均分';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-3cols-plugin';
|
||||
description = '常见布局:三栏均分布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 300;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
display: 'block',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1
|
||||
}
|
||||
}
|
||||
],
|
||||
alignItems: 'stretch'
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* @file Flex 常见布局 上中下布局
|
||||
*/
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout1_1_1_v2 extends FlexPluginBase {
|
||||
name = '上中下';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-3row-plugin';
|
||||
description = '常见布局:上中下布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 303;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
}
|
||||
],
|
||||
direction: 'column',
|
||||
justify: 'center',
|
||||
alignItems: 'stretch'
|
||||
};
|
||||
}
|
||||
50
packages/amis-editor/examples/layout/plugin/Layout1_1_v2.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @file Flex 常见布局 上下布局
|
||||
*/
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout1_1_v2 extends FlexPluginBase {
|
||||
name = '上下布局';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-2row-plugin';
|
||||
description = '常见布局:上下布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 203;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
}
|
||||
],
|
||||
direction: 'column',
|
||||
justify: 'center',
|
||||
alignItems: 'stretch'
|
||||
};
|
||||
}
|
||||
42
packages/amis-editor/examples/layout/plugin/Layout1_2.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file Flex 常见布局 1:2
|
||||
*/
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout1_2 extends FlexPluginBase {
|
||||
name = '1:2 布局';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-2cols-plugin';
|
||||
description = '常见布局:1:2 布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 201;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 2,
|
||||
display: 'block'
|
||||
}
|
||||
}
|
||||
],
|
||||
alignItems: 'stretch'
|
||||
};
|
||||
}
|
||||
53
packages/amis-editor/examples/layout/plugin/Layout1_2_3.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @file Flex 常见布局 1:2:3
|
||||
*/
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout1_2_3 extends FlexPluginBase {
|
||||
name = '1:2:3 三栏';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-3cols-plugin';
|
||||
description = '常见布局:1:2:3 三栏布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 301;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 2,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
display: 'block',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 3
|
||||
}
|
||||
}
|
||||
],
|
||||
alignItems: 'stretch'
|
||||
};
|
||||
}
|
||||
72
packages/amis-editor/examples/layout/plugin/Layout1_2_v2.tsx
Normal file
@@ -0,0 +1,72 @@
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout1_2_v2 extends FlexPluginBase {
|
||||
name = '一拖二';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-1with2-plugin';
|
||||
description = '常见布局:一拖二布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 303;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '100px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'flex',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
}
|
||||
],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
padding: 0
|
||||
},
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
],
|
||||
style: {
|
||||
overflowX: 'auto',
|
||||
margin: '0',
|
||||
maxWidth: 'auto',
|
||||
height: '350px',
|
||||
overflowY: 'auto'
|
||||
},
|
||||
direction: 'column',
|
||||
justify: 'center',
|
||||
alignItems: 'stretch',
|
||||
isFixedHeight: true
|
||||
};
|
||||
}
|
||||
74
packages/amis-editor/examples/layout/plugin/Layout1_2_v3.tsx
Normal file
@@ -0,0 +1,74 @@
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout1_2_v3 extends FlexPluginBase {
|
||||
name = '左一右二';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-1-2-plugin';
|
||||
description = '常见布局:左一右二布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 304;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '250px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'flex',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
}
|
||||
],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
margin: '0'
|
||||
},
|
||||
alignItems: 'stretch',
|
||||
direction: 'column',
|
||||
justify: 'center'
|
||||
}
|
||||
],
|
||||
style: {
|
||||
overflowX: 'auto',
|
||||
margin: '0',
|
||||
maxWidth: 'auto',
|
||||
height: '350px',
|
||||
overflowY: 'auto'
|
||||
},
|
||||
direction: 'row',
|
||||
justify: 'center',
|
||||
alignItems: 'stretch',
|
||||
isFixedHeight: true
|
||||
};
|
||||
}
|
||||
107
packages/amis-editor/examples/layout/plugin/Layout1_2_v4.tsx
Normal file
@@ -0,0 +1,107 @@
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout1_2_v4 extends FlexPluginBase {
|
||||
name = '经典布局';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-3-1-plugin';
|
||||
description = '常见布局:经典布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 307;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'flex',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '250px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'flex',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
}
|
||||
],
|
||||
style: {
|
||||
position: 'static',
|
||||
overflowX: 'auto',
|
||||
overflowY: 'auto',
|
||||
margin: '0',
|
||||
flex: '1 1 auto',
|
||||
flexGrow: 1,
|
||||
flexBasis: 'auto'
|
||||
},
|
||||
alignItems: 'stretch',
|
||||
direction: 'column',
|
||||
justify: 'center',
|
||||
isFixedHeight: false,
|
||||
isFixedWidth: false
|
||||
}
|
||||
],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
overflowX: 'auto',
|
||||
margin: '0',
|
||||
maxWidth: 'auto',
|
||||
overflowY: 'auto',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
width: 'auto',
|
||||
maxHeight: 'auto',
|
||||
minHeight: '300px'
|
||||
},
|
||||
direction: 'row',
|
||||
justify: 'flex-start',
|
||||
alignItems: 'stretch',
|
||||
isFixedHeight: false,
|
||||
isFixedWidth: false
|
||||
}
|
||||
],
|
||||
direction: 'column',
|
||||
justify: 'center',
|
||||
alignItems: 'stretch'
|
||||
};
|
||||
}
|
||||
42
packages/amis-editor/examples/layout/plugin/Layout1_3.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @file Flex 常见布局 1:3
|
||||
*/
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout1_3 extends FlexPluginBase {
|
||||
name = '1:3 布局';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-2cols-plugin';
|
||||
description = '常见布局:1:3 布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 202;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 3,
|
||||
display: 'block'
|
||||
}
|
||||
}
|
||||
],
|
||||
alignItems: 'stretch'
|
||||
};
|
||||
}
|
||||
75
packages/amis-editor/examples/layout/plugin/Layout2_1_v2.tsx
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* @file Flex 常见布局 二拖一布局
|
||||
*/
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout2_1_v2 extends FlexPluginBase {
|
||||
name = '二拖一';
|
||||
isBaseComponent = false; // 在自定义组件面板中展示
|
||||
pluginIcon = 'layout-2with1-plugin';
|
||||
description = '常见布局:二拖一布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 305;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'flex',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
}
|
||||
],
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '100px'
|
||||
},
|
||||
alignItems: 'stretch'
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: '200px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
}
|
||||
],
|
||||
style: {
|
||||
overflowX: 'auto',
|
||||
margin: '0',
|
||||
maxWidth: 'auto',
|
||||
height: '350px',
|
||||
overflowY: 'auto'
|
||||
},
|
||||
direction: 'column',
|
||||
justify: 'center',
|
||||
alignItems: 'stretch',
|
||||
isFixedHeight: true
|
||||
};
|
||||
}
|
||||
73
packages/amis-editor/examples/layout/plugin/Layout2_1_v3.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout2_1_v3 extends FlexPluginBase {
|
||||
name = '左二右一';
|
||||
isBaseComponent = false; // 在自定义组件面板中展示
|
||||
pluginIcon = 'layout-2-1-plugin';
|
||||
description = '常见布局:左二右一布局(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 306;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'flex',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
}
|
||||
],
|
||||
style: {
|
||||
flex: '1 1 auto'
|
||||
},
|
||||
alignItems: 'stretch',
|
||||
direction: 'column',
|
||||
justify: 'center'
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '250px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
}
|
||||
],
|
||||
style: {
|
||||
overflowX: 'auto',
|
||||
margin: '0',
|
||||
maxWidth: 'auto',
|
||||
height: '350px',
|
||||
overflowY: 'auto'
|
||||
},
|
||||
direction: 'row',
|
||||
justify: 'center',
|
||||
alignItems: 'stretch',
|
||||
isFixedHeight: true
|
||||
};
|
||||
}
|
||||
23
packages/amis-editor/examples/layout/plugin/Layout_fixed.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout_fixed extends FlexPluginBase {
|
||||
name = '悬浮容器';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-fixed-plugin';
|
||||
description = '常见布局:悬浮容器(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = -1;
|
||||
scaffold: any = {
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
position: 'fixed',
|
||||
inset: 'auto 50px 50px auto',
|
||||
zIndex: 10,
|
||||
minWidth: '80px',
|
||||
minHeight: '80px'
|
||||
},
|
||||
originPosition: 'right-bottom'
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout_fixed_bottom extends FlexPluginBase {
|
||||
name = '吸底容器';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'flex-container-plugin';
|
||||
description = '常见布局:吸底容器(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 501;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'flex-start',
|
||||
alignItems: 'stretch'
|
||||
}
|
||||
}
|
||||
],
|
||||
style: {
|
||||
position: 'fixed',
|
||||
inset: 'auto auto 0 0',
|
||||
zIndex: 2,
|
||||
width: '100%',
|
||||
overflowX: 'auto',
|
||||
margin: '0',
|
||||
overflowY: 'auto',
|
||||
height: 'auto'
|
||||
},
|
||||
isFixedWidth: true,
|
||||
direction: 'row',
|
||||
justify: 'center',
|
||||
alignItems: 'stretch',
|
||||
isFixedHeight: false,
|
||||
originPosition: 'right-bottom'
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout_fixed_top extends FlexPluginBase {
|
||||
name = '吸顶容器';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'flex-container-plugin';
|
||||
description = '常见布局:吸顶容器(基于 CSS Flex 实现的布局容器)。';
|
||||
tags = ['常见布局'];
|
||||
order = 502;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1,
|
||||
display: 'block'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'wrapper',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '1 1 auto',
|
||||
display: 'block',
|
||||
flexBasis: 'auto',
|
||||
flexGrow: 1
|
||||
}
|
||||
}
|
||||
],
|
||||
style: {
|
||||
position: 'fixed',
|
||||
inset: '0 auto auto 0',
|
||||
zIndex: 10,
|
||||
width: '100%',
|
||||
overflowX: 'auto',
|
||||
margin: '0',
|
||||
overflowY: 'auto'
|
||||
},
|
||||
isFixedWidth: true,
|
||||
direction: 'row',
|
||||
justify: 'center',
|
||||
alignItems: 'stretch',
|
||||
isFixedHeight: false,
|
||||
originPosition: 'right-bottom'
|
||||
};
|
||||
}
|
||||
132
packages/amis-editor/examples/layout/plugin/Layout_scroll_x.tsx
Normal file
@@ -0,0 +1,132 @@
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout_scroll_x extends FlexPluginBase {
|
||||
name = 'x轴滚动容器';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-3cols-plugin';
|
||||
description = 'x轴滚动容器: 基于 CSS Flex 实现的布局容器。';
|
||||
order = 505;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '200px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '200px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto',
|
||||
flexBasis: '200px'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
wrapperBody: false,
|
||||
size: 'xs',
|
||||
body: [],
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '200px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '200px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '200px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '200px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
}
|
||||
],
|
||||
direction: 'row',
|
||||
justify: 'flex-start',
|
||||
alignItems: 'stretch',
|
||||
style: {
|
||||
position: 'static',
|
||||
minHeight: 'auto',
|
||||
maxWidth: '1080px',
|
||||
minWidth: 'auto',
|
||||
height: '200px',
|
||||
overflowX: 'scroll',
|
||||
overflowY: 'scroll',
|
||||
margin: '0 auto'
|
||||
},
|
||||
isFixedHeight: true,
|
||||
isFixedWidth: false
|
||||
};
|
||||
|
||||
onPreview2editor(event: any) {
|
||||
console.log('onPreview2editor-event:', event);
|
||||
}
|
||||
}
|
||||
114
packages/amis-editor/examples/layout/plugin/Layout_scroll_y.tsx
Normal file
@@ -0,0 +1,114 @@
|
||||
import {FlexPluginBase} from '../../../src/plugin/Layout/FlexPluginBase';
|
||||
|
||||
export default class Layout_scroll_y extends FlexPluginBase {
|
||||
name = 'y轴滚动容器';
|
||||
isBaseComponent = false;
|
||||
pluginIcon = 'layout-3row-plugin';
|
||||
description = 'y轴滚动容器: 基于 CSS Flex 实现的布局容器。';
|
||||
order = 504;
|
||||
scaffold: any = {
|
||||
type: 'flex',
|
||||
className: 'p-1',
|
||||
items: [
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '60px',
|
||||
display: 'block',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '60px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '60px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '60px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '60px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
},
|
||||
{
|
||||
type: 'container',
|
||||
size: 'xs',
|
||||
body: [],
|
||||
wrapperBody: false,
|
||||
style: {
|
||||
flex: '0 0 auto',
|
||||
flexBasis: '60px',
|
||||
display: 'block',
|
||||
position: 'static',
|
||||
minWidth: 'auto',
|
||||
minHeight: 'auto'
|
||||
}
|
||||
}
|
||||
],
|
||||
direction: 'column',
|
||||
justify: 'flex-start',
|
||||
alignItems: 'stretch',
|
||||
style: {
|
||||
position: 'static',
|
||||
minHeight: 'auto',
|
||||
maxWidth: 'auto',
|
||||
minWidth: 'auto',
|
||||
height: '200px',
|
||||
width: 'auto',
|
||||
overflowX: 'auto',
|
||||
overflowY: 'scroll',
|
||||
margin: '0'
|
||||
},
|
||||
isFixedHeight: true,
|
||||
isFixedWidth: false
|
||||
};
|
||||
}
|
||||
166
packages/amis-editor/examples/renderer/InputTextI18n.tsx
Normal file
@@ -0,0 +1,166 @@
|
||||
/**
|
||||
* @file client/renderer/InputTextI18n.tsx
|
||||
* @description 支持国际化的 input-text 组件
|
||||
*/
|
||||
|
||||
import {
|
||||
FormControlProps,
|
||||
FormItem,
|
||||
makeTranslator,
|
||||
autobind
|
||||
} from '../../../amis-core/src/index';
|
||||
import React from 'react';
|
||||
import {Icon, InputBox} from '../../../amis-ui/src/index';
|
||||
import {InputBoxProps} from '../../../amis-ui/src/components/InputBox';
|
||||
import cx from 'classnames';
|
||||
import {getEnv} from 'mobx-state-tree';
|
||||
import {pick} from 'lodash';
|
||||
import {LocaleProps} from 'amis-core';
|
||||
|
||||
/** 语料 key 正则表达式 */
|
||||
export const corpusKeyReg =
|
||||
/^i18n:[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/;
|
||||
|
||||
interface InputTextI18nProps extends InputBoxProps, LocaleProps {
|
||||
classPrefix: string;
|
||||
i18nEnabled?: boolean;
|
||||
disabled?: boolean;
|
||||
maxLength?: number;
|
||||
minLength?: number;
|
||||
onI18nChange?: (value: string) => void;
|
||||
}
|
||||
|
||||
export class InputTextI18n extends React.Component<InputTextI18nProps> {
|
||||
constructor(props: InputTextI18nProps) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
let {
|
||||
value,
|
||||
classPrefix,
|
||||
i18nEnabled,
|
||||
className,
|
||||
disabled,
|
||||
translate = makeTranslator(this.props.locale),
|
||||
placeholder,
|
||||
onI18nChange,
|
||||
...rest
|
||||
} = this.props;
|
||||
|
||||
const restProps = rest
|
||||
? pick(rest, [
|
||||
'onBlur',
|
||||
'placeholder',
|
||||
'disabled',
|
||||
'readOnly',
|
||||
'onClear',
|
||||
'hasError',
|
||||
'prefix',
|
||||
'children',
|
||||
'borderMode'
|
||||
])
|
||||
: {};
|
||||
|
||||
const isMatch = corpusKeyReg.test(value!);
|
||||
const _value = i18nEnabled ? translate(value) : value;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cx(className, `${classPrefix}InputI18n-container`, {
|
||||
[`${classPrefix}InputI18n-multi-container`]: i18nEnabled
|
||||
})}
|
||||
>
|
||||
<div className={cx(`${classPrefix}InputI18n-inner-container`)}>
|
||||
<InputBox
|
||||
{...restProps}
|
||||
value={_value}
|
||||
clearable={false}
|
||||
onChange={this.onInputChange}
|
||||
placeholder={placeholder}
|
||||
disabled={disabled}
|
||||
></InputBox>
|
||||
{i18nEnabled && !disabled ? (
|
||||
<div
|
||||
className={cx(`${classPrefix}InputI18n-addon-container`, {
|
||||
[`${classPrefix}InputI18n-addon-active`]: isMatch
|
||||
})}
|
||||
onClick={this.onClickI18nBtn}
|
||||
>
|
||||
<Icon
|
||||
icon="corpus-i18n"
|
||||
className="icon cursor-pointer CorpusI18n-input-icon"
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{isMatch && i18nEnabled ? (
|
||||
<div
|
||||
className={cx(`${classPrefix}InputI18n-overlay`)}
|
||||
onClick={this.onClickI18nBtn}
|
||||
></div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@autobind
|
||||
onClickI18nBtn() {
|
||||
const {value} = this.props;
|
||||
if (corpusKeyReg.test(value!)) {
|
||||
this.props?.onChange?.('');
|
||||
this.props.onI18nChange?.('');
|
||||
return;
|
||||
}
|
||||
let _uuid = 'i18n:1189fb5d-ac5b-4558-b363-068ce5decc99';
|
||||
this.props?.onChange?.(_uuid);
|
||||
this.props.onI18nChange?.(_uuid);
|
||||
}
|
||||
|
||||
@autobind
|
||||
onInputChange(value: string) {
|
||||
this.props.onChange?.(value);
|
||||
}
|
||||
}
|
||||
|
||||
interface InputTextI18nControlProps extends FormControlProps {}
|
||||
|
||||
class InputTextI18nControl extends React.Component<InputTextI18nControlProps> {
|
||||
constructor(props: InputTextI18nControlProps) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
onChange,
|
||||
value,
|
||||
classPrefix,
|
||||
className,
|
||||
classnames,
|
||||
placeholder,
|
||||
disabled,
|
||||
...rest
|
||||
} = this.props;
|
||||
const {i18nEnabled} = getEnv((window as any).editorStore);
|
||||
|
||||
return (
|
||||
<InputTextI18n
|
||||
{...rest}
|
||||
i18nEnabled={i18nEnabled}
|
||||
onChange={onChange}
|
||||
classPrefix={classPrefix}
|
||||
classnames={classnames}
|
||||
value={value}
|
||||
placeholder={placeholder}
|
||||
className={className}
|
||||
disabled={disabled}
|
||||
></InputTextI18n>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@FormItem({
|
||||
type: 'input-text-i18n'
|
||||
})
|
||||
export class InputTextI18nRenderer extends InputTextI18nControl {}
|
||||
83
packages/amis-editor/examples/renderer/TextareaI18n.tsx
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* @file client/renderer/TextAreaI18n.tsx
|
||||
* @description 支持国际化的 textarea 组件
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {
|
||||
autobind,
|
||||
FormControlProps,
|
||||
FormItem
|
||||
} from '../../../amis-core/src/index';
|
||||
import {Icon, Textarea} from '../../../amis-ui/src/index';
|
||||
import cx from 'classnames';
|
||||
|
||||
/** 语料 key 正则表达式 */
|
||||
export const corpusKeyReg =
|
||||
/^i18n:[0-9a-z]{8}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{4}-[0-9a-z]{12}$/;
|
||||
|
||||
export interface TextareaI18nProps extends FormControlProps {}
|
||||
|
||||
class TextareaI18n extends React.Component<TextareaI18nProps> {
|
||||
@autobind
|
||||
onClickI18nBtn() {
|
||||
const {value} = this.props;
|
||||
if (corpusKeyReg.test(value!)) {
|
||||
this.props?.onChange?.('');
|
||||
return;
|
||||
}
|
||||
let _uuid = 'i18n:1189fb5d-ac5b-4558-b363-068ce5decc99';
|
||||
this.props?.onChange?.(_uuid);
|
||||
}
|
||||
|
||||
render() {
|
||||
const {value, onChange, className} = this.props;
|
||||
|
||||
const isMatch = corpusKeyReg.test(value!);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={cx(
|
||||
'TextareaI18n',
|
||||
className,
|
||||
'TextareaI18n-multi-container'
|
||||
)}
|
||||
>
|
||||
<Textarea
|
||||
value={value}
|
||||
clearable={false}
|
||||
onChange={onChange}
|
||||
></Textarea>
|
||||
|
||||
{
|
||||
<ul className={cx('TextareaI18n-footer')}>
|
||||
<li
|
||||
className={cx('TextareaI18n-footer-corpusIcon', {
|
||||
'TextareaI18n-footer-highlight-corpusIcon': isMatch
|
||||
})}
|
||||
onClick={this.onClickI18nBtn}
|
||||
>
|
||||
<a data-tooltip="多语言" data-position="top">
|
||||
<Icon icon="corpus-i18n" className="icon" />
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
}
|
||||
|
||||
{isMatch ? (
|
||||
<div
|
||||
className={cx('TextareaI18n-overlay')}
|
||||
onClick={this.onClickI18nBtn}
|
||||
></div>
|
||||
) : null}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@FormItem({
|
||||
type: 'textarea-i18n'
|
||||
})
|
||||
export class TextAreaI18nRenderer extends TextareaI18n {}
|
||||
21
packages/amis-editor/examples/route/Basic.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# 基本模版
|
||||
|
||||
## 表单项名字
|
||||
|
||||
`formItemName`
|
||||
|
||||
```schema
|
||||
getSchemaTpl('formItemName', {
|
||||
value: 'name'
|
||||
})
|
||||
```
|
||||
|
||||
## 表单项展示模式
|
||||
|
||||
`formItemMode`
|
||||
|
||||
```schema
|
||||
getSchemaTpl('formItemMode', {
|
||||
|
||||
})
|
||||
```
|
||||
117
packages/amis-editor/examples/route/Formula.md
Normal file
@@ -0,0 +1,117 @@
|
||||
# 公式相关
|
||||
|
||||
公式输入相关组件规范说明。
|
||||
|
||||
## 显隐表达式
|
||||
|
||||
比如:`visibleOn`, `disabledOn` 因为存在两种表达式的写法,所以这里需要明确区分。
|
||||
|
||||
- 没有初始值时出现「点击编写表达式」按钮,点击会弹出一个表达式编辑器。
|
||||
- 初始值存在时,且为 js 表达式(即不是 `${` 和 `}`包裹的)时,直接用文本输入框展示与输入。
|
||||
- 初始值存在时,且为 `${` 和 `}`包裹的公式表达式时,用公式编辑器展示,同时点击后,会弹出一个表达式编辑器,能直接回显当前公式
|
||||
- 公式弹窗内部始终是公式语法,不存在模版拼接语法。
|
||||
- 当 js 表达式被删除后,只能用新版公式编辑器了。
|
||||
|
||||
```schema
|
||||
getSchemaTpl('expressionFormulaControl', {
|
||||
label: '无默认值',
|
||||
name: 'var1'
|
||||
}),
|
||||
|
||||
getSchemaTpl('expressionFormulaControl', {
|
||||
label: '默认值为旧语法',
|
||||
name: 'var2',
|
||||
value: 'data.a == 1'
|
||||
}),
|
||||
|
||||
getSchemaTpl('expressionFormulaControl', {
|
||||
label: '默认值为新语法',
|
||||
name: 'var3',
|
||||
value: '\\${a == 1 ? "1" : a == 2 ? "二" : a == 3 ? "三" : "一个很长的表达式"}'
|
||||
})
|
||||
```
|
||||
|
||||
## 文本输入框默认值
|
||||
|
||||
默认展示为文本输入框,通过点击 `+fx` 来添加公式片段,公式部分高亮展示,是整体高亮,而不是表达式内部 token 高亮(变量名、操作符、字面量等会用不同的方式高亮)。整体高亮内部不细化高亮,展示 tooltip 时再细化高亮,并且点击后开始编辑点击部分公式,注意这里是编辑局部公式,而不是整个默认值输入框。
|
||||
|
||||
值格式中如果没有出现 `${` 和 `}` 包裹的公式,则认为是普通文本,如果存在,则会做公式处理。当时用户直接通过文本输入框输入公式时,会当成时输入普通文本,如果用户输入了 `$` 符号,要将其转成 `\\$`,这样就不会被误认为是公式了。要添加公式片段,用户必须通过点击 `+fx` 按钮添加。`+fx` 可以添加多个片段。
|
||||
|
||||
```schema
|
||||
getSchemaTpl('tplFormulaControl', {
|
||||
name: 'value',
|
||||
label: '默认值'
|
||||
}),
|
||||
|
||||
getSchemaTpl('tplFormulaControl', {
|
||||
name: 'value2',
|
||||
label: '默认值',
|
||||
value: 'My name is \\${name}'
|
||||
})
|
||||
```
|
||||
|
||||
## 多行文本输入框默认值
|
||||
|
||||
```schema
|
||||
getSchemaTpl('textareaDefaultValue', {
|
||||
name: 'var1',
|
||||
value: 'My name is \\${name}'
|
||||
})
|
||||
```
|
||||
|
||||
## 数字输入框默认值
|
||||
|
||||
默认展示为数字输入框,通过点击 `fx` 输入公式,因为不是文本,无法拼接,所以默认值要么是公式,要么是静态值。
|
||||
|
||||
```schema
|
||||
getSchemaTpl('valueFormula', {
|
||||
mode: 'vertical',
|
||||
rendererSchema: (schema) => ({
|
||||
type: 'input-number',
|
||||
...schema,
|
||||
displayMode: 'base'
|
||||
}),
|
||||
valueType: 'number' // 期望数值类型
|
||||
})
|
||||
```
|
||||
|
||||
## 日期输入框默认值
|
||||
|
||||
```schema
|
||||
getSchemaTpl('valueFormula', {
|
||||
mode: 'vertical',
|
||||
rendererSchema: (schema) => ({
|
||||
type: 'input-date',
|
||||
...schema
|
||||
}),
|
||||
placeholder: '请选择静态值',
|
||||
header: '表达式或相对值',
|
||||
DateTimeType: 1,
|
||||
label: tipedLabel('默认值', '支持例如: <code>now、+3days、-2weeks、+1hour、+2years</code> 等(minute|min|hour|day|week|month|year|weekday|second|millisecond)这种相对值用法')
|
||||
})
|
||||
```
|
||||
|
||||
## 选项类输入框默认值
|
||||
|
||||
```schema
|
||||
getSchemaTpl('valueFormula', {
|
||||
rendererSchema: (schema) => ({
|
||||
...schema,
|
||||
type: 'select',
|
||||
options: [
|
||||
{
|
||||
label: '选项1',
|
||||
value: '1'
|
||||
},
|
||||
{
|
||||
label: '选项2',
|
||||
value: '2'
|
||||
}
|
||||
]
|
||||
}),
|
||||
// 默认值组件设计有些问题,自动发起了请求,接口数据作为了默认值选项,接口形式应该是设置静态值或者FX
|
||||
needDeleteProps: ['source'],
|
||||
// 当数据源是自定义静态选项时,不额外配置默认值,在选项上直接勾选即可,放开会有个bug:当去掉勾选时,默认值配置组件不清空,只是schema清空了value
|
||||
visibleOn: 'this.selectFirst !== true && this.source != null'
|
||||
})
|
||||
```
|
||||
316
packages/amis-editor/examples/style.scss
Normal file
@@ -0,0 +1,316 @@
|
||||
@import '../../amis-ui/scss/functions';
|
||||
@import '../../amis-ui/scss/variables';
|
||||
@import '../../amis-ui/scss/helper';
|
||||
@import './corpus-i18n';
|
||||
|
||||
$editor-default-color: #151b26; // 默认的字体色
|
||||
$editor-active-color: #2468f2;
|
||||
$editor-hover-color: #5086f5;
|
||||
$editor-border-color: #e8e9eb; // 默认的边框色
|
||||
$default-icon-color: #84868c; // 默认的icon颜色
|
||||
|
||||
$active-bg-color: #e6f0ff; // 激活态的背景色
|
||||
$hover-bg-color: #f7f7f9; // 激活态的背景色
|
||||
|
||||
$disabled-color: #b8babf; // 禁用文字颜色
|
||||
$disabled-bg-color: #f7f7f9; // 禁用背景颜色
|
||||
|
||||
.page-play,
|
||||
.page-edit {
|
||||
&:before {
|
||||
display: table;
|
||||
content: ' ';
|
||||
}
|
||||
&:after {
|
||||
clear: both;
|
||||
display: block;
|
||||
content: '';
|
||||
height: 0;
|
||||
}
|
||||
.app-content {
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
bottom: 0;
|
||||
height: auto;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
.app-content-body {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.Editor-Demo {
|
||||
position: relative;
|
||||
height: 100vh;
|
||||
min-height: 510px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.Editor-header {
|
||||
flex: 0 0 48px;
|
||||
position: relative;
|
||||
background: #fff;
|
||||
// box-shadow: 0 2px 7px 0 rgba(232,232,232,0.50);
|
||||
display: flex;
|
||||
border-bottom: 1px solid $editor-border-color;
|
||||
box-sizing: border-box;
|
||||
z-index: 1000;
|
||||
|
||||
svg {
|
||||
display: inline-block;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.Editor-title {
|
||||
flex: 1 1 565px;
|
||||
padding: 0 15px;
|
||||
font-family: PingFangSC-Medium;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
letter-spacing: 0;
|
||||
user-select: none;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.Editor-view-mode-group-container {
|
||||
flex: 0 1 150px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.Editor-view-mode-group {
|
||||
font-size: 14px;
|
||||
font-family: PingFangSC-Regular;
|
||||
// color: #fff;
|
||||
letter-spacing: 0;
|
||||
text-align: center;
|
||||
width: 100px;
|
||||
height: 32px;
|
||||
border-radius: 4px;
|
||||
font-weight: 400;
|
||||
background-color: #f2f2f4;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
.Editor-view-mode-btn {
|
||||
user-select: none;
|
||||
padding: 0;
|
||||
border-radius: 4px;
|
||||
width: 40px;
|
||||
height: 24px;
|
||||
cursor: pointer;
|
||||
transition: transform ease-out 0.2s;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-right: 12px;
|
||||
|
||||
svg {
|
||||
color: $editor-default-color;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
&:hover > svg {
|
||||
color: $editor-active-color;
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background: $editor-active-color;
|
||||
|
||||
svg {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: #5086f5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.Editor-header-actions {
|
||||
flex: 1 1 565px;
|
||||
padding: 0 24px;
|
||||
font-size: 12px;
|
||||
white-space: nowrap;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
|
||||
.header-action-item {
|
||||
margin-left: 18px;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
transition: transform ease-out 0.2s;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
> svg {
|
||||
width: 16px;
|
||||
fill: $editor-default-color;
|
||||
}
|
||||
|
||||
&:hover > svg {
|
||||
fill: $editor-active-color;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
cursor: not-allowed;
|
||||
|
||||
> svg {
|
||||
fill: $disabled-color;
|
||||
}
|
||||
}
|
||||
|
||||
// 历史记录icon单独处理
|
||||
> svg.icon-editor-history {
|
||||
color: $editor-default-color;
|
||||
|
||||
&:hover {
|
||||
color: $editor-active-color;
|
||||
}
|
||||
|
||||
&.disabled,
|
||||
&.disabled:hover {
|
||||
cursor: not-allowed;
|
||||
color: $disabled-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.header-action-btn {
|
||||
margin-left: 8px;
|
||||
user-select: none;
|
||||
cursor: pointer;
|
||||
padding: 0 16px;
|
||||
min-width: 72px;
|
||||
height: 32px;
|
||||
font-family: PingFangSC-Regular;
|
||||
font-size: 12px;
|
||||
line-height: 20px;
|
||||
color: #fff;
|
||||
font-weight: 400;
|
||||
background: $editor-active-color;
|
||||
border-color: 1px solid $editor-active-color;
|
||||
border-radius: 4px;
|
||||
transition: transform ease-out 0.2s;
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
&.preview-btn {
|
||||
color: #151a26;
|
||||
border: 1px solid #dadbdd;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
|
||||
&:hover {
|
||||
color: $editor-active-color;
|
||||
border-color: $editor-active-color;
|
||||
background: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
background: $editor-hover-color;
|
||||
border-color: $editor-hover-color;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
cursor: not-allowed;
|
||||
color: $disabled-color;
|
||||
background-color: $disabled-bg-color;
|
||||
border-color: $disabled-bg-color;
|
||||
}
|
||||
}
|
||||
|
||||
.margin-left-space {
|
||||
margin-left: 80px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.Editor-inner {
|
||||
position: relative;
|
||||
flex: 1 1 auto;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.resizer {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
margin-left: -2px;
|
||||
width: 4px;
|
||||
background: lighten($dark, 20%);
|
||||
z-index: 1;
|
||||
cursor: col-resize;
|
||||
|
||||
&:hover {
|
||||
background: $dark;
|
||||
}
|
||||
}
|
||||
|
||||
.doc-shcema-preview-popover {
|
||||
box-shadow: none;
|
||||
margin-top: -1px;
|
||||
padding: 0 45px;
|
||||
left: 0 !important;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
background: transparent;
|
||||
border: none;
|
||||
|
||||
.doc-schema-preview {
|
||||
border: 1px solid #ddd;
|
||||
background: rgb(240, 243, 244);
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
#root > .a-Select-popover {
|
||||
z-index: 1500;
|
||||
}
|
||||
|
||||
.schema-tpl-preview {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
|
||||
> *:first-child {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
background-color: rgb(43, 43, 43);
|
||||
}
|
||||
}
|
||||
|
||||
.PanelPreview {
|
||||
background-color: #fff;
|
||||
padding: 0 20px 20px 20px;
|
||||
position: relative;
|
||||
width: 400px;
|
||||
flex-shrink: 0;
|
||||
|
||||
> .editor-right-panel {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
> .react-json-view {
|
||||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
142
packages/amis-editor/examples/utils/overwriteSchemaTpl.tsx
Normal file
@@ -0,0 +1,142 @@
|
||||
import {remarkTpl} from '../../src/index';
|
||||
import {getSchemaTpl, setSchemaTpl} from '../../../amis-editor-core/src/index';
|
||||
|
||||
/** 国际化组件类型 */
|
||||
enum I18nComptType {
|
||||
InputText = 'input-text',
|
||||
Textarea = 'textarea',
|
||||
TextareaFormula = 'textarea-formula',
|
||||
RichText = 'rich-text',
|
||||
ButtonLabel = 'button-label'
|
||||
}
|
||||
|
||||
/** 缓存已经重写过的 tpl 名称 */
|
||||
const overwriteNames: {[propName: string]: boolean} = {};
|
||||
|
||||
/** 重写 schema tpl */
|
||||
const overwriteSchemaTpl = (
|
||||
name: string,
|
||||
i18nType = I18nComptType.InputText,
|
||||
options?: {[key: string]: any}
|
||||
) => {
|
||||
if (overwriteNames[name]) {
|
||||
throw new Error(name + 'has been rewritten');
|
||||
}
|
||||
overwriteNames[name] = true;
|
||||
|
||||
const getType = () => {
|
||||
if (i18nType === I18nComptType.InputText) {
|
||||
return 'input-text-i18n';
|
||||
}
|
||||
if (i18nType === I18nComptType.Textarea) {
|
||||
return 'textarea-i18n';
|
||||
}
|
||||
return 'input-text-i18n';
|
||||
};
|
||||
|
||||
setSchemaTpl(
|
||||
name,
|
||||
getSchemaTpl(
|
||||
name,
|
||||
options
|
||||
? options
|
||||
: {
|
||||
type: getType()
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
overwriteSchemaTpl('label');
|
||||
overwriteSchemaTpl('btnLabel');
|
||||
overwriteSchemaTpl('placeholder');
|
||||
overwriteSchemaTpl('startPlaceholder');
|
||||
overwriteSchemaTpl('endPlaceholder');
|
||||
overwriteSchemaTpl('option');
|
||||
overwriteSchemaTpl('description', I18nComptType.Textarea);
|
||||
overwriteSchemaTpl('pageTitle');
|
||||
overwriteSchemaTpl('pageSubTitle', I18nComptType.Textarea);
|
||||
overwriteSchemaTpl('tpl:rich-text', I18nComptType.RichText);
|
||||
overwriteSchemaTpl('prefix');
|
||||
overwriteSchemaTpl('suffix');
|
||||
overwriteSchemaTpl('unit');
|
||||
overwriteSchemaTpl('optionsTip');
|
||||
overwriteSchemaTpl('tableCellRemark');
|
||||
overwriteSchemaTpl('title');
|
||||
overwriteSchemaTpl('caption');
|
||||
overwriteSchemaTpl('imageCaption');
|
||||
overwriteSchemaTpl('inputBody');
|
||||
overwriteSchemaTpl('stepSubTitle');
|
||||
overwriteSchemaTpl('stepDescription');
|
||||
overwriteSchemaTpl('taskNameLabel');
|
||||
overwriteSchemaTpl('operationLabel');
|
||||
overwriteSchemaTpl('statusLabel');
|
||||
overwriteSchemaTpl('remarkLabel');
|
||||
overwriteSchemaTpl('inputArrayItem');
|
||||
overwriteSchemaTpl('actionPrevLabel');
|
||||
overwriteSchemaTpl('actionNextLabel');
|
||||
overwriteSchemaTpl('actionNextSaveLabel');
|
||||
overwriteSchemaTpl('actionFinishLabel');
|
||||
overwriteSchemaTpl('imgCaption', I18nComptType.Textarea);
|
||||
overwriteSchemaTpl('taskRemark', I18nComptType.Textarea);
|
||||
overwriteSchemaTpl('tooltip', I18nComptType.Textarea);
|
||||
overwriteSchemaTpl('anchorTitle');
|
||||
overwriteSchemaTpl('avatarText');
|
||||
overwriteSchemaTpl('cardTitle');
|
||||
overwriteSchemaTpl('cardSubTitle');
|
||||
overwriteSchemaTpl('cardsPlaceholder');
|
||||
overwriteSchemaTpl('cardDesc', I18nComptType.Textarea);
|
||||
overwriteSchemaTpl('imageTitle');
|
||||
overwriteSchemaTpl('imageDesc', I18nComptType.Textarea);
|
||||
overwriteSchemaTpl('fetchSuccess');
|
||||
overwriteSchemaTpl('fetchFailed');
|
||||
overwriteSchemaTpl('saveOrderSuccess');
|
||||
overwriteSchemaTpl('saveOrderFailed');
|
||||
overwriteSchemaTpl('quickSaveSuccess');
|
||||
overwriteSchemaTpl('quickSaveFailed');
|
||||
overwriteSchemaTpl('saveSuccess');
|
||||
overwriteSchemaTpl('saveFailed');
|
||||
overwriteSchemaTpl('validateFailed');
|
||||
overwriteSchemaTpl('tablePlaceholder');
|
||||
overwriteSchemaTpl('collapseOpenHeader');
|
||||
overwriteSchemaTpl('matrixColumnLabel');
|
||||
overwriteSchemaTpl('matrixRowLabel');
|
||||
overwriteSchemaTpl('matrixRowTitle');
|
||||
overwriteSchemaTpl('submitText');
|
||||
overwriteSchemaTpl('tpl:btnLabel', I18nComptType.ButtonLabel);
|
||||
overwriteSchemaTpl('switchOption');
|
||||
overwriteSchemaTpl('createBtnLabel');
|
||||
overwriteSchemaTpl('tableCellPlaceholder');
|
||||
overwriteSchemaTpl('addOnLabel');
|
||||
overwriteSchemaTpl('onText');
|
||||
overwriteSchemaTpl('offText');
|
||||
overwriteSchemaTpl('propertyTitle');
|
||||
overwriteSchemaTpl('propertyLabel');
|
||||
overwriteSchemaTpl('propertyContent');
|
||||
overwriteSchemaTpl('draggableTip');
|
||||
overwriteSchemaTpl('deleteConfirmText');
|
||||
overwriteSchemaTpl('optionsLabel');
|
||||
overwriteSchemaTpl('checkAllLabel');
|
||||
overwriteSchemaTpl('name');
|
||||
overwriteSchemaTpl('anchorNavTitle');
|
||||
|
||||
setSchemaTpl(
|
||||
'remark',
|
||||
remarkTpl({
|
||||
name: 'remark',
|
||||
label: '控件提示',
|
||||
labelRemark:
|
||||
'在输入控件旁展示提示,注意控件宽度需设置,否则提示触发图标将自动换行',
|
||||
i18nEnabled: true
|
||||
})
|
||||
);
|
||||
|
||||
setSchemaTpl(
|
||||
'labelRemark',
|
||||
remarkTpl({
|
||||
name: 'labelRemark',
|
||||
label: '标题提示',
|
||||
labelRemark: '在标题旁展示提示',
|
||||
i18nEnabled: true
|
||||
})
|
||||
);
|
||||
37
packages/amis-editor/i18nConfig.js
Normal file
@@ -0,0 +1,37 @@
|
||||
module.exports = {
|
||||
entry: {
|
||||
dir: './src'
|
||||
},
|
||||
file: {
|
||||
test: /.*(ts|tsx|js|jsx)$/
|
||||
},
|
||||
ignore: {
|
||||
list: ['src/icons', 'src/locale']
|
||||
},
|
||||
importInfo: {
|
||||
source: 'i18n-runtime',
|
||||
imported: 'i18n',
|
||||
local: '_i18n'
|
||||
},
|
||||
i18nModule: 'i18n-runtime',
|
||||
languages: [
|
||||
{
|
||||
name: 'en-US',
|
||||
path: './src/locale'
|
||||
},
|
||||
{
|
||||
name: 'zh-CN',
|
||||
path: './src/locale'
|
||||
}
|
||||
],
|
||||
output: {
|
||||
fileName: 'editor-i18n',
|
||||
fileExtension: 'xlsx',
|
||||
path: './'
|
||||
},
|
||||
translate: {
|
||||
appId: '20230324001613652', // 私人翻译账户,如有国际化需求,请申请自己的百度翻译服务
|
||||
key: 'Sprp7Mz8_yydeyhYrgE0',
|
||||
host: 'http://api.fanyi.baidu.com'
|
||||
}
|
||||
};
|
||||
57
packages/amis-editor/index.html
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>amis 可视化编辑器</title>
|
||||
<link
|
||||
data-react-helmet="true"
|
||||
rel="shortcut icon"
|
||||
href="https://avatars.githubusercontent.com/u/78204817?s=200&v=4"
|
||||
/>
|
||||
<link
|
||||
data-react-helmet="true"
|
||||
rel="shortcut icon"
|
||||
href="https://avatars.githubusercontent.com/u/78204817?s=200&v=4"
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://bce.bdstatic.com/iconfont/iconfont.css"
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="../../../node_modules/@fortawesome/fontawesome-free/css/all.css"
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="../../../node_modules/@fortawesome/fontawesome-free/css/v4-shims.css"
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
title="cxd"
|
||||
id="baseStyle"
|
||||
href="../amis-ui/scss/themes/cxd.scss"
|
||||
/>
|
||||
<link rel="stylesheet" title="cxd" href="../amis-ui/scss/helper.scss" />
|
||||
<link rel="stylesheet" href="../amis-editor-core/scss/editor.scss" />
|
||||
<link rel="stylesheet" href="../../../examples/doc.css" />
|
||||
<link rel="stylesheet" href="./examples/style.scss" />
|
||||
<style>
|
||||
.app-wrapper {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module">
|
||||
import {bootstrap} from './index';
|
||||
|
||||
var initialState = {};
|
||||
bootstrap(document.getElementById('root'), initialState);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
208
packages/amis-editor/index.tsx
Normal file
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* @file entry of this example.
|
||||
* @author fex
|
||||
*/
|
||||
import React from 'react';
|
||||
import {createRoot} from 'react-dom/client';
|
||||
|
||||
import {Layout, AsideNav, Spinner, NotFound} from 'amis-ui';
|
||||
import {eachTree, TreeArray, TreeItem} from 'amis-core';
|
||||
import {
|
||||
HashRouter as Router,
|
||||
Route,
|
||||
Redirect,
|
||||
Switch,
|
||||
Link,
|
||||
NavLink
|
||||
} from 'react-router-dom';
|
||||
import Doc from './examples/component/Doc';
|
||||
|
||||
function MDComponent(fN: () => Promise<{default: {raw: string}}>) {
|
||||
return React.lazy(() =>
|
||||
fN().then(ret => ({default: () => <Doc children={ret.default.raw} />}))
|
||||
);
|
||||
}
|
||||
|
||||
const pages: TreeArray = [
|
||||
{
|
||||
label: '面板模版',
|
||||
children: [
|
||||
{
|
||||
label: '基础',
|
||||
path: '/basic',
|
||||
component: MDComponent(() => import('./examples/route/Basic.md'))
|
||||
},
|
||||
|
||||
{
|
||||
label: '公式',
|
||||
path: '/formula',
|
||||
component: MDComponent(() => import('./examples/route/Formula.md'))
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
function getPath(path: string) {
|
||||
return path ? (path[0] === '/' ? path : `/${path}`) : '';
|
||||
}
|
||||
|
||||
function isActive(link: any, location: any) {
|
||||
return !!(link.path && getPath(link.path) === location.pathname);
|
||||
}
|
||||
|
||||
export function navigations2route(
|
||||
navigations: any,
|
||||
additionalProperties?: any
|
||||
) {
|
||||
let routes: any = [];
|
||||
|
||||
navigations.forEach((root: any) => {
|
||||
root.children &&
|
||||
eachTree(root.children, (item: any) => {
|
||||
if (item.path && item.component) {
|
||||
routes.push(
|
||||
additionalProperties ? (
|
||||
<Route
|
||||
key={routes.length + 1}
|
||||
path={item.path[0] === '/' ? item.path : `/${item.path}`}
|
||||
render={(props: any) => (
|
||||
<item.component {...additionalProperties} {...props} />
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<Route
|
||||
key={routes.length + 1}
|
||||
path={item.path[0] === '/' ? item.path : `/${item.path}`}
|
||||
component={item.component}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return routes;
|
||||
}
|
||||
|
||||
export function Main() {
|
||||
function renderAside() {
|
||||
return (
|
||||
<AsideNav
|
||||
navigations={pages.map((item: any) => ({
|
||||
...item,
|
||||
children: item.children
|
||||
? item.children.map((item: any) => ({
|
||||
...item,
|
||||
className: 'is-top'
|
||||
}))
|
||||
: []
|
||||
}))}
|
||||
renderLink={({
|
||||
link,
|
||||
active,
|
||||
toggleExpand,
|
||||
classnames: cx,
|
||||
depth
|
||||
}: any) => {
|
||||
let children: any[] = [];
|
||||
|
||||
if (link.children && link.children.length) {
|
||||
children.push(
|
||||
<span
|
||||
key="expand-toggle"
|
||||
className={cx('AsideNav-itemArrow')}
|
||||
onClick={e => toggleExpand(link, e)}
|
||||
></span>
|
||||
);
|
||||
}
|
||||
|
||||
link.badge &&
|
||||
children.push(
|
||||
<b
|
||||
key="badge"
|
||||
className={cx(
|
||||
`AsideNav-itemBadge`,
|
||||
link.badgeClassName || 'bg-info'
|
||||
)}
|
||||
>
|
||||
{link.badge}
|
||||
</b>
|
||||
);
|
||||
|
||||
if (link.icon) {
|
||||
children.push(
|
||||
<i key="icon" className={cx(`AsideNav-itemIcon`, link.icon)} />
|
||||
);
|
||||
}
|
||||
|
||||
children.push(
|
||||
<span className={cx('AsideNav-itemLabel')} key="label">
|
||||
{link.label}
|
||||
</span>
|
||||
);
|
||||
|
||||
return link.path ? (
|
||||
/^https?\:/.test(link.path) ? (
|
||||
<a target="_blank" href={link.path} rel="noopener">
|
||||
{children}
|
||||
</a>
|
||||
) : (
|
||||
<Link
|
||||
to={
|
||||
getPath(link.path) ||
|
||||
(link.children && getPath(link.children[0].path))
|
||||
}
|
||||
>
|
||||
{children}
|
||||
</Link>
|
||||
)
|
||||
) : (
|
||||
<a onClick={link.children ? () => toggleExpand(link) : undefined}>
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
}}
|
||||
isActive={(link: any) => isActive(link, location)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Router>
|
||||
<React.Suspense
|
||||
fallback={<Spinner overlay spinnerClassName="m-t-lg" size="lg" />}
|
||||
>
|
||||
<Switch>
|
||||
<Route
|
||||
component={React.lazy(() => import('./examples/App'))}
|
||||
exact
|
||||
path="/"
|
||||
/>
|
||||
<Layout
|
||||
header={
|
||||
<div id="headerBar" className="box-shadow bg-dark">
|
||||
<div className={`cxd-Layout-brand`}>编辑器面板示例</div>
|
||||
<Link to="/">回到编辑器</Link>
|
||||
</div>
|
||||
}
|
||||
aside={renderAside()}
|
||||
>
|
||||
<React.Suspense
|
||||
fallback={<Spinner overlay spinnerClassName="m-t-lg" size="lg" />}
|
||||
>
|
||||
<Switch>
|
||||
{navigations2route(pages)}
|
||||
<Route render={() => <NotFound description="Not found" />} />
|
||||
</Switch>
|
||||
</React.Suspense>
|
||||
</Layout>
|
||||
</Switch>
|
||||
</React.Suspense>
|
||||
</Router>
|
||||
);
|
||||
}
|
||||
|
||||
export function bootstrap(mountTo: HTMLElement, initalState: any) {
|
||||
const root = createRoot(mountTo);
|
||||
root.render(<Main />);
|
||||
}
|
||||
110
packages/amis-editor/package.json
Normal file
@@ -0,0 +1,110 @@
|
||||
{
|
||||
"name": "amis-editor",
|
||||
"version": "6.13.0",
|
||||
"description": "amis 可视化编辑器",
|
||||
"main": "lib/index.js",
|
||||
"module": "esm/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./lib/index.js",
|
||||
"import": "./esm/index.js"
|
||||
},
|
||||
"./lib/*": {
|
||||
"require": "./lib/*.js",
|
||||
"import": "./esm/*.js"
|
||||
},
|
||||
"./*": {
|
||||
"require": "./lib/*.js",
|
||||
"import": "./esm/*.js"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "echo \"Warnings: no test specified\"",
|
||||
"build": "npm run clean-dist && cross-env NODE_ENV=production rollup -c ",
|
||||
"build-esm": "npm run clean-dist && cross-env NODE_ENV=production rollup -c rollup.esm.config.js",
|
||||
"clean-dist": "rimraf lib/** esm/**",
|
||||
"i18n:update": "npx i18n update --config=./i18nConfig.js",
|
||||
"i18n:translate": "npx i18n translate --config=./i18nConfig.js --l=en-US",
|
||||
"i18n:merge": "npx i18n merge --config=./i18nConfig.js --l=en-US",
|
||||
"format": "prettier --write \"src/**/**/*.{js,jsx,ts,tsx,vue,scss,json}\""
|
||||
},
|
||||
"keywords": [
|
||||
"amis",
|
||||
"editor"
|
||||
],
|
||||
"author": "@fex",
|
||||
"license": "ISC",
|
||||
"files": [
|
||||
"lib",
|
||||
"esm"
|
||||
],
|
||||
"dependencies": {
|
||||
"@webcomponents/webcomponentsjs": "^2.6.0",
|
||||
"amis-editor-core": "^6.13.0",
|
||||
"amis-postcss": "1.0.0",
|
||||
"amis-theme-editor-helper": "*",
|
||||
"i18n-runtime": "*",
|
||||
"lodash": "^4.17.15",
|
||||
"mobx-state-tree": "^3.17.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fortawesome/fontawesome-free": "^6.1.1",
|
||||
"@rollup/plugin-commonjs": "^22.0.0",
|
||||
"@rollup/plugin-json": "^4.1.0",
|
||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||
"@rollup/plugin-typescript": "^8.3.2",
|
||||
"@svgr/rollup": "^6.2.1",
|
||||
"@types/async": "^2.0.45",
|
||||
"@types/codemirror": "5.60.10",
|
||||
"@types/deep-diff": "^1.0.0",
|
||||
"@types/history": "^4.6.0",
|
||||
"@types/hoist-non-react-statics": "^3.0.1",
|
||||
"@types/lodash": "^4.14.76",
|
||||
"@types/node": "^14.0.24",
|
||||
"@types/qs": "^6.5.1",
|
||||
"@types/react": "^18.0.24",
|
||||
"@types/react-dom": "^18.0.8",
|
||||
"@types/react-router": "^4.0.16",
|
||||
"@types/react-router-dom": "^5.1.7",
|
||||
"@types/sortablejs": "^1.10.7",
|
||||
"@types/tinycolor2": "^1.4.3",
|
||||
"ajv": "^8.8.2",
|
||||
"axios": "0.21.1",
|
||||
"concurrently": "^6.2.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"css-loader": "^6.2.0",
|
||||
"faker": "^5.5.3",
|
||||
"i18n-command": "^0.0.23-beta.15",
|
||||
"mini-css-extract-plugin": "^2.3.0",
|
||||
"prettier": "^2.2.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-overlays": "5.1.1",
|
||||
"react-router": "5.2.1",
|
||||
"react-router-dom": "5.3.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.73.0",
|
||||
"rollup-plugin-auto-external": "^2.0.0",
|
||||
"rollup-plugin-license": "^2.7.0",
|
||||
"sass": "^1.49.7",
|
||||
"sass-loader": "^12.5.0",
|
||||
"style-loader": "^3.2.1",
|
||||
"stylelint": "^14.11.0",
|
||||
"ts-jest": "^28.0.3",
|
||||
"ts-loader": "^9.2.5",
|
||||
"ts-node": "^10.5.0",
|
||||
"tslib": "^2.3.1",
|
||||
"typescript": "^4.6.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"amis": "*",
|
||||
"amis-core": "*",
|
||||
"amis-formula": "*",
|
||||
"amis-theme-editor-helper": "*",
|
||||
"amis-ui": "*",
|
||||
"i18n-runtime": "*",
|
||||
"react": ">=16.8.6",
|
||||
"react-dom": ">=16.8.6"
|
||||
}
|
||||
}
|
||||
185
packages/amis-editor/rollup.config.js
Normal file
@@ -0,0 +1,185 @@
|
||||
// rollup.config.js
|
||||
import commonjs from '@rollup/plugin-commonjs';
|
||||
import json from '@rollup/plugin-json';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import typescript from '@rollup/plugin-typescript';
|
||||
import license from 'rollup-plugin-license';
|
||||
import autoExternal from 'rollup-plugin-auto-external';
|
||||
import {
|
||||
name,
|
||||
version,
|
||||
author,
|
||||
main,
|
||||
module,
|
||||
dependencies
|
||||
} from './package.json';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import svgr from '@svgr/rollup';
|
||||
import i18nPlugin from 'plugin-react-i18n';
|
||||
import moment from 'moment';
|
||||
|
||||
const i18nConfig = require('./i18nConfig');
|
||||
|
||||
const settings = {
|
||||
globals: {},
|
||||
commonConfig: {}
|
||||
};
|
||||
|
||||
const pkgs = [];
|
||||
// 读取所有的node_modules目录,获取所有的包名
|
||||
[
|
||||
path.join(__dirname, './node_modules'),
|
||||
path.join(__dirname, '../../node_modules')
|
||||
].forEach(dir => {
|
||||
if (fs.existsSync(dir)) {
|
||||
fs.readdirSync(dir).forEach(item => {
|
||||
if (item.startsWith('.')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.startsWith('@')) {
|
||||
fs.readdirSync(path.join(dir, item)).forEach(subItem => {
|
||||
pkgs.push(item + '/' + subItem);
|
||||
});
|
||||
}
|
||||
|
||||
return pkgs.push(item);
|
||||
});
|
||||
}
|
||||
});
|
||||
const external = id =>
|
||||
pkgs.some(pkg => id.startsWith(pkg) || ~id.indexOf(`node_modules/${pkg}`));
|
||||
const input = './src/index.tsx';
|
||||
|
||||
export default [
|
||||
{
|
||||
input,
|
||||
|
||||
output: [
|
||||
{
|
||||
...settings,
|
||||
...settings.commonConfig,
|
||||
dir: path.dirname(main),
|
||||
format: 'cjs',
|
||||
exports: 'named',
|
||||
preserveModulesRoot: './src',
|
||||
preserveModules: true // Keep directory structure and files
|
||||
}
|
||||
],
|
||||
external,
|
||||
plugins: getPlugins('cjs')
|
||||
},
|
||||
{
|
||||
input,
|
||||
|
||||
output: [
|
||||
{
|
||||
...settings,
|
||||
...settings.commonConfig,
|
||||
dir: path.dirname(module),
|
||||
format: 'esm',
|
||||
exports: 'named',
|
||||
preserveModulesRoot: './src',
|
||||
preserveModules: true // Keep directory structure and files
|
||||
}
|
||||
],
|
||||
external,
|
||||
plugins: getPlugins('esm')
|
||||
}
|
||||
];
|
||||
|
||||
function transpileDynamicImportForCJS(options) {
|
||||
return {
|
||||
name: 'transpile-dynamic-import-for-cjs',
|
||||
renderDynamicImport({format, targetModuleId}) {
|
||||
if (format !== 'cjs') {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require([',
|
||||
right:
|
||||
', "tslib"], function(mod, tslib) {fullfill(tslib.__importStar(mod))})})})'
|
||||
};
|
||||
|
||||
// return {
|
||||
// left: 'Promise.resolve().then(function() {return new Promise(function(fullfill) {require.ensure([',
|
||||
// right:
|
||||
// '], function(r) {fullfill(_interopDefaultLegacy(r("' +
|
||||
// targetModuleId +
|
||||
// '")))})})})'
|
||||
// };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getPlugins(format = 'esm') {
|
||||
const typeScriptOptions = {
|
||||
typescript: require('typescript'),
|
||||
sourceMap: false,
|
||||
outputToFilesystem: true,
|
||||
...(format === 'esm'
|
||||
? {
|
||||
compilerOptions: {
|
||||
rootDir: './src',
|
||||
outDir: path.dirname(module)
|
||||
}
|
||||
}
|
||||
: {
|
||||
compilerOptions: {
|
||||
rootDir: './src',
|
||||
outDir: path.dirname(main)
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
return [
|
||||
i18nPlugin(i18nConfig),
|
||||
typescript(typeScriptOptions),
|
||||
svgr({
|
||||
svgProps: {
|
||||
className: 'icon'
|
||||
},
|
||||
prettier: false,
|
||||
dimensions: false
|
||||
}),
|
||||
transpileDynamicImportForCJS(),
|
||||
autoExternal(),
|
||||
json(),
|
||||
resolve({
|
||||
jsnext: true,
|
||||
main: true
|
||||
}),
|
||||
commonjs({
|
||||
sourceMap: false
|
||||
}),
|
||||
license({
|
||||
banner: `
|
||||
${name} v${version}
|
||||
build time: <%=moment().format('YYYY-MM-DD')%>
|
||||
Copyright 2018<%= moment().format('YYYY') > 2018 ? '-' + moment().format('YYYY') : null %> ${author}
|
||||
`
|
||||
}),
|
||||
onRollupError(error => {
|
||||
console.warn(`[构建异常]${error}`);
|
||||
// 构建异常时,删除 tsconfig.tsbuildinfo
|
||||
fs.unlink(path.resolve(__dirname, 'tsconfig.tsbuildinfo'), () => {
|
||||
console.info(
|
||||
'[构建异常]已自动删除tsconfig.tsbuildinfo,请重试构建命令。'
|
||||
);
|
||||
});
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
function onRollupError(callback = () => {}) {
|
||||
return {
|
||||
name: 'onerror',
|
||||
buildEnd(err) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
5
packages/amis-editor/rollup.esm.config.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import config from "./rollup.config";
|
||||
|
||||
const esmConfig = config[1];
|
||||
|
||||
export default esmConfig;
|
||||
1537
packages/amis-editor/src/builder/ApiDSBuilder.ts
Normal file
292
packages/amis-editor/src/builder/DSBuilder.ts
Normal file
@@ -0,0 +1,292 @@
|
||||
/**
|
||||
* @file DSBuilder.ts
|
||||
* @desc 数据源配置构建器
|
||||
*/
|
||||
|
||||
import {EditorManager} from 'amis-editor-core';
|
||||
import {getFeatValueByKey, getFeatLabelByKey} from './utils';
|
||||
|
||||
import type {EditorNodeType} from 'amis-editor-core';
|
||||
import type {
|
||||
DSFeatureType,
|
||||
GenericSchema,
|
||||
CRUDScaffoldConfig,
|
||||
FormScaffoldConfig
|
||||
} from './type';
|
||||
|
||||
export interface DSBuilderBaseOptions {
|
||||
/** 渲染器类型 */
|
||||
renderer: string;
|
||||
/** Form应用场景 */
|
||||
feat?: DSFeatureType;
|
||||
/** CRUD应用场景 */
|
||||
feats?: DSFeatureType[];
|
||||
/** 当前组件的 Schema */
|
||||
schema?: GenericSchema;
|
||||
/** 数据源字段名 */
|
||||
sourceKey?: string;
|
||||
/** 是否在脚手架环境中 */
|
||||
inScaffold?: boolean;
|
||||
/** 如果为列表类容器,则会返回对应的节点 */
|
||||
scopeNode?: EditorNodeType;
|
||||
/** 数据源控件配置项 */
|
||||
sourceSettings?: Record<string, any>;
|
||||
/** 字段控件配置项 */
|
||||
fieldSettings?: Record<string, any>;
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
export interface DSBuilderInterface<
|
||||
T extends DSBuilderBaseOptions = DSBuilderBaseOptions
|
||||
> {
|
||||
/** 数据源中文名称,主要用于前端展示 */
|
||||
readonly name: string;
|
||||
|
||||
/** 构造器排序权重,数字越小排序越靠前,支持负数 */
|
||||
readonly order: number;
|
||||
|
||||
/** 数据源支持的功能场景 */
|
||||
readonly features: DSFeatureType[];
|
||||
|
||||
/** 是否为默认 */
|
||||
isDefault?: boolean;
|
||||
|
||||
/** 实例获取数据源的key */
|
||||
key: string;
|
||||
|
||||
/** 是否禁用 */
|
||||
disabledOn?: () => boolean;
|
||||
|
||||
/** 获取功能场景的value */
|
||||
getFeatValueByKey(feat: DSFeatureType): string;
|
||||
|
||||
/** 获取功能场景的label */
|
||||
getFeatLabelByKey(feat: DSFeatureType): string;
|
||||
|
||||
/** 按照功能场景过滤 */
|
||||
filterByFeat(feat: any): boolean;
|
||||
|
||||
/** 根据schema,判断是否匹配当前数据源 */
|
||||
match(schema?: any, key?: string): boolean;
|
||||
|
||||
/** 当前上下文中使用的字段 */
|
||||
getContextFields(options: T): Promise<any>;
|
||||
|
||||
/** 当前上下文可以使用的字段 */
|
||||
getAvailableContextFields(
|
||||
options: Omit<T, 'renderer'>,
|
||||
target: EditorNodeType
|
||||
): Promise<any>;
|
||||
|
||||
/** 获取CRUD列表字段 */
|
||||
getCRUDListFields?: <F extends Record<string, any>>(
|
||||
options: T
|
||||
) => Promise<F[]>;
|
||||
|
||||
/** 获取CRUD简单查询字段 */
|
||||
getCRUDSimpleQueryFields?: <F extends Record<string, any>>(
|
||||
options: T
|
||||
) => Promise<F[]>;
|
||||
|
||||
/** 构建简单查询表单项 */
|
||||
buildSimpleQueryCollectionSchema?: (
|
||||
options: T
|
||||
) => Promise<GenericSchema[] | undefined>;
|
||||
|
||||
/** 获取CRUD高级查询字段 */
|
||||
getCRUDAdvancedQueryFields?: <F extends Record<string, any>>(
|
||||
options: T
|
||||
) => Promise<F[]>;
|
||||
|
||||
/** 构建高级查询 */
|
||||
buildAdvancedQuerySchema?: (options: T) => Promise<GenericSchema | undefined>;
|
||||
|
||||
/** 获取CRUD模糊查询字段 */
|
||||
getCRUDFuzzyQueryFields?: <F extends Record<string, any>>(
|
||||
options: T
|
||||
) => Promise<F[]>;
|
||||
|
||||
/** 构建模糊查询 */
|
||||
buildFuzzyQuerySchema?: (options: T) => Promise<GenericSchema | undefined>;
|
||||
|
||||
/** 构造数据源的可视化配置表单 */
|
||||
makeSourceSettingForm(options: T): any[];
|
||||
|
||||
/** 构造数据源字段的可视化配置表单 */
|
||||
makeFieldsSettingForm(options: T): any[];
|
||||
|
||||
/** 新建数据 */
|
||||
buildInsertSchema(options: T, componentId?: string): Promise<any>;
|
||||
|
||||
/** 编辑数据 */
|
||||
buildEditSchema(options: T, componentId?: string): Promise<any>;
|
||||
|
||||
/** 批量编辑数据 */
|
||||
buildBulkEditSchema(options: T, componentId?: string): Promise<any>;
|
||||
|
||||
/** 查看详情数据 */
|
||||
buildViewSchema(options: T, componentId?: string): Promise<any>;
|
||||
|
||||
/** 删除数据 */
|
||||
buildCRUDDeleteSchema(options: T, componentId?: string): Promise<any>;
|
||||
|
||||
/** 批量删除数据 */
|
||||
buildCRUDBulkDeleteSchema(options: T, componentId?: string): Promise<any>;
|
||||
|
||||
/** 数据导出 */
|
||||
buildCRUDExportSchema(options: T, componentId?: string): Promise<any>;
|
||||
|
||||
/** 构建 CRUD 的顶部工具栏 */
|
||||
buildCRUDHeaderToolbar?: (
|
||||
options: T,
|
||||
componentId?: string
|
||||
) => Promise<GenericSchema>;
|
||||
|
||||
/** 表格的表头查询 */
|
||||
buildCRUDFilterSchema(options: T, componentId?: string): Promise<any>;
|
||||
|
||||
/** 表格单列 */
|
||||
buildCRUDColumn?: (
|
||||
field: Record<string, any>,
|
||||
options: T,
|
||||
componentId?: string
|
||||
) => Promise<any>;
|
||||
|
||||
/** 表格操作列 */
|
||||
buildCRUDOpColumn?: (options: T, componentId?: string) => Promise<any>;
|
||||
|
||||
/** 表格列 */
|
||||
buildCRUDColumnsSchema(options: T, componentId?: string): Promise<any>;
|
||||
|
||||
/** 表格构建 */
|
||||
buildCRUDSchema(options: T): Promise<any>;
|
||||
|
||||
/** 表单构建 */
|
||||
buildFormSchema(options: T): Promise<any>;
|
||||
|
||||
/** 基于 schema 还原CRUD脚手架配置 */
|
||||
guessCRUDScaffoldConfig<T extends CRUDScaffoldConfig<any, any>>(options: {
|
||||
schema: GenericSchema;
|
||||
[propName: string]: any;
|
||||
}): Promise<T> | T;
|
||||
|
||||
/** 基于 schema 还原Form脚手架配置 */
|
||||
guessFormScaffoldConfig<T extends FormScaffoldConfig<any, any>>(options: {
|
||||
schema: GenericSchema;
|
||||
[propName: string]: any;
|
||||
}): Promise<T> | T;
|
||||
|
||||
/** 重新构建 API 配置 */
|
||||
buildApiSchema(options: T): Promise<any>;
|
||||
}
|
||||
|
||||
export abstract class DSBuilder<T extends DSBuilderBaseOptions>
|
||||
implements DSBuilderInterface<T>
|
||||
{
|
||||
static key: string;
|
||||
readonly name: string;
|
||||
readonly order: number;
|
||||
/** 是否为默认 */
|
||||
readonly isDefault?: boolean;
|
||||
|
||||
features: DSFeatureType[];
|
||||
|
||||
constructor(readonly manager: EditorManager) {}
|
||||
|
||||
/** 实例获取数据源的key */
|
||||
get key() {
|
||||
return (this.constructor as typeof DSBuilder<T>).key;
|
||||
}
|
||||
|
||||
/** 获取功能场景的value */
|
||||
getFeatValueByKey(feat: DSFeatureType) {
|
||||
return getFeatValueByKey(feat);
|
||||
}
|
||||
|
||||
/** 获取功能场景的label */
|
||||
getFeatLabelByKey(feat: DSFeatureType) {
|
||||
return getFeatLabelByKey(feat);
|
||||
}
|
||||
|
||||
filterByFeat(feat: any) {
|
||||
return feat && this.features.includes(feat);
|
||||
}
|
||||
|
||||
abstract match(schema?: any, key?: string): boolean;
|
||||
|
||||
abstract getContextFields(options: T): Promise<any>;
|
||||
|
||||
abstract getAvailableContextFields(
|
||||
options: Omit<T, 'renderer'>,
|
||||
target: EditorNodeType
|
||||
): Promise<any>;
|
||||
|
||||
abstract makeSourceSettingForm(options: T): any[];
|
||||
|
||||
abstract makeFieldsSettingForm(options: T): any[];
|
||||
|
||||
/** 新建数据 */
|
||||
abstract buildInsertSchema(options: T): Promise<any>;
|
||||
|
||||
/** 查看详情数据 */
|
||||
abstract buildViewSchema(options: T): Promise<any>;
|
||||
|
||||
/** 编辑数据 */
|
||||
abstract buildEditSchema(options: T): Promise<any>;
|
||||
|
||||
/** 批量编辑数据 */
|
||||
abstract buildBulkEditSchema(options: T): Promise<any>;
|
||||
|
||||
/** 删除数据 */
|
||||
abstract buildCRUDDeleteSchema(options: T): Promise<any>;
|
||||
|
||||
/** 批量删除数据 */
|
||||
abstract buildCRUDBulkDeleteSchema(options: T): Promise<any>;
|
||||
|
||||
/** 数据导出 */
|
||||
abstract buildCRUDExportSchema(options: T): Promise<any>;
|
||||
|
||||
/** 表格的表头查询 */
|
||||
abstract buildCRUDFilterSchema(options: T): Promise<any>;
|
||||
|
||||
/** 表格列 */
|
||||
abstract buildCRUDColumnsSchema(options: T): Promise<any>;
|
||||
|
||||
/** 表格 */
|
||||
abstract buildCRUDSchema(options: T): Promise<any>;
|
||||
|
||||
/** 表单 */
|
||||
abstract buildFormSchema(options: T): Promise<any>;
|
||||
|
||||
/** 基于 schema 还原CRUD脚手架配置 */
|
||||
abstract guessCRUDScaffoldConfig<
|
||||
T extends CRUDScaffoldConfig<any, any>
|
||||
>(options: {schema: GenericSchema; [propName: string]: any}): Promise<T> | T;
|
||||
|
||||
/** 基于 schema 还原Form脚手架配置 */
|
||||
abstract guessFormScaffoldConfig<
|
||||
T extends FormScaffoldConfig<any, any>
|
||||
>(options: {schema: GenericSchema; [propName: string]: any}): Promise<T> | T;
|
||||
|
||||
abstract buildApiSchema(options: T): Promise<any>;
|
||||
}
|
||||
|
||||
export interface DSBuilderClass {
|
||||
new (manager: EditorManager): DSBuilderInterface;
|
||||
/** 数据源类型,使用英文,可以覆盖同名 */
|
||||
key: string;
|
||||
}
|
||||
|
||||
export const builderFactory = new Map<string, DSBuilderClass>();
|
||||
|
||||
/** 注册数据源构造器 */
|
||||
export const registerDSBuilder = (klass: DSBuilderClass) => {
|
||||
if (builderFactory.has(klass.key)) {
|
||||
console.warn(
|
||||
`[amis-editor][DSBuilder] duplicate DSBuilder「${klass.key}」`
|
||||
);
|
||||
}
|
||||
|
||||
/** 重名覆盖 */
|
||||
builderFactory.set(klass.key, klass);
|
||||
};
|
||||
174
packages/amis-editor/src/builder/DSBuilderManager.ts
Normal file
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* @file DSBuilderManager
|
||||
* @desc 数据源构造管理器
|
||||
*/
|
||||
|
||||
import {builderFactory, DSBuilderInterface} from './DSBuilder';
|
||||
|
||||
import type {EditorManager} from 'amis-editor-core';
|
||||
import type {GenericSchema} from './type';
|
||||
import type {Option} from 'amis-core';
|
||||
|
||||
export class DSBuilderManager {
|
||||
private builders: Map<string, DSBuilderInterface>;
|
||||
|
||||
constructor(manager: EditorManager) {
|
||||
this.builders = new Map();
|
||||
|
||||
builderFactory.forEach((Builder, key) => {
|
||||
this.builders.set(key, new Builder(manager));
|
||||
});
|
||||
}
|
||||
|
||||
get size() {
|
||||
return this.builders.size;
|
||||
}
|
||||
|
||||
getBuilderByKey(key: string) {
|
||||
return this.builders.get(key);
|
||||
}
|
||||
|
||||
getBuilderByScaffoldSetting(scaffoldConfig: any) {
|
||||
return this.builders.get(scaffoldConfig.dsType);
|
||||
}
|
||||
|
||||
getBuilderBySchema(schema: any, sourceKey?: string) {
|
||||
let builder: DSBuilderInterface | undefined;
|
||||
|
||||
for (let [key, value] of Array.from(this.builders.entries())) {
|
||||
if (value.match(schema, sourceKey)) {
|
||||
builder = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return builder ? builder : this.getDefaultBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认构建器Key
|
||||
*
|
||||
* @returns 返回默认构建器Key
|
||||
*/
|
||||
getDefaultBuilderKey() {
|
||||
const collections = Array.from(this.builders.entries()).filter(
|
||||
([_, builder]) => builder?.disabledOn?.() !== true
|
||||
);
|
||||
const [defaultKey, _] =
|
||||
collections.find(([_, builder]) => builder.isDefault === true) ??
|
||||
collections.sort((lhs, rhs) => {
|
||||
return (lhs[1].order ?? 0) - (rhs[1].order ?? 0);
|
||||
})?.[0] ??
|
||||
[];
|
||||
|
||||
return defaultKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认构建器
|
||||
*
|
||||
* @returns {Object} 默认构建器
|
||||
*/
|
||||
getDefaultBuilder() {
|
||||
const collections = Array.from(this.builders.entries()).filter(
|
||||
([_, builder]) => builder?.disabledOn?.() !== true
|
||||
);
|
||||
const [_, defaultBuilder] =
|
||||
collections.find(([_, builder]) => builder.isDefault === true) ??
|
||||
collections.sort((lhs, rhs) => {
|
||||
return (lhs[1].order ?? 0) - (rhs[1].order ?? 0);
|
||||
})?.[0] ??
|
||||
[];
|
||||
|
||||
return defaultBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可用的构建器列表
|
||||
*
|
||||
* @returns 返回可用构建器的列表
|
||||
*/
|
||||
getAvailableBuilders() {
|
||||
return Array.from(this.builders.entries())
|
||||
.filter(([_, builder]) => builder?.disabledOn?.() !== true)
|
||||
.sort((lhs, rhs) => {
|
||||
return (lhs[1].order ?? 0) - (rhs[1].order ?? 0);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据选择器Schema
|
||||
*
|
||||
* @param patch - 需要进行补丁修复的配置对象
|
||||
* @param config - 包含运行上下文和源键的配置对象
|
||||
* @returns 返回一个对象,包含类型、标签、名称、可见性、选项、默认值和pipeIn等属性
|
||||
*/
|
||||
getDSSelectorSchema(
|
||||
patch: Record<string, any>,
|
||||
config?: {
|
||||
/** 组件 Schema */
|
||||
schema: GenericSchema;
|
||||
/** 组件数据源 Key */
|
||||
sourceKey: string;
|
||||
/** 获取默认值函数 */
|
||||
getDefautlValue?: (key: string, builder: DSBuilderInterface) => Boolean;
|
||||
}
|
||||
) {
|
||||
const {schema, sourceKey, getDefautlValue} = config || {};
|
||||
const builders = this.getAvailableBuilders();
|
||||
let defaultValue: string | undefined = schema?.dsType;
|
||||
const options: Option[] = [];
|
||||
|
||||
for (const [key, builder] of builders) {
|
||||
if (schema && !defaultValue) {
|
||||
if (
|
||||
getDefautlValue &&
|
||||
typeof getDefautlValue === 'function' &&
|
||||
getDefautlValue(key, builder)
|
||||
) {
|
||||
defaultValue = key;
|
||||
} else if (builder.match(schema, sourceKey)) {
|
||||
defaultValue = key;
|
||||
}
|
||||
}
|
||||
|
||||
options.push({
|
||||
label: builder.name,
|
||||
value: key
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'radios',
|
||||
label: '数据来源',
|
||||
name: 'dsType',
|
||||
visible: options.length > 0,
|
||||
options: options,
|
||||
...(defaultValue ? {value: defaultValue} : {}),
|
||||
...patch
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 从构建器中生成集合
|
||||
*
|
||||
* @param callback 回调函数,用于处理每个构建器、构建器键和索引
|
||||
* @returns 返回生成的集合
|
||||
*/
|
||||
buildCollectionFromBuilders(
|
||||
callback: (
|
||||
builder: DSBuilderInterface,
|
||||
builderKey: string,
|
||||
index: number
|
||||
) => any
|
||||
) {
|
||||
const builders = this.getAvailableBuilders();
|
||||
const collection = builders
|
||||
.map(([key, builder], index) => {
|
||||
return callback(builder, key, index);
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
134
packages/amis-editor/src/builder/constants.ts
Normal file
@@ -0,0 +1,134 @@
|
||||
/**
|
||||
* @file constants.ts
|
||||
* @desc builder 相关常量
|
||||
*/
|
||||
|
||||
import {FormOperatorValue, FormOperator} from './type';
|
||||
|
||||
/**
|
||||
* 数据源所需操作,目前是因为schema从后端来
|
||||
*/
|
||||
export enum DSBehavior {
|
||||
/** 创建操作 */
|
||||
create = 'create',
|
||||
/** 查询操作 */
|
||||
view = 'view',
|
||||
/** 更新操作 */
|
||||
update = 'update',
|
||||
table = 'table',
|
||||
filter = 'filter'
|
||||
}
|
||||
|
||||
/** 数据粒度 */
|
||||
export enum DSGrain {
|
||||
/** 实体 */
|
||||
entity = 'entity',
|
||||
/** 多条数据 */
|
||||
list = 'list',
|
||||
/** 单条数据 */
|
||||
piece = 'piece'
|
||||
}
|
||||
|
||||
/** 数据源所使用的功能场景 */
|
||||
export const DSFeature = {
|
||||
List: {
|
||||
value: 'list',
|
||||
label: '列表'
|
||||
},
|
||||
Insert: {
|
||||
value: 'insert',
|
||||
label: '新增'
|
||||
},
|
||||
View: {
|
||||
value: 'view',
|
||||
label: '详情'
|
||||
},
|
||||
Edit: {
|
||||
value: 'edit',
|
||||
label: '编辑'
|
||||
},
|
||||
Delete: {
|
||||
value: 'delete',
|
||||
label: '删除'
|
||||
},
|
||||
BulkEdit: {
|
||||
value: 'bulkEdit',
|
||||
label: '批量编辑'
|
||||
},
|
||||
BulkDelete: {
|
||||
value: 'bulkDelete',
|
||||
label: '批量删除'
|
||||
},
|
||||
Import: {
|
||||
value: 'import',
|
||||
label: '导入'
|
||||
},
|
||||
Export: {
|
||||
value: 'export',
|
||||
label: '数据导出'
|
||||
},
|
||||
SimpleQuery: {
|
||||
value: 'simpleQuery',
|
||||
label: '简单查询'
|
||||
},
|
||||
FuzzyQuery: {
|
||||
value: 'fuzzyQuery',
|
||||
label: '模糊查询'
|
||||
},
|
||||
AdvancedQuery: {
|
||||
value: 'advancedQuery',
|
||||
label: '高级查询'
|
||||
}
|
||||
};
|
||||
|
||||
export enum DSFeatureEnum {
|
||||
List = 'List',
|
||||
Insert = 'Insert',
|
||||
View = 'View',
|
||||
Edit = 'Edit',
|
||||
Delete = 'Delete',
|
||||
BulkEdit = 'BulkEdit',
|
||||
BulkDelete = 'BulkDelete',
|
||||
Import = 'Import',
|
||||
Export = 'Export',
|
||||
SimpleQuery = 'SimpleQuery',
|
||||
FuzzyQuery = 'FuzzyQuery',
|
||||
AdvancedQuery = 'AdvancedQuery'
|
||||
}
|
||||
|
||||
export const DSFeatureList = Object.keys(
|
||||
DSFeature
|
||||
) as (keyof typeof DSFeature)[];
|
||||
|
||||
export const FormOperatorMap: Record<FormOperatorValue, FormOperator> = {
|
||||
cancel: {
|
||||
label: '取消',
|
||||
value: 'cancel',
|
||||
order: 0,
|
||||
schema: {
|
||||
level: 'default'
|
||||
}
|
||||
},
|
||||
reset: {
|
||||
label: '重置',
|
||||
value: 'reset',
|
||||
order: 1,
|
||||
schema: {
|
||||
level: 'default'
|
||||
}
|
||||
},
|
||||
submit: {
|
||||
label: '提交',
|
||||
value: 'submit',
|
||||
order: 2,
|
||||
schema: {
|
||||
level: 'primary'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const ModelDSBuilderKey = 'model-entity';
|
||||
|
||||
export const ApiDSBuilderKey = 'api';
|
||||
|
||||
export const ApiCenterDSBuilderKey = 'apicenter';
|
||||
7
packages/amis-editor/src/builder/index.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export * from './type';
|
||||
export * from './constants';
|
||||
export * from './utils';
|
||||
export * from './DSBuilder';
|
||||
export * from './DSBuilderManager';
|
||||
|
||||
import './ApiDSBuilder';
|
||||
126
packages/amis-editor/src/builder/type.ts
Normal file
@@ -0,0 +1,126 @@
|
||||
/**
|
||||
* @file type.ts
|
||||
* @desc builder 相关声明
|
||||
*/
|
||||
|
||||
import {DSFeature} from './constants';
|
||||
import type {BaseApiObject} from 'amis-core';
|
||||
|
||||
export interface DSField {
|
||||
value: string;
|
||||
label: string;
|
||||
[propKey: string]: any;
|
||||
}
|
||||
|
||||
/** 数据源字段集合 */
|
||||
export interface DSFieldGroup {
|
||||
value: string;
|
||||
label: string;
|
||||
children: DSField[];
|
||||
[propKey: string]: any;
|
||||
}
|
||||
|
||||
export type DSFeatureType = keyof typeof DSFeature;
|
||||
|
||||
export type GenericSchema = Record<string, any>;
|
||||
|
||||
export type DSRendererType = 'form' | 'crud' | 'service';
|
||||
|
||||
export interface ScaffoldField {
|
||||
/** 标题 */
|
||||
label: string;
|
||||
/** 字段名 */
|
||||
name: string;
|
||||
/** 展示控件类型 */
|
||||
displayType: string;
|
||||
/** 输入控件类型 */
|
||||
inputType: string;
|
||||
typeKey?: string;
|
||||
/** 是否启用 */
|
||||
checked?: boolean;
|
||||
}
|
||||
|
||||
/** 表单操作 */
|
||||
export type ApiConfig = string | BaseApiObject;
|
||||
|
||||
/** 表单操作 */
|
||||
export type FormOperatorValue = 'cancel' | 'reset' | 'submit';
|
||||
|
||||
/** 表单操作按钮 */
|
||||
export interface FormOperator {
|
||||
label: string;
|
||||
value: FormOperatorValue;
|
||||
order: number;
|
||||
schema: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface ScaffoldConfigBase {
|
||||
/** 数据源类型 */
|
||||
dsType: string;
|
||||
/** 重新构建时用户的原始 Schema */
|
||||
__pristineSchema?: Record<string, any>;
|
||||
[propName: string]: any;
|
||||
}
|
||||
|
||||
export interface FormScaffoldConfig<
|
||||
Fields extends Record<string, any> = ScaffoldField,
|
||||
API extends any = ApiConfig
|
||||
> extends ScaffoldConfigBase {
|
||||
/** Form功能场景 */
|
||||
feat?: DSFeatureType;
|
||||
/** 表单初始化接口 */
|
||||
initApi?: API;
|
||||
insertApi?: API;
|
||||
editApi?: API;
|
||||
bulkEditApi?: API;
|
||||
insertFields?: Fields[];
|
||||
editFields?: Fields[];
|
||||
bulkEditFields?: Fields[];
|
||||
operators?: FormOperator[];
|
||||
}
|
||||
|
||||
export interface CRUDScaffoldConfig<
|
||||
Fields extends Record<string, any> = ScaffoldField,
|
||||
API extends any = ApiConfig
|
||||
> extends ScaffoldConfigBase {
|
||||
/** 工具栏 */
|
||||
tools?: Extract<
|
||||
DSFeatureType,
|
||||
'Insert' | 'BulkDelete' | 'BulkEdit' | 'Export'
|
||||
>[];
|
||||
/** 数据操作 */
|
||||
operators?: Extract<DSFeatureType, 'View' | 'Edit' | 'Delete'>[];
|
||||
/** 条件查询 */
|
||||
filters?: Extract<
|
||||
DSFeatureType,
|
||||
'FuzzyQuery' | 'SimpleQuery' | 'AdvancedQuery'
|
||||
>[];
|
||||
/** 表格 list 接口 */
|
||||
listApi?: API;
|
||||
viewApi?: API;
|
||||
editApi?: API;
|
||||
/** 编辑表单的初始化接口 */
|
||||
initApi?: API;
|
||||
bulkEditApi?: API;
|
||||
deleteApi?: API;
|
||||
bulkDeleteApi?: API;
|
||||
exportApi?: API;
|
||||
insertApi?: API;
|
||||
listFields?: Fields[];
|
||||
insertFields?: Fields[];
|
||||
viewFields?: Fields[];
|
||||
editFields?: Fields[];
|
||||
bulkEditFields?: Fields[];
|
||||
fuzzyQueryFields?: Fields[];
|
||||
simpleQueryFields?: Fields[];
|
||||
advancedQueryFields?: Fields[];
|
||||
importFields?: Fields[];
|
||||
exportFields?: Fields[];
|
||||
/** 表格脚手架时的主键 */
|
||||
primaryField?: string;
|
||||
}
|
||||
|
||||
export type ScaffoldConfig<
|
||||
Fields extends Record<string, any> = ScaffoldField,
|
||||
API extends any = ApiConfig
|
||||
> = FormScaffoldConfig<Fields, API> | CRUDScaffoldConfig<Fields, API>;
|
||||
95
packages/amis-editor/src/builder/utils.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* @file utils
|
||||
* @desc builder用到的 utils
|
||||
*/
|
||||
|
||||
import isObjectLike from 'lodash/isObjectLike';
|
||||
import {DSFeature} from './constants';
|
||||
import type {DSFeatureType} from './type';
|
||||
|
||||
export const getFeatValueByKey = (feat: DSFeatureType) => {
|
||||
return `${DSFeature?.[feat]?.value}`;
|
||||
};
|
||||
|
||||
export const getFeatLabelByKey = (feat: DSFeatureType) => {
|
||||
return `${DSFeature?.[feat]?.label}`;
|
||||
};
|
||||
|
||||
const _traverseSchemaDeep = (
|
||||
schema: Record<string, any>,
|
||||
mapper: (originKey: string, originValue: any, origin: any) => any[],
|
||||
cache = new WeakMap()
|
||||
) => {
|
||||
const target: Record<string, any> = {};
|
||||
|
||||
if (cache.has(schema)) {
|
||||
return cache.get(schema);
|
||||
}
|
||||
|
||||
cache.set(schema, target);
|
||||
|
||||
const mapArray = (arr: any[]): any =>
|
||||
arr.map((item: any) => {
|
||||
return isObjectLike(item)
|
||||
? _traverseSchemaDeep(item, mapper, cache)
|
||||
: item;
|
||||
});
|
||||
|
||||
if (Array.isArray(schema)) {
|
||||
return mapArray(schema);
|
||||
}
|
||||
|
||||
for (const [key, value] of Object.entries(schema)) {
|
||||
const result = mapper(key, value, schema);
|
||||
|
||||
let [updatedKey, updatedValue] = result;
|
||||
|
||||
if (updatedKey === '__proto__') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isObjectLike(updatedValue)) {
|
||||
updatedValue = Array.isArray(updatedValue)
|
||||
? mapArray(updatedValue)
|
||||
: _traverseSchemaDeep(updatedValue, mapper, cache);
|
||||
}
|
||||
|
||||
target[updatedKey] = updatedValue;
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
export const traverseSchemaDeep = (
|
||||
schema: Record<string, any>,
|
||||
mapper: (originKey: string, originValue: any, origin: any) => any[]
|
||||
) => {
|
||||
if (!isObjectLike(schema)) {
|
||||
return schema;
|
||||
}
|
||||
|
||||
if (Array.isArray(schema)) {
|
||||
return schema;
|
||||
}
|
||||
|
||||
return _traverseSchemaDeep(schema, mapper);
|
||||
};
|
||||
|
||||
/** CRUD列类型转 Form 表单类型 */
|
||||
export const displayType2inputType = (inputType: string): string => {
|
||||
if (!inputType || typeof inputType !== 'string') {
|
||||
return inputType;
|
||||
}
|
||||
|
||||
const map: Record<string, string> = {
|
||||
tpl: 'input-text',
|
||||
image: 'input-image',
|
||||
date: 'input-date',
|
||||
progress: 'input-number',
|
||||
status: 'tag',
|
||||
mapping: 'tag',
|
||||
list: 'input-table'
|
||||
};
|
||||
|
||||
return map.hasOwnProperty(inputType) ? map[inputType] : inputType;
|
||||
};
|
||||
512
packages/amis-editor/src/component/BaseControl.ts
Normal file
@@ -0,0 +1,512 @@
|
||||
/**
|
||||
* @file 基础控件集合
|
||||
*/
|
||||
|
||||
import flatten from 'lodash/flatten';
|
||||
import {NO_SUPPORT_STATIC_FORMITEM_CMPTS} from '../renderer/event-control/constants';
|
||||
import {getEventControlConfig} from '../renderer/event-control/helper';
|
||||
import {getSchemaTpl, isObject, tipedLabel} from 'amis-editor-core';
|
||||
import type {BaseEventContext} from 'amis-editor-core';
|
||||
import {getRendererByName} from 'amis-core';
|
||||
|
||||
// 默认动作
|
||||
export const BUTTON_DEFAULT_ACTION = {
|
||||
onEvent: {
|
||||
click: {
|
||||
actions: []
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export type PrimitiveType = string | number | boolean;
|
||||
/**
|
||||
* 校验项
|
||||
* 数组项为 ValidationType 或 对象形式的配置
|
||||
* 对象形式配置规则 优先匹配 isShow 形式,后匹配 isHidden 形式
|
||||
* 如下:
|
||||
*/
|
||||
export type ValidationOptions = Array<{
|
||||
option: string;
|
||||
isShow?: {
|
||||
// 匹配条件展示该校验项
|
||||
[key: string]: PrimitiveType | Array<PrimitiveType>;
|
||||
};
|
||||
isHidden?: {
|
||||
// 匹配条件隐藏该校验项
|
||||
[key: string]: PrimitiveType | Array<PrimitiveType>;
|
||||
};
|
||||
}>;
|
||||
|
||||
export type FormItemControlPanel =
|
||||
| 'property'
|
||||
| 'common'
|
||||
| 'option'
|
||||
| 'status'
|
||||
| 'validation'
|
||||
| 'style'
|
||||
| 'option'
|
||||
| 'event';
|
||||
|
||||
/**
|
||||
* Label提示
|
||||
* 支持传入Schema或String,传入String则使用默认配置,如下:
|
||||
*
|
||||
* @default
|
||||
* ```
|
||||
* className: 'ae-BaseRemark',
|
||||
* icon: 'fa fa-question-circle',
|
||||
* trigger: ['hover', 'click'],
|
||||
* placement: 'left'
|
||||
* ```
|
||||
*/
|
||||
export const BaseLabelMark = (schema: Record<string, any> | string) => {
|
||||
const base = {
|
||||
className: 'ae-BaseRemark',
|
||||
icon: 'fa fa-question-circle',
|
||||
trigger: ['hover', 'click'],
|
||||
placement: 'left',
|
||||
content: ''
|
||||
};
|
||||
|
||||
if (!isObject(schema) || typeof schema === 'string') {
|
||||
return schema ? {...base, content: schema.toString()} : undefined;
|
||||
}
|
||||
|
||||
const {className, content, ...rest} = schema;
|
||||
|
||||
return content
|
||||
? {
|
||||
...base,
|
||||
...rest,
|
||||
...(className
|
||||
? {className: `${base.className} ${rest.className}`}
|
||||
: {}),
|
||||
content
|
||||
}
|
||||
: undefined;
|
||||
};
|
||||
|
||||
const normalizCollapsedGroup = (publicProps = {}, body: any) => {
|
||||
return body
|
||||
? Array.isArray(body)
|
||||
? body
|
||||
.filter(item => item)
|
||||
.map((item, index) => ({
|
||||
...publicProps,
|
||||
key: item.key || index.toString(),
|
||||
...item,
|
||||
body: flatten(item.body)
|
||||
}))
|
||||
: [
|
||||
{
|
||||
...publicProps,
|
||||
key: '0',
|
||||
...body
|
||||
}
|
||||
]
|
||||
: [];
|
||||
};
|
||||
|
||||
/**
|
||||
* 更新/归一化处理表单项
|
||||
*
|
||||
* @param defaultBody 默认配置
|
||||
* @param body 输入配置
|
||||
* @param replace 是否完全替换
|
||||
* @returns
|
||||
*/
|
||||
const normalizeBodySchema = (
|
||||
defaultBody: Array<Record<string, any>>,
|
||||
body: Array<Record<string, any>> | Record<string, any>,
|
||||
replace: boolean = false,
|
||||
reverse: boolean = false,
|
||||
order: Record<string, number> = {}
|
||||
) => {
|
||||
const normalizedBody = body
|
||||
? Array.isArray(body)
|
||||
? body.concat()
|
||||
: [body]
|
||||
: [];
|
||||
const schema = flatten(
|
||||
replace
|
||||
? normalizedBody
|
||||
: reverse
|
||||
? [...normalizedBody, ...defaultBody]
|
||||
: [...defaultBody, ...normalizedBody]
|
||||
);
|
||||
|
||||
return schema;
|
||||
};
|
||||
|
||||
/**
|
||||
* 表单项组件面板
|
||||
*
|
||||
* @param {Object=} panels
|
||||
* @param {string=} key
|
||||
* `property` 属性
|
||||
* `common` 基本
|
||||
* `status` 状态
|
||||
* `validation` 校验
|
||||
* `style` 样式
|
||||
* `event` 事件
|
||||
* @param {string=} panels.body - 配置面板Schema
|
||||
* @param {boolean=} panels.replace - 是否完全替换默认Schema,默认追加
|
||||
* @param {Array} panels.validation.validationType - 默认显示的校验类型
|
||||
*/
|
||||
export const formItemControl: (
|
||||
panels: Partial<
|
||||
Record<
|
||||
FormItemControlPanel,
|
||||
{
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* 配置项内容
|
||||
*/
|
||||
body?: any;
|
||||
|
||||
/**
|
||||
* 是否完全替换默认配置项
|
||||
*/
|
||||
replace?: boolean;
|
||||
|
||||
/**
|
||||
* 配置项倒序排列
|
||||
*/
|
||||
reverse?: boolean;
|
||||
|
||||
/**
|
||||
* 是否隐藏面板
|
||||
*/
|
||||
hidden?: boolean;
|
||||
|
||||
/**
|
||||
* 配置项排序优先级
|
||||
*/
|
||||
order?: Record<string, number>;
|
||||
|
||||
/**
|
||||
* 默认支持的校验规则
|
||||
*/
|
||||
validationType?: ValidationOptions;
|
||||
}
|
||||
>
|
||||
>,
|
||||
context?: BaseEventContext
|
||||
) => Array<any> = (panels, context) => {
|
||||
const type = context?.schema?.type || '';
|
||||
const render = getRendererByName(type);
|
||||
const supportStatic =
|
||||
!!render?.isFormItem && !NO_SUPPORT_STATIC_FORMITEM_CMPTS.includes(type);
|
||||
const collapseProps = {
|
||||
type: 'collapse',
|
||||
headingClassName: 'ae-formItemControl-header ae-Collapse-header',
|
||||
bodyClassName: 'ae-formItemControl-body'
|
||||
};
|
||||
// 已经配置了的属性
|
||||
const propsList = Object.keys(context?.schema ?? {});
|
||||
// 选项面版内容,支持Option的组件才展示该面板
|
||||
const optionBody = normalizeBodySchema(
|
||||
[],
|
||||
panels?.option?.body,
|
||||
panels?.option?.replace
|
||||
);
|
||||
// 属性面板配置
|
||||
const collapseGroupBody = panels?.property
|
||||
? normalizCollapsedGroup(collapseProps, panels?.property)
|
||||
: [
|
||||
{
|
||||
...collapseProps,
|
||||
header: '基本',
|
||||
key: 'common',
|
||||
body: normalizeBodySchema(
|
||||
[
|
||||
getSchemaTpl('formItemName', {
|
||||
required: true
|
||||
}),
|
||||
getSchemaTpl('label'),
|
||||
getSchemaTpl('labelRemark'),
|
||||
getSchemaTpl('remark'),
|
||||
getSchemaTpl('placeholder'),
|
||||
getSchemaTpl('description')
|
||||
],
|
||||
panels?.common?.body,
|
||||
panels?.common?.replace,
|
||||
panels?.common?.reverse
|
||||
)
|
||||
},
|
||||
...(optionBody.length !== 0
|
||||
? [
|
||||
{
|
||||
...collapseProps,
|
||||
header: panels?.option?.title || '选项',
|
||||
key: 'option',
|
||||
body: optionBody
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
...collapseProps,
|
||||
header: '状态',
|
||||
key: 'status',
|
||||
body: normalizeBodySchema(
|
||||
[
|
||||
getSchemaTpl('visible'),
|
||||
getSchemaTpl('hidden'),
|
||||
getSchemaTpl('clearValueOnHidden'),
|
||||
supportStatic ? getSchemaTpl('static') : null,
|
||||
// TODO: 下面的部分表单项才有,是不是判断一下是否是表单项
|
||||
getSchemaTpl('disabled')
|
||||
],
|
||||
panels?.status?.body,
|
||||
panels?.status?.replace,
|
||||
panels?.status?.reverse
|
||||
)
|
||||
}
|
||||
// ...(panels?.validation?.hidden
|
||||
// ? []
|
||||
// : [
|
||||
// {
|
||||
// ...collapseProps,
|
||||
// className: 'ae-ValidationControl-Panel',
|
||||
// header: '校验',
|
||||
// key: 'validation',
|
||||
// body: normalizeBodySchema(
|
||||
// [
|
||||
// getSchemaTpl(
|
||||
// 'validationControl',
|
||||
// panels?.validation?.validationType
|
||||
// ),
|
||||
// getSchemaTpl('validateOnChange'),
|
||||
// getSchemaTpl('submitOnChange')
|
||||
// ],
|
||||
// panels?.validation?.body,
|
||||
// panels?.validation?.replace,
|
||||
// panels?.validation?.reverse
|
||||
// )
|
||||
// }
|
||||
// ])
|
||||
];
|
||||
return [
|
||||
{
|
||||
type: 'tabs',
|
||||
tabsMode: 'line',
|
||||
className: 'editor-prop-config-tabs',
|
||||
linksClassName: 'editor-prop-config-tabs-links',
|
||||
contentClassName: 'no-border editor-prop-config-tabs-cont',
|
||||
tabs: [
|
||||
{
|
||||
title: '属性',
|
||||
className: 'p-none',
|
||||
body: [
|
||||
{
|
||||
type: 'collapse-group',
|
||||
expandIconPosition: 'right',
|
||||
expandIcon: {
|
||||
type: 'icon',
|
||||
icon: 'chevron-right'
|
||||
},
|
||||
className: 'ae-formItemControl',
|
||||
activeKey: collapseGroupBody.map((group, index) => group.key),
|
||||
body: collapseGroupBody
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: '外观',
|
||||
body: normalizeBodySchema(
|
||||
[
|
||||
getSchemaTpl('formItemMode'),
|
||||
getSchemaTpl('horizontalMode'),
|
||||
getSchemaTpl('horizontal', {
|
||||
label: '',
|
||||
visibleOn:
|
||||
'this.mode == "horizontal" && this.label !== false && this.horizontal'
|
||||
}),
|
||||
// renderer.sizeMutable !== false
|
||||
// ? getSchemaTpl('formItemSize')
|
||||
// : null,
|
||||
getSchemaTpl('formItemInline'),
|
||||
getSchemaTpl('className'),
|
||||
getSchemaTpl('className', {
|
||||
label: 'Label CSS 类名',
|
||||
name: 'labelClassName'
|
||||
}),
|
||||
getSchemaTpl('className', {
|
||||
label: '控件 CSS 类名',
|
||||
name: 'inputClassName'
|
||||
}),
|
||||
getSchemaTpl('className', {
|
||||
label: '描述 CSS 类名',
|
||||
name: 'descriptionClassName',
|
||||
visibleOn: 'this.description'
|
||||
}),
|
||||
...(!supportStatic
|
||||
? []
|
||||
: [
|
||||
getSchemaTpl('className', {
|
||||
label: '静态 CSS 类名',
|
||||
name: 'staticClassName'
|
||||
})
|
||||
])
|
||||
],
|
||||
panels?.style?.body,
|
||||
panels?.style?.replace,
|
||||
panels?.style?.reverse
|
||||
)
|
||||
},
|
||||
...(isObject(context) && !panels?.event?.hidden
|
||||
? [
|
||||
{
|
||||
title: '事件',
|
||||
className: 'p-none',
|
||||
body: normalizeBodySchema(
|
||||
[
|
||||
getSchemaTpl('eventControl', {
|
||||
name: 'onEvent',
|
||||
...getEventControlConfig(
|
||||
context!.info.plugin.manager,
|
||||
context!
|
||||
)
|
||||
})
|
||||
],
|
||||
panels?.event?.body,
|
||||
panels?.event?.replace
|
||||
)
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
/**
|
||||
* 信息提示组件模版
|
||||
*/
|
||||
export function remarkTpl(config: {
|
||||
name: 'remark' | 'labelRemark';
|
||||
label: string;
|
||||
labelRemark?: string;
|
||||
i18nEnabled?: boolean;
|
||||
}) {
|
||||
return {
|
||||
type: 'ae-switch-more',
|
||||
formType: 'dialog',
|
||||
className: 'ae-switch-more-flex',
|
||||
label: config.labelRemark
|
||||
? tipedLabel(config.label, config.labelRemark)
|
||||
: config.label,
|
||||
bulk: false,
|
||||
name: config.name,
|
||||
defaultData: {
|
||||
icon: 'fa fa-question-circle',
|
||||
trigger: ['hover'],
|
||||
className: 'Remark--warning',
|
||||
placement: 'top'
|
||||
},
|
||||
form: {
|
||||
size: 'md',
|
||||
className: 'mb-8',
|
||||
mode: 'horizontal',
|
||||
horizontal: {
|
||||
left: 4,
|
||||
right: 8,
|
||||
justify: true
|
||||
},
|
||||
body: {
|
||||
type: 'grid',
|
||||
className: 'pt-4 right-panel-pop :AMISCSSWrapper',
|
||||
gap: 'lg',
|
||||
columns: [
|
||||
{
|
||||
md: '6',
|
||||
body: [
|
||||
{
|
||||
name: 'title',
|
||||
type: !config.i18nEnabled ? 'input-text' : 'input-text-i18n',
|
||||
label: '提示标题',
|
||||
placeholder: '请输入提示标题'
|
||||
},
|
||||
{
|
||||
name: 'content',
|
||||
type: !config.i18nEnabled ? 'textarea' : 'textarea-i18n',
|
||||
label: '内容'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
md: '6',
|
||||
body: [
|
||||
{
|
||||
name: 'placement',
|
||||
type: 'button-group-select',
|
||||
size: 'md',
|
||||
label: '弹出位置',
|
||||
options: [
|
||||
{
|
||||
label: '上',
|
||||
value: 'top'
|
||||
},
|
||||
{
|
||||
label: '下',
|
||||
value: 'bottom'
|
||||
},
|
||||
{
|
||||
label: '左',
|
||||
value: 'left'
|
||||
},
|
||||
|
||||
{
|
||||
label: '右',
|
||||
value: 'right'
|
||||
}
|
||||
]
|
||||
},
|
||||
getSchemaTpl('icon'),
|
||||
{
|
||||
name: 'className',
|
||||
label: tipedLabel(
|
||||
'CSS 类名',
|
||||
'有哪些辅助类 CSS 类名?请前往 <a href="https://baidu.gitee.io/amis/zh-CN/style/index" target="_blank">样式说明</a>,除此之外你可以添加自定义类名,然后在系统配置中添加自定义样式。'
|
||||
),
|
||||
type: 'input-text'
|
||||
},
|
||||
{
|
||||
name: 'trigger',
|
||||
type: 'select',
|
||||
label: tipedLabel('触发方式', '浮层触发方式默认值为鼠标悬停'),
|
||||
multiple: true,
|
||||
pipeIn: (value: any) =>
|
||||
Array.isArray(value) ? value.join(',') : [],
|
||||
pipeOut: (value: any) =>
|
||||
value && value.length ? value.split(',') : ['hover'],
|
||||
options: [
|
||||
{
|
||||
label: '鼠标悬停',
|
||||
value: 'hover'
|
||||
},
|
||||
{
|
||||
label: '点击',
|
||||
value: 'click'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: 'rootClose',
|
||||
visibleOn: '~this.trigger.indexOf("click")',
|
||||
label: '点击空白关闭',
|
||||
type: 'switch',
|
||||
mode: 'row',
|
||||
inputClassName: 'inline-flex justify-between flex-row-reverse'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
49
packages/amis-editor/src/component/InputComponentName.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import {RendererProps} from 'amis-core';
|
||||
import React, {useEffect, useState} from 'react';
|
||||
|
||||
interface InputComponentNameProps extends RendererProps {
|
||||
value: any;
|
||||
onChange: (value: any) => void;
|
||||
}
|
||||
|
||||
export function InputComponentName(props: InputComponentNameProps) {
|
||||
const {value, onChange, render, name, node, placeholder} = props;
|
||||
const [options, setOptions] = useState<Array<any>>([]);
|
||||
|
||||
useEffect(() => {
|
||||
const thisComp = node?.getComponent();
|
||||
let scoped = thisComp?.context;
|
||||
const comps: Array<any> = [];
|
||||
|
||||
while (scoped?.getComponents) {
|
||||
scoped.getComponents().forEach((c: any) => {
|
||||
if (c.props.name && c !== thisComp) {
|
||||
// todo 把孩子节点拼装成 xxx.xxx
|
||||
comps.push(c.props.name);
|
||||
}
|
||||
});
|
||||
|
||||
scoped = scoped.parent;
|
||||
}
|
||||
setOptions(comps);
|
||||
}, [node]);
|
||||
|
||||
function onInnerChange(value: any) {
|
||||
onChange(value);
|
||||
return false;
|
||||
}
|
||||
|
||||
return render(
|
||||
'inner',
|
||||
{
|
||||
type: 'input-text',
|
||||
name,
|
||||
placeholder
|
||||
},
|
||||
{
|
||||
value,
|
||||
onChange: onInnerChange,
|
||||
options
|
||||
}
|
||||
);
|
||||
}
|
||||
69
packages/amis-editor/src/component/ModalSettingPanel.tsx
Normal file
@@ -0,0 +1,69 @@
|
||||
import {
|
||||
EditorManager,
|
||||
EditorStoreType,
|
||||
SchemaFrom,
|
||||
getSchemaTpl
|
||||
} from 'amis-editor-core';
|
||||
import {observer} from 'mobx-react';
|
||||
import React from 'react';
|
||||
|
||||
export interface ModalSettingPanelProps {
|
||||
store: EditorStoreType;
|
||||
manager: EditorManager;
|
||||
popOverContainer: any;
|
||||
}
|
||||
|
||||
export default observer(function ({
|
||||
store,
|
||||
manager,
|
||||
popOverContainer
|
||||
}: ModalSettingPanelProps) {
|
||||
const body = React.useMemo(() => {
|
||||
return [
|
||||
getSchemaTpl('collapseGroup', [
|
||||
{
|
||||
title: '弹窗入参',
|
||||
body: [
|
||||
{
|
||||
type: 'json-schema-editor',
|
||||
name: 'inputParams',
|
||||
label: false,
|
||||
mini: true,
|
||||
disabledTypes: ['array'],
|
||||
evalMode: true,
|
||||
// variables: '${variables}',
|
||||
addButtonText: '添加入参'
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
];
|
||||
}, []);
|
||||
const node = store.root.firstChild;
|
||||
const value = store.getValueOf(node.id);
|
||||
const onChange = React.useCallback((value: any, diff: any) => {
|
||||
manager.panelChangeValue(value, diff, undefined, node.id);
|
||||
}, []);
|
||||
const env = React.useMemo(
|
||||
() => ({...manager.env, session: 'left-panel-form'}),
|
||||
[]
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="ae-Outline-panel">
|
||||
<div className="panel-header">弹窗参数</div>
|
||||
|
||||
<SchemaFrom
|
||||
body={body}
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
submitOnChange={true}
|
||||
env={env}
|
||||
// popOverContainer={popOverContainer}
|
||||
node={node}
|
||||
manager={manager}
|
||||
justify={true}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
549
packages/amis-editor/src/component/TableViewEditor.tsx
Normal file
@@ -0,0 +1,549 @@
|
||||
/**
|
||||
* @file tableview 相关的可视化编辑,拖动行高等
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import {toast} from 'amis';
|
||||
import {TableViewSchema, TrObject} from 'amis';
|
||||
import {EditorManager} from 'amis-editor-core';
|
||||
import {autobind, JSONGetById, EditorStoreType} from 'amis-editor-core';
|
||||
|
||||
interface TableViewEditorProps {
|
||||
schema: TableViewSchema;
|
||||
manager: EditorManager;
|
||||
children?: any;
|
||||
}
|
||||
|
||||
interface TableViewEditorState {
|
||||
// 行线的 id
|
||||
trIds: string[];
|
||||
// 列线的 id
|
||||
tdIds: string[];
|
||||
// 是否显示合并单元格按钮
|
||||
displayMergeCell: boolean;
|
||||
}
|
||||
|
||||
const ROW_HEIGHT = 42;
|
||||
|
||||
// 找到 td 最多的那一行,将这一行作为列线
|
||||
function findMaxTrChildren(trs: TrObject[]) {
|
||||
let maxSize = 0;
|
||||
let maxIndex = 0;
|
||||
for (let trIndex = 0; trIndex < trs.length; trIndex++) {
|
||||
const childSize = (trs[trIndex].tds || []).length;
|
||||
if (childSize > maxSize) {
|
||||
maxIndex = trIndex;
|
||||
maxSize = childSize;
|
||||
}
|
||||
}
|
||||
return maxIndex;
|
||||
}
|
||||
|
||||
export class TableViewEditor extends React.Component<
|
||||
TableViewEditorProps,
|
||||
TableViewEditorState
|
||||
> {
|
||||
tableViewWrapperRef: React.RefObject<HTMLDivElement>;
|
||||
|
||||
// 下面这些用于行和线的拖拽,来改变高宽
|
||||
// 但这里有个问题还没解决:同一列中如果同时有两个单元格设置宽度,这时究竟该改哪个?
|
||||
draggingId: string;
|
||||
draggingElement: HTMLElement;
|
||||
draggingElementTop: number;
|
||||
draggingElementLeft: number;
|
||||
startX: number;
|
||||
startY: number;
|
||||
maxChildTrIndex: number;
|
||||
|
||||
store: EditorStoreType;
|
||||
|
||||
// 是否进入单元格选择状态,用于单元格合并
|
||||
isSelectionCell: boolean;
|
||||
// 用于单元格合并
|
||||
selectedCell: {
|
||||
[cellId: string]: any;
|
||||
};
|
||||
preventTableClick: boolean = false;
|
||||
|
||||
constructor(props: TableViewEditorProps) {
|
||||
super(props);
|
||||
this.tableViewWrapperRef = React.createRef();
|
||||
this.store = this.props.manager.store;
|
||||
const trs = this.props.schema.trs || [];
|
||||
if (trs.length) {
|
||||
const trsIds = trs.map((tr: any) => tr.$$id);
|
||||
const maxChildTrIndex = findMaxTrChildren(trs);
|
||||
this.maxChildTrIndex = maxChildTrIndex;
|
||||
const tds = trs[maxChildTrIndex].tds || [];
|
||||
const tdsIds = tds.map((td: any) => td.$$id);
|
||||
this.state = {
|
||||
trIds: trsIds,
|
||||
tdIds: tdsIds,
|
||||
displayMergeCell: false
|
||||
};
|
||||
} else {
|
||||
this.state = {
|
||||
trIds: [],
|
||||
tdIds: [],
|
||||
displayMergeCell: false
|
||||
};
|
||||
}
|
||||
|
||||
this.listenTdSelection();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.syncLinePos();
|
||||
this.listenTdSelection();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.removeListenTdSelection();
|
||||
}
|
||||
|
||||
// 同步线数量,主要用于新增行或列
|
||||
syncLineState() {
|
||||
const trs = this.props.schema.trs || [];
|
||||
if (!trs.length) {
|
||||
return;
|
||||
}
|
||||
const trsIds = trs.map((tr: any) => tr.$$id);
|
||||
const maxChildTrIndex = findMaxTrChildren(trs);
|
||||
this.maxChildTrIndex = maxChildTrIndex;
|
||||
const tds = trs[maxChildTrIndex].tds || [];
|
||||
const tdsIds = tds.map((td: any) => td.$$id);
|
||||
this.setState(
|
||||
{
|
||||
trIds: trsIds,
|
||||
tdIds: tdsIds
|
||||
},
|
||||
() => {
|
||||
this.syncLinePos();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@autobind
|
||||
removeListenTdSelection() {
|
||||
const dom = this.tableViewWrapperRef.current;
|
||||
if (dom) {
|
||||
const tbody = dom.querySelector('tbody')!;
|
||||
tbody.removeEventListener('mousedown', this.handleCellMouseDown);
|
||||
tbody.removeEventListener('mousemove', this.handleCellMouseMove);
|
||||
tbody.removeEventListener('mouseup', this.handleCellMouseUp);
|
||||
tbody.removeEventListener('click', this.handleCellMouseClick);
|
||||
}
|
||||
}
|
||||
|
||||
// 监听 td 的拖拽事件,用于实现单元格合并
|
||||
@autobind
|
||||
listenTdSelection() {
|
||||
const dom = this.tableViewWrapperRef.current;
|
||||
if (dom) {
|
||||
const tbody = dom.querySelector('tbody')!;
|
||||
tbody.addEventListener('mousedown', this.handleCellMouseDown);
|
||||
tbody.addEventListener('mousemove', this.handleCellMouseMove);
|
||||
tbody.addEventListener('mouseup', this.handleCellMouseUp);
|
||||
tbody.addEventListener('click', this.handleCellMouseClick);
|
||||
}
|
||||
}
|
||||
|
||||
// 用于单元格合并的点击
|
||||
@autobind
|
||||
handleCellMouseDown(e: MouseEvent) {
|
||||
const td = e.target! as HTMLElement;
|
||||
if (td && td.tagName !== 'TD') {
|
||||
return;
|
||||
}
|
||||
this.removeAllSelectionMark();
|
||||
this.setState({
|
||||
displayMergeCell: false
|
||||
});
|
||||
const tdId = td.getAttribute('data-editor-id')!;
|
||||
this.isSelectionCell = true;
|
||||
this.selectedCell = {
|
||||
[tdId]: JSONGetById(this.props.schema, tdId)
|
||||
};
|
||||
}
|
||||
|
||||
// 用于单元格合并的移动
|
||||
@autobind
|
||||
handleCellMouseMove(e: MouseEvent) {
|
||||
if (this.isSelectionCell) {
|
||||
this.preventTableClick = true; //如果有移动就禁止一次表格 click 事件
|
||||
const td = e.target! as HTMLElement;
|
||||
if (td && td.tagName !== 'TD') {
|
||||
return;
|
||||
}
|
||||
const tdId = td.getAttribute('data-editor-id')!;
|
||||
if (!(tdId in this.selectedCell)) {
|
||||
this.selectedCell[tdId] = JSONGetById(this.props.schema, tdId);
|
||||
this.markSelectingCell();
|
||||
this.setState({
|
||||
displayMergeCell: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查找最大和最小行列位置,考虑跨行的情况,用于单元格合并
|
||||
findFirstAndLastCell() {
|
||||
const tds = [];
|
||||
for (const tdId in this.selectedCell) {
|
||||
tds.push(this.selectedCell[tdId]);
|
||||
}
|
||||
if (!tds.length) {
|
||||
console.warn('必须有 td');
|
||||
}
|
||||
let minCol: number = tds[0].$$col;
|
||||
let minRow: number = tds[0].$$row;
|
||||
let maxCol: number = 0;
|
||||
let maxRow: number = 0;
|
||||
let firstCell = null;
|
||||
let lastCell = null;
|
||||
for (const td of tds) {
|
||||
const col = td.$$col + (td.colspan || 1) - 1; // 这里直接减一不然后面还得弄
|
||||
const row = td.$$row + (td.rowspan || 1) - 1;
|
||||
if (col >= maxCol) {
|
||||
maxCol = col;
|
||||
}
|
||||
if (row >= maxRow) {
|
||||
maxRow = row;
|
||||
}
|
||||
if (td.$$col <= minCol) {
|
||||
minCol = td.$$col;
|
||||
}
|
||||
if (td.$$row <= minRow) {
|
||||
minRow = td.$$row;
|
||||
}
|
||||
if (td.$$col === minCol && td.$$row === minRow) {
|
||||
firstCell = td;
|
||||
}
|
||||
}
|
||||
return {
|
||||
minRow,
|
||||
minCol,
|
||||
maxRow,
|
||||
maxCol,
|
||||
firstCell,
|
||||
lastCell
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择 td 主要是为了单元格合并,它要求是必须是矩形,比如下面的例子
|
||||
* ┌───┬───┬───┬───┐
|
||||
* │ a │ b │ c │ d │
|
||||
* ├───┴───┼───┤ │
|
||||
* │ e │ f │ │
|
||||
* │ ├───┼───┤
|
||||
* │ │ g │ h │
|
||||
* └───────┴───┴───┘
|
||||
* 直接选 a 和 c 是不行的,无法进行单元格合并,所以需要补上 b
|
||||
* 如果选择了 e 和 f,需要自动选择 g 来让整体变成矩形
|
||||
* 这个函数的主要作用就是将矩形补充完整
|
||||
*/
|
||||
markSelectingCell() {
|
||||
// 首先,查找最小和最大的行和列
|
||||
const {minRow, minCol, maxRow, maxCol} = this.findFirstAndLastCell();
|
||||
|
||||
// 变量一遍找出所有在这个范围内的节点,如果不在就添加
|
||||
for (const tr of this.props.schema.trs) {
|
||||
for (const td of tr.tds) {
|
||||
const internalTd = td as any;
|
||||
if (
|
||||
internalTd.$$col >= minCol &&
|
||||
internalTd.$$col <= maxCol &&
|
||||
internalTd.$$row >= minRow &&
|
||||
internalTd.$$row <= maxRow
|
||||
) {
|
||||
if (!(internalTd.$$id in this.selectedCell)) {
|
||||
this.selectedCell[internalTd.$$id] = td;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const dom = this.tableViewWrapperRef.current;
|
||||
if (dom) {
|
||||
const tds = dom.querySelectorAll('td');
|
||||
tds.forEach(td => {
|
||||
const tdId = td.getAttribute('data-editor-id')!;
|
||||
if (tdId in this.selectedCell) {
|
||||
td.setAttribute('data-selected', '1');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 清除之前的单元格选择
|
||||
removeAllSelectionMark() {
|
||||
const dom = this.tableViewWrapperRef.current;
|
||||
if (dom) {
|
||||
const tds = dom.querySelectorAll('td');
|
||||
tds.forEach(td => {
|
||||
td.removeAttribute('data-selected');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@autobind
|
||||
handleCellMouseUp(e: MouseEvent) {
|
||||
this.isSelectionCell = false;
|
||||
}
|
||||
|
||||
// 如果有拖拽的时候就避免选中表格导致状态切换
|
||||
@autobind
|
||||
handleCellMouseClick(e: MouseEvent) {
|
||||
if (this.preventTableClick) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
this.preventTableClick = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 合并单元格操作
|
||||
@autobind
|
||||
handleMergeCell() {
|
||||
const {firstCell, minRow, minCol, maxRow, maxCol} =
|
||||
this.findFirstAndLastCell();
|
||||
if (!firstCell) {
|
||||
console.warn('找不到第一个 cell');
|
||||
return;
|
||||
}
|
||||
|
||||
const firstCellId = firstCell.$$id;
|
||||
const colspan = maxCol - minCol + 1;
|
||||
const rowspan = maxRow - minRow + 1;
|
||||
firstCell.colspan = colspan;
|
||||
firstCell.rowspan = rowspan;
|
||||
const tds = [];
|
||||
for (const tdId in this.selectedCell) {
|
||||
tds.push(this.selectedCell[tdId]);
|
||||
}
|
||||
// 其它单元格,这些单元格会被删掉
|
||||
const otherCellIds = tds
|
||||
.filter(td => td.$$id !== firstCellId)
|
||||
.map(td => td.$$id);
|
||||
|
||||
const trs = this.props.schema.trs;
|
||||
let trIndex = trs.length;
|
||||
while (trIndex--) {
|
||||
const tr = trs[trIndex];
|
||||
tr.tds = tr.tds.filter(td => {
|
||||
return !otherCellIds.includes((td as any).$$id);
|
||||
});
|
||||
if (!tr.tds.length) {
|
||||
trs.splice(trIndex, 1);
|
||||
}
|
||||
}
|
||||
|
||||
const tableId = (this.props.schema as any).$$id;
|
||||
this.store.changeValueById(tableId, this.props.schema);
|
||||
this.setState({displayMergeCell: false});
|
||||
}
|
||||
|
||||
// 同步线的位置
|
||||
syncLinePos() {
|
||||
const dom = this.tableViewWrapperRef.current;
|
||||
if (dom) {
|
||||
const table = dom.querySelector('table')!;
|
||||
const tableRect = table.getBoundingClientRect();
|
||||
const trs = dom.querySelectorAll('tr');
|
||||
if (!trs.length || typeof this.maxChildTrIndex === 'undefined') {
|
||||
return;
|
||||
}
|
||||
const rowLines = Array.from(
|
||||
dom.querySelectorAll<HTMLElement>('.ae-TableViewEditor-rowLine')
|
||||
);
|
||||
for (let trIndex = 0; trIndex < trs.length; trIndex++) {
|
||||
if (!trs[trIndex]) {
|
||||
continue;
|
||||
}
|
||||
const trRect = trs[trIndex].getBoundingClientRect();
|
||||
if (rowLines[trIndex]) {
|
||||
// 线的宽度是 7,所以要减去 3.5
|
||||
rowLines[trIndex].style.top =
|
||||
trRect.top + trRect.height - tableRect.top - 3.5 + 'px';
|
||||
} else {
|
||||
console.warn('行线数量不对');
|
||||
}
|
||||
}
|
||||
const tds = trs[this.maxChildTrIndex].querySelectorAll('td');
|
||||
|
||||
const colLines = Array.from(
|
||||
dom.querySelectorAll<HTMLElement>('.ae-TableViewEditor-colLine')
|
||||
);
|
||||
for (let tdIndex = 0; tdIndex < tds.length; tdIndex++) {
|
||||
const td = tds[tdIndex];
|
||||
if (!td) {
|
||||
continue;
|
||||
}
|
||||
const tdRect = td.getBoundingClientRect();
|
||||
if (colLines[tdIndex]) {
|
||||
colLines[tdIndex].style.left =
|
||||
tdRect.left + tdRect.width - tableRect.left - 3.5 + 'px';
|
||||
} else {
|
||||
console.warn('列线数量不对');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: TableViewEditorProps) {
|
||||
const prevSchema = prevProps.schema;
|
||||
const thisSchema = this.props.schema;
|
||||
if (!isEqual(prevSchema, thisSchema)) {
|
||||
this.syncLineState();
|
||||
}
|
||||
}
|
||||
|
||||
// 水平或垂直线在鼠标按下去时的通用处理
|
||||
lineMouseDownCommon(e: React.MouseEvent<HTMLElement>) {
|
||||
this.startY = e.clientY;
|
||||
this.startX = e.clientX;
|
||||
const currentTarget = e.currentTarget;
|
||||
this.draggingElement = currentTarget;
|
||||
this.draggingElementTop = parseInt(this.draggingElement.style.top, 10);
|
||||
this.draggingElementLeft = parseInt(this.draggingElement.style.left, 10);
|
||||
currentTarget.style.background = '#4285f4';
|
||||
this.draggingId = currentTarget.getAttribute('data-id')!;
|
||||
currentTarget.addEventListener('click', this.handleLineClick, {once: true});
|
||||
}
|
||||
|
||||
// 水平线的拖拽
|
||||
@autobind
|
||||
handleRowMouseDown(e: React.MouseEvent<HTMLElement>) {
|
||||
this.lineMouseDownCommon(e);
|
||||
document.addEventListener('mousemove', this.handleRowMouseMove);
|
||||
document.addEventListener('mouseup', this.handleRowMouseUp);
|
||||
}
|
||||
|
||||
// 水平线移动
|
||||
@autobind
|
||||
handleRowMouseMove(e: MouseEvent) {
|
||||
const moveY = e.clientY - this.startY;
|
||||
this.draggingElement.style.top = this.draggingElementTop + moveY + 'px';
|
||||
}
|
||||
|
||||
// 水平线结束
|
||||
@autobind
|
||||
handleRowMouseUp(e: MouseEvent) {
|
||||
document.removeEventListener('mousemove', this.handleRowMouseMove);
|
||||
document.removeEventListener('mouseup', this.handleRowMouseUp);
|
||||
const moveY = e.clientY - this.startY;
|
||||
const store = this.store;
|
||||
const draggingId = this.draggingId;
|
||||
const value = store.getValueOf(draggingId);
|
||||
const rowElement = this.tableViewWrapperRef.current!.querySelector(
|
||||
`tr[data-editor-id="${draggingId}"]`
|
||||
);
|
||||
this.draggingElement.style.background = 'none';
|
||||
if (!value || !rowElement) {
|
||||
console.warn('找不到对应的 id', draggingId);
|
||||
} else {
|
||||
const height = rowElement.getBoundingClientRect().height;
|
||||
const targetHeight = height + moveY;
|
||||
store.changeValueById(draggingId, {...value, height: targetHeight});
|
||||
if (ROW_HEIGHT - targetHeight > 20) {
|
||||
toast.warning(
|
||||
'由于内边距限制,太小的高度设置会不生效,可以调小默认内边距'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 垂直线的拖拽
|
||||
@autobind
|
||||
handleColMouseDown(e: React.MouseEvent<HTMLElement>) {
|
||||
this.lineMouseDownCommon(e);
|
||||
document.addEventListener('mousemove', this.handleColMouseMove);
|
||||
document.addEventListener('mouseup', this.handleColMouseUp);
|
||||
}
|
||||
|
||||
// 垂直线移动
|
||||
@autobind
|
||||
handleColMouseMove(e: MouseEvent) {
|
||||
const moveX = e.clientX - this.startX;
|
||||
this.draggingElement.style.left = this.draggingElementLeft + moveX + 'px';
|
||||
}
|
||||
|
||||
// 垂直线结束
|
||||
@autobind
|
||||
handleColMouseUp(e: MouseEvent) {
|
||||
document.removeEventListener('mousemove', this.handleColMouseMove);
|
||||
document.removeEventListener('mouseup', this.handleColMouseUp);
|
||||
const moveX = e.clientX - this.startX;
|
||||
const store = this.store;
|
||||
const draggingId = this.draggingId;
|
||||
const value = store.getValueOf(draggingId);
|
||||
const tdElement = this.tableViewWrapperRef!.current!.querySelector(
|
||||
`td[data-editor-id="${draggingId}"]`
|
||||
);
|
||||
this.draggingElement.style.background = 'none';
|
||||
if (!value || !tdElement) {
|
||||
console.warn('找不到对应的 id', draggingId);
|
||||
} else {
|
||||
const width = tdElement.getBoundingClientRect().width;
|
||||
const targetWidth = width + moveX;
|
||||
store.changeValueById(draggingId, {...value, width: targetWidth});
|
||||
}
|
||||
}
|
||||
|
||||
// 阻止冒泡防止切换到表格选中
|
||||
@autobind
|
||||
handleLineClick(e: MouseEvent) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
// 单元格合并的按钮
|
||||
renderMergeIcon() {
|
||||
if (this.state.displayMergeCell) {
|
||||
return (
|
||||
<div
|
||||
className="ae-TableViewEditor-mergeIcon"
|
||||
onMouseDown={this.handleMergeCell}
|
||||
>
|
||||
合并单元格
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
render() {
|
||||
const {children, schema} = this.props;
|
||||
let rowLines = this.state.trIds.map((id: string) => (
|
||||
<div
|
||||
className="ae-TableViewEditor-rowLine"
|
||||
key={`row-${id}`}
|
||||
data-id={id}
|
||||
onMouseDown={this.handleRowMouseDown}
|
||||
></div>
|
||||
));
|
||||
|
||||
let colLines = this.state.tdIds.map((id: string) => (
|
||||
<div
|
||||
className="ae-TableViewEditor-colLine"
|
||||
key={`row-${id}`}
|
||||
data-id={id}
|
||||
onMouseDown={this.handleColMouseDown}
|
||||
></div>
|
||||
));
|
||||
|
||||
return (
|
||||
<div
|
||||
className="ae-TableViewEditor"
|
||||
ref={this.tableViewWrapperRef}
|
||||
style={schema?.style}
|
||||
>
|
||||
{children}
|
||||
{this.renderMergeIcon()}
|
||||
{rowLines}
|
||||
{colLines}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
1
packages/amis-editor/src/icons/btn/btn-group.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke="currentColor"><path stroke-linejoin="round" d="M1.5 4.5h11v9h-11z"/><path stroke-linecap="round" stroke-linejoin="round" d="M3.5 2.5h11v9"/><path d="M4.383 10.506c.32 0 .574-.06.75-.178.208-.143.313-.366.313-.67 0-.203-.05-.367-.148-.485a.734.734 0 0 0-.447-.24.743.743 0 0 0 .346-.25.749.749 0 0 0 .122-.43.682.682 0 0 0-.236-.543c-.168-.144-.405-.216-.704-.216H3v3.012h1.383ZM4.248 8.76h-.755V7.9h.764c.202 0 .346.033.438.1.085.064.131.17.131.313 0 .156-.046.27-.13.341-.09.068-.237.106-.448.106Zm.064 1.34h-.819v-.936h.831c.22 0 .38.038.481.114.097.076.148.199.148.371 0 .17-.068.287-.203.363a.908.908 0 0 1-.438.089Zm2.846.406v-2.59h.987v-.422H5.678v.422h.987v2.59h.493Zm1.839 0V8.304h.017l1.505 2.202H11V7.494h-.498v2.172h-.016l-1.49-2.172h-.493v3.012h.494Z" stroke-width=".1" fill="currentColor" fill-rule="nonzero"/></g></svg>
|
||||
|
After Width: | Height: | Size: 940 B |
1
packages/amis-editor/src/icons/btn/btn-select.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h12v12H2z"/><path d="M5.527 5.52 9.77 6.934 8.356 8.348 6.942 9.762z"/><path stroke-linecap="round" d="m8.356 8.348 2.121 2.122"/></g></svg>
|
||||
|
After Width: | Height: | Size: 298 B |
1
packages/amis-editor/src/icons/btn/btn-toolbar.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke="currentColor"><path stroke-linejoin="round" d="M1.5 2.5h13v11h-13z"/><path d="M4.729 10.118c.4 0 .717-.078.938-.235.259-.19.39-.488.39-.891 0-.269-.063-.487-.184-.644-.127-.163-.311-.27-.559-.32a.934.934 0 0 0 .432-.33c.1-.157.153-.347.153-.572 0-.302-.1-.543-.295-.722-.21-.19-.506-.286-.88-.286H3v4h1.729Zm-.169-2.32h-.943V6.657h.954c.253 0 .432.045.548.134.106.084.164.224.164.415 0 .207-.058.358-.164.454-.11.09-.295.14-.559.14Zm.08 1.782H3.616V8.337h1.038c.274 0 .475.05.601.15.121.102.185.264.185.494 0 .224-.085.38-.253.482-.132.078-.317.117-.549.117Zm3.558.538v-3.44H9.43v-.56H6.347v.56h1.234v3.44h.617Zm2.298 0V7.194h.021l1.882 2.924H13v-4h-.622v2.885h-.021l-1.861-2.885h-.617v4h.617Z" stroke-width=".15" fill="currentColor" fill-rule="nonzero"/></g></svg>
|
||||
|
After Width: | Height: | Size: 872 B |
1
packages/amis-editor/src/icons/btn/button.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke="currentColor"><path stroke-linejoin="round" d="M1.5 2.5h13v11h-13z"/><path d="M4.897 9.785c.38 0 .68-.07.89-.21.245-.17.37-.435.37-.795 0-.24-.06-.435-.175-.575-.12-.145-.295-.24-.53-.285a.881.881 0 0 0 .41-.295.888.888 0 0 0 .146-.51.811.811 0 0 0-.28-.645c-.2-.17-.48-.255-.835-.255H3.258v3.57h1.64Zm-.16-2.07h-.895v-1.02h.905c.24 0 .41.04.52.12.1.075.155.2.155.37 0 .185-.054.32-.154.405-.106.08-.28.125-.53.125Zm.075 1.59h-.97v-1.11h.985c.26 0 .45.045.57.135.115.09.175.235.175.44 0 .2-.08.34-.24.43-.125.07-.3.105-.52.105Zm3.375.48v-3.07h1.17v-.5H6.434v.5h1.17v3.07h.585Zm2.18 0v-2.61h.02l1.785 2.61h.57v-3.57h-.59V8.79h-.02l-1.764-2.575h-.585v3.57h.585Z" stroke-width=".1" fill="currentColor" fill-rule="nonzero"/></g></svg>
|
||||
|
After Width: | Height: | Size: 837 B |
1
packages/amis-editor/src/icons/btn/dropdown-btn.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h12v12H2z"/><path stroke-linecap="round" d="M11.182 6.433 8 9.615 4.818 6.433"/></g></svg>
|
||||
|
After Width: | Height: | Size: 248 B |
1
packages/amis-editor/src/icons/container/anchor-nav.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path stroke-linecap="round" d="M2 2v12"/><path d="M4.5 2H14v2.5H4.5zm0 4.75H14v2.5H4.5zm0 4.75H14V14H4.5z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 264 B |
1
packages/amis-editor/src/icons/container/collapse.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h12v12H2z"/><path stroke-linecap="round" d="M10.828 8 8 5.172 5.172 8M2 11h12"/></g></svg>
|
||||
|
After Width: | Height: | Size: 248 B |
1
packages/amis-editor/src/icons/container/container.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path stroke="currentColor" d="M2 2h12v12H2z" fill="none" stroke-linejoin="round"/></svg>
|
||||
|
After Width: | Height: | Size: 153 B |
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h12v12H2z"/><path stroke-linecap="round" d="M2 6h12M7 6v8"/></g></svg>
|
||||
|
After Width: | Height: | Size: 228 B |
1
packages/amis-editor/src/icons/container/form-group.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h12v12H2z"/><path stroke-linecap="round" d="M4 5h1m2 0h5M4 8h1m2 0h5m-8 3h1m2 0h5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 252 B |
1
packages/amis-editor/src/icons/container/grid.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M1.498 2H7v12H1.498zM9 2h5.502v12H9z" fill="none" stroke-linejoin="round" stroke="currentColor"/></svg>
|
||||
|
After Width: | Height: | Size: 176 B |
1
packages/amis-editor/src/icons/container/iframe.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h12v12H2z"/><path d="M2 8h6v6H2z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 203 B |
1
packages/amis-editor/src/icons/container/panel.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h12v12H2z"/><path stroke-linecap="round" d="M2 6h12"/></g></svg>
|
||||
|
After Width: | Height: | Size: 222 B |
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="20" height="20"><path d="M0 265.143v713.143h1024V265.143H0zm987.429 676.571H36.57v-640h950.86v640zM54.857 228.571h914.286a18.286 18.286 0 0 0 0-36.571H54.857a18.286 18.286 0 0 0 0 36.571zm54.857-73.142h804.572a18.286 18.286 0 0 0 0-36.572H109.714a18.286 18.286 0 0 0 0 36.572zm54.857-73.143H859.43a18.286 18.286 0 0 0 0-36.572H164.57a18.286 18.286 0 0 0 0 36.572z"/></svg>
|
||||
|
After Width: | Height: | Size: 444 B |
1
packages/amis-editor/src/icons/container/table-view.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h12v12H2z"/><path stroke-linecap="round" d="M2 6h12M2 10h12M6 2v12m4-12v12"/></g></svg>
|
||||
|
After Width: | Height: | Size: 245 B |
1
packages/amis-editor/src/icons/container/tabs.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M1.498 2H8v3.838h6.498V14h-13z"/><path stroke-linecap="round" d="M3.713 3.807h2m4.989-.073h2.069"/></g></svg>
|
||||
|
After Width: | Height: | Size: 263 B |
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke="currentColor"><path stroke-linejoin="round" d="M2 2h12v9.5h-4L6 14v-2.5H2z"/><path stroke-linecap="round" stroke-linejoin="round" d="m5.5 4.5 5 .015"/><path stroke-linecap="round" d="M8 4.5v5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 311 B |
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="M9 2a1.5 1.5 0 0 1 1.493 1.356l.007.144H14v4a1.5 1.5 0 0 0 0 3V14h-3.5a1.5 1.5 0 0 0-3 0h-4v-3.5a1.5 1.5 0 0 1-.144-2.993L3.5 7.5v-4h4A1.5 1.5 0 0 1 9 2Z" stroke="currentColor" fill="none" stroke-linejoin="round"/></svg>
|
||||
|
After Width: | Height: | Size: 293 B |
1
packages/amis-editor/src/icons/crud/column-add.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M2.667 8h10.667M8 2.667v10.667" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>
|
||||
|
After Width: | Height: | Size: 188 B |
1
packages/amis-editor/src/icons/crud/column-delete.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="20" height="20" fill="none"><path d="m6.196 6.205 8.396 8.268m-8.752-.106L14.237 6.1" stroke="currentColor" stroke-width="1.6"/></svg>
|
||||
|
After Width: | Height: | Size: 147 B |
1
packages/amis-editor/src/icons/crud/column-setting.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M3 6.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3ZM6.5 8a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0ZM13 6.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3Z" fill="currentColor"/></svg>
|
||||
|
After Width: | Height: | Size: 244 B |
1
packages/amis-editor/src/icons/crud/share-link.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="64" height="64"><path d="M938.667 469.333C915.2 469.333 896 488.533 896 512v405.333c0 12.8-8.533 21.334-21.333 21.334h-768c-12.8 0-21.334-8.534-21.334-21.334V234.667c0-12.8 8.534-21.334 21.334-21.334h362.666c23.467 0 42.667-19.2 42.667-42.666C512 147.2 492.8 128 469.333 128h-384C38.4 128 0 166.4 0 213.333v725.334C0 985.6 38.4 1024 85.333 1024H896c46.933 0 85.333-38.4 85.333-85.333V512c0-23.467-19.2-42.667-42.666-42.667zm72.533-307.2L861.867 12.8C855.467 4.267 844.8 0 832 0c-23.467 0-42.667 19.2-42.667 42.667 0 12.8 4.267 23.466 12.8 29.866l83.2 83.2C554.667 202.667 298.667 488.533 298.667 832c0 23.467 19.2 42.667 42.666 42.667S384 855.467 384 832c0-290.133 206.933-533.333 484.267-586.667l-66.134 66.134c-8.533 6.4-12.8 17.066-12.8 29.866C789.333 364.8 808.533 384 832 384c12.8 0 23.467-4.267 29.867-12.8L1011.2 221.867c8.533-6.4 12.8-17.067 12.8-29.867s-4.267-23.467-12.8-29.867z"/></svg>
|
||||
|
After Width: | Height: | Size: 982 B |
1
packages/amis-editor/src/icons/display/aBaseline.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" width="20" height="20" viewBox="0 0 21 11" xmlns="http://www.w3.org/2000/svg"><path d="M0 5h21v1H0V5zm4.5 0h6v1h-6V5zm6 0h6v1h-6V5z" opacity=".5"/><path d="M11 1h5v9h-5V1zm1 1h3v3h-3V2z"/><path opacity=".4" d="M6 5h3v5H6z"/><path d="M6 3v7h3V3H6zM5 2h5v9H5V2z"/></svg>
|
||||
|
After Width: | Height: | Size: 294 B |
1
packages/amis-editor/src/icons/display/aCenter.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 21 9"><path d="M0 4h21v1H0V4zm4.5 0h6v1h-6V4zm6 0h6v1h-6V4z" opacity=".5"/><path d="M11 0h5v9h-5z"/><path opacity=".4" d="M6 1h3v7H6z"/><path d="M6 1v7h3V1H6zM5 0h5v9H5V0z"/></svg>
|
||||
|
After Width: | Height: | Size: 277 B |
1
packages/amis-editor/src/icons/display/aFlexEnd.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 21 18"><path opacity=".5" d="M0 17h21v1H0z"/><path d="M11 7h5v9h-5z"/><path opacity=".4" d="M6 8h3v7H6z"/><path d="M6 8v7h3V8H6zM5 7h5v9H5V7z"/></svg>
|
||||
|
After Width: | Height: | Size: 247 B |
1
packages/amis-editor/src/icons/display/aFlexStart.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 21 18"><path opacity=".5" d="M0 0h21v1H0z"/><path d="M11 2h5v9h-5z"/><path opacity=".4" d="M6 3h3v7H6z"/><path d="M6 3v7h3V3H6zM5 2h5v9H5V2z"/></svg>
|
||||
|
After Width: | Height: | Size: 246 B |
1
packages/amis-editor/src/icons/display/aStretch.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 21 18"><path opacity=".5" d="M0 17h21v1H0zM0 0h21v1H0z"/><path d="M11 2h5v14h-5z"/><path opacity=".4" d="M6 3h3v12H6z"/><path d="M6 3v12h3V3H6zM5 2h5v14H5V2z"/></svg>
|
||||
|
After Width: | Height: | Size: 263 B |
1
packages/amis-editor/src/icons/display/block.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 22 14"><path opacity=".15" d="M19 3v8H3V3h16m1-1H2v10h18V2z"/><path d="M19.8 1H2.2A1.2 1.2 0 0 0 1 2.2v9.6A1.2 1.2 0 0 0 2.2 13h17.6a1.2 1.2 0 0 0 1.2-1.2V2.2A1.2 1.2 0 0 0 19.8 1zm.2 11H2V2h18v10z"/><path opacity=".35" d="M3 3h16v8H3z"/></svg>
|
||||
|
After Width: | Height: | Size: 321 B |
1
packages/amis-editor/src/icons/display/dcolumn.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 9 18"><path d="M0 6h9v5H0zm5 9v-3H4v3H2l2.5 3L7 15H5z"/><path opacity=".4" d="M1 1h7v3H1z"/><path d="M1 1v3h7V1H1zM0 0h9v5H0V0z"/></svg>
|
||||
|
After Width: | Height: | Size: 213 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="20" height="20" viewBox="0 0 9 18" class="ve-svgicon vs-style-reverse-v" style="vertical-align:middle"><g fill-rule="evenodd"><path d="M0 6h9v5H0zm5 9v-3H4v3H2l2.5 3L7 15H5z"/><path opacity=".4" d="M1 1h7v3H1z" data-spm-anchor-id="a2q5o.26736379.0.i51.35962a19sy6kFy"/><path d="M1 1v3h7V1H1zM0 0h9v5H0V0z"/></g></svg>
|
||||
|
After Width: | Height: | Size: 385 B |
1
packages/amis-editor/src/icons/display/drow.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 19 9"><path d="M16 4h-4v1h4v2l3-2.5L16 2v2zM6 0h5v9H6z"/><path opacity=".4" d="M1 1h3v7H1z"/><path d="M1 1v7h3V1H1zM0 0h5v9H0V0z"/></svg>
|
||||
|
After Width: | Height: | Size: 214 B |
1
packages/amis-editor/src/icons/display/drowReverse.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="20" height="20" viewBox="0 0 19 9"><path d="M16 4h-4v1h4v2l3-2.5L16 2v2zM6 0h5v9H6z"/><path opacity=".4" d="M1 1h3v7H1z"/><path d="M1 1v7h3V1H1zM0 0h5v9H0V0z"/></svg>
|
||||
|
After Width: | Height: | Size: 234 B |
1
packages/amis-editor/src/icons/display/flex.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 23 14"><path d="M21 2v10H2V2h19zm1-1H1v12h21V1z" opacity=".15"/><path d="M1.2 0A1.2 1.2 0 0 0 0 1.2v11.6A1.2 1.2 0 0 0 1.2 14h20.6a1.2 1.2 0 0 0 1.2-1.2V1.2A1.2 1.2 0 0 0 21.8 0H1.2zM22 13H1V1h21v12z"/><path opacity=".4" d="M3 3h5v8H3z"/><path d="M4 4v6h3V4H4zm4-1v8H3V3h5z"/><path opacity=".4" d="M9 3h5v8H9z"/><path d="M10 4v6h3V4h-3zm4-1v8H9V3h5z"/><path opacity=".4" d="M15 3h5v8h-5z"/><path d="M16 4v6h3V4h-3zm4-1v8h-5V3h5z"/></svg>
|
||||
|
After Width: | Height: | Size: 514 B |
1
packages/amis-editor/src/icons/display/inline-block.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 28 14"><path d="M25 3v8H3V3h22m1-1H2v10h24V2z" opacity=".15"/><path opacity=".35" d="M8.418 9.8H7.66L7.25 11h1.58l-.232-.676-.18-.525zM3 11h.567l2.916-7.94h3.15L11 6.78V3H3v8zm15.12-1.002a3.302 3.302 0 0 1-.48-.586c-.173.343-.42.653-.73.888.002 0 .004-.002.005-.003l-.008.006.003-.003a3.145 3.145 0 0 1-1.092.55c-.4.11-.825.15-1.303.15h6.017a4.416 4.416 0 0 1-1.12-.215 3.51 3.51 0 0 1-1.292-.787zM14.237 3c.49 0 .853.014 1.167.06.335.05.656.16.953.314h.003l.004.003c.365.19.694.492.898.866.13.234.197.49.24.747.16-.298.343-.58.578-.82v-.002c.358-.366.8-.643 1.287-.826a4.373 4.373 0 0 1 1.557-.272 5.67 5.67 0 0 1 1.442.18l.01.002.01.003c.205.06.4.126.59.208.15.064.283.125.407.185l.562.274v3.016h-1.54l-.28-.24a7.018 7.018 0 0 0-.233-.188 2.703 2.703 0 0 0-.26-.175 1.594 1.594 0 0 0-.277-.125h-.006l-.2-.03a.772.772 0 0 0-.26.042l-.16.102a.63.63 0 0 0-.13.22 1.486 1.486 0 0 0-.075.516c0 .266.04.436.074.513a.59.59 0 0 0 .13.212l.15.09h.003a.868.868 0 0 0 .265.045l.236-.037h.008a1.04 1.04 0 0 0 .25-.113l.007-.004.01-.005.24-.16a6.41 6.41 0 0 0 .216-.17l.285-.254h1.536v3.017l-.59.266c-.15.066-.292.13-.422.184a4.19 4.19 0 0 1-.53.19 5.918 5.918 0 0 1-.636.15c-.076.012-.16.02-.24.026H25V3H14.237z"/><path d="M25.8 1H2.2A1.2 1.2 0 0 0 1 2.2v9.6A1.2 1.2 0 0 0 2.2 13h23.6a1.2 1.2 0 0 0 1.2-1.2V2.2A1.2 1.2 0 0 0 25.8 1zm.2 11H2V2h24v10zm-7.186-2.72c.258.248.567.435.927.56s.76.19 1.18.19c.29 0 .51-.014.68-.042.167-.028.34-.07.53-.123.143-.04.28-.09.41-.146l.412-.19V8.16h-.154c-.07.06-.157.134-.265.22a3.337 3.337 0 0 1-.35.237 2.11 2.11 0 0 1-.485.22 1.798 1.798 0 0 1-1.1-.01 1.403 1.403 0 0 1-.523-.3c-.15-.14-.28-.33-.38-.57a2.36 2.36 0 0 1-.152-.9c0-.347.047-.64.14-.88s.216-.433.367-.58c.157-.15.33-.26.517-.325a1.786 1.786 0 0 1 1.116-.014c.164.056.316.125.457.206a4.868 4.868 0 0 1 .644.466h.17V4.54a13.03 13.03 0 0 0-.367-.168 3.667 3.667 0 0 0-1.005-.27 4.736 4.736 0 0 0-.65-.04c-.436 0-.837.07-1.205.207s-.675.333-.924.59c-.26.262-.457.58-.59.95S18 6.6 18 7.055c0 .488.07.918.213 1.29s.343.683.6.933zm-3.264.607c.272-.076.52-.2.75-.38.195-.15.35-.338.46-.567.113-.23.17-.488.17-.778 0-.4-.11-.722-.332-.967-.22-.245-.52-.406-.896-.484v-.03a1.46 1.46 0 0 0 .623-.51 1.36 1.36 0 0 0 .22-.77c0-.25-.052-.47-.16-.665a1.15 1.15 0 0 0-.49-.465 2.065 2.065 0 0 0-.64-.215A7.67 7.67 0 0 0 14.237 4H12v6h2.515c.418 0 .763-.037 1.035-.113zM13.478 5.1h.14c.29 0 .517.002.678.006s.296.027.404.07c.12.05.206.123.253.223a.69.69 0 0 1 .072.29.86.86 0 0 1-.062.34c-.042.1-.13.18-.263.24a1.05 1.05 0 0 1-.39.08c-.166.007-.366.01-.6.01h-.233V5.1zm.108 3.8h-.108V7.405h.324c.222 0 .434 0 .638.004.203 0 .363.02.48.05.17.05.29.13.36.23s.106.25.106.44c0 .144-.03.272-.087.384s-.17.2-.32.27a1.257 1.257 0 0 1-.5.104c-.18.003-.48.004-.9.004zm-6.64-.1h2.187l.41 1.2h1.574L8.935 4.06H7.182L5 10h1.535l.412-1.2zM8.04 5.58l.727 2.13H7.313l.727-2.13z"/></svg>
|
||||
|
After Width: | Height: | Size: 2.9 KiB |
1
packages/amis-editor/src/icons/display/inline.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 20 8"><path d="M14.814 6.25c.258.248.567.435.927.56s.76.19 1.18.19c.29 0 .51-.014.68-.042.167-.028.34-.07.53-.123.143-.04.28-.09.41-.146l.41-.19V5.13h-.153c-.07.06-.157.134-.265.22a3.337 3.337 0 0 1-.35.237 2.11 2.11 0 0 1-.484.22 1.798 1.798 0 0 1-1.1-.01 1.403 1.403 0 0 1-.523-.3 1.566 1.566 0 0 1-.38-.57c-.1-.24-.152-.54-.152-.9 0-.346.048-.638.14-.878s.217-.437.368-.58c.16-.155.33-.26.52-.33a1.786 1.786 0 0 1 1.117-.013c.165.055.317.124.458.205a4.385 4.385 0 0 1 .643.47h.17V1.52c-.107-.05-.23-.107-.37-.168a3.613 3.613 0 0 0-1.003-.27 4.736 4.736 0 0 0-.65-.04c-.436 0-.837.07-1.205.207s-.674.33-.923.59c-.26.26-.458.58-.59.95S14 3.57 14 4.02c0 .488.07.918.213 1.29s.343.683.6.933zm-3.264.608c.272-.075.52-.2.75-.377a1.5 1.5 0 0 0 .46-.56 1.72 1.72 0 0 0 .17-.77c0-.4-.11-.72-.332-.96-.22-.244-.52-.404-.896-.48v-.04a1.46 1.46 0 0 0 .623-.516c.147-.22.22-.474.22-.763 0-.25-.052-.47-.16-.66a1.152 1.152 0 0 0-.49-.46 2.06 2.06 0 0 0-.64-.212A7.67 7.67 0 0 0 10.237 1H8v5.97h2.515c.418 0 .763-.037 1.035-.112zM9.478 2.095h.14c.29 0 .517.002.678.006.162.01.296.03.404.07a.46.46 0 0 1 .253.23.69.69 0 0 1 .072.298.85.85 0 0 1-.062.34.492.492 0 0 1-.263.24 1.052 1.052 0 0 1-.39.08c-.166.006-.366.01-.6.01h-.232v-1.27zm.108 3.78h-.108V4.388h.324c.222 0 .434 0 .638.004a1.8 1.8 0 0 1 .48.056c.17.05.29.127.36.23.07.104.106.25.106.44 0 .144-.03.272-.087.383s-.17.2-.32.27-.32.1-.5.11c-.18.004-.48.004-.9.004zm-6.64-.106h2.187l.41 1.2h1.574L4.935 1.03H3.182L1 6.97h1.535l.412-1.2zM4.04 2.55l.727 2.13H3.313l.727-2.13z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
1
packages/amis-editor/src/icons/display/jCenter.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="20" height="20" viewBox="0 0 13 17"><path opacity=".5" d="M6 0h1v17H6z"/><path d="M8 4h5v9H8z"/><path opacity=".4" d="M1 5h3v7H1z"/><path d="M1 5v7h3V5H1zM0 4h5v9H0V4z"/></svg>
|
||||
|
After Width: | Height: | Size: 244 B |
1
packages/amis-editor/src/icons/display/jFlexEnd.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="20" height="20" viewBox="0 0 24 17"><path opacity=".5" d="M23 0h1v17h-1z"/><path d="M17 4h5v9h-5z"/><path opacity=".4" d="M12 5h3v7h-3z"/><path d="M12 5v7h3V5h-3zm-1-1h5v9h-5V4z"/></svg>
|
||||
|
After Width: | Height: | Size: 254 B |
1
packages/amis-editor/src/icons/display/jFlexStart.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="20" height="20" viewBox="0 0 24 17"><path opacity=".5" d="M0 0h1v17H0z"/><path d="M8 4h5v9H8z"/><path opacity=".4" d="M3 5h3v7H3z"/><path d="M3 5v7h3V5H3zM2 4h5v9H2V4z"/></svg>
|
||||
|
After Width: | Height: | Size: 244 B |
1
packages/amis-editor/src/icons/display/jSpaceAround.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="20" height="20" viewBox="0 0 16 17"><path d="M2 0h1v17H2V0zm0 3.5h1v10H2v-10zM13 0h1v17h-1V0zm0 3.5h1v10h-1v-10z" opacity=".5"/><path d="M11 4h5v9h-5z"/><path opacity=".4" d="M1 5h3v7H1z"/><path d="M1 5v7h3V5H1zM0 4h5v9H0V4z"/></svg>
|
||||
|
After Width: | Height: | Size: 301 B |
1
packages/amis-editor/src/icons/display/jSpaceBetween.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="20" height="20" viewBox="0 0 24 17"><path opacity=".5" d="M0 0h1v17H0zm23 0h1v17h-1z"/><path d="M17 4h5v9h-5z"/><path opacity=".4" d="M3 5h3v7H3z"/><path d="M3 5v7h3V5H3zM2 4h5v9H2V4z"/></svg>
|
||||
|
After Width: | Height: | Size: 260 B |
1
packages/amis-editor/src/icons/feat/audio.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2.5 1.5h8l3 3v10h-11z"/><circle cx="7" cy="10.5" r="2"/><path stroke-linecap="round" d="m11 4.5-2 1v5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 269 B |
1
packages/amis-editor/src/icons/feat/custom.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path d="m9 2.5-2 11m-2.247-2.247L1.5 8l3.253-3.253m6.505 6.506L14.511 8l-3.253-3.253" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke="currentColor"/></svg>
|
||||
|
After Width: | Height: | Size: 239 B |
1
packages/amis-editor/src/icons/feat/each.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M6 3.5h5.5m-1.5 9H4.5"/><path stroke-linecap="round" d="M10.086 2.086 11.5 3.5l-1.414 1.414m-4.172 6.172L4.5 12.5l1.414 1.414M6 3.5a4.5 4.5 0 0 0-4.03 6.505m12.065-3.999A4.5 4.5 0 0 1 10 12.5M8 8a1.5 1.5 0 1 0-.998 1.414M8 8a1.5 1.5 0 1 0 1-1.415"/></g></svg>
|
||||
|
After Width: | Height: | Size: 413 B |
1
packages/amis-editor/src/icons/feat/form.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M1.5 2.5h13v11h-13z"/><path stroke-linecap="round" d="M1.5 5.502h13M3.752 8.244h1.5m1.996 0h5m-8.496 2.5h1.5m1.996 0h5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 285 B |
1
packages/amis-editor/src/icons/feat/nav.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><path stroke="currentColor" d="m8 1.5 5.5 13-5.5-3-5.5 3z" fill="none" stroke-linejoin="round"/></svg>
|
||||
|
After Width: | Height: | Size: 166 B |
1
packages/amis-editor/src/icons/feat/qrcode.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h5v5H2zm7 0h5v5H9zM2 9h5v5H2z"/><path stroke-linecap="round" d="M9 9v5m2.5-5v5M14 9v5"/></g></svg>
|
||||
|
After Width: | Height: | Size: 256 B |
1
packages/amis-editor/src/icons/feat/service.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h12v12H2z"/><path stroke-linecap="round" d="M2 6h12M2 10h12M4 4h2M4 8h2m-2 4h2"/></g></svg>
|
||||
|
After Width: | Height: | Size: 249 B |
1
packages/amis-editor/src/icons/feat/table.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke="currentColor"><path stroke-linejoin="round" d="M2 2h12v12H2z"/><path stroke-linecap="round" stroke-linejoin="round" d="M2 6h12M2 10h12"/><path stroke-linecap="round" d="M6 6v8m4-8v8"/></g></svg>
|
||||
|
After Width: | Height: | Size: 301 B |
1
packages/amis-editor/src/icons/feat/tasks.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd" stroke-linejoin="round" stroke="currentColor"><path d="M2 2h12v12H2z"/><path stroke-linecap="round" d="M7.268 4.526 5.146 6.647 3.732 5.233M9 5.5h3"/><circle cx="5.5" cy="10.5" r="1.5"/><path stroke-linecap="round" d="M9 10.5h3"/></g></svg>
|
||||
|
After Width: | Height: | Size: 339 B |