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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/{src/config.d.ts → config.d.ts} +24 -1
  2. package/dist/{src/html-overlay → html-overlay}/auto-height-runtime.d.ts +5 -0
  3. package/dist/{src/html-overlay → html-overlay}/manager.d.ts +53 -0
  4. package/dist/{src/html-overlay → html-overlay}/overlay-transform.d.ts +3 -1
  5. package/dist/{src/index.d.ts → index.d.ts} +2 -2
  6. package/dist/index.js +960 -204
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +960 -204
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/layer-order.d.ts +7 -0
  11. package/dist/{src/sdk-item → sdk-item}/card-item.d.ts +2 -6
  12. package/dist/{src/sdk.d.ts → sdk.d.ts} +22 -2
  13. package/dist/{src/types.d.ts → types.d.ts} +17 -18
  14. package/dist/{src/utils → utils}/page-data-utils.d.ts +11 -0
  15. package/package.json +2 -2
  16. /package/dist/{src/exporter → exporter}/config.d.ts +0 -0
  17. /package/dist/{src/exporter → exporter}/const.d.ts +0 -0
  18. /package/dist/{src/exporter → exporter}/export-media.d.ts +0 -0
  19. /package/dist/{src/exporter → exporter}/exporter.d.ts +0 -0
  20. /package/dist/{src/exporter → exporter}/index.d.ts +0 -0
  21. /package/dist/{src/exporter → exporter}/types.d.ts +0 -0
  22. /package/dist/{src/exporter → exporter}/utils.d.ts +0 -0
  23. /package/dist/{src/exporter → exporter}/wav-audio.d.ts +0 -0
  24. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/adsorption-gizmo.d.ts +0 -0
  25. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/control-gizmo.d.ts +0 -0
  26. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/gizmo.d.ts +0 -0
  27. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/icon-gizmo.d.ts +0 -0
  28. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/index.d.ts +0 -0
  29. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/item-create-gizmo.d.ts +0 -0
  30. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/loading-gizmo.d.ts +0 -0
  31. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/mask-gizmo.d.ts +0 -0
  32. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/picture-cut-gizmo.d.ts +0 -0
  33. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/picture-expand-gizmo.d.ts +0 -0
  34. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/preference-gizmo.d.ts +0 -0
  35. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/selector-gizmo.d.ts +0 -0
  36. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/sprite-text-edit-gizmo.d.ts +0 -0
  37. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/text-gizmo.d.ts +0 -0
  38. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/transform-gizmo.d.ts +0 -0
  39. /package/dist/{src/gesture-handler → gesture-handler}/gizmo/type.d.ts +0 -0
  40. /package/dist/{src/gesture-handler → gesture-handler}/index.d.ts +0 -0
  41. /package/dist/{src/gesture-handler → gesture-handler}/src/gesture-handler.d.ts +0 -0
  42. /package/dist/{src/gesture-handler → gesture-handler}/src/icons.d.ts +0 -0
  43. /package/dist/{src/gesture-handler → gesture-handler}/utils.d.ts +0 -0
  44. /package/dist/{src/html-overlay → html-overlay}/document-runtime.d.ts +0 -0
  45. /package/dist/{src/html-overlay → html-overlay}/document-transform.d.ts +0 -0
  46. /package/dist/{src/html-overlay → html-overlay}/dom-order.d.ts +0 -0
  47. /package/dist/{src/html-overlay → html-overlay}/host-message-runtime.d.ts +0 -0
  48. /package/dist/{src/html-overlay → html-overlay}/html-viewport-style.d.ts +0 -0
  49. /package/dist/{src/html-overlay → html-overlay}/index.d.ts +0 -0
  50. /package/dist/{src/html-overlay → html-overlay}/mime-utils.d.ts +0 -0
  51. /package/dist/{src/html-overlay → html-overlay}/path-utils.d.ts +0 -0
  52. /package/dist/{src/html-overlay → html-overlay}/shell-runtime.d.ts +0 -0
  53. /package/dist/{src/math → math}/box2.d.ts +0 -0
  54. /package/dist/{src/math → math}/circle.d.ts +0 -0
  55. /package/dist/{src/math → math}/euler.d.ts +0 -0
  56. /package/dist/{src/math → math}/index.d.ts +0 -0
  57. /package/dist/{src/math → math}/line2.d.ts +0 -0
  58. /package/dist/{src/math → math}/line3.d.ts +0 -0
  59. /package/dist/{src/math → math}/matrix4.d.ts +0 -0
  60. /package/dist/{src/math → math}/plane.d.ts +0 -0
  61. /package/dist/{src/math → math}/quaternion.d.ts +0 -0
  62. /package/dist/{src/math → math}/ray-caster.d.ts +0 -0
  63. /package/dist/{src/math → math}/ray.d.ts +0 -0
  64. /package/dist/{src/math → math}/type.d.ts +0 -0
  65. /package/dist/{src/math → math}/utils.d.ts +0 -0
  66. /package/dist/{src/math → math}/vector2.d.ts +0 -0
  67. /package/dist/{src/math → math}/vector3.d.ts +0 -0
  68. /package/dist/{src/screen-shot → screen-shot}/index.d.ts +0 -0
  69. /package/dist/{src/screen-shot → screen-shot}/screen-shot.d.ts +0 -0
  70. /package/dist/{src/sdk-item → sdk-item}/base-item.d.ts +0 -0
  71. /package/dist/{src/sdk-item → sdk-item}/effects-item.d.ts +0 -0
  72. /package/dist/{src/sdk-item → sdk-item}/frame-item.d.ts +0 -0
  73. /package/dist/{src/sdk-item → sdk-item}/generator-item.d.ts +0 -0
  74. /package/dist/{src/sdk-item → sdk-item}/group-item.d.ts +0 -0
  75. /package/dist/{src/sdk-item → sdk-item}/index.d.ts +0 -0
  76. /package/dist/{src/sdk-item → sdk-item}/sprite-item.d.ts +0 -0
  77. /package/dist/{src/sdk-item → sdk-item}/text-item.d.ts +0 -0
  78. /package/dist/{src/sdk-item → sdk-item}/types.d.ts +0 -0
  79. /package/dist/{src/sdk-item → sdk-item}/video-item.d.ts +0 -0
  80. /package/dist/{src/service → service}/UndoRedo.d.ts +0 -0
  81. /package/dist/{src/shared → shared}/index.d.ts +0 -0
  82. /package/dist/{src/shared → shared}/player.d.ts +0 -0
  83. /package/dist/{src/size-adapte → size-adapte}/index.d.ts +0 -0
  84. /package/dist/{src/size-adapte → size-adapte}/size-adapt.d.ts +0 -0
  85. /package/dist/{src/utils → utils}/background-manager.d.ts +0 -0
  86. /package/dist/{src/utils → utils}/common-utils.d.ts +0 -0
  87. /package/dist/{src/utils → utils}/index.d.ts +0 -0
  88. /package/dist/{src/utils → utils}/interaction-utils.d.ts +0 -0
  89. /package/dist/{src/utils → utils}/json-data-utils.d.ts +0 -0
  90. /package/dist/{src/utils → utils}/layout-utils.d.ts +0 -0
  91. /package/dist/{src/utils → utils}/player-data-utils.d.ts +0 -0
  92. /package/dist/{src/utils → utils}/types.d.ts +0 -0
  93. /package/dist/{src/wireframe → wireframe}/common/box.d.ts +0 -0
  94. /package/dist/{src/wireframe → wireframe}/common/dashed-line.d.ts +0 -0
  95. /package/dist/{src/wireframe → wireframe}/common/line.d.ts +0 -0
  96. /package/dist/{src/wireframe → wireframe}/common/pixi-ext.d.ts +0 -0
  97. /package/dist/{src/wireframe → wireframe}/common/pixi.d.ts +0 -0
  98. /package/dist/{src/wireframe → wireframe}/index.d.ts +0 -0
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: TODO
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 赤芍,何即,不择,意绮
6
- * Version: v0.2.2-beta.1
6
+ * Version: v0.2.2-beta.12
7
7
  */
8
8
 
9
9
  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 isSingleAutoFitContentCardItem = selectedItems.length === 1 && selectedItem && isCardItem(selectedItem) && !selectedItem.isAutoScale;
55345
+ var isShiftLockScale = selectedItem && selectedItems.length === 1 && (isFrameItem(selectedItem) || isSingleAutoFitContentCardItem) ? !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,23 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55414
55416
  newWidth,
55415
55417
  newHeight
55416
55418
  ], translation1);
55419
+ } else if (isSingleAutoFitContentCardItem && selectedItem && isCardItem(selectedItem)) {
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
+ });
55417
55436
  } else {
55418
55437
  // 普通元素的缩放逻辑
55419
55438
  selectedItems.forEach(function(item) {
@@ -55738,6 +55757,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55738
55757
  var selectedItems = this._pageDataUtils.getSelectedItems();
55739
55758
  var isTemplateMode = SDK.config.mode === 'template';
55740
55759
  var selectedItem = selectedItems.length === 1 ? selectedItems[0] : undefined;
55760
+ var isSingleCardItem = isCardItem(selectedItem);
55741
55761
  var isGeneratorItem = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.GENERATOR;
55742
55762
  var isAutoLayoutFrame = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.FRAME && (selectedItem == null ? void 0 : selectedItem.layoutMode) === FrameLayoutMode.AUTO;
55743
55763
  var canScale = selectedItems.length === 1 && (selectedItem == null ? void 0 : selectedItem.type) !== SDKItemType.GROUP && !isAutoLayoutFrame && !isGeneratorItem;
@@ -55777,9 +55797,11 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55777
55797
  this.wireframe.totalBox.copyFrom(box).expandByScalar(totalBoxExpandScalar);
55778
55798
  // 根据box获取边缘线
55779
55799
  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
- });
55800
+ if (!isSingleCardItem) {
55801
+ corners.forEach(function(corner, i) {
55802
+ _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55803
+ });
55804
+ }
55783
55805
  var _SDK_config_gestureHandlerConfig_transformGizmoConfig = SDK.config.gestureHandlerConfig.transformGizmoConfig, scaleCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.scaleCircleSize, rotationCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.rotationCircleSize;
55784
55806
  // 成组暂不支持缩放
55785
55807
  if (selectedItems.length === 1) {
@@ -59630,12 +59652,6 @@ var MAX_ITEM_DISTANCE_THRESHOLD = 100000;
59630
59652
  /**
59631
59653
  * @description SDKItem position 属性的数字精度(保留小数位数)
59632
59654
  */ 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
59655
  var PageDataUtils = /*#__PURE__*/ function() {
59640
59656
  function PageDataUtils(player, container, emitter, sdk) {
59641
59657
  this.player = player;
@@ -60453,11 +60469,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
60453
60469
  property: property
60454
60470
  }));
60455
60471
  } else if ((existingSDKItem == null ? void 0 : existingSDKItem.type) == SDKItemType.CARD) {
60456
- var cardType = existingSDKItem.cardType, html = existingSDKItem.html;
60472
+ var cardType = existingSDKItem.cardType;
60457
60473
  sdkItem = new CardItem(_extends({}, baseOptions, {
60458
60474
  property: _extends({}, property, {
60459
- cardType: cardType,
60460
- html: html
60475
+ cardType: cardType
60461
60476
  })
60462
60477
  }));
60463
60478
  } else {
@@ -60684,6 +60699,19 @@ var PageDataUtils = /*#__PURE__*/ function() {
60684
60699
  }).call(this);
60685
60700
  };
