@vvfx/sdk 0.2.1 → 0.2.2-beta.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.
Files changed (98) hide show
  1. package/dist/{src/config.d.ts → config.d.ts} +24 -1
  2. package/dist/{src/html-overlay → html-overlay}/auto-height-runtime.d.ts +5 -0
  3. package/dist/{src/html-overlay → html-overlay}/manager.d.ts +53 -0
  4. package/dist/{src/html-overlay → html-overlay}/overlay-transform.d.ts +3 -1
  5. package/dist/{src/index.d.ts → index.d.ts} +2 -2
  6. package/dist/index.js +970 -204
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +970 -204
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/layer-order.d.ts +7 -0
  11. package/dist/{src/sdk-item → sdk-item}/card-item.d.ts +2 -6
  12. package/dist/{src/sdk.d.ts → sdk.d.ts} +22 -2
  13. package/dist/{src/types.d.ts → types.d.ts} +17 -18
  14. package/dist/{src/utils → utils}/page-data-utils.d.ts +11 -0
  15. package/package.json +10 -11
  16. /package/dist/{src/exporter → exporter}/config.d.ts +0 -0
  17. /package/dist/{src/exporter → exporter}/const.d.ts +0 -0
  18. /package/dist/{src/exporter → exporter}/export-media.d.ts +0 -0
  19. /package/dist/{src/exporter → exporter}/exporter.d.ts +0 -0
  20. /package/dist/{src/exporter → exporter}/index.d.ts +0 -0
  21. /package/dist/{src/exporter → exporter}/types.d.ts +0 -0
  22. /package/dist/{src/exporter → exporter}/utils.d.ts +0 -0
  23. /package/dist/{src/exporter → exporter}/wav-audio.d.ts +0 -0
  24. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/adsorption-gizmo.d.ts +0 -0
  25. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/control-gizmo.d.ts +0 -0
  26. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/gizmo.d.ts +0 -0
  27. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/icon-gizmo.d.ts +0 -0
  28. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/index.d.ts +0 -0
  29. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/item-create-gizmo.d.ts +0 -0
  30. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/loading-gizmo.d.ts +0 -0
  31. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/mask-gizmo.d.ts +0 -0
  32. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/picture-cut-gizmo.d.ts +0 -0
  33. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/picture-expand-gizmo.d.ts +0 -0
  34. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/preference-gizmo.d.ts +0 -0
  35. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/selector-gizmo.d.ts +0 -0
  36. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/sprite-text-edit-gizmo.d.ts +0 -0
  37. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/text-gizmo.d.ts +0 -0
  38. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/transform-gizmo.d.ts +0 -0
  39. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/type.d.ts +0 -0
  40. /package/dist/{src/gesture-handler → gesture-handler}/index.d.ts +0 -0
  41. /package/dist/{src/gesture-handler → gesture-handler}/src/gesture-handler.d.ts +0 -0
  42. /package/dist/{src/gesture-handler → gesture-handler}/src/icons.d.ts +0 -0
  43. /package/dist/{src/gesture-handler → gesture-handler}/utils.d.ts +0 -0
  44. /package/dist/{src/html-overlay → html-overlay}/document-runtime.d.ts +0 -0
  45. /package/dist/{src/html-overlay → html-overlay}/document-transform.d.ts +0 -0
  46. /package/dist/{src/html-overlay → html-overlay}/dom-order.d.ts +0 -0
  47. /package/dist/{src/html-overlay → html-overlay}/host-message-runtime.d.ts +0 -0
  48. /package/dist/{src/html-overlay → html-overlay}/html-viewport-style.d.ts +0 -0
  49. /package/dist/{src/html-overlay → html-overlay}/index.d.ts +0 -0
  50. /package/dist/{src/html-overlay → html-overlay}/mime-utils.d.ts +0 -0
  51. /package/dist/{src/html-overlay → html-overlay}/path-utils.d.ts +0 -0
  52. /package/dist/{src/html-overlay → html-overlay}/shell-runtime.d.ts +0 -0
  53. /package/dist/{src/math → math}/box2.d.ts +0 -0
  54. /package/dist/{src/math → math}/circle.d.ts +0 -0
  55. /package/dist/{src/math → math}/euler.d.ts +0 -0
  56. /package/dist/{src/math → math}/index.d.ts +0 -0
  57. /package/dist/{src/math → math}/line2.d.ts +0 -0
  58. /package/dist/{src/math → math}/line3.d.ts +0 -0
  59. /package/dist/{src/math → math}/matrix4.d.ts +0 -0
  60. /package/dist/{src/math → math}/plane.d.ts +0 -0
  61. /package/dist/{src/math → math}/quaternion.d.ts +0 -0
  62. /package/dist/{src/math → math}/ray-caster.d.ts +0 -0
  63. /package/dist/{src/math → math}/ray.d.ts +0 -0
  64. /package/dist/{src/math → math}/type.d.ts +0 -0
  65. /package/dist/{src/math → math}/utils.d.ts +0 -0
  66. /package/dist/{src/math → math}/vector2.d.ts +0 -0
  67. /package/dist/{src/math → math}/vector3.d.ts +0 -0
  68. /package/dist/{src/screen-shot → screen-shot}/index.d.ts +0 -0
  69. /package/dist/{src/screen-shot → screen-shot}/screen-shot.d.ts +0 -0
  70. /package/dist/{src/sdk-item → sdk-item}/base-item.d.ts +0 -0
  71. /package/dist/{src/sdk-item → sdk-item}/effects-item.d.ts +0 -0
  72. /package/dist/{src/sdk-item → sdk-item}/frame-item.d.ts +0 -0
  73. /package/dist/{src/sdk-item → sdk-item}/generator-item.d.ts +0 -0
  74. /package/dist/{src/sdk-item → sdk-item}/group-item.d.ts +0 -0
  75. /package/dist/{src/sdk-item → sdk-item}/index.d.ts +0 -0
  76. /package/dist/{src/sdk-item → sdk-item}/sprite-item.d.ts +0 -0
  77. /package/dist/{src/sdk-item → sdk-item}/text-item.d.ts +0 -0
  78. /package/dist/{src/sdk-item → sdk-item}/types.d.ts +0 -0
  79. /package/dist/{src/sdk-item → sdk-item}/video-item.d.ts +0 -0
  80. /package/dist/{src/service → service}/UndoRedo.d.ts +0 -0
  81. /package/dist/{src/shared → shared}/index.d.ts +0 -0
  82. /package/dist/{src/shared → shared}/player.d.ts +0 -0
  83. /package/dist/{src/size-adapte → size-adapte}/index.d.ts +0 -0
  84. /package/dist/{src/size-adapte → size-adapte}/size-adapt.d.ts +0 -0
  85. /package/dist/{src/utils → utils}/background-manager.d.ts +0 -0
  86. /package/dist/{src/utils → utils}/common-utils.d.ts +0 -0
  87. /package/dist/{src/utils → utils}/index.d.ts +0 -0
  88. /package/dist/{src/utils → utils}/interaction-utils.d.ts +0 -0
  89. /package/dist/{src/utils → utils}/json-data-utils.d.ts +0 -0
  90. /package/dist/{src/utils → utils}/layout-utils.d.ts +0 -0
  91. /package/dist/{src/utils → utils}/player-data-utils.d.ts +0 -0
  92. /package/dist/{src/utils → utils}/types.d.ts +0 -0
  93. /package/dist/{src/wireframe → wireframe}/common/box.d.ts +0 -0
  94. /package/dist/{src/wireframe → wireframe}/common/dashed-line.d.ts +0 -0
  95. /package/dist/{src/wireframe → wireframe}/common/line.d.ts +0 -0
  96. /package/dist/{src/wireframe → wireframe}/common/pixi-ext.d.ts +0 -0
  97. /package/dist/{src/wireframe → wireframe}/common/pixi.d.ts +0 -0
  98. /package/dist/{src/wireframe → wireframe}/index.d.ts +0 -0
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: TODO
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 赤芍,何即,不择,意绮
6
- * Version: v0.2.1
6
+ * Version: v0.2.2-beta.11
7
7
  */
8
8
 
9
9
  'use strict';
@@ -47173,7 +47173,7 @@ var SelectorGizmo = /*#__PURE__*/ function(Gizmo) {
47173
47173
  var preSelectedItem = this.pageDataUtils.getPreSelectedItem();
47174
47174
  var preSelectedItemBox = this.pageDataUtils.getViewBoxById((_ref = preSelectedItem == null ? void 0 : preSelectedItem.id) != null ? _ref : '');
47175
47175
  var _SDK_config_gestureHandlerConfig_selectorGizmoConfig = SDK.config.gestureHandlerConfig.selectorGizmoConfig, regionBoxColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.regionBoxColor, regionBoxAlpha = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.regionBoxAlpha, preSelectedWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedWidth, preSelectedColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedColor, regionWireframeWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.regionWireframeWidth, regionWireframeColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.regionWireframeColor, regionWireframeAlpha = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.regionWireframeAlpha;
47176
- if (!(preSelectedItemBox == null ? void 0 : preSelectedItemBox.isEmpty())) {
47176
+ if (!(preSelectedItemBox == null ? void 0 : preSelectedItemBox.isEmpty()) && !isCardItem(preSelectedItem)) {
47177
47177
  this.graphics.lineStyle(preSelectedWidth, preSelectedColor);
47178
47178
  this.graphics.drawBox(preSelectedItemBox);
47179
47179
  }
@@ -55359,7 +55359,9 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55359
55359
  return;
55360
55360
  }
55361
55361
  var selectedItem = (_selectedItems_ = selectedItems[0]) != null ? _selectedItems_ : undefined;
55362
- var isShfitLockScale = selectedItem && selectedItems.length === 1 && isFrameItem(selectedItem) ? !this.isShiftDown : this.isShiftDown;
55362
+ // html卡片内容在非自动缩放的情况下,拖动的时候内容自适应,因此与智能画板一样,需要默认是自由缩放(即自由改大小)
55363
+ var isAutoFitContentCardItem = selectedItem && isCardItem(selectedItem) && !selectedItem.isAutoScale;
55364
+ var isShiftLockScale = selectedItem && selectedItems.length === 1 && (isFrameItem(selectedItem) || isAutoFitContentCardItem) ? !this.isShiftDown : this.isShiftDown;
55363
55365
  var farthestCorner = this.scaleParam.farthestCorner;
55364
55366
  var isValidScale = (scaleCorner.x - farthestCorner.x) * (this.cursorPoint.x - farthestCorner.x) > 0 && (scaleCorner.y - farthestCorner.y) * (this.cursorPoint.y - farthestCorner.y) > 0;
55365
55367
  if (!isValidScale && this.isLockScale && !this.isShiftDown) {
@@ -55376,7 +55378,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55376
55378
  var currentStartScale = startScale.clone().multiply(lastScalar);
55377
55379
  var currentScale = worldPosition1.clone().subtract(cornerShift).subtract(center1).applyMatrix(rotationMatrix);
55378
55380
  var scalar = new Vector3(1, 1, 1);
55379
- if (!this.isLockScale || isShfitLockScale) {
55381
+ if (!this.isLockScale || isShiftLockScale) {
55380
55382
  scalar.x = isEqual$1(currentStartScale.x, 0) ? 1 : currentScale.x / currentStartScale.x;
55381
55383
  scalar.y = isEqual$1(currentStartScale.y, 0) ? 1 : currentScale.y / currentStartScale.y;
55382
55384
  scalar.z = isEqual$1(currentStartScale.z, 0) ? 1 : currentScale.z / currentStartScale.z;
@@ -55433,6 +55435,33 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55433
55435
  newWidth,
55434
55436
  newHeight
55435
55437
  ], translation1);
55438
+ } else if (isAutoFitContentCardItem) {
55439
+ var currentWidth1 = selectedItem.pixelWidth;
55440
+ var currentHeight1 = selectedItem.pixelHeight;
55441
+ var newWidth1 = currentWidth1 * resultScalar1.x;
55442
+ var newHeight1 = currentHeight1 * resultScalar1.y;
55443
+ this._pageDataUtils.resizeCardItem(selectedItem.id, [
55444
+ newWidth1,
55445
+ newHeight1
55446
+ ], translation1);
55447
+ void this._pageDataUtils.setItemProperty({
55448
+ itemId: selectedItem.id,
55449
+ type: SDKItemType.CARD,
55450
+ property: {
55451
+ width: newWidth1,
55452
+ height: newHeight1
55453
+ }
55454
+ });
55455
+ } else if (selectedItem && selectedItems.length === 1 && isCardItem(selectedItem)) {
55456
+ void this._pageDataUtils.setItemProperty({
55457
+ itemId: selectedItem.id,
55458
+ type: SDKItemType.CARD,
55459
+ property: {
55460
+ width: selectedItem.width * resultScalar1.x,
55461
+ height: selectedItem.height * resultScalar1.y
55462
+ }
55463
+ });
55464
+ this._pageDataUtils.moveItem(selectedItem.id, translation1);
55436
55465
  } else {
55437
55466
  // 普通元素的缩放逻辑
55438
55467
  selectedItems.forEach(function(item) {
@@ -55757,6 +55786,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55757
55786
  var selectedItems = this._pageDataUtils.getSelectedItems();
55758
55787
  var isTemplateMode = SDK.config.mode === 'template';
55759
55788
  var selectedItem = selectedItems.length === 1 ? selectedItems[0] : undefined;
55789
+ var isSingleCardItem = isCardItem(selectedItem);
55760
55790
  var isGeneratorItem = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.GENERATOR;
55761
55791
  var isAutoLayoutFrame = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.FRAME && (selectedItem == null ? void 0 : selectedItem.layoutMode) === FrameLayoutMode.AUTO;
55762
55792
  var canScale = selectedItems.length === 1 && (selectedItem == null ? void 0 : selectedItem.type) !== SDKItemType.GROUP && !isAutoLayoutFrame && !isGeneratorItem;
@@ -55796,9 +55826,11 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55796
55826
  this.wireframe.totalBox.copyFrom(box).expandByScalar(totalBoxExpandScalar);
55797
55827
  // 根据box获取边缘线
55798
55828
  var corners = this.wireframe.box.corners;
55799
- corners.forEach(function(corner, i) {
55800
- _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55801
- });
55829
+ if (!isSingleCardItem) {
55830
+ corners.forEach(function(corner, i) {
55831
+ _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55832
+ });
55833
+ }
55802
55834
  var _SDK_config_gestureHandlerConfig_transformGizmoConfig = SDK.config.gestureHandlerConfig.transformGizmoConfig, scaleCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.scaleCircleSize, rotationCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.rotationCircleSize;
55803
55835
  // 成组暂不支持缩放
55804
55836
  if (selectedItems.length === 1) {
@@ -59649,12 +59681,6 @@ var MAX_ITEM_DISTANCE_THRESHOLD = 100000;
59649
59681
  /**
59650
59682
  * @description SDKItem position 属性的数字精度(保留小数位数)
59651
59683
  */ var POSITION_PRECISION = 4;
59652
- function isCardHTMLContentValue(value) {
59653
- return (value == null ? void 0 : value.kind) === 'inline' || (value == null ? void 0 : value.kind) === 'dom' || (value == null ? void 0 : value.kind) === 'document';
59654
- }
59655
- function isCardHTMLValue(value) {
59656
- return isCardHTMLContentValue(value == null ? void 0 : value.content);
59657
- }
59658
59684
  var PageDataUtils = /*#__PURE__*/ function() {
59659
59685
  function PageDataUtils(player, container, emitter, sdk) {
59660
59686
  this.player = player;
@@ -60472,11 +60498,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
60472
60498
  property: property
60473
60499
  }));
60474
60500
  } else if ((existingSDKItem == null ? void 0 : existingSDKItem.type) == SDKItemType.CARD) {
60475
- var cardType = existingSDKItem.cardType, html = existingSDKItem.html;
60501
+ var cardType = existingSDKItem.cardType;
60476
60502
  sdkItem = new CardItem(_extends({}, baseOptions, {
60477
60503
  property: _extends({}, property, {
60478
- cardType: cardType,
60479
- html: html
60504
+ cardType: cardType
60480
60505
  })
60481
60506
  }));
60482
60507
  } else {
@@ -60703,6 +60728,19 @@ var PageDataUtils = /*#__PURE__*/ function() {
60703
60728
  }).call(this);
60704
60729
  };
60705
60730
  /**
60731
+ * @description 设置元素extension字段
60732
+ */ _proto.setItemExtension = function setItemExtension(itemId, extension) {
60733
+ var item = this.getSDKItem(itemId);
60734
+ if (!item) {
60735
+ console.warn('setItemExtension: item not found');
60736
+ return;
60737
+ }
60738
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.entries(extension)), _step; !(_step = _iterator()).done;){
60739
+ var _step_value = _step.value, key = _step_value[0], value = _step_value[1];
60740
+ item.extension.set(key, value);
60741
+ }
60742
+ };
60743
+ /**
60706
60744
  * @description 场景 1: 设置单个元素的单个属性
60707
60745
  */ _proto.setSingleItemSingleProperty = function setSingleItemSingleProperty(param) {
60708
60746
  return _async_to_generator(function() {
@@ -61060,40 +61098,35 @@ var PageDataUtils = /*#__PURE__*/ function() {
61060
61098
  3,
61061
61099
  31
61062
61100
  ];
61063
- case 'html':
61064
- return [
61065
- 3,
61066
- 32
61067
- ];
61068
61101
  case 'position':
61069
61102
  return [
61070
61103
  3,
61071
- 33
61104
+ 32
61072
61105
  ];
61073
61106
  case 'rotation':
61074
61107
  return [
61075
61108
  3,
61076
- 34
61109
+ 33
61077
61110
  ];
61078
61111
  case 'scale':
61079
61112
  return [
61080
61113
  3,
61081
- 35
61114
+ 34
61082
61115
  ];
61083
61116
  case 'layoutMode':
61084
61117
  return [
61085
61118
  3,
61086
- 36
61119
+ 35
61087
61120
  ];
61088
61121
  case 'visible':
61089
61122
  return [
61090
61123
  3,
61091
- 37
61124
+ 36
61092
61125
  ];
61093
61126
  }
61094
61127
  return [
61095
61128
  3,
61096
- 38
61129
+ 37
61097
61130
  ];
61098
61131
  case 1:
61099
61132
  {
@@ -61106,7 +61139,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61106
61139
  }
61107
61140
  return [
61108
61141
  3,
61109
- 39
61142
+ 38
61110
61143
  ];
61111
61144
  }
61112
61145
  case 2:
@@ -61117,7 +61150,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61117
61150
  }
