@tmagic/editor 1.7.12 → 1.7.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -334,7 +334,7 @@ var Editor = class extends BaseService_default {
|
|
|
334
334
|
if (removedItems.length > 0 && pageForOp) this.pushOpHistory("remove", { removedItems }, pageForOp);
|
|
335
335
|
this.emit("remove", nodes);
|
|
336
336
|
}
|
|
337
|
-
async doUpdate(config, { changeRecords = [] } = {}) {
|
|
337
|
+
async doUpdate(config, { changeRecords = [], selectedAfterUpdate = true } = {}) {
|
|
338
338
|
const root = this.get("root");
|
|
339
339
|
if (!root) throw new Error("root为空");
|
|
340
340
|
if (!config?.id) throw new Error("没有配置或者配置缺少id值");
|
|
@@ -361,10 +361,12 @@ var Editor = class extends BaseService_default {
|
|
|
361
361
|
const layout = await this.getLayout(node);
|
|
362
362
|
if (Array.isArray(newConfig.items) && newLayout !== layout) newConfig = setChildrenLayout(newConfig, newLayout);
|
|
363
363
|
parentNodeItems[index] = newConfig;
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
364
|
+
if (selectedAfterUpdate) {
|
|
365
|
+
const nodes = this.get("nodes");
|
|
366
|
+
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
367
|
+
nodes.splice(targetIndex, 1, newConfig);
|
|
368
|
+
this.set("nodes", [...nodes]);
|
|
369
|
+
}
|
|
368
370
|
if (isPage(newConfig) || isPageFragment(newConfig)) this.set("page", newConfig);
|
|
369
371
|
this.addModifiedNodeId(newConfig.id);
|
|
370
372
|
return {
|
|
@@ -6103,7 +6103,7 @@
|
|
|
6103
6103
|
if (removedItems.length > 0 && pageForOp) this.pushOpHistory("remove", { removedItems }, pageForOp);
|
|
6104
6104
|
this.emit("remove", nodes);
|
|
6105
6105
|
}
|
|
6106
|
-
async doUpdate(config, { changeRecords = [] } = {}) {
|
|
6106
|
+
async doUpdate(config, { changeRecords = [], selectedAfterUpdate = true } = {}) {
|
|
6107
6107
|
const root = this.get("root");
|
|
6108
6108
|
if (!root) throw new Error("root为空");
|
|
6109
6109
|
if (!config?.id) throw new Error("没有配置或者配置缺少id值");
|
|
@@ -6130,10 +6130,12 @@
|
|
|
6130
6130
|
const layout = await this.getLayout(node);
|
|
6131
6131
|
if (Array.isArray(newConfig.items) && newLayout !== layout) newConfig = setChildrenLayout(newConfig, newLayout);
|
|
6132
6132
|
parentNodeItems[index] = newConfig;
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6133
|
+
if (selectedAfterUpdate) {
|
|
6134
|
+
const nodes = this.get("nodes");
|
|
6135
|
+
const targetIndex = nodes.findIndex((nodeItem) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
6136
|
+
nodes.splice(targetIndex, 1, newConfig);
|
|
6137
|
+
this.set("nodes", [...nodes]);
|
|
6138
|
+
}
|
|
6137
6139
|
if ((0, _tmagic_utils.isPage)(newConfig) || (0, _tmagic_utils.isPageFragment)(newConfig)) this.set("page", newConfig);
|
|
6138
6140
|
this.addModifiedNodeId(newConfig.id);
|
|
6139
6141
|
return {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.7.
|
|
2
|
+
"version": "1.7.13",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"moveable": "^0.53.0",
|
|
59
59
|
"serialize-javascript": "^7.0.0",
|
|
60
60
|
"sortablejs": "^1.15.6",
|
|
61
|
-
"@tmagic/
|
|
62
|
-
"@tmagic/
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/
|
|
65
|
-
"@tmagic/
|
|
61
|
+
"@tmagic/form": "1.7.13",
|
|
62
|
+
"@tmagic/stage": "1.7.13",
|
|
63
|
+
"@tmagic/design": "1.7.13",
|
|
64
|
+
"@tmagic/table": "1.7.13",
|
|
65
|
+
"@tmagic/utils": "1.7.13"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.3",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"type-fest": "^5.2.0",
|
|
77
77
|
"typescript": "^6.0.3",
|
|
78
78
|
"vue": "^3.5.33",
|
|
79
|
-
"@tmagic/core": "1.7.
|
|
79
|
+
"@tmagic/core": "1.7.13"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"typescript": {
|
package/src/services/editor.ts
CHANGED
|
@@ -509,7 +509,10 @@ class Editor extends BaseService {
|
|
|
509
509
|
|
|
510
510
|
public async doUpdate(
|
|
511
511
|
config: MNode,
|
|
512
|
-
{
|
|
512
|
+
{
|
|
513
|
+
changeRecords = [],
|
|
514
|
+
selectedAfterUpdate = true,
|
|
515
|
+
}: { changeRecords?: ChangeRecord[]; selectedAfterUpdate?: boolean } = {},
|
|
513
516
|
): Promise<{ newNode: MNode; oldNode: MNode; changeRecords?: ChangeRecord[] }> {
|
|
514
517
|
const root = this.get('root');
|
|
515
518
|
if (!root) throw new Error('root为空');
|
|
@@ -554,10 +557,12 @@ class Editor extends BaseService {
|
|
|
554
557
|
parentNodeItems[index] = newConfig;
|
|
555
558
|
|
|
556
559
|
// 将update后的配置更新到nodes中
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
560
|
+
if (selectedAfterUpdate) {
|
|
561
|
+
const nodes = this.get('nodes');
|
|
562
|
+
const targetIndex = nodes.findIndex((nodeItem: MNode) => `${nodeItem.id}` === `${newConfig.id}`);
|
|
563
|
+
nodes.splice(targetIndex, 1, newConfig);
|
|
564
|
+
this.set('nodes', [...nodes]);
|
|
565
|
+
}
|
|
561
566
|
|
|
562
567
|
if (isPage(newConfig) || isPageFragment(newConfig)) {
|
|
563
568
|
this.set('page', newConfig as MPage | MPageFragment);
|
|
@@ -580,7 +585,7 @@ class Editor extends BaseService {
|
|
|
580
585
|
*/
|
|
581
586
|
public async update(
|
|
582
587
|
config: MNode | MNode[],
|
|
583
|
-
data: { changeRecords?: ChangeRecord[] } = {},
|
|
588
|
+
data: { changeRecords?: ChangeRecord[]; selectedAfterUpdate?: boolean } = {},
|
|
584
589
|
): Promise<MNode | MNode[]> {
|
|
585
590
|
this.captureSelectionBeforeOp();
|
|
586
591
|
|
package/types/index.d.ts
CHANGED
|
@@ -422,9 +422,11 @@ declare class Editor extends export_default {
|
|
|
422
422
|
*/
|
|
423
423
|
remove(nodeOrNodeList: MNode | MNode[]): Promise<void>;
|
|
424
424
|
doUpdate(config: MNode, {
|
|
425
|
-
changeRecords
|
|
425
|
+
changeRecords,
|
|
426
|
+
selectedAfterUpdate
|
|
426
427
|
}?: {
|
|
427
428
|
changeRecords?: ChangeRecord[];
|
|
429
|
+
selectedAfterUpdate?: boolean;
|
|
428
430
|
}): Promise<{
|
|
429
431
|
newNode: MNode;
|
|
430
432
|
oldNode: MNode;
|
|
@@ -438,6 +440,7 @@ declare class Editor extends export_default {
|
|
|
438
440
|
*/
|
|
439
441
|
update(config: MNode | MNode[], data?: {
|
|
440
442
|
changeRecords?: ChangeRecord[];
|
|
443
|
+
selectedAfterUpdate?: boolean;
|
|
441
444
|
}): Promise<MNode | MNode[]>;
|
|
442
445
|
/**
|
|
443
446
|
* 将id为id1的组件移动到id为id2的组件位置上,例如:[1,2,3,4] -> sort(1,3) -> [2,1,3,4]
|