@vvfx/sdk 0.2.2-beta.1 → 0.2.2-beta.12

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 +960 -204
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +960 -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 +2 -2
  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.2-beta.1
6
+ * Version: v0.2.2-beta.12
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 isSingleAutoFitContentCardItem = selectedItems.length === 1 && selectedItem && isCardItem(selectedItem) && !selectedItem.isAutoScale;
55364
+ var isShiftLockScale = selectedItem && selectedItems.length === 1 && (isFrameItem(selectedItem) || isSingleAutoFitContentCardItem) ? !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,23 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55433
55435
  newWidth,
55434
55436
  newHeight
55435
55437
  ], translation1);
55438
+ } else if (isSingleAutoFitContentCardItem && selectedItem && isCardItem(selectedItem)) {
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
+ });
55436
55455
  } else {
55437
55456
  // 普通元素的缩放逻辑
55438
55457
  selectedItems.forEach(function(item) {
@@ -55757,6 +55776,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55757
55776
  var selectedItems = this._pageDataUtils.getSelectedItems();
55758
55777
  var isTemplateMode = SDK.config.mode === 'template';
55759
55778
  var selectedItem = selectedItems.length === 1 ? selectedItems[0] : undefined;
55779
+ var isSingleCardItem = isCardItem(selectedItem);
55760
55780
  var isGeneratorItem = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.GENERATOR;
55761
55781
  var isAutoLayoutFrame = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.FRAME && (selectedItem == null ? void 0 : selectedItem.layoutMode) === FrameLayoutMode.AUTO;
55762
55782
  var canScale = selectedItems.length === 1 && (selectedItem == null ? void 0 : selectedItem.type) !== SDKItemType.GROUP && !isAutoLayoutFrame && !isGeneratorItem;
@@ -55796,9 +55816,11 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55796
55816
  this.wireframe.totalBox.copyFrom(box).expandByScalar(totalBoxExpandScalar);
55797
55817
  // 根据box获取边缘线
55798
55818
  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
- });
55819
+ if (!isSingleCardItem) {
55820
+ corners.forEach(function(corner, i) {
55821
+ _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55822
+ });
55823
+ }
55802
55824
  var _SDK_config_gestureHandlerConfig_transformGizmoConfig = SDK.config.gestureHandlerConfig.transformGizmoConfig, scaleCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.scaleCircleSize, rotationCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.rotationCircleSize;
55803
55825
  // 成组暂不支持缩放
55804
55826
  if (selectedItems.length === 1) {
@@ -59649,12 +59671,6 @@ var MAX_ITEM_DISTANCE_THRESHOLD = 100000;
59649
59671
  /**
59650
59672
  * @description SDKItem position 属性的数字精度(保留小数位数)
59651
59673
  */ 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
59674
  var PageDataUtils = /*#__PURE__*/ function() {
59659
59675
  function PageDataUtils(player, container, emitter, sdk) {
59660
59676
  this.player = player;
@@ -60472,11 +60488,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
60472
60488
  property: property
60473
60489
  }));
60474
60490
  } else if ((existingSDKItem == null ? void 0 : existingSDKItem.type) == SDKItemType.CARD) {
60475
- var cardType = existingSDKItem.cardType, html = existingSDKItem.html;
60491
+ var cardType = existingSDKItem.cardType;
60476
60492
  sdkItem = new CardItem(_extends({}, baseOptions, {
60477
60493
  property: _extends({}, property, {
60478
- cardType: cardType,
60479
- html: html
60494
+ cardType: cardType
60480
60495
  })
60481
60496
  }));
60482
60497
  } else {
@@ -60703,6 +60718,19 @@ var PageDataUtils = /*#__PURE__*/ function() {
60703
60718
  }).call(this);
60704
60719
  };
60705
60720
  /**
60721
+ * @description 设置元素extension字段
60722
+ */ _proto.setItemExtension = function setItemExtension(itemId, extension) {
60723
+ var item = this.getSDKItem(itemId);
60724
+ if (!item) {
60725
+ console.warn('setItemExtension: item not found');
60726
+ return;
60727
+ }
60728
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.entries(extension)), _step; !(_step = _iterator()).done;){
60729
+ var _step_value = _step.value, key = _step_value[0], value = _step_value[1];
60730
+ item.extension.set(key, value);
60731
+ }
60732
+ };
60733
+ /**
60706
60734
  * @description 场景 1: 设置单个元素的单个属性
60707
60735
  */ _proto.setSingleItemSingleProperty = function setSingleItemSingleProperty(param) {
60708
60736
  return _async_to_generator(function() {
@@ -61060,40 +61088,35 @@ var PageDataUtils = /*#__PURE__*/ function() {
61060
61088
  3,
61061
61089
  31
61062
61090
  ];
61063
- case 'html':
61064
- return [
61065
- 3,
61066
- 32
61067
- ];
61068
61091
  case 'position':
61069
61092
  return [
61070
61093
  3,
61071
- 33
61094
+ 32
61072
61095
  ];
61073
61096
  case 'rotation':
61074
61097
  return [
61075
61098
  3,
61076
- 34
61099
+ 33
61077
61100
  ];
61078
61101
  case 'scale':
61079
61102
  return [
61080
61103
  3,
61081
- 35
61104
+ 34
61082
61105
  ];
61083
61106
  case 'layoutMode':
61084
61107
  return [
61085
61108
  3,
61086
- 36
61109
+ 35
61087
61110
  ];
61088
61111
  case 'visible':
61089
61112
  return [
61090
61113
  3,
61091
- 37
61114
+ 36
61092
61115
  ];
61093
61116
  }
61094
61117
  return [
61095
61118
  3,
61096
- 38
61119
+ 37
61097
61120
  ];
61098
61121
  case 1:
61099
61122
  {
@@ -61106,7 +61129,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61106
61129
  }
61107
61130
  return [
61108
61131
  3,
61109
- 39
61132
+ 38
61110
61133
  ];
61111
61134
  }
61112
61135
  case 2:
@@ -61117,7 +61140,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61117
61140
  }
61118
61141
  return [
61119
61142
  3,
61120
- 39
61143
+ 38
61121
61144
  ];
61122
61145
  }
61123
61146
  case 3:
@@ -61149,7 +61172,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61149
61172
  case 5:
61150
61173
  return [
61151
61174
  3,
61152
- 39
61175
+ 38
61153
61176
  ];
61154
61177
  case 6:
61155
61178
  {
@@ -61166,7 +61189,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61166
61189
  }
61167
61190
  return [
61168
61191
  3,
61169
- 39
61192
+ 38
61170
61193
  ];
61171
61194
  }
61172
61195
  case 7:
@@ -61180,7 +61203,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61180
61203
  }
61181
61204
  return [
61182
61205
  3,
61183
- 39
61206
+ 38
61184
61207
  ];
61185
61208
  }
61186
61209
  case 8:
@@ -61193,7 +61216,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61193
61216
  }
61194
61217
  return [
61195
61218
  3,
61196
- 39
61219
+ 38
61197
61220
  ];
61198
61221
  }
61199
61222
  case 9:
@@ -61207,7 +61230,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61207
61230
  }
61208
61231
  return [
61209
61232
  3,
61210
- 39
61233
+ 38
61211
61234
  ];
61212
61235
  }
61213
61236
  case 10:
@@ -61220,7 +61243,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61220
61243
  }
61221
61244
  return [
61222
61245
  3,
61223
- 39
61246
+ 38
61224
61247
  ];
61225
61248
  }
61226
61249
  case 11:
@@ -61233,7 +61256,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61233
61256
  }
61234
61257
  return [
61235
61258
  3,
61236
- 39
61259
+ 38
61237
61260
  ];
61238
61261
  }
61239
61262
  case 12:
@@ -61253,7 +61276,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61253
61276
  }
61254
61277
  return [
61255
61278
  3,
61256
- 39
61279
+ 38
61257
61280
  ];
61258
61281
  }
61259
61282
  case 13:
@@ -61295,7 +61318,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61295
61318
  }
61296
61319
  return [
61297
61320
  3,
61298
- 39
61321
+ 38
61299
61322
  ];
61300
61323
  }
61301
61324
  case 14:
@@ -61330,7 +61353,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61330
61353
  }
61331
61354
  return [
61332
61355
  3,
61333
- 39
61356
+ 38
61334
61357
  ];
61335
61358
  }
61336
61359
  case 15:
@@ -61344,7 +61367,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61344
61367
  }
61345
61368
  return [
61346
61369
  3,
61347
- 39
61370
+ 38
61348
61371
  ];
61349
61372
  }
61350
61373
  case 16:
@@ -61376,7 +61399,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61376
61399
  case 20:
61377
61400
  return [
61378
61401
  3,
61379
- 39
61402
+ 38
61380
61403
  ];
61381
61404
  case 21:
61382
61405
  if (!(typeof propertyValue === 'string' && playerItem.type === EFFECTS.spec.ItemType.video)) return [
@@ -61407,7 +61430,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61407
61430
  case 25:
61408
61431
  return [
61409
61432
  3,
61410
- 39
61433
+ 38
61411
61434
  ];
61412
61435
  case 26:
61413
61436
  if (!(playerItem.type === EFFECTS.spec.ItemType.null)) return [
@@ -61452,7 +61475,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61452
61475
  case 28:
61453
61476
  return [
61454
61477
  3,
61455
- 39
61478
+ 38
61456
61479
  ];
61457
61480
  case 29:
61458
61481
  {
@@ -61464,7 +61487,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61464
61487
  }
61465
61488
  return [
61466
61489
  3,
61467
- 39
61490
+ 38
61468
61491
  ];
61469
61492
  }
61470
61493
  case 30:
@@ -61477,7 +61500,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61477
61500
  }
61478
61501
  return [
61479
61502
  3,
61480
- 39
61503
+ 38
61481
61504
  ];
61482
61505
  }
61483
61506
  case 31:
@@ -61490,20 +61513,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61490
61513
  }
61491
61514
  return [
61492
61515
  3,
61493
- 39
61516
+ 38
61494
61517
  ];
61495
61518
  }
61496
61519
  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
