@vvfx/sdk 0.2.2-beta.3 → 0.2.2-beta.5

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.
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  * Description: TODO
4
4
  * Author: Ant Group CO., Ltd.
5
5
  * Contributors: 赤芍,何即,不择,意绮
6
- * Version: v0.2.2-beta.3
6
+ * Version: v0.2.2-beta.5
7
7
  */
8
8
 
9
9
  'use strict';
@@ -25181,7 +25181,7 @@ var ItemOrderAction = /*#__PURE__*/ function(ItemOrderAction) {
25181
25181
  function CardItem(options) {
25182
25182
  var _this;
25183
25183
  var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
25184
- var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5, _options_property6, _options_property7;
25184
+ var _options_property, _options_property1, _options_property2, _options_property3, _options_property4, _options_property5;
25185
25185
  _this = BaseItem.call(this, options) || this, /**
25186
25186
  * @description 元素类型
25187
25187
  */ _this.type = SDKItemType.CARD;
@@ -25202,9 +25202,7 @@ var ItemOrderAction = /*#__PURE__*/ function(ItemOrderAction) {
25202
25202
  1,
25203
25203
  1
25204
25204
  ],
25205
- cardType: (_ref5 = (_options_property5 = options.property) == null ? void 0 : _options_property5.cardType) != null ? _ref5 : 'unknown',
25206
- autoHeight: (_options_property6 = options.property) == null ? void 0 : _options_property6.autoHeight,
25207
- autoScale: (_options_property7 = options.property) == null ? void 0 : _options_property7.autoScale
25205
+ cardType: (_ref5 = (_options_property5 = options.property) == null ? void 0 : _options_property5.cardType) != null ? _ref5 : 'unknown'
25208
25206
  };
25209
25207
  return _this;
25210
25208
  }
@@ -47319,7 +47317,7 @@ var SelectorGizmo = /*#__PURE__*/ function(Gizmo) {
47319
47317
  var preSelectedItem = this.pageDataUtils.getPreSelectedItem();
47320
47318
  var preSelectedItemBox = this.pageDataUtils.getViewBoxById((_ref = preSelectedItem == null ? void 0 : preSelectedItem.id) != null ? _ref : '');
47321
47319
  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;
47322
- if (!(preSelectedItemBox == null ? void 0 : preSelectedItemBox.isEmpty())) {
47320
+ if (!(preSelectedItemBox == null ? void 0 : preSelectedItemBox.isEmpty()) && !isCardItem(preSelectedItem)) {
47323
47321
  this.graphics.lineStyle(preSelectedWidth, preSelectedColor);
47324
47322
  this.graphics.drawBox(preSelectedItemBox);
47325
47323
  }
@@ -55903,6 +55901,7 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55903
55901
  var selectedItems = this._pageDataUtils.getSelectedItems();
55904
55902
  var isTemplateMode = SDK.config.mode === 'template';
55905
55903
  var selectedItem = selectedItems.length === 1 ? selectedItems[0] : undefined;
55904
+ var isSingleCardItem = isCardItem(selectedItem);
55906
55905
  var isGeneratorItem = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.GENERATOR;
55907
55906
  var isAutoLayoutFrame = (selectedItem == null ? void 0 : selectedItem.type) === SDKItemType.FRAME && (selectedItem == null ? void 0 : selectedItem.layoutMode) === FrameLayoutMode.AUTO;
55908
55907
  var canScale = selectedItems.length === 1 && (selectedItem == null ? void 0 : selectedItem.type) !== SDKItemType.GROUP && !isAutoLayoutFrame && !isGeneratorItem;
@@ -55942,9 +55941,11 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55942
55941
  this.wireframe.totalBox.copyFrom(box).expandByScalar(totalBoxExpandScalar);
55943
55942
  // 根据box获取边缘线
55944
55943
  var corners = this.wireframe.box.corners;
55945
- corners.forEach(function(corner, i) {
55946
- _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55947
- });
55944
+ if (!isSingleCardItem) {
55945
+ corners.forEach(function(corner, i) {
55946
+ _this.wireframe.edges.push(new Line2(new Vector2().copyFrom(corner), new Vector2().copyFrom(corners[(i + 1) % 4])));
55947
+ });
55948
+ }
55948
55949
  var _SDK_config_gestureHandlerConfig_transformGizmoConfig = SDK.config.gestureHandlerConfig.transformGizmoConfig, scaleCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.scaleCircleSize, rotationCircleSize = _SDK_config_gestureHandlerConfig_transformGizmoConfig.rotationCircleSize;
55949
55950
  // 成组暂不支持缩放
55950
55951
  if (selectedItems.length === 1) {
@@ -63184,12 +63185,15 @@ var PageDataUtils = /*#__PURE__*/ function() {
63184
63185
  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 ? [
63185
63186
  1,
63186
63187
  1
63187
- ] : _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, autoScale = _cardInfo_property.autoScale, parentId = cardInfo.parentId, _cardInfo_id = cardInfo.id, id = _cardInfo_id === void 0 ? EFFECTS.generateGUID() : _cardInfo_id, extension = cardInfo.extension;
63188
+ ] : _cardInfo_property_scale, cardType = _cardInfo_property.cardType, tmp = _cardInfo_property.rotation, sourceRotation = tmp === void 0 ? 0 : tmp, sourcePosition = _cardInfo_property.position, parentId = cardInfo.parentId, _cardInfo_id = cardInfo.id, id = _cardInfo_id === void 0 ? EFFECTS.generateGUID() : _cardInfo_id, extension = cardInfo.extension;
63188
63189
  // 校验 cardType 是否已在配置中注册
63190
+ var cardTypeConfig = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
63191
+ return t.type === cardType;
63192
+ });
63189
63193
  var registeredTypes = SDK.config.itemConfig.cardConfig.cardTypes.map(function(t) {
63190
63194
  return t.type;
63191
63195
  });
63192
- if (!registeredTypes.includes(cardType)) {
63196
+ if (!cardTypeConfig) {
63193
63197
  console.warn('CardItem cardType "' + cardType + '" is not registered. Registered types: ' + registeredTypes.join(', '));
63194
63198
  return;
63195
63199
  }
@@ -63233,9 +63237,7 @@ var PageDataUtils = /*#__PURE__*/ function() {
63233
63237
  width: width,
63234
63238
  height: height,
63235
63239
  scale: [].concat(scale),
63236
- cardType: cardType,
63237
- autoHeight: autoHeight,
63238
- autoScale: autoScale
63240
+ cardType: cardType
63239
63241
  },
63240
63242
  extension: extension
63241
63243
  });
@@ -83223,10 +83225,10 @@ var BaseConfig = {
83223
83225
  },