60686
60701
  /**
60702
+ * @description 设置元素extension字段
60703
+ */ _proto.setItemExtension = function setItemExtension(itemId, extension) {
60704
+ var item = this.getSDKItem(itemId);
60705
+ if (!item) {
60706
+ console.warn('setItemExtension: item not found');
60707
+ return;
60708
+ }
60709
+ for(var _iterator = _create_for_of_iterator_helper_loose(Object.entries(extension)), _step; !(_step = _iterator()).done;){
60710
+ var _step_value = _step.value, key = _step_value[0], value = _step_value[1];
60711
+ item.extension.set(key, value);
60712
+ }
60713
+ };
60714
+ /**
60687
60715
  * @description 场景 1: 设置单个元素的单个属性
60688
60716
  */ _proto.setSingleItemSingleProperty = function setSingleItemSingleProperty(param) {
60689
60717
  return _async_to_generator(function() {
@@ -61041,40 +61069,35 @@ var PageDataUtils = /*#__PURE__*/ function() {
61041
61069
  3,
61042
61070
  31
61043
61071
  ];
61044
- case 'html':
61045
- return [
61046
- 3,
61047
- 32
61048
- ];
61049
61072
  case 'position':
61050
61073
  return [
61051
61074
  3,
61052
- 33
61075
+ 32
61053
61076
  ];
61054
61077
  case 'rotation':
61055
61078
  return [
61056
61079
  3,
61057
- 34
61080
+ 33
61058
61081
  ];
61059
61082
  case 'scale':
61060
61083
  return [
61061
61084
  3,
61062
- 35
61085
+ 34
61063
61086
  ];
61064
61087
  case 'layoutMode':
61065
61088
  return [
61066
61089
  3,
61067
- 36
61090
+ 35
61068
61091
  ];
61069
61092
  case 'visible':
61070
61093
  return [
61071
61094
  3,
61072
- 37
61095
+ 36
61073
61096
  ];
61074
61097
  }
61075
61098
  return [
61076
61099
  3,
61077
- 38
61100
+ 37
61078
61101
  ];
61079
61102
  case 1:
61080
61103
  {
@@ -61087,7 +61110,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61087
61110
  }
61088
61111
  return [
61089
61112
  3,
61090
- 39
61113
+ 38
61091
61114
  ];
61092
61115
  }
61093
61116
  case 2:
@@ -61098,7 +61121,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61098
61121
  }
61099
61122
  return [
61100
61123
  3,
61101
- 39
61124
+ 38
61102
61125
  ];
61103
61126
  }
61104
61127
  case 3:
@@ -61130,7 +61153,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61130
61153
  case 5:
61131
61154
  return [
61132
61155
  3,
61133
- 39
61156
+ 38
61134
61157
  ];
61135
61158
  case 6:
61136
61159
  {
@@ -61147,7 +61170,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61147
61170
  }
61148
61171
  return [
61149
61172
  3,
61150
- 39
61173
+ 38
61151
61174
  ];
61152
61175
  }
61153
61176
  case 7:
@@ -61161,7 +61184,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61161
61184
  }
61162
61185
  return [
61163
61186
  3,
61164
- 39
61187
+ 38
61165
61188
  ];
61166
61189
  }
61167
61190
  case 8:
@@ -61174,7 +61197,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61174
61197
  }
61175
61198
  return [
61176
61199
  3,
61177
- 39
61200
+ 38
61178
61201
  ];
61179
61202
  }
61180
61203
  case 9:
@@ -61188,7 +61211,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61188
61211
  }
61189
61212
  return [
61190
61213
  3,
61191
- 39
61214
+ 38
61192
61215
  ];
61193
61216
  }
61194
61217
  case 10:
@@ -61201,7 +61224,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61201
61224
  }
61202
61225
  return [
61203
61226
  3,
61204
- 39
61227
+ 38
61205
61228
  ];
61206
61229
  }
61207
61230
  case 11:
@@ -61214,7 +61237,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61214
61237
  }
61215
61238
  return [
61216
61239
  3,
61217
- 39
61240
+ 38
61218
61241
  ];
61219
61242
  }
61220
61243
  case 12:
@@ -61234,7 +61257,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61234
61257
  }
61235
61258
  return [
61236
61259
  3,
61237
- 39
61260
+ 38
61238
61261
  ];
61239
61262
  }
61240
61263
  case 13:
@@ -61276,7 +61299,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61276
61299
  }
61277
61300
  return [
61278
61301
  3,
61279
- 39
61302
+ 38
61280
61303
  ];
61281
61304
  }
61282
61305
  case 14:
@@ -61311,7 +61334,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61311
61334
  }
61312
61335
  return [
61313
61336
  3,
61314
- 39
61337
+ 38
61315
61338
  ];
61316
61339
  }
61317
61340
  case 15:
@@ -61325,7 +61348,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61325
61348
  }
61326
61349
  return [
61327
61350
  3,
61328
- 39
61351
+ 38
61329
61352
  ];
61330
61353
  }
61331
61354
  case 16:
@@ -61357,7 +61380,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61357
61380
  case 20:
61358
61381
  return [
61359
61382
  3,
61360
- 39
61383
+ 38
61361
61384
  ];
61362
61385
  case 21:
61363
61386
  if (!(typeof propertyValue === 'string' && playerItem.type === spec.ItemType.video)) return [
@@ -61388,7 +61411,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61388
61411
  case 25:
61389
61412
  return [
61390
61413
  3,
61391
- 39
61414
+ 38
61392
61415
  ];
61393
61416
  case 26:
61394
61417
  if (!(playerItem.type === spec.ItemType.null)) return [
@@ -61433,7 +61456,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61433
61456
  case 28:
61434
61457
  return [
61435
61458
  3,
61436
- 39
61459
+ 38
61437
61460
  ];
61438
61461
  case 29:
61439
61462
  {
@@ -61445,7 +61468,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61445
61468
  }
61446
61469
  return [
61447
61470
  3,
61448
- 39
61471
+ 38
61449
61472
  ];
61450
61473
  }
61451
61474
  case 30:
@@ -61458,7 +61481,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
61458
61481
  }
61459
61482
  return [
61460
61483
  3,
61461
- 39
61484
+ 38
61462
61485
  ];
61463
61486
  }
61464
61487
  case 31:
@@ -61471,20 +61494,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61471
61494
  }
61472
61495
  return [
61473
61496
  3,
61474
- 39
61497
+ 38
61475
61498
  ];
61476
61499
  }
61477
61500
  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
61501
  {
61489
61502
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61490
61503
  pixelTranslation = propertyValue.map(function(v, i) {
@@ -61497,10 +61510,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61497
61510
  }
61498
61511
  return [
61499
61512
  3,
61500
- 39
61513
+ 38
61501
61514
  ];
61502
61515
  }
61503
- case 34:
61516
+ case 33:
61504
61517
  {
61505
61518
  if (Array.isArray(propertyValue) && propertyValue.length === 3) {
61506
61519
  rotation = propertyValue.map(function(v, i) {
@@ -61511,10 +61524,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61511
61524
  }
61512
61525
  return [
61513
61526
  3,
61514
- 39
61527
+ 38
61515
61528
  ];
61516
61529
  }
61517
- case 35:
61530
+ case 34:
61518
61531
  {
61519
61532
  if (Array.isArray(propertyValue) && propertyValue.length === 2) {
61520
61533
  currentScale = targetItem.property.scale;
@@ -61528,10 +61541,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61528
61541
  }
61529
61542
  return [
61530
61543
  3,
61531
- 39
61544
+ 38
61532
61545
  ];
61533
61546
  }
61534
- case 36:
61547
+ case 35:
61535
61548
  {
61536
61549
  if (propertyValue === FrameLayoutMode.AUTO || propertyValue === FrameLayoutMode.FREE) {
61537
61550
  frameComponent = playerItem.getComponent(FrameComponent);
@@ -61541,10 +61554,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61541
61554
  }
61542
61555
  return [
61543
61556
  3,
61544
- 39
61557
+ 38
61545
61558
  ];
61546
61559
  }
61547
- case 37:
61560
+ case 36:
61548
61561
  {
61549
61562
  if (typeof propertyValue === 'boolean') {
61550
61563
  playerItem.setVisible(propertyValue);
@@ -61557,10 +61570,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
61557
61570
  }
61558
61571
  return [
61559
61572
  3,
61560
- 39
61573
+ 38
61561
61574
  ];
61562
61575
  }
61563
- case 38:
61576
+ case 37:
61564
61577
  {
61565
61578
  console.log('ignore property name ', propertyName);
61566
61579
  // 对于未明确处理的属性,尝试直接设置到 property 对象
@@ -61568,8 +61581,8 @@ var PageDataUtils = /*#__PURE__*/ function() {
61568
61581
  targetItem.property[propertyName] = propertyValue;
61569
61582
  }
61570
61583
  }
61571
- _state.label = 39;
61572
- case 39:
61584
+ _state.label = 38;
61585
+ case 38:
61573
61586
  // 非位置属性需要刷新播放器
61574
61587
  // template 模式下保持暂停态以避免播放器自动播放,editor 模式继续推进
61575
61588
  if (![
@@ -62449,6 +62462,10 @@ var PageDataUtils = /*#__PURE__*/ function() {
62449
62462
  }
62450
62463
  break;
62451
62464
  }
62465
+ case 'cardType':
62466
+ {
62467
+ break;
62468
+ }
62452
62469
  default:
62453
62470
  {
62454
62471
  console.warn("Target property " + propertyName + " can not be changed.");
@@ -63041,12 +63058,15 @@ var PageDataUtils = /*#__PURE__*/ function() {
63041
63058
  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
63059
  1,
63043
63060
  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;
63061
+ ] : _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
63062
  // 校验 cardType 是否已在配置中注册
63063
+ var cardTypeConfig = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
63064
+ return t.type === cardType;
63065
+ });
63046
63066
  var registeredTypes = SDK.config.itemConfig.cardConfig.cardTypes.map(function(t) {
63047
63067
  return t.type;
63048
63068
  });
63049
- if (!registeredTypes.includes(cardType)) {
63069
+ if (!cardTypeConfig) {
63050
63070
  console.warn('CardItem cardType "' + cardType + '" is not registered. Registered types: ' + registeredTypes.join(', '));
63051
63071
  return;
63052
63072
  }
@@ -63090,9 +63110,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
63090
63110
  width: width,
63091
63111
  height: height,
63092
63112
  scale: [].concat(scale),
63093
- cardType: cardType,
63094
- autoHeight: autoHeight,
63095
- html: html
63113
+ cardType: cardType
63096
63114
  },
63097
63115
  extension: extension
63098
63116
  });
@@ -64474,8 +64492,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
64474
64492
  scalar.y
64475
64493
  ],
64476
64494
  rotation: [].concat(rotation),
64477
- position: [].concat(resultPosition),
64478
- html: sdkItem.html
64495
+ position: [].concat(resultPosition)
64479
64496
  },
64480
64497
  extension: extension
64481
64498
  };
@@ -65521,7 +65538,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
65521
65538
  _this = this;