61520
  {
61508
61521
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61509
61522
  pixelTranslation = propertyValue.map(function(v, i) {
@@ -61516,10 +61529,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61516
61529
  }
61517
61530
  return [
61518
61531
  3,
61519
- 39
61532
+ 38
61520
61533
  ];
61521
61534
  }
61522
- case 34:
61535
+ case 33:
61523
61536
  {
61524
61537
  if (Array.isArray(propertyValue) && propertyValue.length === 3) {
61525
61538
  rotation = propertyValue.map(function(v, i) {
@@ -61530,10 +61543,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61530
61543
  }
61531
61544
  return [
61532
61545
  3,
61533
- 39
61546
+ 38
61534
61547
  ];
61535
61548
  }
61536
- case 35:
61549
+ case 34:
61537
61550
  {
61538
61551
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61539
61552
  currentScale = targetItem.property.scale;
@@ -61547,10 +61560,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61547
61560
  }
61548
61561
  return [
61549
61562
  3,
61550
- 39
61563
+ 38
61551
61564
  ];
61552
61565
  }
61553
- case 36:
61566
+ case 35:
61554
61567
  {
61555
61568
  if (propertyValue === FrameLayoutMode.AUTO || propertyValue === FrameLayoutMode.FREE) {
61556
61569
  frameComponent = playerItem.getComponent(EFFECTS.FrameComponent);
@@ -61560,10 +61573,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61560
61573
  }
61561
61574
  return [
61562
61575
  3,
61563
- 39
61576
+ 38
61564
61577
  ];
61565
61578
  }
61566
- case 37:
61579
+ case 36:
61567
61580
  {
61568
61581
  if (typeof propertyValue === 'boolean') {
61569
61582
  playerItem.setVisible(propertyValue);
@@ -61576,10 +61589,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61576
61589
  }
61577
61590
  return [
61578
61591
  3,
61579
- 39
61592
+ 38
61580
61593
  ];
61581
61594
  }
61582
- case 38:
61595
+ case 37:
61583
61596
  {
61584
61597
  console.log('ignore property name ', propertyName);
61585
61598
  // 对于未明确处理的属性,尝试直接设置到 property 对象
@@ -61587,8 +61600,8 @@ var PageDataUtils = /*#__PURE__*/ function() {
61587
61600
  targetItem.property[propertyName] = propertyValue;
61588
61601
  }
61589
61602
  }
61590
- _state.label = 39;
61591
- case 39:
61603
+ _state.label = 38;
61604
+ case 38:
61592
61605
  // 非位置属性需要刷新播放器
61593
61606
  // template 模式下保持暂停态以避免播放器自动播放,editor 模式继续推进
61594
61607
  if (![
@@ -62468,6 +62481,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
62468
62481
  }
62469
62482
  break;
62470
62483
  }
62484
+ case 'cardType':
62485
+ {
62486
+ break;
62487
+ }
62471
62488
  default:
62472
62489
  {
62473
62490
  console.warn("Target property " + propertyName + " can not be changed.");
@@ -63060,12 +63077,15 @@ var PageDataUtils = /*#__PURE__*/ function() {
63060
63077
  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
63078
  1,
63062
63079
  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;
63080
+ ] : _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
63081
  // 校验 cardType 是否已在配置中注册
63082
+ var cardTypeConfig = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
63083
+ return t.type === cardType;
63084
+ });
63065
63085
  var registeredTypes = SDK.config.itemConfig.cardConfig.cardTypes.map(function(t) {
63066
63086
  return t.type;
63067
63087
  });
63068
- if (!registeredTypes.includes(cardType)) {
63088
+ if (!cardTypeConfig) {
63069
63089
  console.warn('CardItem cardType "' + cardType + '" is not registered. Registered types: ' + registeredTypes.join(', '));
63070
63090
  return;
63071
63091
  }
@@ -63109,9 +63129,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
63109
63129
  width: width,
63110
63130
  height: height,
63111
63131
  scale: [].concat(scale),
63112
- cardType: cardType,
63113
- autoHeight: autoHeight,
63114
- html: html
63132
+ cardType: cardType
63115
63133
  },
63116
63134
  extension: extension
63117
63135
  });
@@ -64493,8 +64511,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
64493
64511
  scalar.y
64494
64512
  ],
64495
64513
  rotation: [].concat(rotation),
64496
- position: [].concat(resultPosition),
64497
- html: sdkItem.html
64514
+ position: [].concat(resultPosition)
64498
64515
  },
64499
64516
  extension: extension
64500
64517
  };
@@ -65540,7 +65557,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
65540
65557
  _this = this;