61118
61151
  return [
61119
61152
  3,
61120
- 39
61153
+ 38
61121
61154
  ];
61122
61155
  }
61123
61156
  case 3:
@@ -61149,7 +61182,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61149
61182
  case 5:
61150
61183
  return [
61151
61184
  3,
61152
- 39
61185
+ 38
61153
61186
  ];
61154
61187
  case 6:
61155
61188
  {
@@ -61166,7 +61199,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61166
61199
  }
61167
61200
  return [
61168
61201
  3,
61169
- 39
61202
+ 38
61170
61203
  ];
61171
61204
  }
61172
61205
  case 7:
@@ -61180,7 +61213,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61180
61213
  }
61181
61214
  return [
61182
61215
  3,
61183
- 39
61216
+ 38
61184
61217
  ];
61185
61218
  }
61186
61219
  case 8:
@@ -61193,7 +61226,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61193
61226
  }
61194
61227
  return [
61195
61228
  3,
61196
- 39
61229
+ 38
61197
61230
  ];
61198
61231
  }
61199
61232
  case 9:
@@ -61207,7 +61240,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61207
61240
  }
61208
61241
  return [
61209
61242
  3,
61210
- 39
61243
+ 38
61211
61244
  ];
61212
61245
  }
61213
61246
  case 10:
@@ -61220,7 +61253,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61220
61253
  }
61221
61254
  return [
61222
61255
  3,
61223
- 39
61256
+ 38
61224
61257
  ];
61225
61258
  }
61226
61259
  case 11:
@@ -61233,7 +61266,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61233
61266
  }
61234
61267
  return [
61235
61268
  3,
61236
- 39
61269
+ 38
61237
61270
  ];
61238
61271
  }
61239
61272
  case 12:
@@ -61253,7 +61286,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61253
61286
  }
61254
61287
  return [
61255
61288
  3,
61256
- 39
61289
+ 38
61257
61290
  ];
61258
61291
  }
61259
61292
  case 13:
@@ -61295,7 +61328,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61295
61328
  }
61296
61329
  return [
61297
61330
  3,
61298
- 39
61331
+ 38
61299
61332
  ];
61300
61333
  }
61301
61334
  case 14:
@@ -61330,7 +61363,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61330
61363
  }
61331
61364
  return [
61332
61365
  3,
61333
- 39
61366
+ 38
61334
61367
  ];
61335
61368
  }
61336
61369
  case 15:
@@ -61344,7 +61377,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61344
61377
  }
61345
61378
  return [
61346
61379
  3,
61347
- 39
61380
+ 38
61348
61381
  ];
61349
61382
  }
61350
61383
  case 16:
@@ -61376,7 +61409,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61376
61409
  case 20:
61377
61410
  return [
61378
61411
  3,
61379
- 39
61412
+ 38
61380
61413
  ];
61381
61414
  case 21:
61382
61415
  if (!(typeof propertyValue === 'string' && playerItem.type === EFFECTS.spec.ItemType.video)) return [
@@ -61407,7 +61440,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61407
61440
  case 25:
61408
61441
  return [
61409
61442
  3,
61410
- 39
61443
+ 38
61411
61444
  ];
61412
61445
  case 26:
61413
61446
  if (!(playerItem.type === EFFECTS.spec.ItemType.null)) return [
@@ -61452,7 +61485,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61452
61485
  case 28:
61453
61486
  return [
61454
61487
  3,
61455
- 39
61488
+ 38
61456
61489
  ];
61457
61490
  case 29:
61458
61491
  {
@@ -61464,7 +61497,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61464
61497
  }
61465
61498
  return [
61466
61499
  3,
61467
- 39
61500
+ 38
61468
61501
  ];
61469
61502
  }
61470
61503
  case 30:
@@ -61477,7 +61510,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61477
61510
  }
61478
61511
  return [
61479
61512
  3,
61480
- 39
61513
+ 38
61481
61514
  ];
61482
61515
  }
61483
61516
  case 31:
@@ -61490,20 +61523,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61490
61523
  }
61491
61524
  return [
61492
61525
  3,
61493
- 39
61526
+ 38
61494
61527
  ];
61495
61528
  }
61496
61529
  case 32:
61497
- {
61498
- if (isCardItem(targetItem)) {
61499
- targetItem.html = isCardHTMLValue(propertyValue) ? propertyValue : undefined;
61500
- }
61501
- return [
61502
- 3,
61503
- 39
61504
- ];
61505
- }
61506
- case 33:
61507
61530
  {
61508
61531
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61509
61532
  pixelTranslation = propertyValue.map(function(v, i) {
@@ -61516,10 +61539,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61516
61539
  }
61517
61540
  return [
61518
61541
  3,
61519
- 39
61542
+ 38
61520
61543
  ];
61521
61544
  }
61522
- case 34:
61545
+ case 33:
61523
61546
  {
61524
61547
  if (Array.isArray(propertyValue) && propertyValue.length === 3) {
61525
61548
  rotation = propertyValue.map(function(v, i) {
@@ -61530,10 +61553,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61530
61553
  }
61531
61554
  return [
61532
61555
  3,
61533
- 39
61556
+ 38
61534
61557
  ];
61535
61558
  }
61536
- case 35:
61559
+ case 34:
61537
61560
  {
61538
61561
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61539
61562
  currentScale = targetItem.property.scale;
@@ -61547,10 +61570,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61547
61570
  }
61548
61571
  return [
61549
61572
  3,
61550
- 39
61573
+ 38
61551
61574
  ];
61552
61575
  }
61553
- case 36:
61576
+ case 35:
61554
61577
  {
61555
61578
  if (propertyValue === FrameLayoutMode.AUTO || propertyValue === FrameLayoutMode.FREE) {
61556
61579
  frameComponent = playerItem.getComponent(EFFECTS.FrameComponent);
@@ -61560,10 +61583,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61560
61583
  }
61561
61584
  return [
61562
61585
  3,
61563
- 39
61586
+ 38
61564
61587
  ];
61565
61588
  }
61566
- case 37:
61589
+ case 36:
61567
61590
  {
61568
61591
  if (typeof propertyValue === 'boolean') {
61569
61592
  playerItem.setVisible(propertyValue);
@@ -61576,10 +61599,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61576
61599
  }
61577
61600
  return [
61578
61601
  3,
61579
- 39
61602
+ 38
61580
61603
  ];
61581
61604
  }
61582
- case 38:
61605
+ case 37:
61583
61606
  {
61584
61607
  console.log('ignore property name ', propertyName);
61585
61608
  // 对于未明确处理的属性,尝试直接设置到 property 对象
@@ -61587,8 +61610,8 @@ var PageDataUtils = /*#__PURE__*/ function() {
61587
61610
  targetItem.property[propertyName] = propertyValue;
61588
61611
  }
61589
61612
  }
61590
- _state.label = 39;
61591
- case 39:
61613
+ _state.label = 38;
61614
+ case 38:
61592
61615
  // 非位置属性需要刷新播放器
61593
61616
  // template 模式下保持暂停态以避免播放器自动播放,editor 模式继续推进
61594
61617
  if (![
@@ -62468,6 +62491,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
62468
62491
  }
62469
62492
  break;
62470
62493
  }
62494
+ case 'cardType':
62495
+ {
62496
+ break;
62497
+ }
62471
62498
  default:
62472
62499
  {
62473
62500
  console.warn("Target property " + propertyName + " can not be changed.");
@@ -63060,12 +63087,15 @@ var PageDataUtils = /*#__PURE__*/ function() {
63060
63087
  var _cardInfo_name = cardInfo.name, name = _cardInfo_name === void 0 ? '卡片' : _cardInfo_name, _cardInfo_property = cardInfo.property, width = _cardInfo_property.width, height = _cardInfo_property.height, _cardInfo_property_scale = _cardInfo_property.scale, scale = _cardInfo_property_scale === void 0 ? [
63061
63088
  1,
63062
63089
  1
63063
- ] : _cardInfo_property_scale, cardType = _cardInfo_property.cardType, tmp = _cardInfo_property.rotation, sourceRotation = tmp === void 0 ? 0 : tmp, sourcePosition = _cardInfo_property.position, autoHeight = _cardInfo_property.autoHeight, html = _cardInfo_property.html, parentId = cardInfo.parentId, _cardInfo_id = cardInfo.id, id = _cardInfo_id === void 0 ? EFFECTS.generateGUID() : _cardInfo_id, extension = cardInfo.extension;
63090
+ ] : _cardInfo_property_scale, cardType = _cardInfo_property.cardType, tmp = _cardInfo_property.rotation, sourceRotation = tmp === void 0 ? 0 : tmp, sourcePosition = _cardInfo_property.position, parentId = cardInfo.parentId, _cardInfo_id = cardInfo.id, id = _cardInfo_id === void 0 ? EFFECTS.generateGUID() : _cardInfo_id, extension = cardInfo.extension;
63064
63091
  // 校验 cardType 是否已在配置中注册
63092
+ var cardTypeConfig = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
63093
+ return t.type === cardType;
63094
+ });
63065
63095
  var registeredTypes = SDK.config.itemConfig.cardConfig.cardTypes.map(function(t) {
63066
63096
  return t.type;
63067
63097
  });
63068
- if (!registeredTypes.includes(cardType)) {
63098
+ if (!cardTypeConfig) {
63069
63099
  console.warn('CardItem cardType "' + cardType + '" is not registered. Registered types: ' + registeredTypes.join(', '));
63070
63100
  return;
63071
63101
  }
@@ -63109,9 +63139,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
63109
63139
  width: width,
63110
63140
  height: height,
63111
63141
  scale: [].concat(scale),
63112
- cardType: cardType,
63113
- autoHeight: autoHeight,
63114
- html: html
63142
+ cardType: cardType
63115
63143
  },
63116
63144
  extension: extension
63117
63145
  });