65522
65539
  changeProeprty = function changeProeprty(targetCreateInfo) {
65523
65540
  return _async_to_generator(function() {
65524
- var currentCreateInfo;
65541
+ var currentCreateInfo, itemId;
65525
65542
  return _ts_generator(this, function(_state) {
65526
65543
  switch(_state.label){
65527
65544
  case 0:
@@ -65532,16 +65549,20 @@ var PageDataUtils = /*#__PURE__*/ function() {
65532
65549
  2
65533
65550
  ];
65534
65551
  }
65552
+ itemId = targetCreateInfo.id;
65535
65553
  return [
65536
65554
  4,
65537
65555
  this.setItemProperty({
65538
- itemId: currentCreateInfo.id,
65556
+ itemId: itemId,
65539
65557
  type: currentCreateInfo.type,
65540
65558
  property: targetCreateInfo.property
65541
65559
  })
65542
65560
  ];
65543
65561
  case 1:
65544
65562
  _state.sent();
65563
+ if (targetCreateInfo.extension) {
65564
+ this.setItemExtension(itemId, targetCreateInfo.extension);
65565
+ }
65545
65566
  return [
65546
65567
  2
65547
65568
  ];
@@ -65859,35 +65880,56 @@ var PageDataUtils = /*#__PURE__*/ function() {
65859
65880
  };
65860
65881
  _proto.asyncAddItemByCreateInfos = function asyncAddItemByCreateInfos(createInfos) {
65861
65882
  return _async_to_generator(function() {
65862
- var _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, createInfo, id, type, url, textureId, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65883
+ var _loop, _this, createInfoWithIds, itemToTextureInfo, _iterator, _step, toAddedCreateInfo, groupCreateInfos, frameCreateInfos, ids, composition, loadTexture;
65863
65884
  return _ts_generator(this, function(_state) {
65864
65885
  switch(_state.label){
65865
65886
  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, {
65887
+ _loop = function() {
65888
+ var createInfo = _step.value;
65889
+ var _ref = function() {
65890
+ switch(createInfo.type){
65891
+ case SDKItemType.SPRITE:
65892
+ {
65893
+ return {
65894
+ url: createInfo.property.image,
65895
+ type: 'image'
65896
+ };
65897
+ }
65898
+ case SDKItemType.VIDEO:
65899
+ {
65900
+ return {
65901
+ url: createInfo.property.video,
65902
+ type: 'video'
65903
+ };
65904
+ }
65905
+ default:
65906
+ {
65907
+ return {};
65908
+ }
65909
+ }
65910
+ }(), url = _ref.url, type = _ref.type;
65911
+ if (url && type) {
65912
+ var textureId = generateGUID();
65913
+ itemToTextureInfo.set(createInfo.id, {
65882
65914
  id: textureId,
65883
65915
  url: url,
65884
- type: type === SDKItemType.SPRITE ? 'image' : 'video'
65916
+ type: type
65885
65917
  });
65886
65918
  Object.assign(createInfo, {
65887
65919
  textureId: textureId
65888
65920
  });
65889
65921
  }
65890
- }
65922
+ };
65923
+ _this = this;
65924
+ createInfoWithIds = createInfos.map(function(createInfo) {
65925
+ var _createInfo_id;
65926
+ return Object.assign({}, createInfo, {
65927
+ id: (_createInfo_id = createInfo.id) != null ? _createInfo_id : generateGUID()
65928
+ });
65929
+ });
65930
+ itemToTextureInfo = new Map();
65931
+ // 预处理所有 createInfo,分配 textureId
65932
+ for(_iterator = _create_for_of_iterator_helper_loose(createInfoWithIds); !(_step = _iterator()).done;)_loop();
65891
65933
  // 并行创建所有 item
65892
65934
  toAddedCreateInfo = createInfoWithIds.filter(function(createInfo) {
65893
65935
  return ![
@@ -66856,6 +66898,51 @@ var PageDataUtils = /*#__PURE__*/ function() {
66856
66898
  * @param id 元素id
66857
66899
  * @param size 目标大小 [width, height]
66858
66900
  * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66901
+ */ _proto.resizeCardItem = function resizeCardItem(id, size, translation) {
66902
+ var _frameController_children;
66903
+ var frameItem = this.getSDKItem(id);
66904
+ if (!frameItem) {
66905
+ return;
66906
+ }
66907
+ var newWidth = size[0], newHeight = size[1];
66908
+ // const originalWidth = frameItem.property.width
66909
+ // 计算世界尺寸(供后续使用)
66910
+ var viewSize = this.interactionUtils.getViewSizeByPixelSize(new Vector2(newWidth, newHeight));
66911
+ var worldSize = this.interactionUtils.getWorldSizeByViewSize(viewSize).abs();
66912
+ // 1 更新 Player 层的预合成和子元素
66913
+ // 1.1 更新 Player Item(空节点控制器)的大小
66914
+ var frameController = this.getPlayerItemById(id);
66915
+ if (frameController) {
66916
+ frameController.transform.setSize(worldSize.x, worldSize.y);
66917
+ // 如果有位移,更新位置
66918
+ if (translation && (translation.x !== 0 || translation.y !== 0)) {
66919
+ var currentPosition = frameController.transform.position;
66920
+ frameController.setPosition(currentPosition.x + translation.x, currentPosition.y + translation.y, currentPosition.z);
66921
+ }
66922
+ }
66923
+ // 1.2 更新 Player Children Item 的大小
66924
+ var subCompositionItem = frameController == null ? void 0 : (_frameController_children = frameController.children) == null ? void 0 : _frameController_children[0];
66925
+ if (subCompositionItem && translation) {
66926
+ // 更新子元素
66927
+ subCompositionItem.children.forEach(function(item) {
66928
+ var _item;
66929
+ var _item_transform_getParentMatrix;
66930
+ var parentMatrix = new Matrix4().copyFrom((_item_transform_getParentMatrix = item.transform.getParentMatrix()) != null ? _item_transform_getParentMatrix : new Matrix4());
66931
+ parentMatrix.setPosition(new Vector3());
66932
+ var result = translation.clone().applyMatrix(parentMatrix.invert()).negate();
66933
+ (_item = item).translate.apply(_item, [].concat(result.toArray()));
66934
+ item.transform.updateLocalMatrix();
66935
+ });
66936
+ }
66937
+ // 2: 刷新 SDKItem 数据
66938
+ // 更新 FrameItem 的 property
66939
+ this.refreshSDKItem(frameItem.id);
66940
+ };
66941
+ /**
66942
+ * @description 修改画板元素大小
66943
+ * @param id 元素id
66944
+ * @param size 目标大小 [width, height]
66945
+ * @param translation 位置偏移补偿(可选,用于保持拖拽角点固定)
66859
66946
  */ _proto.resizeFrameItem = function resizeFrameItem(id, size, translation) {
66860
66947
  var _this = this;
66861
66948
  var _frameController_children;
@@ -83060,43 +83147,12 @@ var BaseConfig = {
83060
83147
  },
83061
83148
  cardConfig: {
83062
83149
  backgroundColor: [
83063
- 0.6,
83064
- 0.6,
83065
- 0.6,
83066
- 0.12
83150
+ 1,
83151
+ 1,
83152
+ 1,
83153
+ 0
83067
83154
  ],
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
- ]
83155
+ cardTypes: []
83100
83156
  }
83101
83157
  }
83102
83158
  };
@@ -91425,11 +91481,18 @@ function isCardHTMLAutoHeightMessage(data, id) {
91425
91481
  var message = data;
91426
91482
  return message.source === 'vvfx-card-html-auto-height' && message.id === id && typeof message.height === 'number';
91427
91483
  }
91484
+ function requestCardHTMLAutoHeight(iframe, id) {
91485
+ var _iframe_contentWindow;
91486
+ (_iframe_contentWindow = iframe.contentWindow) == null ? void 0 : _iframe_contentWindow.postMessage({
91487
+ source: 'vvfx-card-html-auto-height-request',
91488
+ id: id
91489
+ }, '*');
91490
+ }
91428
91491
  function withCardHTMLAutoHeightBridge(html, id) {
91429
91492
  if (!id) {
91430
91493
  return html;
91431
91494
  }
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>";
91495
+ 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
91496
  if (/<\/body>/i.test(html)) {
91434
91497
  return html.replace(/<\/body>/i, "" + script + "</body>");
91435
91498
  }
@@ -91702,30 +91765,38 @@ function syncElementStackOrder(_container, elements) {
91702
91765
  });
91703
91766
  }
91704
91767
 
91705
- function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY) {
91768
+ function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, _autoScale) {
91706
91769
  if (offsetX === void 0) offsetX = 0;
91707
91770
  if (offsetY === void 0) offsetY = 0;
91708
91771
  if (box.corners.length === 4 && width > 0 && height > 0) {
91709
91772
  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;
91773
+ var contentWidth = width;
91774
+ var contentHeight = height;
91775
+ var a = (rightTop.x - leftTop.x) / contentWidth;
91776
+ var b = (rightTop.y - leftTop.y) / contentWidth;
91777
+ var c = (leftBottom.x - leftTop.x) / contentHeight;
91778
+ var d = (leftBottom.y - leftTop.y) / contentHeight;
91714
91779
  var e = leftTop.x - offsetX;
91715
91780
  var f = leftTop.y - offsetY;
91716
91781
  return {
91717
91782
  left: '0px',
91718
91783
  top: '0px',
91719
- width: "" + width + "px",
91720
- height: "" + height + "px",
91784
+ width: "" + formatPixelNumber(contentWidth) + "px",
91785
+ height: "" + formatPixelNumber(contentHeight) + "px",
91786
+ contentWidth: contentWidth,
91787
+ contentHeight: contentHeight,
91721
91788
  transform: "matrix(" + formatMatrixNumber(a) + ", " + formatMatrixNumber(b) + ", " + formatMatrixNumber(c) + ", " + formatMatrixNumber(d) + ", " + formatMatrixNumber(e) + ", " + formatMatrixNumber(f) + ")"
91722
91789
  };
91723
91790
  }
91791
+ var contentWidth1 = box.max.x - box.min.x;
91792
+ var contentHeight1 = box.max.y - box.min.y;
91724
91793
  return {
91725
91794
  left: "" + (box.min.x - offsetX) + "px",
91726
91795
  top: "" + (box.min.y - offsetY) + "px",
91727
- width: "" + (box.max.x - box.min.x) + "px",
91728
- height: "" + (box.max.y - box.min.y) + "px",
91796
+ width: "" + contentWidth1 + "px",
91797
+ height: "" + contentHeight1 + "px",
91798
+ contentWidth: contentWidth1,
91799
+ contentHeight: contentHeight1,
91729
91800
  transform: ''
91730
91801
  };
91731
91802
  }
@@ -91748,6 +91819,10 @@ function formatMatrixNumber(value) {
91748
91819
  var normalized = Object.is(value, -0) ? 0 : value;
91749
91820
  return Number(normalized.toFixed(6)).toString();
91750
91821
  }
91822
+ function formatPixelNumber(value) {
91823
+ var normalized = Object.is(value, -0) ? 0 : value;
91824
+ return Number(normalized.toFixed(6)).toString();
91825
+ }
91751
91826
 
91752
91827
  function mountHTMLShell(container, content, shell) {
91753
91828
  if (!shell) {
@@ -91768,6 +91843,26 @@ function mountHTMLShell(container, content, shell) {
91768
91843
 
91769
91844
  var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
91770
91845
  var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
91846
+ var CONTENT_INTERACTIVE_SELECTOR = [
91847
+ '[data-vvfx-html-interaction-zone="self"]',
91848
+ '[data-vvfx-html-interaction-zone="subtree"]',
91849
+ 'a[href]',
91850
+ 'button:not([disabled])',
91851
+ 'input:not([disabled])',
91852
+ 'textarea:not([disabled])',
91853
+ 'select:not([disabled])',
91854
+ 'summary',
91855
+ 'video[controls]',
91856
+ 'audio[controls]',
91857
+ '[contenteditable]:not([contenteditable="false"])',
91858
+ '[role="button"]',
91859
+ '[role="link"]',
91860
+ '[role="textbox"]',
91861
+ '[tabindex]:not([tabindex="-1"])'
91862
+ ].join(', ');
91863
+ var CONTENT_INTERACTION_NONE_SELECTOR = [
91864
+ '[data-vvfx-html-interaction-zone="none"]'
91865
+ ].join(', ');
91771
91866
  var EDITING_VIEWPORT_PADDING = 48;
91772
91867
  var EDITING_VIEWPORT_BOX_SCALE = 1.1;
91773
91868
  var AUTO_HEIGHT_EPSILON = 0.5;
@@ -91777,14 +91872,20 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91777
91872
  var _this = this;
91778
91873
  this.options = options;
91779
91874
  this.eventCleanups = [];
91875
+ this.htmlRootConfigCleanups = new WeakMap();
91780
91876
  this.state = {
91781
91877
  frameElements: new Map(),
91782
91878
  elements: new Map(),
91879
+ selectionElements: new Map(),
91783
91880
  contentScaleElements: new Map(),
91784
91881
  contentElements: new Map(),
91785
91882
  contentMountElements: new Map(),
91883
+ contentInteractionZones: new Map(),
91884
+ contentInteractionZoneCleanups: new Map(),
91885
+ contentInteractionResizeCleanups: new Map(),
91786
91886
  contents: new Map(),
91787
91887
  cleanups: new Map(),
91888
+ autoHeightModes: new Map(),
91788
91889
  autoHeightCleanups: new Map(),
91789
91890
  autoHeightFrames: new Map()
91790
91891
  };
@@ -91801,6 +91902,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91801
91902
  }
91802
91903
  return;
91803
91904
  }
91905
+ if (!_this.isEditableCard(targetId)) {
91906
+ return;
91907
+ }
91804
91908
  event.preventDefault();
91805
91909
  event.stopPropagation();
91806
91910
  _this.enterEditing(targetId);
@@ -91816,6 +91920,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91816
91920
  _this.exitEditing();
91817
91921
  };
91818
91922
  this.handleContainerMouseMove = function(event) {
91923
+ _this.scheduleActiveContentInteractionSync(event);
91819
91924
  var hoverShellInteractiveId = _this.getHoverShellInteractiveIdByEvent(event);
91820
91925
  if (_this.state.hoverShellInteractiveId === hoverShellInteractiveId) {
91821
91926
  return;
@@ -91829,7 +91934,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91829
91934
  _this.syncContentInteraction(hoverShellInteractiveId);
91830
91935
  }
91831
91936
  };
91832
- this.handleContainerMouseLeave = function() {
91937
+ this.handleContainerMouseLeave = function(event) {
91938
+ if (_this.isMouseLeaveWithinContainer(event)) {
91939
+ return;
91940
+ }
91941
+ if (_this.contentInteractionFrame !== undefined) {
91942
+ cancelAnimationFrame(_this.contentInteractionFrame);
91943
+ _this.contentInteractionFrame = undefined;
91944
+ }
91945
+ _this.pendingContentInteractionEvent = undefined;
91946
+ _this.setActiveContentInteraction(undefined);
91833
91947
  var previousId = _this.state.hoverShellInteractiveId;
91834
91948
  if (!previousId) {
91835
91949
  return;
@@ -91837,6 +91951,33 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91837
91951
  _this.state.hoverShellInteractiveId = undefined;
91838
91952
  _this.syncContentInteraction(previousId);
91839
91953
  };
91954
+ this.handleContainerContextMenu = function(event) {
91955
+ var activeInteraction = _this.state.activeContentInteraction;
91956
+ if (!activeInteraction || !_this.isEventInsideOverlay(activeInteraction.id, event) || _this.isHTMLContextMenuEvent(event)) {
91957
+ return;
91958
+ }
91959
+ var canvas = _this.options.getCanvasEventTarget == null ? void 0 : _this.options.getCanvasEventTarget.call(_this.options);
91960
+ if (!canvas) {
91961
+ return;
91962
+ }
91963
+ event.preventDefault();
91964
+ event.stopPropagation();
91965
+ _this.setActiveContentInteraction(undefined);
91966
+ canvas.dispatchEvent(new MouseEvent('contextmenu', {
91967
+ bubbles: true,
91968
+ cancelable: true,
91969
+ clientX: event.clientX,
91970
+ clientY: event.clientY,
91971
+ screenX: event.screenX,
91972
+ screenY: event.screenY,
91973
+ button: event.button,
91974
+ buttons: event.buttons,
91975
+ ctrlKey: event.ctrlKey,
91976
+ shiftKey: event.shiftKey,
91977
+ altKey: event.altKey,
91978
+ metaKey: event.metaKey
91979
+ }));
91980
+ };
91840
91981
  this.isAutoHeightMessage = isCardHTMLAutoHeightMessage;
91841
91982
  }
91842
91983
  var _proto = HTMLOverlayManager.prototype;
@@ -91850,7 +91991,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91850
91991
  layer.style.position = 'absolute';
91851
91992
  layer.style.inset = '0';
91852
91993
  layer.style.pointerEvents = 'none';
91853
- layer.style.zIndex = '1';
91854
91994
  container.appendChild(layer);
91855
91995
  this.state.layer = layer;
91856
91996
  this.initDOMEvents();
@@ -91863,16 +92003,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91863
92003
  cancelAnimationFrame(this.state.updateFrame);
91864
92004
  this.state.updateFrame = undefined;
91865
92005
  }
92006
+ if (this.contentInteractionFrame !== undefined) {
92007
+ cancelAnimationFrame(this.contentInteractionFrame);
92008
+ this.contentInteractionFrame = undefined;
92009
+ }
92010
+ this.pendingContentInteractionEvent = undefined;
91866
92011
  this.state.cleanups.forEach(function(cleanup) {
91867
92012
  cleanup();
91868
92013
  });
91869
92014
  this.state.frameElements.clear();
91870
92015
  this.state.elements.clear();
92016
+ this.state.selectionElements.clear();
91871
92017
  this.state.contentScaleElements.clear();
91872
92018
  this.state.contentElements.clear();
91873
92019
  this.state.contentMountElements.clear();
92020
+ this.state.contentInteractionZones.clear();
92021
+ this.state.contentInteractionZoneCleanups.forEach(function(cleanup) {
92022
+ cleanup();
92023
+ });
92024
+ this.state.contentInteractionZoneCleanups.clear();
92025
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92026
+ cleanup();
92027
+ });
92028
+ this.state.contentInteractionResizeCleanups.clear();
91874
92029
  this.state.contents.clear();
91875
92030
  this.state.cleanups.clear();
92031
+ this.state.autoHeightModes.clear();
91876
92032
  this.state.autoHeightCleanups.forEach(function(cleanup) {
91877
92033
  cleanup();
91878
92034
  });
@@ -91887,10 +92043,12 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91887
92043
  this.eventCleanups = [];
91888
92044
  (_this_state_layer = this.state.layer) == null ? void 0 : _this_state_layer.remove();
91889
92045
  this.state.layer = undefined;
92046
+ this.state.selectionLayer = undefined;
91890
92047
  this.options.container.removeEventListener('dblclick', this.handleContainerDoubleClick, true);
91891
92048
  this.options.container.removeEventListener('mousedown', this.handleContainerMouseDown, true);
91892
92049
  this.options.container.removeEventListener('mousemove', this.handleContainerMouseMove, true);
91893
92050
  this.options.container.removeEventListener('mouseleave', this.handleContainerMouseLeave, true);
92051
+ this.options.container.removeEventListener('contextmenu', this.handleContainerContextMenu, true);
91894
92052
  };
91895
92053
  _proto.scheduleRender = function scheduleRender() {
91896
92054
  var _this = this;
@@ -91902,6 +92060,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91902
92060
  _this.render();
91903
92061
  });
91904
92062
  };
92063
+ _proto.invalidateCardHTML = function invalidateCardHTML(id) {
92064
+ this.cleanupOverlayContent(id);
92065
+ this.invalidateContentInteractionZones(id);
92066
+ };
91905
92067
  _proto.rasterizeCard = function rasterizeCard(id, options) {
91906
92068
  return _async_to_generator(function() {
91907
92069
  var contentOverlay, capture, _ref, _options_pixelRatio, image, error;
@@ -91994,6 +92156,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91994
92156
  var events = [
91995
92157
  'pageDataChange',
91996
92158
  'selectedItemChange',
92159
+ 'preSelectedItemChange',
91997
92160
  'itemPropertyChange',
91998
92161
  'viewportTransform',
91999
92162
  'viewRebuildFinish'
@@ -92003,6 +92166,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92003
92166
  if (event === 'viewportTransform') {
92004
92167
  _this.handleViewportTransform();
92005
92168
  }
92169
+ _this.invalidateContentInteractionZones();
92006
92170
  _this.scheduleRender();
92007
92171
  });
92008
92172
  });
@@ -92012,6 +92176,24 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92012
92176
  this.options.container.addEventListener('mousedown', this.handleContainerMouseDown, true);
92013
92177
  this.options.container.addEventListener('mousemove', this.handleContainerMouseMove, true);
92014
92178
  this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
92179
+ this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
92180
+ };
92181
+ _proto.isMouseLeaveWithinContainer = function isMouseLeaveWithinContainer(event) {
92182
+ var relatedTarget = event.relatedTarget;
92183
+ if (!relatedTarget) {
92184
+ return false;
92185
+ }
92186
+ try {
92187
+ return this.options.container.contains(relatedTarget);
92188
+ } catch (unused) {
92189
+ return false;
92190
+ }
92191
+ };
92192
+ _proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
92193
+ if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
92194
+ return false;
92195
+ }
92196
+ return !!event.target.closest('[data-interaction-contextmenu="self"], [data-vvfx-html-contextmenu="self"]');
92015
92197
  };
92016
92198
  _proto.handleViewportTransform = function handleViewportTransform() {
92017
92199
  var editing = this.state.editing;
@@ -92031,11 +92213,16 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92031
92213
  }
92032
92214
  var items = this.options.getItems();
92033
92215
  var frameByChildId = this.renderFrameOverlays(items, layer);
92216
+ var selectionLayer = this.getOrCreateSelectionLayer(layer);
92034
92217
  var visibleCardIds = new Set();
92035
92218
  var editingVisible = false;
92036
92219
  items.forEach(function(item) {
92037
92220
  var _this_state_editing;
92038
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92221
+ if (!isCardItem(item) || !item.visible) {
92222
+ return;
92223
+ }
92224
+ var html = _this.options.resolveCardHTML(item);
92225
+ if (html === undefined) {
92039
92226
  return;
92040
92227
  }
92041
92228
  var itemBox = _this.options.getViewBoxById(item.id);
@@ -92050,21 +92237,31 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92050
92237
  var frameBox = frameId ? _this.options.getViewBoxById(frameId) : undefined;
92051
92238
  var overlay = _this.getOrCreateOverlay(item.id, parentOverlay, elements);
92052
92239
  var contentOverlay = _this.getOrCreateContentOverlay(item.id, overlay);
92053
- var html = item.html;
92054
- if (html && _this.state.contents.get(item.id) !== html) {
92240
+ var selectionOverlay = _this.getOrCreateSelectionOverlay(item.id, selectionLayer);
92241
+ if (!_this.state.contents.has(item.id)) {
92055
92242
  _this.renderOverlayHTML(item.id, contentOverlay, html);
92056
92243
  }
92244
+ _this.applyHTMLRootConfig(overlay, html);
92057
92245
  var offsetX = frameBox && !frameBox.isEmpty() ? frameBox.min.x : 0;
92058
92246
  var offsetY = frameBox && !frameBox.isEmpty() ? frameBox.min.y : 0;
92059
- var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY);
92247
+ var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY, _this.isAutoScaleEnabled(item));
92060
92248
  overlay.style.left = boxStyle.left;
92061
92249
  overlay.style.top = boxStyle.top;
92062
92250
  overlay.style.width = boxStyle.width;
92063
92251
  overlay.style.height = boxStyle.height;
92064
92252
  overlay.style.transform = boxStyle.transform;
92065
92253
  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);
92254
+ var selectionBoxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, 0, 0, _this.isAutoScaleEnabled(item));
92255
+ selectionOverlay.style.left = selectionBoxStyle.left;
92256
+ selectionOverlay.style.top = selectionBoxStyle.top;
92257
+ selectionOverlay.style.width = selectionBoxStyle.width;
92258
+ selectionOverlay.style.height = selectionBoxStyle.height;
92259
+ selectionOverlay.style.transform = selectionBoxStyle.transform;
92260
+ selectionOverlay.style.transformOrigin = '0 0';
92261
+ _this.applyHTMLRootConfig(selectionOverlay, html);
92262
+ _this.syncOverlaySelection(item.id, overlay, selectionOverlay);
92263
+ _this.syncContentScale(item.id, boxStyle.contentWidth, boxStyle.contentHeight);
92264
+ _this.syncAutoHeight(item.id, _this.isAutoHeightEnabled(item));
92068
92265
  _this.syncContentInteraction(item.id);
92069
92266
  });
