@vvfx/sdk 0.2.1 → 0.2.2-beta.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/{src/config.d.ts → config.d.ts} +24 -1
  2. package/dist/{src/html-overlay → html-overlay}/auto-height-runtime.d.ts +5 -0
  3. package/dist/{src/html-overlay → html-overlay}/manager.d.ts +53 -0
  4. package/dist/{src/html-overlay → html-overlay}/overlay-transform.d.ts +3 -1
  5. package/dist/{src/index.d.ts → index.d.ts} +2 -2
  6. package/dist/index.js +970 -204
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +970 -204
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/layer-order.d.ts +7 -0
  11. package/dist/{src/sdk-item → sdk-item}/card-item.d.ts +2 -6
  12. package/dist/{src/sdk.d.ts → sdk.d.ts} +22 -2
  13. package/dist/{src/types.d.ts → types.d.ts} +17 -18
  14. package/dist/{src/utils → utils}/page-data-utils.d.ts +11 -0
  15. package/package.json +10 -11
  16. /package/dist/{src/exporter → exporter}/config.d.ts +0 -0
  17. /package/dist/{src/exporter → exporter}/const.d.ts +0 -0
  18. /package/dist/{src/exporter → exporter}/export-media.d.ts +0 -0
  19. /package/dist/{src/exporter → exporter}/exporter.d.ts +0 -0
  20. /package/dist/{src/exporter → exporter}/index.d.ts +0 -0
  21. /package/dist/{src/exporter → exporter}/types.d.ts +0 -0
  22. /package/dist/{src/exporter → exporter}/utils.d.ts +0 -0
  23. /package/dist/{src/exporter → exporter}/wav-audio.d.ts +0 -0
  24. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/adsorption-gizmo.d.ts +0 -0
  25. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/control-gizmo.d.ts +0 -0
  26. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/gizmo.d.ts +0 -0
  27. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/icon-gizmo.d.ts +0 -0
  28. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/index.d.ts +0 -0
  29. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/item-create-gizmo.d.ts +0 -0
  30. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/loading-gizmo.d.ts +0 -0
  31. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/mask-gizmo.d.ts +0 -0
  32. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/picture-cut-gizmo.d.ts +0 -0
  33. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/picture-expand-gizmo.d.ts +0 -0
  34. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/preference-gizmo.d.ts +0 -0
  35. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/selector-gizmo.d.ts +0 -0
  36. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/sprite-text-edit-gizmo.d.ts +0 -0
  37. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/text-gizmo.d.ts +0 -0
  38. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/transform-gizmo.d.ts +0 -0
  39. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/type.d.ts +0 -0
  40. /package/dist/{src/gesture-handler → gesture-handler}/index.d.ts +0 -0
  41. /package/dist/{src/gesture-handler → gesture-handler}/src/gesture-handler.d.ts +0 -0
  42. /package/dist/{src/gesture-handler → gesture-handler}/src/icons.d.ts +0 -0
  43. /package/dist/{src/gesture-handler → gesture-handler}/utils.d.ts +0 -0
  44. /package/dist/{src/html-overlay → html-overlay}/document-runtime.d.ts +0 -0
  45. /package/dist/{src/html-overlay → html-overlay}/document-transform.d.ts +0 -0
  46. /package/dist/{src/html-overlay → html-overlay}/dom-order.d.ts +0 -0
  47. /package/dist/{src/html-overlay → html-overlay}/host-message-runtime.d.ts +0 -0
  48. /package/dist/{src/html-overlay → html-overlay}/html-viewport-style.d.ts +0 -0
  49. /package/dist/{src/html-overlay → html-overlay}/index.d.ts +0 -0
  50. /package/dist/{src/html-overlay → html-overlay}/mime-utils.d.ts +0 -0
  51. /package/dist/{src/html-overlay → html-overlay}/path-utils.d.ts +0 -0
  52. /package/dist/{src/html-overlay → html-overlay}/shell-runtime.d.ts +0 -0
  53. /package/dist/{src/math → math}/box2.d.ts +0 -0
  54. /package/dist/{src/math → math}/circle.d.ts +0 -0
  55. /package/dist/{src/math → math}/euler.d.ts +0 -0
  56. /package/dist/{src/math → math}/index.d.ts +0 -0
  57. /package/dist/{src/math → math}/line2.d.ts +0 -0
  58. /package/dist/{src/math → math}/line3.d.ts +0 -0
  59. /package/dist/{src/math → math}/matrix4.d.ts +0 -0
  60. /package/dist/{src/math → math}/plane.d.ts +0 -0
  61. /package/dist/{src/math → math}/quaternion.d.ts +0 -0
  62. /package/dist/{src/math → math}/ray-caster.d.ts +0 -0
  63. /package/dist/{src/math → math}/ray.d.ts +0 -0
  64. /package/dist/{src/math → math}/type.d.ts +0 -0
  65. /package/dist/{src/math → math}/utils.d.ts +0 -0
  66. /package/dist/{src/math → math}/vector2.d.ts +0 -0
  67. /package/dist/{src/math → math}/vector3.d.ts +0 -0
  68. /package/dist/{src/screen-shot → screen-shot}/index.d.ts +0 -0
  69. /package/dist/{src/screen-shot → screen-shot}/screen-shot.d.ts +0 -0
  70. /package/dist/{src/sdk-item → sdk-item}/base-item.d.ts +0 -0
  71. /package/dist/{src/sdk-item → sdk-item}/effects-item.d.ts +0 -0
  72. /package/dist/{src/sdk-item → sdk-item}/frame-item.d.ts +0 -0
  73. /package/dist/{src/sdk-item → sdk-item}/generator-item.d.ts +0 -0
  74. /package/dist/{src/sdk-item → sdk-item}/group-item.d.ts +0 -0
  75. /package/dist/{src/sdk-item → sdk-item}/index.d.ts +0 -0
  76. /package/dist/{src/sdk-item → sdk-item}/sprite-item.d.ts +0 -0
  77. /package/dist/{src/sdk-item → sdk-item}/text-item.d.ts +0 -0
  78. /package/dist/{src/sdk-item → sdk-item}/types.d.ts +0 -0
  79. /package/dist/{src/sdk-item → sdk-item}/video-item.d.ts +0 -0
  80. /package/dist/{src/service → service}/UndoRedo.d.ts +0 -0
  81. /package/dist/{src/shared → shared}/index.d.ts +0 -0
  82. /package/dist/{src/shared → shared}/player.d.ts +0 -0
  83. /package/dist/{src/size-adapte → size-adapte}/index.d.ts +0 -0
  84. /package/dist/{src/size-adapte → size-adapte}/size-adapt.d.ts +0 -0
  85. /package/dist/{src/utils → utils}/background-manager.d.ts +0 -0
  86. /package/dist/{src/utils → utils}/common-utils.d.ts +0 -0
  87. /package/dist/{src/utils → utils}/index.d.ts +0 -0
  88. /package/dist/{src/utils → utils}/interaction-utils.d.ts +0 -0
  89. /package/dist/{src/utils → utils}/json-data-utils.d.ts +0 -0
  90. /package/dist/{src/utils → utils}/layout-utils.d.ts +0 -0
  91. /package/dist/{src/utils → utils}/player-data-utils.d.ts +0 -0
  92. /package/dist/{src/utils → utils}/types.d.ts +0 -0
  93. /package/dist/{src/wireframe → wireframe}/common/box.d.ts +0 -0
  94. /package/dist/{src/wireframe → wireframe}/common/dashed-line.d.ts +0 -0
  95. /package/dist/{src/wireframe → wireframe}/common/line.d.ts +0 -0
  96. /package/dist/{src/wireframe → wireframe}/common/pixi-ext.d.ts +0 -0
  97. /package/dist/{src/wireframe → wireframe}/common/pixi.d.ts +0 -0
  98. /package/dist/{src/wireframe → wireframe}/index.d.ts +0 -0
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: TODO
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 赤芍,何即,不择,意绮
6
- * Version: v0.2.1
6
+ * Version: v0.2.2-beta.11
7
7
  */
8
8
 
9
9
  import * as EFFECTS from '@galacean/effects';