65541
65558
  changeProeprty = function changeProeprty(targetCreateInfo) {
65542
65559
  return _async_to_generator(function() {
65543
- var currentCreateInfo;
65560
+ var currentCreateInfo, itemId;
65544
65561
  return _ts_generator(this, function(_state) {
65545
65562
  switch(_state.label){
65546
65563
  case 0:
@@ -65551,16 +65568,20 @@ var PageDataUtils = /*#__PURE__*/ function() {
65551
65568
  2
65552
65569
  ];
65553
65570
  }
65571
+ itemId = targetCreateInfo.id;
65554
65572
  return [
65555
65573
  4,
65556
65574
  this.setItemProperty({
65557
- itemId: currentCreateInfo.id,
65575
+ itemId: itemId,
65558
65576
  type: currentCreateInfo.type,
65559
65577
  property: targetCreateInfo.property
65560
65578
  })
65561
65579
  ];
65562
65580
  case 1:
65563
65581
  _state.sent();
65582
+ if (targetCreateInfo.extension) {
65583
+ this.setItemExtension(itemId, targetCreateInfo.extension);
65584
+ }
65564
65585
  return [
65565
65586
  2
65566
65587
  ];
@@ -65878,35 +65899,56 @@ var PageDataUtils = /*#__PURE__*/ function() {
65878
65899
  };
65879
65900
  _proto.asyncAddItemByCreateInfos = function asyncAddItemByCreateInfos(createInfos) {
65880
65901
  return _async_to_generator(function() {
65881
- var _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, createInfo, id, type, url, textureId, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65902
+ var _loop, _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65882
65903
  return _ts_generator(this, function(_state) {
65883
65904
  switch(_state.label){
65884
65905
  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, {
65906
+ _loop = function() {
65907
+ var createInfo = _step.value;
65908
+ var _ref = function() {
65909
+ switch(createInfo.type){
65910
+ case SDKItemType.SPRITE:
65911
+ {
65912
+ return {
65913
+ url: createInfo.property.image,
65914
+ type: 'image'
65915
+ };
65916
+ }
65917
+ case SDKItemType.VIDEO:
65918
+ {
65919
+ return {
65920
+ url: createInfo.property.video,
65921
+ type: 'video'
65922
+ };
65923
+ }
65924
+ default:
65925
+ {
65926
+ return {};
65927
+ }
65928
+ }
65929
+ }(), url = _ref.url, type = _ref.type;
65930
+ if (url && type) {
65931
+ var textureId = EFFECTS.generateGUID();
65932
+ itemToTextureInfo.set(createInfo.id, {
65901
65933
  id: textureId,
65902
65934
  url: url,
65903
- type: type === SDKItemType.SPRITE ? 'image' : 'video'
65935
+ type: type
65904
65936
  });
65905
65937
  Object.assign(createInfo, {
65906
65938
  textureId: textureId
65907
65939
  });
65908
65940
  }
65909
- }
65941
+ };
65942
+ _this = this;
65943
+ createInfoWithIds = createInfos.map(function(createInfo) {
65944
+ var _createInfo_id;
65945
+ return Object.assign({}, createInfo, {
65946
+ id: (_createInfo_id = createInfo.id) != null ? _createInfo_id : EFFECTS.generateGUID()
65947
+ });
65948
+ });
65949
+ itemToTextureInfo = new Map();
65950
+ // 预处理所有 createInfo,分配 textureId
65951
+ for(_iterator = _create_for_of_iterator_helper_loose(createInfoWithIds); !(_step = _iterator()).done;)_loop();
65910
65952
  // 并行创建所有 item
65911
65953
  toAddedCreateInfo = createInfoWithIds.filter(function(createInfo) {
65912
65954
  return ![
@@ -66875,6 +66917,51 @@ var PageDataUtils = /*#__PURE__*/ function() {
66875
66917
  * @param id 元素id
66876
66918
  * @param size 目标大小 [width, height]
66877
66919
  * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66920
+ */ _proto.resizeCardItem = function resizeCardItem(id, size, translation) {
66921
+ var _frameController_children;
66922
+ var frameItem = this.getSDKItem(id);
66923
+ if (!frameItem) {
66924
+ return;
66925
+ }
66926
+ var newWidth = size[0], newHeight = size[1];
66927
+ // const originalWidth = frameItem.property.width
66928
+ // 计算世界尺寸(供后续使用)
66929
+ var viewSize = this.interactionUtils.getViewSizeByPixelSize(new Vector2(newWidth, newHeight));
66930
+ var worldSize = this.interactionUtils.getWorldSizeByViewSize(viewSize).abs();
66931
+ // 1 更新 Player 层的预合成和子元素
66932
+ // 1.1 更新 Player Item(空节点控制器)的大小
66933
+ var frameController = this.getPlayerItemById(id);
66934
+ if (frameController) {
66935
+ frameController.transform.setSize(worldSize.x, worldSize.y);
66936
+ // 如果有位移,更新位置
66937
+ if (translation && (translation.x !== 0 || translation.y !== 0)) {
66938
+ var currentPosition = frameController.transform.position;
66939
+ frameController.setPosition(currentPosition.x + translation.x, currentPosition.y + translation.y, currentPosition.z);
66940
+ }
66941
+ }
66942
+ // 1.2 更新 Player Children Item 的大小
66943
+ var subCompositionItem = frameController == null ? void 0 : (_frameController_children = frameController.children) == null ? void 0 : _frameController_children[0];
66944
+ if (subCompositionItem && translation) {
66945
+ // 更新子元素
66946
+ subCompositionItem.children.forEach(function(item) {
66947
+ var _item;
66948
+ var _item_transform_getParentMatrix;
66949
+ var parentMatrix = new Matrix4().copyFrom((_item_transform_getParentMatrix = item.transform.getParentMatrix()) != null ? _item_transform_getParentMatrix : new Matrix4());
66950
+ parentMatrix.setPosition(new Vector3());
66951
+ var result = translation.clone().applyMatrix(parentMatrix.invert()).negate();
66952
+ (_item = item).translate.apply(_item, [].concat(result.toArray()));
66953
+ item.transform.updateLocalMatrix();
66954
+ });
66955
+ }
66956
+ // 2: 刷新 SDKItem 数据
66957
+ // 更新 FrameItem 的 property
66958
+ this.refreshSDKItem(frameItem.id);
66959
+ };
66960
+ /**
66961
+ * @description 修改画板元素大小
66962
+ * @param id 元素id
66963
+ * @param size 目标大小 [width, height]
66964
+ * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66878
66965
  */ _proto.resizeFrameItem = function resizeFrameItem(id, size, translation) {
66879
66966
  var _this = this;
66880
66967
  var _frameController_children;
@@ -83079,43 +83166,12 @@ var BaseConfig = {
83079
83166
  },
83080
83167
  cardConfig: {
83081
83168
  backgroundColor: [
83082
- 0.6,
83083
- 0.6,
83084
- 0.6,
83085
- 0.12
83169
+ 1,
83170
+ 1,
83171
+ 1,
83172
+ 0
83086
83173
  ],
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
- ]
83174
+ cardTypes: []
83119
83175
  }
83120
83176
  }
83121
83177
  };
@@ -91444,11 +91500,18 @@ function isCardHTMLAutoHeightMessage(data, id) {
91444
91500
  var message = data;
91445
91501
  return message.source === 'vvfx-card-html-auto-height' && message.id === id && typeof message.height === 'number';
91446
91502
  }
91503
+ function requestCardHTMLAutoHeight(iframe, id) {
91504
+ var _iframe_contentWindow;
91505
+ (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage({
91506
+ source: 'vvfx-card-html-auto-height-request',
91507
+ id: id
91508
+ }, '*');
91509
+ }
91447
91510
  function withCardHTMLAutoHeightBridge(html, id) {
91448
91511
  if (!id) {
91449
91512
  return html;
91450
91513
  }
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>";
91514
+ 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
91515
  if (/<\/body>/i.test(html)) {
91453
91516
  return html.replace(/<\/body>/i, "" + script + "</body>");
91454
91517
  }
@@ -91721,30 +91784,38 @@ function syncElementStackOrder(_container, elements) {
91721
91784
  });
91722
91785
  }
91723
91786
 
91724
- function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY) {
91787
+ function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, _autoScale) {
91725
91788
  if (offsetX === void 0) offsetX = 0;
91726
91789
  if (offsetY === void 0) offsetY = 0;
91727
91790
  if (box.corners.length === 4 && width > 0 && height > 0) {
91728
91791
  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;
91792
+ var contentWidth = width;
91793
+ var contentHeight = height;
91794
+ var a = (rightTop.x - leftTop.x) / contentWidth;
91795
+ var b = (rightTop.y - leftTop.y) / contentWidth;
91796
+ var c = (leftBottom.x - leftTop.x) / contentHeight;
91797
+ var d = (leftBottom.y - leftTop.y) / contentHeight;
91733
91798
  var e = leftTop.x - offsetX;
91734
91799
  var f = leftTop.y - offsetY;
91735
91800
  return {
91736
91801
  left: '0px',
91737
91802
  top: '0px',
91738
- width: "" + width + "px",
91739
- height: "" + height + "px",
91803
+ width: "" + formatPixelNumber(contentWidth) + "px",
91804
+ height: "" + formatPixelNumber(contentHeight) + "px",
91805
+ contentWidth: contentWidth,
91806
+ contentHeight: contentHeight,
91740
91807
  transform: "matrix(" + formatMatrixNumber(a) + ", " + formatMatrixNumber(b) + ", " + formatMatrixNumber(c) + ", " + formatMatrixNumber(d) + ", " + formatMatrixNumber(e) + ", " + formatMatrixNumber(f) + ")"
91741
91808
  };
91742
91809
  }
91810
+ var contentWidth1 = box.max.x - box.min.x;
91811
+ var contentHeight1 = box.max.y - box.min.y;
91743
91812
  return {
91744
91813
  left: "" + (box.min.x - offsetX) + "px",
91745
91814
  top: "" + (box.min.y - offsetY) + "px",
91746
- width: "" + (box.max.x - box.min.x) + "px",
91747
- height: "" + (box.max.y - box.min.y) + "px",
91815
+ width: "" + contentWidth1 + "px",
91816
+ height: "" + contentHeight1 + "px",
91817
+ contentWidth: contentWidth1,
91818
+ contentHeight: contentHeight1,
91748
91819
  transform: ''
91749
91820
  };
91750
91821
  }
@@ -91767,6 +91838,10 @@ function formatMatrixNumber(value) {
91767
91838
  var normalized = Object.is(value, -0) ? 0 : value;
91768
91839
  return Number(normalized.toFixed(6)).toString();
91769
91840
  }
91841
+ function formatPixelNumber(value) {
91842
+ var normalized = Object.is(value, -0) ? 0 : value;
91843
+ return Number(normalized.toFixed(6)).toString();
91844
+ }
91770
91845
 
91771
91846
  function mountHTMLShell(container, content, shell) {
91772
91847
  if (!shell) {
@@ -91787,6 +91862,26 @@ function mountHTMLShell(container, content, shell) {
91787
91862
 
91788
91863
  var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
91789
91864
  var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
91865
+ var CONTENT_INTERACTIVE_SELECTOR = [
91866
+ '[data-vvfx-html-interaction-zone="self"]',
91867
+ '[data-vvfx-html-interaction-zone="subtree"]',
91868
+ 'a[href]',
91869
+ 'button:not([disabled])',
91870
+ 'input:not([disabled])',
91871
+ 'textarea:not([disabled])',
91872
+ 'select:not([disabled])',
91873
+ 'summary',
91874
+ 'video[controls]',
91875
+ 'audio[controls]',
91876
+ '[contenteditable]:not([contenteditable="false"])',
91877
+ '[role="button"]',
91878
+ '[role="link"]',
91879
+ '[role="textbox"]',
91880
+ '[tabindex]:not([tabindex="-1"])'
91881
+ ].join(', ');
91882
+ var CONTENT_INTERACTION_NONE_SELECTOR = [
91883
+ '[data-vvfx-html-interaction-zone="none"]'
91884
+ ].join(', ');
91790
91885
  var EDITING_VIEWPORT_PADDING = 48;
91791
91886
  var EDITING_VIEWPORT_BOX_SCALE = 1.1;
91792
91887
  var AUTO_HEIGHT_EPSILON = 0.5;
@@ -91796,14 +91891,20 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91796
91891
  var _this = this;
91797
91892
  this.options = options;
91798
91893
  this.eventCleanups = [];
91894
+ this.htmlRootConfigCleanups = new WeakMap();
91799
91895
  this.state = {
91800
91896
  frameElements: new Map(),
91801
91897
  elements: new Map(),
91898
+ selectionElements: new Map(),
91802
91899
  contentScaleElements: new Map(),
91803
91900
  contentElements: new Map(),
91804
91901
  contentMountElements: new Map(),
91902
+ contentInteractionZones: new Map(),
91903
+ contentInteractionZoneCleanups: new Map(),
91904
+ contentInteractionResizeCleanups: new Map(),
91805
91905
  contents: new Map(),
91806
91906
  cleanups: new Map(),
91907
+ autoHeightModes: new Map(),
91807
91908
  autoHeightCleanups: new Map(),
91808
91909
  autoHeightFrames: new Map()
91809
91910
  };
@@ -91820,6 +91921,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91820
91921
  }
91821
91922
  return;
91822
91923
  }
91924
+ if (!_this.isEditableCard(targetId)) {
91925
+ return;
91926
+ }
91823
91927
  event.preventDefault();
91824
91928
  event.stopPropagation();
91825
91929
  _this.enterEditing(targetId);
@@ -91835,6 +91939,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91835
91939
  _this.exitEditing();
91836
91940
  };
91837
91941
  this.handleContainerMouseMove = function(event) {
91942
+ _this.scheduleActiveContentInteractionSync(event);
91838
91943
  var hoverShellInteractiveId = _this.getHoverShellInteractiveIdByEvent(event);
91839
91944
  if (_this.state.hoverShellInteractiveId === hoverShellInteractiveId) {
91840
91945
  return;
@@ -91848,7 +91953,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91848
91953
  _this.syncContentInteraction(hoverShellInteractiveId);
91849
91954
  }
91850
91955
  };
91851
- this.handleContainerMouseLeave = function() {
91956
+ this.handleContainerMouseLeave = function(event) {
91957
+ if (_this.isMouseLeaveWithinContainer(event)) {
91958
+ return;
91959
+ }
91960
+ if (_this.contentInteractionFrame !== undefined) {
91961
+ cancelAnimationFrame(_this.contentInteractionFrame);
91962
+ _this.contentInteractionFrame = undefined;
91963
+ }
91964
+ _this.pendingContentInteractionEvent = undefined;
91965
+ _this.setActiveContentInteraction(undefined);
91852
91966
  var previousId = _this.state.hoverShellInteractiveId;
91853
91967
  if (!previousId) {
91854
91968
  return;
@@ -91856,6 +91970,33 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91856
91970
  _this.state.hoverShellInteractiveId = undefined;
91857
91971
  _this.syncContentInteraction(previousId);
91858
91972
  };
91973
+ this.handleContainerContextMenu = function(event) {
91974
+ var activeInteraction = _this.state.activeContentInteraction;
91975
+ if (!activeInteraction || !_this.isEventInsideOverlay(activeInteraction.id, event) || _this.isHTMLContextMenuEvent(event)) {
91976
+ return;
91977
+ }
91978
+ var canvas = _this.options.getCanvasEventTarget == null ? void 0 : _this.options.getCanvasEventTarget.call(_this.options);
91979
+ if (!canvas) {
91980
+ return;
91981
+ }
91982
+ event.preventDefault();
91983
+ event.stopPropagation();
91984
+ _this.setActiveContentInteraction(undefined);
91985
+ canvas.dispatchEvent(new MouseEvent('contextmenu', {
91986
+ bubbles: true,
91987
+ cancelable: true,
91988
+ clientX: event.clientX,
91989
+ clientY: event.clientY,
91990
+ screenX: event.screenX,
91991
+ screenY: event.screenY,
91992
+ button: event.button,
91993
+ buttons: event.buttons,
91994
+ ctrlKey: event.ctrlKey,
91995
+ shiftKey: event.shiftKey,
91996
+ altKey: event.altKey,
91997
+ metaKey: event.metaKey
91998
+ }));
91999
+ };
91859
92000
  this.isAutoHeightMessage = isCardHTMLAutoHeightMessage;
91860
92001
  }
91861
92002
  var _proto = HTMLOverlayManager.prototype;
@@ -91869,7 +92010,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91869
92010
  layer.style.position = 'absolute';
91870
92011
  layer.style.inset = '0';
91871
92012
  layer.style.pointerEvents = 'none';
91872
- layer.style.zIndex = '1';
91873
92013
  container.appendChild(layer);
91874
92014
  this.state.layer = layer;
91875
92015
  this.initDOMEvents();
@@ -91882,16 +92022,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91882
92022
  cancelAnimationFrame(this.state.updateFrame);
91883
92023
  this.state.updateFrame = undefined;
91884
92024
  }
92025
+ if (this.contentInteractionFrame !== undefined) {
92026
+ cancelAnimationFrame(this.contentInteractionFrame);
92027
+ this.contentInteractionFrame = undefined;
92028
+ }
92029
+ this.pendingContentInteractionEvent = undefined;
91885
92030
  this.state.cleanups.forEach(function(cleanup) {
91886
92031
  cleanup();
91887
92032
  });
91888
92033
  this.state.frameElements.clear();
91889
92034
  this.state.elements.clear();
92035
+ this.state.selectionElements.clear();
91890
92036
  this.state.contentScaleElements.clear();
91891
92037
  this.state.contentElements.clear();
91892
92038
  this.state.contentMountElements.clear();
92039
+ this.state.contentInteractionZones.clear();
92040
+ this.state.contentInteractionZoneCleanups.forEach(function(cleanup) {
92041
+ cleanup();
92042
+ });
92043
+ this.state.contentInteractionZoneCleanups.clear();
92044
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92045
+ cleanup();
92046
+ });
92047
+ this.state.contentInteractionResizeCleanups.clear();
91893
92048
  this.state.contents.clear();
91894
92049
  this.state.cleanups.clear();
92050
+ this.state.autoHeightModes.clear();
91895
92051
  this.state.autoHeightCleanups.forEach(function(cleanup) {
91896
92052
  cleanup();
91897
92053
  });
@@ -91906,10 +92062,12 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91906
92062
  this.eventCleanups = [];
91907
92063
  (_this_state_layer = this.state.layer) == null ? void 0 : _this_state_layer.remove();
91908
92064
  this.state.layer = undefined;
92065
+ this.state.selectionLayer = undefined;
91909
92066
  this.options.container.removeEventListener('dblclick', this.handleContainerDoubleClick, true);
91910
92067
  this.options.container.removeEventListener('mousedown', this.handleContainerMouseDown, true);
91911
92068
  this.options.container.removeEventListener('mousemove', this.handleContainerMouseMove, true);
91912
92069
  this.options.container.removeEventListener('mouseleave', this.handleContainerMouseLeave, true);
92070
+ this.options.container.removeEventListener('contextmenu', this.handleContainerContextMenu, true);
91913
92071
  };
91914
92072
  _proto.scheduleRender = function scheduleRender() {
91915
92073
  var _this = this;
@@ -91921,6 +92079,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91921
92079
  _this.render();
91922
92080
  });
91923
92081
  };
92082
+ _proto.invalidateCardHTML = function invalidateCardHTML(id) {
92083
+ this.cleanupOverlayContent(id);
92084
+ this.invalidateContentInteractionZones(id);
92085
+ };
91924
92086
  _proto.rasterizeCard = function rasterizeCard(id, options) {
91925
92087
  return _async_to_generator(function() {
91926
92088
  var contentOverlay, capture, _ref, _options_pixelRatio, image, error;
@@ -92013,6 +92175,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92013
92175
  var events = [
92014
92176
  'pageDataChange',
92015
92177
  'selectedItemChange',
92178
+ 'preSelectedItemChange',
92016
92179
  'itemPropertyChange',
92017
92180
  'viewportTransform',
92018
92181
  'viewRebuildFinish'
@@ -92022,6 +92185,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92022
92185
  if (event === 'viewportTransform') {
92023
92186
  _this.handleViewportTransform();
92024
92187
  }
92188
+ _this.invalidateContentInteractionZones();
92025
92189
  _this.scheduleRender();
92026
92190
  });
92027
92191
  });
@@ -92031,6 +92195,24 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92031
92195
  this.options.container.addEventListener('mousedown', this.handleContainerMouseDown, true);
92032
92196
  this.options.container.addEventListener('mousemove', this.handleContainerMouseMove, true);
92033
92197
  this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
92198
+ this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
92199
+ };
92200
+ _proto.isMouseLeaveWithinContainer = function isMouseLeaveWithinContainer(event) {
92201
+ var relatedTarget = event.relatedTarget;
92202
+ if (!relatedTarget) {
92203
+ return false;
92204
+ }
92205
+ try {
92206
+ return this.options.container.contains(relatedTarget);
92207
+ } catch (unused) {
92208
+ return false;
92209
+ }
92210
+ };
92211
+ _proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
92212
+ if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
92213
+ return false;
92214
+ }
92215
+ return !!event.target.closest('[data-interaction-contextmenu="self"], [data-vvfx-html-contextmenu="self"]');
92034
92216
  };
92035
92217
  _proto.handleViewportTransform = function handleViewportTransform() {
92036
92218
  var editing = this.state.editing;
@@ -92050,11 +92232,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92050
92232
  }
92051
92233
  var items = this.options.getItems();
92052
92234
  var frameByChildId = this.renderFrameOverlays(items, layer);
92235
+ var selectionLayer = this.getOrCreateSelectionLayer(layer);
92053
92236
  var visibleCardIds = new Set();
92054
92237
  var editingVisible = false;
92055
92238
  items.forEach(function(item) {
92056
92239
  var _this_state_editing;
92057
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92240
+ if (!isCardItem(item) || !item.visible) {
92241
+ return;
92242
+ }
92243
+ var html = _this.options.resolveCardHTML(item);
92244
+ if (html === undefined) {
92058
92245
  return;
92059
92246
  }
92060
92247
  var itemBox = _this.options.getViewBoxById(item.id);
@@ -92069,21 +92256,31 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92069
92256
  var frameBox = frameId ? _this.options.getViewBoxById(frameId) : undefined;
92070
92257
  var overlay = _this.getOrCreateOverlay(item.id, parentOverlay, elements);
92071
92258
  var contentOverlay = _this.getOrCreateContentOverlay(item.id, overlay);
92072
- var html = item.html;
92073
- if (html && _this.state.contents.get(item.id) !== html) {
92259
+ var selectionOverlay = _this.getOrCreateSelectionOverlay(item.id, selectionLayer);
92260
+ if (!_this.state.contents.has(item.id)) {
92074
92261
  _this.renderOverlayHTML(item.id, contentOverlay, html);
92075
92262
  }
92263
+ _this.applyHTMLRootConfig(overlay, html);
92076
92264
  var offsetX = frameBox && !frameBox.isEmpty() ? frameBox.min.x : 0;
92077
92265
  var offsetY = frameBox && !frameBox.isEmpty() ? frameBox.min.y : 0;
92078
- var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY);
92266
+ var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY, _this.isAutoScaleEnabled(item));
92079
92267
  overlay.style.left = boxStyle.left;
92080
92268
  overlay.style.top = boxStyle.top;
92081
92269
  overlay.style.width = boxStyle.width;
92082
92270
  overlay.style.height = boxStyle.height;
92083
92271
  overlay.style.transform = boxStyle.transform;
92084
92272
  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);
92273
+ var selectionBoxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, 0, 0, _this.isAutoScaleEnabled(item));
92274
+ selectionOverlay.style.left = selectionBoxStyle.left;
92275
+ selectionOverlay.style.top = selectionBoxStyle.top;
92276
+ selectionOverlay.style.width = selectionBoxStyle.width;
92277
+ selectionOverlay.style.height = selectionBoxStyle.height;
92278
+ selectionOverlay.style.transform = selectionBoxStyle.transform;
92279
+ selectionOverlay.style.transformOrigin = '0 0';
92280
+ _this.applyHTMLRootConfig(selectionOverlay, html);
92281
+ _this.syncOverlaySelection(item.id, overlay, selectionOverlay);
92282
+ _this.syncContentScale(item.id, boxStyle.contentWidth, boxStyle.contentHeight);
92283
+ _this.syncAutoHeight(item.id, _this.isAutoHeightEnabled(item));
92087
92284
  _this.syncContentInteraction(item.id);
92088
92285
  });
92089
92286
  elements.forEach(function(_overlay, id) {
@@ -92122,6 +92319,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92122
92319
  }
92123
92320
  }
92124
92321
  syncElementStackOrder(layer, rootElements);
92322
+ if (this.state.selectionLayer) {
92323
+ this.state.selectionLayer.style.zIndex = "" + (rootElements.length + 1);
92324
+ }
92125
92325
  this.state.frameElements.forEach(function(frameOverlay, frameId) {
92126
92326
  var frameElements = [];
92127
92327
  for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
@@ -92137,6 +92337,28 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92137
92337
  syncElementStackOrder(frameOverlay, frameElements);
92138
92338
  });
92139
92339
  };