@@ -64493,8 +64521,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
64493
64521
  scalar.y
64494
64522
  ],
64495
64523
  rotation: [].concat(rotation),
64496
- position: [].concat(resultPosition),
64497
- html: sdkItem.html
64524
+ position: [].concat(resultPosition)
64498
64525
  },
64499
64526
  extension: extension
64500
64527
  };
@@ -65540,7 +65567,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
65540
65567
  _this = this;
65541
65568
  changeProeprty = function changeProeprty(targetCreateInfo) {
65542
65569
  return _async_to_generator(function() {
65543
- var currentCreateInfo;
65570
+ var currentCreateInfo, itemId;
65544
65571
  return _ts_generator(this, function(_state) {
65545
65572
  switch(_state.label){
65546
65573
  case 0:
@@ -65551,16 +65578,20 @@ var PageDataUtils = /*#__PURE__*/ function() {
65551
65578
  2
65552
65579
  ];
65553
65580
  }
65581
+ itemId = targetCreateInfo.id;
65554
65582
  return [
65555
65583
  4,
65556
65584
  this.setItemProperty({
65557
- itemId: currentCreateInfo.id,
65585
+ itemId: itemId,
65558
65586
  type: currentCreateInfo.type,
65559
65587
  property: targetCreateInfo.property
65560
65588
  })
65561
65589
  ];
65562
65590
  case 1:
65563
65591
  _state.sent();
65592
+ if (targetCreateInfo.extension) {
65593
+ this.setItemExtension(itemId, targetCreateInfo.extension);
65594
+ }
65564
65595
  return [
65565
65596
  2
65566
65597
  ];
@@ -65878,35 +65909,56 @@ var PageDataUtils = /*#__PURE__*/ function() {
65878
65909
  };
65879
65910
  _proto.asyncAddItemByCreateInfos = function asyncAddItemByCreateInfos(createInfos) {
65880
65911
  return _async_to_generator(function() {
65881
- var _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, createInfo, id, type, url, textureId, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65912
+ var _loop, _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65882
65913
  return _ts_generator(this, function(_state) {
65883
65914
  switch(_state.label){
65884
65915
  case 0:
65885
- _this = this;
65886
- createInfoWithIds = createInfos.map(function(createInfo) {
65887
- return Object.assign({}, createInfo, createInfo.id ? {} : {
65888
- id: EFFECTS.generateGUID()
65889
- });
65890
- });
65891
- itemToTextureInfo = new Map();
65892
- // 预处理所有 createInfo,分配 textureId
65893
- for(_iterator = _create_for_of_iterator_helper_loose(createInfoWithIds); !(_step = _iterator()).done;){
65894
- createInfo = _step.value;
65895
- id = createInfo.id;
65896
- type = createInfo.type;
65897
- url = type === SDKItemType.SPRITE ? createInfo.property.image : type === SDKItemType.VIDEO ? createInfo.property.video : undefined;
65898
- if ((type === SDKItemType.SPRITE || type === SDKItemType.VIDEO) && url) {
65899
- textureId = EFFECTS.generateGUID();
65900
- itemToTextureInfo.set(id, {
65916
+ _loop = function() {
65917
+ var createInfo = _step.value;
65918
+ var _ref = function() {
65919
+ switch(createInfo.type){
65920
+ case SDKItemType.SPRITE:
65921
+ {
65922
+ return {
65923
+ url: createInfo.property.image,
65924
+ type: 'image'
65925
+ };
65926
+ }
65927
+ case SDKItemType.VIDEO:
65928
+ {
65929
+ return {
65930
+ url: createInfo.property.video,
65931
+ type: 'video'
65932
+ };
65933
+ }
65934
+ default:
65935
+ {
65936
+ return {};
65937
+ }
65938
+ }
65939
+ }(), url = _ref.url, type = _ref.type;
65940
+ if (url && type) {
65941
+ var textureId = EFFECTS.generateGUID();
65942
+ itemToTextureInfo.set(createInfo.id, {
65901
65943
  id: textureId,
65902
65944
  url: url,
65903
- type: type === SDKItemType.SPRITE ? 'image' : 'video'
65945
+ type: type
65904
65946
  });
65905
65947
  Object.assign(createInfo, {
65906
65948
  textureId: textureId
65907
65949
  });
65908
65950
  }
65909
- }
65951
+ };
65952
+ _this = this;
65953
+ createInfoWithIds = createInfos.map(function(createInfo) {
65954
+ var _createInfo_id;
65955
+ return Object.assign({}, createInfo, {
65956
+ id: (_createInfo_id = createInfo.id) != null ? _createInfo_id : EFFECTS.generateGUID()
65957
+ });
65958
+ });
65959
+ itemToTextureInfo = new Map();
65960
+ // 预处理所有 createInfo,分配 textureId
65961
+ for(_iterator = _create_for_of_iterator_helper_loose(createInfoWithIds); !(_step = _iterator()).done;)_loop();
65910
65962
  // 并行创建所有 item
65911
65963
  toAddedCreateInfo = createInfoWithIds.filter(function(createInfo) {
65912
65964
  return ![
@@ -66875,6 +66927,51 @@ var PageDataUtils = /*#__PURE__*/ function() {
66875
66927
  * @param id 元素id
66876
66928
  * @param size 目标大小 [width, height]
66877
66929
  * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66930
+ */ _proto.resizeCardItem = function resizeCardItem(id, size, translation) {
66931
+ var _frameController_children;
66932
+ var frameItem = this.getSDKItem(id);
66933
+ if (!frameItem) {
66934
+ return;
66935
+ }
66936
+ var newWidth = size[0], newHeight = size[1];
66937
+ // const originalWidth = frameItem.property.width
66938
+ // 计算世界尺寸(供后续使用)
66939
+ var viewSize = this.interactionUtils.getViewSizeByPixelSize(new Vector2(newWidth, newHeight));
66940
+ var worldSize = this.interactionUtils.getWorldSizeByViewSize(viewSize).abs();
66941
+ // 1 更新 Player 层的预合成和子元素
66942
+ // 1.1 更新 Player Item(空节点控制器)的大小
66943
+ var frameController = this.getPlayerItemById(id);
66944
+ if (frameController) {
66945
+ frameController.transform.setSize(worldSize.x, worldSize.y);
66946
+ // 如果有位移,更新位置
66947
+ if (translation && (translation.x !== 0 || translation.y !== 0)) {
66948
+ var currentPosition = frameController.transform.position;
66949
+ frameController.setPosition(currentPosition.x + translation.x, currentPosition.y + translation.y, currentPosition.z);
66950
+ }
66951
+ }
66952
+ // 1.2 更新 Player Children Item 的大小
66953
+ var subCompositionItem = frameController == null ? void 0 : (_frameController_children = frameController.children) == null ? void 0 : _frameController_children[0];
66954
+ if (subCompositionItem && translation) {
66955
+ // 更新子元素
66956
+ subCompositionItem.children.forEach(function(item) {
66957
+ var _item;
66958
+ var _item_transform_getParentMatrix;
66959
+ var parentMatrix = new Matrix4().copyFrom((_item_transform_getParentMatrix = item.transform.getParentMatrix()) != null ? _item_transform_getParentMatrix : new Matrix4());
66960
+ parentMatrix.setPosition(new Vector3());
66961
+ var result = translation.clone().applyMatrix(parentMatrix.invert()).negate();
66962
+ (_item = item).translate.apply(_item, [].concat(result.toArray()));
66963
+ item.transform.updateLocalMatrix();
66964
+ });
66965
+ }
66966
+ // 2: 刷新 SDKItem 数据
66967
+ // 更新 FrameItem 的 property
66968
+ this.refreshSDKItem(frameItem.id);
66969
+ };
66970
+ /**
66971
+ * @description 修改画板元素大小
66972
+ * @param id 元素id
66973
+ * @param size 目标大小 [width, height]
66974
+ * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66878
66975
  */ _proto.resizeFrameItem = function resizeFrameItem(id, size, translation) {
66879
66976
  var _this = this;
66880
66977
  var _frameController_children;
@@ -83079,43 +83176,12 @@ var BaseConfig = {
83079
83176
  },
83080
83177
  cardConfig: {
83081
83178
  backgroundColor: [
83082
- 0.6,
83083
- 0.6,
83084
- 0.6,
83085
- 0.12
83179
+ 1,
83180
+ 1,
83181
+ 1,
83182
+ 0
83086
83183
  ],
83087
- cardTypes: [
83088
- {
83089
- type: 'character',
83090
- label: '角色图',
83091
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83092
- },
83093
- {
83094
- type: 'environment',
83095
- label: '环境图',
83096
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83097
- },
83098
- {
83099
- type: 'storyboard',
83100
- label: '分镜图',
83101
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83102
- },
83103
- {
83104
- type: 'scene-clip',
83105
- label: '场景剪辑',
83106
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83107
- },
83108
- {
83109
- type: 'video-compose',
83110
- label: '视频合成',
83111
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83112
- },
83113
- {
83114
- type: 'video-generate',
83115
- label: '生成视频',
83116
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83117
- }
83118
- ]
83184
+ cardTypes: []
83119
83185
  }
83120
83186
  }
83121
83187
  };
@@ -91444,11 +91510,18 @@ function isCardHTMLAutoHeightMessage(data, id) {
91444
91510
  var message = data;
91445
91511
  return message.source === 'vvfx-card-html-auto-height' && message.id === id && typeof message.height === 'number';
91446
91512
  }
91513
+ function requestCardHTMLAutoHeight(iframe, id) {
91514
+ var _iframe_contentWindow;
91515
+ (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage({
91516
+ source: 'vvfx-card-html-auto-height-request',
91517
+ id: id
91518
+ }, '*');
91519
+ }
91447
91520
  function withCardHTMLAutoHeightBridge(html, id) {
91448
91521
  if (!id) {
91449
91522
  return html;
91450
91523
  }
91451
- var script = "\n<script data-vvfx-card-html-auto-height>\n(() => {\n const id = " + JSON.stringify(id) + ";\n let frame = 0;\n const getChildrenHeight = (element) => {\n if (!element) return 0;\n return Array.from(element.children).reduce((height, child) => {\n const rect = child.getBoundingClientRect();\n return Math.max(height, rect.bottom + window.scrollY);\n }, 0);\n };\n const getHeight = () => {\n const body = document.body;\n const root = document.documentElement;\n const childHeight = getChildrenHeight(body);\n const scrollHeight = Math.max(root.scrollHeight, body ? body.scrollHeight : 0);\n return Math.ceil(Math.max(childHeight, scrollHeight));\n };\n const postHeight = () => {\n frame = 0;\n window.parent.postMessage({\n source: 'vvfx-card-html-auto-height',\n id,\n height: getHeight(),\n }, '*');\n };\n const schedule = () => {\n if (frame) return;\n frame = requestAnimationFrame(postHeight);\n };\n window.addEventListener('load', schedule);\n window.addEventListener('resize', schedule);\n new ResizeObserver(schedule).observe(document.documentElement);\n if (document.body) {\n new ResizeObserver(schedule).observe(document.body);\n new MutationObserver(schedule).observe(document.body, {\n attributes: true,\n childList: true,\n subtree: true,\n characterData: true,\n });\n }\n schedule();\n})();\n</script>";
91524
+ var script = "\n<script data-vvfx-card-html-auto-height>\n(() => {\n const id = " + JSON.stringify(id) + ";\n let frame = 0;\n const getNodeHeight = (node) => {\n if (node.nodeType === Node.ELEMENT_NODE) {\n const rect = node.getBoundingClientRect();\n return rect.bottom + window.scrollY;\n }\n if (node.nodeType === Node.TEXT_NODE && node.textContent.trim()) {\n const range = document.createRange();\n range.selectNodeContents(node);\n const rects = Array.from(range.getClientRects());\n range.detach();\n return rects.reduce((height, rect) => Math.max(height, rect.bottom + window.scrollY), 0);\n }\n\n return 0;\n };\n const getContentHeight = (element) => {\n if (!element) return 0;\n return Array.from(element.childNodes).reduce((height, child) => {\n return Math.max(height, getNodeHeight(child));\n }, 0);\n };\n const getHeight = () => {\n const body = document.body;\n const root = document.documentElement;\n const contentHeight = getContentHeight(body);\n const scrollHeight = Math.max(root.scrollHeight, body ? body.scrollHeight : 0);\n return Math.ceil(contentHeight > 0 ? contentHeight : scrollHeight);\n };\n const postHeight = () => {\n frame = 0;\n window.parent.postMessage({\n source: 'vvfx-card-html-auto-height',\n id,\n height: getHeight(),\n }, '*');\n };\n const schedule = () => {\n if (frame) return;\n frame = requestAnimationFrame(postHeight);\n };\n window.addEventListener('message', (event) => {\n const message = event.data;\n if (!message || message.source !== 'vvfx-card-html-auto-height-request' || message.id !== id) {\n return;\n }\n\n schedule();\n });\n window.addEventListener('load', schedule);\n window.addEventListener('resize', schedule);\n new ResizeObserver(schedule).observe(document.documentElement);\n if (document.body) {\n new ResizeObserver(schedule).observe(document.body);\n new MutationObserver(schedule).observe(document.body, {\n attributes: true,\n childList: true,\n subtree: true,\n characterData: true,\n });\n }\n schedule();\n})();\n</script>";
91452
91525
  if (/<\/body>/i.test(html)) {
91453
91526
  return html.replace(/<\/body>/i, "" + script + "</body>");
91454
91527
  }
@@ -91721,30 +91794,38 @@ function syncElementStackOrder(_container, elements) {
91721
91794
  });
91722
91795
  }
91723
91796
 
91724
- function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY) {
91797
+ function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, _autoScale) {
91725
91798
  if (offsetX === void 0) offsetX = 0;
91726
91799
  if (offsetY === void 0) offsetY = 0;
91727
91800
  if (box.corners.length === 4 && width > 0 && height > 0) {
91728
91801
  var _box_corners = box.corners, rightTop = _box_corners[0], leftBottom = _box_corners[2], leftTop = _box_corners[3];
91729
- var a = (rightTop.x - leftTop.x) / width;
91730
- var b = (rightTop.y - leftTop.y) / width;
91731
- var c = (leftBottom.x - leftTop.x) / height;
91732
- var d = (leftBottom.y - leftTop.y) / height;
91802
+ var contentWidth = width;
91803
+ var contentHeight = height;
91804
+ var a = (rightTop.x - leftTop.x) / contentWidth;
91805
+ var b = (rightTop.y - leftTop.y) / contentWidth;
91806
+ var c = (leftBottom.x - leftTop.x) / contentHeight;
91807
+ var d = (leftBottom.y - leftTop.y) / contentHeight;
91733
91808
  var e = leftTop.x - offsetX;
91734
91809
  var f = leftTop.y - offsetY;
91735
91810
  return {
91736
91811
  left: '0px',
91737
91812
  top: '0px',
91738
- width: "" + width + "px",
91739
- height: "" + height + "px",
91813
+ width: "" + formatPixelNumber(contentWidth) + "px",
91814
+ height: "" + formatPixelNumber(contentHeight) + "px",
91815
+ contentWidth: contentWidth,
91816
+ contentHeight: contentHeight,
91740
91817
  transform: "matrix(" + formatMatrixNumber(a) + ", " + formatMatrixNumber(b) + ", " + formatMatrixNumber(c) + ", " + formatMatrixNumber(d) + ", " + formatMatrixNumber(e) + ", " + formatMatrixNumber(f) + ")"
91741
91818
  };
91742
91819
  }
91820
+ var contentWidth1 = box.max.x - box.min.x;
91821
+ var contentHeight1 = box.max.y - box.min.y;
91743
91822
  return {
91744
91823
  left: "" + (box.min.x - offsetX) + "px",
91745
91824
  top: "" + (box.min.y - offsetY) + "px",
91746
- width: "" + (box.max.x - box.min.x) + "px",
91747
- height: "" + (box.max.y - box.min.y) + "px",
91825
+ width: "" + contentWidth1 + "px",
91826
+ height: "" + contentHeight1 + "px",
91827
+ contentWidth: contentWidth1,
91828
+ contentHeight: contentHeight1,
91748
91829
  transform: ''
91749
91830
  };
91750
91831
  }
@@ -91767,6 +91848,10 @@ function formatMatrixNumber(value) {
91767
91848
  var normalized = Object.is(value, -0) ? 0 : value;
91768
91849
  return Number(normalized.toFixed(6)).toString();
91769
91850
  }
91851
+ function formatPixelNumber(value) {
91852
+ var normalized = Object.is(value, -0) ? 0 : value;
91853
+ return Number(normalized.toFixed(6)).toString();
91854
+ }
91770
91855
 
91771
91856
  function mountHTMLShell(container, content, shell) {
91772
91857
  if (!shell) {
@@ -91787,6 +91872,26 @@ function mountHTMLShell(container, content, shell) {
91787
91872
 
91788
91873
  var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
91789
91874
  var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
91875
+ var CONTENT_INTERACTIVE_SELECTOR = [
91876
+ '[data-vvfx-html-interaction-zone="self"]',
91877
+ '[data-vvfx-html-interaction-zone="subtree"]',
91878
+ 'a[href]',
91879
+ 'button:not([disabled])',
91880
+ 'input:not([disabled])',
91881
+ 'textarea:not([disabled])',
91882
+ 'select:not([disabled])',
91883
+ 'summary',
91884
+ 'video[controls]',
91885
+ 'audio[controls]',
91886
+ '[contenteditable]:not([contenteditable="false"])',
91887
+ '[role="button"]',
91888
+ '[role="link"]',
91889
+ '[role="textbox"]',
91890
+ '[tabindex]:not([tabindex="-1"])'
91891
+ ].join(', ');
91892
+ var CONTENT_INTERACTION_NONE_SELECTOR = [
91893
+ '[data-vvfx-html-interaction-zone="none"]'
91894
+ ].join(', ');
91790
91895
  var EDITING_VIEWPORT_PADDING = 48;
91791
91896
  var EDITING_VIEWPORT_BOX_SCALE = 1.1;
91792
91897
  var AUTO_HEIGHT_EPSILON = 0.5;
@@ -91796,14 +91901,20 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91796
91901
  var _this = this;
91797
91902
  this.options = options;
91798
91903
  this.eventCleanups = [];
91904
+ this.htmlRootConfigCleanups = new WeakMap();
91799
91905
  this.state = {
91800
91906
  frameElements: new Map(),
91801
91907
  elements: new Map(),
91908
+ selectionElements: new Map(),
91802
91909
  contentScaleElements: new Map(),
91803
91910
  contentElements: new Map(),
91804
91911
  contentMountElements: new Map(),
91912
+ contentInteractionZones: new Map(),
91913
+ contentInteractionZoneCleanups: new Map(),
91914
+ contentInteractionResizeCleanups: new Map(),
91805
91915
  contents: new Map(),
91806
91916
  cleanups: new Map(),
91917
+ autoHeightModes: new Map(),
91807
91918
  autoHeightCleanups: new Map(),
91808
91919
  autoHeightFrames: new Map()
91809
91920
  };
@@ -91820,6 +91931,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91820
91931
  }
91821
91932
  return;
91822
91933
  }
91934
+ if (!_this.isEditableCard(targetId)) {
91935
+ return;
91936
+ }
91823
91937
  event.preventDefault();
91824
91938
  event.stopPropagation();
91825
91939
  _this.enterEditing(targetId);
@@ -91835,6 +91949,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91835
91949
  _this.exitEditing();
91836
91950
  };
91837
91951
  this.handleContainerMouseMove = function(event) {
91952
+ _this.scheduleActiveContentInteractionSync(event);
91838
91953
  var hoverShellInteractiveId = _this.getHoverShellInteractiveIdByEvent(event);
91839
91954
  if (_this.state.hoverShellInteractiveId === hoverShellInteractiveId) {
91840
91955
  return;
@@ -91848,7 +91963,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91848
91963
  _this.syncContentInteraction(hoverShellInteractiveId);
91849
91964
  }
91850
91965
  };
91851
- this.handleContainerMouseLeave = function() {
91966
+ this.handleContainerMouseLeave = function(event) {
91967
+ if (_this.isMouseLeaveWithinContainer(event)) {
91968
+ return;
91969
+ }
91970
+ if (_this.contentInteractionFrame !== undefined) {
91971
+ cancelAnimationFrame(_this.contentInteractionFrame);
91972
+ _this.contentInteractionFrame = undefined;
91973
+ }
91974
+ _this.pendingContentInteractionEvent = undefined;
91975
+ _this.setActiveContentInteraction(undefined);
91852
91976
  var previousId = _this.state.hoverShellInteractiveId;
91853
91977
  if (!previousId) {
91854
91978
  return;
@@ -91856,6 +91980,33 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91856
91980
  _this.state.hoverShellInteractiveId = undefined;
91857
91981
  _this.syncContentInteraction(previousId);
91858
91982
  };
91983
+ this.handleContainerContextMenu = function(event) {
91984
+ var activeInteraction = _this.state.activeContentInteraction;
91985
+ if (!activeInteraction || !_this.isEventInsideOverlay(activeInteraction.id, event) || _this.isHTMLContextMenuEvent(event)) {
91986
+ return;
91987
+ }
91988
+ var canvas = _this.options.getCanvasEventTarget == null ? void 0 : _this.options.getCanvasEventTarget.call(_this.options);
91989
+ if (!canvas) {
91990
+ return;
91991
+ }
91992
+ event.preventDefault();
91993
+ event.stopPropagation();
91994
+ _this.setActiveContentInteraction(undefined);
91995
+ canvas.dispatchEvent(new MouseEvent('contextmenu', {
91996
+ bubbles: true,
91997
+ cancelable: true,
91998
+ clientX: event.clientX,
91999
+ clientY: event.clientY,
92000
+ screenX: event.screenX,
92001
+ screenY: event.screenY,
92002
+ button: event.button,
92003
+ buttons: event.buttons,
92004
+ ctrlKey: event.ctrlKey,
92005
+ shiftKey: event.shiftKey,
92006
+ altKey: event.altKey,
92007
+ metaKey: event.metaKey
92008
+ }));
92009
+ };
91859
92010
  this.isAutoHeightMessage = isCardHTMLAutoHeightMessage;
91860
92011
  }
91861
92012
  var _proto = HTMLOverlayManager.prototype;
@@ -91869,7 +92020,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91869
92020
  layer.style.position = 'absolute';
91870
92021
  layer.style.inset = '0';
91871
92022
  layer.style.pointerEvents = 'none';
91872
- layer.style.zIndex = '1';
91873
92023
  container.appendChild(layer);
91874
92024
  this.state.layer = layer;
91875
92025
  this.initDOMEvents();
@@ -91882,16 +92032,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91882
92032
  cancelAnimationFrame(this.state.updateFrame);
91883
92033
  this.state.updateFrame = undefined;
91884
92034
  }
92035
+ if (this.contentInteractionFrame !== undefined) {
92036
+ cancelAnimationFrame(this.contentInteractionFrame);
92037
+ this.contentInteractionFrame = undefined;
92038
+ }
92039
+ this.pendingContentInteractionEvent = undefined;
91885
92040
  this.state.cleanups.forEach(function(cleanup) {
91886
92041
  cleanup();
91887
92042
  });
91888
92043
  this.state.frameElements.clear();
91889
92044
  this.state.elements.clear();
92045
+ this.state.selectionElements.clear();
91890
92046
  this.state.contentScaleElements.clear();
91891
92047
  this.state.contentElements.clear();
91892
92048
  this.state.contentMountElements.clear();
92049
+ this.state.contentInteractionZones.clear();
92050
+ this.state.contentInteractionZoneCleanups.forEach(function(cleanup) {
92051
+ cleanup();
92052
+ });
92053
+ this.state.contentInteractionZoneCleanups.clear();
92054
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92055
+ cleanup();
92056
+ });
92057
+ this.state.contentInteractionResizeCleanups.clear();
91893
92058
  this.state.contents.clear();
91894
92059
  this.state.cleanups.clear();
92060
+ this.state.autoHeightModes.clear();
91895
92061
  this.state.autoHeightCleanups.forEach(function(cleanup) {
91896
92062
  cleanup();
91897
92063
  });
@@ -91906,10 +92072,12 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91906
92072
  this.eventCleanups = [];
91907
92073
  (_this_state_layer = this.state.layer) == null ? void 0 : _this_state_layer.remove();
91908
92074
  this.state.layer = undefined;
92075
+ this.state.selectionLayer = undefined;
91909
92076
  this.options.container.removeEventListener('dblclick', this.handleContainerDoubleClick, true);
91910
92077
  this.options.container.removeEventListener('mousedown', this.handleContainerMouseDown, true);
91911
92078
  this.options.container.removeEventListener('mousemove', this.handleContainerMouseMove, true);
91912
92079
  this.options.container.removeEventListener('mouseleave', this.handleContainerMouseLeave, true);
92080
+ this.options.container.removeEventListener('contextmenu', this.handleContainerContextMenu, true);
91913
92081
  };
91914
92082
  _proto.scheduleRender = function scheduleRender() {
91915
92083
  var _this = this;
@@ -91921,6 +92089,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91921
92089
  _this.render();
91922
92090
  });
91923
92091
  };
92092
+ _proto.invalidateCardHTML = function invalidateCardHTML(id) {
92093
+ this.cleanupOverlayContent(id);
92094
+ this.invalidateContentInteractionZones(id);
92095
+ };
91924
92096
  _proto.rasterizeCard = function rasterizeCard(id, options) {
91925
92097
  return _async_to_generator(function() {
91926
92098
  var contentOverlay, capture, _ref, _options_pixelRatio, image, error;
@@ -92013,6 +92185,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92013
92185
  var events = [
92014
92186
  'pageDataChange',
92015
92187
  'selectedItemChange',
92188
+ 'preSelectedItemChange',
92016
92189
  'itemPropertyChange',
92017
92190
  'viewportTransform',
92018
92191
  'viewRebuildFinish'
@@ -92022,6 +92195,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92022
92195
  if (event === 'viewportTransform') {
92023
92196
  _this.handleViewportTransform();
92024
92197
  }
92198
+ _this.invalidateContentInteractionZones();
92025
92199
  _this.scheduleRender();
92026
92200
  });
92027
92201
  });
@@ -92031,6 +92205,24 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92031
92205
  this.options.container.addEventListener('mousedown', this.handleContainerMouseDown, true);
92032
92206
  this.options.container.addEventListener('mousemove', this.handleContainerMouseMove, true);
92033
92207
  this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
92208
+ this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
92209
+ };
92210
+ _proto.isMouseLeaveWithinContainer = function isMouseLeaveWithinContainer(event) {
92211
+ var relatedTarget = event.relatedTarget;
92212
+ if (!relatedTarget) {
92213
+ return false;
92214
+ }
92215
+ try {
92216
+ return this.options.container.contains(relatedTarget);
92217
+ } catch (unused) {
92218
+ return false;
92219
+ }
92220
+ };
92221
+ _proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
92222
+ if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
92223
+ return false;
92224
+ }
92225
+ return !!event.target.closest('[data-interaction-contextmenu="self"], [data-vvfx-html-contextmenu="self"]');
92034
92226
  };
92035
92227
  _proto.handleViewportTransform = function handleViewportTransform() {
92036
92228
  var editing = this.state.editing;
@@ -92050,11 +92242,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92050
92242
  }
92051
92243
  var items = this.options.getItems();
92052
92244
  var frameByChildId = this.renderFrameOverlays(items, layer);
92245
+ var selectionLayer = this.getOrCreateSelectionLayer(layer);
92053
92246
  var visibleCardIds = new Set();
92054
92247
  var editingVisible = false;
92055
92248
  items.forEach(function(item) {
92056
92249
  var _this_state_editing;
92057
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92250
+ if (!isCardItem(item) || !item.visible) {
92251
+ return;
92252
+ }
92253
+ var html = _this.options.resolveCardHTML(item);
92254
+ if (html === undefined) {
92058
92255
  return;
92059
92256
  }
92060
92257
  var itemBox = _this.options.getViewBoxById(item.id);
@@ -92069,21 +92266,31 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92069
92266
  var frameBox = frameId ? _this.options.getViewBoxById(frameId) : undefined;
92070
92267
  var overlay = _this.getOrCreateOverlay(item.id, parentOverlay, elements);
92071
92268
  var contentOverlay = _this.getOrCreateContentOverlay(item.id, overlay);
92072
- var html = item.html;
92073
- if (html && _this.state.contents.get(item.id) !== html) {
92269
+ var selectionOverlay = _this.getOrCreateSelectionOverlay(item.id, selectionLayer);
92270
+ if (!_this.state.contents.has(item.id)) {
92074
92271
  _this.renderOverlayHTML(item.id, contentOverlay, html);
92075
92272
  }
92273
+ _this.applyHTMLRootConfig(overlay, html);
92076
92274
  var offsetX = frameBox && !frameBox.isEmpty() ? frameBox.min.x : 0;
92077
92275
  var offsetY = frameBox && !frameBox.isEmpty() ? frameBox.min.y : 0;
92078
- var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY);
92276
+ var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY, _this.isAutoScaleEnabled(item));
92079
92277
  overlay.style.left = boxStyle.left;
92080
92278
  overlay.style.top = boxStyle.top;
92081
92279
  overlay.style.width = boxStyle.width;
92082
92280
  overlay.style.height = boxStyle.height;
92083
92281
  overlay.style.transform = boxStyle.transform;
92084
92282
  overlay.style.transformOrigin = '0 0';
92085
- _this.syncContentScale(item.id, item.property.width, item.property.height);
92086
- _this.syncAutoHeight(item.id, item.property.autoHeight === true);
92283
+ var selectionBoxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, 0, 0, _this.isAutoScaleEnabled(item));
92284
+ selectionOverlay.style.left = selectionBoxStyle.left;
92285
+ selectionOverlay.style.top = selectionBoxStyle.top;
92286
+ selectionOverlay.style.width = selectionBoxStyle.width;
92287
+ selectionOverlay.style.height = selectionBoxStyle.height;
92288
+ selectionOverlay.style.transform = selectionBoxStyle.transform;
92289
+ selectionOverlay.style.transformOrigin = '0 0';
92290
+ _this.applyHTMLRootConfig(selectionOverlay, html);
92291
+ _this.syncOverlaySelection(item.id, overlay, selectionOverlay);
92292
+ _this.syncContentScale(item.id, boxStyle.contentWidth, boxStyle.contentHeight);
92293
+ _this.syncAutoHeight(item.id, _this.isAutoHeightEnabled(item));
92087
92294
  _this.syncContentInteraction(item.id);
92088
92295
  });
92089
92296
  elements.forEach(function(_overlay, id) {
@@ -92122,6 +92329,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92122
92329
  }
92123
92330
  }
92124
92331
  syncElementStackOrder(layer, rootElements);
92332
+ if (this.state.selectionLayer) {
92333
+ this.state.selectionLayer.style.zIndex = "" + (rootElements.length + 1);
92334
+ }
92125
92335
  this.state.frameElements.forEach(function(frameOverlay, frameId) {
92126
92336
  var frameElements = [];
92127
92337
  for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
@@ -92137,6 +92347,28 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92137
92347
  syncElementStackOrder(frameOverlay, frameElements);
92138
92348
  });
92139
92349
  };
92350
+ _proto.getOrCreateSelectionLayer = function getOrCreateSelectionLayer(layer) {
92351
+ var _layer_ownerDocument;
92352
+ if (this.state.selectionLayer) {
92353
+ if (this.state.selectionLayer.parentElement !== layer) {
92354
+ layer.appendChild(this.state.selectionLayer);
92355
+ }
92356
+ return this.state.selectionLayer;
92357
+ }
92358
+ var ownerDocument = (_layer_ownerDocument = layer.ownerDocument) != null ? _layer_ownerDocument : typeof document === 'undefined' ? undefined : document;
92359
+ if (!ownerDocument) {
92360
+ return layer;
92361
+ }
92362
+ var selectionLayer = ownerDocument.createElement('div');
92363
+ selectionLayer.className = 'vvfx-card-html-overlay-selection-layer';
92364
+ selectionLayer.style.position = 'absolute';
92365
+ selectionLayer.style.inset = '0';
92366
+ selectionLayer.style.pointerEvents = 'none';
92367
+ selectionLayer.style.zIndex = '1';
92368
+ layer.appendChild(selectionLayer);
92369
+ this.state.selectionLayer = selectionLayer;
92370
+ return selectionLayer;
92371
+ };
92140
92372
  _proto.renderFrameOverlays = function renderFrameOverlays(items, layer) {
92141
92373
  var _this = this;
92142
92374
  var visibleFrameIds = new Set();
@@ -92201,6 +92433,41 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92201
92433
  elements.set(id, overlay);
92202
92434
  return overlay;
92203
92435
  };
92436
+ _proto.getOrCreateSelectionOverlay = function getOrCreateSelectionOverlay(id, parent) {
92437
+ var selectionOverlay = this.state.selectionElements.get(id);
92438
+ if (selectionOverlay) {
92439
+ if (selectionOverlay.parentElement !== parent) {
92440
+ parent.appendChild(selectionOverlay);
92441
+ }
92442
+ return selectionOverlay;
92443
+ }
92444
+ selectionOverlay = document.createElement('div');
92445
+ selectionOverlay.className = 'vvfx-card-html-overlay-selection';
92446
+ selectionOverlay.dataset.itemId = id;
92447
+ selectionOverlay.style.position = 'absolute';
92448
+ selectionOverlay.style.pointerEvents = 'none';
92449
+ selectionOverlay.style.zIndex = '1';
92450
+ parent.appendChild(selectionOverlay);
92451
+ this.state.selectionElements.set(id, selectionOverlay);
92452
+ return selectionOverlay;
92453
+ };
92454
+ _proto.syncOverlaySelection = function syncOverlaySelection(id, overlay, selectionOverlay) {
92455
+ var isSelected = this.options.getSelectedItemIds().includes(id);
92456
+ var isPreSelected = !isSelected && this.options.getPreSelectedItemId() === id;
92457
+ overlay.dataset.selected = isSelected ? 'true' : 'false';
92458
+ overlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92459
+ selectionOverlay.dataset.selected = isSelected ? 'true' : 'false';
92460
+ selectionOverlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92461
+ selectionOverlay.style.boxShadow = isSelected ? this.getSelectionBoxShadow() : isPreSelected ? this.getPreSelectionBoxShadow() : '';
92462
+ };
92463
+ _proto.getSelectionBoxShadow = function getSelectionBoxShadow() {
92464
+ var _this_options_getSelectionEdgeStyle = this.options.getSelectionEdgeStyle(), color = _this_options_getSelectionEdgeStyle.color, alpha = _this_options_getSelectionEdgeStyle.alpha, width = _this_options_getSelectionEdgeStyle.width;
92465
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92466
+ };
92467
+ _proto.getPreSelectionBoxShadow = function getPreSelectionBoxShadow() {
92468
+ var _this_options_getPreSelectionEdgeStyle = this.options.getPreSelectionEdgeStyle(), color = _this_options_getPreSelectionEdgeStyle.color, alpha = _this_options_getPreSelectionEdgeStyle.alpha, width = _this_options_getPreSelectionEdgeStyle.width;
92469
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92470
+ };
92204
92471
  _proto.getHTMLCardIdByEvent = function getHTMLCardIdByEvent(event) {
92205
92472
  var layer = this.state.layer;
92206
92473
  if (!layer) {
@@ -92210,7 +92477,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92210
92477
  var items = this.options.getItems();
92211
92478
  for(var i = items.length - 1; i >= 0; i--){
92212
92479
  var item = items[i];
92213
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92480
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92214
92481
  continue;
92215
92482
  }
92216
92483
  var box = this.options.getViewBoxById(item.id);
@@ -92229,7 +92496,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92229
92496
  var items = this.options.getItems();
92230
92497
  for(var i = items.length - 1; i >= 0; i--){
92231
92498
  var item = items[i];
92232
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92499
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92233
92500
  continue;
92234
92501
  }
92235
92502
  var box = this.options.getViewBoxById(item.id);
@@ -92239,13 +92506,206 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92239
92506
  var contentOverlay = this.state.contentElements.get(item.id);
92240
92507
  var interactiveElements = contentOverlay ? Array.from(contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR)) : [];
92241
92508
  var isHoveringShellInteractive = interactiveElements.some(function(element) {
92242
- var rect = element.getBoundingClientRect();
92243
- return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
92509
+ return isMouseEventInsideRect(event, element.getBoundingClientRect());
92244
92510
  });
92245
92511
  return isHoveringShellInteractive ? item.id : undefined;
92246
92512
  }
92247
92513
  return undefined;
92248
92514
  };
92515
+ _proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
92516
+ var decision = this.resolveHTMLInteractionTarget(event);
92517
+ if (decision.kind === 'canvas' && this.shouldKeepActiveContentInteractionForFocusedElement()) {
92518
+ return;
92519
+ }
92520
+ this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
92521
+ };
92522
+ _proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
92523
+ var _this = this;
92524
+ if (typeof requestAnimationFrame !== 'function') {
92525
+ this.syncActiveContentInteraction(event);
92526
+ return;
92527
+ }
92528
+ this.pendingContentInteractionEvent = event;
92529
+ if (this.contentInteractionFrame !== undefined) {
92530
+ return;
92531
+ }
92532
+ this.contentInteractionFrame = requestAnimationFrame(function() {
92533
+ _this.contentInteractionFrame = undefined;
92534
+ var pendingEvent = _this.pendingContentInteractionEvent;
92535
+ _this.pendingContentInteractionEvent = undefined;
92536
+ if (pendingEvent) {
92537
+ _this.syncActiveContentInteraction(pendingEvent);
92538
+ }
92539
+ });
92540
+ };
92541
+ _proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
92542
+ var _this = this;
92543
+ var previous = this.state.activeContentInteraction;
92544
+ if ((previous == null ? void 0 : previous.id) === (zone == null ? void 0 : zone.id) && (previous == null ? void 0 : previous.element) === (zone == null ? void 0 : zone.element) && (previous == null ? void 0 : previous.zone) === (zone == null ? void 0 : zone.zone)) {
92545
+ return;
92546
+ }
92547
+ this.state.activeContentInteraction = zone;
92548
+ var changedIds = new Set();
92549
+ if (previous) {
92550
+ changedIds.add(previous.id);
92551
+ }
92552
+ if (zone) {
92553
+ changedIds.add(zone.id);
92554
+ }
92555
+ changedIds.forEach(function(id) {
92556
+ _this.syncContentInteraction(id);
92557
+ });
92558
+ };
92559
+ _proto.shouldKeepActiveContentInteractionForFocusedElement = function shouldKeepActiveContentInteractionForFocusedElement() {
92560
+ var activeInteraction = this.state.activeContentInteraction;
92561
+ if (!activeInteraction || typeof document === 'undefined') {
92562
+ return false;
92563
+ }
92564
+ var activeElement = document.activeElement;
92565
+ if (!activeElement || activeElement === document.body) {
92566
+ return false;
92567
+ }
92568
+ var interactionElement = activeInteraction.element;
92569
+ return interactionElement === activeElement || typeof interactionElement.contains === 'function' && interactionElement.contains(activeElement);
92570
+ };
92571
+ _proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
92572
+ var id = this.getHTMLCardIdByEvent(event);
92573
+ if (!id || this.isEditableCard(id)) {
92574
+ return {
92575
+ kind: 'canvas',
92576
+ id: id
92577
+ };
92578
+ }
92579
+ var contentOverlay = this.state.contentElements.get(id);
92580
+ if (!contentOverlay) {
92581
+ return {
92582
+ kind: 'canvas',
92583
+ id: id
92584
+ };
92585
+ }
92586
+ var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
92587
+ if (activeSubtree) {
92588
+ return {
92589
+ kind: 'html',
92590
+ interaction: activeSubtree
92591
+ };
92592
+ }
92593
+ var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
92594
+ return isMouseEventInsideRect(event, zone.rect);
92595
+ });
92596
+ var zone = this.resolveContentInteractionZone(matchedZones);
92597
+ if (zone) {
92598
+ return {
92599
+ kind: 'html',
92600
+ interaction: {
92601
+ id: id,
92602
+ element: zone.element,
92603
+ zone: zone.zone
92604
+ }
92605
+ };
92606
+ }
92607
+ return {
92608
+ kind: 'canvas',
92609
+ id: id
92610
+ };
92611
+ };
92612
+ _proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
92613
+ var activeInteraction = this.state.activeContentInteraction;
92614
+ if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
92615
+ return undefined;
92616
+ }
92617
+ var rect = activeInteraction.element.getBoundingClientRect();
92618
+ return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
92619
+ };
92620
+ _proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
92621
+ if (zones.length <= 1) {
92622
+ return zones[0];
92623
+ }
92624
+ var subtreeRoot = zones.find(function(candidate) {
92625
+ return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
92626
+ return zone.element !== candidate.element && candidate.element.contains(zone.element);
92627
+ });
92628
+ });
92629
+ return subtreeRoot != null ? subtreeRoot : zones[0];
92630
+ };
92631
+ _proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
92632
+ var _this = this;
92633
+ var cachedZones = this.state.contentInteractionZones.get(id);
92634
+ if (cachedZones) {
92635
+ return cachedZones;
92636
+ }
92637
+ var zones = Array.from(contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id))).filter(function(element) {
92638
+ return !_this.isContentInteractionDisabled(element);
92639
+ }).map(function(element) {
92640
+ return {
92641
+ element: element,
92642
+ rect: element.getBoundingClientRect(),
92643
+ zone: _this.getContentInteractionZoneMode(element)
92644
+ };
92645
+ });
92646
+ this.state.contentInteractionZones.set(id, zones);
92647
+ this.observeContentInteractionZoneResizes(id, zones);
92648
+ return zones;
92649
+ };
92650
+ _proto.getContentInteractiveSelector = function getContentInteractiveSelector(id) {
92651
+ var _ref;
92652
+ var _this_options_resolveCardTypeConfig_htmlInteractionSelectors, _this_options_resolveCardTypeConfig;
92653
+ var item = this.options.getItems().find(function(item) {
92654
+ return item.id === id;
92655
+ });
92656
+ if (!item) {
92657
+ return CONTENT_INTERACTIVE_SELECTOR;
92658
+ }
92659
+ var selectors = (_ref = (_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : (_this_options_resolveCardTypeConfig_htmlInteractionSelectors = _this_options_resolveCardTypeConfig.htmlInteractionSelectors) == null ? void 0 : _this_options_resolveCardTypeConfig_htmlInteractionSelectors.filter(Boolean)) != null ? _ref : [];
92660
+ if (selectors.length === 0) {
92661
+ return CONTENT_INTERACTIVE_SELECTOR;
92662
+ }
92663
+ return [].concat([
92664
+ CONTENT_INTERACTIVE_SELECTOR
92665
+ ], selectors).join(', ');
92666
+ };
92667
+ _proto.isContentInteractionDisabled = function isContentInteractionDisabled(element) {
92668
+ if (typeof element.closest !== 'function') {
92669
+ return false;
92670
+ }
92671
+ return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
92672
+ };
92673
+ _proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
92674
+ var zone = element.dataset.vvfxHtmlInteractionZone;
92675
+ return zone === 'subtree' ? 'subtree' : 'self';
92676
+ };
92677
+ _proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
92678
+ if (id) {
92679
+ var _this_state_contentInteractionResizeCleanups_get;
92680
+ this.state.contentInteractionZones.delete(id);
92681
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92682
+ this.state.contentInteractionResizeCleanups.delete(id);
92683
+ return;
92684
+ }
92685
+ this.state.contentInteractionZones.clear();
92686
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92687
+ cleanup();
92688
+ });
92689
+ this.state.contentInteractionResizeCleanups.clear();
92690
+ };
92691
+ _proto.observeContentInteractionZoneResizes = function observeContentInteractionZoneResizes(id, zones) {
92692
+ var _this = this;
92693
+ var _this_state_contentInteractionResizeCleanups_get;
92694
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92695
+ this.state.contentInteractionResizeCleanups.delete(id);
92696
+ if (zones.length === 0 || typeof ResizeObserver !== 'function') {
92697
+ return;
92698
+ }
92699
+ var observer = new ResizeObserver(function() {
92700
+ _this.invalidateContentInteractionZones(id);
92701
+ });
92702
+ zones.forEach(function(zone) {
92703
+ observer.observe(zone.element);
92704
+ });
92705
+ this.state.contentInteractionResizeCleanups.set(id, function() {
92706
+ observer.disconnect();
92707
+ });
92708
+ };
92249
92709
  _proto.getLayerPoint = function getLayerPoint(event) {
92250
92710
  var rect = this.options.container.getBoundingClientRect();
92251
92711
  return {
@@ -92302,19 +92762,35 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92302
92762
  if (!scaleOverlay || !contentOverlay || width <= 0 || height <= 0) {
92303
92763
  return;
92304
92764
  }
92305
- scaleOverlay.style.width = "" + width + "px";
92306
- scaleOverlay.style.height = "" + height + "px";
92765
+ var nextWidth = "" + width + "px";
92766
+ var nextHeight = "" + height + "px";
92767
+ var sizeChanged = scaleOverlay.style.width !== nextWidth || scaleOverlay.style.height !== nextHeight;
92768
+ scaleOverlay.style.width = nextWidth;
92769
+ scaleOverlay.style.height = nextHeight;
92307
92770
  scaleOverlay.style.transform = 'none';
92308
- contentOverlay.style.width = "" + width + "px";
92309
- contentOverlay.style.height = "" + height + "px";
92771
+ contentOverlay.style.width = nextWidth;
92772
+ contentOverlay.style.height = nextHeight;
92773
+ if (sizeChanged && this.state.autoHeightModes.get(id) === 'message') {
92774
+ this.requestAutoHeightFromIframes(id, contentOverlay);
92775
+ }
92776
+ if (sizeChanged) {
92777
+ this.invalidateContentInteractionZones(id);
92778
+ }
92779
+ };
92780
+ _proto.requestAutoHeightFromIframes = function requestAutoHeightFromIframes(id, contentOverlay) {
92781
+ contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92782
+ requestCardHTMLAutoHeight(iframe, id);
92783
+ });
92310
92784
  };