83224
83226
  cardConfig: {
83225
83227
  backgroundColor: [
83226
- 0.6,
83227
- 0.6,
83228
- 0.6,
83229
- 0.12
83228
+ 1,
83229
+ 1,
83230
+ 1,
83231
+ 0
83230
83232
  ],
83231
83233
  cardTypes: []
83232
83234
  }
@@ -91920,6 +91922,27 @@ function mountHTMLShell(container, content, shell) {
91920
91922
 
91921
91923
  var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
91922
91924
  var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
91925
+ var CONTENT_INTERACTIVE_SELECTOR = [
91926
+ '[data-interaction-zone="self"]',
91927
+ '[data-vvfx-html-interaction-zone="self"]',
91928
+ 'a[href]',
91929
+ 'button:not([disabled])',
91930
+ 'input:not([disabled])',
91931
+ 'textarea:not([disabled])',
91932
+ 'select:not([disabled])',
91933
+ 'summary',
91934
+ 'video[controls]',
91935
+ 'audio[controls]',
91936
+ '[contenteditable]:not([contenteditable="false"])',
91937
+ '[role="button"]',
91938
+ '[role="link"]',
91939
+ '[role="textbox"]',
91940
+ '[tabindex]:not([tabindex="-1"])'
91941
+ ].join(', ');
91942
+ var CONTENT_INTERACTION_NONE_SELECTOR = [
91943
+ '[data-interaction-zone="none"]',
91944
+ '[data-vvfx-html-interaction-zone="none"]'
91945
+ ].join(', ');
91923
91946
  var EDITING_VIEWPORT_PADDING = 48;
91924
91947
  var EDITING_VIEWPORT_BOX_SCALE = 1.1;
91925
91948
  var AUTO_HEIGHT_EPSILON = 0.5;
@@ -91929,12 +91952,17 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91929
91952
  var _this = this;
91930
91953
  this.options = options;
91931
91954
  this.eventCleanups = [];
91955
+ this.htmlRootConfigCleanups = new WeakMap();
91932
91956
  this.state = {
91933
91957
  frameElements: new Map(),
91934
91958
  elements: new Map(),
91959
+ selectionElements: new Map(),
91935
91960
  contentScaleElements: new Map(),
91936
91961
  contentElements: new Map(),
91937
91962
  contentMountElements: new Map(),
91963
+ contentInteractionZones: new Map(),
91964
+ contentInteractionZoneCleanups: new Map(),
91965
+ contentInteractionResizeCleanups: new Map(),
91938
91966
  contents: new Map(),
91939
91967
  cleanups: new Map(),
91940
91968
  autoHeightModes: new Map(),
@@ -91954,6 +91982,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91954
91982
  }
91955
91983
  return;
91956
91984
  }
91985
+ if (!_this.isEditableCard(targetId)) {
91986
+ return;
91987
+ }
91957
91988
  event.preventDefault();
91958
91989
  event.stopPropagation();
91959
91990
  _this.enterEditing(targetId);
@@ -91969,6 +92000,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91969
92000
  _this.exitEditing();
91970
92001
  };
91971
92002
  this.handleContainerMouseMove = function(event) {
92003
+ _this.scheduleActiveContentInteractionSync(event);
91972
92004
  var hoverShellInteractiveId = _this.getHoverShellInteractiveIdByEvent(event);
91973
92005
  if (_this.state.hoverShellInteractiveId === hoverShellInteractiveId) {
91974
92006
  return;
@@ -91983,6 +92015,12 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91983
92015
  }
91984
92016
  };
91985
92017
  this.handleContainerMouseLeave = function() {
92018
+ if (_this.contentInteractionFrame !== undefined) {
92019
+ cancelAnimationFrame(_this.contentInteractionFrame);
92020
+ _this.contentInteractionFrame = undefined;
92021
+ }
92022
+ _this.pendingContentInteractionEvent = undefined;
92023
+ _this.setActiveContentInteraction(undefined);
91986
92024
  var previousId = _this.state.hoverShellInteractiveId;
91987
92025
  if (!previousId) {
91988
92026
  return;
@@ -91990,6 +92028,33 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
91990
92028
  _this.state.hoverShellInteractiveId = undefined;
91991
92029
  _this.syncContentInteraction(previousId);
91992
92030
  };
92031
+ this.handleContainerContextMenu = function(event) {
92032
+ var activeInteraction = _this.state.activeContentInteraction;
92033
+ if (!activeInteraction || !_this.isEventInsideOverlay(activeInteraction.id, event) || _this.isHTMLContextMenuEvent(event)) {
92034
+ return;
92035
+ }
92036
+ var canvas = _this.options.getCanvasEventTarget == null ? void 0 : _this.options.getCanvasEventTarget.call(_this.options);
92037
+ if (!canvas) {
92038
+ return;
92039
+ }
92040
+ event.preventDefault();
92041
+ event.stopPropagation();
92042
+ _this.setActiveContentInteraction(undefined);
92043
+ canvas.dispatchEvent(new MouseEvent('contextmenu', {
92044
+ bubbles: true,
92045
+ cancelable: true,
92046
+ clientX: event.clientX,
92047
+ clientY: event.clientY,
92048
+ screenX: event.screenX,
92049
+ screenY: event.screenY,
92050
+ button: event.button,
92051
+ buttons: event.buttons,
92052
+ ctrlKey: event.ctrlKey,
92053
+ shiftKey: event.shiftKey,
92054
+ altKey: event.altKey,
92055
+ metaKey: event.metaKey
92056
+ }));
92057
+ };
91993
92058
  this.isAutoHeightMessage = isCardHTMLAutoHeightMessage;
91994
92059
  }
91995
92060
  var _proto = HTMLOverlayManager.prototype;
@@ -92003,7 +92068,6 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92003
92068
  layer.style.position = 'absolute';
92004
92069
  layer.style.inset = '0';
92005
92070
  layer.style.pointerEvents = 'none';
92006
- layer.style.zIndex = '1';
92007
92071
  container.appendChild(layer);
92008
92072
  this.state.layer = layer;
92009
92073
  this.initDOMEvents();
@@ -92016,14 +92080,29 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92016
92080
  cancelAnimationFrame(this.state.updateFrame);
92017
92081
  this.state.updateFrame = undefined;
92018
92082
  }
92083
+ if (this.contentInteractionFrame !== undefined) {
92084
+ cancelAnimationFrame(this.contentInteractionFrame);
92085
+ this.contentInteractionFrame = undefined;
92086
+ }
92087
+ this.pendingContentInteractionEvent = undefined;
92019
92088
  this.state.cleanups.forEach(function(cleanup) {
92020
92089
  cleanup();
92021
92090
  });
92022
92091
  this.state.frameElements.clear();
92023
92092
  this.state.elements.clear();
92093
+ this.state.selectionElements.clear();
92024
92094
  this.state.contentScaleElements.clear();
92025
92095
  this.state.contentElements.clear();
