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

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.5
6
+ * Version: v0.2.2-beta.7
7
7
  */
8
8
 
9
9
  'use strict';
@@ -55577,6 +55577,16 @@ var TransformGizmo = /*#__PURE__*/ function(Gizmo) {
55577
55577
  newWidth,
55578
55578
  newHeight
55579
55579
  ], translation1);
55580
+ } else if (selectedItem && selectedItems.length === 1 && isCardItem(selectedItem)) {
55581
+ void this._pageDataUtils.setItemProperty({
55582
+ itemId: selectedItem.id,
55583
+ type: SDKItemType.CARD,
55584
+ property: {
55585
+ width: selectedItem.width * resultScalar1.x,
55586
+ height: selectedItem.height * resultScalar1.y
55587
+ }
55588
+ });
55589
+ this._pageDataUtils.moveItem(selectedItem.id, translation1);
55580
55590
  } else {
55581
55591
  // 普通元素的缩放逻辑
55582
55592
  selectedItems.forEach(function(item) {
@@ -91843,14 +91853,13 @@ function syncElementStackOrder(_container, elements) {
91843
91853
  });
91844
91854
  }
91845
91855
 
91846
- function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, autoScale) {
91856
+ function getCardOverlayBoxStyle(box, width, height, offsetX, offsetY, _autoScale) {
91847
91857
  if (offsetX === void 0) offsetX = 0;
91848
91858
  if (offsetY === void 0) offsetY = 0;
91849
- if (autoScale === void 0) autoScale = true;
91850
91859
  if (box.corners.length === 4 && width > 0 && height > 0) {
91851
91860
  var _box_corners = box.corners, rightTop = _box_corners[0], leftBottom = _box_corners[2], leftTop = _box_corners[3];
91852
- var contentWidth = autoScale ? width : rightTop.distanceTo(leftTop);
91853
- var contentHeight = autoScale ? height : leftBottom.distanceTo(leftTop);
91861
+ var contentWidth = width;
91862
+ var contentHeight = height;
91854
91863
  var a = (rightTop.x - leftTop.x) / contentWidth;
91855
91864
  var b = (rightTop.y - leftTop.y) / contentWidth;
91856
91865
  var c = (leftBottom.x - leftTop.x) / contentHeight;
@@ -91923,8 +91932,8 @@ function mountHTMLShell(container, content, shell) {
91923
91932
  var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
91924
91933
  var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
91925
91934
  var CONTENT_INTERACTIVE_SELECTOR = [
91926
- '[data-interaction-zone="self"]',
91927
91935
  '[data-vvfx-html-interaction-zone="self"]',
91936
+ '[data-vvfx-html-interaction-zone="subtree"]',
91928
91937
  'a[href]',
91929
91938
  'button:not([disabled])',
91930
91939
  'input:not([disabled])',
@@ -91940,7 +91949,6 @@ var CONTENT_INTERACTIVE_SELECTOR = [
91940
91949
  '[tabindex]:not([tabindex="-1"])'
91941
91950
  ].join(', ');
91942
91951
  var CONTENT_INTERACTION_NONE_SELECTOR = [
91943
- '[data-interaction-zone="none"]',
91944
91952
  '[data-vvfx-html-interaction-zone="none"]'
91945
91953
  ].join(', ');
91946
91954
  var EDITING_VIEWPORT_PADDING = 48;
@@ -92014,7 +92022,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92014
92022
  _this.syncContentInteraction(hoverShellInteractiveId);
92015
92023
  }
92016
92024
  };
92017
- this.handleContainerMouseLeave = function() {
92025
+ this.handleContainerMouseLeave = function(event) {
92026
+ if (_this.isMouseLeaveWithinContainer(event)) {
92027
+ return;
92028
+ }
92018
92029
  if (_this.contentInteractionFrame !== undefined) {
92019
92030
  cancelAnimationFrame(_this.contentInteractionFrame);
92020
92031
  _this.contentInteractionFrame = undefined;
@@ -92255,6 +92266,17 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92255
92266
  this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
92256
92267
  this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
92257
92268
  };
92269
+ _proto.isMouseLeaveWithinContainer = function isMouseLeaveWithinContainer(event) {
92270
+ var relatedTarget = event.relatedTarget;
92271
+ if (!relatedTarget) {
92272
+ return false;
92273
+ }
92274
+ try {
92275
+ return this.options.container.contains(relatedTarget);
92276
+ } catch (unused) {
92277
+ return false;
92278
+ }
92279
+ };
92258
92280
  _proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
92259
92281
  if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
92260
92282
  return false;
@@ -92550,8 +92572,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92550
92572
  return undefined;
92551
92573
  };
92552
92574
  _proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
92553
- var zone = this.getContentInteractiveZoneByEvent(event);
92554
- this.setActiveContentInteraction(zone);
92575
+ var decision = this.resolveHTMLInteractionTarget(event);
92576
+ this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
92555
92577
  };
92556
92578
  _proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
92557
92579
  var _this = this;
@@ -92575,7 +92597,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92575
92597
  _proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
92576
92598
  var _this = this;
92577
92599
  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)) {
92600
+ 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)) {
92579
92601
  return;
92580
92602
  }
