@vvfx/sdk 0.2.2-beta.12 → 0.2.2-beta.13
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/config.d.ts +5 -0
- package/dist/html-overlay/manager.d.ts +12 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +170 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +170 -27
- package/dist/index.mjs.map +1 -1
- package/dist/sdk.d.ts +24 -0
- package/dist/types.d.ts +48 -0
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { CardHTML } from './types';
|
|
|
4
4
|
import type { CardItem } from './sdk-item/card-item';
|
|
5
5
|
export type SDKMode = 'editor' | 'template';
|
|
6
6
|
export type CardTypeHTMLResolver = (item: CardItem) => CardHTML | undefined;
|
|
7
|
+
export type CardAutoHeightAnchor = 'top' | 'center';
|
|
7
8
|
/**
|
|
8
9
|
* @description SDK功能配置
|
|
9
10
|
*/
|
|
@@ -147,6 +148,10 @@ export type CardTypeConfig = {
|
|
|
147
148
|
* @description 是否根据 HTML 挂载内容的自然高度自动更新卡片高度
|
|
148
149
|
*/
|
|
149
150
|
autoHeight?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* @description autoHeight 更新卡片高度时的锚点。top 保持上边缘不动,center 保持中心点不动。未配置时默认 top。
|
|
153
|
+
*/
|
|
154
|
+
autoHeightAnchor?: CardAutoHeightAnchor;
|
|
150
155
|
/**
|
|
151
156
|
* @description HTML 内容是否跟随卡片 scale 缩放,关闭后 HTML 按最终显示尺寸重新布局
|
|
152
157
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Box2 } from '../math';
|
|
2
2
|
import { type SnapdomOptions } from '@zumer/snapdom';
|
|
3
|
-
import type { CardTypeConfig } from '../config';
|
|
3
|
+
import type { CardAutoHeightAnchor, CardTypeConfig } from '../config';
|
|
4
4
|
import type { EventEmitter } from '../shared';
|
|
5
5
|
import type { SDKEvents } from '../sdk';
|
|
6
6
|
import { type SDKItem } from '../sdk-item';
|
|
@@ -11,6 +11,10 @@ type CardRasterizeOptions = {
|
|
|
11
11
|
pixelRatio?: number;
|
|
12
12
|
snapdomOptions?: SnapdomOptions;
|
|
13
13
|
};
|
|
14
|
+
type SetCardItemHeightOptions = {
|
|
15
|
+
anchor: CardAutoHeightAnchor;
|
|
16
|
+
previousHeight: number;
|
|
17
|
+
};
|
|
14
18
|
type HTMLOverlayManagerOptions = {
|
|
15
19
|
container: HTMLElement;
|
|
16
20
|
emitter: EventEmitter<SDKEvents>;
|
|
@@ -25,7 +29,7 @@ type HTMLOverlayManagerOptions = {
|
|
|
25
29
|
translation: [number, number];
|
|
26
30
|
}) => void;
|
|
27
31
|
viewportFit: (box: Box2) => void;
|
|
28
|
-
setCardItemHeight: (id: string, height: number) => void;
|
|
32
|
+
setCardItemHeight: (id: string, height: number, options: SetCardItemHeightOptions) => void;
|
|
29
33
|
getSelectedItemIds: () => string[];
|
|
30
34
|
getPreSelectedItemId: () => string | undefined;
|
|
31
35
|
getSelectionEdgeStyle: () => {
|
|
@@ -55,6 +59,9 @@ export declare class HTMLOverlayManager {
|
|
|
55
59
|
dispose(): void;
|
|
56
60
|
scheduleRender(): void;
|
|
57
61
|
invalidateCardHTML(id: string): void;
|
|
62
|
+
getHtmlCardWindow(id: string): Window | null | undefined;
|
|
63
|
+
patchCardHTML(id: string, patch: unknown): boolean;
|
|
64
|
+
dispatchHtmlCardEvent(id: string, type: string, detail?: unknown): boolean;
|
|
58
65
|
rasterizeCard(id: string, options: CardRasterizeOptions): Promise<string | undefined>;
|
|
59
66
|
private initEvents;
|
|
60
67
|
private initDOMEvents;
|
|
@@ -106,8 +113,10 @@ export declare class HTMLOverlayManager {
|
|
|
106
113
|
private getEditingFitZoom;
|
|
107
114
|
private isEventInsideOverlay;
|
|
108
115
|
private renderOverlayHTML;
|
|
116
|
+
private createPatchContext;
|
|
109
117
|
private observeContentInteractionZones;
|
|
110
118
|
private applyHTMLRootConfig;
|
|
119
|
+
private makeSelectionOverlayTransparent;
|
|
111
120
|
private renderOverlayContent;
|
|
112
121
|
private chainCleanups;
|
|
113
122
|
private cleanupOverlayContent;
|
|
@@ -122,6 +131,7 @@ export declare class HTMLOverlayManager {
|
|
|
122
131
|
private getChildrenNaturalHeight;
|
|
123
132
|
private cleanupAutoHeight;
|
|
124
133
|
private applyAutoHeight;
|
|
134
|
+
private getAutoHeightAnchor;
|
|
125
135
|
private getAutoHeightItemHeight;
|
|
126
136
|
private isAutoHeightMessage;
|
|
127
137
|
private isAutoHeightEnabled;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type { SDKOptions, SDKInputParam, PageData, PageProperty, ViewProperty, ActiveData, ViewParam, BaseItemProperty, SpriteItemProperty, TextItemProperty, VideoItemProperty, GeneratorItemProperty, FrameItemProperty, FrameLayoutMode, SpriteCreateInfo, TextCreateInfo, GroupCreateInfo, VideoCreateInfo, GeneratorCreateInfo, EffectsCreateInfo, FrameCreateInfo, CardCreateInfo, CardItemProperty, CardItemTransformInfo, CardHTML, CardHTMLContent, CardHTMLInlineContent, CardHTMLDOMRendererContent, CardHTMLDocumentContent, CardHTMLDocumentMessage, CardHTMLShellContent, CardHTMLShellRenderer, CardHTMLShellRendererContext, CardHTMLShellRendererResult, CardHTMLDOMRenderer, CardHTMLContentCleanup, CardHTMLRenderCleanup, CardHTMLRootConfig, CardHTMLRootStyle, ItemCreateInfo, } from './types';
|
|
2
|
-
export type { SDKConfig, SDKMode, CardTypeConfig, CardConfig, CardTypeHTMLResolver, } from './config';
|
|
1
|
+
export type { SDKOptions, SDKInputParam, PageData, PageProperty, ViewProperty, ActiveData, ViewParam, BaseItemProperty, SpriteItemProperty, TextItemProperty, VideoItemProperty, GeneratorItemProperty, FrameItemProperty, FrameLayoutMode, SpriteCreateInfo, TextCreateInfo, GroupCreateInfo, VideoCreateInfo, GeneratorCreateInfo, EffectsCreateInfo, FrameCreateInfo, CardCreateInfo, CardItemProperty, CardItemTransformInfo, CardHTML, CardHTMLContent, CardHTMLInlineContent, CardHTMLDOMRendererContent, CardHTMLDocumentContent, CardHTMLDocumentMessage, CardHTMLShellContent, CardHTMLShellRenderer, CardHTMLShellRendererContext, CardHTMLShellRendererResult, CardHTMLDOMRenderer, CardHTMLContentCleanup, CardHTMLRenderCleanup, CardHTMLPatchContext, CardHTMLPatchHandler, CardHTMLWindowEventMessage, CardHTMLRootConfig, CardHTMLRootStyle, ItemCreateInfo, } from './types';
|
|
2
|
+
export type { SDKConfig, SDKMode, CardTypeConfig, CardConfig, CardAutoHeightAnchor, CardTypeHTMLResolver, } from './config';
|
|
3
3
|
export type { SDKItem } from './sdk-item';
|
|
4
4
|
export { BaseItem, SpriteItem, TextItem, VideoItem, GroupItem, GeneratorItem, EffectsItem, FrameItem, CardItem, isBaseItem, isSpriteItem, isTextItem, isVideoItem, isGroupItem, isGeneratorItem, isEffectsItem, isFrameItem, isCardItem, SDKItemType, } from './sdk-item';
|
|
5
5
|
export type { SDKItemOptions, SpriteItemOptions, TextItemOptions, VideoItemOptions, GroupItemOptions, GeneratorItemOptions, EffectsItemOptions, FrameItemOptions, CardItemOptions, } from './sdk-item';
|
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.13
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as EFFECTS from '@galacean/effects';
|
|
@@ -91867,6 +91867,30 @@ var EDITING_VIEWPORT_PADDING = 48;
|
|
|
91867
91867
|
var EDITING_VIEWPORT_BOX_SCALE = 1.1;
|
|
91868
91868
|
var AUTO_HEIGHT_EPSILON = 0.5;
|
|
91869
91869
|
var CARD_RASTERIZE_READY_TIMEOUT = 3000;
|
|
91870
|
+
var CARD_HTML_EVENT_MESSAGE_SOURCE = 'vvfx-card-html-event';
|
|
91871
|
+
var requestHTMLOverlayFrame = function requestHTMLOverlayFrame(callback) {
|
|
91872
|
+
if (typeof requestAnimationFrame === 'function') {
|
|
91873
|
+
try {
|
|
91874
|
+
return requestAnimationFrame(callback);
|
|
91875
|
+
} catch (unused) {
|
|
91876
|
+
// Some non-browser test runtimes install a RAF polyfill that depends on window.
|
|
91877
|
+
}
|
|
91878
|
+
}
|
|
91879
|
+
return setTimeout(function() {
|
|
91880
|
+
callback(Date.now());
|
|
91881
|
+
}, 16);
|
|
91882
|
+
};
|
|
91883
|
+
var cancelHTMLOverlayFrame = function cancelHTMLOverlayFrame(frame) {
|
|
91884
|
+
if (typeof cancelAnimationFrame === 'function') {
|
|
91885
|
+
try {
|
|
91886
|
+
cancelAnimationFrame(frame);
|
|
91887
|
+
return;
|
|
91888
|
+
} catch (unused) {
|
|
91889
|
+
// Fall back to clearTimeout for frames created by requestHTMLOverlayFrame.
|
|
91890
|
+
}
|
|
91891
|
+
}
|
|
91892
|
+
clearTimeout(frame);
|
|
91893
|
+
};
|
|
91870
91894
|
var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
91871
91895
|
function HTMLOverlayManager(options) {
|
|
91872
91896
|
var _this = this;
|
|
@@ -91939,7 +91963,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
91939
91963
|
return;
|
|
91940
91964
|
}
|
|
91941
91965
|
if (_this.contentInteractionFrame !== undefined) {
|
|
91942
|
-
|
|
91966
|
+
cancelHTMLOverlayFrame(_this.contentInteractionFrame);
|
|
91943
91967
|
_this.contentInteractionFrame = undefined;
|
|
91944
91968
|
}
|
|
91945
91969
|
_this.pendingContentInteractionEvent = undefined;
|
|
@@ -92000,11 +92024,11 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92000
92024
|
_proto.dispose = function dispose() {
|
|
92001
92025
|
var _this_state_layer;
|
|
92002
92026
|
if (this.state.updateFrame !== undefined) {
|
|
92003
|
-
|
|
92027
|
+
cancelHTMLOverlayFrame(this.state.updateFrame);
|
|
92004
92028
|
this.state.updateFrame = undefined;
|
|
92005
92029
|
}
|
|
92006
92030
|
if (this.contentInteractionFrame !== undefined) {
|
|
92007
|
-
|
|
92031
|
+
cancelHTMLOverlayFrame(this.contentInteractionFrame);
|
|
92008
92032
|
this.contentInteractionFrame = undefined;
|
|
92009
92033
|
}
|
|
92010
92034
|
this.pendingContentInteractionEvent = undefined;
|
|
@@ -92034,7 +92058,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92034
92058
|
});
|
|
92035
92059
|
this.state.autoHeightCleanups.clear();
|
|
92036
92060
|
this.state.autoHeightFrames.forEach(function(frame) {
|
|
92037
|
-
|
|
92061
|
+
cancelHTMLOverlayFrame(frame);
|
|
92038
92062
|
});
|
|
92039
92063
|
this.state.autoHeightFrames.clear();
|
|
92040
92064
|
this.eventCleanups.forEach(function(cleanup) {
|
|
@@ -92053,9 +92077,9 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92053
92077
|
_proto.scheduleRender = function scheduleRender() {
|
|
92054
92078
|
var _this = this;
|
|
92055
92079
|
if (this.state.updateFrame !== undefined) {
|
|
92056
|
-
|
|
92080
|
+
cancelHTMLOverlayFrame(this.state.updateFrame);
|
|
92057
92081
|
}
|
|
92058
|
-
this.state.updateFrame =
|
|
92082
|
+
this.state.updateFrame = requestHTMLOverlayFrame(function() {
|
|
92059
92083
|
_this.state.updateFrame = undefined;
|
|
92060
92084
|
_this.render();
|
|
92061
92085
|
});
|
|
@@ -92064,6 +92088,40 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92064
92088
|
this.cleanupOverlayContent(id);
|
|
92065
92089
|
this.invalidateContentInteractionZones(id);
|
|
92066
92090
|
};
|
|
92091
|
+
_proto.getHtmlCardWindow = function getHtmlCardWindow(id) {
|
|
92092
|
+
var contentOverlay = this.state.contentElements.get(id);
|
|
92093
|
+
var iframe = contentOverlay == null ? void 0 : contentOverlay.querySelector('iframe');
|
|
92094
|
+
return iframe == null ? void 0 : iframe.contentWindow;
|
|
92095
|
+
};
|
|
92096
|
+
_proto.patchCardHTML = function patchCardHTML(id, patch) {
|
|
92097
|
+
var html = this.state.contents.get(id);
|
|
92098
|
+
if (!html) {
|
|
92099
|
+
return false;
|
|
92100
|
+
}
|
|
92101
|
+
var patchHandler = html.content.patch;
|
|
92102
|
+
if (!patchHandler) {
|
|
92103
|
+
return false;
|
|
92104
|
+
}
|
|
92105
|
+
var context = this.createPatchContext(id, html);
|
|
92106
|
+
return patchHandler(patch, context) !== false;
|
|
92107
|
+
};
|
|
92108
|
+
_proto.dispatchHtmlCardEvent = function dispatchHtmlCardEvent(id, type, detail) {
|
|
92109
|
+
var targetWindow = this.getHtmlCardWindow(id);
|
|
92110
|
+
try {
|
|
92111
|
+
if (!targetWindow || typeof targetWindow.postMessage !== 'function') {
|
|
92112
|
+
return false;
|
|
92113
|
+
}
|
|
92114
|
+
targetWindow.postMessage({
|
|
92115
|
+
detail: detail,
|
|
92116
|
+
payload: detail,
|
|
92117
|
+
source: CARD_HTML_EVENT_MESSAGE_SOURCE,
|
|
92118
|
+
type: type
|
|
92119
|
+
}, '*');
|
|
92120
|
+
return true;
|
|
92121
|
+
} catch (unused) {
|
|
92122
|
+
return false;
|
|
92123
|
+
}
|
|
92124
|
+
};
|
|
92067
92125
|
_proto.rasterizeCard = function rasterizeCard(id, options) {
|
|
92068
92126
|
return _async_to_generator(function() {
|
|
92069
92127
|
var contentOverlay, capture, _ref, _options_pixelRatio, image, error;
|
|
@@ -92071,7 +92129,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92071
92129
|
switch(_state.label){
|
|
92072
92130
|
case 0:
|
|
92073
92131
|
if (this.state.updateFrame !== undefined) {
|
|
92074
|
-
|
|
92132
|
+
cancelHTMLOverlayFrame(this.state.updateFrame);
|
|
92075
92133
|
this.state.updateFrame = undefined;
|
|
92076
92134
|
}
|
|
92077
92135
|
this.render();
|
|
@@ -92238,13 +92296,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92238
92296
|
var overlay = _this.getOrCreateOverlay(item.id, parentOverlay, elements);
|
|
92239
92297
|
var contentOverlay = _this.getOrCreateContentOverlay(item.id, overlay);
|
|
92240
92298
|
var selectionOverlay = _this.getOrCreateSelectionOverlay(item.id, selectionLayer);
|
|
92241
|
-
if (!_this.state.contents.has(item.id)) {
|
|
92242
|
-
_this.renderOverlayHTML(item.id, contentOverlay, html);
|
|
92243
|
-
}
|
|
92244
|
-
_this.applyHTMLRootConfig(overlay, html);
|
|
92245
92299
|
var offsetX = frameBox && !frameBox.isEmpty() ? frameBox.min.x : 0;
|
|
92246
92300
|
var offsetY = frameBox && !frameBox.isEmpty() ? frameBox.min.y : 0;
|
|
92247
92301
|
var boxStyle = getCardOverlayBoxStyle(itemBox, item.property.width, item.property.height, offsetX, offsetY, _this.isAutoScaleEnabled(item));
|
|
92302
|
+
_this.applyHTMLRootConfig(overlay, html);
|
|
92248
92303
|
overlay.style.left = boxStyle.left;
|
|
92249
92304
|
overlay.style.top = boxStyle.top;
|
|
92250
92305
|
overlay.style.width = boxStyle.width;
|
|
@@ -92259,8 +92314,12 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92259
92314
|
selectionOverlay.style.transform = selectionBoxStyle.transform;
|
|
92260
92315
|
selectionOverlay.style.transformOrigin = '0 0';
|
|
92261
92316
|
_this.applyHTMLRootConfig(selectionOverlay, html);
|
|
92317
|
+
_this.makeSelectionOverlayTransparent(selectionOverlay);
|
|
92262
92318
|
_this.syncOverlaySelection(item.id, overlay, selectionOverlay);
|
|
92263
92319
|
_this.syncContentScale(item.id, boxStyle.contentWidth, boxStyle.contentHeight);
|
|
92320
|
+
if (!_this.state.contents.has(item.id)) {
|
|
92321
|
+
_this.renderOverlayHTML(item.id, contentOverlay, html);
|
|
92322
|
+
}
|
|
92264
92323
|
_this.syncAutoHeight(item.id, _this.isAutoHeightEnabled(item));
|
|
92265
92324
|
_this.syncContentInteraction(item.id);
|
|
92266
92325
|
});
|
|
@@ -92500,14 +92559,20 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92500
92559
|
if (this.contentInteractionFrame !== undefined) {
|
|
92501
92560
|
return;
|
|
92502
92561
|
}
|
|
92503
|
-
|
|
92504
|
-
|
|
92505
|
-
|
|
92506
|
-
|
|
92507
|
-
|
|
92508
|
-
|
|
92509
|
-
|
|
92510
|
-
|
|
92562
|
+
try {
|
|
92563
|
+
this.contentInteractionFrame = requestAnimationFrame(function() {
|
|
92564
|
+
_this.contentInteractionFrame = undefined;
|
|
92565
|
+
var pendingEvent = _this.pendingContentInteractionEvent;
|
|
92566
|
+
_this.pendingContentInteractionEvent = undefined;
|
|
92567
|
+
if (pendingEvent) {
|
|
92568
|
+
_this.syncActiveContentInteraction(pendingEvent);
|
|
92569
|
+
}
|
|
92570
|
+
});
|
|
92571
|
+
} catch (unused) {
|
|
92572
|
+
this.contentInteractionFrame = undefined;
|
|
92573
|
+
this.pendingContentInteractionEvent = undefined;
|
|
92574
|
+
this.syncActiveContentInteraction(event);
|
|
92575
|
+
}
|
|
92511
92576
|
};
|
|
92512
92577
|
_proto.setActiveContentInteraction = function setActiveContentInteraction(zone) {
|
|
92513
92578
|
var _this = this;
|
|
@@ -92931,6 +92996,20 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92931
92996
|
});
|
|
92932
92997
|
this.state.contents.set(id, html);
|
|
92933
92998
|
};
|
|
92999
|
+
_proto.createPatchContext = function createPatchContext(id, html) {
|
|
93000
|
+
var _this = this;
|
|
93001
|
+
return {
|
|
93002
|
+
id: id,
|
|
93003
|
+
html: html,
|
|
93004
|
+
content: html.content,
|
|
93005
|
+
container: this.state.contentMountElements.get(id),
|
|
93006
|
+
contentWindow: this.getHtmlCardWindow(id),
|
|
93007
|
+
refresh: function refresh() {
|
|
93008
|
+
_this.invalidateCardHTML(id);
|
|
93009
|
+
_this.scheduleRender();
|
|
93010
|
+
}
|
|
93011
|
+
};
|
|
93012
|
+
};
|
|
92934
93013
|
_proto.observeContentInteractionZones = function observeContentInteractionZones(id, contentContainer) {
|
|
92935
93014
|
var _this = this;
|
|
92936
93015
|
var _this_state_contentInteractionZoneCleanups_get;
|
|
@@ -92990,6 +93069,10 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
92990
93069
|
});
|
|
92991
93070
|
});
|
|
92992
93071
|
};
|
|
93072
|
+
_proto.makeSelectionOverlayTransparent = function makeSelectionOverlayTransparent(selectionOverlay) {
|
|
93073
|
+
selectionOverlay.style.background = 'transparent';
|
|
93074
|
+
selectionOverlay.style.backgroundColor = 'transparent';
|
|
93075
|
+
};
|
|
92993
93076
|
_proto.renderOverlayContent = function renderOverlayContent(overlay, content, options) {
|
|
92994
93077
|
var _this = this;
|
|
92995
93078
|
switch(content.kind){
|
|
@@ -93182,7 +93265,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
93182
93265
|
if (this.state.autoHeightFrames.has(id)) {
|
|
93183
93266
|
return;
|
|
93184
93267
|
}
|
|
93185
|
-
var frame =
|
|
93268
|
+
var frame = requestHTMLOverlayFrame(function() {
|
|
93186
93269
|
_this.state.autoHeightFrames.delete(id);
|
|
93187
93270
|
_this.measureAutoHeight(id);
|
|
93188
93271
|
});
|
|
@@ -93266,7 +93349,7 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
93266
93349
|
}
|
|
93267
93350
|
var frame = this.state.autoHeightFrames.get(id);
|
|
93268
93351
|
if (frame !== undefined) {
|
|
93269
|
-
|
|
93352
|
+
cancelHTMLOverlayFrame(frame);
|
|
93270
93353
|
this.state.autoHeightFrames.delete(id);
|
|
93271
93354
|
}
|
|
93272
93355
|
};
|
|
@@ -93284,7 +93367,18 @@ var HTMLOverlayManager = /*#__PURE__*/ function() {
|
|
|
93284
93367
|
if (Math.abs(nextHeight - item.property.height) <= AUTO_HEIGHT_EPSILON) {
|
|
93285
93368
|
return;
|
|
93286
93369
|
}
|
|
93287
|
-
this.options.setCardItemHeight(id, nextHeight
|
|
93370
|
+
this.options.setCardItemHeight(id, nextHeight, {
|
|
93371
|
+
anchor: this.getAutoHeightAnchor(item),
|
|
93372
|
+
previousHeight: item.property.height
|
|
93373
|
+
});
|
|
93374
|
+
};
|
|
93375
|
+
_proto.getAutoHeightAnchor = function getAutoHeightAnchor(item) {
|
|
93376
|
+
var _ref;
|
|
93377
|
+
var _this_options_resolveCardTypeConfig;
|
|
93378
|
+
if (!isCardItem(item)) {
|
|
93379
|
+
return 'top';
|
|
93380
|
+
}
|
|
93381
|
+
return (_ref = (_this_options_resolveCardTypeConfig = this.options.resolveCardTypeConfig(item)) == null ? void 0 : _this_options_resolveCardTypeConfig.autoHeightAnchor) != null ? _ref : 'top';
|
|
93288
93382
|
};
|
|
93289
93383
|
_proto.getAutoHeightItemHeight = function getAutoHeightItemHeight(item, contentHeight) {
|
|
93290
93384
|
if (!isCardItem(item) || this.isAutoScaleEnabled(item)) {
|
|
@@ -93370,7 +93464,7 @@ function formatCssNumber(value) {
|
|
|
93370
93464
|
}
|
|
93371
93465
|
function nextAnimationFrame() {
|
|
93372
93466
|
return new Promise(function(resolve) {
|
|
93373
|
-
|
|
93467
|
+
requestHTMLOverlayFrame(function() {
|
|
93374
93468
|
resolve();
|
|
93375
93469
|
});
|
|
93376
93470
|
});
|
|
@@ -93939,12 +94033,29 @@ var SDK = /*#__PURE__*/ function() {
|
|
|
93939
94033
|
bottom: HTML_CARD_EDITING_VIEWPORT_PADDING
|
|
93940
94034
|
}, box);
|
|
93941
94035
|
},
|
|
93942
|
-
setCardItemHeight: function setCardItemHeight(id, height) {
|
|
94036
|
+
setCardItemHeight: function setCardItemHeight(id, height, options) {
|
|
94037
|
+
var item = _this.getSDKItem(id);
|
|
94038
|
+
if (!isCardItem(item) || options.anchor === 'center') {
|
|
94039
|
+
void _this.setItemProperty({
|
|
94040
|
+
itemId: id,
|
|
94041
|
+
type: SDKItemType.CARD,
|
|
94042
|
+
propertyName: 'height',
|
|
94043
|
+
propertyValue: height
|
|
94044
|
+
});
|
|
94045
|
+
return;
|
|
94046
|
+
}
|
|
94047
|
+
var _item_property_position = item.property.position, x = _item_property_position[0], y = _item_property_position[1];
|
|
94048
|
+
var deltaY = (height - options.previousHeight) / 2;
|
|
93943
94049
|
void _this.setItemProperty({
|
|
93944
94050
|
itemId: id,
|
|
93945
94051
|
type: SDKItemType.CARD,
|
|
93946
|
-
|
|
93947
|
-
|
|
94052
|
+
property: {
|
|
94053
|
+
height: height,
|
|
94054
|
+
position: [
|
|
94055
|
+
x,
|
|
94056
|
+
y + deltaY
|
|
94057
|
+
]
|
|
94058
|
+
}
|
|
93948
94059
|
});
|
|
93949
94060
|
},
|
|
93950
94061
|
getSelectedItemIds: function getSelectedItemIds() {
|
|
@@ -96168,6 +96279,38 @@ var SDK = /*#__PURE__*/ function() {
|
|
|
96168
96279
|
return true;
|
|
96169
96280
|
};
|
|
96170
96281
|
/**
|
|
96282
|
+
* @description 获取指定 HTML 卡片当前 iframe 的 window。
|
|
96283
|
+
* @description 仅 inline/document 或自行渲染 iframe 的 DOM 内容会返回 window。
|
|
96284
|
+
* @param id 卡片元素 ID
|
|
96285
|
+
* @returns HTML iframe window
|
|
96286
|
+
*/ _proto.getHtmlCardWindow = function getHtmlCardWindow(id) {
|
|
96287
|
+
var _this__htmlOverlayManager;
|
|
96288
|
+
return (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.getHtmlCardWindow(id);
|
|
96289
|
+
};
|
|
96290
|
+
/**
|
|
96291
|
+
* @description 向指定 HTML 卡片发送增量 patch。
|
|
96292
|
+
* @description 当卡片内容配置了 CardHTMLPatchHandler 时,可用于局部更新 HTML,而不必整卡 refresh。
|
|
96293
|
+
* @param id 卡片元素 ID
|
|
96294
|
+
* @param patch patch 负载,由卡片内容自己的 patch handler 解释
|
|
96295
|
+
* @returns 是否被 patch handler 处理
|
|
96296
|
+
*/ _proto.patchCardHTML = function patchCardHTML(id, patch) {
|
|
96297
|
+
var _ref;
|
|
96298
|
+
var _this__htmlOverlayManager;
|
|
96299
|
+
return (_ref = (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.patchCardHTML(id, patch)) != null ? _ref : false;
|
|
96300
|
+
};
|
|
96301
|
+
/**
|
|
96302
|
+
* @description 向指定 HTML 卡片 iframe 派发事件。
|
|
96303
|
+
* @description 通过 postMessage 投递事件,跨源/同源行为一致,消息 source 为 vvfx-card-html-event。
|
|
96304
|
+
* @param id 卡片元素 ID
|
|
96305
|
+
* @param type 事件名称
|
|
96306
|
+
* @param detail 事件 detail
|
|
96307
|
+
* @returns 是否成功派发或投递
|
|
96308
|
+
*/ _proto.dispatchHtmlCardEvent = function dispatchHtmlCardEvent(id, type, detail) {
|
|
96309
|
+
var _ref;
|
|
96310
|
+
var _this__htmlOverlayManager;
|
|
96311
|
+
return (_ref = (_this__htmlOverlayManager = this._htmlOverlayManager) == null ? void 0 : _this__htmlOverlayManager.dispatchHtmlCardEvent(id, type, detail)) != null ? _ref : false;
|
|
96312
|
+
};
|
|
96313
|
+
/**
|
|
96171
96314
|
* @description 创建卡片元素
|
|
96172
96315
|
* @description 底层以透明 SpriteItem 形式渲染,支持 cardType 属性
|
|
96173
96316
|
* @param createInfo 卡片创建信息
|