@@ -47154,7 +47154,7 @@ var SelectorGizmo = /*#__PURE__*/ function(Gizmo) {
47154
47154
  var preSelectedItem = this.pageDataUtils.getPreSelectedItem();
47155
47155
  var preSelectedItemBox = this.pageDataUtils.getViewBoxById((_ref = preSelectedItem == null ? void 0 : preSelectedItem.id) != null ? _ref : '');
47156
47156
  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;
47157
- if (!(preSelectedItemBox == null ? void 0 : preSelectedItemBox.isEmpty())) {
47157
+ if (!(preSelectedItemBox == null ? void 0 : preSelectedItemBox.isEmpty()) && !isCardItem(preSelectedItem)) {
47158
47158
  this.graphics.lineStyle(preSelectedWidth, preSelectedColor);
47159
47159
  this.graphics.drawBox(preSelectedItemBox);
47160
47160
  }
@@ -55340,7 +55340,9 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55340
55340
  return;
55341
55341
  }
55342
55342
  var selectedItem = (_selectedItems_ = selectedItems[0]) != null ? _selectedItems_ : undefined;
55343
- var isShfitLockScale = selectedItem && selectedItems.length === 1 && isFrameItem(selectedItem) ? !this.isShiftDown : this.isShiftDown;
55343
+ // html卡片内容在非自动缩放的情况下,拖动的时候内容自适应,因此与智能画板一样,需要默认是自由缩放(即自由改大小)
55344
+ var isAutoFitContentCardItem = selectedItem && isCardItem(selectedItem) && !selectedItem.isAutoScale;
55345
+ var isShiftLockScale = selectedItem && selectedItems.length === 1 && (isFrameItem(selectedItem) || isAutoFitContentCardItem) ? !this.isShiftDown : this.isShiftDown;
55344
55346
  var farthestCorner = this.scaleParam.farthestCorner;
55345
55347
  var isValidScale = (scaleCorner.x - farthestCorner.x) * (this.cursorPoint.x - farthestCorner.x) > 0 && (scaleCorner.y - farthestCorner.y) * (this.cursorPoint.y - farthestCorner.y) > 0;
55346
55348
  if (!isValidScale && this.isLockScale && !this.isShiftDown) {
@@ -55357,7 +55359,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55357
55359
  var currentStartScale = startScale.clone().multiply(lastScalar);
55358
55360
  var currentScale = worldPosition1.clone().subtract(cornerShift).subtract(center1).applyMatrix(rotationMatrix);
55359
55361
  var scalar = new Vector3(1, 1, 1);
55360
- if (!this.isLockScale || isShfitLockScale) {
55362
+ if (!this.isLockScale || isShiftLockScale) {
55361
55363
  scalar.x = isEqual$1(currentStartScale.x, 0) ? 1 : currentScale.x / currentStartScale.x;
55362
55364
  scalar.y = isEqual$1(currentStartScale.y, 0) ? 1 : currentScale.y / currentStartScale.y;
55363
55365
  scalar.z = isEqual$1(currentStartScale.z, 0) ? 1 : currentScale.z / currentStartScale.z;
@@ -55414,6 +55416,33 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55414
55416
  newWidth,
55415
55417
  newHeight
55416
55418
  ], translation1);
55419
+ } else if (isAutoFitContentCardItem) {
55420
+ var currentWidth1 = selectedItem.pixelWidth;
55421
+ var currentHeight1 = selectedItem.pixelHeight;
55422
+ var newWidth1 = currentWidth1 * resultScalar1.x;
55423
+ var newHeight1 = currentHeight1 * resultScalar1.y;
55424
+ this._pageDataUtils.resizeCardItem(selectedItem.id, [
55425
+ newWidth1,
55426
+ newHeight1
55427
+ ], translation1);
55428
+ void this._pageDataUtils.setItemProperty({
55429
+ itemId: selectedItem.id,
55430
+ type: SDKItemType.CARD,
55431
+ property: {
55432
+ width: newWidth1,
55433
+ height: newHeight1
55434
+ }
55435
+ });
55436
+ } else if (selectedItem && selectedItems.length === 1 && isCardItem(selectedItem)) {
55437
+ void this._pageDataUtils.setItemProperty({
55438
+ itemId: selectedItem.id,
55439
+ type: SDKItemType.CARD,
55440
+ property: {
55441
+ width: selectedItem.width * resultScalar1.x,
55442
+ height: selectedItem.height * resultScalar1.y
55443
+ }
55444
+ });
55445
+ this._pageDataUtils.moveItem(selectedItem.id, translation1);
55417
55446
  } else {
55418
55447
  // 普通元素的缩放逻辑
55419
55448
  selectedItems.forEach(function(item) {
@@ -55738,6 +55767,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55738
55767
  var selectedItems = this._pageDataUtils.getSelectedItems();
55739
55768
  var isTemplateMode = SDK.config.mode === 'template';
55740
55769
  var selectedItem = selectedItems.length === 1 ? selectedItems[0] : undefined;
55770
+ var isSingleCardItem = isCardItem(selectedItem);
55741
55771
  var isGeneratorItem = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.GENERATOR;
55742
55772
  var isAutoLayoutFrame = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.FRAME && (selectedItem == null ? void 0 : selectedItem.layoutMode) === FrameLayoutMode.AUTO;
55743
55773
  var canScale = selectedItems.length === 1 && (selectedItem == null ? void 0 : selectedItem.type) !== SDKItemType.GROUP && !isAutoLayoutFrame && !isGeneratorItem;
@@ -55777,9 +55807,11 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55777
55807
  this.wireframe.totalBox.copyFrom(box).expandByScalar(totalBoxExpandScalar);
55778
55808
  // 根据box获取边缘线
55779
55809
  var corners = this.wireframe.box.corners;
55780
- corners.forEach(function(corner, i) {
55781
- _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55782
- });
55810
+ if (!isSingleCardItem) {
55811
+ corners.forEach(function(corner, i) {
55812
+ _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55813
+ });
55814
+ }
55783
55815
  var _SDK_config_gestureHandlerConfig_transformGizmoConfig = SDK.config.gestureHandlerConfig.transformGizmoConfig, scaleCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.scaleCircleSize, rotationCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.rotationCircleSize;
55784
55816
  // 成组暂不支持缩放
55785
55817
  if (selectedItems.length === 1) {
@@ -59630,12 +59662,6 @@ var MAX_ITEM_DISTANCE_THRESHOLD = 100000;
59630
59662
  /**
59631
59663
  * @description SDKItem position 属性的数字精度(保留小数位数)
59632
59664
  */ var POSITION_PRECISION = 4;
59633
- function isCardHTMLContentValue(value) {
59634
- return (value == null ? void 0 : value.kind) === 'inline' || (value == null ? void 0 : value.kind) === 'dom' || (value == null ? void 0 : value.kind) === 'document';
59635
- }
59636
- function isCardHTMLValue(value) {
59637
- return isCardHTMLContentValue(value == null ? void 0 : value.content);
59638
- }
59639
59665
  var PageDataUtils = /*#__PURE__*/ function() {
59640
59666
  function PageDataUtils(player, container, emitter, sdk) {
59641
59667
  this.player = player;
@@ -60453,11 +60479,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
60453
60479
  property: property
60454
60480
  }));
60455
60481
  } else if ((existingSDKItem == null ? void 0 : existingSDKItem.type) == SDKItemType.CARD) {
60456
- var cardType = existingSDKItem.cardType, html = existingSDKItem.html;
60482
+ var cardType = existingSDKItem.cardType;
60457
60483
  sdkItem = new CardItem(_extends({}, baseOptions, {
60458
60484
  property: _extends({}, property, {
60459
- cardType: cardType,
60460
- html: html
60485
+ cardType: cardType
60461
60486
  })
60462
60487
  }));
60463
60488
  } else {
@@ -60684,6 +60709,19 @@ var PageDataUtils = /*#__PURE__*/ function() {
60684
60709
  }).call(this);
60685
60710
  };
60686
60711
  /**
60712
+ * @description 设置元素extension字段
60713
+ */ _proto.setItemExtension = function setItemExtension(itemId, extension) {
60714
+ var item = this.getSDKItem(itemId);
60715
+ if (!item) {
60716
+ console.warn('setItemExtension: item not found');
60717
+ return;
60718
+ }
60719
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.entries(extension)), _step; !(_step = _iterator()).done;){
60720
+ var _step_value = _step.value, key = _step_value[0], value = _step_value[1];
60721
+ item.extension.set(key, value);
60722
+ }
60723
+ };
60724
+ /**
60687
60725
  * @description 场景 1: 设置单个元素的单个属性
60688
60726
  */ _proto.setSingleItemSingleProperty = function setSingleItemSingleProperty(param) {
60689
60727
  return _async_to_generator(function() {
@@ -61041,40 +61079,35 @@ var PageDataUtils = /*#__PURE__*/ function() {
61041
61079
  3,
61042
61080
  31
61043
61081
  ];
61044
- case 'html':
61045
- return [
61046
- 3,
61047
- 32
61048
- ];
61049
61082
  case 'position':
61050
61083
  return [
61051
61084
  3,
61052
- 33
61085
+ 32
61053
61086
  ];
61054
61087
  case 'rotation':
61055
61088
  return [
61056
61089
  3,
61057
- 34
61090
+ 33
61058
61091
  ];
61059
61092
  case 'scale':
61060
61093
  return [
61061
61094
  3,
61062
- 35
61095
+ 34
61063
61096
  ];
61064
61097
  case 'layoutMode':
61065
61098
  return [
61066
61099
  3,
61067
- 36
61100
+ 35
61068
61101
  ];
61069
61102
  case 'visible':
61070
61103
  return [
61071
61104
  3,
61072
- 37
61105
+ 36
61073
61106
  ];
61074
61107
  }
61075
61108
  return [
61076
61109
  3,
61077
- 38
61110
+ 37
61078
61111
  ];
61079
61112
  case 1:
61080
61113
  {
@@ -61087,7 +61120,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61087
61120
  }
61088
61121
  return [
61089
61122
  3,
61090
- 39
61123
+ 38
61091
61124
  ];
61092
61125
  }
61093
61126
  case 2:
@@ -61098,7 +61131,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61098
61131
  }
61099
61132
  return [
61100
61133
  3,
61101
- 39
61134
+ 38
61102
61135
  ];
61103
61136
  }
61104
61137
  case 3:
@@ -61130,7 +61163,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61130
61163
  case 5:
61131
61164
  return [
61132
61165
  3,
61133
- 39
61166
+ 38
61134
61167
  ];
61135
61168
  case 6:
61136
61169
  {
@@ -61147,7 +61180,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61147
61180
  }
61148
61181
  return [
61149
61182
  3,
61150
- 39
61183
+ 38
61151
61184
  ];
61152
61185
  }
61153
61186
  case 7:
@@ -61161,7 +61194,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61161
61194
  }
61162
61195
  return [
61163
61196
  3,
61164
- 39
61197
+ 38
61165
61198
  ];
61166
61199
  }
61167
61200
  case 8:
@@ -61174,7 +61207,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61174
61207
  }
61175
61208
  return [
61176
61209
  3,
61177
- 39
61210
+ 38
61178
61211
  ];
61179
61212
  }
61180
61213
  case 9:
@@ -61188,7 +61221,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61188
61221
  }
61189
61222
  return [
61190
61223
  3,
61191
- 39
61224
+ 38
61192
61225
  ];
61193
61226
  }
61194
61227
  case 10:
@@ -61201,7 +61234,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61201
61234
  }
61202
61235
  return [
61203
61236
  3,
61204
- 39
61237
+ 38
61205
61238
  ];
61206
61239
  }
61207
61240
  case 11:
@@ -61214,7 +61247,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61214
61247
  }
61215
61248
  return [
61216
61249
  3,
61217
- 39
61250
+ 38
61218
61251
  ];
61219
61252
  }
61220
61253
  case 12:
@@ -61234,7 +61267,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61234
61267
  }
61235
61268
  return [
61236
61269
  3,
61237
- 39
61270
+ 38
61238
61271
  ];
61239
61272
  }
61240
61273
  case 13:
@@ -61276,7 +61309,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61276
61309
  }
61277
61310
  return [
61278
61311
  3,
61279
- 39
61312
+ 38
61280
61313
  ];
61281
61314
  }
61282
61315
  case 14:
@@ -61311,7 +61344,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61311
61344
  }
61312
61345
  return [
61313
61346
  3,
61314
- 39
61347
+ 38
61315
61348
  ];
61316
61349
  }
61317
61350
  case 15:
@@ -61325,7 +61358,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61325
61358
  }
61326
61359
  return [
61327
61360
  3,
61328
- 39
61361
+ 38
61329
61362
  ];
61330
61363
  }
61331
61364
  case 16:
@@ -61357,7 +61390,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61357
61390
  case 20:
61358
61391
  return [
61359
61392
  3,
61360
- 39
61393
+ 38
61361
61394
  ];
61362
61395
  case 21:
61363
61396
  if (!(typeof propertyValue === 'string' && playerItem.type === spec.ItemType.video)) return [
@@ -61388,7 +61421,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61388
61421
  case 25:
61389
61422
  return [
61390
61423
  3,
61391
- 39
61424
+ 38
61392
61425
  ];
61393
61426
  case 26:
61394
61427
  if (!(playerItem.type === spec.ItemType.null)) return [
@@ -61433,7 +61466,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61433
61466
  case 28:
61434
61467
  return [
61435
61468
  3,
61436
- 39
61469
+ 38
61437
61470
  ];
61438
61471
  case 29:
61439
61472
  {
@@ -61445,7 +61478,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61445
61478
  }
61446
61479
  return [
61447
61480
  3,
61448
- 39
61481
+ 38
61449
61482
  ];
61450
61483
  }
61451
61484
  case 30:
@@ -61458,7 +61491,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61458
61491
  }
61459
61492
  return [
61460
61493
  3,
61461
- 39
61494
+ 38
61462
61495
  ];
61463
61496
  }
61464
61497
  case 31:
@@ -61471,20 +61504,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61471
61504
  }
61472
61505
  return [
61473
61506
  3,
61474
- 39
61507
+ 38
61475
61508
  ];
61476
61509
  }
61477
61510
  case 32:
61478
- {
61479
- if (isCardItem(targetItem)) {
61480
- targetItem.html = isCardHTMLValue(propertyValue) ? propertyValue : undefined;
61481
- }
61482
- return [
61483
- 3,
61484
- 39
61485
- ];
61486
- }
61487
- case 33:
61488
61511
  {
61489
61512
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61490
61513
  pixelTranslation = propertyValue.map(function(v, i) {
@@ -61497,10 +61520,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61497
61520
  }
61498
61521
  return [
61499
61522
  3,
61500
- 39
61523
+ 38
61501
61524
  ];
61502
61525
  }
61503
- case 34:
61526
+ case 33:
61504
61527
  {
61505
61528
  if (Array.isArray(propertyValue) && propertyValue.length === 3) {
61506
61529
  rotation = propertyValue.map(function(v, i) {
@@ -61511,10 +61534,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61511
61534
  }
61512
61535
  return [
61513
61536
  3,
61514
- 39
61537
+ 38
61515
61538
  ];
61516
61539
  }
61517
- case 35:
61540
+ case 34:
61518
61541
  {
61519
61542
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61520
61543
  currentScale = targetItem.property.scale;
@@ -61528,10 +61551,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61528
61551
  }
61529
61552
  return [
61530
61553
  3,
61531
- 39
61554
+ 38
61532
61555
  ];
61533
61556
  }
61534
- case 36:
61557
+ case 35:
61535
61558
  {
61536
61559
  if (propertyValue === FrameLayoutMode.AUTO || propertyValue === FrameLayoutMode.FREE) {
61537
61560
  frameComponent = playerItem.getComponent(FrameComponent);
@@ -61541,10 +61564,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61541
61564
  }
61542
61565
  return [
61543
61566
  3,
61544
- 39
61567
+ 38
61545
61568
  ];
61546
61569
  }
61547
- case 37:
61570
+ case 36:
61548
61571
  {
61549
61572
  if (typeof propertyValue === 'boolean') {
61550
61573
  playerItem.setVisible(propertyValue);
@@ -61557,10 +61580,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61557
61580
  }
61558
61581
  return [
61559
61582
  3,
61560
- 39
61583
+ 38
61561
61584
  ];
61562
61585
  }
61563
- case 38:
61586
+ case 37:
61564
61587
  {
61565
61588
  console.log('ignore property name ', propertyName);
61566
61589
  // 对于未明确处理的属性,尝试直接设置到 property 对象
@@ -61568,8 +61591,8 @@ var PageDataUtils = /*#__PURE__*/ function() {
61568
61591
  targetItem.property[propertyName] = propertyValue;
61569
61592
  }
61570
61593
  }
61571
- _state.label = 39;
61572
- case 39:
61594
+ _state.label = 38;
61595
+ case 38:
61573
61596
  // 非位置属性需要刷新播放器
61574
61597
  // template 模式下保持暂停态以避免播放器自动播放,editor 模式继续推进
61575
61598
  if (![
@@ -62449,6 +62472,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
62449
62472
  }
62450
62473
  break;
62451
62474
  }
62475
+ case 'cardType':
62476
+ {
62477
+ break;
62478
+ }
62452
62479
  default:
62453
62480
  {
62454
62481
  console.warn("Target property " + propertyName + " can not be changed.");
@@ -63041,12 +63068,15 @@ var PageDataUtils = /*#__PURE__*/ function() {
63041
63068
  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 ? [
63042
63069
  1,
63043
63070
  1
63044
- ] : _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 ? generateGUID() : _cardInfo_id, extension = cardInfo.extension;
63071
+ ] : _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 ? generateGUID() : _cardInfo_id, extension = cardInfo.extension;
63045
63072
  // 校验 cardType 是否已在配置中注册
63073
+ var cardTypeConfig = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
63074
+ return t.type === cardType;
63075
+ });
63046
63076
  var registeredTypes = SDK.config.itemConfig.cardConfig.cardTypes.map(function(t) {
63047
63077
  return t.type;
63048
63078
  });
63049
- if (!registeredTypes.includes(cardType)) {
63079
+ if (!cardTypeConfig) {
63050
63080
  console.warn('CardItem cardType "' + cardType + '" is not registered. Registered types: ' + registeredTypes.join(', '));
63051
63081
  return;
63052
63082
  }
@@ -63090,9 +63120,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
63090
63120
  width: width,
63091
63121
  height: height,
63092
63122
  scale: [].concat(scale),
63093
- cardType: cardType,
63094
- autoHeight: autoHeight,
63095
- html: html
63123
+ cardType: cardType
63096
63124
  },
63097
63125
  extension: extension
63098
63126
  });