92070
92267
  elements.forEach(function(_overlay, id) {
@@ -92103,6 +92300,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92103
92300
  }
92104
92301
  }
92105
92302
  syncElementStackOrder(layer, rootElements);
92303
+ if (this.state.selectionLayer) {
92304
+ this.state.selectionLayer.style.zIndex = "" + (rootElements.length + 1);
92305
+ }
92106
92306
  this.state.frameElements.forEach(function(frameOverlay, frameId) {
92107
92307
  var frameElements = [];
92108
92308
  for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
@@ -92118,6 +92318,28 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92118
92318
  syncElementStackOrder(frameOverlay, frameElements);
92119
92319
  });
92120
92320
  };
92321
+ _proto.getOrCreateSelectionLayer = function getOrCreateSelectionLayer(layer) {
92322
+ var _layer_ownerDocument;
92323
+ if (this.state.selectionLayer) {
92324
+ if (this.state.selectionLayer.parentElement !== layer) {
92325
+ layer.appendChild(this.state.selectionLayer);
92326
+ }
92327
+ return this.state.selectionLayer;
92328
+ }
92329
+ var ownerDocument = (_layer_ownerDocument = layer.ownerDocument) != null ? _layer_ownerDocument : typeof document === 'undefined' ? undefined : document;
92330
+ if (!ownerDocument) {
92331
+ return layer;
92332
+ }
92333
+ var selectionLayer = ownerDocument.createElement('div');
92334
+ selectionLayer.className = 'vvfx-card-html-overlay-selection-layer';
92335
+ selectionLayer.style.position = 'absolute';
92336
+ selectionLayer.style.inset = '0';
92337
+ selectionLayer.style.pointerEvents = 'none';
92338
+ selectionLayer.style.zIndex = '1';
92339
+ layer.appendChild(selectionLayer);
92340
+ this.state.selectionLayer = selectionLayer;
92341
+ return selectionLayer;
92342
+ };
92121
92343
  _proto.renderFrameOverlays = function renderFrameOverlays(items, layer) {
92122
92344
  var _this = this;
92123
92345
  var visibleFrameIds = new Set();
@@ -92182,6 +92404,41 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92182
92404
  elements.set(id, overlay);
92183
92405
  return overlay;
92184
92406
  };