92581
92603
  this.state.activeContentInteraction = zone;
@@ -92590,22 +92612,65 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92590
92612
  _this.syncContentInteraction(id);
92591
92613
  });
92592
92614
  };
92593
- _proto.getContentInteractiveZoneByEvent = function getContentInteractiveZoneByEvent(event) {
92615
+ _proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
92594
92616
  var id = this.getHTMLCardIdByEvent(event);
92595
92617
  if (!id || this.isEditableCard(id)) {
92596
- return undefined;
92618
+ return {
92619
+ kind: 'canvas',
92620
+ id: id
92621
+ };
92597
92622
  }
92598
92623
  var contentOverlay = this.state.contentElements.get(id);
92599
92624
  if (!contentOverlay) {
92600
- return undefined;
92625
+ return {
92626
+ kind: 'canvas',
92627
+ id: id
92628
+ };
92601
92629
  }
92602
- var zone = this.getContentInteractionZones(id, contentOverlay).find(function(zone) {
92630
+ var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
92631
+ if (activeSubtree) {
92632
+ return {
92633
+ kind: 'html',
92634
+ interaction: activeSubtree
92635
+ };
92636
+ }
92637
+ var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
92603
92638
  return isMouseEventInsideRect(event, zone.rect);
92604
92639
  });
92605
- return zone ? {
92606
- id: id,
92607
- element: zone.element
92608
- } : undefined;
92640
+ var zone = this.resolveContentInteractionZone(matchedZones);
92641
+ if (zone) {
92642
+ return {
92643
+ kind: 'html',
92644
+ interaction: {
92645
+ id: id,
92646
+ element: zone.element,
92647
+ zone: zone.zone
92648
+ }
92649
+ };
92650
+ }
92651
+ return {
92652
+ kind: 'canvas',
92653
+ id: id
92654
+ };
92655
+ };
92656
+ _proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
92657
+ var activeInteraction = this.state.activeContentInteraction;
92658
+ if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
92659
+ return undefined;
92660
+ }
92661
+ var rect = activeInteraction.element.getBoundingClientRect();
92662
+ return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
92663
+ };
92664
+ _proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
92665
+ if (zones.length <= 1) {
92666
+ return zones[0];
92667
+ }
92668
+ var subtreeRoot = zones.find(function(candidate) {
92669
+ return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
92670
+ return zone.element !== candidate.element && candidate.element.contains(zone.element);
92671
+ });
92672
+ });
92673
+ return subtreeRoot != null ? subtreeRoot : zones[0];
92609
92674
  };
92610
92675
  _proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
92611
92676
  var _this = this;