@@ -64474,8 +64502,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
64474
64502
  scalar.y
64475
64503
  ],
64476
64504
  rotation: [].concat(rotation),
64477
- position: [].concat(resultPosition),
64478
- html: sdkItem.html
64505
+ position: [].concat(resultPosition)
64479
64506
  },
64480
64507
  extension: extension
64481
64508
  };
@@ -65521,7 +65548,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
65521
65548
  _this = this;
65522
65549
  changeProeprty = function changeProeprty(targetCreateInfo) {
65523
65550
  return _async_to_generator(function() {
65524
- var currentCreateInfo;
65551
+ var currentCreateInfo, itemId;
65525
65552
  return _ts_generator(this, function(_state) {
65526
65553
  switch(_state.label){
65527
65554
  case 0:
@@ -65532,16 +65559,20 @@ var PageDataUtils = /*#__PURE__*/ function() {
65532
65559
  2
65533
65560
  ];
65534
65561
  }
65562
+ itemId = targetCreateInfo.id;
65535
65563
  return [
65536
65564
  4,
65537
65565
  this.setItemProperty({
65538
- itemId: currentCreateInfo.id,
65566
+ itemId: itemId,
65539
65567
  type: currentCreateInfo.type,
65540
65568
  property: targetCreateInfo.property
65541
65569
  })
65542
65570
  ];
65543
65571
  case 1:
65544
65572
  _state.sent();
65573
+ if (targetCreateInfo.extension) {
65574
+ this.setItemExtension(itemId, targetCreateInfo.extension);
65575
+ }
65545
65576
  return [
65546
65577
  2
65547
65578
  ];
@@ -65859,35 +65890,56 @@ var PageDataUtils = /*#__PURE__*/ function() {
65859
65890
  };
65860
65891
  _proto.asyncAddItemByCreateInfos = function asyncAddItemByCreateInfos(createInfos) {
65861
65892
  return _async_to_generator(function() {
65862
- var _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, createInfo, id, type, url, textureId, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65893
+ var _loop, _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65863
65894
  return _ts_generator(this, function(_state) {
65864
65895
  switch(_state.label){
65865
65896
  case 0:
65866
- _this = this;
65867
- createInfoWithIds = createInfos.map(function(createInfo) {
65868
- return Object.assign({}, createInfo, createInfo.id ? {} : {
65869
- id: generateGUID()
65870
- });
65871
- });
65872
- itemToTextureInfo = new Map();
65873
- // 预处理所有 createInfo,分配 textureId
65874
- for(_iterator = _create_for_of_iterator_helper_loose(createInfoWithIds); !(_step = _iterator()).done;){
65875
- createInfo = _step.value;
65876
- id = createInfo.id;
65877
- type = createInfo.type;
65878
- url = type === SDKItemType.SPRITE ? createInfo.property.image : type === SDKItemType.VIDEO ? createInfo.property.video : undefined;
65879
- if ((type === SDKItemType.SPRITE || type === SDKItemType.VIDEO) && url) {
65880
- textureId = generateGUID();
65881
- itemToTextureInfo.set(id, {
65897
+ _loop = function() {
65898
+ var createInfo = _step.value;
65899
+ var _ref = function() {
65900
+ switch(createInfo.type){
65901
+ case SDKItemType.SPRITE:
65902
+ {
65903
+ return {
65904
+ url: createInfo.property.image,
65905
+ type: 'image'
65906
+ };
65907
+ }
65908
+ case SDKItemType.VIDEO:
65909
+ {
65910
+ return {
65911
+ url: createInfo.property.video,
65912
+ type: 'video'
65913
+ };
65914
+ }
65915
+ default:
65916
+ {
65917
+ return {};
65918
+ }
65919
+ }
65920
+ }(), url = _ref.url, type = _ref.type;
65921
+ if (url && type) {
65922
+ var textureId = generateGUID();
65923
+ itemToTextureInfo.set(createInfo.id, {
65882
65924
  id: textureId,
65883
65925
  url: url,
65884
- type: type === SDKItemType.SPRITE ? 'image' : 'video'
65926
+ type: type
65885
65927
  });
65886
65928
  Object.assign(createInfo, {
65887
65929
  textureId: textureId
65888
65930
  });
65889
65931
  }
65890
- }
65932
+ };
65933
+ _this = this;
65934
+ createInfoWithIds = createInfos.map(function(createInfo) {
65935
+ var _createInfo_id;
65936
+ return Object.assign({}, createInfo, {
65937
+ id: (_createInfo_id = createInfo.id) != null ? _createInfo_id : generateGUID()
65938
+ });
65939
+ });
65940
+ itemToTextureInfo = new Map();
65941
+ // 预处理所有 createInfo,分配 textureId
65942
+ for(_iterator = _create_for_of_iterator_helper_loose(createInfoWithIds); !(_step = _iterator()).done;)_loop();
65891
65943
  // 并行创建所有 item
65892
65944
  toAddedCreateInfo = createInfoWithIds.filter(function(createInfo) {
65893
65945
  return ![
@@ -66856,6 +66908,51 @@ var PageDataUtils = /*#__PURE__*/ function() {
66856
66908
  * @param id 元素id
66857
66909
  * @param size 目标大小 [width, height]
66858
66910
  * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66911
+ */ _proto.resizeCardItem = function resizeCardItem(id, size, translation) {
66912
+ var _frameController_children;
66913
+ var frameItem = this.getSDKItem(id);
66914
+ if (!frameItem) {
66915
+ return;
66916
+ }
66917
+ var newWidth = size[0], newHeight = size[1];
66918
+ // const originalWidth = frameItem.property.width
66919
+ // 计算世界尺寸(供后续使用)
66920
+ var viewSize = this.interactionUtils.getViewSizeByPixelSize(new Vector2(newWidth, newHeight));
66921
+ var worldSize = this.interactionUtils.getWorldSizeByViewSize(viewSize).abs();
66922
+ // 1 更新 Player 层的预合成和子元素
66923
+ // 1.1 更新 Player Item(空节点控制器)的大小
66924
+ var frameController = this.getPlayerItemById(id);
66925
+ if (frameController) {
66926
+ frameController.transform.setSize(worldSize.x, worldSize.y);
66927
+ // 如果有位移,更新位置
66928
+ if (translation && (translation.x !== 0 || translation.y !== 0)) {
66929
+ var currentPosition = frameController.transform.position;
66930
+ frameController.setPosition(currentPosition.x + translation.x, currentPosition.y + translation.y, currentPosition.z);
66931
+ }
66932
+ }
66933
+ // 1.2 更新 Player Children Item 的大小
66934
+ var subCompositionItem = frameController == null ? void 0 : (_frameController_children = frameController.children) == null ? void 0 : _frameController_children[0];
66935
+ if (subCompositionItem && translation) {
66936
+ // 更新子元素
66937
+ subCompositionItem.children.forEach(function(item) {
66938
+ var _item;
66939
+ var _item_transform_getParentMatrix;
66940
+ var parentMatrix = new Matrix4().copyFrom((_item_transform_getParentMatrix = item.transform.getParentMatrix()) != null ? _item_transform_getParentMatrix : new Matrix4());
66941
+ parentMatrix.setPosition(new Vector3());
66942
+ var result = translation.clone().applyMatrix(parentMatrix.invert()).negate();
66943
+ (_item = item).translate.apply(_item, [].concat(result.toArray()));
66944
+ item.transform.updateLocalMatrix();
66945
+ });
66946
+ }
66947
+ // 2: 刷新 SDKItem 数据
66948
+ // 更新 FrameItem 的 property
66949
+ this.refreshSDKItem(frameItem.id);
66950
+ };
66951
+ /**
66952
+ * @description 修改画板元素大小
66953
+ * @param id 元素id
66954
+ * @param size 目标大小 [width, height]
66955
+ * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66859
66956
  */ _proto.resizeFrameItem = function resizeFrameItem(id, size, translation) {
66860
66957
  var _this = this;
66861
66958
  var _frameController_children;
@@ -83060,43 +83157,12 @@ var BaseConfig = {
83060
83157
  },
83061
83158
  cardConfig: {
83062
83159
  backgroundColor: [
83063
- 0.6,
83064
- 0.6,
83065
- 0.6,
83066
- 0.12
83160
+ 1,
83161
+ 1,
83162
+ 1,
83163
+ 0
83067
83164
  ],
83068
- cardTypes: [
83069
- {
83070
- type: 'character',
83071
- label: '角色图',
83072
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83073
- },
83074
- {
83075
- type: 'environment',
83076
- label: '环境图',
83077
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83078
- },
83079
- {
83080
- type: 'storyboard',
83081
- label: '分镜图',
83082
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83083
- },
83084
- {
83085
- type: 'scene-clip',
83086
- label: '场景剪辑',
83087
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83088
- },
83089
- {
83090
- type: 'video-compose',
83091
- label: '视频合成',
83092
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83093
- },
83094
- {
83095
- type: 'video-generate',
83096
- label: '生成视频',
83097
- iconUrl: 'https://mdn.alipayobjects.com/huamei_ixsp8m/afts/img/A*F2wVS7x0MfIAAAAAQBAAAAgAev-aAQ/original'
83098
- }
83099
- ]
83165
+ cardTypes: []
83100
83166
  }
83101
83167
  }
83102
83168
  };
@@ -91425,11 +91491,18 @@ function isCardHTMLAutoHeightMessage(data, id) {
91425
91491
  var message = data;
91426
91492
  return message.source === 'vvfx-card-html-auto-height' && message.id === id && typeof message.height === 'number';
91427
91493
  }
91494
+ function requestCardHTMLAutoHeight(iframe, id) {
91495
+ var _iframe_contentWindow;
91496
+ (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage({
91497
+ source: 'vvfx-card-html-auto-height-request',
91498
+ id: id
91499
+ }, '*');
91500
+ }
91428
91501
  function withCardHTMLAutoHeightBridge(html, id) {
91429
91502
  if (!id) {
91430
91503
  return html;
91431
91504
  }
91432
- 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>";
91505
+ 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>";
91433
91506
  if (/<\/body>/i.test(html)) {
91434
91507
  return html.replace(/<\/body>/i, "" + script + "</body>");
91435
91508
  }
@@ -91702,30 +91775,38 @@ function syncElementStackOrder(_container, elements) {
91702
91775
  });
91703
91776
  }
91704
91777
 
91705
- function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY) {
91778
+ function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, _autoScale) {
91706
91779
  if (offsetX === void 0) offsetX = 0;
91707
91780
  if (offsetY === void 0) offsetY = 0;
91708
91781
  if (box.corners.length === 4 && width > 0 && height > 0) {
91709
91782
  var _box_corners = box.corners, rightTop = _box_corners[0], leftBottom = _box_corners[2], leftTop = _box_corners[3];
91710
- var a = (rightTop.x - leftTop.x) / width;
91711
- var b = (rightTop.y - leftTop.y) / width;
91712
- var c = (leftBottom.x - leftTop.x) / height;
91713
- var d = (leftBottom.y - leftTop.y) / height;
91783
+ var contentWidth = width;
91784
+ var contentHeight = height;
91785
+ var a = (rightTop.x - leftTop.x) / contentWidth;
91786
+ var b = (rightTop.y - leftTop.y) / contentWidth;
91787
+ var c = (leftBottom.x - leftTop.x) / contentHeight;
91788
+ var d = (leftBottom.y - leftTop.y) / contentHeight;
91714
91789
  var e = leftTop.x - offsetX;
91715
91790
  var f = leftTop.y - offsetY;
91716
91791
  return {
91717
91792
  left: '0px',
91718
91793
  top: '0px',
91719
- width: "" + width + "px",
91720
- height: "" + height + "px",
91794
+ width: "" + formatPixelNumber(contentWidth) + "px",
91795
+ height: "" + formatPixelNumber(contentHeight) + "px",
91796
+ contentWidth: contentWidth,
91797
+ contentHeight: contentHeight,
91721
91798
  transform: "matrix(" + formatMatrixNumber(a) + ", " + formatMatrixNumber(b) + ", " + formatMatrixNumber(c) + ", " + formatMatrixNumber(d) + ", " + formatMatrixNumber(e) + ", " + formatMatrixNumber(f) + ")"
91722
91799
  };
91723
91800
  }
91801
+ var contentWidth1 = box.max.x - box.min.x;
91802
+ var contentHeight1 = box.max.y - box.min.y;
91724
91803
  return {
91725
91804
  left: "" + (box.min.x - offsetX) + "px",
91726
91805
  top: "" + (box.min.y - offsetY) + "px",
91727
- width: "" + (box.max.x - box.min.x) + "px",
91728
- height: "" + (box.max.y - box.min.y) + "px",
91806
+ width: "" + contentWidth1 + "px",
91807
+ height: "" + contentHeight1 + "px",
91808
+ contentWidth: contentWidth1,
91809
+ contentHeight: contentHeight1,
91729
91810
  transform: ''
91730
91811
  };
91731
91812
  }
@@ -91748,6 +91829,10 @@ function formatMatrixNumber(value) {
91748
91829
  var normalized = Object.is(value, -0) ? 0 : value;
91749
91830
  return Number(normalized.toFixed(6)).toString();
91750
91831
  }
91832
+ function formatPixelNumber(value) {
91833
+ var normalized = Object.is(value, -0) ? 0 : value;
91834
+ return Number(normalized.toFixed(6)).toString();
91835
+ }
91751
91836
 
91752
91837
  function mountHTMLShell(container, content, shell) {
91753
91838
  if (!shell) {
@@ -91768,6 +91853,26 @@ function mountHTMLShell(container, content, shell) {
91768
91853
 
91769
91854
  var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
91770
91855
  var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
91856
+ var CONTENT_INTERACTIVE_SELECTOR = [
91857
+ '[data-vvfx-html-interaction-zone="self"]',
91858
+ '[data-vvfx-html-interaction-zone="subtree"]',
91859
+ 'a[href]',
91860
+ 'button:not([disabled])',
91861
+ 'input:not([disabled])',
91862
+ 'textarea:not([disabled])',
91863
+ 'select:not([disabled])',
91864
+ 'summary',
91865
+ 'video[controls]',
91866
+ 'audio[controls]',
91867
+ '[contenteditable]:not([contenteditable="false"])',
91868
+ '[role="button"]',
91869
+ '[role="link"]',
91870
+ '[role="textbox"]',
91871
+ '[tabindex]:not([tabindex="-1"])'
91872
+ ].join(', ');
91873
+ var CONTENT_INTERACTION_NONE_SELECTOR = [
91874
+ '[data-vvfx-html-interaction-zone="none"]'
91875
+ ].join(', ');
91771
91876
  var EDITING_VIEWPORT_PADDING = 48;
91772
91877
  var EDITING_VIEWPORT_BOX_SCALE = 1.1;
91773
91878
  var AUTO_HEIGHT_EPSILON = 0.5;
@@ -91777,14 +91882,20 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91777
91882
  var _this = this;
91778
91883
  this.options = options;
91779
91884
  this.eventCleanups = [];
91885
+ this.htmlRootConfigCleanups = new WeakMap();
91780
91886
  this.state = {
91781
91887
  frameElements: new Map(),
91782
91888
  elements: new Map(),
91889
+ selectionElements: new Map(),
91783
91890
  contentScaleElements: new Map(),
91784
91891
  contentElements: new Map(),
91785
91892
  contentMountElements: new Map(),
91893
+ contentInteractionZones: new Map(),
91894
+ contentInteractionZoneCleanups: new Map(),
91895
+ contentInteractionResizeCleanups: new Map(),
91786
91896
  contents: new Map(),
91787
91897
  cleanups: new Map(),
91898
+ autoHeightModes: new Map(),
91788
91899
  autoHeightCleanups: new Map(),
91789
91900
  autoHeightFrames: new Map()
91790
91901
  };
@@ -91801,6 +91912,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91801
91912
  }
91802
91913
  return;
91803
91914
  }
91915
+ if (!_this.isEditableCard(targetId)) {
91916
+ return;
91917
+ }
91804
91918
  event.preventDefault();
91805
91919
  event.stopPropagation();
91806
91920
  _this.enterEditing(targetId);
@@ -91816,6 +91930,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91816
91930
  _this.exitEditing();
91817
91931
  };
91818
91932
  this.handleContainerMouseMove = function(event) {
91933
+ _this.scheduleActiveContentInteractionSync(event);
91819
91934
  var hoverShellInteractiveId = _this.getHoverShellInteractiveIdByEvent(event);
91820
91935
  if (_this.state.hoverShellInteractiveId === hoverShellInteractiveId) {
91821
91936
  return;
@@ -91829,7 +91944,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91829
91944
  _this.syncContentInteraction(hoverShellInteractiveId);
91830
91945
  }
91831
91946
  };
91832
- this.handleContainerMouseLeave = function() {
91947
+ this.handleContainerMouseLeave = function(event) {
91948
+ if (_this.isMouseLeaveWithinContainer(event)) {
91949
+ return;
91950
+ }
91951
+ if (_this.contentInteractionFrame !== undefined) {
91952
+ cancelAnimationFrame(_this.contentInteractionFrame);
91953
+ _this.contentInteractionFrame = undefined;
91954
+ }
91955
+ _this.pendingContentInteractionEvent = undefined;
91956
+ _this.setActiveContentInteraction(undefined);
91833
91957
  var previousId = _this.state.hoverShellInteractiveId;
91834
91958
  if (!previousId) {
91835
91959
  return;
@@ -91837,6 +91961,33 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91837
91961
  _this.state.hoverShellInteractiveId = undefined;
91838
91962
  _this.syncContentInteraction(previousId);
91839
91963
  };
91964
+ this.handleContainerContextMenu = function(event) {
91965
+ var activeInteraction = _this.state.activeContentInteraction;
91966
+ if (!activeInteraction || !_this.isEventInsideOverlay(activeInteraction.id, event) || _this.isHTMLContextMenuEvent(event)) {
91967
+ return;
91968
+ }
91969
+ var canvas = _this.options.getCanvasEventTarget == null ? void 0 : _this.options.getCanvasEventTarget.call(_this.options);
91970
+ if (!canvas) {
91971
+ return;
91972
+ }
91973
+ event.preventDefault();
91974
+ event.stopPropagation();
91975
+ _this.setActiveContentInteraction(undefined);
91976
+ canvas.dispatchEvent(new MouseEvent('contextmenu', {
91977
+ bubbles: true,
91978
+ cancelable: true,
91979
+ clientX: event.clientX,
91980
+ clientY: event.clientY,
91981
+ screenX: event.screenX,
91982
+ screenY: event.screenY,
91983
+ button: event.button,
91984
+ buttons: event.buttons,
91985
+ ctrlKey: event.ctrlKey,
91986
+ shiftKey: event.shiftKey,
91987
+ altKey: event.altKey,
91988
+ metaKey: event.metaKey
91989
+ }));
91990
+ };
91840
91991
  this.isAutoHeightMessage = isCardHTMLAutoHeightMessage;
91841
91992
  }
91842
91993
  var _proto = HTMLOverlayManager.prototype;
@@ -91850,7 +92001,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91850
92001
  layer.style.position = 'absolute';
91851
92002
  layer.style.inset = '0';
91852
92003
  layer.style.pointerEvents = 'none';
91853
- layer.style.zIndex = '1';
91854
92004
  container.appendChild(layer);
91855
92005
  this.state.layer = layer;
91856
92006
  this.initDOMEvents();
@@ -91863,16 +92013,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91863
92013
  cancelAnimationFrame(this.state.updateFrame);
91864
92014
  this.state.updateFrame = undefined;
91865
92015
  }
92016
+ if (this.contentInteractionFrame !== undefined) {
92017
+ cancelAnimationFrame(this.contentInteractionFrame);
92018
+ this.contentInteractionFrame = undefined;
92019
+ }
92020
+ this.pendingContentInteractionEvent = undefined;
91866
92021
  this.state.cleanups.forEach(function(cleanup) {
91867
92022
  cleanup();
91868
92023
  });
91869
92024
  this.state.frameElements.clear();
91870
92025
  this.state.elements.clear();
92026
+ this.state.selectionElements.clear();
91871
92027
  this.state.contentScaleElements.clear();
91872
92028
  this.state.contentElements.clear();
91873
92029
  this.state.contentMountElements.clear();
92030
+ this.state.contentInteractionZones.clear();
92031
+ this.state.contentInteractionZoneCleanups.forEach(function(cleanup) {
92032
+ cleanup();
92033
+ });
92034
+ this.state.contentInteractionZoneCleanups.clear();
92035
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92036
+ cleanup();
92037
+ });
92038
+ this.state.contentInteractionResizeCleanups.clear();
91874
92039
  this.state.contents.clear();
91875
92040
  this.state.cleanups.clear();
92041
+ this.state.autoHeightModes.clear();
91876
92042
  this.state.autoHeightCleanups.forEach(function(cleanup) {
91877
92043
  cleanup();
91878
92044
  });
@@ -91887,10 +92053,12 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91887
92053
  this.eventCleanups = [];
91888
92054
  (_this_state_layer = this.state.layer) == null ? void 0 : _this_state_layer.remove();
91889
92055
  this.state.layer = undefined;
92056
+ this.state.selectionLayer = undefined;
91890
92057
  this.options.container.removeEventListener('dblclick', this.handleContainerDoubleClick, true);
91891
92058
  this.options.container.removeEventListener('mousedown', this.handleContainerMouseDown, true);
91892
92059
  this.options.container.removeEventListener('mousemove', this.handleContainerMouseMove, true);
91893
92060
  this.options.container.removeEventListener('mouseleave', this.handleContainerMouseLeave, true);
92061
+ this.options.container.removeEventListener('contextmenu', this.handleContainerContextMenu, true);
91894
92062
  };
91895
92063
  _proto.scheduleRender = function scheduleRender() {
91896
92064
  var _this = this;
@@ -91902,6 +92070,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91902
92070
  _this.render();
91903
92071
  });
91904
92072
  };
92073
+ _proto.invalidateCardHTML = function invalidateCardHTML(id) {
92074
+ this.cleanupOverlayContent(id);
92075
+ this.invalidateContentInteractionZones(id);
92076
+ };
91905
92077
  _proto.rasterizeCard = function rasterizeCard(id, options) {
91906
92078
  return _async_to_generator(function() {
91907
92079
  var contentOverlay, capture, _ref, _options_pixelRatio, image, error;
@@ -91994,6 +92166,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91994
92166
  var events = [
91995
92167
  'pageDataChange',
91996
92168
  'selectedItemChange',
92169
+ 'preSelectedItemChange',
91997
92170
  'itemPropertyChange',
91998
92171
  'viewportTransform',
91999
92172
  'viewRebuildFinish'
@@ -92003,6 +92176,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92003
92176
  if (event === 'viewportTransform') {
92004
92177
  _this.handleViewportTransform();
92005
92178
  }
92179
+ _this.invalidateContentInteractionZones();
92006
92180
  _this.scheduleRender();
92007
92181
  });
92008
92182
  });
@@ -92012,6 +92186,24 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92012
92186
  this.options.container.addEventListener('mousedown', this.handleContainerMouseDown, true);
92013
92187
  this.options.container.addEventListener('mousemove', this.handleContainerMouseMove, true);
92014
92188
  this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
92189
+ this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
92190
+ };
92191
+ _proto.isMouseLeaveWithinContainer = function isMouseLeaveWithinContainer(event) {
92192
+ var relatedTarget = event.relatedTarget;
92193
+ if (!relatedTarget) {
92194
+ return false;
92195
+ }
92196
+ try {
92197
+ return this.options.container.contains(relatedTarget);
92198
+ } catch (unused) {
92199
+ return false;
92200
+ }
92201
+ };
92202
+ _proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
92203
+ if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
92204
+ return false;
92205
+ }
92206
+ return !!event.target.closest('[data-interaction-contextmenu="self"], [data-vvfx-html-contextmenu="self"]');
92015
92207
  };
92016
92208
  _proto.handleViewportTransform = function handleViewportTransform() {
92017
92209
  var editing = this.state.editing;
@@ -92031,11 +92223,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92031
92223
  }
92032
92224
  var items = this.options.getItems();
92033
92225
  var frameByChildId = this.renderFrameOverlays(items, layer);
92226
+ var selectionLayer = this.getOrCreateSelectionLayer(layer);
92034
92227
  var visibleCardIds = new Set();
92035
92228
  var editingVisible = false;
92036
92229
  items.forEach(function(item) {
92037
92230
  var _this_state_editing;
92038
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92231
+ if (!isCardItem(item) || !item.visible) {
92232
+ return;
92233
+ }
92234
+ var html = _this.options.resolveCardHTML(item);
92235
+ if (html === undefined) {
92039
92236
  return;
92040
92237
  }
92041
92238
  var itemBox = _this.options.getViewBoxById(item.id);
@@ -92050,21 +92247,31 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92050
92247
  var frameBox = frameId ? _this.options.getViewBoxById(frameId) : undefined;
92051
92248
  var overlay = _this.getOrCreateOverlay(item.id, parentOverlay, elements);
92052
92249
  var contentOverlay = _this.getOrCreateContentOverlay(item.id, overlay);
92053
- var html = item.html;
92054
- if (html && _this.state.contents.get(item.id) !== html) {
92250
+ var selectionOverlay = _this.getOrCreateSelectionOverlay(item.id, selectionLayer);
92251
+ if (!_this.state.contents.has(item.id)) {
92055
92252
  _this.renderOverlayHTML(item.id, contentOverlay, html);
92056
92253
  }
92254
+ _this.applyHTMLRootConfig(overlay, html);
92057
92255
  var offsetX = frameBox && !frameBox.isEmpty() ? frameBox.min.x : 0;
92058
92256
  var offsetY = frameBox && !frameBox.isEmpty() ? frameBox.min.y : 0;
92059
- var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY);
92257
+ var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY, _this.isAutoScaleEnabled(item));
92060
92258
  overlay.style.left = boxStyle.left;
92061
92259
  overlay.style.top = boxStyle.top;
92062
92260
  overlay.style.width = boxStyle.width;
92063
92261
  overlay.style.height = boxStyle.height;
92064
92262
  overlay.style.transform = boxStyle.transform;
92065
92263
  overlay.style.transformOrigin = '0 0';
92066
- _this.syncContentScale(item.id, item.property.width, item.property.height);
92067
- _this.syncAutoHeight(item.id, item.property.autoHeight === true);
92264
+ var selectionBoxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, 0, 0, _this.isAutoScaleEnabled(item));
92265
+ selectionOverlay.style.left = selectionBoxStyle.left;
92266
+ selectionOverlay.style.top = selectionBoxStyle.top;
92267
+ selectionOverlay.style.width = selectionBoxStyle.width;
92268
+ selectionOverlay.style.height = selectionBoxStyle.height;
92269
+ selectionOverlay.style.transform = selectionBoxStyle.transform;
92270
+ selectionOverlay.style.transformOrigin = '0 0';
92271
+ _this.applyHTMLRootConfig(selectionOverlay, html);
92272
+ _this.syncOverlaySelection(item.id, overlay, selectionOverlay);
92273
+ _this.syncContentScale(item.id, boxStyle.contentWidth, boxStyle.contentHeight);
92274
+ _this.syncAutoHeight(item.id, _this.isAutoHeightEnabled(item));
92068
92275
  _this.syncContentInteraction(item.id);
92069
92276
  });
92070
92277
  elements.forEach(function(_overlay, id) {
@@ -92103,6 +92310,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92103
92310
  }
92104
92311
  }
92105
92312
  syncElementStackOrder(layer, rootElements);
92313
+ if (this.state.selectionLayer) {
92314
+ this.state.selectionLayer.style.zIndex = "" + (rootElements.length + 1);
92315
+ }
92106
92316
  this.state.frameElements.forEach(function(frameOverlay, frameId) {
92107
92317
  var frameElements = [];
92108
92318
  for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
@@ -92118,6 +92328,28 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92118
92328
  syncElementStackOrder(frameOverlay, frameElements);
92119
92329
  });
92120
92330
  };
92331
+ _proto.getOrCreateSelectionLayer = function getOrCreateSelectionLayer(layer) {
92332
+ var _layer_ownerDocument;
92333
+ if (this.state.selectionLayer) {
92334
+ if (this.state.selectionLayer.parentElement !== layer) {
92335
+ layer.appendChild(this.state.selectionLayer);
92336
+ }
92337
+ return this.state.selectionLayer;
92338
+ }
92339
+ var ownerDocument = (_layer_ownerDocument = layer.ownerDocument) != null ? _layer_ownerDocument : typeof document === 'undefined' ? undefined : document;
92340
+ if (!ownerDocument) {
92341
+ return layer;
92342
+ }
92343
+ var selectionLayer = ownerDocument.createElement('div');
92344
+ selectionLayer.className = 'vvfx-card-html-overlay-selection-layer';
92345
+ selectionLayer.style.position = 'absolute';
92346
+ selectionLayer.style.inset = '0';
92347
+ selectionLayer.style.pointerEvents = 'none';
92348
+ selectionLayer.style.zIndex = '1';
92349
+ layer.appendChild(selectionLayer);
92350
+ this.state.selectionLayer = selectionLayer;
92351
+ return selectionLayer;
92352
+ };
92121
92353
  _proto.renderFrameOverlays = function renderFrameOverlays(items, layer) {
92122
92354
  var _this = this;
92123
92355
  var visibleFrameIds = new Set();
@@ -92182,6 +92414,41 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92182
92414
  elements.set(id, overlay);
92183
92415
  return overlay;
92184
92416
  };
92417
+ _proto.getOrCreateSelectionOverlay = function getOrCreateSelectionOverlay(id, parent) {
92418
+ var selectionOverlay = this.state.selectionElements.get(id);
92419
+ if (selectionOverlay) {
92420
+ if (selectionOverlay.parentElement !== parent) {
92421
+ parent.appendChild(selectionOverlay);
92422
+ }
92423
+ return selectionOverlay;
92424
+ }
92425
+ selectionOverlay = document.createElement('div');
92426
+ selectionOverlay.className = 'vvfx-card-html-overlay-selection';
92427
+ selectionOverlay.dataset.itemId = id;
92428
+ selectionOverlay.style.position = 'absolute';
92429
+ selectionOverlay.style.pointerEvents = 'none';
92430
+ selectionOverlay.style.zIndex = '1';
92431
+ parent.appendChild(selectionOverlay);
92432
+ this.state.selectionElements.set(id, selectionOverlay);
92433
+ return selectionOverlay;
92434
+ };
92435
+ _proto.syncOverlaySelection = function syncOverlaySelection(id, overlay, selectionOverlay) {
92436
+ var isSelected = this.options.getSelectedItemIds().includes(id);
92437
+ var isPreSelected = !isSelected && this.options.getPreSelectedItemId() === id;
92438
+ overlay.dataset.selected = isSelected ? 'true' : 'false';
92439
+ overlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92440
+ selectionOverlay.dataset.selected = isSelected ? 'true' : 'false';
92441
+ selectionOverlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92442
+ selectionOverlay.style.boxShadow = isSelected ? this.getSelectionBoxShadow() : isPreSelected ? this.getPreSelectionBoxShadow() : '';
92443
+ };
92444
+ _proto.getSelectionBoxShadow = function getSelectionBoxShadow() {
92445
+ var _this_options_getSelectionEdgeStyle = this.options.getSelectionEdgeStyle(), color = _this_options_getSelectionEdgeStyle.color, alpha = _this_options_getSelectionEdgeStyle.alpha, width = _this_options_getSelectionEdgeStyle.width;
92446
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92447
+ };
92448
+ _proto.getPreSelectionBoxShadow = function getPreSelectionBoxShadow() {
92449
+ var _this_options_getPreSelectionEdgeStyle = this.options.getPreSelectionEdgeStyle(), color = _this_options_getPreSelectionEdgeStyle.color, alpha = _this_options_getPreSelectionEdgeStyle.alpha, width = _this_options_getPreSelectionEdgeStyle.width;
92450
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92451
+ };
92185
92452
  _proto.getHTMLCardIdByEvent = function getHTMLCardIdByEvent(event) {
92186
92453
  var layer = this.state.layer;
92187
92454
  if (!layer) {
@@ -92191,7 +92458,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92191
92458
  var items = this.options.getItems();
92192
92459
  for(var i = items.length - 1; i >= 0; i--){
92193
92460
  var item = items[i];
92194
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92461
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92195
92462
  continue;
92196
92463
  }
92197
92464
  var box = this.options.getViewBoxById(item.id);
@@ -92210,7 +92477,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92210
92477
  var items = this.options.getItems();
92211
92478
  for(var i = items.length - 1; i >= 0; i--){
92212
92479
  var item = items[i];
92213
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92480
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92214
92481
  continue;
92215
92482
  }
92216
92483
  var box = this.options.getViewBoxById(item.id);
@@ -92220,13 +92487,206 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92220
92487
  var contentOverlay = this.state.contentElements.get(item.id);
92221
92488
  var interactiveElements = contentOverlay ? Array.from(contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR)) : [];
92222
92489
  var isHoveringShellInteractive = interactiveElements.some(function(element) {
92223
- var rect = element.getBoundingClientRect();
92224
- return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
92490
+ return isMouseEventInsideRect(event, element.getBoundingClientRect());
92225
92491
  });
92226
92492
  return isHoveringShellInteractive ? item.id : undefined;
92227
92493
  }
92228
92494
  return undefined;
92229
92495
  };
92496
+ _proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
92497
+ var decision = this.resolveHTMLInteractionTarget(event);
92498
+ if (decision.kind === 'canvas' && this.shouldKeepActiveContentInteractionForFocusedElement()) {
92499
+ return;
92500
+ }
92501
+ this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
92502
+ };
92503
+ _proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
92504
+ var _this = this;
92505
+ if (typeof requestAnimationFrame !== 'function') {
92506
+ this.syncActiveContentInteraction(event);
92507
+ return;
92508
+ }
92509
+ this.pendingContentInteractionEvent = event;
92510
+ if (this.contentInteractionFrame !== undefined) {
92511
+ return;
92512
+ }
92513
+ this.contentInteractionFrame = requestAnimationFrame(function() {
92514
+ _this.contentInteractionFrame = undefined;
92515
+ var pendingEvent = _this.pendingContentInteractionEvent;
92516
+ _this.pendingContentInteractionEvent = undefined;
92517
+ if (pendingEvent) {
92518
+ _this.syncActiveContentInteraction(pendingEvent);
92519
+ }
92520
+ });
92521
+ };
92522
+ _proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
92523
+ var _this = this;
92524
+ var previous = this.state.activeContentInteraction;
92525
+ 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)) {
92526
+ return;
92527
+ }
92528
+ this.state.activeContentInteraction = zone;
92529
+ var changedIds = new Set();
92530
+ if (previous) {
92531
+ changedIds.add(previous.id);
92532
+ }
92533
+ if (zone) {
92534
+ changedIds.add(zone.id);
92535
+ }
92536
+ changedIds.forEach(function(id) {
92537
+ _this.syncContentInteraction(id);
92538
+ });
92539
+ };
92540
+ _proto.shouldKeepActiveContentInteractionForFocusedElement = function shouldKeepActiveContentInteractionForFocusedElement() {
92541
+ var activeInteraction = this.state.activeContentInteraction;
92542
+ if (!activeInteraction || typeof document === 'undefined') {
92543
+ return false;
92544
+ }
92545
+ var activeElement = document.activeElement;
92546
+ if (!activeElement || activeElement === document.body) {
92547
+ return false;
92548
+ }
92549
+ var interactionElement = activeInteraction.element;
92550
+ return interactionElement === activeElement || typeof interactionElement.contains === 'function' && interactionElement.contains(activeElement);
92551
+ };
92552
+ _proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
92553
+ var id = this.getHTMLCardIdByEvent(event);
92554
+ if (!id || this.isEditableCard(id)) {
92555
+ return {
92556
+ kind: 'canvas',
92557
+ id: id
92558
+ };
92559
+ }
92560
+ var contentOverlay = this.state.contentElements.get(id);
92561
+ if (!contentOverlay) {
92562
+ return {
92563
+ kind: 'canvas',
92564
+ id: id
92565
+ };
92566
+ }
92567
+ var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
92568
+ if (activeSubtree) {
92569
+ return {
92570
+ kind: 'html',
92571
+ interaction: activeSubtree
92572
+ };
92573
+ }
92574
+ var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
92575
+ return isMouseEventInsideRect(event, zone.rect);
92576
+ });
92577
+ var zone = this.resolveContentInteractionZone(matchedZones);
92578
+ if (zone) {
92579
+ return {
92580
+ kind: 'html',
92581
+ interaction: {
92582
+ id: id,
92583
+ element: zone.element,
92584
+ zone: zone.zone
92585
+ }
92586
+ };
92587
+ }
92588
+ return {
92589
+ kind: 'canvas',
92590
+ id: id
92591
+ };
92592
+ };
92593
+ _proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
92594
+ var activeInteraction = this.state.activeContentInteraction;
92595
+ if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
92596
+ return undefined;
92597
+ }
92598
+ var rect = activeInteraction.element.getBoundingClientRect();
92599
+ return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
92600
+ };
92601
+ _proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
92602
+ if (zones.length <= 1) {
92603
+ return zones[0];
92604
+ }
92605
+ var subtreeRoot = zones.find(function(candidate) {
92606
+ return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
92607
+ return zone.element !== candidate.element && candidate.element.contains(zone.element);
92608
+ });
92609
+ });
92610
+ return subtreeRoot != null ? subtreeRoot : zones[0];
92611
+ };
92612
+ _proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
92613
+ var _this = this;
92614
+ var cachedZones = this.state.contentInteractionZones.get(id);
92615
+ if (cachedZones) {
92616
+ return cachedZones;
92617
+ }
92618
+ var zones = Array.from(contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id))).filter(function(element) {
92619
+ return !_this.isContentInteractionDisabled(element);
92620
+ }).map(function(element) {
92621
+ return {
92622
+ element: element,
92623
+ rect: element.getBoundingClientRect(),
92624
+ zone: _this.getContentInteractionZoneMode(element)
92625
+ };
92626
+ });
92627
+ this.state.contentInteractionZones.set(id, zones);
92628
+ this.observeContentInteractionZoneResizes(id, zones);
92629
+ return zones;
92630
+ };
92631
+ _proto.getContentInteractiveSelector = function getContentInteractiveSelector(id) {
92632
+ var _ref;
92633
+ var _this_options_resolveCardTypeConfig_htmlInteractionSelectors, _this_options_resolveCardTypeConfig;
92634
+ var item = this.options.getItems().find(function(item) {
92635
+ return item.id === id;
92636
+ });
92637
+ if (!item) {
92638
+ return CONTENT_INTERACTIVE_SELECTOR;
92639
+ }
92640
+ 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 : [];
92641
+ if (selectors.length === 0) {
92642
+ return CONTENT_INTERACTIVE_SELECTOR;
92643
+ }
92644
+ return [].concat([
92645
+ CONTENT_INTERACTIVE_SELECTOR
92646
+ ], selectors).join(', ');
92647
+ };
92648
+ _proto.isContentInteractionDisabled = function isContentInteractionDisabled(element) {
92649
+ if (typeof element.closest !== 'function') {
92650
+ return false;
92651
+ }
92652
+ return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
92653
+ };
92654
+ _proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
92655
+ var zone = element.dataset.vvfxHtmlInteractionZone;
92656
+ return zone === 'subtree' ? 'subtree' : 'self';
92657
+ };
92658
+ _proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
92659
+ if (id) {
92660
+ var _this_state_contentInteractionResizeCleanups_get;
92661
+ this.state.contentInteractionZones.delete(id);
92662
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92663
+ this.state.contentInteractionResizeCleanups.delete(id);
92664
+ return;
92665
+ }
92666
+ this.state.contentInteractionZones.clear();
92667
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92668
+ cleanup();
92669
+ });
92670
+ this.state.contentInteractionResizeCleanups.clear();
92671
+ };
92672
+ _proto.observeContentInteractionZoneResizes = function observeContentInteractionZoneResizes(id, zones) {
92673
+ var _this = this;
92674
+ var _this_state_contentInteractionResizeCleanups_get;
92675
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92676
+ this.state.contentInteractionResizeCleanups.delete(id);
92677
+ if (zones.length === 0 || typeof ResizeObserver !== 'function') {
92678
+ return;
92679
+ }
92680
+ var observer = new ResizeObserver(function() {
92681
+ _this.invalidateContentInteractionZones(id);
92682
+ });
92683
+ zones.forEach(function(zone) {
92684
+ observer.observe(zone.element);
92685
+ });
92686
+ this.state.contentInteractionResizeCleanups.set(id, function() {
92687
+ observer.disconnect();
92688
+ });
92689
+ };
92230
92690
  _proto.getLayerPoint = function getLayerPoint(event) {
92231
92691
  var rect = this.options.container.getBoundingClientRect();
92232
92692
  return {
@@ -92283,19 +92743,35 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92283
92743
  if (!scaleOverlay || !contentOverlay || width <= 0 || height <= 0) {
92284
92744
  return;
92285
92745
  }
92286
- scaleOverlay.style.width = "" + width + "px";
92287
- scaleOverlay.style.height = "" + height + "px";
92746
+ var nextWidth = "" + width + "px";
92747
+ var nextHeight = "" + height + "px";
92748
+ var sizeChanged = scaleOverlay.style.width !== nextWidth || scaleOverlay.style.height !== nextHeight;
92749
+ scaleOverlay.style.width = nextWidth;
92750
+ scaleOverlay.style.height = nextHeight;
92288
92751
  scaleOverlay.style.transform = 'none';
92289
- contentOverlay.style.width = "" + width + "px";
92290
- contentOverlay.style.height = "" + height + "px";
92752
+ contentOverlay.style.width = nextWidth;
92753
+ contentOverlay.style.height = nextHeight;
92754
+ if (sizeChanged && this.state.autoHeightModes.get(id) === 'message') {
92755
+ this.requestAutoHeightFromIframes(id, contentOverlay);
92756
+ }
92757
+ if (sizeChanged) {
92758
+ this.invalidateContentInteractionZones(id);
92759
+ }
92760
+ };
92761
+ _proto.requestAutoHeightFromIframes = function requestAutoHeightFromIframes(id, contentOverlay) {
92762
+ contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92763
+ requestCardHTMLAutoHeight(iframe, id);
92764
+ });
92291
92765
  };