92407
+ _proto.getOrCreateSelectionOverlay = function getOrCreateSelectionOverlay(id, parent) {
92408
+ var selectionOverlay = this.state.selectionElements.get(id);
92409
+ if (selectionOverlay) {
92410
+ if (selectionOverlay.parentElement !== parent) {
92411
+ parent.appendChild(selectionOverlay);
92412
+ }
92413
+ return selectionOverlay;
92414
+ }
92415
+ selectionOverlay = document.createElement('div');
92416
+ selectionOverlay.className = 'vvfx-card-html-overlay-selection';
92417
+ selectionOverlay.dataset.itemId = id;
92418
+ selectionOverlay.style.position = 'absolute';
92419
+ selectionOverlay.style.pointerEvents = 'none';
92420
+ selectionOverlay.style.zIndex = '1';
92421
+ parent.appendChild(selectionOverlay);
92422
+ this.state.selectionElements.set(id, selectionOverlay);
92423
+ return selectionOverlay;
92424
+ };
92425
+ _proto.syncOverlaySelection = function syncOverlaySelection(id, overlay, selectionOverlay) {
92426
+ var isSelected = this.options.getSelectedItemIds().includes(id);
92427
+ var isPreSelected = !isSelected && this.options.getPreSelectedItemId() === id;
92428
+ overlay.dataset.selected = isSelected ? 'true' : 'false';
92429
+ overlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92430
+ selectionOverlay.dataset.selected = isSelected ? 'true' : 'false';
92431
+ selectionOverlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92432
+ selectionOverlay.style.boxShadow = isSelected ? this.getSelectionBoxShadow() : isPreSelected ? this.getPreSelectionBoxShadow() : '';
92433
+ };
92434
+ _proto.getSelectionBoxShadow = function getSelectionBoxShadow() {
92435
+ var _this_options_getSelectionEdgeStyle = this.options.getSelectionEdgeStyle(), color = _this_options_getSelectionEdgeStyle.color, alpha = _this_options_getSelectionEdgeStyle.alpha, width = _this_options_getSelectionEdgeStyle.width;
92436
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92437
+ };
92438
+ _proto.getPreSelectionBoxShadow = function getPreSelectionBoxShadow() {
92439
+ var _this_options_getPreSelectionEdgeStyle = this.options.getPreSelectionEdgeStyle(), color = _this_options_getPreSelectionEdgeStyle.color, alpha = _this_options_getPreSelectionEdgeStyle.alpha, width = _this_options_getPreSelectionEdgeStyle.width;
92440
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92441
+ };
92185
92442
  _proto.getHTMLCardIdByEvent = function getHTMLCardIdByEvent(event) {
92186
92443
  var layer = this.state.layer;
92187
92444
  if (!layer) {
@@ -92191,7 +92448,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92191
92448
  var items = this.options.getItems();
92192
92449
  for(var i = items.length - 1; i >= 0; i--){
92193
92450
  var item = items[i];
92194
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92451
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92195
92452
  continue;
92196
92453
  }
92197
92454
  var box = this.options.getViewBoxById(item.id);
@@ -92210,7 +92467,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92210
92467
  var items = this.options.getItems();
92211
92468
  for(var i = items.length - 1; i >= 0; i--){
92212
92469
  var item = items[i];
92213
- if (!isCardItem(item) || !item.visible || item.html === undefined) {
92470
+ if (!isCardItem(item) || !item.visible || this.options.resolveCardHTML(item) === undefined) {
92214
92471
  continue;
92215
92472
  }
92216
92473
  var box = this.options.getViewBoxById(item.id);
@@ -92220,13 +92477,206 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92220
92477
  var contentOverlay = this.state.contentElements.get(item.id);
92221
92478
  var interactiveElements = contentOverlay ? Array.from(contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR)) : [];
92222
92479
  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;
92480
+ return isMouseEventInsideRect(event, element.getBoundingClientRect());
92225
92481
  });
92226
92482
  return isHoveringShellInteractive ? item.id : undefined;
92227
92483
  }
92228
92484
  return undefined;
92229
92485
  };
92486
+ _proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
92487
+ var decision = this.resolveHTMLInteractionTarget(event);
92488
+ if (decision.kind === 'canvas' && this.shouldKeepActiveContentInteractionForFocusedElement()) {
92489
+ return;
92490
+ }
92491
+ this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
92492
+ };
92493
+ _proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
92494
+ var _this = this;
92495
+ if (typeof requestAnimationFrame !== 'function') {
92496
+ this.syncActiveContentInteraction(event);
92497
+ return;
92498
+ }
92499
+ this.pendingContentInteractionEvent = event;
92500
+ if (this.contentInteractionFrame !== undefined) {
92501
+ return;
92502
+ }
92503
+ this.contentInteractionFrame = requestAnimationFrame(function() {
92504
+ _this.contentInteractionFrame = undefined;
92505
+ var pendingEvent = _this.pendingContentInteractionEvent;
92506
+ _this.pendingContentInteractionEvent = undefined;
92507
+ if (pendingEvent) {
92508
+ _this.syncActiveContentInteraction(pendingEvent);
92509
+ }
92510
+ });
92511
+ };
92512
+ _proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
92513
+ var _this = this;
92514
+ var previous = this.state.activeContentInteraction;
92515
+ 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)) {
92516
+ return;
92517
+ }
92518
+ this.state.activeContentInteraction = zone;
92519
+ var changedIds = new Set();
92520
+ if (previous) {
92521
+ changedIds.add(previous.id);
92522
+ }
92523
+ if (zone) {
92524
+ changedIds.add(zone.id);
92525
+ }
92526
+ changedIds.forEach(function(id) {
92527
+ _this.syncContentInteraction(id);
92528
+ });
92529
+ };
92530
+ _proto.shouldKeepActiveContentInteractionForFocusedElement = function shouldKeepActiveContentInteractionForFocusedElement() {
92531
+ var activeInteraction = this.state.activeContentInteraction;
92532
+ if (!activeInteraction || typeof document === 'undefined') {
92533
+ return false;
92534
+ }
92535
+ var activeElement = document.activeElement;
92536
+ if (!activeElement || activeElement === document.body) {
92537
+ return false;
92538
+ }
92539
+ var interactionElement = activeInteraction.element;
92540
+ return interactionElement === activeElement || typeof interactionElement.contains === 'function' && interactionElement.contains(activeElement);
92541
+ };
92542
+ _proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
92543
+ var id = this.getHTMLCardIdByEvent(event);
92544
+ if (!id || this.isEditableCard(id)) {
92545
+ return {
92546
+ kind: 'canvas',
92547
+ id: id
92548
+ };
92549
+ }
92550
+ var contentOverlay = this.state.contentElements.get(id);
92551
+ if (!contentOverlay) {
92552
+ return {
92553
+ kind: 'canvas',
92554
+ id: id
92555
+ };
92556
+ }
92557
+ var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
92558
+ if (activeSubtree) {
92559
+ return {
92560
+ kind: 'html',
92561
+ interaction: activeSubtree
92562
+ };
92563
+ }
92564
+ var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
92565
+ return isMouseEventInsideRect(event, zone.rect);
92566
+ });
92567
+ var zone = this.resolveContentInteractionZone(matchedZones);
92568
+ if (zone) {
92569
+ return {
92570
+ kind: 'html',
92571
+ interaction: {
92572
+ id: id,
92573
+ element: zone.element,
92574
+ zone: zone.zone
92575
+ }
92576
+ };
92577
+ }
92578
+ return {
92579
+ kind: 'canvas',
92580
+ id: id
92581
+ };
92582
+ };
92583
+ _proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
92584
+ var activeInteraction = this.state.activeContentInteraction;
92585
+ if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
92586
+ return undefined;
92587
+ }
92588
+ var rect = activeInteraction.element.getBoundingClientRect();
92589
+ return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
92590
+ };
92591
+ _proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
92592
+ if (zones.length <= 1) {
92593
+ return zones[0];
92594
+ }
92595
+ var subtreeRoot = zones.find(function(candidate) {
92596
+ return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
92597
+ return zone.element !== candidate.element && candidate.element.contains(zone.element);
92598
+ });
92599
+ });
92600
+ return subtreeRoot != null ? subtreeRoot : zones[0];
92601
+ };
92602
+ _proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
92603
+ var _this = this;
92604
+ var cachedZones = this.state.contentInteractionZones.get(id);
92605
+ if (cachedZones) {
92606
+ return cachedZones;
92607
+ }
92608
+ var zones = Array.from(contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id))).filter(function(element) {
92609
+ return !_this.isContentInteractionDisabled(element);
92610
+ }).map(function(element) {
92611
+ return {
92612
+ element: element,
92613
+ rect: element.getBoundingClientRect(),
92614
+ zone: _this.getContentInteractionZoneMode(element)
92615
+ };
92616
+ });
92617
+ this.state.contentInteractionZones.set(id, zones);
92618
+ this.observeContentInteractionZoneResizes(id, zones);
92619
+ return zones;
92620
+ };
92621
+ _proto.getContentInteractiveSelector = function getContentInteractiveSelector(id) {
92622
+ var _ref;
92623
+ var _this_options_resolveCardTypeConfig_htmlInteractionSelectors, _this_options_resolveCardTypeConfig;
92624
+ var item = this.options.getItems().find(function(item) {
92625
+ return item.id === id;
92626
+ });
92627
+ if (!item) {
92628
+ return CONTENT_INTERACTIVE_SELECTOR;
92629
+ }
92630
+ 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 : [];
92631
+ if (selectors.length === 0) {
92632
+ return CONTENT_INTERACTIVE_SELECTOR;
92633
+ }
92634
+ return [].concat([
92635
+ CONTENT_INTERACTIVE_SELECTOR
92636
+ ], selectors).join(', ');
92637
+ };
92638
+ _proto.isContentInteractionDisabled = function isContentInteractionDisabled(element) {
92639
+ if (typeof element.closest !== 'function') {
92640
+ return false;
92641
+ }
92642
+ return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
92643
+ };
92644
+ _proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
92645
+ var zone = element.dataset.vvfxHtmlInteractionZone;
92646
+ return zone === 'subtree' ? 'subtree' : 'self';
92647
+ };
92648
+ _proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
92649
+ if (id) {
92650
+ var _this_state_contentInteractionResizeCleanups_get;
92651
+ this.state.contentInteractionZones.delete(id);
92652
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92653
+ this.state.contentInteractionResizeCleanups.delete(id);
92654
+ return;
92655
+ }
92656
+ this.state.contentInteractionZones.clear();
92657
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92658
+ cleanup();
92659
+ });
92660
+ this.state.contentInteractionResizeCleanups.clear();
92661
+ };
92662
+ _proto.observeContentInteractionZoneResizes = function observeContentInteractionZoneResizes(id, zones) {
92663
+ var _this = this;
92664
+ var _this_state_contentInteractionResizeCleanups_get;
92665
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92666
+ this.state.contentInteractionResizeCleanups.delete(id);
92667
+ if (zones.length === 0 || typeof ResizeObserver !== 'function') {
92668
+ return;
92669
+ }
92670
+ var observer = new ResizeObserver(function() {
92671
+ _this.invalidateContentInteractionZones(id);
92672
+ });
92673
+ zones.forEach(function(zone) {
92674
+ observer.observe(zone.element);
92675
+ });
92676
+ this.state.contentInteractionResizeCleanups.set(id, function() {
92677
+ observer.disconnect();
92678
+ });
92679
+ };
92230
92680
  _proto.getLayerPoint = function getLayerPoint(event) {
92231
92681
  var rect = this.options.container.getBoundingClientRect();
92232
92682
  return {
@@ -92283,19 +92733,35 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92283
92733
  if (!scaleOverlay || !contentOverlay || width <= 0 || height <= 0) {
92284
92734
  return;
92285
92735
  }
92286
- scaleOverlay.style.width = "" + width + "px";
92287
- scaleOverlay.style.height = "" + height + "px";
92736
+ var nextWidth = "" + width + "px";
92737
+ var nextHeight = "" + height + "px";
92738
+ var sizeChanged = scaleOverlay.style.width !== nextWidth || scaleOverlay.style.height !== nextHeight;
92739
+ scaleOverlay.style.width = nextWidth;
92740
+ scaleOverlay.style.height = nextHeight;
92288
92741
  scaleOverlay.style.transform = 'none';
92289
- contentOverlay.style.width = "" + width + "px";
92290
- contentOverlay.style.height = "" + height + "px";
92742
+ contentOverlay.style.width = nextWidth;
92743
+ contentOverlay.style.height = nextHeight;
92744
+ if (sizeChanged && this.state.autoHeightModes.get(id) === 'message') {
92745
+ this.requestAutoHeightFromIframes(id, contentOverlay);
92746
+ }
92747
+ if (sizeChanged) {
92748
+ this.invalidateContentInteractionZones(id);
92749
+ }
92750
+ };
92751
+ _proto.requestAutoHeightFromIframes = function requestAutoHeightFromIframes(id, contentOverlay) {
92752
+ contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92753
+ requestCardHTMLAutoHeight(iframe, id);
92754
+ });
92291
92755
  };