92340
+ _proto.getOrCreateSelectionLayer = function getOrCreateSelectionLayer(layer) {
92341
+ var _layer_ownerDocument;
92342
+ if (this.state.selectionLayer) {
92343
+ if (this.state.selectionLayer.parentElement !== layer) {
92344
+ layer.appendChild(this.state.selectionLayer);
92345
+ }
92346
+ return this.state.selectionLayer;
92347
+ }
92348
+ var ownerDocument = (_layer_ownerDocument = layer.ownerDocument) != null ? _layer_ownerDocument : typeof document === 'undefined' ? undefined : document;
92349
+ if (!ownerDocument) {
92350
+ return layer;
92351
+ }
92352
+ var selectionLayer = ownerDocument.createElement('div');
92353
+ selectionLayer.className = 'vvfx-card-html-overlay-selection-layer';
92354
+ selectionLayer.style.position = 'absolute';
92355
+ selectionLayer.style.inset = '0';
92356
+ selectionLayer.style.pointerEvents = 'none';
92357
+ selectionLayer.style.zIndex = '1';
92358
+ layer.appendChild(selectionLayer);
92359
+ this.state.selectionLayer = selectionLayer;
92360
+ return selectionLayer;
92361
+ };
92140
92362
  _proto.renderFrameOverlays = function renderFrameOverlays(items, layer) {
92141
92363
  var _this = this;
92142
92364
  var visibleFrameIds = new Set();
@@ -92201,6 +92423,41 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92201
92423
  elements.set(id, overlay);
92202
92424
  return overlay;
92203
92425
  };