92292
92766
  _proto.syncContentInteraction = function syncContentInteraction(id) {
92293
- var _this_state_editing;
92767
+ var _this_state_editing, _this_state_activeContentInteraction;
92294
92768
  var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
92769
+ var activeInteraction = ((_this_state_activeContentInteraction = this.state.activeContentInteraction) == null ? void 0 : _this_state_activeContentInteraction.id) === id ? this.state.activeContentInteraction : undefined;
92295
92770
  var overlay = this.state.elements.get(id);
92296
92771
  var scaleOverlay = this.state.contentScaleElements.get(id);
92297
92772
  var contentOverlay = this.state.contentElements.get(id);
92298
92773
  var contentMount = this.state.contentMountElements.get(id);
92774
+ var isInteractive = isEditing || !!activeInteraction;
92299
92775
  if (overlay) {
92300
92776
  overlay.dataset.editing = isEditing ? 'true' : 'false';
92301
92777
  overlay.style.pointerEvents = 'none';
@@ -92306,34 +92782,62 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92306
92782
  }
92307
92783
  if (contentOverlay) {
92308
92784
  contentOverlay.dataset.editing = isEditing ? 'true' : 'false';
92309
- contentOverlay.style.pointerEvents = 'none';
92785
+ contentOverlay.style.pointerEvents = isInteractive ? 'auto' : 'none';
92310
92786
  contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92311
- iframe.style.pointerEvents = isEditing ? 'auto' : 'none';
92312
- iframe.tabIndex = isEditing ? 0 : -1;
92787
+ var isActiveIframe = isEditing || (activeInteraction == null ? void 0 : activeInteraction.element) === iframe;
92788
+ iframe.style.pointerEvents = isActiveIframe ? 'auto' : 'none';
92789
+ iframe.tabIndex = isActiveIframe ? 0 : -1;
92313
92790
  });
