mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-06-11 06:29:22 +08:00
feat(editor): propsService.setNewItemId新增force参数
This commit is contained in:
parent
456692ff8a
commit
a9d794dc19
@ -139,12 +139,13 @@ class Props extends BaseService {
|
||||
|
||||
/**
|
||||
* 将组件与组件的子元素配置中的id都设置成一个新的ID
|
||||
* 如果没有相同ID则保持不变
|
||||
* 如果没有相同ID并且force为false则保持不变
|
||||
* @param {Object} config 组件配置
|
||||
* @param {Boolean} force 是否强制设置新的ID
|
||||
*/
|
||||
/* eslint no-param-reassign: ["error", { "props": false }] */
|
||||
public async setNewItemId(config: MNode) {
|
||||
if (editorService.getNodeById(config.id)) {
|
||||
public async setNewItemId(config: MNode, force = true) {
|
||||
if (force || editorService.getNodeById(config.id)) {
|
||||
const newId = await this.createId(config.type || 'component');
|
||||
this.setRelateId(config.id, newId);
|
||||
config.id = newId;
|
||||
|
@ -40,7 +40,7 @@ export const beforePaste = async (position: PastePosition, config: MNode[]): Pro
|
||||
if (pastePosition.top && configItem.style?.top) {
|
||||
pastePosition.top = configItem.style?.top - referenceTop + pastePosition.top;
|
||||
}
|
||||
const pasteConfig = await propsService.setNewItemId(configItem);
|
||||
const pasteConfig = await propsService.setNewItemId(configItem, false);
|
||||
|
||||
if (pasteConfig.style) {
|
||||
const { left, top } = pasteConfig.style;
|
||||
|
Loading…
x
Reference in New Issue
Block a user