92426
+ _proto.getOrCreateSelectionOverlay = function getOrCreateSelectionOverlay(id, parent) {
92427
+ var selectionOverlay = this.state.selectionElements.get(id);
92428
+ if (selectionOverlay) {
92429
+ if (selectionOverlay.parentElement !== parent) {
92430
+ parent.appendChild(selectionOverlay);
92431
+ }
92432
+ return selectionOverlay;
92433
+ }
92434
+ selectionOverlay = document.createElement('div');
92435
+ selectionOverlay.className = 'vvfx-card-html-overlay-selection';
92436
+ selectionOverlay.dataset.itemId = id;
92437
+ selectionOverlay.style.position = 'absolute';
92438
+ selectionOverlay.style.pointerEvents = 'none';
92439
+ selectionOverlay.style.zIndex = '1';
92440
+ parent.appendChild(selectionOverlay);
92441
+ this.state.selectionElements.set(id, selectionOverlay);
92442
+ return selectionOverlay;
92443
+ };
92444
+ _proto.syncOverlaySelection = function syncOverlaySelection(id, overlay, selectionOverlay) {
92445
+ var isSelected = this.options.getSelectedItemIds().includes(id);
92446
+ var isPreSelected = !isSelected && this.options.getPreSelectedItemId() === id;
92447
+ overlay.dataset.selected = isSelected ? 'true' : 'false';
92448
+ overlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92449
+ selectionOverlay.dataset.selected = isSelected ? 'true' : 'false';
92450
+ selectionOverlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92451
+ selectionOverlay.style.boxShadow = isSelected ? this.getSelectionBoxShadow() : isPreSelected ? this.getPreSelectionBoxShadow() : '';
92452
+ };
92453
+ _proto.getSelectionBoxShadow = function getSelectionBoxShadow() {
92454
+ var _this_options_getSelectionEdgeStyle = this.options.getSelectionEdgeStyle(), color = _this_options_getSelectionEdgeStyle.color, alpha = _this_options_getSelectionEdgeStyle.alpha, width = _this_options_getSelectionEdgeStyle.width;
92455
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92456
+ };
92457
+ _proto.getPreSelectionBoxShadow = function getPreSelectionBoxShadow() {
92458
+ var _this_options_getPreSelectionEdgeStyle = this.options.getPreSelectionEdgeStyle(), color = _this_options_getPreSelectionEdgeStyle.color, alpha = _this_options_getPreSelectionEdgeStyle.alpha, width = _this_options_getPreSelectionEdgeStyle.width;
92459
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92460
+ };
92204
92461
  _proto.getHTMLCardIdByEvent = function getHTMLCardIdByEvent(event) {
92205
92462
  var layer = this.state.layer;
92206
92463
  if (!layer) {
@@ -92210,7 +92467,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92210
92467
  var items = this.options.getItems();
92211
92468
  for(var i = items.length - 1; i >= 0; i--){
92212
92469
  var item = items[i];
92213
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92470
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92214
92471
  continue;
92215
92472
  }
92216
92473
  var box = this.options.getViewBoxById(item.id);
@@ -92229,7 +92486,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92229
92486
  var items = this.options.getItems();
92230
92487
  for(var i = items.length - 1; i >= 0; i--){
92231
92488
  var item = items[i];
92232
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92489
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92233
92490
  continue;
92234
92491
  }
92235
92492
  var box = this.options.getViewBoxById(item.id);
@@ -92239,13 +92496,206 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92239
92496
  var contentOverlay = this.state.contentElements.get(item.id);
92240
92497
  var interactiveElements = contentOverlay ? Array.from(contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR)) : [];
92241
92498
  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;
92499
+ return isMouseEventInsideRect(event, element.getBoundingClientRect());
92244
92500
  });
92245
92501
  return isHoveringShellInteractive ? item.id : undefined;
92246
92502
  }
92247
92503
  return undefined;
92248
92504
  };
92505
+ _proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
92506
+ var decision = this.resolveHTMLInteractionTarget(event);
92507
+ if (decision.kind === 'canvas' && this.shouldKeepActiveContentInteractionForFocusedElement()) {
92508
+ return;
92509
+ }
92510
+ this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
92511
+ };
92512
+ _proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
92513
+ var _this = this;
92514
+ if (typeof requestAnimationFrame !== 'function') {
92515
+ this.syncActiveContentInteraction(event);
92516
+ return;
92517
+ }
92518
+ this.pendingContentInteractionEvent = event;
92519
+ if (this.contentInteractionFrame !== undefined) {
92520
+ return;
92521
+ }
92522
+ this.contentInteractionFrame = requestAnimationFrame(function() {
92523
+ _this.contentInteractionFrame = undefined;
92524
+ var pendingEvent = _this.pendingContentInteractionEvent;
92525
+ _this.pendingContentInteractionEvent = undefined;
92526
+ if (pendingEvent) {
92527
+ _this.syncActiveContentInteraction(pendingEvent);
92528
+ }
92529
+ });
92530
+ };
92531
+ _proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
92532
+ var _this = this;
92533
+ var previous = this.state.activeContentInteraction;
92534
+ 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)) {
92535
+ return;
92536
+ }
92537
+ this.state.activeContentInteraction = zone;
92538
+ var changedIds = new Set();
92539
+ if (previous) {
92540
+ changedIds.add(previous.id);
92541
+ }
92542
+ if (zone) {
92543
+ changedIds.add(zone.id);
92544
+ }
92545
+ changedIds.forEach(function(id) {
92546
+ _this.syncContentInteraction(id);
92547
+ });
92548
+ };
92549
+ _proto.shouldKeepActiveContentInteractionForFocusedElement = function shouldKeepActiveContentInteractionForFocusedElement() {
92550
+ var activeInteraction = this.state.activeContentInteraction;
92551
+ if (!activeInteraction || typeof document === 'undefined') {
92552
+ return false;
92553
+ }
92554
+ var activeElement = document.activeElement;
92555
+ if (!activeElement || activeElement === document.body) {
92556
+ return false;
92557
+ }
92558
+ var interactionElement = activeInteraction.element;
92559
+ return interactionElement === activeElement || typeof interactionElement.contains === 'function' && interactionElement.contains(activeElement);
92560
+ };
92561
+ _proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
92562
+ var id = this.getHTMLCardIdByEvent(event);
92563
+ if (!id || this.isEditableCard(id)) {
92564
+ return {
92565
+ kind: 'canvas',
92566
+ id: id
92567
+ };
92568
+ }
92569
+ var contentOverlay = this.state.contentElements.get(id);
92570
+ if (!contentOverlay) {
92571
+ return {
92572
+ kind: 'canvas',
92573
+ id: id
92574
+ };
92575
+ }
92576
+ var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
92577
+ if (activeSubtree) {
92578
+ return {
92579
+ kind: 'html',
92580
+ interaction: activeSubtree
92581
+ };
92582
+ }
92583
+ var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
92584
+ return isMouseEventInsideRect(event, zone.rect);
92585
+ });
92586
+ var zone = this.resolveContentInteractionZone(matchedZones);
92587
+ if (zone) {
92588
+ return {
92589
+ kind: 'html',
92590
+ interaction: {
92591
+ id: id,
92592
+ element: zone.element,
92593
+ zone: zone.zone
92594
+ }
92595
+ };
92596
+ }
92597
+ return {
92598
+ kind: 'canvas',
92599
+ id: id
92600
+ };
92601
+ };
92602
+ _proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
92603
+ var activeInteraction = this.state.activeContentInteraction;
92604
+ if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
92605
+ return undefined;
92606
+ }
92607
+ var rect = activeInteraction.element.getBoundingClientRect();
92608
+ return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
92609
+ };
92610
+ _proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
92611
+ if (zones.length <= 1) {
92612
+ return zones[0];
92613
+ }
92614
+ var subtreeRoot = zones.find(function(candidate) {
92615
+ return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
92616
+ return zone.element !== candidate.element && candidate.element.contains(zone.element);
92617
+ });
92618
+ });
92619
+ return subtreeRoot != null ? subtreeRoot : zones[0];
92620
+ };
92621
+ _proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
92622
+ var _this = this;
92623
+ var cachedZones = this.state.contentInteractionZones.get(id);
92624
+ if (cachedZones) {
92625
+ return cachedZones;
92626
+ }
92627
+ var zones = Array.from(contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id))).filter(function(element) {
92628
+ return !_this.isContentInteractionDisabled(element);
92629
+ }).map(function(element) {
92630
+ return {
92631
+ element: element,
92632
+ rect: element.getBoundingClientRect(),
92633
+ zone: _this.getContentInteractionZoneMode(element)
92634
+ };
92635
+ });
92636
+ this.state.contentInteractionZones.set(id, zones);
92637
+ this.observeContentInteractionZoneResizes(id, zones);
92638
+ return zones;
92639
+ };
92640
+ _proto.getContentInteractiveSelector = function getContentInteractiveSelector(id) {
92641
+ var _ref;
92642
+ var _this_options_resolveCardTypeConfig_htmlInteractionSelectors, _this_options_resolveCardTypeConfig;
92643
+ var item = this.options.getItems().find(function(item) {
92644
+ return item.id === id;
92645
+ });
92646
+ if (!item) {
92647
+ return CONTENT_INTERACTIVE_SELECTOR;
92648
+ }
92649
+ 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 : [];
92650
+ if (selectors.length === 0) {
92651
+ return CONTENT_INTERACTIVE_SELECTOR;
92652
+ }
92653
+ return [].concat([
92654
+ CONTENT_INTERACTIVE_SELECTOR
92655
+ ], selectors).join(', ');
92656
+ };
92657
+ _proto.isContentInteractionDisabled = function isContentInteractionDisabled(element) {
92658
+ if (typeof element.closest !== 'function') {
92659
+ return false;
92660
+ }
92661
+ return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
92662
+ };
92663
+ _proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
92664
+ var zone = element.dataset.vvfxHtmlInteractionZone;
92665
+ return zone === 'subtree' ? 'subtree' : 'self';
92666
+ };
92667
+ _proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
92668
+ if (id) {
92669
+ var _this_state_contentInteractionResizeCleanups_get;
92670
+ this.state.contentInteractionZones.delete(id);
92671
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92672
+ this.state.contentInteractionResizeCleanups.delete(id);
92673
+ return;
92674
+ }
92675
+ this.state.contentInteractionZones.clear();
92676
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92677
+ cleanup();
92678
+ });
92679
+ this.state.contentInteractionResizeCleanups.clear();
92680
+ };
92681
+ _proto.observeContentInteractionZoneResizes = function observeContentInteractionZoneResizes(id, zones) {
92682
+ var _this = this;
92683
+ var _this_state_contentInteractionResizeCleanups_get;
92684
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92685
+ this.state.contentInteractionResizeCleanups.delete(id);
92686
+ if (zones.length === 0 || typeof ResizeObserver !== 'function') {
92687
+ return;
92688
+ }
92689
+ var observer = new ResizeObserver(function() {
92690
+ _this.invalidateContentInteractionZones(id);
92691
+ });
92692
+ zones.forEach(function(zone) {
92693
+ observer.observe(zone.element);
92694
+ });
92695
+ this.state.contentInteractionResizeCleanups.set(id, function() {
92696
+ observer.disconnect();
92697
+ });
92698
+ };
92249
92699
  _proto.getLayerPoint = function getLayerPoint(event) {
92250
92700
  var rect = this.options.container.getBoundingClientRect();
92251
92701
  return {
@@ -92302,19 +92752,35 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92302
92752
  if (!scaleOverlay || !contentOverlay || width <= 0 || height <= 0) {
92303
92753
  return;
92304
92754
  }
92305
- scaleOverlay.style.width = "" + width + "px";
92306
- scaleOverlay.style.height = "" + height + "px";
92755
+ var nextWidth = "" + width + "px";
92756
+ var nextHeight = "" + height + "px";
92757
+ var sizeChanged = scaleOverlay.style.width !== nextWidth || scaleOverlay.style.height !== nextHeight;
92758
+ scaleOverlay.style.width = nextWidth;
92759
+ scaleOverlay.style.height = nextHeight;
92307
92760
  scaleOverlay.style.transform = 'none';
92308
- contentOverlay.style.width = "" + width + "px";
92309
- contentOverlay.style.height = "" + height + "px";
92761
+ contentOverlay.style.width = nextWidth;
92762
+ contentOverlay.style.height = nextHeight;
92763
+ if (sizeChanged && this.state.autoHeightModes.get(id) === 'message') {
92764
+ this.requestAutoHeightFromIframes(id, contentOverlay);
92765
+ }
92766
+ if (sizeChanged) {
92767
+ this.invalidateContentInteractionZones(id);
92768
+ }
92769
+ };
92770
+ _proto.requestAutoHeightFromIframes = function requestAutoHeightFromIframes(id, contentOverlay) {
92771
+ contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92772
+ requestCardHTMLAutoHeight(iframe, id);
92773
+ });
92310
92774
  };