92292
92756
  _proto.syncContentInteraction = function syncContentInteraction(id) {
92293
- var _this_state_editing;
92757
+ var _this_state_editing, _this_state_activeContentInteraction;
92294
92758
  var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
92759
+ var activeInteraction = ((_this_state_activeContentInteraction = this.state.activeContentInteraction) == null ? void 0 : _this_state_activeContentInteraction.id) === id ? this.state.activeContentInteraction : undefined;
92295
92760
  var overlay = this.state.elements.get(id);
92296
92761
  var scaleOverlay = this.state.contentScaleElements.get(id);
92297
92762
  var contentOverlay = this.state.contentElements.get(id);
92298
92763
  var contentMount = this.state.contentMountElements.get(id);
92764
+ var isInteractive = isEditing || !!activeInteraction;
92299
92765
  if (overlay) {
92300
92766
  overlay.dataset.editing = isEditing ? 'true' : 'false';
92301
92767
  overlay.style.pointerEvents = 'none';
@@ -92306,34 +92772,62 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92306
92772
  }
92307
92773
  if (contentOverlay) {
92308
92774
  contentOverlay.dataset.editing = isEditing ? 'true' : 'false';
92309
- contentOverlay.style.pointerEvents = 'none';
92775
+ contentOverlay.style.pointerEvents = isInteractive ? 'auto' : 'none';
92310
92776
  contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92311
- iframe.style.pointerEvents = isEditing ? 'auto' : 'none';
92312
- iframe.tabIndex = isEditing ? 0 : -1;
92777
+ var isActiveIframe = isEditing || (activeInteraction == null ? void 0 : activeInteraction.element) === iframe;
92778
+ iframe.style.pointerEvents = isActiveIframe ? 'auto' : 'none';
92779
+ iframe.tabIndex = isActiveIframe ? 0 : -1;
92313
92780
  });
92314
- this.syncShellInteraction(id, contentOverlay, isEditing);
92781
+ this.syncShellInteraction(id, contentOverlay, isInteractive);
92782
+ this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
92315
92783
  }
92316
92784
  if (contentMount) {
92317
92785
  contentMount.dataset.editing = isEditing ? 'true' : 'false';
92318
- contentMount.style.pointerEvents = isEditing ? 'auto' : 'none';
92319
- contentMount.inert = !isEditing;
92320
- if (isEditing) {
92786
+ contentMount.style.pointerEvents = isInteractive ? 'auto' : 'none';
92787
+ contentMount.inert = !isInteractive;
92788
+ if (isInteractive) {
92321
92789
  contentMount.removeAttribute('aria-hidden');
92322
92790
  } else {
92323
92791
  contentMount.setAttribute('aria-hidden', 'true');
92324
92792
  }
92325
92793
  }
92326
92794
  };
92327
- _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isEditing) {
92795
+ _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
92796
+ var _this = this;
92797
+ var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
92798
+ contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
92799
+ if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
92800
+ _this.clearContentInteractionState(element);
92801
+ return;
92802
+ }
92803
+ if (!isInteractive) {
92804
+ _this.clearContentInteractionState(element);
92805
+ return;
92806
+ }
92807
+ if (_this.isContentInteractionDisabled(element)) {
92808
+ element.dataset.vvfxHtmlInteractionActive = 'false';
92809
+ element.style.pointerEvents = 'none';
92810
+ return;
92811
+ }
92812
+ var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
92813
+ element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
92814
+ element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
92815
+ });
92816
+ };
92817
+ _proto.clearContentInteractionState = function clearContentInteractionState(element) {
92818
+ delete element.dataset.vvfxHtmlInteractionActive;
92819
+ element.style.pointerEvents = '';
92820
+ };
92821
+ _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
92328
92822
  var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
92329
- var isShellInteractiveActive = isEditing || isHoveringShellInteractive;
92823
+ var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
92330
92824
  contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR).forEach(function(element) {
92331
92825
  element.dataset.vvfxHtmlShellInteractiveHover = isHoveringShellInteractive ? 'true' : 'false';
92332
92826
  element.dataset.vvfxHtmlShellInteractiveActive = isShellInteractiveActive ? 'true' : 'false';
92333
92827
  element.style.pointerEvents = isShellInteractiveActive ? 'auto' : 'none';
92334
92828
  });
92335
92829
  contentOverlay.querySelectorAll(EDITING_INTERACTIVE_SELECTOR).forEach(function(element) {
92336
- element.style.pointerEvents = isEditing ? 'auto' : 'none';
92830
+ element.style.pointerEvents = isInteractive ? 'auto' : 'none';
92337
92831
  });
92338
92832
  };