92311
92785
  _proto.syncContentInteraction = function syncContentInteraction(id) {
92312
- var _this_state_editing;
92786
+ var _this_state_editing, _this_state_activeContentInteraction;
92313
92787
  var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
92788
+ var activeInteraction = ((_this_state_activeContentInteraction = this.state.activeContentInteraction) == null ? void 0 : _this_state_activeContentInteraction.id) === id ? this.state.activeContentInteraction : undefined;
92314
92789
  var overlay = this.state.elements.get(id);
92315
92790
  var scaleOverlay = this.state.contentScaleElements.get(id);
92316
92791
  var contentOverlay = this.state.contentElements.get(id);
92317
92792
  var contentMount = this.state.contentMountElements.get(id);
92793
+ var isInteractive = isEditing || !!activeInteraction;
92318
92794
  if (overlay) {
92319
92795
  overlay.dataset.editing = isEditing ? 'true' : 'false';
92320
92796
  overlay.style.pointerEvents = 'none';
@@ -92325,34 +92801,62 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92325
92801
  }
92326
92802
  if (contentOverlay) {
92327
92803
  contentOverlay.dataset.editing = isEditing ? 'true' : 'false';
92328
- contentOverlay.style.pointerEvents = 'none';
92804
+ contentOverlay.style.pointerEvents = isInteractive ? 'auto' : 'none';
92329
92805
  contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92330
- iframe.style.pointerEvents = isEditing ? 'auto' : 'none';
92331
- iframe.tabIndex = isEditing ? 0 : -1;
92806
+ var isActiveIframe = isEditing || (activeInteraction == null ? void 0 : activeInteraction.element) === iframe;
92807
+ iframe.style.pointerEvents = isActiveIframe ? 'auto' : 'none';
92808
+ iframe.tabIndex = isActiveIframe ? 0 : -1;
92332
92809
  });