92311
92775
  _proto.syncContentInteraction = function syncContentInteraction(id) {
92312
- var _this_state_editing;
92776
+ var _this_state_editing, _this_state_activeContentInteraction;
92313
92777
  var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
92778
+ var activeInteraction = ((_this_state_activeContentInteraction = this.state.activeContentInteraction) == null ? void 0 : _this_state_activeContentInteraction.id) === id ? this.state.activeContentInteraction : undefined;
92314
92779
  var overlay = this.state.elements.get(id);
92315
92780
  var scaleOverlay = this.state.contentScaleElements.get(id);
92316
92781
  var contentOverlay = this.state.contentElements.get(id);
92317
92782
  var contentMount = this.state.contentMountElements.get(id);
92783
+ var isInteractive = isEditing || !!activeInteraction;
92318
92784
  if (overlay) {
92319
92785
  overlay.dataset.editing = isEditing ? 'true' : 'false';
92320
92786
  overlay.style.pointerEvents = 'none';
@@ -92325,34 +92791,62 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92325
92791
  }
92326
92792
  if (contentOverlay) {
92327
92793
  contentOverlay.dataset.editing = isEditing ? 'true' : 'false';
92328
- contentOverlay.style.pointerEvents = 'none';
92794
+ contentOverlay.style.pointerEvents = isInteractive ? 'auto' : 'none';
92329
92795
  contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92330
- iframe.style.pointerEvents = isEditing ? 'auto' : 'none';
92331
- iframe.tabIndex = isEditing ? 0 : -1;
92796
+ var isActiveIframe = isEditing || (activeInteraction == null ? void 0 : activeInteraction.element) === iframe;
92797
+ iframe.style.pointerEvents = isActiveIframe ? 'auto' : 'none';
92798
+ iframe.tabIndex = isActiveIframe ? 0 : -1;
92332
92799
  });
92333
- this.syncShellInteraction(id, contentOverlay, isEditing);
92800
+ this.syncShellInteraction(id, contentOverlay, isInteractive);
92801
+ this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
92334
92802
  }
92335
92803
  if (contentMount) {
92336
92804
  contentMount.dataset.editing = isEditing ? 'true' : 'false';
92337
- contentMount.style.pointerEvents = isEditing ? 'auto' : 'none';
92338
- contentMount.inert = !isEditing;
92339
- if (isEditing) {
92805
+ contentMount.style.pointerEvents = isInteractive ? 'auto' : 'none';
92806
+ contentMount.inert = !isInteractive;
92807
+ if (isInteractive) {
92340
92808
  contentMount.removeAttribute('aria-hidden');
92341
92809
  } else {
92342
92810
  contentMount.setAttribute('aria-hidden', 'true');
92343
92811
  }
92344
92812
  }
92345
92813
  };
92346
- _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isEditing) {
92814
+ _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
92815
+ var _this = this;
92816
+ var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
92817
+ contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
92818
+ if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
92819
+ _this.clearContentInteractionState(element);
92820
+ return;
92821
+ }
92822
+ if (!isInteractive) {
92823
+ _this.clearContentInteractionState(element);
92824
+ return;
92825
+ }
92826
+ if (_this.isContentInteractionDisabled(element)) {
92827
+ element.dataset.vvfxHtmlInteractionActive = 'false';
92828
+ element.style.pointerEvents = 'none';
92829
+ return;
92830
+ }
92831
+ var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
92832
+ element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
92833
+ element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
92834
+ });
92835
+ };
92836
+ _proto.clearContentInteractionState = function clearContentInteractionState(element) {
92837
+ delete element.dataset.vvfxHtmlInteractionActive;
92838
+ element.style.pointerEvents = '';
92839
+ };
92840
+ _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
92347
92841
  var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
92348
- var isShellInteractiveActive = isEditing || isHoveringShellInteractive;
92842
+ var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
92349
92843
  contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR).forEach(function(element) {
92350
92844
  element.dataset.vvfxHtmlShellInteractiveHover = isHoveringShellInteractive ? 'true' : 'false';
92351
92845
  element.dataset.vvfxHtmlShellInteractiveActive = isShellInteractiveActive ? 'true' : 'false';
92352
92846
  element.style.pointerEvents = isShellInteractiveActive ? 'auto' : 'none';
92353
92847
  });
92354
92848
  contentOverlay.querySelectorAll(EDITING_INTERACTIVE_SELECTOR).forEach(function(element) {
92355
- element.style.pointerEvents = isEditing ? 'auto' : 'none';
92849
+ element.style.pointerEvents = isInteractive ? 'auto' : 'none';
92356
92850
  });
92357
92851
  };
92358
92852
  _proto.enterEditing = function enterEditing(id) {
@@ -92360,6 +92854,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92360
92854
  if (((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id) {
92361
92855
  return;
92362
92856
  }
92857
+ if (!this.isEditableCard(id)) {
92858
+ return;
92859
+ }
92363
92860
  var box = this.options.getViewBoxById(id);
92364
92861
  if (box.isEmpty()) {
92365
92862
  return;
@@ -92403,6 +92900,13 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92403
92900
  this.options.setViewport(editing.restoreViewport);
92404
92901
  this.scheduleRender();
92405
92902
  };
92903
+ _proto.isEditableCard = function isEditableCard(id) {
92904
+ var _this_options_resolveCardTypeConfig;
92905
+ var item = this.options.getItems().find(function(item) {
92906
+ return item.id === id;
92907
+ });
92908
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.editable) !== false;
92909
+ };
92406
92910
  _proto.getEditingFitZoom = function getEditingFitZoom(box, currentZoom) {
92407
92911
  var viewportElement = this.options.container.parentElement;
92408
92912
  if (!viewportElement) {
@@ -92427,6 +92931,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92427
92931
  };
92428
92932
  _proto.renderOverlayHTML = function renderOverlayHTML(id, overlay, html) {
92429
92933
  this.cleanupOverlayContent(id);
92934
+ this.invalidateContentInteractionZones(id);
92430
92935
  overlay.innerHTML = '';
92431
92936
  var shell = mountHTMLShell(overlay, html.content, html.shell);
92432
92937
  var autoHeightMeasureElement = shell.contentContainer.isConnected ? shell.contentContainer : overlay;
@@ -92436,18 +92941,81 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92436
92941
  });
92437
92942
  var contentCleanup = this.renderOverlayContent(shell.contentContainer, html.content, {
92438
92943
  id: id,
92439
- autoHeight: isCardItem(item) && item.property.autoHeight === true
92944
+ autoHeight: this.isAutoHeightEnabled(item)
92440
92945
  });
92946
+ this.observeContentInteractionZones(id, shell.contentContainer);
92441
92947
  this.state.cleanups.set(id, function() {
92442
92948
  contentCleanup == null ? void 0 : contentCleanup();
92443
92949
  shell.cleanup == null ? void 0 : shell.cleanup.call(shell);
92444
92950
  });
92445
92951
  this.state.contents.set(id, html);
92446
92952
  };
92953
+ _proto.observeContentInteractionZones = function observeContentInteractionZones(id, contentContainer) {
92954
+ var _this = this;
92955
+ var _this_state_contentInteractionZoneCleanups_get;
92956
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
92957
+ this.state.contentInteractionZoneCleanups.delete(id);
92958
+ if (typeof MutationObserver !== 'function') {
92959
+ return;
92960
+ }
92961
+ var observer = new MutationObserver(function() {
92962
+ _this.invalidateContentInteractionZones(id);
92963
+ });
92964
+ observer.observe(contentContainer, {
92965
+ attributes: true,
92966
+ childList: true,
92967
+ subtree: true
92968
+ });
92969
+ this.state.contentInteractionZoneCleanups.set(id, function() {
92970
+ observer.disconnect();
92971
+ });
92972
+ };
92973
+ _proto.applyHTMLRootConfig = function applyHTMLRootConfig(root, html) {
92974
+ var _ref, _config_style;
92975
+ var _this_htmlRootConfigCleanups_get, _config_className;
92976
+ (_this_htmlRootConfigCleanups_get = this.htmlRootConfigCleanups.get(root)) == null ? void 0 : _this_htmlRootConfigCleanups_get();
92977
+ this.htmlRootConfigCleanups.delete(root);
92978
+ var config = html.root;
92979
+ if (!config) {
92980
+ return;
92981
+ }
92982
+ var classNames = (_ref = (_config_className = config.className) == null ? void 0 : _config_className.split(/\s+/).filter(Boolean)) != null ? _ref : [];
92983
+ var styleProperties = [];
92984
+ classNames.forEach(function(className) {
92985
+ root.classList.add(className);
92986
+ });
92987
+ Object.entries((_config_style = config.style) != null ? _config_style : {}).forEach(function(param) {
92988
+ var property = param[0], value = param[1];
92989
+ if (value === undefined) {
92990
+ return;
92991
+ }
92992
+ styleProperties.push(property);
92993
+ if (property.startsWith('--') || property.includes('-')) {
92994
+ root.style.setProperty(property, String(value));
92995
+ return;
92996
+ }
92997
+ root.style[property] = String(value);
92998
+ });
92999
+ this.htmlRootConfigCleanups.set(root, function() {
93000
+ classNames.forEach(function(className) {
93001
+ root.classList.remove(className);
93002
+ });
93003
+ styleProperties.forEach(function(property) {
93004
+ if (property.startsWith('--') || property.includes('-')) {
93005
+ root.style.removeProperty(property);
93006
+ return;
93007
+ }
93008
+ root.style[property] = '';
93009
+ });
93010
+ });
93011
+ };
92447
93012
  _proto.renderOverlayContent = function renderOverlayContent(overlay, content, options) {
92448
93013
  var _this = this;
92449
93014
  switch(content.kind){
92450
93015
  case 'inline':
93016
+ if (options == null ? void 0 : options.autoHeight) {
93017
+ this.state.autoHeightModes.set(options.id, 'message');
93018
+ }
92451
93019
  return this.chainCleanups(function() {
92452
93020
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92453
93021
  }, renderDocumentContent(overlay, {
@@ -92464,6 +93032,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92464
93032
  }));
92465
93033
  case 'dom':
92466
93034
  {
93035
+ if (options == null ? void 0 : options.autoHeight) {
93036
+ this.state.autoHeightModes.set(options.id, 'measure');
93037
+ }
92467
93038
  if (content.target === 'iframe') {
92468
93039
  return renderDOMContentInIframe(overlay, content.render, content.cleanup);
92469
93040
  }
@@ -92473,6 +93044,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92473
93044
  } : undefined;
92474
93045
  }
92475
93046
  case 'document':
93047
+ if (options == null ? void 0 : options.autoHeight) {
93048
+ this.state.autoHeightModes.set(options.id, 'message');
93049
+ }
92476
93050
  return this.chainCleanups(function() {
92477
93051
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92478
93052
  }, renderDocumentContent(overlay, content, {
@@ -92500,6 +93074,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92500
93074
  };
92501
93075
  };
92502
93076
  _proto.cleanupOverlayContent = function cleanupOverlayContent(id) {
93077
+ var _this_state_contentInteractionZoneCleanups_get;
92503
93078
  var cleanup = this.state.cleanups.get(id);
92504
93079
  if (cleanup) {
92505
93080
  cleanup();
@@ -92507,13 +93082,19 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92507
93082
  }
92508
93083
  this.state.contents.delete(id);
92509
93084
  this.state.contentMountElements.delete(id);
93085
+ this.state.autoHeightModes.delete(id);
93086
+ this.invalidateContentInteractionZones(id);
93087
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
93088
+ this.state.contentInteractionZoneCleanups.delete(id);
92510
93089
  this.cleanupAutoHeight(id);
92511
93090
  };
92512
93091
  _proto.removeOverlay = function removeOverlay(id) {
92513
- var _this_state_elements_get;
93092
+ var _this_state_elements_get, _this_state_selectionElements_get;
92514
93093
  this.cleanupOverlayContent(id);
92515
93094
  (_this_state_elements_get = this.state.elements.get(id)) == null ? void 0 : _this_state_elements_get.remove();
93095
+ (_this_state_selectionElements_get = this.state.selectionElements.get(id)) == null ? void 0 : _this_state_selectionElements_get.remove();
92516
93096
  this.state.elements.delete(id);
93097
+ this.state.selectionElements.delete(id);
92517
93098
  this.state.contentScaleElements.delete(id);
92518
93099
  this.state.contentElements.delete(id);
92519
93100
  };
@@ -92522,11 +93103,27 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92522
93103
  this.cleanupAutoHeight(id);
92523
93104
  return;
92524
93105
  }
93106
+ this.ensureAutoHeightMode(id);
93107
+ if (this.state.autoHeightModes.get(id) === 'message') {
93108
+ this.cleanupAutoHeight(id);
93109
+ return;
93110
+ }
92525
93111
  if (!this.state.autoHeightCleanups.has(id)) {
92526
93112
  this.state.autoHeightCleanups.set(id, this.createAutoHeightObserver(id));
92527
93113
  }
92528
93114
  this.scheduleAutoHeightMeasure(id);
92529
93115
  };
93116
+ _proto.ensureAutoHeightMode = function ensureAutoHeightMode(id) {
93117
+ var _this_state_contents_get;
93118
+ if (this.state.autoHeightModes.has(id)) {
93119
+ return;
93120
+ }
93121
+ var content = (_this_state_contents_get = this.state.contents.get(id)) == null ? void 0 : _this_state_contents_get.content;
93122
+ if (!content) {
93123
+ return;
93124
+ }
93125
+ this.state.autoHeightModes.set(id, content.kind === 'inline' || content.kind === 'document' ? 'message' : 'measure');
93126
+ };
92530
93127
  _proto.createAutoHeightObserver = function createAutoHeightObserver(id) {
92531
93128
  var _this = this;
92532
93129
  var cleanupFns = [];
@@ -92614,7 +93211,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92614
93211
  var item = this.options.getItems().find(function(candidate) {
92615
93212
  return candidate.id === id;
92616
93213
  });
92617
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93214
+ if (!this.isAutoHeightEnabled(item)) {
92618
93215
  this.cleanupAutoHeight(id);
92619
93216
  return;
92620
93217
  }
@@ -92633,7 +93230,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92633
93230
  }).filter(function(height) {
92634
93231
  return typeof height === 'number' && Number.isFinite(height) && height > 0;
92635
93232
  });