92339
92833
  _proto.enterEditing = function enterEditing(id) {
@@ -92341,6 +92835,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92341
92835
  if (((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id) {
92342
92836
  return;
92343
92837
  }
92838
+ if (!this.isEditableCard(id)) {
92839
+ return;
92840
+ }
92344
92841
  var box = this.options.getViewBoxById(id);
92345
92842
  if (box.isEmpty()) {
92346
92843
  return;
@@ -92384,6 +92881,13 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92384
92881
  this.options.setViewport(editing.restoreViewport);
92385
92882
  this.scheduleRender();
92386
92883
  };
92884
+ _proto.isEditableCard = function isEditableCard(id) {
92885
+ var _this_options_resolveCardTypeConfig;
92886
+ var item = this.options.getItems().find(function(item) {
92887
+ return item.id === id;
92888
+ });
92889
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.editable) !== false;
92890
+ };
92387
92891
  _proto.getEditingFitZoom = function getEditingFitZoom(box, currentZoom) {
92388
92892
  var viewportElement = this.options.container.parentElement;
92389
92893
  if (!viewportElement) {
@@ -92408,6 +92912,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92408
92912
  };
92409
92913
  _proto.renderOverlayHTML = function renderOverlayHTML(id, overlay, html) {
92410
92914
  this.cleanupOverlayContent(id);
92915
+ this.invalidateContentInteractionZones(id);
92411
92916
  overlay.innerHTML = '';
92412
92917
  var shell = mountHTMLShell(overlay, html.content, html.shell);
92413
92918
  var autoHeightMeasureElement = shell.contentContainer.isConnected ? shell.contentContainer : overlay;
@@ -92417,18 +92922,81 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92417
92922
  });
92418
92923
  var contentCleanup = this.renderOverlayContent(shell.contentContainer, html.content, {
92419
92924
  id: id,
92420
- autoHeight: isCardItem(item) && item.property.autoHeight === true
92925
+ autoHeight: this.isAutoHeightEnabled(item)
92421
92926
  });
92927
+ this.observeContentInteractionZones(id, shell.contentContainer);
92422
92928
  this.state.cleanups.set(id, function() {
92423
92929
  contentCleanup == null ? void 0 : contentCleanup();
92424
92930
  shell.cleanup == null ? void 0 : shell.cleanup.call(shell);
92425
92931
  });
92426
92932
  this.state.contents.set(id, html);
92427
92933
  };
92934
+ _proto.observeContentInteractionZones = function observeContentInteractionZones(id, contentContainer) {
92935
+ var _this = this;
92936
+ var _this_state_contentInteractionZoneCleanups_get;
92937
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
92938
+ this.state.contentInteractionZoneCleanups.delete(id);
92939
+ if (typeof MutationObserver !== 'function') {
92940
+ return;
92941
+ }
92942
+ var observer = new MutationObserver(function() {
92943
+ _this.invalidateContentInteractionZones(id);
92944
+ });
92945
+ observer.observe(contentContainer, {
92946
+ attributes: true,
92947
+ childList: true,
92948
+ subtree: true
92949
+ });
92950
+ this.state.contentInteractionZoneCleanups.set(id, function() {
92951
+ observer.disconnect();
92952
+ });
92953
+ };
92954
+ _proto.applyHTMLRootConfig = function applyHTMLRootConfig(root, html) {
92955
+ var _ref, _config_style;
92956
+ var _this_htmlRootConfigCleanups_get, _config_className;
92957
+ (_this_htmlRootConfigCleanups_get = this.htmlRootConfigCleanups.get(root)) == null ? void 0 : _this_htmlRootConfigCleanups_get();
92958
+ this.htmlRootConfigCleanups.delete(root);
92959
+ var config = html.root;
92960
+ if (!config) {
92961
+ return;
92962
+ }
92963
+ var classNames = (_ref = (_config_className = config.className) == null ? void 0 : _config_className.split(/\s+/).filter(Boolean)) != null ? _ref : [];
92964
+ var styleProperties = [];
92965
+ classNames.forEach(function(className) {
92966
+ root.classList.add(className);
92967
+ });
92968
+ Object.entries((_config_style = config.style) != null ? _config_style : {}).forEach(function(param) {
92969
+ var property = param[0], value = param[1];
92970
+ if (value === undefined) {
92971
+ return;
92972
+ }
92973
+ styleProperties.push(property);
92974
+ if (property.startsWith('--') || property.includes('-')) {
92975
+ root.style.setProperty(property, String(value));
92976
+ return;
92977
+ }
92978
+ root.style[property] = String(value);
92979
+ });
92980
+ this.htmlRootConfigCleanups.set(root, function() {
92981
+ classNames.forEach(function(className) {
92982
+ root.classList.remove(className);
92983
+ });
92984
+ styleProperties.forEach(function(property) {
92985
+ if (property.startsWith('--') || property.includes('-')) {
92986
+ root.style.removeProperty(property);
92987
+ return;
92988
+ }
92989
+ root.style[property] = '';
92990
+ });
92991
+ });
92992
+ };
92428
92993
  _proto.renderOverlayContent = function renderOverlayContent(overlay, content, options) {
92429
92994
  var _this = this;
92430
92995
  switch(content.kind){
92431
92996
  case 'inline':
92997
+ if (options == null ? void 0 : options.autoHeight) {
92998
+ this.state.autoHeightModes.set(options.id, 'message');
92999
+ }
92432
93000
  return this.chainCleanups(function() {
92433
93001
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92434
93002
  }, renderDocumentContent(overlay, {
@@ -92445,6 +93013,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92445
93013
  }));
92446
93014
  case 'dom':
92447
93015
  {
93016
+ if (options == null ? void 0 : options.autoHeight) {
93017
+ this.state.autoHeightModes.set(options.id, 'measure');
93018
+ }
92448
93019
  if (content.target === 'iframe') {
92449
93020
  return renderDOMContentInIframe(overlay, content.render, content.cleanup);
92450
93021
  }
@@ -92454,6 +93025,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92454
93025
  } : undefined;
92455
93026
  }
92456
93027
  case 'document':
93028
+ if (options == null ? void 0 : options.autoHeight) {
93029
+ this.state.autoHeightModes.set(options.id, 'message');
93030
+ }
92457
93031
  return this.chainCleanups(function() {
92458
93032
  return content.cleanup == null ? void 0 : content.cleanup.call(content, overlay);
92459
93033
  }, renderDocumentContent(overlay, content, {
@@ -92481,6 +93055,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92481
93055
  };
92482
93056
  };
92483
93057
  _proto.cleanupOverlayContent = function cleanupOverlayContent(id) {
93058
+ var _this_state_contentInteractionZoneCleanups_get;
92484
93059
  var cleanup = this.state.cleanups.get(id);
92485
93060
  if (cleanup) {
92486
93061
  cleanup();
@@ -92488,13 +93063,19 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92488
93063
  }
92489
93064
  this.state.contents.delete(id);
92490
93065
  this.state.contentMountElements.delete(id);
93066
+ this.state.autoHeightModes.delete(id);
93067
+ this.invalidateContentInteractionZones(id);
93068
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
93069
+ this.state.contentInteractionZoneCleanups.delete(id);
92491
93070
  this.cleanupAutoHeight(id);
92492
93071
  };
92493
93072
  _proto.removeOverlay = function removeOverlay(id) {
92494
- var _this_state_elements_get;
93073
+ var _this_state_elements_get, _this_state_selectionElements_get;
92495
93074
  this.cleanupOverlayContent(id);
92496
93075
  (_this_state_elements_get = this.state.elements.get(id)) == null ? void 0 : _this_state_elements_get.remove();
93076
+ (_this_state_selectionElements_get = this.state.selectionElements.get(id)) == null ? void 0 : _this_state_selectionElements_get.remove();
92497
93077
  this.state.elements.delete(id);
93078
+ this.state.selectionElements.delete(id);
92498
93079
  this.state.contentScaleElements.delete(id);
92499
93080
  this.state.contentElements.delete(id);
92500
93081
  };
@@ -92503,11 +93084,27 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92503
93084
  this.cleanupAutoHeight(id);
92504
93085
  return;
92505
93086
  }
93087
+ this.ensureAutoHeightMode(id);
93088
+ if (this.state.autoHeightModes.get(id) === 'message') {
93089
+ this.cleanupAutoHeight(id);
93090
+ return;
93091
+ }
92506
93092
  if (!this.state.autoHeightCleanups.has(id)) {
92507
93093
  this.state.autoHeightCleanups.set(id, this.createAutoHeightObserver(id));
92508
93094
  }
92509
93095
  this.scheduleAutoHeightMeasure(id);
92510
93096
  };
93097
+ _proto.ensureAutoHeightMode = function ensureAutoHeightMode(id) {
93098
+ var _this_state_contents_get;
93099
+ if (this.state.autoHeightModes.has(id)) {
93100
+ return;
93101
+ }
93102
+ var content = (_this_state_contents_get = this.state.contents.get(id)) == null ? void 0 : _this_state_contents_get.content;
93103
+ if (!content) {
93104
+ return;
93105
+ }
93106
+ this.state.autoHeightModes.set(id, content.kind === 'inline' || content.kind === 'document' ? 'message' : 'measure');
93107
+ };
92511
93108
  _proto.createAutoHeightObserver = function createAutoHeightObserver(id) {
92512
93109
  var _this = this;
92513
93110
  var cleanupFns = [];
@@ -92595,7 +93192,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92595
93192
  var item = this.options.getItems().find(function(candidate) {
92596
93193
  return candidate.id === id;
92597
93194
  });
92598
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93195
+ if (!this.isAutoHeightEnabled(item)) {
92599
93196
  this.cleanupAutoHeight(id);
92600
93197
  return;
92601
93198
  }
@@ -92614,7 +93211,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92614
93211
  }).filter(function(height) {
92615
93212
  return typeof height === 'number' && Number.isFinite(height) && height > 0;
92616
93213
  });
92617
- var childHeight = this.getChildrenNaturalHeight(element);
93214
+ var childHeight = this.getChildrenNaturalHeight(element, {
93215
+ includeIframes: iframeHeights.length === 0
93216
+ });
92618
93217
  var naturalHeight = (_Math = Math).max.apply(_Math, [].concat([
92619
93218
  childHeight
92620
93219
  ], iframeHeights));
@@ -92634,10 +93233,29 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92634
93233
  }
92635
93234
  return Math.max(documentElement.scrollHeight, (_ref = body == null ? void 0 : body.scrollHeight) != null ? _ref : 0);
92636
93235
  };
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);
93236
+ _proto.getChildrenNaturalHeight = function getChildrenNaturalHeight(element, options) {
93237
+ var _ref;
93238
+ var includeIframes = (_ref = options == null ? void 0 : options.includeIframes) != null ? _ref : true;
93239
+ return Array.from(element.childNodes).reduce(function(height, child) {
93240
+ var _child_textContent;
93241
+ if (child.nodeType === Node.ELEMENT_NODE) {
93242
+ var childElement = child;
93243
+ if (!includeIframes && childElement.tagName === 'IFRAME') {
93244
+ return height;
93245
+ }
93246
+ return Math.max(height, childElement.offsetTop + childElement.offsetHeight);
93247
+ }
93248
+ if (child.nodeType === Node.TEXT_NODE && ((_child_textContent = child.textContent) == null ? void 0 : _child_textContent.trim())) {
93249
+ var range = element.ownerDocument.createRange();
93250
+ range.selectNodeContents(child);
93251
+ var rects = Array.from(range.getClientRects());
93252
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
93253
+ range.detach();
93254
+ return rects.reduce(function(textHeight, rect) {
93255
+ return Math.max(textHeight, rect.bottom - element.getBoundingClientRect().top);
93256
+ }, height);
93257
+ }
93258
+ return height;
92641
93259
  }, 0);
92642
93260
  };
92643
93261
  _proto.cleanupAutoHeight = function cleanupAutoHeight(id) {
@@ -92656,14 +93274,48 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92656
93274
  var item = this.options.getItems().find(function(candidate) {
92657
93275
  return candidate.id === id;
92658
93276
  });
92659
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93277
+ if (!isCardItem(item) || !this.isAutoHeightEnabled(item)) {
92660
93278
  return;
92661
93279
  }
92662
- if (!Number.isFinite(height) || height <= 0 || Math.abs(height - item.property.height) <= AUTO_HEIGHT_EPSILON) {
93280
+ if (!Number.isFinite(height) || height <= 0) {
92663
93281
  return;
92664
93282
  }
92665
- this.options.setCardItemHeight(id, Math.ceil(height));
93283
+ var nextHeight = Math.ceil(this.getAutoHeightItemHeight(item, height));
93284
+ if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
93285
+ return;
93286
+ }
93287
+ this.options.setCardItemHeight(id, nextHeight);
93288
+ };
93289
+ _proto.getAutoHeightItemHeight = function getAutoHeightItemHeight(item, contentHeight) {
93290
+ if (!isCardItem(item) || this.isAutoScaleEnabled(item)) {
93291
+ return contentHeight;
93292
+ }
93293
+ var scaleOverlay = this.state.contentScaleElements.get(item.id);
93294
+ var displayedHeight = scaleOverlay ? Number.parseFloat(scaleOverlay.style.height) : 0;
93295
+ if (!Number.isFinite(displayedHeight) || displayedHeight <= 0 || item.property.height <= 0) {
93296
+ return contentHeight;
93297
+ }
93298
+ return contentHeight / displayedHeight * item.property.height;
93299
+ };
93300
+ _proto.isAutoHeightEnabled = function isAutoHeightEnabled(item) {
93301
+ var _this_options_resolveCardTypeConfig;
93302
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeight) === true;
93303
+ };
93304
+ _proto.isAutoScaleEnabled = function isAutoScaleEnabled(item) {
93305
+ var _this_options_resolveCardTypeConfig;
93306
+ if (!isCardItem(item)) {
93307
+ return true;
93308
+ }
93309
+ return ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoScale) !== false;
92666
93310
  };
93311
+ _create_class(HTMLOverlayManager, [
93312
+ {
93313
+ key: "layerElement",
93314
+ get: function get() {
93315
+ return this.state.layer;
93316
+ }
93317
+ }
93318
+ ]);
92667
93319
  return HTMLOverlayManager;
92668
93320
  }();
92669
93321
  function waitForCardCaptureReady(root) {
@@ -92705,6 +93357,17 @@ function waitForCardCaptureReady(root) {
92705
93357
  });
92706
93358
  })();
92707
93359
  }
