diff --git a/packages/amis-editor/src/plugin/Alert.tsx b/packages/amis-editor/src/plugin/Alert.tsx index 9d560c8008c..fdbbbefe446 100644 --- a/packages/amis-editor/src/plugin/Alert.tsx +++ b/packages/amis-editor/src/plugin/Alert.tsx @@ -3,6 +3,7 @@ import {registerEditorPlugin} from 'amis-editor-core'; import {BaseEventContext, BasePlugin} from 'amis-editor-core'; import {getSchemaTpl} from 'amis-editor-core'; import type {SchemaObject} from 'amis'; +import {generateId} from '../util'; export class AlertPlugin extends BasePlugin { static id = 'AlertPlugin'; @@ -28,7 +29,8 @@ export class AlertPlugin extends BasePlugin { type: 'tpl', tpl: '提示内容', wrapperComponent: '', - inline: false + inline: false, + id: generateId() }, level: 'info' }; diff --git a/packages/amis-editor/src/plugin/AnchorNav.tsx b/packages/amis-editor/src/plugin/AnchorNav.tsx index 7c8f8fc7f85..9c2600e574c 100644 --- a/packages/amis-editor/src/plugin/AnchorNav.tsx +++ b/packages/amis-editor/src/plugin/AnchorNav.tsx @@ -8,6 +8,7 @@ import findIndex from 'lodash/findIndex'; import {RegionWrapper as Region} from 'amis-editor-core'; import {AnchorNavSection} from 'amis-ui'; import {registerFilter} from 'amis-formula'; +import {generateId} from '../util'; registerFilter('appTranslate', (input: any) => translateSchema(input)); export class AnchorNavPlugin extends BasePlugin { @@ -36,7 +37,8 @@ export class AnchorNavPlugin extends BasePlugin { type: 'tpl', tpl: '这里是锚点内容1', wrapperComponent: '', - inline: false + inline: false, + id: generateId() } ] }, @@ -48,7 +50,8 @@ export class AnchorNavPlugin extends BasePlugin { type: 'tpl', tpl: '这里是锚点内容2', wrapperComponent: '', - inline: false + inline: false, + id: generateId() } ] }, @@ -60,7 +63,8 @@ export class AnchorNavPlugin extends BasePlugin { type: 'tpl', tpl: '这里是锚点内容3', wrapperComponent: '', - inline: false + inline: false, + id: generateId() } ] } diff --git a/packages/amis-editor/src/plugin/ButtonGroup.tsx b/packages/amis-editor/src/plugin/ButtonGroup.tsx index adf86a32608..d99449527a4 100644 --- a/packages/amis-editor/src/plugin/ButtonGroup.tsx +++ b/packages/amis-editor/src/plugin/ButtonGroup.tsx @@ -9,6 +9,7 @@ import { translateSchema } from 'amis-editor-core'; import {BUTTON_DEFAULT_ACTION} from '../component/BaseControl'; +import {generateId} from '../util'; export class ButtonGroupPlugin extends BasePlugin { static id = 'ButtonGroupPlugin'; @@ -31,12 +32,14 @@ export class ButtonGroupPlugin extends BasePlugin { { type: 'button', label: '按钮1', + id: generateId(), ...BUTTON_DEFAULT_ACTION }, { type: 'button', label: '按钮2', + id: generateId(), ...BUTTON_DEFAULT_ACTION } ] diff --git a/packages/amis-editor/src/plugin/Card.tsx b/packages/amis-editor/src/plugin/Card.tsx index c8b80f5d10d..f628439a4e5 100644 --- a/packages/amis-editor/src/plugin/Card.tsx +++ b/packages/amis-editor/src/plugin/Card.tsx @@ -16,6 +16,7 @@ import { import {defaultValue, getSchemaTpl} from 'amis-editor-core'; import flatten from 'lodash/flatten'; import {VRenderer} from 'amis-editor-core'; +import {generateId} from '../util'; export class CardPlugin extends BasePlugin { static id = 'CardPlugin'; @@ -44,6 +45,7 @@ export class CardPlugin extends BasePlugin { type: 'button', label: '按钮', actionType: 'dialog', + id: generateId(), dialog: { title: '标题', body: '内容' diff --git a/packages/amis-editor/src/plugin/Cards.tsx b/packages/amis-editor/src/plugin/Cards.tsx index aa30b20ba9a..4afc81b704a 100644 --- a/packages/amis-editor/src/plugin/Cards.tsx +++ b/packages/amis-editor/src/plugin/Cards.tsx @@ -18,7 +18,7 @@ import {defaultValue, getSchemaTpl} from 'amis-editor-core'; import {diff, JSONPipeOut, repeatArray} from 'amis-editor-core'; import set from 'lodash/set'; import merge from 'lodash/merge'; -import {escapeFormula, resolveArrayDatasource} from '../util'; +import {escapeFormula, generateId, resolveArrayDatasource} from '../util'; export class CardsPlugin extends BasePlugin { static id = 'CardsPlugin'; @@ -63,7 +63,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:c3a694c7f4e6' + id: generateId() }, { type: 'tpl', @@ -83,7 +83,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:4273575e1d7b' + id: generateId() } ], style: { @@ -103,7 +103,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:561592d2ff0a' + id: generateId() }, { type: 'flex', @@ -130,7 +130,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:c53d2e838649' + id: generateId() }, { type: 'tpl', @@ -146,7 +146,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:774766c09a3e' + id: generateId() } ], style: { @@ -167,7 +167,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:7b8d9478caf0' + id: generateId() }, { type: 'container', @@ -185,7 +185,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:4abe984e2cdf' + id: generateId() } ], style: { @@ -201,7 +201,7 @@ export class CardsPlugin extends BasePlugin { isFixedHeight: false, isFixedWidth: false, size: 'none', - id: 'u:10268e055c48' + id: generateId() } ], size: 'xs', @@ -219,7 +219,7 @@ export class CardsPlugin extends BasePlugin { wrapperBody: false, isFixedHeight: false, isFixedWidth: false, - id: 'u:a35d9094c57a' + id: generateId() }, { type: 'container', @@ -239,7 +239,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:dfa080010477' + id: generateId() }, { type: 'tpl', @@ -254,7 +254,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:ee6afab8bebf' + id: generateId() } ], size: 'xs', @@ -272,7 +272,7 @@ export class CardsPlugin extends BasePlugin { wrapperBody: false, isFixedHeight: false, isFixedWidth: false, - id: 'u:8d1113a60808' + id: generateId() }, { type: 'container', @@ -292,7 +292,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:538523c38973' + id: generateId() }, { type: 'tpl', @@ -307,7 +307,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:4b2f8311836c' + id: generateId() } ], size: 'xs', @@ -325,13 +325,13 @@ export class CardsPlugin extends BasePlugin { wrapperBody: false, isFixedHeight: false, isFixedWidth: false, - id: 'u:7543aef28c33' + id: generateId() } ], style: { position: 'relative' }, - id: 'u:0f802c8852fd' + id: generateId() }, { type: 'container', @@ -350,7 +350,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:ec80d1113007' + id: generateId() }, { type: 'tpl', @@ -366,7 +366,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:7f6bef513eb3' + id: generateId() } ], style: { @@ -385,7 +385,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:6606cebce092' + id: generateId() } ], size: 'none', @@ -435,7 +435,7 @@ export class CardsPlugin extends BasePlugin { } } }, - id: 'u:b39411e7f540' + id: generateId() }, placeholder: '', name: '', @@ -443,7 +443,7 @@ export class CardsPlugin extends BasePlugin { gutterX: 15, gutterY: 15 }, - id: 'u:1f941707f77f' + id: generateId() }; previewSchema = { ...this.scaffold, diff --git a/packages/amis-editor/src/plugin/Collapse.tsx b/packages/amis-editor/src/plugin/Collapse.tsx index 8a5e6c5e709..569968f61c0 100644 --- a/packages/amis-editor/src/plugin/Collapse.tsx +++ b/packages/amis-editor/src/plugin/Collapse.tsx @@ -15,6 +15,7 @@ import { getEventControlConfig } from '../renderer/event-control/helper'; import {getActionCommonProps} from '../renderer/event-control/helper'; +import {generateId} from '../util'; export class CollapsePlugin extends BasePlugin { static id = 'CollapsePlugin'; @@ -38,7 +39,8 @@ export class CollapsePlugin extends BasePlugin { type: 'tpl', tpl: '内容', wrapperComponent: '', - inline: false + inline: false, + id: generateId() } ] }; diff --git a/packages/amis-editor/src/plugin/CollapseGroup.tsx b/packages/amis-editor/src/plugin/CollapseGroup.tsx index bab36f1717e..7559c5b947f 100644 --- a/packages/amis-editor/src/plugin/CollapseGroup.tsx +++ b/packages/amis-editor/src/plugin/CollapseGroup.tsx @@ -9,6 +9,7 @@ import {defaultValue, getSchemaTpl} from 'amis-editor-core'; import {tipedLabel} from 'amis-editor-core'; import {isObject} from 'amis-editor-core'; import {getEventControlConfig} from '../renderer/event-control/helper'; +import {generateId} from '../util'; export class CollapseGroupPlugin extends BasePlugin { static id = 'CollapseGroupPlugin'; @@ -35,12 +36,14 @@ export class CollapseGroupPlugin extends BasePlugin { key: '1', active: true, header: '标题1', + id: generateId(), body: [ { type: 'tpl', tpl: '这里是内容1', wrapperComponent: '', - inline: false + inline: false, + id: generateId() } ] }, @@ -48,12 +51,14 @@ export class CollapseGroupPlugin extends BasePlugin { type: 'collapse', key: '2', header: '标题2', + id: generateId(), body: [ { type: 'tpl', tpl: '这里是内容1', wrapperComponent: '', - inline: false + inline: false, + id: generateId() } ] } diff --git a/packages/amis-editor/src/plugin/CustomRegion.tsx b/packages/amis-editor/src/plugin/CustomRegion.tsx index 0fc63abb405..471e9b74466 100644 --- a/packages/amis-editor/src/plugin/CustomRegion.tsx +++ b/packages/amis-editor/src/plugin/CustomRegion.tsx @@ -13,6 +13,7 @@ import { } from 'amis-editor-core'; import {defaultValue, getSchemaTpl} from 'amis-editor-core'; import isArray from 'lodash/isArray'; +import {generateId} from '../util'; export class CustomPlugin extends BasePlugin { static id = 'CustomRegionPlugin'; @@ -37,7 +38,8 @@ export class CustomPlugin extends BasePlugin { { type: 'tpl', wrapperComponent: '', - tpl: '自定义容器区域' + tpl: '自定义容器区域', + id: generateId() } ] }; diff --git a/packages/amis-editor/src/plugin/DropDownButton.tsx b/packages/amis-editor/src/plugin/DropDownButton.tsx index ef2370c676f..f4f1b670561 100644 --- a/packages/amis-editor/src/plugin/DropDownButton.tsx +++ b/packages/amis-editor/src/plugin/DropDownButton.tsx @@ -14,6 +14,7 @@ import { } from 'amis-editor-core'; import {BUTTON_DEFAULT_ACTION} from '../component/BaseControl'; import {buttonStateFunc} from '../renderer/style-control/helper'; +import {generateId} from '../util'; export class DropDownButtonPlugin extends BasePlugin { static id = 'DropDownButtonPlugin'; static scene = ['layout']; @@ -38,12 +39,14 @@ export class DropDownButtonPlugin extends BasePlugin { { type: 'button', label: '按钮1', + id: generateId(), ...BUTTON_DEFAULT_ACTION }, { type: 'button', label: '按钮2', + id: generateId(), ...BUTTON_DEFAULT_ACTION } ] diff --git a/packages/amis-editor/src/plugin/Each.tsx b/packages/amis-editor/src/plugin/Each.tsx index 181b5658e3f..f3d0472b1bc 100644 --- a/packages/amis-editor/src/plugin/Each.tsx +++ b/packages/amis-editor/src/plugin/Each.tsx @@ -3,7 +3,7 @@ import React from 'react'; import {EditorNodeType, registerEditorPlugin} from 'amis-editor-core'; import {BaseEventContext, BasePlugin} from 'amis-editor-core'; import {getSchemaTpl} from 'amis-editor-core'; -import {escapeFormula} from '../util'; +import {escapeFormula, generateId} from '../util'; import merge from 'lodash/merge'; import set from 'lodash/set'; @@ -49,7 +49,7 @@ export class EachPlugin extends BasePlugin { } } }, - id: 'u:7fb7aa9c1c43' + id: generateId() }, { type: 'tpl', @@ -66,7 +66,7 @@ export class EachPlugin extends BasePlugin { } } }, - id: 'u:5b5f4735dcb0' + id: generateId() } ], style: { @@ -86,7 +86,7 @@ export class EachPlugin extends BasePlugin { } } }, - id: 'u:ee96c8898ee8' + id: generateId() }, { type: 'container', @@ -107,7 +107,7 @@ export class EachPlugin extends BasePlugin { } } }, - id: 'u:d7c386d27b64' + id: generateId() } ], style: { @@ -115,7 +115,7 @@ export class EachPlugin extends BasePlugin { display: 'block' }, wrapperBody: false, - id: 'u:ba92a34b6492' + id: generateId() } ], size: 'none', @@ -147,7 +147,7 @@ export class EachPlugin extends BasePlugin { } } }, - id: 'u:7484a2c497ed' + id: generateId() }, placeholder: '', style: { @@ -162,7 +162,7 @@ export class EachPlugin extends BasePlugin { isFixedHeight: false, isFixedWidth: false, size: 'none', - id: 'u:330fe2b1f73e' + id: generateId() }; previewSchema = { diff --git a/packages/amis-editor/src/plugin/Form/ButtonToolbar.tsx b/packages/amis-editor/src/plugin/Form/ButtonToolbar.tsx index ffe7eec35ec..2e908547d80 100644 --- a/packages/amis-editor/src/plugin/Form/ButtonToolbar.tsx +++ b/packages/amis-editor/src/plugin/Form/ButtonToolbar.tsx @@ -6,6 +6,7 @@ import { BUTTON_DEFAULT_ACTION, formItemControl } from '../../component/BaseControl'; +import {generateId} from '../../util'; export class ButtonToolbarControlPlugin extends BasePlugin { static id = 'ButtonToolbarControlPlugin'; @@ -29,11 +30,13 @@ export class ButtonToolbarControlPlugin extends BasePlugin { { type: 'button', label: '按钮1', + id: generateId(), ...BUTTON_DEFAULT_ACTION }, { type: 'button', label: '按钮2', + id: generateId(), ...BUTTON_DEFAULT_ACTION } ] diff --git a/packages/amis-editor/src/plugin/Form/Combo.tsx b/packages/amis-editor/src/plugin/Form/Combo.tsx index cf4786b0d29..b2d8e90356c 100644 --- a/packages/amis-editor/src/plugin/Form/Combo.tsx +++ b/packages/amis-editor/src/plugin/Form/Combo.tsx @@ -22,7 +22,7 @@ import { getActionCommonProps, buildLinkActionDesc } from '../../renderer/event-control/helper'; -import {resolveInputTableEventDataSchame} from '../../util'; +import {generateId, resolveInputTableEventDataSchame} from '../../util'; import React from 'react'; export class ComboControlPlugin extends BasePlugin { @@ -57,12 +57,14 @@ export class ComboControlPlugin extends BasePlugin { { type: 'input-text', name: 'text', - placeholder: '文本' + placeholder: '文本', + id: generateId() }, { type: 'select', name: 'select', placeholder: '选项', + id: generateId(), options: [ { label: 'A', diff --git a/packages/amis-editor/src/plugin/Form/ConditionBuilder.tsx b/packages/amis-editor/src/plugin/Form/ConditionBuilder.tsx index e4b9d29f6a3..0ad0461f79b 100644 --- a/packages/amis-editor/src/plugin/Form/ConditionBuilder.tsx +++ b/packages/amis-editor/src/plugin/Form/ConditionBuilder.tsx @@ -15,6 +15,7 @@ import isString from 'lodash/isString'; import defaultConfig, { OperationMap } from 'amis-ui/lib/components/condition-builder/config'; +import {generateId} from '../../util'; export class ConditionBilderPlugin extends BasePlugin { static id = 'ConditionBilderPlugin'; @@ -41,21 +42,25 @@ export class ConditionBilderPlugin extends BasePlugin { { label: '文本', type: 'text', + id: generateId(), name: 'text' }, { label: '数字', type: 'number', + id: generateId(), name: 'number' }, { label: '布尔', type: 'boolean', + id: generateId(), name: 'boolean' }, { label: '选项', type: 'select', + id: generateId(), name: 'select', options: [ { @@ -83,16 +88,19 @@ export class ConditionBilderPlugin extends BasePlugin { { label: '日期', type: 'date', + id: generateId(), name: 'date' }, { label: '时间', type: 'time', + id: generateId(), name: 'time' }, { label: '日期时间', type: 'datetime', + id: generateId(), name: 'datetime' } ] diff --git a/packages/amis-editor/src/plugin/Form/Control.tsx b/packages/amis-editor/src/plugin/Form/Control.tsx index 10b789b3ac0..27c19c871f4 100644 --- a/packages/amis-editor/src/plugin/Form/Control.tsx +++ b/packages/amis-editor/src/plugin/Form/Control.tsx @@ -4,6 +4,7 @@ import {getSchemaTpl} from 'amis-editor-core'; import {registerEditorPlugin} from 'amis-editor-core'; import {BasePlugin, RegionConfig, BaseEventContext} from 'amis-editor-core'; import {formItemControl} from '../../component/BaseControl'; +import {generateId} from '../../util'; export class ControlPlugin extends BasePlugin { static id = 'ControlPlugin'; @@ -30,6 +31,7 @@ export class ControlPlugin extends BasePlugin { { type: 'tpl', wrapperComponent: '', + id: generateId(), tpl: 'a' } ] diff --git a/packages/amis-editor/src/plugin/Form/FieldSet.tsx b/packages/amis-editor/src/plugin/Form/FieldSet.tsx index 7ee95255948..d391bbfa73b 100644 --- a/packages/amis-editor/src/plugin/Form/FieldSet.tsx +++ b/packages/amis-editor/src/plugin/Form/FieldSet.tsx @@ -3,6 +3,7 @@ import React from 'react'; import {defaultValue, getSchemaTpl} from 'amis-editor-core'; import {registerEditorPlugin} from 'amis-editor-core'; import {BaseEventContext, BasePlugin, RegionConfig} from 'amis-editor-core'; +import {generateId} from '../../util'; export class FieldSetControlPlugin extends BasePlugin { static id = 'FieldSetControlPlugin'; @@ -26,11 +27,13 @@ export class FieldSetControlPlugin extends BasePlugin { { type: 'input-text', label: '文本1', + id: generateId(), name: 'text' }, { type: 'input-text', label: '文本2', + id: generateId(), name: 'text' } ] diff --git a/packages/amis-editor/src/plugin/Form/Form.tsx b/packages/amis-editor/src/plugin/Form/Form.tsx index 6d9edeb2b36..4ad054955e9 100644 --- a/packages/amis-editor/src/plugin/Form/Form.tsx +++ b/packages/amis-editor/src/plugin/Form/Form.tsx @@ -43,7 +43,7 @@ import { getActionCommonProps } from '../../renderer/event-control/helper'; import {FieldSetting} from '../../renderer/FieldSetting'; -import {_isModelComp} from '../../util'; +import {_isModelComp, generateId} from '../../util'; import type {FormScaffoldConfig} from '../../builder'; @@ -99,6 +99,7 @@ export class FormPlugin extends BasePlugin { { label: '文本框', type: 'input-text', + id: generateId(), name: 'text' } ] diff --git a/packages/amis-editor/src/plugin/Form/Group.tsx b/packages/amis-editor/src/plugin/Form/Group.tsx index 3b644c46678..301ad9f6db9 100644 --- a/packages/amis-editor/src/plugin/Form/Group.tsx +++ b/packages/amis-editor/src/plugin/Form/Group.tsx @@ -9,6 +9,7 @@ import { } from 'amis-editor-core'; import {defaultValue, getSchemaTpl} from 'amis-editor-core'; import {JSONPipeIn, JSONUpdate, makeHorizontalDeeper} from 'amis-editor-core'; +import {generateId} from '../../util'; export class GroupControlPlugin extends BasePlugin { static id = 'GroupControlPlugin'; @@ -31,12 +32,14 @@ export class GroupControlPlugin extends BasePlugin { { type: 'input-text', label: '文本', + id: generateId(), name: 'var1' }, { type: 'input-text', label: '文本', + id: generateId(), name: 'var2' } ], diff --git a/packages/amis-editor/src/plugin/Form/InputArray.tsx b/packages/amis-editor/src/plugin/Form/InputArray.tsx index cff4f734dff..059bce61720 100644 --- a/packages/amis-editor/src/plugin/Form/InputArray.tsx +++ b/packages/amis-editor/src/plugin/Form/InputArray.tsx @@ -13,6 +13,7 @@ import { import {defaultValue, getSchemaTpl, valuePipeOut} from 'amis-editor-core'; import React from 'react'; import {diff, JSONPipeOut} from 'amis-editor-core'; +import {generateId} from '../../util'; export class ArrayControlPlugin extends BasePlugin { static id = 'ArrayControlPlugin'; @@ -36,6 +37,7 @@ export class ArrayControlPlugin extends BasePlugin { name: 'array', items: { type: 'input-text', + id: generateId(), placeholder: '请输入' } }; diff --git a/packages/amis-editor/src/plugin/Form/InputGroup.tsx b/packages/amis-editor/src/plugin/Form/InputGroup.tsx index ab6194d379e..f733a91f7a1 100644 --- a/packages/amis-editor/src/plugin/Form/InputGroup.tsx +++ b/packages/amis-editor/src/plugin/Form/InputGroup.tsx @@ -8,6 +8,7 @@ import { tipedLabel } from 'amis-editor-core'; import {ValidatorTag} from '../../validator'; +import {generateId} from '../../util'; export class InputGroupControlPlugin extends BasePlugin { static id = 'InputGroupControlPlugin'; @@ -33,11 +34,13 @@ export class InputGroupControlPlugin extends BasePlugin { { type: 'input-text', inputClassName: 'b-r-none p-r-none', + id: generateId(), name: 'input-group' }, { type: 'submit', label: '提交', + id: generateId(), level: 'primary' } ] diff --git a/packages/amis-editor/src/plugin/Form/InputSubForm.tsx b/packages/amis-editor/src/plugin/Form/InputSubForm.tsx index abb49cacbae..e0bb93bc0fc 100644 --- a/packages/amis-editor/src/plugin/Form/InputSubForm.tsx +++ b/packages/amis-editor/src/plugin/Form/InputSubForm.tsx @@ -14,6 +14,7 @@ import { EditorNodeType, jsonToJsonSchema } from 'amis-editor-core'; +import {generateId} from '../../util'; export class SubFormControlPlugin extends BasePlugin { static id = 'SubFormControlPlugin'; @@ -39,6 +40,7 @@ export class SubFormControlPlugin extends BasePlugin { { type: 'input-text', label: '文本', + id: generateId(), name: 'text' } ] diff --git a/packages/amis-editor/src/plugin/Form/InputTable.tsx b/packages/amis-editor/src/plugin/Form/InputTable.tsx index 97d31714040..313dc521614 100644 --- a/packages/amis-editor/src/plugin/Form/InputTable.tsx +++ b/packages/amis-editor/src/plugin/Form/InputTable.tsx @@ -30,6 +30,7 @@ import { } from '../../renderer/event-control/helper'; import cloneDeep from 'lodash/cloneDeep'; import { + generateId, resolveArrayDatasource, resolveInputTableEventDataSchame } from '../../util'; @@ -60,6 +61,7 @@ export class TableControlPlugin extends BasePlugin { name: 'name', quickEdit: { type: 'input-text', + id: generateId(), name: 'name1' } }, @@ -69,6 +71,7 @@ export class TableControlPlugin extends BasePlugin { quickEdit: { type: 'input-number', mode: 'inline', + id: generateId(), name: 'score' } }, @@ -78,6 +81,7 @@ export class TableControlPlugin extends BasePlugin { quickEdit: { type: 'select', name: 'level', + id: generateId(), options: [ { label: 'A', diff --git a/packages/amis-editor/src/plugin/List.tsx b/packages/amis-editor/src/plugin/List.tsx index 0692aa611d8..ffb6c754d11 100644 --- a/packages/amis-editor/src/plugin/List.tsx +++ b/packages/amis-editor/src/plugin/List.tsx @@ -21,7 +21,8 @@ import set from 'lodash/set'; import { schemaArrayFormat, resolveArrayDatasource, - schemaToArray + schemaToArray, + generateId } from '../util'; export class ListPlugin extends BasePlugin { @@ -49,7 +50,8 @@ export class ListPlugin extends BasePlugin { { type: 'tpl', tpl: '简单的展示数据:$a $b', - wrapperComponent: '' + wrapperComponent: '', + id: generateId() } ], actions: [ diff --git a/packages/amis-editor/src/plugin/List2.tsx b/packages/amis-editor/src/plugin/List2.tsx index 32415376722..386e55e47e0 100644 --- a/packages/amis-editor/src/plugin/List2.tsx +++ b/packages/amis-editor/src/plugin/List2.tsx @@ -11,7 +11,7 @@ import { import {defaultValue, getSchemaTpl} from 'amis-editor-core'; import {repeatArray} from 'amis-editor-core'; import set from 'lodash/set'; -import {escapeFormula, resolveArrayDatasource} from '../util'; +import {escapeFormula, generateId, resolveArrayDatasource} from '../util'; import merge from 'lodash/merge'; export class List2Plugin extends BasePlugin { @@ -59,7 +59,7 @@ export class List2Plugin extends BasePlugin { } } }, - id: 'u:0597d8ab5c3a' + id: generateId() }, { type: 'tpl', @@ -67,7 +67,7 @@ export class List2Plugin extends BasePlugin { inline: true, wrapperComponent: '', style: {}, - id: 'u:95d2a3ac3e70', + id: generateId(), themeCss: { baseControlClassName: { 'padding-and-margin:default': { @@ -96,7 +96,7 @@ export class List2Plugin extends BasePlugin { } } }, - id: 'u:d153d5c33ebf' + id: generateId() }, { type: 'tpl', @@ -111,7 +111,7 @@ export class List2Plugin extends BasePlugin { } } }, - id: 'u:4e03af905add' + id: generateId() } ], style: { @@ -125,7 +125,7 @@ export class List2Plugin extends BasePlugin { wrapperBody: false, isFixedHeight: false, isFixedWidth: false, - id: 'u:3e3e5dc43b6a' + id: generateId() } ], size: 'none', @@ -156,7 +156,7 @@ export class List2Plugin extends BasePlugin { } } }, - id: 'u:7a02e453c997' + id: generateId() }, { type: 'container', @@ -168,7 +168,7 @@ export class List2Plugin extends BasePlugin { wrapperComponent: '', style: {}, maxLine: 1, - id: 'u:105ca9cda3ef', + id: generateId(), themeCss: { baseControlClassName: { 'padding-and-margin:default': { @@ -197,7 +197,7 @@ export class List2Plugin extends BasePlugin { } } }, - id: 'u:d8e3f4be33db' + id: generateId() } ], size: 'none', @@ -214,7 +214,7 @@ export class List2Plugin extends BasePlugin { wrapperBody: false, isFixedHeight: false, isFixedWidth: false, - id: 'u:0c0b56fd0c17' + id: generateId() }, { type: 'container', @@ -260,7 +260,7 @@ export class List2Plugin extends BasePlugin { } } }, - id: 'u:0a2fe27eb501' + id: generateId() } ], size: 'xs', @@ -277,7 +277,7 @@ export class List2Plugin extends BasePlugin { wrapperBody: false, isFixedHeight: false, isFixedWidth: false, - id: 'u:77cb3edb2288' + id: generateId() } ], wrapperBody: false, @@ -317,13 +317,13 @@ export class List2Plugin extends BasePlugin { } } }, - id: 'u:bb14c60372c6' + id: generateId() }, placeholder: '', style: { gutterY: 10 }, - id: 'u:0fb820345fc1' + id: generateId() }; previewSchema = { diff --git a/packages/amis-editor/src/plugin/Operation.tsx b/packages/amis-editor/src/plugin/Operation.tsx index fd5485bd19a..e8ec1eee689 100644 --- a/packages/amis-editor/src/plugin/Operation.tsx +++ b/packages/amis-editor/src/plugin/Operation.tsx @@ -10,6 +10,7 @@ import { SubRendererInfo } from 'amis-editor-core'; import {getSchemaTpl} from 'amis-editor-core'; +import {generateId} from '../util'; export class OperationPlugin extends BasePlugin { static id = 'OperationPlugin'; @@ -29,7 +30,8 @@ export class OperationPlugin extends BasePlugin { buttons: [ { label: '按钮', - type: 'button' + type: 'button', + id: generateId() } ] }; diff --git a/packages/amis-editor/src/plugin/Page.tsx b/packages/amis-editor/src/plugin/Page.tsx index 5eca49a870a..1823071f40e 100644 --- a/packages/amis-editor/src/plugin/Page.tsx +++ b/packages/amis-editor/src/plugin/Page.tsx @@ -15,6 +15,7 @@ import type {SchemaObject} from 'amis'; import {tipedLabel} from 'amis-editor-core'; import {jsonToJsonSchema, EditorNodeType} from 'amis-editor-core'; import omit from 'lodash/omit'; +import {generateId} from '../util'; export class PagePlugin extends BasePlugin { static id = 'PagePlugin'; @@ -39,7 +40,8 @@ export class PagePlugin extends BasePlugin { body: [ { type: 'tpl', - tpl: '内容' + tpl: '内容', + id: generateId() } ] }; diff --git a/packages/amis-editor/src/plugin/SearchBox.tsx b/packages/amis-editor/src/plugin/SearchBox.tsx index fb54baeb775..6ff96bd9da1 100644 --- a/packages/amis-editor/src/plugin/SearchBox.tsx +++ b/packages/amis-editor/src/plugin/SearchBox.tsx @@ -6,11 +6,12 @@ import { RendererPluginAction, getSchemaTpl } from 'amis-editor-core'; -import type {Schema} from 'amis-core'; +import {type Schema} from 'amis-core'; import { getEventControlConfig, getActionCommonProps } from '../renderer/event-control/helper'; +import {generateId} from '../util'; export class SearchBoxPlugin extends BasePlugin { static id = 'SearchBoxPlugin'; @@ -36,7 +37,8 @@ export class SearchBoxPlugin extends BasePlugin { type: 'tpl', tpl: '搜索框', wrapperComponent: '', - inline: false + inline: false, + id: generateId() }, level: 'info' }; diff --git a/packages/amis-editor/src/plugin/SwitchContainer.tsx b/packages/amis-editor/src/plugin/SwitchContainer.tsx index c17e37b09a7..c6772cb177e 100644 --- a/packages/amis-editor/src/plugin/SwitchContainer.tsx +++ b/packages/amis-editor/src/plugin/SwitchContainer.tsx @@ -13,6 +13,7 @@ import { import {RegionWrapper as Region} from 'amis-editor-core'; import {getEventControlConfig} from '../renderer/event-control'; import React from 'react'; +import {generateId} from '../util'; export class SwitchContainerPlugin extends LayoutBasePlugin { static id = 'SwitchContainerPlugin'; @@ -34,21 +35,25 @@ export class SwitchContainerPlugin extends LayoutBasePlugin { items: [ { title: '状态一', + id: generateId(), body: [ { type: 'tpl', tpl: '状态一内容', - wrapperComponent: '' + wrapperComponent: '', + id: generateId() } ] }, { title: '状态二', + id: generateId(), body: [ { type: 'tpl', tpl: '状态二内容', - wrapperComponent: '' + wrapperComponent: '', + id: generateId() } ] } diff --git a/packages/amis-editor/src/plugin/TableView.tsx b/packages/amis-editor/src/plugin/TableView.tsx index b64cdcdb20f..de773dfe82a 100644 --- a/packages/amis-editor/src/plugin/TableView.tsx +++ b/packages/amis-editor/src/plugin/TableView.tsx @@ -18,9 +18,10 @@ import { } from 'amis-editor-core'; import {defaultValue, getSchemaTpl} from 'amis-editor-core'; import {VRenderer} from 'amis-editor-core'; -import type {TableViewSchema} from 'amis'; +import {type TableViewSchema} from 'amis'; import {JSONGetById} from 'amis-editor-core'; import {TableViewEditor} from '../component/TableViewEditor'; +import {generateId} from '../util'; /** * 尚未实现的功能: @@ -111,13 +112,15 @@ export class TableViewPlugin extends BasePlugin { body: { type: 'tpl', wrapperComponent: '', - tpl: '地区' + tpl: '地区', + id: generateId() } }, { body: { type: 'tpl', wrapperComponent: '', + id: generateId(), tpl: '城市' } }, @@ -125,6 +128,7 @@ export class TableViewPlugin extends BasePlugin { body: { type: 'tpl', wrapperComponent: '', + id: generateId(), tpl: '销量' } } @@ -137,6 +141,7 @@ export class TableViewPlugin extends BasePlugin { body: { type: 'tpl', wrapperComponent: '', + id: generateId(), tpl: '华北' } }, @@ -144,6 +149,7 @@ export class TableViewPlugin extends BasePlugin { body: { type: 'tpl', wrapperComponent: '', + id: generateId(), tpl: '北京' } }, @@ -151,6 +157,7 @@ export class TableViewPlugin extends BasePlugin { body: { type: 'tpl', wrapperComponent: '', + id: generateId(), tpl: '${beijing}' } } @@ -162,6 +169,7 @@ export class TableViewPlugin extends BasePlugin { body: { type: 'tpl', wrapperComponent: '', + id: generateId(), tpl: '天津' } }, @@ -169,6 +177,7 @@ export class TableViewPlugin extends BasePlugin { body: { type: 'tpl', wrapperComponent: '', + id: generateId(), tpl: '${tianjing}' } } diff --git a/packages/amis-editor/src/plugin/TooltipWrapper.tsx b/packages/amis-editor/src/plugin/TooltipWrapper.tsx index 455ab564113..a3bd4262253 100644 --- a/packages/amis-editor/src/plugin/TooltipWrapper.tsx +++ b/packages/amis-editor/src/plugin/TooltipWrapper.tsx @@ -1,11 +1,11 @@ /** * @file 文字提示容器 */ - import {registerEditorPlugin} from 'amis-editor-core'; import {BasePlugin, RegionConfig, BaseEventContext} from 'amis-editor-core'; import {defaultValue, getSchemaTpl} from 'amis-editor-core'; import {tipedLabel} from 'amis-editor-core'; +import {generateId} from '../util'; export class TooltipWrapperPlugin extends BasePlugin { static id = 'TooltipWrapperPlugin'; @@ -30,7 +30,8 @@ export class TooltipWrapperPlugin extends BasePlugin { { type: 'tpl', wrapperComponent: '', - tpl: '内容' + tpl: '内容', + id: generateId() } ], enterable: true, diff --git a/packages/amis-editor/src/plugin/Wizard.tsx b/packages/amis-editor/src/plugin/Wizard.tsx index 74f27283795..2dd45e98dca 100644 --- a/packages/amis-editor/src/plugin/Wizard.tsx +++ b/packages/amis-editor/src/plugin/Wizard.tsx @@ -22,6 +22,7 @@ import { getActionCommonProps, buildLinkActionDesc } from '../renderer/event-control/helper'; +import {generateId} from '../util'; export class WizardPlugin extends BasePlugin { static id = 'WizardPlugin'; @@ -47,7 +48,8 @@ export class WizardPlugin extends BasePlugin { { type: 'input-text', label: '文本', - name: 'var1' + name: 'var1', + id: generateId() } ] }, @@ -58,7 +60,8 @@ export class WizardPlugin extends BasePlugin { { type: 'input-text', label: '文本2', - name: 'var2' + name: 'var2', + id: generateId() } ] } diff --git a/packages/amis-editor/src/util.ts b/packages/amis-editor/src/util.ts index f57ca4f59c1..3ee834c8cbf 100644 --- a/packages/amis-editor/src/util.ts +++ b/packages/amis-editor/src/util.ts @@ -1,5 +1,5 @@ import {JSONValueMap, findTree, resolveVariableAndFilter} from 'amis'; -import {EditorManager} from 'amis-editor-core'; +import {EditorManager, guid} from 'amis-editor-core'; import isString from 'lodash/isString'; /** @@ -513,3 +513,7 @@ export const getOwnValue = (obj: any, key: string) => { return obj[key]; } }; + +export function generateId() { + return `u:${guid()}`; +} diff --git a/packages/amis/src/schemaExtend.ts b/packages/amis/src/schemaExtend.ts index 5eeebb9bdea..c821975a6a0 100644 --- a/packages/amis/src/schemaExtend.ts +++ b/packages/amis/src/schemaExtend.ts @@ -2,7 +2,7 @@ * 扩展 Schema,目前用于实现 input-kv */ import isEqual from 'lodash/isEqual'; -import {Schema} from 'amis-core'; +import {guid, Schema} from 'amis-core'; import {addSchemaFilter} from 'amis-core'; import {isObject} from 'amis-core'; @@ -63,6 +63,7 @@ addSchemaFilter(function (schema: Schema, renderer, props?: any) { items: [ schema.keySchema ? { + id: `u:${guid()}`, ...schema.keySchema, unique: true, name: 'key', @@ -75,21 +76,24 @@ addSchemaFilter(function (schema: Schema, renderer, props?: any) { unique: true, name: 'key', required: true, - validateOnChange: true + validateOnChange: true, + id: `u:${guid()}` }, schema.valueSchema - ? {...schema.valueSchema, name: 'value'} + ? {id: `u:${guid()}`, ...schema.valueSchema, name: 'value'} : schema.valueComponent ? { placeholder: schema.valuePlaceholder ?? 'Value', component: schema.valueComponent, asFormItem: true, - name: 'value' + name: 'value', + id: `u:${guid()}` } : { placeholder: schema.valuePlaceholder ?? 'Value', type: schema.valueType || 'input-text', - name: 'value' + name: 'value', + id: `u:${guid()}` } ] };