92314
- this.syncShellInteraction(id, contentOverlay, isEditing);
92791
+ this.syncShellInteraction(id, contentOverlay, isInteractive);
92792
+ this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
92315
92793
  }
92316
92794
  if (contentMount) {
92317
92795
  contentMount.dataset.editing = isEditing ? 'true' : 'false';
92318
- contentMount.style.pointerEvents = isEditing ? 'auto' : 'none';
92319
- contentMount.inert = !isEditing;
92320
- if (isEditing) {
92796
+ contentMount.style.pointerEvents = isInteractive ? 'auto' : 'none';
92797
+ contentMount.inert = !isInteractive;
92798
+ if (isInteractive) {
92321
92799
  contentMount.removeAttribute('aria-hidden');
92322
92800
  } else {
92323
92801
  contentMount.setAttribute('aria-hidden', 'true');
92324
92802
  }
92325
92803
  }
92326
92804
  };
92327
- _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isEditing) {
92805
+ _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
92806
+ var _this = this;
92807
+ var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
92808
+ contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
92809
+ if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
92810
+ _this.clearContentInteractionState(element);
92811
+ return;
92812
+ }
92813
+ if (!isInteractive) {
92814
+ _this.clearContentInteractionState(element);
92815
+ return;
92816
+ }
92817
+ if (_this.isContentInteractionDisabled(element)) {
92818
+ element.dataset.vvfxHtmlInteractionActive = 'false';
92819
+ element.style.pointerEvents = 'none';
92820
+ return;
92821
+ }
92822
+ var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
92823
+ element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
92824
+ element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
92825
+ });
92826
+ };
92827
+ _proto.clearContentInteractionState = function clearContentInteractionState(element) {
92828
+ delete element.dataset.vvfxHtmlInteractionActive;
92829
+ element.style.pointerEvents = '';
92830
+ };
92831
+ _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
92328
92832
  var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
