@lvce-editor/api 8.54.0 → 8.55.0
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.
|
@@ -44,6 +44,7 @@ export interface DomEventListener {
|
|
|
44
44
|
export interface VirtualDomViewInstance {
|
|
45
45
|
readonly dispose?: () => unknown;
|
|
46
46
|
readonly getContext?: () => Readonly<Record<string, boolean>>;
|
|
47
|
+
readonly getCss?: () => string | Promise<string>;
|
|
47
48
|
readonly getMenuEntries?: (menuId: string) => readonly MenuEntry[] | Promise<readonly MenuEntry[]>;
|
|
48
49
|
readonly handleEvent?: (event: ViewEvent) => unknown;
|
|
49
50
|
readonly render: () => readonly VirtualDomNode[] | Promise<readonly VirtualDomNode[]>;
|
|
@@ -79,6 +80,7 @@ export interface ViewRegistrySnapshot {
|
|
|
79
80
|
readonly views: readonly RegisteredView[];
|
|
80
81
|
}
|
|
81
82
|
export interface ViewRenderResultDom {
|
|
83
|
+
readonly css?: string;
|
|
82
84
|
readonly dom: readonly VirtualDomNode[];
|
|
83
85
|
readonly focusSelector?: string;
|
|
84
86
|
readonly scrollPosition?: ViewScrollPosition;
|
|
@@ -87,6 +89,7 @@ export interface ViewRenderResultDom {
|
|
|
87
89
|
readonly type: 'setDom';
|
|
88
90
|
}
|
|
89
91
|
export interface ViewRenderResultPatches {
|
|
92
|
+
readonly css?: string;
|
|
90
93
|
readonly focusSelector?: string;
|
|
91
94
|
readonly patches: readonly unknown[];
|
|
92
95
|
readonly scrollPosition?: ViewScrollPosition;
|
|
@@ -362,6 +362,19 @@ const withFocusSelector = async (result, instance, contextChange) => {
|
|
|
362
362
|
focusSelector,
|
|
363
363
|
};
|
|
364
364
|
};
|
|
365
|
+
const withCss = async (result, instance) => {
|
|
366
|
+
if (typeof instance.getCss !== 'function') {
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
369
|
+
const css = await instance.getCss();
|
|
370
|
+
if (typeof css !== 'string') {
|
|
371
|
+
throw new ExtensionApiError('view getCss result must be a string');
|
|
372
|
+
}
|
|
373
|
+
return {
|
|
374
|
+
...result,
|
|
375
|
+
css,
|
|
376
|
+
};
|
|
377
|
+
};
|
|
365
378
|
const withTitle = async (result, instance) => {
|
|
366
379
|
if (typeof instance.renderTitle !== 'function') {
|
|
367
380
|
return result;
|
|
@@ -402,7 +415,8 @@ const withScrollPosition = async (result, instance) => {
|
|
|
402
415
|
};
|
|
403
416
|
};
|
|
404
417
|
const withRenderMetadata = async (result, instance, contextChange) => {
|
|
405
|
-
const
|
|
418
|
+
const resultWithCss = await withCss(result, instance);
|
|
419
|
+
const resultWithFocus = await withFocusSelector(resultWithCss, instance, contextChange);
|
|
406
420
|
const resultWithSelections = await withSelections(resultWithFocus, instance);
|
|
407
421
|
const resultWithScrollPosition = await withScrollPosition(resultWithSelections, instance);
|
|
408
422
|
return withTitle(resultWithScrollPosition, instance);
|