92636
- var childHeight = this.getChildrenNaturalHeight(element);
93233
+ var childHeight = this.getChildrenNaturalHeight(element, {
93234
+ includeIframes: iframeHeights.length === 0
93235
+ });
92637
93236
  var naturalHeight = (_Math = Math).max.apply(_Math, [].concat([
92638
93237
  childHeight
92639
93238
  ], iframeHeights));
@@ -92653,10 +93252,29 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92653
93252
  }
92654
93253
  return Math.max(documentElement.scrollHeight, (_ref = body == null ? void 0 : body.scrollHeight) != null ? _ref : 0);
92655
93254
  };
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);
93255
+ _proto.getChildrenNaturalHeight = function getChildrenNaturalHeight(element, options) {
93256
+ var _ref;
93257
+ var includeIframes = (_ref = options == null ? void 0 : options.includeIframes) != null ? _ref : true;
93258
+ return Array.from(element.childNodes).reduce(function(height, child) {
93259
+ var _child_textContent;
93260
+ if (child.nodeType === Node.ELEMENT_NODE) {
93261
+ var childElement = child;
93262
+ if (!includeIframes && childElement.tagName === 'IFRAME') {
93263
+ return height;
93264
+ }
93265
+ return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
93266
+ }
93267
+ if (child.nodeType === Node.TEXT_NODE && ((_child_textContent = child.textContent) == null ? void 0 : _child_textContent.trim())) {
93268
+ var range = element.ownerDocument.createRange();
93269
+ range.selectNodeContents(child);
93270
+ var rects = Array.from(range.getClientRects());
93271
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
93272
+ range.detach();
93273
+ return rects.reduce(function(textHeight, rect) {
93274
+ return Math.max(textHeight, rect.bottom - element.getBoundingClientRect().top);
93275
+ }, height);
93276
+ }
93277
+ return height;
92660
93278
  }, 0);
92661
93279
  };
92662
93280
  _proto.cleanupAutoHeight = function cleanupAutoHeight(id) {
@@ -92675,14 +93293,48 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92675
93293
  var item = this.options.getItems().find(function(candidate) {
92676
93294
  return candidate.id === id;
92677
93295
  });
92678
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93296
+ if (!isCardItem(item) || !this.isAutoHeightEnabled(item)) {
92679
93297
  return;
92680
93298
  }
92681
- if (!Number.isFinite(height) || height <= 0 || Math.abs(height - item.property.height) <= AUTO_HEIGHT_EPSILON) {
93299
+ if (!Number.isFinite(height) || height <= 0) {
92682
93300
  return;
92683
93301
  }
92684
- this.options.setCardItemHeight(id, Math.ceil(height));
93302
+ var nextHeight = Math.ceil(this.getAutoHeightItemHeight(item, height));
93303
+ if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
93304
+ return;
93305
+ }
93306
+ this.options.setCardItemHeight(id, nextHeight);
93307
+ };
93308
+ _proto.getAutoHeightItemHeight = function getAutoHeightItemHeight(item, contentHeight) {
93309
+ if (!isCardItem(item) || this.isAutoScaleEnabled(item)) {
93310
+ return contentHeight;
93311
+ }
93312
+ var scaleOverlay = this.state.contentScaleElements.get(item.id);
93313
+ var displayedHeight = scaleOverlay ? Number.parseFloat(scaleOverlay.style.height) : 0;
93314
+ if (!Number.isFinite(displayedHeight) || displayedHeight <= 0 || item.property.height <= 0) {
93315
+ return contentHeight;
93316
+ }
93317
+ return contentHeight / displayedHeight * item.property.height;
93318
+ };
93319
+ _proto.isAutoHeightEnabled = function isAutoHeightEnabled(item) {
93320
+ var _this_options_resolveCardTypeConfig;
93321
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeight) === true;
93322
+ };
93323
+ _proto.isAutoScaleEnabled = function isAutoScaleEnabled(item) {
93324
+ var _this_options_resolveCardTypeConfig;
93325
+ if (!isCardItem(item)) {
93326
+ return true;
93327
+ }
93328
+ return ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoScale) !== false;
92685
93329
  };
93330
+ _create_class(HTMLOverlayManager, [
93331
+ {
93332
+ key: "layerElement",
93333
+ get: function get() {
93334
+ return this.state.layer;
93335
+ }
93336
+ }
93337
+ ]);
92686
93338
  return HTMLOverlayManager;
92687
93339
  }();
92688
93340
  function waitForCardCaptureReady(root) {
@@ -92724,6 +93376,17 @@ function waitForCardCaptureReady(root) {
92724
93376
  });
92725
93377
  })();
92726
93378
  }