92026
92096
  this.state.contentMountElements.clear();
92097
+ this.state.contentInteractionZones.clear();
92098
+ this.state.contentInteractionZoneCleanups.forEach(function(cleanup) {
92099
+ cleanup();
92100
+ });
92101
+ this.state.contentInteractionZoneCleanups.clear();
92102
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92103
+ cleanup();
92104
+ });
92105
+ this.state.contentInteractionResizeCleanups.clear();
92027
92106
  this.state.contents.clear();
92028
92107
  this.state.cleanups.clear();
92029
92108
  this.state.autoHeightModes.clear();
@@ -92041,10 +92120,12 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92041
92120
  this.eventCleanups = [];
92042
92121
  (_this_state_layer = this.state.layer) == null ? void 0 : _this_state_layer.remove();
92043
92122
  this.state.layer = undefined;
92123
+ this.state.selectionLayer = undefined;
92044
92124
  this.options.container.removeEventListener('dblclick', this.handleContainerDoubleClick, true);
92045
92125
  this.options.container.removeEventListener('mousedown', this.handleContainerMouseDown, true);
92046
92126
  this.options.container.removeEventListener('mousemove', this.handleContainerMouseMove, true);
92047
92127
  this.options.container.removeEventListener('mouseleave', this.handleContainerMouseLeave, true);
92128
+ this.options.container.removeEventListener('contextmenu', this.handleContainerContextMenu, true);
92048
92129
  };
92049
92130
  _proto.scheduleRender = function scheduleRender() {
92050
92131
  var _this = this;
@@ -92056,6 +92137,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92056
92137
  _this.render();
92057
92138
  });
92058
92139
  };
92140
+ _proto.invalidateCardHTML = function invalidateCardHTML(id) {
92141
+ this.cleanupOverlayContent(id);
92142
+ this.invalidateContentInteractionZones(id);
92143
+ };
92059
92144
  _proto.rasterizeCard = function rasterizeCard(id, options) {
92060
92145
  return _async_to_generator(function() {
92061
92146
  var contentOverlay, capture, _ref, _options_pixelRatio, image, error;
@@ -92148,6 +92233,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92148
92233
  var events = [
92149
92234
  'pageDataChange',
92150
92235
  'selectedItemChange',
92236
+ 'preSelectedItemChange',
92151
92237
  'itemPropertyChange',
92152
92238
  'viewportTransform',
92153
92239
  'viewRebuildFinish'
@@ -92157,6 +92243,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92157
92243
  if (event === 'viewportTransform') {
92158
92244
  _this.handleViewportTransform();
92159
92245
  }
92246
+ _this.invalidateContentInteractionZones();
92160
92247
  _this.scheduleRender();
92161
92248
  });
92162
92249
  });
@@ -92166,6 +92253,13 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92166
92253
  this.options.container.addEventListener('mousedown', this.handleContainerMouseDown, true);
92167
92254
  this.options.container.addEventListener('mousemove', this.handleContainerMouseMove, true);
92168
92255
  this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
92256
+ this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
92257
+ };
92258
+ _proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
92259
+ if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
92260
+ return false;
92261
+ }
92262
+ return !!event.target.closest('[data-interaction-contextmenu="self"], [data-vvfx-html-contextmenu="self"]');
92169
92263
  };
92170
92264
  _proto.handleViewportTransform = function handleViewportTransform() {
92171
92265
  var editing = this.state.editing;
@@ -92185,6 +92279,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92185
92279
  }
92186
92280
  var items = this.options.getItems();
92187
92281
  var frameByChildId = this.renderFrameOverlays(items, layer);
92282
+ var selectionLayer = this.getOrCreateSelectionLayer(layer);
92188
92283
  var visibleCardIds = new Set();
92189
92284
  var editingVisible = false;
92190
92285
  items.forEach(function(item) {
@@ -92208,20 +92303,31 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92208
92303
  var frameBox = frameId ? _this.options.getViewBoxById(frameId) : undefined;
92209
92304
  var overlay = _this.getOrCreateOverlay(item.id, parentOverlay, elements);
92210
92305
  var contentOverlay = _this.getOrCreateContentOverlay(item.id, overlay);
92211
- if (html && _this.state.contents.get(item.id) !== html) {
92306
+ var selectionOverlay = _this.getOrCreateSelectionOverlay(item.id, selectionLayer);
92307
+ if (!_this.state.contents.has(item.id)) {
92212
92308
  _this.renderOverlayHTML(item.id, contentOverlay, html);
92213
92309
  }
92310
+ _this.applyHTMLRootConfig(overlay, html);
92214
92311
  var offsetX = frameBox && !frameBox.isEmpty() ? frameBox.min.x : 0;
92215
92312
  var offsetY = frameBox && !frameBox.isEmpty() ? frameBox.min.y : 0;
92216
- var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY, item.property.autoScale !== false);
92313
+ var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY, _this.isAutoScaleEnabled(item));
92217
92314
  overlay.style.left = boxStyle.left;
92218
92315
  overlay.style.top = boxStyle.top;
92219
92316
  overlay.style.width = boxStyle.width;
92220
92317
  overlay.style.height = boxStyle.height;
92221
92318
  overlay.style.transform = boxStyle.transform;
92222
92319
  overlay.style.transformOrigin = '0 0';
92320
+ var selectionBoxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, 0, 0, _this.isAutoScaleEnabled(item));
92321
+ selectionOverlay.style.left = selectionBoxStyle.left;
92322
+ selectionOverlay.style.top = selectionBoxStyle.top;
92323
+ selectionOverlay.style.width = selectionBoxStyle.width;
92324
+ selectionOverlay.style.height = selectionBoxStyle.height;
92325
+ selectionOverlay.style.transform = selectionBoxStyle.transform;
92326
+ selectionOverlay.style.transformOrigin = '0 0';
92327
+ _this.applyHTMLRootConfig(selectionOverlay, html);
92328
+ _this.syncOverlaySelection(item.id, overlay, selectionOverlay);
92223
92329
  _this.syncContentScale(item.id, boxStyle.contentWidth, boxStyle.contentHeight);
92224
- _this.syncAutoHeight(item.id, item.property.autoHeight === true);
92330
+ _this.syncAutoHeight(item.id, _this.isAutoHeightEnabled(item));
92225
92331
  _this.syncContentInteraction(item.id);
92226
92332
  });
92227
92333
  elements.forEach(function(_overlay, id) {
@@ -92260,6 +92366,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92260
92366
  }
92261
92367
  }
92262
92368
  syncElementStackOrder(layer, rootElements);