92333
- this.syncShellInteraction(id, contentOverlay, isEditing);
92810
+ this.syncShellInteraction(id, contentOverlay, isInteractive);
92811
+ this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
92334
92812
  }
92335
92813
  if (contentMount) {
92336
92814
  contentMount.dataset.editing = isEditing ? 'true' : 'false';
92337
- contentMount.style.pointerEvents = isEditing ? 'auto' : 'none';
92338
- contentMount.inert = !isEditing;
92339
- if (isEditing) {
92815
+ contentMount.style.pointerEvents = isInteractive ? 'auto' : 'none';
92816
+ contentMount.inert = !isInteractive;
92817
+ if (isInteractive) {
92340
92818
  contentMount.removeAttribute('aria-hidden');
92341
92819
  } else {
92342
92820
  contentMount.setAttribute('aria-hidden', 'true');
92343
92821
  }
92344
92822
  }
92345
92823
  };
92346
- _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isEditing) {
92824
+ _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
92825
+ var _this = this;
92826
+ var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
92827
+ contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
92828
+ if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
92829
+ _this.clearContentInteractionState(element);
92830
+ return;
92831
+ }
92832
+ if (!isInteractive) {
92833
+ _this.clearContentInteractionState(element);
92834
+ return;
92835
+ }
92836
+ if (_this.isContentInteractionDisabled(element)) {
92837
+ element.dataset.vvfxHtmlInteractionActive = 'false';
92838
+ element.style.pointerEvents = 'none';
92839
+ return;
92840
+ }
92841
+ var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
92842
+ element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
92843
+ element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
92844
+ });
92845
+ };
92846
+ _proto.clearContentInteractionState = function clearContentInteractionState(element) {
92847
+ delete element.dataset.vvfxHtmlInteractionActive;
92848
+ element.style.pointerEvents = '';
92849
+ };
92850
+ _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
92347
92851
  var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