92329
- var isShellInteractiveActive = isEditing || isHoveringShellInteractive;
92833
+ var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
92330
92834
  contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR).forEach(function(element) {
92331
92835
  element.dataset.vvfxHtmlShellInteractiveHover = isHoveringShellInteractive ? 'true' : 'false';
92332
92836
  element.dataset.vvfxHtmlShellInteractiveActive = isShellInteractiveActive ? 'true' : 'false';
92333
92837
  element.style.pointerEvents = isShellInteractiveActive ? 'auto' : 'none';
92334
92838
  });
92335
92839
  contentOverlay.querySelectorAll(EDITING_INTERACTIVE_SELECTOR).forEach(function(element) {
92336
- element.style.pointerEvents = isEditing ? 'auto' : 'none';
92840
+ element.style.pointerEvents = isInteractive ? 'auto' : 'none';
92337
92841
  });
92338
92842
  };
92339
92843
  _proto.enterEditing = function enterEditing(id) {
@@ -92341,6 +92845,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92341
92845
  if (((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id) {
92342
92846
  return;
92343
92847
  }
92848
+ if (!this.isEditableCard(id)) {
92849
+ return;
92850
+ }
92344
92851
  var box = this.options.getViewBoxById(id);
92345
92852
  if (box.isEmpty()) {
92346
92853
  return;
@@ -92384,6 +92891,13 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92384
92891
  this.options.setViewport(editing.restoreViewport);
92385
92892
  this.scheduleRender();
92386
92893
  };
92894
+ _proto.isEditableCard = function isEditableCard(id) {
92895
+ var _this_options_resolveCardTypeConfig;
92896
+ var item = this.options.getItems().find(function(item) {
92897
+ return item.id === id;
92898
+ });
92899
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.editable) !== false;
92900
+ };
92387
92901
  _proto.getEditingFitZoom = function getEditingFitZoom(box, currentZoom) {
92388
92902
  var viewportElement = this.options.container.parentElement;
92389
92903
  if (!viewportElement) {
@@ -92408,6 +92922,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92408
92922
  };
92409
92923
  _proto.renderOverlayHTML = function renderOverlayHTML(id, overlay, html) {
92410
92924
  this.cleanupOverlayContent(id);
92925
+ this.invalidateContentInteractionZones(id);
92411
92926
  overlay.innerHTML = '';
92412
92927
  var shell = mountHTMLShell(overlay, html.content, html.shell);
92413
92928
  var autoHeightMeasureElement = shell.contentContainer.isConnected ? shell.contentContainer : overlay;
@@ -92417,18 +92932,81 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92417
92932
  });
92418
92933
  var contentCleanup = this.renderOverlayContent(shell.contentContainer, html.content, {
92419
92934
  id: id,
92420
- autoHeight: isCardItem(item) && item.property.autoHeight === true
92935
+ autoHeight: this.isAutoHeightEnabled(item)
92421
92936
  });
92937
+ this.observeContentInteractionZones(id, shell.contentContainer);
92422
92938
  this.state.cleanups.set(id, function() {
92423
92939
  contentCleanup == null ? void 0 : contentCleanup();
92424
92940
  shell.cleanup == null ? void 0 : shell.cleanup.call(shell);
92425
92941
  });
92426
92942
  this.state.contents.set(id, html);
92427
92943
  };
92944
+ _proto.observeContentInteractionZones = function observeContentInteractionZones(id, contentContainer) {
92945
+ var _this = this;
92946
+ var _this_state_contentInteractionZoneCleanups_get;
92947
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
92948
+ this.state.contentInteractionZoneCleanups.delete(id);
92949
+ if (typeof MutationObserver !== 'function') {
92950
+ return;
92951
+ }
92952
+ var observer = new MutationObserver(function() {
92953
+ _this.invalidateContentInteractionZones(id);
92954
+ });
92955
+ observer.observe(contentContainer, {
92956
+ attributes: true,
92957
+ childList: true,
92958
+ subtree: true
92959
+ });
92960
+ this.state.contentInteractionZoneCleanups.set(id, function() {
92961
+ observer.disconnect();
92962
+ });
92963
+ };
92964
+ _proto.applyHTMLRootConfig = function applyHTMLRootConfig(root, html) {
92965
+ var _ref, _config_style;
92966
+ var _this_htmlRootConfigCleanups_get, _config_className;
92967
+ (_this_htmlRootConfigCleanups_get = this.htmlRootConfigCleanups.get(root)) == null ? void 0 : _this_htmlRootConfigCleanups_get();
92968
+ this.htmlRootConfigCleanups.delete(root);
92969
+ var config = html.root;
92970
+ if (!config) {
92971
+ return;
92972
+ }
92973
+ var classNames = (_ref = (_config_className = config.className) == null ? void 0 : _config_className.split(/\s+/).filter(Boolean)) != null ? _ref : [];
92974
+ var styleProperties = [];
92975
+ classNames.forEach(function(className) {
92976
+ root.classList.add(className);
92977
+ });
92978
+ Object.entries((_config_style = config.style) != null ? _config_style : {}).forEach(function(param) {
92979
+ var property = param[0], value = param[1];
92980
+ if (value === undefined) {
92981
+ return;
92982
+ }
92983
+ styleProperties.push(property);
92984
+ if (property.startsWith('--') || property.includes('-')) {
92985
+ root.style.setProperty(property, String(value));
92986
+ return;
92987
+ }
92988
+ root.style[property] = String(value);
92989
+ });
92990
+ this.htmlRootConfigCleanups.set(root, function() {
92991
+ classNames.forEach(function(className) {
92992
+ root.classList.remove(className);
92993
+ });
92994
+ styleProperties.forEach(function(property) {
92995
+ if (property.startsWith('--') || property.includes('-')) {
92996
+ root.style.removeProperty(property);
92997
+ return;
92998
+ }
92999
+ root.style[property] = '';
93000
+ });
93001
+ });
93002
+ };
92428
93003
  _proto.renderOverlayContent = function renderOverlayContent(overlay, content, options) {
92429
93004
  var _this = this;
92430
93005
  switch(content.kind){
92431
93006
  case 'inline':
93007
+ if (options == null ? void 0 : options.autoHeight) {
93008
+ this.state.autoHeightModes.set(options.id, 'message');
93009
+ }
92432
93010
  return this.chainCleanups(function() {
92433
93011
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92434
93012
  }, renderDocumentContent(overlay, {
@@ -92445,6 +93023,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92445
93023
  }));
92446
93024
  case 'dom':
92447
93025
  {
93026
+ if (options == null ? void 0 : options.autoHeight) {
93027
+ this.state.autoHeightModes.set(options.id, 'measure');
93028
+ }
92448
93029
  if (content.target === 'iframe') {
92449
93030
  return renderDOMContentInIframe(overlay, content.render, content.cleanup);
92450
93031
  }
@@ -92454,6 +93035,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92454
93035
  } : undefined;
92455
93036
  }
92456
93037
  case 'document':
93038
+ if (options == null ? void 0 : options.autoHeight) {
93039
+ this.state.autoHeightModes.set(options.id, 'message');
93040
+ }
92457
93041
  return this.chainCleanups(function() {
92458
93042
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92459
93043
  }, renderDocumentContent(overlay, content, {
@@ -92481,6 +93065,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92481
93065
  };
92482
93066
  };
92483
93067
  _proto.cleanupOverlayContent = function cleanupOverlayContent(id) {
93068
+ var _this_state_contentInteractionZoneCleanups_get;
92484
93069
  var cleanup = this.state.cleanups.get(id);
92485
93070
  if (cleanup) {
92486
93071
  cleanup();
@@ -92488,13 +93073,19 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92488
93073
  }
92489
93074
  this.state.contents.delete(id);
92490
93075
  this.state.contentMountElements.delete(id);
93076
+ this.state.autoHeightModes.delete(id);
93077
+ this.invalidateContentInteractionZones(id);
93078
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
93079
+ this.state.contentInteractionZoneCleanups.delete(id);
92491
93080
  this.cleanupAutoHeight(id);
92492
93081
  };
92493
93082
  _proto.removeOverlay = function removeOverlay(id) {
92494
- var _this_state_elements_get;
93083
+ var _this_state_elements_get, _this_state_selectionElements_get;
92495
93084
  this.cleanupOverlayContent(id);
92496
93085
  (_this_state_elements_get = this.state.elements.get(id)) == null ? void 0 : _this_state_elements_get.remove();
93086
+ (_this_state_selectionElements_get = this.state.selectionElements.get(id)) == null ? void 0 : _this_state_selectionElements_get.remove();
92497
93087
  this.state.elements.delete(id);
93088
+ this.state.selectionElements.delete(id);
92498
93089
  this.state.contentScaleElements.delete(id);
92499
93090
  this.state.contentElements.delete(id);
92500
93091
  };
@@ -92503,11 +93094,27 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92503
93094
  this.cleanupAutoHeight(id);
92504
93095
  return;
92505
93096
  }
93097
+ this.ensureAutoHeightMode(id);
93098
+ if (this.state.autoHeightModes.get(id) === 'message') {
93099
+ this.cleanupAutoHeight(id);
93100
+ return;
93101
+ }
92506
93102
  if (!this.state.autoHeightCleanups.has(id)) {
92507
93103
  this.state.autoHeightCleanups.set(id, this.createAutoHeightObserver(id));
92508
93104
  }
92509
93105
  this.scheduleAutoHeightMeasure(id);
92510
93106
  };
93107
+ _proto.ensureAutoHeightMode = function ensureAutoHeightMode(id) {
93108
+ var _this_state_contents_get;
93109
+ if (this.state.autoHeightModes.has(id)) {
93110
+ return;
93111
+ }
93112
+ var content = (_this_state_contents_get = this.state.contents.get(id)) == null ? void 0 : _this_state_contents_get.content;
93113
+ if (!content) {
93114
+ return;
93115
+ }
93116
+ this.state.autoHeightModes.set(id, content.kind === 'inline' || content.kind === 'document' ? 'message' : 'measure');
93117
+ };
92511
93118
  _proto.createAutoHeightObserver = function createAutoHeightObserver(id) {
92512
93119
  var _this = this;
92513
93120
  var cleanupFns = [];
@@ -92595,7 +93202,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92595
93202
  var item = this.options.getItems().find(function(candidate) {
92596
93203
  return candidate.id === id;
92597
93204
  });
92598
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93205
+ if (!this.isAutoHeightEnabled(item)) {
92599
93206
  this.cleanupAutoHeight(id);
92600
93207
  return;
92601
93208
  }
@@ -92614,7 +93221,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92614
93221
  }).filter(function(height) {
92615
93222
  return typeof height === 'number' && Number.isFinite(height) && height > 0;
92616
93223
  });