92369
+ if (this.state.selectionLayer) {
92370
+ this.state.selectionLayer.style.zIndex = "" + (rootElements.length + 1);
92371
+ }
92263
92372
  this.state.frameElements.forEach(function(frameOverlay, frameId) {
92264
92373
  var frameElements = [];
92265
92374
  for(var _iterator = _create_for_of_iterator_helper_loose(items), _step; !(_step = _iterator()).done;){
@@ -92275,6 +92384,28 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92275
92384
  syncElementStackOrder(frameOverlay, frameElements);
92276
92385
  });
92277
92386
  };
92387
+ _proto.getOrCreateSelectionLayer = function getOrCreateSelectionLayer(layer) {
92388
+ var _layer_ownerDocument;
92389
+ if (this.state.selectionLayer) {
92390
+ if (this.state.selectionLayer.parentElement !== layer) {
92391
+ layer.appendChild(this.state.selectionLayer);
92392
+ }
92393
+ return this.state.selectionLayer;
92394
+ }
92395
+ var ownerDocument = (_layer_ownerDocument = layer.ownerDocument) != null ? _layer_ownerDocument : typeof document === 'undefined' ? undefined : document;
92396
+ if (!ownerDocument) {
92397
+ return layer;
92398
+ }
92399
+ var selectionLayer = ownerDocument.createElement('div');
92400
+ selectionLayer.className = 'vvfx-card-html-overlay-selection-layer';
92401
+ selectionLayer.style.position = 'absolute';
92402
+ selectionLayer.style.inset = '0';
92403
+ selectionLayer.style.pointerEvents = 'none';
92404
+ selectionLayer.style.zIndex = '1';
92405
+ layer.appendChild(selectionLayer);
92406
+ this.state.selectionLayer = selectionLayer;
92407
+ return selectionLayer;
92408
+ };
92278
92409
  _proto.renderFrameOverlays = function renderFrameOverlays(items, layer) {
92279
92410
  var _this = this;
92280
92411
  var visibleFrameIds = new Set();
@@ -92339,6 +92470,41 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92339
92470
  elements.set(id, overlay);
92340
92471
  return overlay;
92341
92472
  };
92473
+ _proto.getOrCreateSelectionOverlay = function getOrCreateSelectionOverlay(id, parent) {
92474
+ var selectionOverlay = this.state.selectionElements.get(id);
92475
+ if (selectionOverlay) {
92476
+ if (selectionOverlay.parentElement !== parent) {
92477
+ parent.appendChild(selectionOverlay);
92478
+ }
92479
+ return selectionOverlay;
92480
+ }
92481
+ selectionOverlay = document.createElement('div');
92482
+ selectionOverlay.className = 'vvfx-card-html-overlay-selection';
92483
+ selectionOverlay.dataset.itemId = id;
92484
+ selectionOverlay.style.position = 'absolute';
92485
+ selectionOverlay.style.pointerEvents = 'none';
92486
+ selectionOverlay.style.zIndex = '1';
92487
+ parent.appendChild(selectionOverlay);
92488
+ this.state.selectionElements.set(id, selectionOverlay);
92489
+ return selectionOverlay;
92490
+ };
92491
+ _proto.syncOverlaySelection = function syncOverlaySelection(id, overlay, selectionOverlay) {
92492
+ var isSelected = this.options.getSelectedItemIds().includes(id);
92493
+ var isPreSelected = !isSelected && this.options.getPreSelectedItemId() === id;
92494
+ overlay.dataset.selected = isSelected ? 'true' : 'false';
92495
+ overlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92496
+ selectionOverlay.dataset.selected = isSelected ? 'true' : 'false';
92497
+ selectionOverlay.dataset.preSelected = isPreSelected ? 'true' : 'false';
92498
+ selectionOverlay.style.boxShadow = isSelected ? this.getSelectionBoxShadow() : isPreSelected ? this.getPreSelectionBoxShadow() : '';
92499
+ };
92500
+ _proto.getSelectionBoxShadow = function getSelectionBoxShadow() {
92501
+ var _this_options_getSelectionEdgeStyle = this.options.getSelectionEdgeStyle(), color = _this_options_getSelectionEdgeStyle.color, alpha = _this_options_getSelectionEdgeStyle.alpha, width = _this_options_getSelectionEdgeStyle.width;
92502
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92503
+ };
92504
+ _proto.getPreSelectionBoxShadow = function getPreSelectionBoxShadow() {
92505
+ var _this_options_getPreSelectionEdgeStyle = this.options.getPreSelectionEdgeStyle(), color = _this_options_getPreSelectionEdgeStyle.color, alpha = _this_options_getPreSelectionEdgeStyle.alpha, width = _this_options_getPreSelectionEdgeStyle.width;
92506
+ return "inset 0 0 0 " + formatCssNumber(width) + "px " + formatCssColor(color, alpha);
92507
+ };
92342
92508
  _proto.getHTMLCardIdByEvent = function getHTMLCardIdByEvent(event) {
92343
92509
  var layer = this.state.layer;
92344
92510
  if (!layer) {
@@ -92377,13 +92543,143 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92377
92543
  var contentOverlay = this.state.contentElements.get(item.id);
92378
92544
  var interactiveElements = contentOverlay ? Array.from(contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR)) : [];
92379
92545
  var isHoveringShellInteractive = interactiveElements.some(function(element) {
92380
- var rect = element.getBoundingClientRect();
92381
- return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
92546
+ return isMouseEventInsideRect(event, element.getBoundingClientRect());
92382
92547
  });
92383
92548
  return isHoveringShellInteractive ? item.id : undefined;
92384
92549
  }
92385
92550
  return undefined;
92386
92551
  };