92348
- var isShellInteractiveActive = isEditing || isHoveringShellInteractive;
92852
+ var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
92349
92853
  contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR).forEach(function(element) {
92350
92854
  element.dataset.vvfxHtmlShellInteractiveHover = isHoveringShellInteractive ? 'true' : 'false';
92351
92855
  element.dataset.vvfxHtmlShellInteractiveActive = isShellInteractiveActive ? 'true' : 'false';
92352
92856
  element.style.pointerEvents = isShellInteractiveActive ? 'auto' : 'none';
92353
92857
  });
92354
92858
  contentOverlay.querySelectorAll(EDITING_INTERACTIVE_SELECTOR).forEach(function(element) {
92355
- element.style.pointerEvents = isEditing ? 'auto' : 'none';
92859
+ element.style.pointerEvents = isInteractive ? 'auto' : 'none';
92356
92860
  });
92357
92861
  };
92358
92862
  _proto.enterEditing = function enterEditing(id) {
@@ -92360,6 +92864,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92360
92864
  if (((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id) {
92361
92865
  return;
92362
92866
  }
92867
+ if (!this.isEditableCard(id)) {
92868
+ return;
92869
+ }
92363
92870
  var box = this.options.getViewBoxById(id);
92364
92871
  if (box.isEmpty()) {
92365
92872
  return;
@@ -92403,6 +92910,13 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92403
92910
  this.options.setViewport(editing.restoreViewport);
92404
92911
  this.scheduleRender();
92405
92912
  };
92913
+ _proto.isEditableCard = function isEditableCard(id) {
92914
+ var _this_options_resolveCardTypeConfig;
92915
+ var item = this.options.getItems().find(function(item) {
92916
+ return item.id === id;
92917
+ });
92918
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.editable) !== false;
92919
+ };
92406
92920
  _proto.getEditingFitZoom = function getEditingFitZoom(box, currentZoom) {
92407
92921
  var viewportElement = this.options.container.parentElement;
92408
92922
  if (!viewportElement) {
@@ -92427,6 +92941,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92427
92941
  };
92428
92942
  _proto.renderOverlayHTML = function renderOverlayHTML(id, overlay, html) {
92429
92943
  this.cleanupOverlayContent(id);
92944
+ this.invalidateContentInteractionZones(id);
92430
92945
  overlay.innerHTML = '';
92431
92946
  var shell = mountHTMLShell(overlay, html.content, html.shell);
92432
92947
  var autoHeightMeasureElement = shell.contentContainer.isConnected ? shell.contentContainer : overlay;
@@ -92436,18 +92951,81 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92436
92951
  });
92437
92952
  var contentCleanup = this.renderOverlayContent(shell.contentContainer, html.content, {
92438
92953
  id: id,
92439
- autoHeight: isCardItem(item) && item.property.autoHeight === true
92954
+ autoHeight: this.isAutoHeightEnabled(item)
92440
92955
  });
92956
+ this.observeContentInteractionZones(id, shell.contentContainer);
92441
92957
  this.state.cleanups.set(id, function() {
92442
92958
  contentCleanup == null ? void 0 : contentCleanup();
92443
92959
  shell.cleanup == null ? void 0 : shell.cleanup.call(shell);
92444
92960
  });
92445
92961
  this.state.contents.set(id, html);
92446
92962
  };
92963
+ _proto.observeContentInteractionZones = function observeContentInteractionZones(id, contentContainer) {
92964
+ var _this = this;
92965
+ var _this_state_contentInteractionZoneCleanups_get;
92966
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
92967
+ this.state.contentInteractionZoneCleanups.delete(id);
92968
+ if (typeof MutationObserver !== 'function') {
92969
+ return;
92970
+ }
92971
+ var observer = new MutationObserver(function() {
92972
+ _this.invalidateContentInteractionZones(id);
92973
+ });
92974
+ observer.observe(contentContainer, {
92975
+ attributes: true,
92976
+ childList: true,
92977
+ subtree: true
92978
+ });
92979
+ this.state.contentInteractionZoneCleanups.set(id, function() {
92980
+ observer.disconnect();
92981
+ });
92982
+ };
92983
+ _proto.applyHTMLRootConfig = function applyHTMLRootConfig(root, html) {
92984
+ var _ref, _config_style;
92985
+ var _this_htmlRootConfigCleanups_get, _config_className;
92986
+ (_this_htmlRootConfigCleanups_get = this.htmlRootConfigCleanups.get(root)) == null ? void 0 : _this_htmlRootConfigCleanups_get();
92987
+ this.htmlRootConfigCleanups.delete(root);
92988
+ var config = html.root;
92989
+ if (!config) {
92990
+ return;
92991
+ }
92992
+ var classNames = (_ref = (_config_className = config.className) == null ? void 0 : _config_className.split(/\s+/).filter(Boolean)) != null ? _ref : [];
92993
+ var styleProperties = [];
92994
+ classNames.forEach(function(className) {
92995
+ root.classList.add(className);
92996
+ });
92997
+ Object.entries((_config_style = config.style) != null ? _config_style : {}).forEach(function(param) {
92998
+ var property = param[0], value = param[1];
92999
+ if (value === undefined) {
93000
+ return;
93001
+ }
93002
+ styleProperties.push(property);
93003
+ if (property.startsWith('--') || property.includes('-')) {
93004
+ root.style.setProperty(property, String(value));
93005
+ return;
93006
+ }
93007
+ root.style[property] = String(value);
93008
+ });
93009
+ this.htmlRootConfigCleanups.set(root, function() {
93010
+ classNames.forEach(function(className) {
93011
+ root.classList.remove(className);
93012
+ });
93013
+ styleProperties.forEach(function(property) {
93014
+ if (property.startsWith('--') || property.includes('-')) {
93015
+ root.style.removeProperty(property);
93016
+ return;
93017
+ }
93018
+ root.style[property] = '';
93019
+ });
93020
+ });
93021
+ };
92447
93022
  _proto.renderOverlayContent = function renderOverlayContent(overlay, content, options) {
92448
93023
  var _this = this;
92449
93024
  switch(content.kind){
92450
93025
  case 'inline':
93026
+ if (options == null ? void 0 : options.autoHeight) {
93027
+ this.state.autoHeightModes.set(options.id, 'message');
93028
+ }
92451
93029
  return this.chainCleanups(function() {
92452
93030
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92453
93031
  }, renderDocumentContent(overlay, {
@@ -92464,6 +93042,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92464
93042
  }));
92465
93043
  case 'dom':
92466
93044
  {
93045
+ if (options == null ? void 0 : options.autoHeight) {
93046
+ this.state.autoHeightModes.set(options.id, 'measure');
93047
+ }
92467
93048
  if (content.target === 'iframe') {
92468
93049
  return renderDOMContentInIframe(overlay, content.render, content.cleanup);
92469
93050
  }
@@ -92473,6 +93054,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92473
93054
  } : undefined;
92474
93055
  }
92475
93056
  case 'document':
93057
+ if (options == null ? void 0 : options.autoHeight) {
93058
+ this.state.autoHeightModes.set(options.id, 'message');
93059
+ }
92476
93060
  return this.chainCleanups(function() {
92477
93061
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92478
93062
  }, renderDocumentContent(overlay, content, {
@@ -92500,6 +93084,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92500
93084
  };
92501
93085
  };
92502
93086
  _proto.cleanupOverlayContent = function cleanupOverlayContent(id) {
93087
+ var _this_state_contentInteractionZoneCleanups_get;
92503
93088
  var cleanup = this.state.cleanups.get(id);
92504
93089
  if (cleanup) {
92505
93090
  cleanup();
@@ -92507,13 +93092,19 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92507
93092
  }
92508
93093
  this.state.contents.delete(id);
92509
93094
  this.state.contentMountElements.delete(id);
93095
+ this.state.autoHeightModes.delete(id);
93096
+ this.invalidateContentInteractionZones(id);
93097
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
93098
+ this.state.contentInteractionZoneCleanups.delete(id);
92510
93099
  this.cleanupAutoHeight(id);
92511
93100
  };
92512
93101
  _proto.removeOverlay = function removeOverlay(id) {
92513
- var _this_state_elements_get;
93102
+ var _this_state_elements_get, _this_state_selectionElements_get;
92514
93103
  this.cleanupOverlayContent(id);
92515
93104
  (_this_state_elements_get = this.state.elements.get(id)) == null ? void 0 : _this_state_elements_get.remove();
93105
+ (_this_state_selectionElements_get = this.state.selectionElements.get(id)) == null ? void 0 : _this_state_selectionElements_get.remove();
92516
93106
  this.state.elements.delete(id);
93107
+ this.state.selectionElements.delete(id);
92517
93108
  this.state.contentScaleElements.delete(id);
92518
93109
  this.state.contentElements.delete(id);
92519
93110
  };
@@ -92522,11 +93113,27 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92522
93113
  this.cleanupAutoHeight(id);
92523
93114
  return;
92524
93115
  }
93116
+ this.ensureAutoHeightMode(id);
93117
+ if (this.state.autoHeightModes.get(id) === 'message') {
93118
+ this.cleanupAutoHeight(id);
93119
+ return;
93120
+ }
92525
93121
  if (!this.state.autoHeightCleanups.has(id)) {
92526
93122
  this.state.autoHeightCleanups.set(id, this.createAutoHeightObserver(id));
92527
93123
  }
92528
93124
  this.scheduleAutoHeightMeasure(id);
92529
93125
  };
93126
+ _proto.ensureAutoHeightMode = function ensureAutoHeightMode(id) {
93127
+ var _this_state_contents_get;
93128
+ if (this.state.autoHeightModes.has(id)) {
93129
+ return;
93130
+ }
93131
+ var content = (_this_state_contents_get = this.state.contents.get(id)) == null ? void 0 : _this_state_contents_get.content;
93132
+ if (!content) {
93133
+ return;
93134
+ }
93135
+ this.state.autoHeightModes.set(id, content.kind === 'inline' || content.kind === 'document' ? 'message' : 'measure');
93136
+ };
92530
93137
  _proto.createAutoHeightObserver = function createAutoHeightObserver(id) {
92531
93138
  var _this = this;
92532
93139
  var cleanupFns = [];
@@ -92614,7 +93221,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92614
93221
  var item = this.options.getItems().find(function(candidate) {
92615
93222
  return candidate.id === id;
92616
93223
  });
92617
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93224
+ if (!this.isAutoHeightEnabled(item)) {
92618
93225
  this.cleanupAutoHeight(id);
92619
93226
  return;
92620
93227
  }
@@ -92633,7 +93240,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92633
93240
  }).filter(function(height) {
92634
93241
  return typeof height === 'number' && Number.isFinite(height) && height > 0;
92635
93242
  });