92617
- var childHeight = this.getChildrenNaturalHeight(element);
93224
+ var childHeight = this.getChildrenNaturalHeight(element, {
93225
+ includeIframes: iframeHeights.length === 0
93226
+ });
92618
93227
  var naturalHeight = (_Math = Math).max.apply(_Math, [].concat([
92619
93228
  childHeight
92620
93229
  ], iframeHeights));
@@ -92634,10 +93243,29 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92634
93243
  }
92635
93244
  return Math.max(documentElement.scrollHeight, (_ref = body == null ? void 0 : body.scrollHeight) != null ? _ref : 0);
92636
93245
  };
92637
- _proto.getChildrenNaturalHeight = function getChildrenNaturalHeight(element) {
92638
- return Array.from(element.children).reduce(function(height, child) {
92639
- var childElement = child;
92640
- return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
93246
+ _proto.getChildrenNaturalHeight = function getChildrenNaturalHeight(element, options) {
93247
+ var _ref;
93248
+ var includeIframes = (_ref = options == null ? void 0 : options.includeIframes) != null ? _ref : true;
93249
+ return Array.from(element.childNodes).reduce(function(height, child) {
93250
+ var _child_textContent;
93251
+ if (child.nodeType === Node.ELEMENT_NODE) {
93252
+ var childElement = child;
93253
+ if (!includeIframes && childElement.tagName === 'IFRAME') {
93254
+ return height;
93255
+ }
93256
+ return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
93257
+ }
93258
+ if (child.nodeType === Node.TEXT_NODE && ((_child_textContent = child.textContent) == null ? void 0 : _child_textContent.trim())) {
93259
+ var range = element.ownerDocument.createRange();
93260
+ range.selectNodeContents(child);
93261
+ var rects = Array.from(range.getClientRects());
93262
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
93263
+ range.detach();
93264
+ return rects.reduce(function(textHeight, rect) {
93265
+ return Math.max(textHeight, rect.bottom - element.getBoundingClientRect().top);
93266
+ }, height);
93267
+ }
93268
+ return height;
92641
93269
  }, 0);
92642
93270
  };
92643
93271
  _proto.cleanupAutoHeight = function cleanupAutoHeight(id) {
@@ -92656,14 +93284,48 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92656
93284
  var item = this.options.getItems().find(function(candidate) {
92657
93285
  return candidate.id === id;
92658
93286
  });
92659
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93287
+ if (!isCardItem(item) || !this.isAutoHeightEnabled(item)) {
93288
+ return;
93289
+ }
93290
+ if (!Number.isFinite(height) || height <= 0) {
92660
93291
  return;
92661
93292
  }
92662
- if (!Number.isFinite(height) || height <= 0 || Math.abs(height - item.property.height) <= AUTO_HEIGHT_EPSILON) {
93293
+ var nextHeight = Math.ceil(this.getAutoHeightItemHeight(item, height));
93294
+ if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
92663
93295
  return;
92664
93296
  }
92665
- this.options.setCardItemHeight(id, Math.ceil(height));
93297
+ this.options.setCardItemHeight(id, nextHeight);
93298
+ };
93299
+ _proto.getAutoHeightItemHeight = function getAutoHeightItemHeight(item, contentHeight) {
93300
+ if (!isCardItem(item) || this.isAutoScaleEnabled(item)) {
93301
+ return contentHeight;
93302
+ }
93303
+ var scaleOverlay = this.state.contentScaleElements.get(item.id);
93304
+ var displayedHeight = scaleOverlay ? Number.parseFloat(scaleOverlay.style.height) : 0;
93305
+ if (!Number.isFinite(displayedHeight) || displayedHeight <= 0 || item.property.height <= 0) {
93306
+ return contentHeight;
93307
+ }
93308
+ return contentHeight / displayedHeight * item.property.height;
93309
+ };
93310
+ _proto.isAutoHeightEnabled = function isAutoHeightEnabled(item) {
93311
+ var _this_options_resolveCardTypeConfig;
93312
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeight) === true;
93313
+ };
93314
+ _proto.isAutoScaleEnabled = function isAutoScaleEnabled(item) {
93315
+ var _this_options_resolveCardTypeConfig;
93316
+ if (!isCardItem(item)) {
93317
+ return true;
93318
+ }
93319
+ return ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoScale) !== false;
92666
93320
  };
93321
+ _create_class(HTMLOverlayManager, [
93322
+ {
93323
+ key: "layerElement",
93324
+ get: function get() {
93325
+ return this.state.layer;
93326
+ }
93327
+ }
93328
+ ]);
92667
93329
  return HTMLOverlayManager;
92668
93330
  }();