92552
+ _proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
92553
+ var zone = this.getContentInteractiveZoneByEvent(event);
92554
+ this.setActiveContentInteraction(zone);
92555
+ };
92556
+ _proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
92557
+ var _this = this;
92558
+ if (typeof requestAnimationFrame !== 'function') {
92559
+ this.syncActiveContentInteraction(event);
92560
+ return;
92561
+ }
92562
+ this.pendingContentInteractionEvent = event;
92563
+ if (this.contentInteractionFrame !== undefined) {
92564
+ return;
92565
+ }
92566
+ this.contentInteractionFrame = requestAnimationFrame(function() {
92567
+ _this.contentInteractionFrame = undefined;
92568
+ var pendingEvent = _this.pendingContentInteractionEvent;
92569
+ _this.pendingContentInteractionEvent = undefined;
92570
+ if (pendingEvent) {
92571
+ _this.syncActiveContentInteraction(pendingEvent);
92572
+ }
92573
+ });
92574
+ };
92575
+ _proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
92576
+ var _this = this;
92577
+ var previous = this.state.activeContentInteraction;
92578
+ 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)) {
92579
+ return;
92580
+ }
92581
+ this.state.activeContentInteraction = zone;
92582
+ var changedIds = new Set();
92583
+ if (previous) {
92584
+ changedIds.add(previous.id);
92585
+ }
92586
+ if (zone) {
92587
+ changedIds.add(zone.id);
92588
+ }
92589
+ changedIds.forEach(function(id) {
92590
+ _this.syncContentInteraction(id);
92591
+ });
92592
+ };
92593
+ _proto.getContentInteractiveZoneByEvent = function getContentInteractiveZoneByEvent(event) {
92594
+ var id = this.getHTMLCardIdByEvent(event);
92595
+ if (!id || this.isEditableCard(id)) {
92596
+ return undefined;
92597
+ }
92598
+ var contentOverlay = this.state.contentElements.get(id);
92599
+ if (!contentOverlay) {
92600
+ return undefined;
92601
+ }
92602
+ var zone = this.getContentInteractionZones(id, contentOverlay).find(function(zone) {
92603
+ return isMouseEventInsideRect(event, zone.rect);
92604
+ });
92605
+ return zone ? {
92606
+ id: id,
92607
+ element: zone.element
92608
+ } : undefined;
92609
+ };
92610
+ _proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
92611
+ var _this = this;
92612
+ var cachedZones = this.state.contentInteractionZones.get(id);
92613
+ if (cachedZones) {
92614
+ return cachedZones;
92615
+ }
92616
+ var zones = Array.from(contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id))).filter(function(element) {
92617
+ return !_this.isContentInteractionDisabled(element);
92618
+ }).map(function(element) {
92619
+ return {
92620
+ element: element,
92621
+ rect: element.getBoundingClientRect()
92622
+ };
92623
+ });
92624
+ this.state.contentInteractionZones.set(id, zones);
92625
+ this.observeContentInteractionZoneResizes(id, zones);
92626
+ return zones;
92627
+ };
92628
+ _proto.getContentInteractiveSelector = function getContentInteractiveSelector(id) {
92629
+ var _ref;
92630
+ var _this_options_resolveCardTypeConfig_htmlInteractionSelectors, _this_options_resolveCardTypeConfig;
92631
+ var item = this.options.getItems().find(function(item) {
92632
+ return item.id === id;
92633
+ });
92634
+ if (!item) {
92635
+ return CONTENT_INTERACTIVE_SELECTOR;
92636
+ }
92637
+ 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 : [];
92638
+ if (selectors.length === 0) {
92639
+ return CONTENT_INTERACTIVE_SELECTOR;
92640
+ }
92641
+ return [].concat([
92642
+ CONTENT_INTERACTIVE_SELECTOR
92643
+ ], selectors).join(', ');
92644
+ };
92645
+ _proto.isContentInteractionDisabled = function isContentInteractionDisabled(element) {
92646
+ if (typeof element.closest !== 'function') {
92647
+ return false;
92648
+ }
92649
+ return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
92650
+ };
92651
+ _proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
92652
+ if (id) {
92653
+ var _this_state_contentInteractionResizeCleanups_get;
92654
+ this.state.contentInteractionZones.delete(id);
92655
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92656
+ this.state.contentInteractionResizeCleanups.delete(id);
92657
+ return;
92658
+ }
92659
+ this.state.contentInteractionZones.clear();
92660
+ this.state.contentInteractionResizeCleanups.forEach(function(cleanup) {
92661
+ cleanup();
92662
+ });
92663
+ this.state.contentInteractionResizeCleanups.clear();
92664
+ };
92665
+ _proto.observeContentInteractionZoneResizes = function observeContentInteractionZoneResizes(id, zones) {
92666
+ var _this = this;
92667
+ var _this_state_contentInteractionResizeCleanups_get;
92668
+ (_this_state_contentInteractionResizeCleanups_get = this.state.contentInteractionResizeCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionResizeCleanups_get();
92669
+ this.state.contentInteractionResizeCleanups.delete(id);
92670
+ if (zones.length === 0 || typeof ResizeObserver !== 'function') {
92671
+ return;
92672
+ }
92673
+ var observer = new ResizeObserver(function() {
92674
+ _this.invalidateContentInteractionZones(id);
92675
+ });
92676
+ zones.forEach(function(zone) {
92677
+ observer.observe(zone.element);
92678
+ });
92679
+ this.state.contentInteractionResizeCleanups.set(id, function() {
92680
+ observer.disconnect();
92681
+ });
92682
+ };
92387
92683
  _proto.getLayerPoint = function getLayerPoint(event) {
92388
92684
  var rect = this.options.container.getBoundingClientRect();
92389
92685
  return {
@@ -92451,6 +92747,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92451
92747
  if (sizeChanged && this.state.autoHeightModes.get(id) === 'message') {
92452
92748
  this.requestAutoHeightFromIframes(id, contentOverlay);
92453
92749
  }
92750
+ if (sizeChanged) {
92751
+ this.invalidateContentInteractionZones(id);
92752
+ }
92454
92753
  };
92455
92754
  _proto.requestAutoHeightFromIframes = function requestAutoHeightFromIframes(id, contentOverlay) {
92456
92755
  contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
@@ -92458,8 +92757,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92458
92757
  });
92459
92758
  };
92460
92759
  _proto.syncContentInteraction = function syncContentInteraction(id) {
92461
- var _this_state_editing;
92760
+ var _this_state_editing, _this_state_activeContentInteraction;
92462
92761
  var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
92762
+ var activeInteraction = ((_this_state_activeContentInteraction = this.state.activeContentInteraction) == null ? void 0 : _this_state_activeContentInteraction.id) === id ? this.state.activeContentInteraction : undefined;
92763
+ var isInteractive = isEditing || !!activeInteraction;
92463
92764
  var overlay = this.state.elements.get(id);
92464
92765
  var scaleOverlay = this.state.contentScaleElements.get(id);
92465
92766
  var contentOverlay = this.state.contentElements.get(id);
@@ -92474,34 +92775,49 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92474
92775
  }
92475
92776
  if (contentOverlay) {
92476
92777
  contentOverlay.dataset.editing = isEditing ? 'true' : 'false';
92477
- contentOverlay.style.pointerEvents = 'none';
92778
+ contentOverlay.style.pointerEvents = isInteractive ? 'auto' : 'none';
92478
92779
  contentOverlay.querySelectorAll('iframe').forEach(function(iframe) {
92479
- iframe.style.pointerEvents = isEditing ? 'auto' : 'none';
92480
- iframe.tabIndex = isEditing ? 0 : -1;
92780
+ var isActiveIframe = isEditing || (activeInteraction == null ? void 0 : activeInteraction.element) === iframe;
92781
+ iframe.style.pointerEvents = isActiveIframe ? 'auto' : 'none';
92782
+ iframe.tabIndex = isActiveIframe ? 0 : -1;
92481
92783
  });
92482
- this.syncShellInteraction(id, contentOverlay, isEditing);
92784
+ this.syncShellInteraction(id, contentOverlay, isInteractive);
92785
+ this.syncContentInteractionZones(id, contentOverlay, activeInteraction == null ? void 0 : activeInteraction.element, isEditing, isInteractive);
92483
92786
  }
