@tmagic/stage 1.5.21 → 1.5.23

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.
@@ -1659,6 +1659,10 @@ class ActionManager extends EventEmitter {
1659
1659
  getDragStatus() {
1660
1660
  return this.dr?.getDragStatus();
1661
1661
  }
1662
+ updateMoveableOptions() {
1663
+ this.dr?.updateMoveable();
1664
+ this.multiDr?.updateMoveable();
1665
+ }
1662
1666
  destroy() {
1663
1667
  this.container.removeEventListener("mousedown", this.mouseDownHandler);
1664
1668
  this.container.removeEventListener("mousemove", this.mouseMoveHandler);
@@ -1907,13 +1911,16 @@ class Rule extends EventEmitter {
1907
1911
  guidesOptions;
1908
1912
  constructor(container, options) {
1909
1913
  super();
1914
+ if (options?.disabledRule) {
1915
+ return;
1916
+ }
1910
1917
  this.guidesOptions = options?.guidesOptions || {};
1911
1918
  this.container = container;
1912
1919
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
1913
1920
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
1914
1921
  this.containerResizeObserver = new ResizeObserver(() => {
1915
- this.vGuides.resize();
1916
- this.hGuides.resize();
1922
+ this.vGuides?.resize();
1923
+ this.hGuides?.resize();
1917
1924
  });
1918
1925
  this.containerResizeObserver.observe(this.container);
1919
1926
  }
@@ -1923,20 +1930,20 @@ class Rule extends EventEmitter {
1923
1930
  */
1924
1931
  showGuides(isShowGuides = true) {
1925
1932
  this.isShowGuides = isShowGuides;
1926
- this.hGuides.setState({
1933
+ this.hGuides?.setState({
1927
1934
  showGuides: isShowGuides
1928
1935
  });
1929
- this.vGuides.setState({
1936
+ this.vGuides?.setState({
1930
1937
  showGuides: isShowGuides
1931
1938
  });
1932
1939
  }
1933
1940
  setGuides([hLines, vLines]) {
1934
1941
  this.horizontalGuidelines = hLines;
1935
1942
  this.verticalGuidelines = vLines;
1936
- this.hGuides.setState({
1943
+ this.hGuides?.setState({
1937
1944
  defaultGuides: hLines
1938
1945
  });
1939
- this.vGuides.setState({
1946
+ this.vGuides?.setState({
1940
1947
  defaultGuides: vLines
1941
1948
  });
1942
1949
  this.emit("change-guides", {
@@ -1964,12 +1971,12 @@ class Rule extends EventEmitter {
1964
1971
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
1965
1972
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
1966
1973
  } else {
1967
- this.hGuides.setState({
1974
+ this.hGuides?.setState({
1968
1975
  rulerStyle: {
1969
1976
  visibility: "hidden"
1970
1977
  }
1971
1978
  });
1972
- this.vGuides.setState({
1979
+ this.vGuides?.setState({
1973
1980
  rulerStyle: {
1974
1981
  visibility: "hidden"
1975
1982
  }
@@ -1977,24 +1984,27 @@ class Rule extends EventEmitter {
1977
1984
  }
1978
1985
  }
1979
1986
  scrollRule(scrollTop) {
1980
- this.hGuides.scrollGuides(scrollTop);
1981
- this.hGuides.scroll(0);
1982
- this.vGuides.scrollGuides(0);
1983
- this.vGuides.scroll(scrollTop);
1987
+ this.hGuides?.scrollGuides(scrollTop);
1988
+ this.hGuides?.scroll(0);
1989
+ this.vGuides?.scrollGuides(0);
1990
+ this.vGuides?.scroll(scrollTop);
1984
1991
  }
1985
1992
  destroy() {
1986
1993
  this.destroyGuides();
1987
- this.hGuides.off("changeGuides", this.hGuidesChangeGuidesHandler);
1988
- this.vGuides.off("changeGuides", this.vGuidesChangeGuidesHandler);
1989
- this.containerResizeObserver.disconnect();
1994
+ this.hGuides?.off("changeGuides", this.hGuidesChangeGuidesHandler);
1995
+ this.vGuides?.off("changeGuides", this.vGuidesChangeGuidesHandler);
1996
+ this.containerResizeObserver?.disconnect();
1990
1997
  this.removeAllListeners();
1991
1998
  }
1992
1999
  destroyGuides() {
1993
- this.hGuides.destroy();
1994
- this.vGuides.destroy();
1995
- this.container.querySelectorAll(`.${guidesClass}`).forEach((el) => {
2000
+ this.hGuides?.destroy();
2001
+ this.vGuides?.destroy();
2002
+ this.container?.querySelectorAll(`.${guidesClass}`).forEach((el) => {
1996
2003
  el.remove();
1997
2004
  });
2005
+ this.hGuides = void 0;
2006
+ this.vGuides = void 0;
2007
+ this.container = void 0;
1998
2008
  }
1999
2009
  getGuidesStyle = (type) => ({
2000
2010
  position: "fixed",
@@ -2005,6 +2015,9 @@ class Rule extends EventEmitter {
2005
2015
  height: type === GuidesType.HORIZONTAL ? "30px" : "100%"
2006
2016
  });
2007
2017
  createGuides = (type, defaultGuides = []) => {
2018
+ if (!this.container) {
2019
+ return;
2020
+ }
2008
2021
  const guides = new Guides(this.container, {
2009
2022
  type,
2010
2023
  defaultGuides,
@@ -2211,6 +2224,10 @@ class StageMask extends Rule {
2211
2224
  const { clientHeight, clientWidth } = entry.target;
2212
2225
  this.wrapperHeight = clientHeight;
2213
2226
  this.wrapperWidth = clientWidth;
2227
+ if (this.mode === Mode.FIXED) {
2228
+ this.content.style.width = `${this.wrapperWidth}px`;
2229
+ this.content.style.height = `${this.wrapperHeight}px`;
2230
+ }
2214
2231
  this.setMaxScrollLeft();
2215
2232
  this.setMaxScrollTop();
2216
2233
  });
@@ -2250,7 +2267,9 @@ class StageMask extends Rule {
2250
2267
  setHeight(height) {
2251
2268
  this.height = height;
2252
2269
  this.setMaxScrollTop();
2253
- this.content.style.height = `${height}px`;
2270
+ if (this.mode !== Mode.FIXED) {
2271
+ this.content.style.height = `${height}px`;
2272
+ }
2254
2273
  }
2255
2274
  /**
2256
2275
  * 设置蒙层宽度
@@ -2259,7 +2278,9 @@ class StageMask extends Rule {
2259
2278
  setWidth(width) {
2260
2279
  this.width = width;
2261
2280
  this.setMaxScrollLeft();
2262
- this.content.style.width = `${width}px`;
2281
+ if (this.mode !== Mode.FIXED) {
2282
+ this.content.style.width = `${width}px`;
2283
+ }
2263
2284
  }
2264
2285
  /**
2265
2286
  * 计算并设置最大滚动宽度
@@ -2324,7 +2345,10 @@ class StageRender extends EventEmitter$1 {
2324
2345
  }
2325
2346
  }
2326
2347
  getMagicApi = () => ({
2327
- onPageElUpdate: (el) => this.emit("page-el-update", el),
2348
+ id: guid(),
2349
+ onPageElUpdate: (el) => {
2350
+ this.emit("page-el-update", el);
2351
+ },
2328
2352
  onRuntimeReady: (runtime) => {
2329
2353
  if (this.runtime) {
2330
2354
  return;
@@ -2523,7 +2547,8 @@ class StageCore extends EventEmitter$1 {
2523
2547
  }
2524
2548
  });
2525
2549
  this.mask = new StageMask({
2526
- guidesOptions: config.guidesOptions
2550
+ guidesOptions: config.guidesOptions,
2551
+ disabledRule: config.disabledRule
2527
2552
  });
2528
2553
  this.actionManager = new ActionManager(this.getActionManagerConfig(config));
2529
2554
  this.initRenderEvent();
@@ -4132,6 +4132,10 @@
4132
4132
  getDragStatus() {
4133
4133
  return this.dr?.getDragStatus();
4134
4134
  }
4135
+ updateMoveableOptions() {
4136
+ this.dr?.updateMoveable();
4137
+ this.multiDr?.updateMoveable();
4138
+ }
4135
4139
  destroy() {
4136
4140
  this.container.removeEventListener("mousedown", this.mouseDownHandler);
4137
4141
  this.container.removeEventListener("mousemove", this.mouseMoveHandler);
@@ -4380,13 +4384,16 @@
4380
4384
  guidesOptions;
4381
4385
  constructor(container, options) {
4382
4386
  super();
4387
+ if (options?.disabledRule) {
4388
+ return;
4389
+ }
4383
4390
  this.guidesOptions = options?.guidesOptions || {};
4384
4391
  this.container = container;
4385
4392
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
4386
4393
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
4387
4394
  this.containerResizeObserver = new ResizeObserver(() => {
4388
- this.vGuides.resize();
4389
- this.hGuides.resize();
4395
+ this.vGuides?.resize();
4396
+ this.hGuides?.resize();
4390
4397
  });
4391
4398
  this.containerResizeObserver.observe(this.container);
4392
4399
  }
@@ -4396,20 +4403,20 @@
4396
4403
  */
4397
4404
  showGuides(isShowGuides = true) {
4398
4405
  this.isShowGuides = isShowGuides;
4399
- this.hGuides.setState({
4406
+ this.hGuides?.setState({
4400
4407
  showGuides: isShowGuides
4401
4408
  });
4402
- this.vGuides.setState({
4409
+ this.vGuides?.setState({
4403
4410
  showGuides: isShowGuides
4404
4411
  });
4405
4412
  }
4406
4413
  setGuides([hLines, vLines]) {
4407
4414
  this.horizontalGuidelines = hLines;
4408
4415
  this.verticalGuidelines = vLines;
4409
- this.hGuides.setState({
4416
+ this.hGuides?.setState({
4410
4417
  defaultGuides: hLines
4411
4418
  });
4412
- this.vGuides.setState({
4419
+ this.vGuides?.setState({
4413
4420
  defaultGuides: vLines
4414
4421
  });
4415
4422
  this.emit("change-guides", {
@@ -4437,12 +4444,12 @@
4437
4444
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
4438
4445
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
4439
4446
  } else {
4440
- this.hGuides.setState({
4447
+ this.hGuides?.setState({
4441
4448
  rulerStyle: {
4442
4449
  visibility: "hidden"
4443
4450
  }
4444
4451
  });
4445
- this.vGuides.setState({
4452
+ this.vGuides?.setState({
4446
4453
  rulerStyle: {
4447
4454
  visibility: "hidden"
4448
4455
  }
@@ -4450,24 +4457,27 @@
4450
4457
  }
4451
4458
  }
4452
4459
  scrollRule(scrollTop) {
4453
- this.hGuides.scrollGuides(scrollTop);
4454
- this.hGuides.scroll(0);
4455
- this.vGuides.scrollGuides(0);
4456
- this.vGuides.scroll(scrollTop);
4460
+ this.hGuides?.scrollGuides(scrollTop);
4461
+ this.hGuides?.scroll(0);
4462
+ this.vGuides?.scrollGuides(0);
4463
+ this.vGuides?.scroll(scrollTop);
4457
4464
  }
4458
4465
  destroy() {
4459
4466
  this.destroyGuides();
4460
- this.hGuides.off("changeGuides", this.hGuidesChangeGuidesHandler);
4461
- this.vGuides.off("changeGuides", this.vGuidesChangeGuidesHandler);
4462
- this.containerResizeObserver.disconnect();
4467
+ this.hGuides?.off("changeGuides", this.hGuidesChangeGuidesHandler);
4468
+ this.vGuides?.off("changeGuides", this.vGuidesChangeGuidesHandler);
4469
+ this.containerResizeObserver?.disconnect();
4463
4470
  this.removeAllListeners();
4464
4471
  }
4465
4472
  destroyGuides() {
4466
- this.hGuides.destroy();
4467
- this.vGuides.destroy();
4468
- this.container.querySelectorAll(`.${guidesClass}`).forEach((el) => {
4473
+ this.hGuides?.destroy();
4474
+ this.vGuides?.destroy();
4475
+ this.container?.querySelectorAll(`.${guidesClass}`).forEach((el) => {
4469
4476
  el.remove();
4470
4477
  });
4478
+ this.hGuides = void 0;
4479
+ this.vGuides = void 0;
4480
+ this.container = void 0;
4471
4481
  }
4472
4482
  getGuidesStyle = (type) => ({
4473
4483
  position: "fixed",
@@ -4478,6 +4488,9 @@
4478
4488
  height: type === GuidesType.HORIZONTAL ? "30px" : "100%"
4479
4489
  });
4480
4490
  createGuides = (type, defaultGuides = []) => {
4491
+ if (!this.container) {
4492
+ return;
4493
+ }
4481
4494
  const guides = new Guides(this.container, {
4482
4495
  type,
4483
4496
  defaultGuides,
@@ -4684,6 +4697,10 @@
4684
4697
  const { clientHeight, clientWidth } = entry.target;
4685
4698
  this.wrapperHeight = clientHeight;
4686
4699
  this.wrapperWidth = clientWidth;
4700
+ if (this.mode === Mode.FIXED) {
4701
+ this.content.style.width = `${this.wrapperWidth}px`;
4702
+ this.content.style.height = `${this.wrapperHeight}px`;
4703
+ }
4687
4704
  this.setMaxScrollLeft();
4688
4705
  this.setMaxScrollTop();
4689
4706
  });
@@ -4723,7 +4740,9 @@
4723
4740
  setHeight(height) {
4724
4741
  this.height = height;
4725
4742
  this.setMaxScrollTop();
4726
- this.content.style.height = `${height}px`;
4743
+ if (this.mode !== Mode.FIXED) {
4744
+ this.content.style.height = `${height}px`;
4745
+ }
4727
4746
  }
4728
4747
  /**
4729
4748
  * 设置蒙层宽度
@@ -4732,7 +4751,9 @@
4732
4751
  setWidth(width) {
4733
4752
  this.width = width;
4734
4753
  this.setMaxScrollLeft();
4735
- this.content.style.width = `${width}px`;
4754
+ if (this.mode !== Mode.FIXED) {
4755
+ this.content.style.width = `${width}px`;
4756
+ }
4736
4757
  }
4737
4758
  /**
4738
4759
  * 计算并设置最大滚动宽度
@@ -4797,7 +4818,10 @@
4797
4818
  }
4798
4819
  }
4799
4820
  getMagicApi = () => ({
4800
- onPageElUpdate: (el) => this.emit("page-el-update", el),
4821
+ id: core.guid(),
4822
+ onPageElUpdate: (el) => {
4823
+ this.emit("page-el-update", el);
4824
+ },
4801
4825
  onRuntimeReady: (runtime) => {
4802
4826
  if (this.runtime) {
4803
4827
  return;
@@ -4996,7 +5020,8 @@
4996
5020
  }
4997
5021
  });
4998
5022
  this.mask = new StageMask({
4999
- guidesOptions: config.guidesOptions
5023
+ guidesOptions: config.guidesOptions,
5024
+ disabledRule: config.disabledRule
5000
5025
  });
5001
5026
  this.actionManager = new ActionManager(this.getActionManagerConfig(config));
5002
5027
  this.initRenderEvent();
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.21",
2
+ "version": "1.5.23",
3
3
  "name": "@tmagic/stage",
4
4
  "type": "module",
5
5
  "main": "dist/tmagic-stage.umd.cjs",
@@ -37,12 +37,12 @@
37
37
  "scenejs": "^1.10.3"
38
38
  },
39
39
  "devDependencies": {
40
- "@types/events": "^3.0.0",
40
+ "@types/events": "^3.0.3",
41
41
  "@types/lodash-es": "^4.17.4"
42
42
  },
43
43
  "peerDependencies": {
44
- "typescript": "*",
45
- "@tmagic/core": "1.5.21"
44
+ "typescript": "^5.8.3",
45
+ "@tmagic/core": "1.5.23"
46
46
  },
47
47
  "peerDependenciesMeta": {
48
48
  "typescript": {
@@ -380,6 +380,11 @@ export default class ActionManager extends EventEmitter {
380
380
  return this.dr?.getDragStatus();
381
381
  }
382
382
 
383
+ public updateMoveableOptions(): void {
384
+ this.dr?.updateMoveable();
385
+ this.multiDr?.updateMoveable();
386
+ }
387
+
383
388
  public destroy(): void {
384
389
  this.container.removeEventListener('mousedown', this.mouseDownHandler);
385
390
  this.container.removeEventListener('mousemove', this.mouseMoveHandler);
package/src/Rule.ts CHANGED
@@ -8,19 +8,23 @@ import type { RuleOptions } from './types';
8
8
  const guidesClass = 'tmagic-stage-guides';
9
9
 
10
10
  export default class Rule extends EventEmitter {
11
- public hGuides: Guides;
12
- public vGuides: Guides;
11
+ public hGuides?: Guides;
12
+ public vGuides?: Guides;
13
13
  public horizontalGuidelines: number[] = [];
14
14
  public verticalGuidelines: number[] = [];
15
15
 
16
- private container: HTMLDivElement;
17
- private containerResizeObserver: ResizeObserver;
16
+ private container?: HTMLDivElement;
17
+ private containerResizeObserver?: ResizeObserver;
18
18
  private isShowGuides = true;
19
19
  private guidesOptions?: Partial<GuidesOptions>;
20
20
 
21
21
  constructor(container: HTMLDivElement, options?: RuleOptions) {
22
22
  super();
23
23
 
24
+ if (options?.disabledRule) {
25
+ return;
26
+ }
27
+
24
28
  this.guidesOptions = options?.guidesOptions || {};
25
29
 
26
30
  this.container = container;
@@ -28,8 +32,8 @@ export default class Rule extends EventEmitter {
28
32
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
29
33
 
30
34
  this.containerResizeObserver = new ResizeObserver(() => {
31
- this.vGuides.resize();
32
- this.hGuides.resize();
35
+ this.vGuides?.resize();
36
+ this.hGuides?.resize();
33
37
  });
34
38
 
35
39
  this.containerResizeObserver.observe(this.container);
@@ -42,11 +46,11 @@ export default class Rule extends EventEmitter {
42
46
  public showGuides(isShowGuides = true) {
43
47
  this.isShowGuides = isShowGuides;
44
48
 
45
- this.hGuides.setState({
49
+ this.hGuides?.setState({
46
50
  showGuides: isShowGuides,
47
51
  });
48
52
 
49
- this.vGuides.setState({
53
+ this.vGuides?.setState({
50
54
  showGuides: isShowGuides,
51
55
  });
52
56
  }
@@ -55,11 +59,11 @@ export default class Rule extends EventEmitter {
55
59
  this.horizontalGuidelines = hLines;
56
60
  this.verticalGuidelines = vLines;
57
61
 
58
- this.hGuides.setState({
62
+ this.hGuides?.setState({
59
63
  defaultGuides: hLines,
60
64
  });
61
65
 
62
- this.vGuides.setState({
66
+ this.vGuides?.setState({
63
67
  defaultGuides: vLines,
64
68
  });
65
69
 
@@ -93,13 +97,13 @@ export default class Rule extends EventEmitter {
93
97
  this.hGuides = this.createGuides(GuidesType.HORIZONTAL, this.horizontalGuidelines);
94
98
  this.vGuides = this.createGuides(GuidesType.VERTICAL, this.verticalGuidelines);
95
99
  } else {
96
- this.hGuides.setState({
100
+ this.hGuides?.setState({
97
101
  rulerStyle: {
98
102
  visibility: 'hidden',
99
103
  },
100
104
  });
101
105
 
102
- this.vGuides.setState({
106
+ this.vGuides?.setState({
103
107
  rulerStyle: {
104
108
  visibility: 'hidden',
105
109
  },
@@ -108,28 +112,32 @@ export default class Rule extends EventEmitter {
108
112
  }
109
113
 
110
114
  public scrollRule(scrollTop: number) {
111
- this.hGuides.scrollGuides(scrollTop);
112
- this.hGuides.scroll(0);
115
+ this.hGuides?.scrollGuides(scrollTop);
116
+ this.hGuides?.scroll(0);
113
117
 
114
- this.vGuides.scrollGuides(0);
115
- this.vGuides.scroll(scrollTop);
118
+ this.vGuides?.scrollGuides(0);
119
+ this.vGuides?.scroll(scrollTop);
116
120
  }
117
121
 
118
122
  public destroy(): void {
119
123
  this.destroyGuides();
120
- this.hGuides.off('changeGuides', this.hGuidesChangeGuidesHandler);
121
- this.vGuides.off('changeGuides', this.vGuidesChangeGuidesHandler);
122
- this.containerResizeObserver.disconnect();
124
+ this.hGuides?.off('changeGuides', this.hGuidesChangeGuidesHandler);
125
+ this.vGuides?.off('changeGuides', this.vGuidesChangeGuidesHandler);
126
+ this.containerResizeObserver?.disconnect();
123
127
  this.removeAllListeners();
124
128
  }
125
129
 
126
130
  public destroyGuides(): void {
127
- this.hGuides.destroy();
128
- this.vGuides.destroy();
131
+ this.hGuides?.destroy();
132
+ this.vGuides?.destroy();
129
133
 
130
- this.container.querySelectorAll(`.${guidesClass}`).forEach((el) => {
134
+ this.container?.querySelectorAll(`.${guidesClass}`).forEach((el) => {
131
135
  el.remove();
132
136
  });
137
+
138
+ this.hGuides = undefined;
139
+ this.vGuides = undefined;
140
+ this.container = undefined;
133
141
  }
134
142
 
135
143
  private getGuidesStyle = (type: GuidesType) => ({
@@ -141,7 +149,11 @@ export default class Rule extends EventEmitter {
141
149
  height: type === GuidesType.HORIZONTAL ? '30px' : '100%',
142
150
  });
143
151
 
144
- private createGuides = (type: GuidesType, defaultGuides: number[] = []): Guides => {
152
+ private createGuides = (type: GuidesType, defaultGuides: number[] = []): Guides | undefined => {
153
+ if (!this.container) {
154
+ return;
155
+ }
156
+
145
157
  const guides = new Guides(this.container, {
146
158
  type,
147
159
  defaultGuides,
package/src/StageCore.ts CHANGED
@@ -74,6 +74,7 @@ export default class StageCore extends EventEmitter {
74
74
  });
75
75
  this.mask = new StageMask({
76
76
  guidesOptions: config.guidesOptions,
77
+ disabledRule: config.disabledRule,
77
78
  });
78
79
  this.actionManager = new ActionManager(this.getActionManagerConfig(config));
79
80
 
package/src/StageMask.ts CHANGED
@@ -236,6 +236,12 @@ export default class StageMask extends Rule {
236
236
  const { clientHeight, clientWidth } = entry.target;
237
237
  this.wrapperHeight = clientHeight;
238
238
  this.wrapperWidth = clientWidth;
239
+
240
+ if (this.mode === Mode.FIXED) {
241
+ this.content.style.width = `${this.wrapperWidth}px`;
242
+ this.content.style.height = `${this.wrapperHeight}px`;
243
+ }
244
+
239
245
  this.setMaxScrollLeft();
240
246
  this.setMaxScrollTop();
241
247
  });
@@ -286,7 +292,9 @@ export default class StageMask extends Rule {
286
292
  private setHeight(height: number): void {
287
293
  this.height = height;
288
294
  this.setMaxScrollTop();
289
- this.content.style.height = `${height}px`;
295
+ if (this.mode !== Mode.FIXED) {
296
+ this.content.style.height = `${height}px`;
297
+ }
290
298
  }
291
299
 
292
300
  /**
@@ -296,7 +304,9 @@ export default class StageMask extends Rule {
296
304
  private setWidth(width: number): void {
297
305
  this.width = width;
298
306
  this.setMaxScrollLeft();
299
- this.content.style.width = `${width}px`;
307
+ if (this.mode !== Mode.FIXED) {
308
+ this.content.style.width = `${width}px`;
309
+ }
300
310
  }
301
311
 
302
312
  /**
@@ -19,7 +19,7 @@
19
19
  import { EventEmitter } from 'events';
20
20
 
21
21
  import type { Id } from '@tmagic/core';
22
- import { getElById, getHost, injectStyle, isSameDomain } from '@tmagic/core';
22
+ import { getElById, getHost, guid, injectStyle, isSameDomain } from '@tmagic/core';
23
23
 
24
24
  import { DEFAULT_ZOOM, RenderType } from './const';
25
25
  import style from './style.css?raw';
@@ -54,7 +54,10 @@ export default class StageRender extends EventEmitter {
54
54
  }
55
55
 
56
56
  public getMagicApi = () => ({
57
- onPageElUpdate: (el: HTMLElement) => this.emit('page-el-update', el),
57
+ id: guid(),
58
+ onPageElUpdate: (el: HTMLElement) => {
59
+ this.emit('page-el-update', el);
60
+ },
58
61
  onRuntimeReady: (runtime: Runtime) => {
59
62
  if (this.runtime) {
60
63
  return;
package/src/types.ts CHANGED
@@ -67,6 +67,7 @@ export interface StageCoreConfig {
67
67
  renderType?: RenderType;
68
68
  guidesOptions?: Partial<GuidesOptions>;
69
69
  disabledMultiSelect?: boolean;
70
+ disabledRule?: boolean;
70
71
  }
71
72
 
72
73
  export interface ActionManagerConfig {
@@ -214,6 +215,7 @@ export interface Runtime {
214
215
  }
215
216
 
216
217
  export interface Magic {
218
+ id: string;
217
219
  /** 当前页面的根节点变化时调用该方法,编辑器会同步该el和stage的大小,该方法由stage注入到iframe.contentWindow中 */
218
220
  onPageElUpdate: (el: HTMLElement) => void;
219
221
 
@@ -239,6 +241,7 @@ export interface TargetShadowConfig {
239
241
 
240
242
  export interface RuleOptions {
241
243
  guidesOptions?: Partial<GuidesOptions>;
244
+ disabledRule?: boolean;
242
245
  }
243
246
 
244
247
  export interface CoreEvents {
package/types/index.d.ts CHANGED
@@ -189,6 +189,7 @@ interface StageCoreConfig {
189
189
  renderType?: RenderType;
190
190
  guidesOptions?: Partial<GuidesOptions>;
191
191
  disabledMultiSelect?: boolean;
192
+ disabledRule?: boolean;
192
193
  }
193
194
  interface ActionManagerConfig {
194
195
  container: HTMLElement;
@@ -317,6 +318,7 @@ interface Runtime {
317
318
  [key: string]: any;
318
319
  }
319
320
  interface Magic {
321
+ id: string;
320
322
  /** 当前页面的根节点变化时调用该方法,编辑器会同步该el和stage的大小,该方法由stage注入到iframe.contentWindow中 */
321
323
  onPageElUpdate: (el: HTMLElement) => void;
322
324
  onRuntimeReady: (runtime: Runtime) => void;
@@ -337,6 +339,7 @@ interface TargetShadowConfig {
337
339
  }
338
340
  interface RuleOptions {
339
341
  guidesOptions?: Partial<GuidesOptions>;
342
+ disabledRule?: boolean;
340
343
  }
341
344
  interface CoreEvents {
342
345
  mounted: [];
@@ -507,6 +510,7 @@ declare class ActionManager extends EventEmitter {
507
510
  */
508
511
  delayedMarkContainer(event: MouseEvent, excludeElList?: Element[]): NodeJS.Timeout | undefined;
509
512
  getDragStatus(): StageDragStatus | undefined;
513
+ updateMoveableOptions(): void;
510
514
  destroy(): void;
511
515
  on<Name extends keyof ActionManagerEvents, Param extends ActionManagerEvents[Name]>(eventName: Name, listener: (...args: Param) => void): this;
512
516
  emit<Name extends keyof ActionManagerEvents, Param extends ActionManagerEvents[Name]>(eventName: Name, ...args: Param): boolean;
@@ -548,12 +552,12 @@ declare class ActionManager extends EventEmitter {
548
552
  }
549
553
 
550
554
  declare class Rule extends EventEmitter {
551
- hGuides: Guides;
552
- vGuides: Guides;
555
+ hGuides?: Guides;
556
+ vGuides?: Guides;
553
557
  horizontalGuidelines: number[];
554
558
  verticalGuidelines: number[];
555
- private container;
556
- private containerResizeObserver;
559
+ private container?;
560
+ private containerResizeObserver?;
557
561
  private isShowGuides;
558
562
  private guidesOptions?;
559
563
  constructor(container: HTMLDivElement, options?: RuleOptions);
@@ -680,7 +684,8 @@ declare class StageRender extends EventEmitter$1 {
680
684
  private customizedRender?;
681
685
  constructor({ runtimeUrl, zoom, customizedRender, renderType }: StageRenderConfig);
682
686
  getMagicApi: () => {
683
- onPageElUpdate: (el: HTMLElement) => boolean;
687
+ id: string;
688
+ onPageElUpdate: (el: HTMLElement) => void;
684
689
  onRuntimeReady: (runtime: Runtime) => void;
685
690
  };
686
691
  add(data: UpdateData): Promise<void>;