92636
- var childHeight = this.getChildrenNaturalHeight(element);
93243
+ var childHeight = this.getChildrenNaturalHeight(element, {
93244
+ includeIframes: iframeHeights.length === 0
93245
+ });
92637
93246
  var naturalHeight = (_Math = Math).max.apply(_Math, [].concat([
92638
93247
  childHeight
92639
93248
  ], iframeHeights));
@@ -92653,10 +93262,29 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92653
93262
  }
92654
93263
  return Math.max(documentElement.scrollHeight, (_ref = body == null ? void 0 : body.scrollHeight) != null ? _ref : 0);
92655
93264
  };
92656
- _proto.getChildrenNaturalHeight = function getChildrenNaturalHeight(element) {
92657
- return Array.from(element.children).reduce(function(height, child) {
92658
- var childElement = child;
92659
- return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
93265
+ _proto.getChildrenNaturalHeight = function getChildrenNaturalHeight(element, options) {
93266
+ var _ref;
93267
+ var includeIframes = (_ref = options == null ? void 0 : options.includeIframes) != null ? _ref : true;
93268
+ return Array.from(element.childNodes).reduce(function(height, child) {
93269
+ var _child_textContent;
93270
+ if (child.nodeType === Node.ELEMENT_NODE) {
93271
+ var childElement = child;
93272
+ if (!includeIframes && childElement.tagName === 'IFRAME') {
93273
+ return height;
93274
+ }
93275
+ return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
93276
+ }
93277
+ if (child.nodeType === Node.TEXT_NODE && ((_child_textContent = child.textContent) == null ? void 0 : _child_textContent.trim())) {
93278
+ var range = element.ownerDocument.createRange();
93279
+ range.selectNodeContents(child);
93280
+ var rects = Array.from(range.getClientRects());
93281
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
93282
+ range.detach();
93283
+ return rects.reduce(function(textHeight, rect) {
93284
+ return Math.max(textHeight, rect.bottom - element.getBoundingClientRect().top);
93285
+ }, height);
93286
+ }
93287
+ return height;
92660
93288
  }, 0);
92661
93289
  };
92662
93290
  _proto.cleanupAutoHeight = function cleanupAutoHeight(id) {
@@ -92675,14 +93303,48 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92675
93303
  var item = this.options.getItems().find(function(candidate) {
92676
93304
  return candidate.id === id;
92677
93305
  });
92678
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93306
+ if (!isCardItem(item) || !this.isAutoHeightEnabled(item)) {
93307
+ return;
93308
+ }
93309
+ if (!Number.isFinite(height) || height <= 0) {
92679
93310
  return;
92680
93311
  }
92681
- if (!Number.isFinite(height) || height <= 0 || Math.abs(height - item.property.height) <= AUTO_HEIGHT_EPSILON) {
93312
+ var nextHeight = Math.ceil(this.getAutoHeightItemHeight(item, height));
93313
+ if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
92682
93314
  return;
92683
93315
  }
92684
- this.options.setCardItemHeight(id, Math.ceil(height));
93316
+ this.options.setCardItemHeight(id, nextHeight);
93317
+ };
93318
+ _proto.getAutoHeightItemHeight = function getAutoHeightItemHeight(item, contentHeight) {
93319
+ if (!isCardItem(item) || this.isAutoScaleEnabled(item)) {
93320
+ return contentHeight;
93321
+ }
93322
+ var scaleOverlay = this.state.contentScaleElements.get(item.id);
93323
+ var displayedHeight = scaleOverlay ? Number.parseFloat(scaleOverlay.style.height) : 0;
93324
+ if (!Number.isFinite(displayedHeight) || displayedHeight <= 0 || item.property.height <= 0) {
93325
+ return contentHeight;
93326
+ }
93327
+ return contentHeight / displayedHeight * item.property.height;
93328
+ };
93329
+ _proto.isAutoHeightEnabled = function isAutoHeightEnabled(item) {
93330
+ var _this_options_resolveCardTypeConfig;
93331
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeight) === true;
93332
+ };
93333
+ _proto.isAutoScaleEnabled = function isAutoScaleEnabled(item) {
93334
+ var _this_options_resolveCardTypeConfig;
93335
+ if (!isCardItem(item)) {
93336
+ return true;
93337
+ }
93338
+ return ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoScale) !== false;
92685
93339
  };
93340
+ _create_class(HTMLOverlayManager, [
93341
+ {
93342
+ key: "layerElement",
93343
+ get: function get() {
93344
+ return this.state.layer;
93345
+ }
93346
+ }
93347
+ ]);
92686
93348
  return HTMLOverlayManager;
92687
93349
  }();
92688
93350
  function waitForCardCaptureReady(root) {
@@ -92724,6 +93386,17 @@ function waitForCardCaptureReady(root) {
92724
93386
  });