92484
92787
  if (contentMount) {
92485
92788
  contentMount.dataset.editing = isEditing ? 'true' : 'false';
92486
- contentMount.style.pointerEvents = isEditing ? 'auto' : 'none';
92487
- contentMount.inert = !isEditing;
92488
- if (isEditing) {
92789
+ contentMount.style.pointerEvents = isInteractive ? 'auto' : 'none';
92790
+ contentMount.inert = !isInteractive;
92791
+ if (isInteractive) {
92489
92792
  contentMount.removeAttribute('aria-hidden');
92490
92793
  } else {
92491
92794
  contentMount.setAttribute('aria-hidden', 'true');
92492
92795
  }
92493
92796
  }
92494
92797
  };
92495
- _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isEditing) {
92798
+ _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeElement, isEditing, isInteractive) {
92799
+ var _this = this;
92800
+ contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
92801
+ if (!isInteractive || _this.isContentInteractionDisabled(element)) {
92802
+ element.dataset.vvfxHtmlInteractionActive = 'false';
92803
+ element.style.pointerEvents = 'none';
92804
+ return;
92805
+ }
92806
+ var isElementInteractive = isEditing || activeElement === element;
92807
+ element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
92808
+ element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
92809
+ });
92810
+ };
92811
+ _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
92496
92812
  var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
92497
- var isShellInteractiveActive = isEditing || isHoveringShellInteractive;
92813
+ var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
92498
92814
  contentOverlay.querySelectorAll(SHELL_INTERACTIVE_SELECTOR).forEach(function(element) {
92499
92815
  element.dataset.vvfxHtmlShellInteractiveHover = isHoveringShellInteractive ? 'true' : 'false';
92500
92816
  element.dataset.vvfxHtmlShellInteractiveActive = isShellInteractiveActive ? 'true' : 'false';
92501
92817
  element.style.pointerEvents = isShellInteractiveActive ? 'auto' : 'none';
92502
92818
  });
92503
92819
  contentOverlay.querySelectorAll(EDITING_INTERACTIVE_SELECTOR).forEach(function(element) {
92504
- element.style.pointerEvents = isEditing ? 'auto' : 'none';
92820
+ element.style.pointerEvents = isInteractive ? 'auto' : 'none';
92505
92821
  });
92506
92822
  };
