@tmagic/editor 1.7.11 → 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 {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import base_default from "./formConfigs/base.js";
|
|
2
2
|
import http_default from "./formConfigs/http.js";
|
|
3
|
-
import { defineFormItem } from "@tmagic/form";
|
|
4
3
|
import { dataSourceTemplateRegExp, getKeysArray, isNumber } from "@tmagic/utils";
|
|
5
4
|
//#region packages/editor/src/utils/data-source/index.ts
|
|
6
|
-
var dataSourceFormConfig =
|
|
5
|
+
var dataSourceFormConfig = {
|
|
7
6
|
type: "tab",
|
|
8
7
|
items: [
|
|
9
8
|
{
|
|
@@ -65,7 +64,7 @@ var dataSourceFormConfig = defineFormItem({
|
|
|
65
64
|
}]
|
|
66
65
|
}
|
|
67
66
|
]
|
|
68
|
-
}
|
|
67
|
+
};
|
|
69
68
|
var fillConfig = (config) => [
|
|
70
69
|
...base_default(),
|
|
71
70
|
...config,
|
|
@@ -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 {
|
|
@@ -7100,7 +7102,7 @@
|
|
|
7100
7102
|
]);
|
|
7101
7103
|
//#endregion
|
|
7102
7104
|
//#region packages/editor/src/utils/data-source/index.ts
|
|
7103
|
-
var dataSourceFormConfig =
|
|
7105
|
+
var dataSourceFormConfig = {
|
|
7104
7106
|
type: "tab",
|
|
7105
7107
|
items: [
|
|
7106
7108
|
{
|
|
@@ -7162,7 +7164,7 @@
|
|
|
7162
7164
|
}]
|
|
7163
7165
|
}
|
|
7164
7166
|
]
|
|
7165
|
-
}
|
|
7167
|
+
};
|
|
7166
7168
|
var fillConfig$1 = (config) => [
|
|
7167
7169
|
...base_default(),
|
|
7168
7170
|
...config,
|
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/stage": "1.7.
|
|
63
|
-
"@tmagic/
|
|
64
|
-
"@tmagic/
|
|
65
|
-
"@tmagic/utils": "1.7.
|
|
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
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { DataSchema, DataSourceFieldType, DataSourceSchema } from '@tmagic/core';
|
|
2
|
-
import { type CascaderOption,
|
|
2
|
+
import { type CascaderOption, type FormConfig, type TabConfig } from '@tmagic/form';
|
|
3
3
|
import { dataSourceTemplateRegExp, getKeysArray, isNumber } from '@tmagic/utils';
|
|
4
4
|
|
|
5
5
|
import BaseFormConfig from './formConfigs/base';
|
|
6
6
|
import HttpFormConfig from './formConfigs/http';
|
|
7
7
|
|
|
8
|
-
const dataSourceFormConfig =
|
|
8
|
+
const dataSourceFormConfig: TabConfig = {
|
|
9
9
|
type: 'tab',
|
|
10
10
|
items: [
|
|
11
11
|
{
|
|
@@ -73,9 +73,13 @@ const dataSourceFormConfig = defineFormItem({
|
|
|
73
73
|
],
|
|
74
74
|
},
|
|
75
75
|
],
|
|
76
|
-
}
|
|
76
|
+
};
|
|
77
77
|
|
|
78
|
-
const fillConfig = (config: FormConfig): FormConfig => [
|
|
78
|
+
const fillConfig = <T = never>(config: FormConfig<T>): FormConfig<T> => [
|
|
79
|
+
...BaseFormConfig(),
|
|
80
|
+
...config,
|
|
81
|
+
dataSourceFormConfig,
|
|
82
|
+
];
|
|
79
83
|
|
|
80
84
|
export const getFormConfig = (type: string, configs: Record<string, FormConfig>): FormConfig => {
|
|
81
85
|
switch (type) {
|
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]
|