92725
93387
  })();
92726
93388
  }
93389
+ function formatCssColor(color, alpha) {
93390
+ var normalizedColor = Math.max(0, Math.min(0xFFFFFF, Math.round(color)));
93391
+ var red = normalizedColor >> 16 & 0xFF;
93392
+ var green = normalizedColor >> 8 & 0xFF;
93393
+ var blue = normalizedColor & 0xFF;
93394
+ return "rgba(" + red + ", " + green + ", " + blue + ", " + formatCssNumber(alpha) + ")";
93395
+ }
93396
+ function formatCssNumber(value) {
93397
+ var normalized = Number.isFinite(value) ? value : 0;
93398
+ return Number(normalized.toFixed(6)).toString();
93399
+ }
92727
93400
  function nextAnimationFrame() {
92728
93401
  return new Promise(function(resolve) {
92729
93402
  requestAnimationFrame(function() {
@@ -93142,6 +93815,9 @@ function createFlattenedContent(target, frameStyle, ownerDocument) {
93142
93815
  });
93143
93816
  return replacement;
93144
93817
  }
93818
+ function isMouseEventInsideRect(event, rect) {
93819
+ return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
93820
+ }
93145
93821
  function createFlattenedIframeContent(iframe) {
93146
93822
  var doc = iframe.contentDocument;
93147
93823
  if (!doc) {
@@ -93181,6 +93857,19 @@ function withTimeout(promise, timeout) {
93181
93857
  });
93182
93858
  }
93183
93859
 
93860
+ function orderSDKCanvasLayers(param) {
93861
+ var container = param.container, playerContainer = param.playerContainer, htmlOverlayLayer = param.htmlOverlayLayer, gestureCanvas = param.gestureCanvas;
93862
+ [
93863
+ playerContainer,
93864
+ htmlOverlayLayer,
93865
+ gestureCanvas
93866
+ ].forEach(function(layer) {
93867
+ if ((layer == null ? void 0 : layer.parentElement) === container) {
93868
+ container.appendChild(layer);
93869
+ }
93870
+ });
93871
+ }
93872
+
93184
93873
  var HTML_CARD_EDITING_VIEWPORT_PADDING = 48;
93185
93874
  var SDK = /*#__PURE__*/ function() {
93186
93875
  function SDK(container, mode) {
@@ -93286,9 +93975,45 @@ var SDK = /*#__PURE__*/ function() {
93286
93975
  propertyName: 'height',
93287
93976
  propertyValue: height
93288
93977
  });
93978
+ },
93979
+ getSelectedItemIds: function getSelectedItemIds() {
93980
+ var _ref;
93981
+ var _this__pageData;
93982
+ return (_ref = (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.selectedItems) != null ? _ref : [];
93983
+ },
93984
+ getPreSelectedItemId: function getPreSelectedItemId() {
93985
+ var _this__pageData;
93986
+ return (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.preSelectedItem;
93987
+ },
93988
+ getSelectionEdgeStyle: function getSelectionEdgeStyle() {
93989
+ var _SDK_config_gestureHandlerConfig_transformGizmoConfig = SDK.config.gestureHandlerConfig.transformGizmoConfig, wireframeColor = _SDK_config_gestureHandlerConfig_transformGizmoConfig.wireframeColor, wireframeAlpha = _SDK_config_gestureHandlerConfig_transformGizmoConfig.wireframeAlpha, wireframeWidth = _SDK_config_gestureHandlerConfig_transformGizmoConfig.wireframeWidth;
93990
+ return {
93991
+ color: wireframeColor,
93992
+ alpha: wireframeAlpha,
93993
+ width: wireframeWidth
93994
+ };
93995
+ },
93996
+ getPreSelectionEdgeStyle: function getPreSelectionEdgeStyle() {
93997
+ var _SDK_config_gestureHandlerConfig_selectorGizmoConfig = SDK.config.gestureHandlerConfig.selectorGizmoConfig, preSelectedColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedColor, preSelectedWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedWidth;
93998
+ return {
93999
+ color: preSelectedColor,
94000
+ alpha: 1,
94001
+ width: preSelectedWidth
94002
+ };
94003
+ },
94004
+ getCanvasEventTarget: function getCanvasEventTarget() {
94005
+ var _this__gestureHandler;
94006
+ return (_this__gestureHandler = _this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view;
94007
+ },
94008
+ resolveCardHTML: function resolveCardHTML(item) {
94009
+ return isCardItem(item) ? _this.resolveCardHTML(item) : undefined;
94010
+ },
94011
+ resolveCardTypeConfig: function resolveCardTypeConfig(item) {
94012
+ return isCardItem(item) ? _this.resolveCardTypeConfig(item) : undefined;
93289
94013
  }
93290
94014
  });
93291
94015
  this._htmlOverlayManager.attach();
94016
+ this.syncCanvasLayerOrder();
93292
94017
  }
93293
94018
  var _proto = SDK.prototype;
93294
94019
  _proto.dispose = function dispose() {
@@ -93384,6 +94109,7 @@ var SDK = /*#__PURE__*/ function() {
93384
94109
  this.initPlayer(SDK.config.mode);
93385
94110
  this._pageDataUtils = new PageDataUtils(this.player, this._playerContainer, this._eventEmitter, this);
93386
94111
  this._gestureHandler = new GestureHandler(this._container);
94112
+ this.syncCanvasLayerOrder();
93387
94113
  return [
93388
94114
  4,
93389
94115
  this.runByPageData(this.pageData)
@@ -93433,6 +94159,16 @@ var SDK = /*#__PURE__*/ function() {
93433
94159
  env: 'editor'
93434
94160
  });
93435
94161
  this.player.resize();
94162
+ this.syncCanvasLayerOrder();
94163
+ };
94164
+ _proto.syncCanvasLayerOrder = function syncCanvasLayerOrder() {
94165
+ var _this__htmlOverlayManager, _this__gestureHandler;
94166
+ orderSDKCanvasLayers({
94167
+ container: this._container,
94168
+ playerContainer: this._playerContainer,
94169
+ htmlOverlayLayer: (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.layerElement,
94170
+ gestureCanvas: (_this__gestureHandler = this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view
94171
+ });
93436
94172
  };
93437
94173
  _proto.getInitParam = function getInitParam(param) {
93438
94174
  return _async_to_generator(function() {
@@ -94527,8 +95263,7 @@ var SDK = /*#__PURE__*/ function() {
94527
95263
  * @param ignoreClamp 是否忽视约束
94528
95264
  */ _proto.setPageZoom = function setPageZoom(zoom, center, ignoreClamp) {
94529
95265
  EFFECTS.assertExist(this._pageData);
94530
- this._pageData.property.zoom = zoom;
94531
- this._pageDataUtils.setPageZoom(this._pageData.property.zoom, center, ignoreClamp);
95266
+ this._pageDataUtils.setPageZoom(zoom, center, ignoreClamp);
94532
95267
  this._gestureHandler.render();
94533
95268
  };
94534
95269
  /**
@@ -95424,6 +96159,44 @@ var SDK = /*#__PURE__*/ function() {
95424
96159
  });
95425
96160
  };
95426
96161
  /**
96162
+ * @description 按 cardType 从注册表解析卡片的 HTML 渲染配置。
96163
+ * @param item 卡片元素
96164
+ * @returns HTML 渲染配置
96165
+ */ _proto.resolveCardHTML = function resolveCardHTML(item) {
96166
+ var _cardTypeConfig_html;
96167
+ var cardTypeConfig = this.resolveCardTypeConfig(item);
96168
+ return cardTypeConfig == null ? void 0 : (_cardTypeConfig_html = cardTypeConfig.html) == null ? void 0 : _cardTypeConfig_html.call(cardTypeConfig, item);
96169
+ };
96170
+ /**
96171
+ * @description 按 cardType 从注册表解析卡片类型配置。
96172
+ * @param item 卡片元素
96173
+ * @returns 卡片类型配置
96174
+ */ _proto.resolveCardTypeConfig = function resolveCardTypeConfig(item) {
96175
+ return SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96176
+ return t.type === item.cardType;
96177
+ });
96178
+ };
96179
+ /**
96180
+ * @description 重新解析并挂载指定卡片的 HTML 内容。
96181
+ * @description 当 inline/document 内容依赖 extension 或外部状态变化时,可调用此方法刷新 DOM。
96182
+ * @param id 卡片元素 ID
96183
+ * @returns 是否成功触发刷新
96184
+ */ _proto.refreshCardHTML = function refreshCardHTML(id) {
96185
+ var _this__htmlOverlayManager, _this__htmlOverlayManager1;
96186
+ var item = this.getSDKItem(id);
96187
+ if (!isCardItem(item)) {
96188
+ console.warn('CardItem "' + id + '" not found.');
96189
+ return false;
96190
+ }
96191
+ if (!this.resolveCardHTML(item)) {
96192
+ console.warn('CardItem "' + id + '" has no registered HTML renderer.');
96193
+ return false;
96194
+ }
96195
+ (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.invalidateCardHTML(id);
96196
+ (_this__htmlOverlayManager1 = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager1.scheduleRender();
96197
+ return true;
96198
+ };
96199
+ /**
95427
96200
  * @description 创建卡片元素
95428
96201
  * @description 底层以透明 SpriteItem 形式渲染,支持 cardType 属性
95429
96202
  * @param createInfo 卡片创建信息
@@ -95718,8 +96491,8 @@ SDK.config = BaseConfig;
95718
96491
  _inherits(CardItem, BaseItem);
95719
96492
  function CardItem(options) {
95720
96493
  var _this;
95721
- var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
95722
- var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5, _SDK_config_itemConfig_cardConfig_cardTypes_, _options_property6, _options_property7;
96494
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
96495
+ var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5;
95723
96496
  _this = BaseItem.call(this, options) || this, /**
95724
96497
  * @description 元素类型
95725
96498
  */ _this.type = SDKItemType.CARD;
@@ -95740,9 +96513,7 @@ SDK.config = BaseConfig;
95740
96513
  1,
95741
96514
  1
95742
96515
  ],
95743
- cardType: (_ref5 = (_ref6 = (_options_property5 = options.property) == null ? void 0 : _options_property5.cardType) != null ? _ref6 : (_SDK_config_itemConfig_cardConfig_cardTypes_ = SDK.config.itemConfig.cardConfig.cardTypes[0]) == null ? void 0 : _SDK_config_itemConfig_cardConfig_cardTypes_.type) != null ? _ref5 : '',
95744
- autoHeight: (_options_property6 = options.property) == null ? void 0 : _options_property6.autoHeight,
95745
- html: (_options_property7 = options.property) == null ? void 0 : _options_property7.html
96516
+ cardType: (_ref5 = (_options_property5 = options.property) == null ? void 0 : _options_property5.cardType) != null ? _ref5 : 'unknown'
95746
96517
  };
95747
96518
  return _this;
95748
96519
  }
@@ -95753,22 +96524,18 @@ SDK.config = BaseConfig;
95753
96524
  * @param withParent 是否包含父节点ID
95754
96525
  */ _proto.toCreateInfo = function toCreateInfo(withParent) {
95755
96526
  var extension = this.getAllExtension();
95756
- var property = deepClone(this.property);
95757
- property.html = this.html;
95758
96527
  return {
95759
96528
  type: SDKItemType.CARD,
95760
96529
  id: this.id,
95761
96530
  name: this.name,
95762
96531
  parentId: withParent ? this.parentId : undefined,
95763
96532
  extension: Object.keys(extension).length > 0 ? extension : undefined,
95764
- property: property
96533
+ property: deepClone(this.property)
95765
96534
  };
95766
96535
  };
95767
96536
  /**
95768
96537
  * @description 克隆 SDKItem
95769
96538
  */ _proto.clone = function clone() {
95770
- var property = deepClone(this.property);
95771
- property.html = this.html;
95772
96539
  return new CardItem({
95773
96540
  id: EFFECTS.generateGUID(),
95774
96541
  name: this.name,
@@ -95778,7 +96545,7 @@ SDK.config = BaseConfig;
95778
96545
  endBehavior: this.endBehavior,
95779
96546
  isLocked: this.isLocked,
95780
96547
  isCoreEditable: this.isCoreEditable,
95781
- property: property,
96548
+ property: deepClone(this.property),
95782
96549
  extension: this.getAllExtension()
95783
96550
  });
95784
96551
  };
@@ -95795,17 +96562,6 @@ SDK.config = BaseConfig;
95795
96562
  this.property.cardType = value;
95796
96563
  }
95797
96564
  },
95798
- {
95799
- key: "html",
95800
- get: /**
95801
- * @description HTML 覆盖层配置
95802
- */ function get() {
95803
- return this.property.html;
95804
- },
95805
- set: function set(value) {
95806
- this.property.html = value;
95807
- }
95808
- },
95809
96565
  {
95810
96566
  key: "position",
95811
96567
  get: // ==================== 便捷访问器 ====================
@@ -95818,6 +96574,16 @@ SDK.config = BaseConfig;
95818
96574
  this.property.position = value;
95819
96575
  }
95820
96576
  },
96577
+ {
96578
+ key: "isAutoScale",
96579
+ get: function get() {
96580
+ var _this = this;
96581
+ var config = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96582
+ return t.type === _this.cardType;
96583
+ });
96584
+ return !!(config == null ? void 0 : config.autoScale);
96585
+ }
96586
+ },
95821
96587
  {
95822
96588
  key: "width",
95823
96589
  get: /**