92507
92823
  _proto.enterEditing = function enterEditing(id) {
@@ -92509,6 +92825,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92509
92825
  if (((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id) {
92510
92826
  return;
92511
92827
  }
92828
+ if (!this.isEditableCard(id)) {
92829
+ return;
92830
+ }
92512
92831
  var box = this.options.getViewBoxById(id);
92513
92832
  if (box.isEmpty()) {
92514
92833
  return;
@@ -92552,6 +92871,13 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92552
92871
  this.options.setViewport(editing.restoreViewport);
92553
92872
  this.scheduleRender();
92554
92873
  };
92874
+ _proto.isEditableCard = function isEditableCard(id) {
92875
+ var _this_options_resolveCardTypeConfig;
92876
+ var item = this.options.getItems().find(function(item) {
92877
+ return item.id === id;
92878
+ });
92879
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.editable) !== false;
92880
+ };
92555
92881
  _proto.getEditingFitZoom = function getEditingFitZoom(box, currentZoom) {
92556
92882
  var viewportElement = this.options.container.parentElement;
92557
92883
  if (!viewportElement) {
@@ -92576,6 +92902,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92576
92902
  };
92577
92903
  _proto.renderOverlayHTML = function renderOverlayHTML(id, overlay, html) {
92578
92904
  this.cleanupOverlayContent(id);
92905
+ this.invalidateContentInteractionZones(id);
92579
92906
  overlay.innerHTML = '';
92580
92907
  var shell = mountHTMLShell(overlay, html.content, html.shell);
92581
92908
  var autoHeightMeasureElement = shell.contentContainer.isConnected ? shell.contentContainer : overlay;
@@ -92585,14 +92912,74 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92585
92912
  });
92586
92913
  var contentCleanup = this.renderOverlayContent(shell.contentContainer, html.content, {
92587
92914
  id: id,
92588
- autoHeight: isCardItem(item) && item.property.autoHeight === true
92915
+ autoHeight: this.isAutoHeightEnabled(item)
92589
92916
  });
92917
+ this.observeContentInteractionZones(id, shell.contentContainer);
92590
92918
  this.state.cleanups.set(id, function() {
92591
92919
  contentCleanup == null ? void 0 : contentCleanup();
92592
92920
  shell.cleanup == null ? void 0 : shell.cleanup.call(shell);
92593
92921
  });
92594
92922
  this.state.contents.set(id, html);
92595
92923
  };
92924
+ _proto.observeContentInteractionZones = function observeContentInteractionZones(id, contentContainer) {
92925
+ var _this = this;
92926
+ var _this_state_contentInteractionZoneCleanups_get;
92927
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
92928
+ this.state.contentInteractionZoneCleanups.delete(id);
92929
+ if (typeof MutationObserver !== 'function') {
92930
+ return;
92931
+ }
92932
+ var observer = new MutationObserver(function() {
92933
+ _this.invalidateContentInteractionZones(id);
92934
+ });
92935
+ observer.observe(contentContainer, {
92936
+ attributes: true,
92937
+ childList: true,
92938
+ subtree: true
92939
+ });
92940
+ this.state.contentInteractionZoneCleanups.set(id, function() {
92941
+ observer.disconnect();
92942
+ });
92943
+ };
92944
+ _proto.applyHTMLRootConfig = function applyHTMLRootConfig(root, html) {
92945
+ var _ref, _config_style;
92946
+ var _this_htmlRootConfigCleanups_get, _config_className;
92947
+ (_this_htmlRootConfigCleanups_get = this.htmlRootConfigCleanups.get(root)) == null ? void 0 : _this_htmlRootConfigCleanups_get();
92948
+ this.htmlRootConfigCleanups.delete(root);
92949
+ var config = html.root;
92950
+ if (!config) {
92951
+ return;
92952
+ }
92953
+ var classNames = (_ref = (_config_className = config.className) == null ? void 0 : _config_className.split(/\s+/).filter(Boolean)) != null ? _ref : [];
92954
+ var styleProperties = [];
92955
+ classNames.forEach(function(className) {
92956
+ root.classList.add(className);
92957
+ });
92958
+ Object.entries((_config_style = config.style) != null ? _config_style : {}).forEach(function(param) {
92959
+ var property = param[0], value = param[1];
92960
+ if (value === undefined) {
92961
+ return;
92962
+ }
92963
+ styleProperties.push(property);
92964
+ if (property.startsWith('--') || property.includes('-')) {
92965
+ root.style.setProperty(property, String(value));
92966
+ return;
92967
+ }
92968
+ root.style[property] = String(value);
92969
+ });
92970
+ this.htmlRootConfigCleanups.set(root, function() {
92971
+ classNames.forEach(function(className) {
92972
+ root.classList.remove(className);
92973
+ });
92974
+ styleProperties.forEach(function(property) {
92975
+ if (property.startsWith('--') || property.includes('-')) {
92976
+ root.style.removeProperty(property);
92977
+ return;
92978
+ }
92979
+ root.style[property] = '';
92980
+ });
92981
+ });
92982
+ };
92596
92983
  _proto.renderOverlayContent = function renderOverlayContent(overlay, content, options) {
92597
92984
  var _this = this;
92598
92985
  switch(content.kind){
@@ -92658,6 +93045,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92658
93045
  };
92659
93046
  };
92660
93047
  _proto.cleanupOverlayContent = function cleanupOverlayContent(id) {
93048
+ var _this_state_contentInteractionZoneCleanups_get;
92661
93049
  var cleanup = this.state.cleanups.get(id);
92662
93050
  if (cleanup) {
92663
93051
  cleanup();
@@ -92666,13 +93054,18 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92666
93054
  this.state.contents.delete(id);
92667
93055
  this.state.contentMountElements.delete(id);
92668
93056
  this.state.autoHeightModes.delete(id);
93057
+ this.invalidateContentInteractionZones(id);
93058
+ (_this_state_contentInteractionZoneCleanups_get = this.state.contentInteractionZoneCleanups.get(id)) == null ? void 0 : _this_state_contentInteractionZoneCleanups_get();
93059
+ this.state.contentInteractionZoneCleanups.delete(id);
92669
93060
  this.cleanupAutoHeight(id);
92670
93061
  };
92671
93062
  _proto.removeOverlay = function removeOverlay(id) {
92672
- var _this_state_elements_get;
93063
+ var _this_state_elements_get, _this_state_selectionElements_get;
92673
93064
  this.cleanupOverlayContent(id);
92674
93065
  (_this_state_elements_get = this.state.elements.get(id)) == null ? void 0 : _this_state_elements_get.remove();
93066
+ (_this_state_selectionElements_get = this.state.selectionElements.get(id)) == null ? void 0 : _this_state_selectionElements_get.remove();
92675
93067
  this.state.elements.delete(id);
93068
+ this.state.selectionElements.delete(id);
92676
93069
  this.state.contentScaleElements.delete(id);
92677
93070
  this.state.contentElements.delete(id);
92678
93071
  };
@@ -92789,7 +93182,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92789
93182
  var item = this.options.getItems().find(function(candidate) {
92790
93183
  return candidate.id === id;
92791
93184
  });
92792
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93185
+ if (!this.isAutoHeightEnabled(item)) {
92793
93186
  this.cleanupAutoHeight(id);
92794
93187
  return;
92795
93188
  }
@@ -92871,7 +93264,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92871
93264
  var item = this.options.getItems().find(function(candidate) {
92872
93265
  return candidate.id === id;
92873
93266
  });
92874
- if (!isCardItem(item) || item.property.autoHeight !== true) {
93267
+ if (!isCardItem(item) || !this.isAutoHeightEnabled(item)) {
92875
93268
  return;
92876
93269
  }
92877
93270
  if (!Number.isFinite(height) || height <= 0) {
@@ -92884,7 +93277,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92884
93277
  this.options.setCardItemHeight(id, nextHeight);
92885
93278
  };
92886
93279
  _proto.getAutoHeightItemHeight = function getAutoHeightItemHeight(item, contentHeight) {
92887
- if (!isCardItem(item) || item.property.autoScale !== false) {
93280
+ if (!isCardItem(item) || this.isAutoScaleEnabled(item)) {
92888
93281
  return contentHeight;
92889
93282
  }
92890
93283
  var scaleOverlay = this.state.contentScaleElements.get(item.id);
@@ -92894,6 +93287,25 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92894
93287
  }
92895
93288
  return contentHeight / displayedHeight * item.property.height;
92896
93289
  };
93290
+ _proto.isAutoHeightEnabled = function isAutoHeightEnabled(item) {
93291
+ var _this_options_resolveCardTypeConfig;
93292
+ return isCardItem(item) && ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeight) === true;
93293
+ };
93294
+ _proto.isAutoScaleEnabled = function isAutoScaleEnabled(item) {
93295
+ var _this_options_resolveCardTypeConfig;
93296
+ if (!isCardItem(item)) {
93297
+ return true;
93298
+ }
93299
+ return ((_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoScale) !== false;
93300
+ };
93301
+ _create_class(HTMLOverlayManager, [
93302
+ {
93303
+ key: "layerElement",
93304
+ get: function get() {
93305
+ return this.state.layer;
93306
+ }
93307
+ }
93308
+ ]);
92897
93309
  return HTMLOverlayManager;
92898
93310
  }();
92899
93311
  function waitForCardCaptureReady(root) {
@@ -92935,6 +93347,17 @@ function waitForCardCaptureReady(root) {
92935
93347
  });
92936
93348
  })();
92937
93349
  }