@@ -92618,7 +92683,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92618
92683
  }).map(function(element) {
92619
92684
  return {
92620
92685
  element: element,
92621
- rect: element.getBoundingClientRect()
92686
+ rect: element.getBoundingClientRect(),
92687
+ zone: _this.getContentInteractionZoneMode(element)
92622
92688
  };
92623
92689
  });
92624
92690
  this.state.contentInteractionZones.set(id, zones);
@@ -92648,6 +92714,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92648
92714
  }
92649
92715
  return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
92650
92716
  };
92717
+ _proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
92718
+ var zone = element.dataset.vvfxHtmlInteractionZone;
92719
+ return zone === 'subtree' ? 'subtree' : 'self';
92720
+ };
92651
92721
  _proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
92652
92722
  if (id) {
92653
92723
  var _this_state_contentInteractionResizeCleanups_get;
@@ -92760,11 +92830,11 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92760
92830
  var _this_state_editing, _this_state_activeContentInteraction;
92761
92831
  var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
92762
92832
  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;
92764
92833
  var overlay = this.state.elements.get(id);
92765
92834
  var scaleOverlay = this.state.contentScaleElements.get(id);
92766
92835
  var contentOverlay = this.state.contentElements.get(id);
92767
92836
  var contentMount = this.state.contentMountElements.get(id);
92837
+ var isInteractive = isEditing || !!activeInteraction;
92768
92838
  if (overlay) {
92769
92839
  overlay.dataset.editing = isEditing ? 'true' : 'false';
92770
92840
  overlay.style.pointerEvents = 'none';
@@ -92782,7 +92852,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92782
92852
  iframe.tabIndex = isActiveIframe ? 0 : -1;
92783
92853
  });
92784
92854
  this.syncShellInteraction(id, contentOverlay, isInteractive);
92785
- this.syncContentInteractionZones(id, contentOverlay, activeInteraction == null ? void 0 : activeInteraction.element, isEditing, isInteractive);
92855
+ this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
92786
92856
  }
92787
92857
  if (contentMount) {
92788
92858
  contentMount.dataset.editing = isEditing ? 'true' : 'false';
@@ -92795,19 +92865,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
92795
92865
  }
92796
92866
  }
92797
92867
  };
92798
- _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeElement, isEditing, isInteractive) {
92868
+ _proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
92799
92869
  var _this = this;
92870
+ var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
92800
92871
  contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
92801
- if (!isInteractive || _this.isContentInteractionDisabled(element)) {
92872
+ if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
92873
+ _this.clearContentInteractionState(element);
92874
+ return;
92875
+ }
92876
+ if (!isInteractive) {
92877
+ _this.clearContentInteractionState(element);
92878
+ return;
92879
+ }
92880
+ if (_this.isContentInteractionDisabled(element)) {
92802
92881
  element.dataset.vvfxHtmlInteractionActive = 'false';
92803
92882
  element.style.pointerEvents = 'none';
92804
92883
  return;
92805
92884
  }
92806
- var isElementInteractive = isEditing || activeElement === element;
92885
+ var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
92807
92886
  element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
92808
92887
  element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
92809
92888
  });
92810
92889
  };
92890
+ _proto.clearContentInteractionState = function clearContentInteractionState(element) {
92891
+ delete element.dataset.vvfxHtmlInteractionActive;
92892
+ element.style.pointerEvents = '';
92893
+ };
92811
92894
  _proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
92812
92895
  var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
92813
92896
  var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
@@ -95224,8 +95307,7 @@ var SDK = /*#__PURE__*/ function() {
95224
95307
  * @param ignoreClamp 是否忽视约束
95225
95308
  */ _proto.setPageZoom = function setPageZoom(zoom, center, ignoreClamp) {
95226
95309
  EFFECTS.assertExist(this._pageData);
95227
- this._pageData.property.zoom = zoom;
95228
- this._pageDataUtils.setPageZoom(this._pageData.property.zoom, center, ignoreClamp);
95310
+ this._pageDataUtils.setPageZoom(zoom, center, ignoreClamp);
95229
95311
  this._gestureHandler.render();
95230
95312
  };
95231
95313
  /**