@vvfx/sdk 0.2.2-beta.6 → 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/html-overlay/manager.d.ts +6 -1
- package/dist/index.js +95 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +95 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -62,6 +62,7 @@ export declare class HTMLOverlayManager {
|
|
|
62
62
|
private handleContainerMouseDown;
|
|
63
63
|
private handleContainerMouseMove;
|
|
64
64
|
private handleContainerMouseLeave;
|
|
65
|
+
private isMouseLeaveWithinContainer;
|
|
65
66
|
private handleContainerContextMenu;
|
|
66
67
|
private isHTMLContextMenuEvent;
|
|
67
68
|
private handleViewportTransform;
|
|
@@ -80,10 +81,13 @@ export declare class HTMLOverlayManager {
|
|
|
80
81
|
private syncActiveContentInteraction;
|
|
81
82
|
private scheduleActiveContentInteractionSync;
|
|
82
83
|
private setActiveContentInteraction;
|
|
83
|
-
private
|
|
84
|
+
private resolveHTMLInteractionTarget;
|
|
85
|
+
private getActiveSubtreeInteractionAtEvent;
|
|
86
|
+
private resolveContentInteractionZone;
|
|
84
87
|
private getContentInteractionZones;
|
|
85
88
|
private getContentInteractiveSelector;
|
|
86
89
|
private isContentInteractionDisabled;
|
|
90
|
+
private getContentInteractionZoneMode;
|
|
87
91
|
private invalidateContentInteractionZones;
|
|
88
92
|
private observeContentInteractionZoneResizes;
|
|
89
93
|
private getLayerPoint;
|
|
@@ -93,6 +97,7 @@ export declare class HTMLOverlayManager {
|
|
|
93
97
|
private requestAutoHeightFromIframes;
|
|
94
98
|
private syncContentInteraction;
|
|
95
99
|
private syncContentInteractionZones;
|
|
100
|
+
private clearContentInteractionState;
|
|
96
101
|
private syncShellInteraction;
|
|
97
102
|
private enterEditing;
|
|
98
103
|
private exitEditing;
|
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.
|
|
6
|
+
* Version: v0.2.2-beta.7
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
@@ -91913,8 +91913,8 @@ function mountHTMLShell(container, content, shell) {
|
|
|
91913
91913
|
var SHELL_INTERACTIVE_SELECTOR = '[data-vvfx-html-shell-interactive="true"]';
|
|
91914
91914
|
var EDITING_INTERACTIVE_SELECTOR = '[data-vvfx-html-editing-interactive="true"]';
|
|
91915
91915
|
var CONTENT_INTERACTIVE_SELECTOR = [
|
|
91916
|
-
'[data-interaction-zone="self"]',
|
|
91917
91916
|
'[data-vvfx-html-interaction-zone="self"]',
|
|
91917
|
+
'[data-vvfx-html-interaction-zone="subtree"]',
|
|
91918
91918
|
'a[href]',
|
|
91919
91919
|
'button:not([disabled])',
|
|
91920
91920
|
'input:not([disabled])',
|
|
@@ -91930,7 +91930,6 @@ var CONTENT_INTERACTIVE_SELECTOR = [
|
|
|
91930
91930
|
'[tabindex]:not([tabindex="-1"])'
|
|
91931
91931
|
].join(', ');
|
|
91932
91932
|
var CONTENT_INTERACTION_NONE_SELECTOR = [
|
|
91933
|
-
'[data-interaction-zone="none"]',
|
|
91934
91933
|
'[data-vvfx-html-interaction-zone="none"]'
|
|
91935
91934
|
].join(', ');
|
|
91936
91935
|
var EDITING_VIEWPORT_PADDING = 48;
|
|
@@ -92004,7 +92003,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92004
92003
|
_this.syncContentInteraction(hoverShellInteractiveId);
|
|
92005
92004
|
}
|
|
92006
92005
|
};
|
|
92007
|
-
this.handleContainerMouseLeave = function() {
|
|
92006
|
+
this.handleContainerMouseLeave = function(event) {
|
|
92007
|
+
if (_this.isMouseLeaveWithinContainer(event)) {
|
|
92008
|
+
return;
|
|
92009
|
+
}
|
|
92008
92010
|
if (_this.contentInteractionFrame !== undefined) {
|
|
92009
92011
|
cancelAnimationFrame(_this.contentInteractionFrame);
|
|
92010
92012
|
_this.contentInteractionFrame = undefined;
|
|
@@ -92245,6 +92247,17 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92245
92247
|
this.options.container.addEventListener('mouseleave', this.handleContainerMouseLeave, true);
|
|
92246
92248
|
this.options.container.addEventListener('contextmenu', this.handleContainerContextMenu, true);
|
|
92247
92249
|
};
|
|
92250
|
+
_proto.isMouseLeaveWithinContainer = function isMouseLeaveWithinContainer(event) {
|
|
92251
|
+
var relatedTarget = event.relatedTarget;
|
|
92252
|
+
if (!relatedTarget) {
|
|
92253
|
+
return false;
|
|
92254
|
+
}
|
|
92255
|
+
try {
|
|
92256
|
+
return this.options.container.contains(relatedTarget);
|
|
92257
|
+
} catch (unused) {
|
|
92258
|
+
return false;
|
|
92259
|
+
}
|
|
92260
|
+
};
|
|
92248
92261
|
_proto.isHTMLContextMenuEvent = function isHTMLContextMenuEvent(event) {
|
|
92249
92262
|
if (typeof Element !== 'function' || !_instanceof(event.target, Element)) {
|
|
92250
92263
|
return false;
|
|
@@ -92540,8 +92553,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92540
92553
|
return undefined;
|
|
92541
92554
|
};
|
|
92542
92555
|
_proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
|
|
92543
|
-
var
|
|
92544
|
-
this.setActiveContentInteraction(
|
|
92556
|
+
var decision = this.resolveHTMLInteractionTarget(event);
|
|
92557
|
+
this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
|
|
92545
92558
|
};
|
|
92546
92559
|
_proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
|
|
92547
92560
|
var _this = this;
|
|
@@ -92565,7 +92578,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92565
92578
|
_proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
|
|
92566
92579
|
var _this = this;
|
|
92567
92580
|
var previous = this.state.activeContentInteraction;
|
|
92568
|
-
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)) {
|
|
92581
|
+
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)) {
|
|
92569
92582
|
return;
|
|
92570
92583
|
}
|
|
92571
92584
|
this.state.activeContentInteraction = zone;
|
|
@@ -92580,22 +92593,65 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92580
92593
|
_this.syncContentInteraction(id);
|
|
92581
92594
|
});
|
|
92582
92595
|
};
|
|
92583
|
-
_proto.
|
|
92596
|
+
_proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
|
|
92584
92597
|
var id = this.getHTMLCardIdByEvent(event);
|
|
92585
92598
|
if (!id || this.isEditableCard(id)) {
|
|
92586
|
-
return
|
|
92599
|
+
return {
|
|
92600
|
+
kind: 'canvas',
|
|
92601
|
+
id: id
|
|
92602
|
+
};
|
|
92587
92603
|
}
|
|
92588
92604
|
var contentOverlay = this.state.contentElements.get(id);
|
|
92589
92605
|
if (!contentOverlay) {
|
|
92590
|
-
return
|
|
92606
|
+
return {
|
|
92607
|
+
kind: 'canvas',
|
|
92608
|
+
id: id
|
|
92609
|
+
};
|
|
92591
92610
|
}
|
|
92592
|
-
var
|
|
92611
|
+
var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
|
|
92612
|
+
if (activeSubtree) {
|
|
92613
|
+
return {
|
|
92614
|
+
kind: 'html',
|
|
92615
|
+
interaction: activeSubtree
|
|
92616
|
+
};
|
|
92617
|
+
}
|
|
92618
|
+
var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
|
|
92593
92619
|
return isMouseEventInsideRect(event, zone.rect);
|
|
92594
92620
|
});
|
|
92595
|
-
|
|
92596
|
-
|
|
92597
|
-
|
|
92598
|
-
|
|
92621
|
+
var zone = this.resolveContentInteractionZone(matchedZones);
|
|
92622
|
+
if (zone) {
|
|
92623
|
+
return {
|
|
92624
|
+
kind: 'html',
|
|
92625
|
+
interaction: {
|
|
92626
|
+
id: id,
|
|
92627
|
+
element: zone.element,
|
|
92628
|
+
zone: zone.zone
|
|
92629
|
+
}
|
|
92630
|
+
};
|
|
92631
|
+
}
|
|
92632
|
+
return {
|
|
92633
|
+
kind: 'canvas',
|
|
92634
|
+
id: id
|
|
92635
|
+
};
|
|
92636
|
+
};
|
|
92637
|
+
_proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
|
|
92638
|
+
var activeInteraction = this.state.activeContentInteraction;
|
|
92639
|
+
if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
|
|
92640
|
+
return undefined;
|
|
92641
|
+
}
|
|
92642
|
+
var rect = activeInteraction.element.getBoundingClientRect();
|
|
92643
|
+
return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
|
|
92644
|
+
};
|
|
92645
|
+
_proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
|
|
92646
|
+
if (zones.length <= 1) {
|
|
92647
|
+
return zones[0];
|
|
92648
|
+
}
|
|
92649
|
+
var subtreeRoot = zones.find(function(candidate) {
|
|
92650
|
+
return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
|
|
92651
|
+
return zone.element !== candidate.element && candidate.element.contains(zone.element);
|
|
92652
|
+
});
|
|
92653
|
+
});
|
|
92654
|
+
return subtreeRoot != null ? subtreeRoot : zones[0];
|
|
92599
92655
|
};
|
|
92600
92656
|
_proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
|
|
92601
92657
|
var _this = this;
|
|
@@ -92608,7 +92664,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92608
92664
|
}).map(function(element) {
|
|
92609
92665
|
return {
|
|
92610
92666
|
element: element,
|
|
92611
|
-
rect: element.getBoundingClientRect()
|
|
92667
|
+
rect: element.getBoundingClientRect(),
|
|
92668
|
+
zone: _this.getContentInteractionZoneMode(element)
|
|
92612
92669
|
};
|
|
92613
92670
|
});
|
|
92614
92671
|
this.state.contentInteractionZones.set(id, zones);
|
|
@@ -92638,6 +92695,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92638
92695
|
}
|
|
92639
92696
|
return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
|
|
92640
92697
|
};
|
|
92698
|
+
_proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
|
|
92699
|
+
var zone = element.dataset.vvfxHtmlInteractionZone;
|
|
92700
|
+
return zone === 'subtree' ? 'subtree' : 'self';
|
|
92701
|
+
};
|
|
92641
92702
|
_proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
|
|
92642
92703
|
if (id) {
|
|
92643
92704
|
var _this_state_contentInteractionResizeCleanups_get;
|
|
@@ -92750,11 +92811,11 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92750
92811
|
var _this_state_editing, _this_state_activeContentInteraction;
|
|
92751
92812
|
var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
|
|
92752
92813
|
var activeInteraction = ((_this_state_activeContentInteraction = this.state.activeContentInteraction) == null ? void 0 : _this_state_activeContentInteraction.id) === id ? this.state.activeContentInteraction : undefined;
|
|
92753
|
-
var isInteractive = isEditing || !!activeInteraction;
|
|
92754
92814
|
var overlay = this.state.elements.get(id);
|
|
92755
92815
|
var scaleOverlay = this.state.contentScaleElements.get(id);
|
|
92756
92816
|
var contentOverlay = this.state.contentElements.get(id);
|
|
92757
92817
|
var contentMount = this.state.contentMountElements.get(id);
|
|
92818
|
+
var isInteractive = isEditing || !!activeInteraction;
|
|
92758
92819
|
if (overlay) {
|
|
92759
92820
|
overlay.dataset.editing = isEditing ? 'true' : 'false';
|
|
92760
92821
|
overlay.style.pointerEvents = 'none';
|
|
@@ -92772,7 +92833,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92772
92833
|
iframe.tabIndex = isActiveIframe ? 0 : -1;
|
|
92773
92834
|
});
|
|
92774
92835
|
this.syncShellInteraction(id, contentOverlay, isInteractive);
|
|
92775
|
-
this.syncContentInteractionZones(id, contentOverlay, activeInteraction
|
|
92836
|
+
this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
|
|
92776
92837
|
}
|
|
92777
92838
|
if (contentMount) {
|
|
92778
92839
|
contentMount.dataset.editing = isEditing ? 'true' : 'false';
|
|
@@ -92785,19 +92846,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92785
92846
|
}
|
|
92786
92847
|
}
|
|
92787
92848
|
};
|
|
92788
|
-
_proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay,
|
|
92849
|
+
_proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
|
|
92789
92850
|
var _this = this;
|
|
92851
|
+
var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
|
|
92790
92852
|
contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
|
|
92791
|
-
if (
|
|
92853
|
+
if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
|
|
92854
|
+
_this.clearContentInteractionState(element);
|
|
92855
|
+
return;
|
|
92856
|
+
}
|
|
92857
|
+
if (!isInteractive) {
|
|
92858
|
+
_this.clearContentInteractionState(element);
|
|
92859
|
+
return;
|
|
92860
|
+
}
|
|
92861
|
+
if (_this.isContentInteractionDisabled(element)) {
|
|
92792
92862
|
element.dataset.vvfxHtmlInteractionActive = 'false';
|
|
92793
92863
|
element.style.pointerEvents = 'none';
|
|
92794
92864
|
return;
|
|
92795
92865
|
}
|
|
92796
|
-
var isElementInteractive = isEditing || activeElement === element;
|
|
92866
|
+
var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
|
|
92797
92867
|
element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
|
|
92798
92868
|
element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
|
|
92799
92869
|
});
|
|
92800
92870
|
};
|
|
92871
|
+
_proto.clearContentInteractionState = function clearContentInteractionState(element) {
|
|
92872
|
+
delete element.dataset.vvfxHtmlInteractionActive;
|
|
92873
|
+
element.style.pointerEvents = '';
|
|
92874
|
+
};
|
|
92801
92875
|
_proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
|
|
92802
92876
|
var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
|
|
92803
92877
|
var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
|