92669
93331
  function waitForCardCaptureReady(root) {
@@ -92705,6 +93367,17 @@ function waitForCardCaptureReady(root) {
92705
93367
  });
92706
93368
  })();
92707
93369
  }
93370
+ function formatCssColor(color, alpha) {
93371
+ var normalizedColor = Math.max(0, Math.min(0xFFFFFF, Math.round(color)));
93372
+ var red = normalizedColor >> 16 & 0xFF;
93373
+ var green = normalizedColor >> 8 & 0xFF;
93374
+ var blue = normalizedColor & 0xFF;
93375
+ return "rgba(" + red + ", " + green + ", " + blue + ", " + formatCssNumber(alpha) + ")";
93376
+ }
93377
+ function formatCssNumber(value) {
93378
+ var normalized = Number.isFinite(value) ? value : 0;
93379
+ return Number(normalized.toFixed(6)).toString();
93380
+ }
92708
93381
  function nextAnimationFrame() {
92709
93382
  return new Promise(function(resolve) {
92710
93383
  requestAnimationFrame(function() {
@@ -93123,6 +93796,9 @@ function createFlattenedContent(target, frameStyle, ownerDocument) {
93123
93796
  });
93124
93797
  return replacement;
93125
93798
  }
93799
+ function isMouseEventInsideRect(event, rect) {
93800
+ return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
93801
+ }
93126
93802
  function createFlattenedIframeContent(iframe) {
93127
93803
  var doc = iframe.contentDocument;
93128
93804
  if (!doc) {
@@ -93162,6 +93838,19 @@ function withTimeout(promise, timeout) {
93162
93838
  });
93163
93839
  }
93164
93840
 
93841
+ function orderSDKCanvasLayers(param) {
93842
+ var container = param.container, playerContainer = param.playerContainer, htmlOverlayLayer = param.htmlOverlayLayer, gestureCanvas = param.gestureCanvas;
93843
+ [
93844
+ playerContainer,
93845
+ htmlOverlayLayer,
93846
+ gestureCanvas
93847
+ ].forEach(function(layer) {
93848
+ if ((layer == null ? void 0 : layer.parentElement) === container) {
93849
+ container.appendChild(layer);
93850
+ }
93851
+ });
93852
+ }
93853
+
93165
93854
  var HTML_CARD_EDITING_VIEWPORT_PADDING = 48;
93166
93855
  var SDK = /*#__PURE__*/ function() {
93167
93856
  function SDK(container, mode) {
@@ -93267,9 +93956,45 @@ var SDK = /*#__PURE__*/ function() {
93267
93956
  propertyName: 'height',
93268
93957
  propertyValue: height
93269
93958
  });
93959
+ },
93960
+ getSelectedItemIds: function getSelectedItemIds() {
93961
+ var _ref;
93962
+ var _this__pageData;
93963
+ return (_ref = (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.selectedItems) != null ? _ref : [];
93964
+ },
93965
+ getPreSelectedItemId: function getPreSelectedItemId() {
93966
+ var _this__pageData;
93967
+ return (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.preSelectedItem;
93968
+ },
93969
+ getSelectionEdgeStyle: function getSelectionEdgeStyle() {
93970
+ 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;
93971
+ return {
93972
+ color: wireframeColor,
93973
+ alpha: wireframeAlpha,
93974
+ width: wireframeWidth
93975
+ };
93976
+ },
93977
+ getPreSelectionEdgeStyle: function getPreSelectionEdgeStyle() {
93978
+ var _SDK_config_gestureHandlerConfig_selectorGizmoConfig = SDK.config.gestureHandlerConfig.selectorGizmoConfig, preSelectedColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedColor, preSelectedWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedWidth;
93979
+ return {
93980
+ color: preSelectedColor,
93981
+ alpha: 1,
93982
+ width: preSelectedWidth
93983
+ };
93984
+ },
93985
+ getCanvasEventTarget: function getCanvasEventTarget() {
93986
+ var _this__gestureHandler;
93987
+ return (_this__gestureHandler = _this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view;
93988
+ },
93989
+ resolveCardHTML: function resolveCardHTML(item) {
93990
+ return isCardItem(item) ? _this.resolveCardHTML(item) : undefined;
93991
+ },
93992
+ resolveCardTypeConfig: function resolveCardTypeConfig(item) {
93993
+ return isCardItem(item) ? _this.resolveCardTypeConfig(item) : undefined;
93270
93994
  }
93271
93995
  });
93272
93996
  this._htmlOverlayManager.attach();
93997
+ this.syncCanvasLayerOrder();
93273
93998
  }
93274
93999
  var _proto = SDK.prototype;
93275
94000
  _proto.dispose = function dispose() {
@@ -93365,6 +94090,7 @@ var SDK = /*#__PURE__*/ function() {
93365
94090
  this.initPlayer(SDK.config.mode);
93366
94091
  this._pageDataUtils = new PageDataUtils(this.player, this._playerContainer, this._eventEmitter, this);
93367
94092
  this._gestureHandler = new GestureHandler(this._container);
94093
+ this.syncCanvasLayerOrder();
93368
94094
  return [
93369
94095
  4,
93370
94096
  this.runByPageData(this.pageData)
@@ -93414,6 +94140,16 @@ var SDK = /*#__PURE__*/ function() {
93414
94140
  env: 'editor'
93415
94141
  });
93416
94142
  this.player.resize();
94143
+ this.syncCanvasLayerOrder();
94144
+ };
94145
+ _proto.syncCanvasLayerOrder = function syncCanvasLayerOrder() {
94146
+ var _this__htmlOverlayManager, _this__gestureHandler;
94147
+ orderSDKCanvasLayers({
94148
+ container: this._container,
94149
+ playerContainer: this._playerContainer,
94150
+ htmlOverlayLayer: (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.layerElement,
94151
+ gestureCanvas: (_this__gestureHandler = this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view
94152
+ });
93417
94153
  };
93418
94154
  _proto.getInitParam = function getInitParam(param) {
93419
94155
  return _async_to_generator(function() {
@@ -94508,8 +95244,7 @@ var SDK = /*#__PURE__*/ function() {
94508
95244
  * @param ignoreClamp 是否忽视约束
94509
95245
  */ _proto.setPageZoom = function setPageZoom(zoom, center, ignoreClamp) {
94510
95246
  assertExist$1(this._pageData);
94511
- this._pageData.property.zoom = zoom;
94512
- this._pageDataUtils.setPageZoom(this._pageData.property.zoom, center, ignoreClamp);
95247
+ this._pageDataUtils.setPageZoom(zoom, center, ignoreClamp);
94513
95248
  this._gestureHandler.render();
94514
95249
  };
94515
95250
  /**
@@ -95405,6 +96140,44 @@ var SDK = /*#__PURE__*/ function() {
95405
96140
  });
95406
96141
  };
95407
96142
  /**
96143
+ * @description 按 cardType 从注册表解析卡片的 HTML 渲染配置。
96144
+ * @param item 卡片元素
96145
+ * @returns HTML 渲染配置
96146
+ */ _proto.resolveCardHTML = function resolveCardHTML(item) {
96147
+ var _cardTypeConfig_html;
96148
+ var cardTypeConfig = this.resolveCardTypeConfig(item);
96149
+ return cardTypeConfig == null ? void 0 : (_cardTypeConfig_html = cardTypeConfig.html) == null ? void 0 : _cardTypeConfig_html.call(cardTypeConfig, item);
96150
+ };
96151
+ /**
96152
+ * @description 按 cardType 从注册表解析卡片类型配置。
96153
+ * @param item 卡片元素
96154
+ * @returns 卡片类型配置
96155
+ */ _proto.resolveCardTypeConfig = function resolveCardTypeConfig(item) {
96156
+ return SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96157
+ return t.type === item.cardType;
96158
+ });
96159
+ };
96160
+ /**
96161
+ * @description 重新解析并挂载指定卡片的 HTML 内容。
96162
+ * @description 当 inline/document 内容依赖 extension 或外部状态变化时,可调用此方法刷新 DOM。
96163
+ * @param id 卡片元素 ID
96164
+ * @returns 是否成功触发刷新
96165
+ */ _proto.refreshCardHTML = function refreshCardHTML(id) {
96166
+ var _this__htmlOverlayManager, _this__htmlOverlayManager1;
96167
+ var item = this.getSDKItem(id);
96168
+ if (!isCardItem(item)) {
96169
+ console.warn('CardItem "' + id + '" not found.');
96170
+ return false;
96171
+ }
96172
+ if (!this.resolveCardHTML(item)) {
96173
+ console.warn('CardItem "' + id + '" has no registered HTML renderer.');
96174
+ return false;
96175
+ }
96176
+ (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.invalidateCardHTML(id);
96177
+ (_this__htmlOverlayManager1 = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager1.scheduleRender();
96178
+ return true;
96179
+ };
96180
+ /**
95408
96181
  * @description 创建卡片元素
95409
96182
  * @description 底层以透明 SpriteItem 形式渲染,支持 cardType 属性
95410
96183
  * @param createInfo 卡片创建信息
@@ -95699,8 +96472,8 @@ SDK.config = BaseConfig;
95699
96472
  _inherits(CardItem, BaseItem);
95700
96473
  function CardItem(options) {
95701
96474
  var _this;
95702
- var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6;
95703
- var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5, _SDK_config_itemConfig_cardConfig_cardTypes_, _options_property6, _options_property7;
96475
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
96476
+ var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5;
95704
96477
  _this = BaseItem.call(this, options) || this, /**
95705
96478
  * @description 元素类型
95706
96479
  */ _this.type = SDKItemType.CARD;
@@ -95721,9 +96494,7 @@ SDK.config = BaseConfig;
95721
96494
  1,
95722
96495
  1
95723
96496
  ],
95724
- 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 : '',
95725
- autoHeight: (_options_property6 = options.property) == null ? void 0 : _options_property6.autoHeight,
95726
- html: (_options_property7 = options.property) == null ? void 0 : _options_property7.html
96497
+ cardType: (_ref5 = (_options_property5 = options.property) == null ? void 0 : _options_property5.cardType) != null ? _ref5 : 'unknown'
95727
96498
  };
95728
96499
  return _this;
95729
96500
  }
@@ -95734,22 +96505,18 @@ SDK.config = BaseConfig;
95734
96505
  * @param withParent 是否包含父节点ID
95735
96506
  */ _proto.toCreateInfo = function toCreateInfo(withParent) {
95736
96507
  var extension = this.getAllExtension();
95737
- var property = deepClone(this.property);
95738
- property.html = this.html;
95739
96508
  return {
95740
96509
  type: SDKItemType.CARD,
95741
96510
  id: this.id,
95742
96511
  name: this.name,
95743
96512
  parentId: withParent ? this.parentId : undefined,
95744
96513
  extension: Object.keys(extension).length > 0 ? extension : undefined,
95745
- property: property
96514
+ property: deepClone(this.property)
95746
96515
  };
95747
96516
  };
95748
96517
  /**
95749
96518
  * @description 克隆 SDKItem
95750
96519
  */ _proto.clone = function clone() {
95751
- var property = deepClone(this.property);
95752
- property.html = this.html;
95753
96520
  return new CardItem({
95754
96521
  id: generateGUID(),
95755
96522
  name: this.name,
@@ -95759,7 +96526,7 @@ SDK.config = BaseConfig;
95759
96526
  endBehavior: this.endBehavior,
95760
96527
  isLocked: this.isLocked,
95761
96528
  isCoreEditable: this.isCoreEditable,
95762
- property: property,
96529
+ property: deepClone(this.property),
95763
96530
  extension: this.getAllExtension()
95764
96531
  });
95765
96532
  };
@@ -95776,17 +96543,6 @@ SDK.config = BaseConfig;
95776
96543
  this.property.cardType = value;
95777
96544
  }
95778
96545
  },
95779
- {
95780
- key: "html",
95781
- get: /**
95782
- * @description HTML 覆盖层配置
95783
- */ function get() {
95784
- return this.property.html;
95785
- },
95786
- set: function set(value) {
95787
- this.property.html = value;
95788
- }
95789
- },
95790
96546
  {
95791
96547
  key: "position",
95792
96548
  get: // ==================== 便捷访问器 ====================
@@ -95799,6 +96555,16 @@ SDK.config = BaseConfig;
95799
96555
  this.property.position = value;
95800
96556
  }
95801
96557
  },
96558
+ {
96559
+ key: "isAutoScale",
96560
+ get: function get() {
96561
+ var _this = this;
96562
+ var config = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96563
+ return t.type === _this.cardType;
96564
+ });
96565
+ return !!(config == null ? void 0 : config.autoScale);
96566
+ }
96567
+ },
95802
96568
  {
95803
96569
  key: "width",
95804
96570
  get: /**