@tmagic/editor 1.0.0-rc.10 → 1.0.0-rc.11

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.
@@ -23,21 +23,24 @@ declare class Editor extends BaseService {
23
23
  /**
24
24
  * 根据id获取组件、组件的父组件以及组件所属的页面节点
25
25
  * @param {number | string} id 组件id
26
+ * @param {boolean} raw 是否使用toRaw
26
27
  * @returns {EditorNodeInfo}
27
28
  */
28
- getNodeInfo(id: Id): EditorNodeInfo;
29
+ getNodeInfo(id: Id, raw?: boolean): EditorNodeInfo;
29
30
  /**
30
31
  * 根据ID获取指点节点配置
31
32
  * @param id 组件ID
33
+ * @param {boolean} raw 是否使用toRaw
32
34
  * @returns 组件节点配置
33
35
  */
34
- getNodeById(id: Id): MNode | undefined;
36
+ getNodeById(id: Id, raw?: boolean): MNode | undefined;
35
37
  /**
36
38
  * 根据ID获取指点节点的父节点配置
37
39
  * @param id 组件ID
40
+ * @param {boolean} raw 是否使用toRaw
38
41
  * @returns 指点组件的父节点配置
39
42
  */
40
- getParentById(id: Id): MContainer | undefined;
43
+ getParentById(id: Id, raw?: boolean): MContainer | undefined;
41
44
  /**
42
45
  * 只有容器拥有布局
43
46
  */
@@ -44,6 +44,7 @@ export declare const DEFAULT_CONFIG: FormConfig;
44
44
  export declare const getDefaultPropsValue: (type: string, id: string) => {
45
45
  type: string;
46
46
  id: string;
47
+ layout: string;
47
48
  style: {};
48
49
  name: string;
49
50
  items: never[];
@@ -52,5 +53,6 @@ export declare const getDefaultPropsValue: (type: string, id: string) => {
52
53
  id: string;
53
54
  style: {};
54
55
  name: string;
56
+ layout?: undefined;
55
57
  items?: undefined;
56
58
  };
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-rc.10",
2
+ "version": "1.0.0-rc.11",
3
3
  "name": "@tmagic/editor",
4
4
  "sideEffects": [
5
5
  "dist/*",
@@ -43,11 +43,11 @@
43
43
  "dependencies": {
44
44
  "@babel/core": "^7.18.0",
45
45
  "@element-plus/icons": "0.0.11",
46
- "@tmagic/core": "1.0.0-rc.10",
47
- "@tmagic/form": "1.0.0-rc.10",
48
- "@tmagic/schema": "1.0.0-rc.10",
49
- "@tmagic/stage": "1.0.0-rc.10",
50
- "@tmagic/utils": "1.0.0-rc.10",
46
+ "@tmagic/core": "1.0.0-rc.11",
47
+ "@tmagic/form": "1.0.0-rc.11",
48
+ "@tmagic/schema": "1.0.0-rc.11",
49
+ "@tmagic/stage": "1.0.0-rc.11",
50
+ "@tmagic/utils": "1.0.0-rc.11",
51
51
  "buffer": "^6.0.3",
52
52
  "color": "^3.1.3",
53
53
  "element-plus": "^2.2.0",
@@ -60,7 +60,7 @@
60
60
  "vue": "^3.2.0"
61
61
  },
62
62
  "peerDependencies": {
63
- "@tmagic/form": "1.0.0-rc.10",
63
+ "@tmagic/form": "1.0.0-rc.11",
64
64
  "element-plus": "^2.2.0",
65
65
  "monaco-editor": "^0.32.1",
66
66
  "vue": "^3.2.0"
@@ -123,7 +123,7 @@ export default defineComponent({
123
123
  stage?.on('runtime-ready', (rt) => {
124
124
  runtime = rt;
125
125
  // toRaw返回的值是一个引用而非快照,需要cloneDeep
126
- root.value && runtime?.updateRootConfig(cloneDeep(toRaw(root.value)));
126
+ root.value && runtime?.updateRootConfig?.(cloneDeep(toRaw(root.value)));
127
127
  page.value?.id && runtime?.updatePageId?.(page.value.id);
128
128
  setTimeout(() => {
129
129
  node.value && stage?.select(toRaw(node.value.id));
@@ -138,7 +138,7 @@ export default defineComponent({
138
138
 
139
139
  watch(root, (root) => {
140
140
  if (runtime && root) {
141
- runtime.updateRootConfig(cloneDeep(toRaw(root)));
141
+ runtime.updateRootConfig?.(cloneDeep(toRaw(root)));
142
142
  }
143
143
  });
144
144
 
@@ -108,10 +108,14 @@ class Editor extends BaseService {
108
108
  /**
109
109
  * 根据id获取组件、组件的父组件以及组件所属的页面节点
110
110
  * @param {number | string} id 组件id
111
+ * @param {boolean} raw 是否使用toRaw
111
112
  * @returns {EditorNodeInfo}
112
113
  */
113
- public getNodeInfo(id: Id): EditorNodeInfo {
114
- const root = toRaw(this.get<MApp | null>('root'));
114
+ public getNodeInfo(id: Id, raw = true): EditorNodeInfo {
115
+ let root = this.get<MApp | null>('root');
116
+ if (raw) {
117
+ root = toRaw(root);
118
+ }
115
119
  if (!root) return {};
116
120
 
117
121
  if (id === root.id) {
@@ -141,21 +145,23 @@ class Editor extends BaseService {
141
145
  /**
142
146
  * 根据ID获取指点节点配置
143
147
  * @param id 组件ID
148
+ * @param {boolean} raw 是否使用toRaw
144
149
  * @returns 组件节点配置
145
150
  */
146
- public getNodeById(id: Id): MNode | undefined {
147
- const { node } = this.getNodeInfo(id);
151
+ public getNodeById(id: Id, raw = true): MNode | undefined {
152
+ const { node } = this.getNodeInfo(id, raw);
148
153
  return node;
149
154
  }
150
155
 
151
156
  /**
152
157
  * 根据ID获取指点节点的父节点配置
153
158
  * @param id 组件ID
159
+ * @param {boolean} raw 是否使用toRaw
154
160
  * @returns 指点组件的父节点配置
155
161
  */
156
- public getParentById(id: Id): MContainer | undefined {
162
+ public getParentById(id: Id, raw = true): MContainer | undefined {
157
163
  if (!this.get<MApp | null>('root')) return;
158
- const { parent } = this.getNodeInfo(id);
164
+ const { parent } = this.getNodeInfo(id, raw);
159
165
  return parent;
160
166
  }
161
167
 
@@ -279,7 +285,7 @@ class Editor extends BaseService {
279
285
  } else if (curNode.items) {
280
286
  parentNode = curNode;
281
287
  } else {
282
- parentNode = this.getParentById(curNode.id);
288
+ parentNode = this.getParentById(curNode.id, false);
283
289
  }
284
290
 
285
291
  if (!parentNode) throw new Error('未找到父元素');
@@ -332,7 +338,7 @@ class Editor extends BaseService {
332
338
 
333
339
  if (!root) throw new Error('没有root');
334
340
 
335
- const { parent, node: curNode } = this.getNodeInfo(node.id);
341
+ const { parent, node: curNode } = this.getNodeInfo(node.id, false);
336
342
 
337
343
  if (!parent || !curNode) throw new Error('找不要删除的节点');
338
344
 
@@ -384,7 +390,7 @@ class Editor extends BaseService {
384
390
  public async update(config: MNode): Promise<MNode> {
385
391
  if (!config?.id) throw new Error('没有配置或者配置缺少id值');
386
392
 
387
- const info = this.getNodeInfo(config.id);
393
+ const info = this.getNodeInfo(config.id, false);
388
394
 
389
395
  if (!info.node) throw new Error(`获取不到id为${config.id}的节点`);
390
396
 
@@ -25,6 +25,7 @@
25
25
  justify-items: center;
26
26
  align-items: center;
27
27
  background-color: #f3f3f3;
28
+ white-space: nowrap;
28
29
 
29
30
  &.active {
30
31
  background-color: #fff;
@@ -248,6 +248,7 @@ export const getDefaultPropsValue = (type: string, id: string) =>
248
248
  ? {
249
249
  type,
250
250
  id,
251
+ layout: 'absolute',
251
252
  style: {},
252
253
  name: type,
253
254
  items: [],