93350
+ function formatCssColor(color, alpha) {
93351
+ var normalizedColor = Math.max(0, Math.min(0xFFFFFF, Math.round(color)));
93352
+ var red = normalizedColor >> 16 & 0xFF;
93353
+ var green = normalizedColor >> 8 & 0xFF;
93354
+ var blue = normalizedColor & 0xFF;
93355
+ return "rgba(" + red + ", " + green + ", " + blue + ", " + formatCssNumber(alpha) + ")";
93356
+ }
93357
+ function formatCssNumber(value) {
93358
+ var normalized = Number.isFinite(value) ? value : 0;
93359
+ return Number(normalized.toFixed(6)).toString();
93360
+ }
92938
93361
  function nextAnimationFrame() {
92939
93362
  return new Promise(function(resolve) {
92940
93363
  requestAnimationFrame(function() {
@@ -93353,6 +93776,9 @@ function createFlattenedContent(target, frameStyle, ownerDocument) {
93353
93776
  });
93354
93777
  return replacement;
93355
93778
  }
93779
+ function isMouseEventInsideRect(event, rect) {
93780
+ return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
93781
+ }
93356
93782
  function createFlattenedIframeContent(iframe) {
93357
93783
  var doc = iframe.contentDocument;
93358
93784
  if (!doc) {
@@ -93392,6 +93818,19 @@ function withTimeout(promise, timeout) {
93392
93818
  });
93393
93819
  }
93394
93820
 
93821
+ function orderSDKCanvasLayers(param) {
93822
+ var container = param.container, playerContainer = param.playerContainer, htmlOverlayLayer = param.htmlOverlayLayer, gestureCanvas = param.gestureCanvas;
93823
+ [
93824
+ playerContainer,
93825
+ htmlOverlayLayer,
93826
+ gestureCanvas
93827
+ ].forEach(function(layer) {
93828
+ if ((layer == null ? void 0 : layer.parentElement) === container) {
93829
+ container.appendChild(layer);
93830
+ }
93831
+ });
93832
+ }
93833
+
93395
93834
  var HTML_CARD_EDITING_VIEWPORT_PADDING = 48;
93396
93835
  var SDK = /*#__PURE__*/ function() {
93397
93836
  function SDK(container, mode) {
@@ -93498,11 +93937,44 @@ var SDK = /*#__PURE__*/ function() {
93498
93937
  propertyValue: height
93499
93938
  });
93500
93939
  },
93940
+ getSelectedItemIds: function getSelectedItemIds() {
93941
+ var _ref;
93942
+ var _this__pageData;
93943
+ return (_ref = (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.selectedItems) != null ? _ref : [];
93944
+ },
93945
+ getPreSelectedItemId: function getPreSelectedItemId() {
93946
+ var _this__pageData;
93947
+ return (_this__pageData = _this._pageData) == null ? void 0 : _this__pageData.activeData.preSelectedItem;
93948
+ },
93949
+ getSelectionEdgeStyle: function getSelectionEdgeStyle() {
93950
+ 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;
93951
+ return {
93952
+ color: wireframeColor,
93953
+ alpha: wireframeAlpha,
93954
+ width: wireframeWidth
93955
+ };
93956
+ },
93957
+ getPreSelectionEdgeStyle: function getPreSelectionEdgeStyle() {
93958
+ var _SDK_config_gestureHandlerConfig_selectorGizmoConfig = SDK.config.gestureHandlerConfig.selectorGizmoConfig, preSelectedColor = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedColor, preSelectedWidth = _SDK_config_gestureHandlerConfig_selectorGizmoConfig.preSelectedWidth;
93959
+ return {
93960
+ color: preSelectedColor,
93961
+ alpha: 1,
93962
+ width: preSelectedWidth
93963
+ };
93964
+ },
93965
+ getCanvasEventTarget: function getCanvasEventTarget() {
93966
+ var _this__gestureHandler;
93967
+ return (_this__gestureHandler = _this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view;
93968
+ },
93501
93969
  resolveCardHTML: function resolveCardHTML(item) {
93502
93970
  return isCardItem(item) ? _this.resolveCardHTML(item) : undefined;
93971
+ },
93972
+ resolveCardTypeConfig: function resolveCardTypeConfig(item) {
93973
+ return isCardItem(item) ? _this.resolveCardTypeConfig(item) : undefined;
93503
93974
  }
93504
93975
  });
93505
93976
  this._htmlOverlayManager.attach();
93977
+ this.syncCanvasLayerOrder();
93506
93978
  }
93507
93979
  var _proto = SDK.prototype;
93508
93980
  _proto.dispose = function dispose() {
@@ -93598,6 +94070,7 @@ var SDK = /*#__PURE__*/ function() {
93598
94070
  this.initPlayer(SDK.config.mode);
93599
94071
  this._pageDataUtils = new PageDataUtils(this.player, this._playerContainer, this._eventEmitter, this);
93600
94072
  this._gestureHandler = new GestureHandler(this._container);
94073
+ this.syncCanvasLayerOrder();
93601
94074
  return [
93602
94075
  4,
93603
94076
  this.runByPageData(this.pageData)
@@ -93647,6 +94120,16 @@ var SDK = /*#__PURE__*/ function() {
93647
94120
  env: 'editor'
93648
94121
  });
93649
94122
  this.player.resize();
94123
+ this.syncCanvasLayerOrder();
94124
+ };
94125
+ _proto.syncCanvasLayerOrder = function syncCanvasLayerOrder() {
94126
+ var _this__htmlOverlayManager, _this__gestureHandler;
94127
+ orderSDKCanvasLayers({
94128
+ container: this._container,
94129
+ playerContainer: this._playerContainer,
94130
+ htmlOverlayLayer: (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.layerElement,
94131
+ gestureCanvas: (_this__gestureHandler = this._gestureHandler) == null ? void 0 : _this__gestureHandler.wireframeApplication.view
94132
+ });
93650
94133
  };
93651
94134
  _proto.getInitParam = function getInitParam(param) {
93652
94135
  return _async_to_generator(function() {
@@ -95643,10 +96126,37 @@ var SDK = /*#__PURE__*/ function() {
95643
96126
  * @returns HTML 渲染配置
95644
96127
  */ _proto.resolveCardHTML = function resolveCardHTML(item) {
95645
96128
  var _cardTypeConfig_html;
95646
- var cardTypeConfig = SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
96129
+ var cardTypeConfig = this.resolveCardTypeConfig(item);
96130
+ return cardTypeConfig == null ? void 0 : (_cardTypeConfig_html = cardTypeConfig.html) == null ? void 0 : _cardTypeConfig_html.call(cardTypeConfig, item);
96131
+ };
96132
+ /**
96133
+ * @description 按 cardType 从注册表解析卡片类型配置。
96134
+ * @param item 卡片元素
96135
+ * @returns 卡片类型配置
96136
+ */ _proto.resolveCardTypeConfig = function resolveCardTypeConfig(item) {
96137
+ return SDK.config.itemConfig.cardConfig.cardTypes.find(function(t) {
95647
96138
  return t.type === item.cardType;
95648
96139
  });
95649
- return cardTypeConfig == null ? void 0 : (_cardTypeConfig_html = cardTypeConfig.html) == null ? void 0 : _cardTypeConfig_html.call(cardTypeConfig, item);
96140
+ };
96141
+ /**
96142
+ * @description 重新解析并挂载指定卡片的 HTML 内容。
96143
+ * @description 当 inline/document 内容依赖 extension 或外部状态变化时,可调用此方法刷新 DOM。
96144
+ * @param id 卡片元素 ID
96145
+ * @returns 是否成功触发刷新
96146
+ */ _proto.refreshCardHTML = function refreshCardHTML(id) {
96147
+ var _this__htmlOverlayManager, _this__htmlOverlayManager1;
96148
+ var item = this.getSDKItem(id);
96149
+ if (!isCardItem(item)) {
96150
+ console.warn('CardItem "' + id + '" not found.');
96151
+ return false;
96152
+ }
96153
+ if (!this.resolveCardHTML(item)) {
96154
+ console.warn('CardItem "' + id + '" has no registered HTML renderer.');
96155
+ return false;
96156
+ }
96157
+ (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.invalidateCardHTML(id);
96158
+ (_this__htmlOverlayManager1 = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager1.scheduleRender();
96159
+ return true;
95650
96160
  };
95651
96161
  /**
95652
96162
  * @description 创建卡片元素