@vvfx/sdk 0.2.2-beta.6 → 0.2.2-beta.8
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 +7 -1
- package/dist/index.js +110 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +110 -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,14 @@ export declare class HTMLOverlayManager {
|
|
|
80
81
|
private syncActiveContentInteraction;
|
|
81
82
|
private scheduleActiveContentInteractionSync;
|
|
82
83
|
private setActiveContentInteraction;
|
|
83
|
-
private
|
|
84
|
+
private shouldKeepActiveContentInteractionForFocusedElement;
|
|
85
|
+
private resolveHTMLInteractionTarget;
|
|
86
|
+
private getActiveSubtreeInteractionAtEvent;
|
|
87
|
+
private resolveContentInteractionZone;
|
|
84
88
|
private getContentInteractionZones;
|
|
85
89
|
private getContentInteractiveSelector;
|
|
86
90
|
private isContentInteractionDisabled;
|
|
91
|
+
private getContentInteractionZoneMode;
|
|
87
92
|
private invalidateContentInteractionZones;
|
|
88
93
|
private observeContentInteractionZoneResizes;
|
|
89
94
|
private getLayerPoint;
|
|
@@ -93,6 +98,7 @@ export declare class HTMLOverlayManager {
|
|
|
93
98
|
private requestAutoHeightFromIframes;
|
|
94
99
|
private syncContentInteraction;
|
|
95
100
|
private syncContentInteractionZones;
|
|
101
|
+
private clearContentInteractionState;
|
|
96
102
|
private syncShellInteraction;
|
|
97
103
|
private enterEditing;
|
|
98
104
|
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.8
|
|
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,11 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92540
92553
|
return undefined;
|
|
92541
92554
|
};
|
|
92542
92555
|
_proto.syncActiveContentInteraction = function syncActiveContentInteraction(event) {
|
|
92543
|
-
var
|
|
92544
|
-
this.
|
|
92556
|
+
var decision = this.resolveHTMLInteractionTarget(event);
|
|
92557
|
+
if (decision.kind === 'canvas' && this.shouldKeepActiveContentInteractionForFocusedElement()) {
|
|
92558
|
+
return;
|
|
92559
|
+
}
|
|
92560
|
+
this.setActiveContentInteraction(decision.kind === 'html' ? decision.interaction : undefined);
|
|
92545
92561
|
};
|
|
92546
92562
|
_proto.scheduleActiveContentInteractionSync = function scheduleActiveContentInteractionSync(event) {
|
|
92547
92563
|
var _this = this;
|
|
@@ -92565,7 +92581,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92565
92581
|
_proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
|
|
92566
92582
|
var _this = this;
|
|
92567
92583
|
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)) {
|
|
92584
|
+
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
92585
|
return;
|
|
92570
92586
|
}
|
|
92571
92587
|
this.state.activeContentInteraction = zone;
|
|
@@ -92580,22 +92596,77 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92580
92596
|
_this.syncContentInteraction(id);
|
|
92581
92597
|
});
|
|
92582
92598
|
};
|
|
92583
|
-
_proto.
|
|
92599
|
+
_proto.shouldKeepActiveContentInteractionForFocusedElement = function shouldKeepActiveContentInteractionForFocusedElement() {
|
|
92600
|
+
var activeInteraction = this.state.activeContentInteraction;
|
|
92601
|
+
if (!activeInteraction || typeof document === 'undefined') {
|
|
92602
|
+
return false;
|
|
92603
|
+
}
|
|
92604
|
+
var activeElement = document.activeElement;
|
|
92605
|
+
if (!activeElement || activeElement === document.body) {
|
|
92606
|
+
return false;
|
|
92607
|
+
}
|
|
92608
|
+
var interactionElement = activeInteraction.element;
|
|
92609
|
+
return interactionElement === activeElement || typeof interactionElement.contains === 'function' && interactionElement.contains(activeElement);
|
|
92610
|
+
};
|
|
92611
|
+
_proto.resolveHTMLInteractionTarget = function resolveHTMLInteractionTarget(event) {
|
|
92584
92612
|
var id = this.getHTMLCardIdByEvent(event);
|
|
92585
92613
|
if (!id || this.isEditableCard(id)) {
|
|
92586
|
-
return
|
|
92614
|
+
return {
|
|
92615
|
+
kind: 'canvas',
|
|
92616
|
+
id: id
|
|
92617
|
+
};
|
|
92587
92618
|
}
|
|
92588
92619
|
var contentOverlay = this.state.contentElements.get(id);
|
|
92589
92620
|
if (!contentOverlay) {
|
|
92590
|
-
return
|
|
92621
|
+
return {
|
|
92622
|
+
kind: 'canvas',
|
|
92623
|
+
id: id
|
|
92624
|
+
};
|
|
92625
|
+
}
|
|
92626
|
+
var activeSubtree = this.getActiveSubtreeInteractionAtEvent(id, event);
|
|
92627
|
+
if (activeSubtree) {
|
|
92628
|
+
return {
|
|
92629
|
+
kind: 'html',
|
|
92630
|
+
interaction: activeSubtree
|
|
92631
|
+
};
|
|
92591
92632
|
}
|
|
92592
|
-
var
|
|
92633
|
+
var matchedZones = this.getContentInteractionZones(id, contentOverlay).filter(function(zone) {
|
|
92593
92634
|
return isMouseEventInsideRect(event, zone.rect);
|
|
92594
92635
|
});
|
|
92595
|
-
|
|
92596
|
-
|
|
92597
|
-
|
|
92598
|
-
|
|
92636
|
+
var zone = this.resolveContentInteractionZone(matchedZones);
|
|
92637
|
+
if (zone) {
|
|
92638
|
+
return {
|
|
92639
|
+
kind: 'html',
|
|
92640
|
+
interaction: {
|
|
92641
|
+
id: id,
|
|
92642
|
+
element: zone.element,
|
|
92643
|
+
zone: zone.zone
|
|
92644
|
+
}
|
|
92645
|
+
};
|
|
92646
|
+
}
|
|
92647
|
+
return {
|
|
92648
|
+
kind: 'canvas',
|
|
92649
|
+
id: id
|
|
92650
|
+
};
|
|
92651
|
+
};
|
|
92652
|
+
_proto.getActiveSubtreeInteractionAtEvent = function getActiveSubtreeInteractionAtEvent(id, event) {
|
|
92653
|
+
var activeInteraction = this.state.activeContentInteraction;
|
|
92654
|
+
if ((activeInteraction == null ? void 0 : activeInteraction.id) !== id || activeInteraction.zone !== 'subtree') {
|
|
92655
|
+
return undefined;
|
|
92656
|
+
}
|
|
92657
|
+
var rect = activeInteraction.element.getBoundingClientRect();
|
|
92658
|
+
return isMouseEventInsideRect(event, rect) ? activeInteraction : undefined;
|
|
92659
|
+
};
|
|
92660
|
+
_proto.resolveContentInteractionZone = function resolveContentInteractionZone(zones) {
|
|
92661
|
+
if (zones.length <= 1) {
|
|
92662
|
+
return zones[0];
|
|
92663
|
+
}
|
|
92664
|
+
var subtreeRoot = zones.find(function(candidate) {
|
|
92665
|
+
return candidate.zone === 'subtree' && typeof candidate.element.contains === 'function' && zones.some(function(zone) {
|
|
92666
|
+
return zone.element !== candidate.element && candidate.element.contains(zone.element);
|
|
92667
|
+
});
|
|
92668
|
+
});
|
|
92669
|
+
return subtreeRoot != null ? subtreeRoot : zones[0];
|
|
92599
92670
|
};
|
|
92600
92671
|
_proto.getContentInteractionZones = function getContentInteractionZones(id, contentOverlay) {
|
|
92601
92672
|
var _this = this;
|
|
@@ -92608,7 +92679,8 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92608
92679
|
}).map(function(element) {
|
|
92609
92680
|
return {
|
|
92610
92681
|
element: element,
|
|
92611
|
-
rect: element.getBoundingClientRect()
|
|
92682
|
+
rect: element.getBoundingClientRect(),
|
|
92683
|
+
zone: _this.getContentInteractionZoneMode(element)
|
|
92612
92684
|
};
|
|
92613
92685
|
});
|
|
92614
92686
|
this.state.contentInteractionZones.set(id, zones);
|
|
@@ -92638,6 +92710,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92638
92710
|
}
|
|
92639
92711
|
return !!element.closest(CONTENT_INTERACTION_NONE_SELECTOR);
|
|
92640
92712
|
};
|
|
92713
|
+
_proto.getContentInteractionZoneMode = function getContentInteractionZoneMode(element) {
|
|
92714
|
+
var zone = element.dataset.vvfxHtmlInteractionZone;
|
|
92715
|
+
return zone === 'subtree' ? 'subtree' : 'self';
|
|
92716
|
+
};
|
|
92641
92717
|
_proto.invalidateContentInteractionZones = function invalidateContentInteractionZones(id) {
|
|
92642
92718
|
if (id) {
|
|
92643
92719
|
var _this_state_contentInteractionResizeCleanups_get;
|
|
@@ -92750,11 +92826,11 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92750
92826
|
var _this_state_editing, _this_state_activeContentInteraction;
|
|
92751
92827
|
var isEditing = ((_this_state_editing = this.state.editing) == null ? void 0 : _this_state_editing.id) === id;
|
|
92752
92828
|
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
92829
|
var overlay = this.state.elements.get(id);
|
|
92755
92830
|
var scaleOverlay = this.state.contentScaleElements.get(id);
|
|
92756
92831
|
var contentOverlay = this.state.contentElements.get(id);
|
|
92757
92832
|
var contentMount = this.state.contentMountElements.get(id);
|
|
92833
|
+
var isInteractive = isEditing || !!activeInteraction;
|
|
92758
92834
|
if (overlay) {
|
|
92759
92835
|
overlay.dataset.editing = isEditing ? 'true' : 'false';
|
|
92760
92836
|
overlay.style.pointerEvents = 'none';
|
|
@@ -92772,7 +92848,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92772
92848
|
iframe.tabIndex = isActiveIframe ? 0 : -1;
|
|
92773
92849
|
});
|
|
92774
92850
|
this.syncShellInteraction(id, contentOverlay, isInteractive);
|
|
92775
|
-
this.syncContentInteractionZones(id, contentOverlay, activeInteraction
|
|
92851
|
+
this.syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive);
|
|
92776
92852
|
}
|
|
92777
92853
|
if (contentMount) {
|
|
92778
92854
|
contentMount.dataset.editing = isEditing ? 'true' : 'false';
|
|
@@ -92785,19 +92861,32 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92785
92861
|
}
|
|
92786
92862
|
}
|
|
92787
92863
|
};
|
|
92788
|
-
_proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay,
|
|
92864
|
+
_proto.syncContentInteractionZones = function syncContentInteractionZones(id, contentOverlay, activeInteraction, isEditing, isInteractive) {
|
|
92789
92865
|
var _this = this;
|
|
92866
|
+
var activeElement = activeInteraction == null ? void 0 : activeInteraction.element;
|
|
92790
92867
|
contentOverlay.querySelectorAll(this.getContentInteractiveSelector(id)).forEach(function(element) {
|
|
92791
|
-
if (
|
|
92868
|
+
if ((activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && activeElement && element !== activeElement && typeof activeElement.contains === 'function' && activeElement.contains(element)) {
|
|
92869
|
+
_this.clearContentInteractionState(element);
|
|
92870
|
+
return;
|
|
92871
|
+
}
|
|
92872
|
+
if (!isInteractive) {
|
|
92873
|
+
_this.clearContentInteractionState(element);
|
|
92874
|
+
return;
|
|
92875
|
+
}
|
|
92876
|
+
if (_this.isContentInteractionDisabled(element)) {
|
|
92792
92877
|
element.dataset.vvfxHtmlInteractionActive = 'false';
|
|
92793
92878
|
element.style.pointerEvents = 'none';
|
|
92794
92879
|
return;
|
|
92795
92880
|
}
|
|
92796
|
-
var isElementInteractive = isEditing || activeElement === element;
|
|
92881
|
+
var isElementInteractive = isEditing || activeElement === element || (activeInteraction == null ? void 0 : activeInteraction.zone) === 'subtree' && typeof (activeElement == null ? void 0 : activeElement.contains) === 'function' && activeElement.contains(element);
|
|
92797
92882
|
element.dataset.vvfxHtmlInteractionActive = isElementInteractive ? 'true' : 'false';
|
|
92798
92883
|
element.style.pointerEvents = isElementInteractive ? 'auto' : 'none';
|
|
92799
92884
|
});
|
|
92800
92885
|
};
|
|
92886
|
+
_proto.clearContentInteractionState = function clearContentInteractionState(element) {
|
|
92887
|
+
delete element.dataset.vvfxHtmlInteractionActive;
|
|
92888
|
+
element.style.pointerEvents = '';
|
|
92889
|
+
};
|
|
92801
92890
|
_proto.syncShellInteraction = function syncShellInteraction(id, contentOverlay, isInteractive) {
|
|
92802
92891
|
var isHoveringShellInteractive = this.state.hoverShellInteractiveId === id;
|
|
92803
92892
|
var isShellInteractiveActive = isInteractive || isHoveringShellInteractive;
|