93379
+ function formatCssColor(color, alpha) {
93380
+ var normalizedColor = Math.max(0, Math.min(0xFFFFFF, Math.round(color)));
93381
+ var red = normalizedColor >> 16 & 0xFF;
93382
+ var green = normalizedColor >> 8 & 0xFF;
93383
+ var blue = normalizedColor & 0xFF;
93384
+ return "rgba(" + red + ", " + green + ", " + blue + ", " + formatCssNumber(alpha) + ")";
93385
+ }
93386
+ function formatCssNumber(value) {
93387
+ var normalized = Number.isFinite(value) ? value : 0;
93388
+ return Number(normalized.toFixed(6)).toString();
93389
+ }
92727
93390
  function nextAnimationFrame() {
92728
93391
  return new Promise(function(resolve) {
92729
93392
  requestAnimationFrame(function() {
@@ -93142,6 +93805,9 @@ function createFlattenedContent(target, frameStyle, ownerDocument) {
93142
93805
  });
93143
93806
  return replacement;
93144
93807
  }
93808
+ function isMouseEventInsideRect(event, rect) {
93809
+ return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
93810
+ }
93145
93811
  function createFlattenedIframeContent(iframe) {
93146
93812
  var doc = iframe.contentDocument;
93147
93813
  if (!doc) {
@@ -93181,6 +93847,19 @@ function withTimeout(promise, timeout) {
93181
93847
  });
93182
93848
  }
93183
93849
 
93850
+ function orderSDKCanvasLayers(param) {
93851
+ var container = param.container, playerContainer = param.playerContainer, htmlOverlayLayer = param.htmlOverlayLayer, gestureCanvas = param.gestureCanvas;
93852
+ [
93853
+ playerContainer,
93854
+ htmlOverlayLayer,
93855
+ gestureCanvas
93856
+ ].forEach(function(layer) {
93857
+ if ((layer == null ? void 0 : layer.parentElement) === container) {
93858
+ container.appendChild(layer);
93859
+ }
93860
+ });
93861
+ }
93862
+
93184
93863
  var HTML_CARD_EDITING_VIEWPORT_PADDING = 48;
93185
93864
  var SDK = /*#__PURE__*/ function() {
93186
93865
  function SDK(container, mode) {
@@ -93286,9 +93965,45 @@ var SDK = /*#__PURE__*/ function() {
93286
93965
  propertyName: 'height',
93287
93966
  propertyValue: height
93288
93967
  });
93968
+ },
93969
+ getSelectedItemIds: function getSelectedItemIds() {
93970
+ var _ref;
93971
+ var _this__pageData;
93972
+ return (_ref = (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.selectedItems) != null ? _ref : [];
93973
+ },
93974
+ getPreSelectedItemId: function getPreSelectedItemId() {
93975
+ var _this__pageData;
93976
+ return (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.preSelectedItem;
93977
+ },
93978
+ getSelectionEdgeStyle: function getSelectionEdgeStyle() {
93979
+ 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;
93980
+ return {
93981
+ color: wireframeColor,
93982
+ alpha: wireframeAlpha,
93983
+ width: wireframeWidth
93984
+ };
93985
+ },
93986
+ getPreSelectionEdgeStyle: function getPreSelectionEdgeStyle() {
93987
+ var _SDK_config_gestureHandlerConfig_selectorGizmoConfig = SDK.config.gestureHandlerConfig.selectorGizmoConfig, preSelectedColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedColor, preSelectedWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedWidth;
93988
+ return {
93989
+ color: preSelectedColor,
93990
+ alpha: 1,
93991
+ width: preSelectedWidth
93992
+ };
93993
+ },
93994
+ getCanvasEventTarget: function getCanvasEventTarget() {
93995
+ var _this__gestureHandler;
93996
+ return (_this__gestureHandler = _this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view;
93997
+ },
93998
+ resolveCardHTML: function resolveCardHTML(item) {
93999
+ return isCardItem(item) ? _this.resolveCardHTML(item) : undefined;
94000
+ },
94001
+ resolveCardTypeConfig: function resolveCardTypeConfig(item) {
94002
+ return isCardItem(item) ? _this.resolveCardTypeConfig(item) : undefined;
93289
94003
  }
93290
94004
  });
93291
94005
  this._htmlOverlayManager.attach();
94006
+ this.syncCanvasLayerOrder();
93292
94007
  }
93293
94008
  var _proto = SDK.prototype;
93294
94009
  _proto.dispose = function dispose() {
@@ -93384,6 +94099,7 @@ var SDK = /*#__PURE__*/ function() {
93384
94099
  this.initPlayer(SDK.config.mode);
93385
94100
  this._pageDataUtils = new PageDataUtils(this.player, this._playerContainer, this._eventEmitter, this);
93386
94101
  this._gestureHandler = new GestureHandler(this._container);
94102
+ this.syncCanvasLayerOrder();
93387
94103
  return [
93388
94104
  4,
93389
94105
  this.runByPageData(this.pageData)
@@ -93433,6 +94149,16 @@ var SDK = /*#__PURE__*/ function() {
93433
94149
  env: 'editor'
93434
94150
  });
93435
94151
  this.player.resize();
94152
+ this.syncCanvasLayerOrder();
94153
+ };
94154
+ _proto.syncCanvasLayerOrder = function syncCanvasLayerOrder() {
94155
+ var _this__htmlOverlayManager, _this__gestureHandler;
94156
+ orderSDKCanvasLayers({
94157
+ container: this._container,
94158
+ playerContainer: this._playerContainer,
94159
+ htmlOverlayLayer: (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.layerElement,
94160
+ gestureCanvas: (_this__gestureHandler = this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view
94161
+ });
93436
94162
  };
93437
94163
  _proto.getInitParam = function getInitParam(param) {
93438
94164
  return _async_to_generator(function() {
@@ -94527,8 +95253,7 @@ var SDK = /*#__PURE__*/ function() {
94527
95253
  * @param ignoreClamp 是否忽视约束
94528
95254
  */ _proto.setPageZoom = function setPageZoom(zoom, center, ignoreClamp) {
94529
95255
  EFFECTS.assertExist(this._pageData);
94530
- this._pageData.property.zoom = zoom;
94531
- this._pageDataUtils.setPageZoom(this._pageData.property.zoom, center, ignoreClamp);
95256
+ this._pageDataUtils.setPageZoom(zoom, center, ignoreClamp);
94532
95257
  this._gestureHandler.render();
94533
95258
  };
94534
95259
  /**
@@ -95424,6 +96149,44 @@ var SDK = /*#__PURE__*/ function() {
95424
96149
  });
95425
96150
  };
95426
96151
  /**
96152
+ * @description 按 cardType 从注册表解析卡片的 HTML 渲染配置。
96153
+ * @param item 卡片元素
96154
+ * @returns HTML 渲染配置
96155
+ */ _proto.resolveCardHTML = function resolveCardHTML(item) {
96156
+ var _cardTypeConfig_html;
96157
+ var cardTypeConfig = this.resolveCardTypeConfig(item);
96158
+ return cardTypeConfig == null ? void 0 : (_cardTypeConfig_html = cardTypeConfig.html) == null ? void 0 : _cardTypeConfig_html.call(cardTypeConfig, item);
96159
+ };
96160
+ /**
96161
+ * @description 按 cardType 从注册表解析卡片类型配置。
96162
+ * @param item 卡片元素
96163
+ * @returns 卡片类型配置
96164
+ */ _proto.resolveCardTypeConfig = function resolveCardTypeConfig(item) {
96165
+ return SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96166
+ return t.type === item.cardType;
96167
+ });
96168
+ };
96169
+ /**
96170
+ * @description 重新解析并挂载指定卡片的 HTML 内容。
96171
+ * @description 当 inline/document 内容依赖 extension 或外部状态变化时,可调用此方法刷新 DOM。
96172
+ * @param id 卡片元素 ID
96173
+ * @returns 是否成功触发刷新
96174
+ */ _proto.refreshCardHTML = function refreshCardHTML(id) {
96175
+ var _this__htmlOverlayManager, _this__htmlOverlayManager1;
96176
+ var item = this.getSDKItem(id);
96177
+ if (!isCardItem(item)) {
96178
+ console.warn('CardItem "' + id + '" not found.');
96179
+ return false;
96180
+ }
96181
+ if (!this.resolveCardHTML(item)) {
96182
+ console.warn('CardItem "' + id + '" has no registered HTML renderer.');
96183
+ return false;
96184
+ }
96185
+ (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.invalidateCardHTML(id);
96186
+ (_this__htmlOverlayManager1 = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager1.scheduleRender();
96187
+ return true;
96188
+ };
96189
+ /**
95427
96190
  * @description 创建卡片元素
95428
96191
  * @description 底层以透明 SpriteItem 形式渲染,支持 cardType 属性
95429
96192
  * @param createInfo 卡片创建信息
@@ -95718,8 +96481,8 @@ SDK.config = BaseConfig;
95718
96481
  _inherits(CardItem, BaseItem);
95719
96482
  function CardItem(options) {
95720
96483
  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;
96484
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
96485
+ var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5;
95723
96486
  _this = BaseItem.call(this, options) || this, /**
95724
96487
  * @description 元素类型
95725
96488
  */ _this.type = SDKItemType.CARD;
@@ -95740,9 +96503,7 @@ SDK.config = BaseConfig;
95740
96503
  1,
95741
96504
  1
95742
96505
  ],
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
96506
+ cardType: (_ref5 = (_options_property5 = options.property) == null ? void 0 : _options_property5.cardType) != null ? _ref5 : 'unknown'
95746
96507
  };
95747
96508
  return _this;
95748
96509
  }
@@ -95753,22 +96514,18 @@ SDK.config = BaseConfig;
95753
96514
  * @param withParent 是否包含父节点ID
95754
96515
  */ _proto.toCreateInfo = function toCreateInfo(withParent) {
95755
96516
  var extension = this.getAllExtension();
95756
- var property = deepClone(this.property);
95757
- property.html = this.html;
95758
96517
  return {
95759
96518
  type: SDKItemType.CARD,
95760
96519
  id: this.id,
95761
96520
  name: this.name,
95762
96521
  parentId: withParent ? this.parentId : undefined,
95763
96522
  extension: Object.keys(extension).length > 0 ? extension : undefined,
95764
- property: property
96523
+ property: deepClone(this.property)
95765
96524
  };
95766
96525
  };
95767
96526
  /**
95768
96527
  * @description 克隆 SDKItem
95769
96528
  */ _proto.clone = function clone() {
95770
- var property = deepClone(this.property);
95771
- property.html = this.html;
95772
96529
  return new CardItem({
95773
96530
  id: EFFECTS.generateGUID(),
95774
96531
  name: this.name,
@@ -95778,7 +96535,7 @@ SDK.config = BaseConfig;
95778
96535
  endBehavior: this.endBehavior,
95779
96536
  isLocked: this.isLocked,
95780
96537
  isCoreEditable: this.isCoreEditable,
95781
- property: property,
96538
+ property: deepClone(this.property),
95782
96539
  extension: this.getAllExtension()
95783
96540
  });
95784
96541
  };
@@ -95795,17 +96552,6 @@ SDK.config = BaseConfig;
95795
96552
  this.property.cardType = value;
95796
96553
  }
95797
96554
  },
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
96555
  {
95810
96556
  key: "position",
95811
96557
  get: // ==================== 便捷访问器 ====================
@@ -95818,6 +96564,16 @@ SDK.config = BaseConfig;
95818
96564
  this.property.position = value;
95819
96565
  }
95820
96566
  },
96567
+ {
96568
+ key: "isAutoScale",
96569
+ get: function get() {
96570
+ var _this = this;
96571
+ var config = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96572
+ return t.type === _this.cardType;
96573
+ });
96574
+ return (config == null ? void 0 : config.autoScale) !== false;
96575
+ }
96576
+ },
95821
96577
  {
95822
96578
  key: "width",
95823
96579
  get: /**