93360
+ function formatCssColor(color, alpha) {
93361
+ var normalizedColor = Math.max(0, Math.min(0xFFFFFF, Math.round(color)));
93362
+ var red = normalizedColor >> 16 & 0xFF;
93363
+ var green = normalizedColor >> 8 & 0xFF;
93364
+ var blue = normalizedColor & 0xFF;
93365
+ return "rgba(" + red + ", " + green + ", " + blue + ", " + formatCssNumber(alpha) + ")";
93366
+ }
93367
+ function formatCssNumber(value) {
93368
+ var normalized = Number.isFinite(value) ? value : 0;
93369
+ return Number(normalized.toFixed(6)).toString();
93370
+ }
92708
93371
  function nextAnimationFrame() {
92709
93372
  return new Promise(function(resolve) {
92710
93373
  requestAnimationFrame(function() {
@@ -93123,6 +93786,9 @@ function createFlattenedContent(target, frameStyle, ownerDocument) {
93123
93786
  });
93124
93787
  return replacement;
93125
93788
  }
93789
+ function isMouseEventInsideRect(event, rect) {
93790
+ return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
93791
+ }
93126
93792
  function createFlattenedIframeContent(iframe) {
93127
93793
  var doc = iframe.contentDocument;
93128
93794
  if (!doc) {
@@ -93162,6 +93828,19 @@ function withTimeout(promise, timeout) {
93162
93828
  });
93163
93829
  }
93164
93830
 
93831
+ function orderSDKCanvasLayers(param) {
93832
+ var container = param.container, playerContainer = param.playerContainer, htmlOverlayLayer = param.htmlOverlayLayer, gestureCanvas = param.gestureCanvas;
93833
+ [
93834
+ playerContainer,
93835
+ htmlOverlayLayer,
93836
+ gestureCanvas
93837
+ ].forEach(function(layer) {
93838
+ if ((layer == null ? void 0 : layer.parentElement) === container) {
93839
+ container.appendChild(layer);
93840
+ }
93841
+ });
93842
+ }
93843
+
93165
93844
  var HTML_CARD_EDITING_VIEWPORT_PADDING = 48;
93166
93845
  var SDK = /*#__PURE__*/ function() {
93167
93846
  function SDK(container, mode) {
@@ -93267,9 +93946,45 @@ var SDK = /*#__PURE__*/ function() {
93267
93946
  propertyName: 'height',
93268
93947
  propertyValue: height
93269
93948
  });
93949
+ },
93950
+ getSelectedItemIds: function getSelectedItemIds() {
93951
+ var _ref;
93952
+ var _this__pageData;
93953
+ return (_ref = (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.selectedItems) != null ? _ref : [];
93954
+ },
93955
+ getPreSelectedItemId: function getPreSelectedItemId() {
93956
+ var _this__pageData;
93957
+ return (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.preSelectedItem;
93958
+ },
93959
+ getSelectionEdgeStyle: function getSelectionEdgeStyle() {
93960
+ 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;
93961
+ return {
93962
+ color: wireframeColor,
93963
+ alpha: wireframeAlpha,
93964
+ width: wireframeWidth
93965
+ };
93966
+ },
93967
+ getPreSelectionEdgeStyle: function getPreSelectionEdgeStyle() {
93968
+ var _SDK_config_gestureHandlerConfig_selectorGizmoConfig = SDK.config.gestureHandlerConfig.selectorGizmoConfig, preSelectedColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedColor, preSelectedWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedWidth;
93969
+ return {
93970
+ color: preSelectedColor,
93971
+ alpha: 1,
93972
+ width: preSelectedWidth
93973
+ };
93974
+ },
93975
+ getCanvasEventTarget: function getCanvasEventTarget() {
93976
+ var _this__gestureHandler;
93977
+ return (_this__gestureHandler = _this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view;
93978
+ },
93979
+ resolveCardHTML: function resolveCardHTML(item) {
93980
+ return isCardItem(item) ? _this.resolveCardHTML(item) : undefined;
93981
+ },
93982
+ resolveCardTypeConfig: function resolveCardTypeConfig(item) {
93983
+ return isCardItem(item) ? _this.resolveCardTypeConfig(item) : undefined;
93270
93984
  }
93271
93985
  });
93272
93986
  this._htmlOverlayManager.attach();
93987
+ this.syncCanvasLayerOrder();
93273
93988
  }
93274
93989
  var _proto = SDK.prototype;
93275
93990
  _proto.dispose = function dispose() {
@@ -93365,6 +94080,7 @@ var SDK = /*#__PURE__*/ function() {
93365
94080
  this.initPlayer(SDK.config.mode);
93366
94081
  this._pageDataUtils = new PageDataUtils(this.player, this._playerContainer, this._eventEmitter, this);
93367
94082
  this._gestureHandler = new GestureHandler(this._container);
94083
+ this.syncCanvasLayerOrder();
93368
94084
  return [
93369
94085
  4,
93370
94086
  this.runByPageData(this.pageData)
@@ -93414,6 +94130,16 @@ var SDK = /*#__PURE__*/ function() {
93414
94130
  env: 'editor'
93415
94131
  });
93416
94132
  this.player.resize();
94133
+ this.syncCanvasLayerOrder();
94134
+ };
94135
+ _proto.syncCanvasLayerOrder = function syncCanvasLayerOrder() {
94136
+ var _this__htmlOverlayManager, _this__gestureHandler;
94137
+ orderSDKCanvasLayers({
94138
+ container: this._container,
94139
+ playerContainer: this._playerContainer,
94140
+ htmlOverlayLayer: (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.layerElement,
94141
+ gestureCanvas: (_this__gestureHandler = this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view
94142
+ });
93417
94143
  };
93418
94144
  _proto.getInitParam = function getInitParam(param) {
93419
94145
  return _async_to_generator(function() {
@@ -94508,8 +95234,7 @@ var SDK = /*#__PURE__*/ function() {
94508
95234
  * @param ignoreClamp 是否忽视约束
94509
95235
  */ _proto.setPageZoom = function setPageZoom(zoom, center, ignoreClamp) {
94510
95236
  assertExist$1(this._pageData);
94511
- this._pageData.property.zoom = zoom;
94512
- this._pageDataUtils.setPageZoom(this._pageData.property.zoom, center, ignoreClamp);
95237
+ this._pageDataUtils.setPageZoom(zoom, center, ignoreClamp);
94513
95238
  this._gestureHandler.render();
94514
95239
  };
94515
95240
  /**
@@ -95405,6 +96130,44 @@ var SDK = /*#__PURE__*/ function() {
95405
96130
  });
95406
96131
  };
95407
96132
  /**
96133
+ * @description 按 cardType 从注册表解析卡片的 HTML 渲染配置。
96134
+ * @param item 卡片元素
96135
+ * @returns HTML 渲染配置
96136
+ */ _proto.resolveCardHTML = function resolveCardHTML(item) {
96137
+ var _cardTypeConfig_html;
96138
+ var cardTypeConfig = this.resolveCardTypeConfig(item);
96139
+ return cardTypeConfig == null ? void 0 : (_cardTypeConfig_html = cardTypeConfig.html) == null ? void 0 : _cardTypeConfig_html.call(cardTypeConfig, item);
96140
+ };
96141
+ /**
96142
+ * @description 按 cardType 从注册表解析卡片类型配置。
96143
+ * @param item 卡片元素
96144
+ * @returns 卡片类型配置
96145
+ */ _proto.resolveCardTypeConfig = function resolveCardTypeConfig(item) {
96146
+ return SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96147
+ return t.type === item.cardType;
96148
+ });
96149
+ };
96150
+ /**
96151
+ * @description 重新解析并挂载指定卡片的 HTML 内容。
96152
+ * @description 当 inline/document 内容依赖 extension 或外部状态变化时,可调用此方法刷新 DOM。
96153
+ * @param id 卡片元素 ID
96154
+ * @returns 是否成功触发刷新
96155
+ */ _proto.refreshCardHTML = function refreshCardHTML(id) {
96156
+ var _this__htmlOverlayManager, _this__htmlOverlayManager1;
96157
+ var item = this.getSDKItem(id);
96158
+ if (!isCardItem(item)) {
96159
+ console.warn('CardItem "' + id + '" not found.');
96160
+ return false;
96161
+ }
96162
+ if (!this.resolveCardHTML(item)) {
96163
+ console.warn('CardItem "' + id + '" has no registered HTML renderer.');
96164
+ return false;
96165
+ }
96166
+ (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.invalidateCardHTML(id);
96167
+ (_this__htmlOverlayManager1 = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager1.scheduleRender();
96168
+ return true;
96169
+ };
96170
+ /**
95408
96171
  * @description 创建卡片元素
95409
96172
  * @description 底层以透明 SpriteItem 形式渲染,支持 cardType 属性
95410
96173
  * @param createInfo 卡片创建信息
@@ -95699,8 +96462,8 @@ SDK.config = BaseConfig;
95699
96462
  _inherits(CardItem, BaseItem);
95700
96463
  function CardItem(options) {
95701
96464
  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;
96465
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
96466
+ var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5;
95704
96467
  _this = BaseItem.call(this, options) || this, /**
95705
96468
  * @description 元素类型
95706
96469
  */ _this.type = SDKItemType.CARD;
@@ -95721,9 +96484,7 @@ SDK.config = BaseConfig;
95721
96484
  1,
95722
96485
  1
95723
96486
  ],
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
96487
+ cardType: (_ref5 = (_options_property5 = options.property) == null ? void 0 : _options_property5.cardType) != null ? _ref5 : 'unknown'
95727
96488
  };
95728
96489
  return _this;
95729
96490
  }
@@ -95734,22 +96495,18 @@ SDK.config = BaseConfig;
95734
96495
  * @param withParent 是否包含父节点ID
95735
96496
  */ _proto.toCreateInfo = function toCreateInfo(withParent) {
95736
96497
  var extension = this.getAllExtension();
95737
- var property = deepClone(this.property);
95738
- property.html = this.html;
95739
96498
  return {
95740
96499
  type: SDKItemType.CARD,
95741
96500
  id: this.id,
95742
96501
  name: this.name,
95743
96502
  parentId: withParent ? this.parentId : undefined,
95744
96503
  extension: Object.keys(extension).length > 0 ? extension : undefined,
95745
- property: property
96504
+ property: deepClone(this.property)
95746
96505
  };
95747
96506
  };
95748
96507
  /**
95749
96508
  * @description 克隆 SDKItem
95750
96509
  */ _proto.clone = function clone() {
95751
- var property = deepClone(this.property);
95752
- property.html = this.html;
95753
96510
  return new CardItem({
95754
96511
  id: generateGUID(),
95755
96512
  name: this.name,
@@ -95759,7 +96516,7 @@ SDK.config = BaseConfig;
95759
96516
  endBehavior: this.endBehavior,
95760
96517
  isLocked: this.isLocked,
95761
96518
  isCoreEditable: this.isCoreEditable,
95762
- property: property,
96519
+ property: deepClone(this.property),
95763
96520
  extension: this.getAllExtension()
95764
96521
  });
95765
96522
  };
@@ -95776,17 +96533,6 @@ SDK.config = BaseConfig;
95776
96533
  this.property.cardType = value;
95777
96534
  }
95778
96535
  },
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
96536
  {
95791
96537
  key: "position",
95792
96538
  get: // ==================== 便捷访问器 ====================
@@ -95799,6 +96545,16 @@ SDK.config = BaseConfig;
95799
96545
  this.property.position = value;
95800
96546
  }
95801
96547
  },
96548
+ {
96549
+ key: "isAutoScale",
96550
+ get: function get() {
96551
+ var _this = this;
96552
+ var config = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96553
+ return t.type === _this.cardType;
96554
+ });
96555
+ return (config == null ? void 0 : config.autoScale) !== false;
96556
+ }
96557
+ },
95802
96558
  {
95803
96559
  key: "width",
95804
96560
  get: /**