@vscode/web-editors 0.0.2-104 → 0.0.2-105
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.d.ts +73 -3
- package/dist/index.js +120 -7
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2143,12 +2143,14 @@ declare const ZodReadonly: $constructor<ZodReadonly>;
|
|
|
2143
2143
|
declare const zEditorCapabilities: ZodObject<{
|
|
2144
2144
|
supportsContentEdits: ZodOptional<ZodBoolean>;
|
|
2145
2145
|
supportsOptions: ZodOptional<ZodBoolean>;
|
|
2146
|
+
supportsPresentation: ZodOptional<ZodBoolean>;
|
|
2146
2147
|
}, $strip>;
|
|
2147
2148
|
declare const zHostCapabilities: ZodObject<{
|
|
2148
2149
|
supportsContentEdits: ZodOptional<ZodBoolean>;
|
|
2149
2150
|
supportsOptions: ZodOptional<ZodBoolean>;
|
|
2150
2151
|
supportsForceUpdate: ZodOptional<ZodBoolean>;
|
|
2151
2152
|
supportsHostTransport: ZodOptional<ZodBoolean>;
|
|
2153
|
+
supportsPresentation: ZodOptional<ZodBoolean>;
|
|
2152
2154
|
}, $strip>;
|
|
2153
2155
|
declare const zTextEdit: ZodObject<{
|
|
2154
2156
|
offset: ZodNumber;
|
|
@@ -2176,16 +2178,39 @@ declare const zWebEditorUpdate: ZodObject<{
|
|
|
2176
2178
|
acknowledgedClientRevision: ZodOptional<ZodNumber>;
|
|
2177
2179
|
force: ZodOptional<ZodBoolean>;
|
|
2178
2180
|
}, $strip>;
|
|
2181
|
+
/** How an embedding host currently presents the editor. */
|
|
2182
|
+
declare const zPresentationMode: ZodEnum<{
|
|
2183
|
+
inline: "inline";
|
|
2184
|
+
"full-width": "full-width";
|
|
2185
|
+
"full-view": "full-view";
|
|
2186
|
+
}>;
|
|
2187
|
+
/**
|
|
2188
|
+
* Presentation controls the editor asks its embedding host for. The host's own
|
|
2189
|
+
* configuration takes precedence over these preferences.
|
|
2190
|
+
*/
|
|
2191
|
+
declare const zPresentationPreferences: ZodObject<{
|
|
2192
|
+
resizable: ZodOptional<ZodBoolean>;
|
|
2193
|
+
fullWidth: ZodOptional<ZodBoolean>;
|
|
2194
|
+
fullView: ZodOptional<ZodBoolean>;
|
|
2195
|
+
minHeight: ZodOptional<ZodNumber>;
|
|
2196
|
+
maxAutomaticHeight: ZodOptional<ZodNumber>;
|
|
2197
|
+
}, $strip>;
|
|
2179
2198
|
type ContentEdit = output<typeof zContentEdit>;
|
|
2180
2199
|
type TextEdit = output<typeof zTextEdit>;
|
|
2181
2200
|
type EditorCapabilities = output<typeof zEditorCapabilities>;
|
|
2182
2201
|
type HostCapabilities = output<typeof zHostCapabilities>;
|
|
2183
2202
|
type WebEditorUpdate = output<typeof zWebEditorUpdate>;
|
|
2203
|
+
type PresentationMode = output<typeof zPresentationMode>;
|
|
2204
|
+
type PresentationPreferences = output<typeof zPresentationPreferences>;
|
|
2184
2205
|
type ContentType = "text" | "json";
|
|
2185
2206
|
declare const webEditorHostInterface: any;
|
|
2186
2207
|
declare const webEditorInterface: any;
|
|
2187
2208
|
declare const webEditorHostTransportInterface: any;
|
|
2188
2209
|
declare const webEditorClientTransportInterface: any;
|
|
2210
|
+
/** Methods the editor exposes to a presenting host. */
|
|
2211
|
+
declare const webEditorPresentationInterface: any;
|
|
2212
|
+
/** Methods a presenting host exposes to the editor. */
|
|
2213
|
+
declare const webEditorPresentationHostInterface: any;
|
|
2189
2214
|
declare const zEmbeddedAppDescriptor: ZodObject<{
|
|
2190
2215
|
handleId: ZodString;
|
|
2191
2216
|
appId: ZodString;
|
|
@@ -2210,6 +2235,8 @@ type WebEditorHostProxy = InterfaceClient<typeof webEditorHostInterface>;
|
|
|
2210
2235
|
type WebEditorProxy = InterfaceClient<typeof webEditorInterface>;
|
|
2211
2236
|
type WebEditorHostTransportProxy = InterfaceClient<typeof webEditorHostTransportInterface>;
|
|
2212
2237
|
type WebEditorClientTransportProxy = InterfaceClient<typeof webEditorClientTransportInterface>;
|
|
2238
|
+
type WebEditorPresentationProxy = InterfaceClient<typeof webEditorPresentationInterface>;
|
|
2239
|
+
type WebEditorPresentationHostProxy = InterfaceClient<typeof webEditorPresentationHostInterface>;
|
|
2213
2240
|
/** Typed proxy used by an app to invoke `vscode-app-host` methods. */
|
|
2214
2241
|
type VsCodeAppHostProxy = InterfaceClient<typeof vscodeAppHostInterface>;
|
|
2215
2242
|
type VsCodeAppEmbeddingEventsProxy = InterfaceClient<typeof vscodeAppEmbeddingEventsInterface>;
|
|
@@ -2319,6 +2346,12 @@ interface WebEditorHostOptions {
|
|
|
2319
2346
|
capabilities?: HostCapabilities;
|
|
2320
2347
|
/** Optional message transport to expose to the editor. */
|
|
2321
2348
|
hostTransport?: HostTransport;
|
|
2349
|
+
/**
|
|
2350
|
+
* The host presents the editor inline (for example as a block in a document)
|
|
2351
|
+
* and exchanges presentation state with editors that support it: see
|
|
2352
|
+
* {@link WebEditorHost.setPresentationMode} and the presentation events.
|
|
2353
|
+
*/
|
|
2354
|
+
supportsPresentation?: boolean;
|
|
2322
2355
|
/** Called when the editor sends malformed input. Defaults to `console.error`. */
|
|
2323
2356
|
onError?: (message: string, detail?: unknown) => void;
|
|
2324
2357
|
}
|
|
@@ -2333,6 +2366,7 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2333
2366
|
private readonly _connection;
|
|
2334
2367
|
private readonly _editor;
|
|
2335
2368
|
private readonly _clientTransport;
|
|
2369
|
+
private readonly _presentation;
|
|
2336
2370
|
private readonly _contentType;
|
|
2337
2371
|
private readonly _jsonFormat;
|
|
2338
2372
|
private readonly _onError;
|
|
@@ -2340,6 +2374,7 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2340
2374
|
private readonly _hostTransportSubscription;
|
|
2341
2375
|
private _text;
|
|
2342
2376
|
private _readOnly;
|
|
2377
|
+
private _presentationMode;
|
|
2343
2378
|
private _serverRevision;
|
|
2344
2379
|
private _acknowledgedClientRevision;
|
|
2345
2380
|
private _editorInitialized;
|
|
@@ -2357,6 +2392,12 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2357
2392
|
readonly onDidReportSize: Event<{
|
|
2358
2393
|
height: number;
|
|
2359
2394
|
}>;
|
|
2395
|
+
private readonly _onDidSetPresentationPreferences;
|
|
2396
|
+
/** The editor replaced its presentation preferences. Only fires with `supportsPresentation`. */
|
|
2397
|
+
readonly onDidSetPresentationPreferences: Event<PresentationPreferences>;
|
|
2398
|
+
private readonly _onDidRequestExitFullView;
|
|
2399
|
+
/** The editor asked to leave full view. Only fires with `supportsPresentation`. */
|
|
2400
|
+
readonly onDidRequestExitFullView: Event<void>;
|
|
2360
2401
|
constructor(options: WebEditorHostOptions);
|
|
2361
2402
|
/** The text the host believes the document currently holds. */
|
|
2362
2403
|
getText(): string;
|
|
@@ -2374,6 +2415,11 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2374
2415
|
*/
|
|
2375
2416
|
reuse(text: string, readOnly: boolean): void;
|
|
2376
2417
|
getReadOnly(): boolean;
|
|
2418
|
+
/**
|
|
2419
|
+
* Tell the editor how the host presents it. Sent to editors that support
|
|
2420
|
+
* presentation once they initialized, and again after they reconnect.
|
|
2421
|
+
*/
|
|
2422
|
+
setPresentationMode(mode: PresentationMode): void;
|
|
2377
2423
|
setReadOnly(readOnly: boolean): void;
|
|
2378
2424
|
/**
|
|
2379
2425
|
* Push fine-grained edits to the editor.
|
|
@@ -2383,6 +2429,7 @@ declare class WebEditorHost implements IDisposable {
|
|
|
2383
2429
|
dispose(): void;
|
|
2384
2430
|
private _pushFullUpdate;
|
|
2385
2431
|
private _pushAcknowledgement;
|
|
2432
|
+
private _pushPresentationMode;
|
|
2386
2433
|
private _acknowledgeAndRestore;
|
|
2387
2434
|
}
|
|
2388
2435
|
//#endregion
|
|
@@ -2484,12 +2531,16 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2484
2531
|
private readonly _connection;
|
|
2485
2532
|
private readonly _host;
|
|
2486
2533
|
private readonly _hostTransportProxy;
|
|
2534
|
+
private readonly _presentationHost;
|
|
2487
2535
|
private readonly _onError;
|
|
2488
2536
|
private _hostTransport;
|
|
2489
2537
|
private _content;
|
|
2490
2538
|
private _readOnly;
|
|
2491
2539
|
private _options;
|
|
2492
2540
|
private _hostCapabilities;
|
|
2541
|
+
private _connected;
|
|
2542
|
+
private _presentationMode;
|
|
2543
|
+
private _presentationPreferences;
|
|
2493
2544
|
private readonly _pendingHostTransportMessages;
|
|
2494
2545
|
private _hostTransportActivated;
|
|
2495
2546
|
private _clientRevision;
|
|
@@ -2514,6 +2565,11 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2514
2565
|
readonly onDidChangeOptions: Event<{
|
|
2515
2566
|
options: JsonValue;
|
|
2516
2567
|
}>;
|
|
2568
|
+
private readonly _onDidChangePresentationMode;
|
|
2569
|
+
/** The embedding host changed how it presents this editor. See {@link getPresentationMode}. */
|
|
2570
|
+
readonly onDidChangePresentationMode: Event<{
|
|
2571
|
+
mode: PresentationMode;
|
|
2572
|
+
}>;
|
|
2517
2573
|
private readonly _onDidReceiveHostMessage;
|
|
2518
2574
|
/** Resolves once the host has acknowledged `initialized`. */
|
|
2519
2575
|
readonly onDidConnect: Promise<{
|
|
@@ -2539,10 +2595,24 @@ declare class WebEditorClient implements IDisposable {
|
|
|
2539
2595
|
*/
|
|
2540
2596
|
applyEdits(edits: readonly ContentEdit[]): void;
|
|
2541
2597
|
/**
|
|
2542
|
-
* Report the editor's
|
|
2543
|
-
*
|
|
2598
|
+
* Report the editor's preferred content height (px): the height it needs to
|
|
2599
|
+
* show its content without scrolling, independent of the frame's current
|
|
2600
|
+
* height. A host embedding this editor in an iframe sizes the frame to it.
|
|
2544
2601
|
*/
|
|
2545
2602
|
reportSize(height: number): void;
|
|
2603
|
+
/**
|
|
2604
|
+
* How an embedding host currently presents this editor, or `undefined` when
|
|
2605
|
+
* the host does not present it inline (for example a standalone editor).
|
|
2606
|
+
*/
|
|
2607
|
+
getPresentationMode(): PresentationMode | undefined;
|
|
2608
|
+
/**
|
|
2609
|
+
* Ask a presenting host for presentation controls (resize grips, full view).
|
|
2610
|
+
* Replaces earlier preferences; sent once connected, and ignored by hosts
|
|
2611
|
+
* that do not present the editor inline.
|
|
2612
|
+
*/
|
|
2613
|
+
setPresentationPreferences(preferences: PresentationPreferences): void;
|
|
2614
|
+
/** Ask a presenting host to leave full view. */
|
|
2615
|
+
exitFullView(): void;
|
|
2546
2616
|
dispose(): void;
|
|
2547
2617
|
private _handleUpdate;
|
|
2548
2618
|
private _handleApplyContentEdits;
|
|
@@ -2683,5 +2753,5 @@ declare class VsCodeAppHostClient {
|
|
|
2683
2753
|
}): Promise<EditorAssociationResult>;
|
|
2684
2754
|
}
|
|
2685
2755
|
//#endregion
|
|
2686
|
-
export { AppContext, type ConnectionInput, ContentEdit, ContentType, EditorAssociationResult, EditorCapabilities, EditorRegistrationStatus, EditorScope, EmbeddedAppAccessOptions, EmbeddedAppDescriptor, EmbeddedAppHandle, EmbeddingContext, type Event, HostCapabilities, HostTransport, type IDisposable, JsonFormatOptions, JsonValue, type MessageEndpoint, type MessageLikeEvent, ScopeRegistration, TextEdit, VsCodeAppEmbeddingEventsProxy, VsCodeAppHostClient, VsCodeAppHostClientOptions, VsCodeAppHostProxy, WebEditorClient, WebEditorClientOptions, WebEditorClientState, WebEditorClientTransportProxy, WebEditorHost, WebEditorHostOptions, WebEditorHostProxy, WebEditorHostTransportProxy, WebEditorProxy, WebEditorUpdate, WindowMessageTransport, applyContentEdits, applyTextEdits, createWindowParentConnection, decodeFromEditor, encodeForEditor, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorClientTransportInterface, webEditorHostInterface, webEditorHostTransportInterface, webEditorInterface };
|
|
2756
|
+
export { AppContext, type ConnectionInput, ContentEdit, ContentType, EditorAssociationResult, EditorCapabilities, EditorRegistrationStatus, EditorScope, EmbeddedAppAccessOptions, EmbeddedAppDescriptor, EmbeddedAppHandle, EmbeddingContext, type Event, HostCapabilities, HostTransport, type IDisposable, JsonFormatOptions, JsonValue, type MessageEndpoint, type MessageLikeEvent, PresentationMode, PresentationPreferences, ScopeRegistration, TextEdit, VsCodeAppEmbeddingEventsProxy, VsCodeAppHostClient, VsCodeAppHostClientOptions, VsCodeAppHostProxy, WebEditorClient, WebEditorClientOptions, WebEditorClientState, WebEditorClientTransportProxy, WebEditorHost, WebEditorHostOptions, WebEditorHostProxy, WebEditorHostTransportProxy, WebEditorPresentationHostProxy, WebEditorPresentationProxy, WebEditorProxy, WebEditorUpdate, WindowMessageTransport, applyContentEdits, applyTextEdits, createWindowParentConnection, decodeFromEditor, encodeForEditor, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorClientTransportInterface, webEditorHostInterface, webEditorHostTransportInterface, webEditorInterface, webEditorPresentationHostInterface, webEditorPresentationInterface };
|
|
2687
2757
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -4120,13 +4120,17 @@ function superRefine(fn, params) {
|
|
|
4120
4120
|
const zJsonValue = unknown();
|
|
4121
4121
|
const zEditorCapabilities = object({
|
|
4122
4122
|
supportsContentEdits: boolean().optional(),
|
|
4123
|
-
supportsOptions: boolean().optional()
|
|
4123
|
+
supportsOptions: boolean().optional(),
|
|
4124
|
+
/** The editor implements `web-editor-presentation` (see {@link webEditorPresentationInterface}). */
|
|
4125
|
+
supportsPresentation: boolean().optional()
|
|
4124
4126
|
});
|
|
4125
4127
|
const zHostCapabilities = object({
|
|
4126
4128
|
supportsContentEdits: boolean().optional(),
|
|
4127
4129
|
supportsOptions: boolean().optional(),
|
|
4128
4130
|
supportsForceUpdate: boolean().optional(),
|
|
4129
|
-
supportsHostTransport: boolean().optional()
|
|
4131
|
+
supportsHostTransport: boolean().optional(),
|
|
4132
|
+
/** The host presents the editor inline and implements `web-editor-presentation-host`. */
|
|
4133
|
+
supportsPresentation: boolean().optional()
|
|
4130
4134
|
});
|
|
4131
4135
|
const zTextEdit = object({
|
|
4132
4136
|
offset: number().int().nonnegative(),
|
|
@@ -4150,6 +4154,28 @@ const zWebEditorUpdate = object({
|
|
|
4150
4154
|
acknowledgedClientRevision: number().int().nonnegative().optional(),
|
|
4151
4155
|
force: boolean().optional()
|
|
4152
4156
|
});
|
|
4157
|
+
/** How an embedding host currently presents the editor. */
|
|
4158
|
+
const zPresentationMode = _enum([
|
|
4159
|
+
"inline",
|
|
4160
|
+
"full-width",
|
|
4161
|
+
"full-view"
|
|
4162
|
+
]);
|
|
4163
|
+
const zEditorHeight = number().positive().max(1e4);
|
|
4164
|
+
/**
|
|
4165
|
+
* Presentation controls the editor asks its embedding host for. The host's own
|
|
4166
|
+
* configuration takes precedence over these preferences.
|
|
4167
|
+
*/
|
|
4168
|
+
const zPresentationPreferences = object({
|
|
4169
|
+
/** A height grip; dragging near the automatic (content) height snaps back to it. */
|
|
4170
|
+
resizable: boolean().optional(),
|
|
4171
|
+
/** A width grip that widens the editor up to the host's viewport. */
|
|
4172
|
+
fullWidth: boolean().optional(),
|
|
4173
|
+
/** A toolbar action that fills the host's viewport. */
|
|
4174
|
+
fullView: boolean().optional(),
|
|
4175
|
+
minHeight: zEditorHeight.optional(),
|
|
4176
|
+
/** Upper bound for the automatic height; users can still resize beyond it. */
|
|
4177
|
+
maxAutomaticHeight: zEditorHeight.optional()
|
|
4178
|
+
});
|
|
4153
4179
|
const webEditorHostInterface = defineInterface({
|
|
4154
4180
|
id: "web-editor-host",
|
|
4155
4181
|
description: "Methods the host exposes to the editor (web-editor/0.12)."
|
|
@@ -4197,6 +4223,23 @@ const webEditorClientTransportInterface = defineInterface({
|
|
|
4197
4223
|
id: "web-editor-client-transport",
|
|
4198
4224
|
description: "Optional messages the web editor host sends to the editor."
|
|
4199
4225
|
}, { message: notificationType(object({ message: zJsonValue })) });
|
|
4226
|
+
/** Methods the editor exposes to a presenting host. */
|
|
4227
|
+
const webEditorPresentationInterface = defineInterface({
|
|
4228
|
+
id: "web-editor-presentation",
|
|
4229
|
+
description: "How the embedding host currently presents the editor."
|
|
4230
|
+
}, {
|
|
4231
|
+
/** Sent once the editor initialized, and whenever the mode changes. */
|
|
4232
|
+
changed: notificationType(object({ mode: zPresentationMode })) });
|
|
4233
|
+
/** Methods a presenting host exposes to the editor. */
|
|
4234
|
+
const webEditorPresentationHostInterface = defineInterface({
|
|
4235
|
+
id: "web-editor-presentation-host",
|
|
4236
|
+
description: "Presentation preferences and actions of an embedded editor."
|
|
4237
|
+
}, {
|
|
4238
|
+
/** Replaces the editor's previous preferences. */
|
|
4239
|
+
setPreferences: notificationType(zPresentationPreferences),
|
|
4240
|
+
/** Asks the host to leave full view, for example when the user presses Escape. */
|
|
4241
|
+
exitFullView: notificationType(object({}))
|
|
4242
|
+
});
|
|
4200
4243
|
/** Per-scope registration: `registered` (toolbar button) and `isDefault` (auto-open). */
|
|
4201
4244
|
const zScopeRegistration = object({
|
|
4202
4245
|
registered: boolean(),
|
|
@@ -4395,6 +4438,7 @@ var WebEditorHost = class {
|
|
|
4395
4438
|
_connection;
|
|
4396
4439
|
_editor;
|
|
4397
4440
|
_clientTransport;
|
|
4441
|
+
_presentation;
|
|
4398
4442
|
_contentType;
|
|
4399
4443
|
_jsonFormat;
|
|
4400
4444
|
_onError;
|
|
@@ -4402,6 +4446,7 @@ var WebEditorHost = class {
|
|
|
4402
4446
|
_hostTransportSubscription;
|
|
4403
4447
|
_text;
|
|
4404
4448
|
_readOnly;
|
|
4449
|
+
_presentationMode;
|
|
4405
4450
|
_serverRevision = 0;
|
|
4406
4451
|
_acknowledgedClientRevision = 0;
|
|
4407
4452
|
_editorInitialized = false;
|
|
@@ -4413,6 +4458,12 @@ var WebEditorHost = class {
|
|
|
4413
4458
|
onDidInitialize = this._onDidInitialize.event;
|
|
4414
4459
|
_onDidReportSize = new Emitter();
|
|
4415
4460
|
onDidReportSize = this._onDidReportSize.event;
|
|
4461
|
+
_onDidSetPresentationPreferences = new Emitter();
|
|
4462
|
+
/** The editor replaced its presentation preferences. Only fires with `supportsPresentation`. */
|
|
4463
|
+
onDidSetPresentationPreferences = this._onDidSetPresentationPreferences.event;
|
|
4464
|
+
_onDidRequestExitFullView = new Emitter();
|
|
4465
|
+
/** The editor asked to leave full view. Only fires with `supportsPresentation`. */
|
|
4466
|
+
onDidRequestExitFullView = this._onDidRequestExitFullView.event;
|
|
4416
4467
|
constructor(options) {
|
|
4417
4468
|
this._connection = options.connection;
|
|
4418
4469
|
this._contentType = options.contentType ?? "text";
|
|
@@ -4422,10 +4473,12 @@ var WebEditorHost = class {
|
|
|
4422
4473
|
this._onError = options.onError ?? ((m, d) => console.error("WebEditorHost:", m, d));
|
|
4423
4474
|
this._capabilities = {
|
|
4424
4475
|
...options.capabilities ?? { supportsForceUpdate: true },
|
|
4425
|
-
supportsHostTransport: options.hostTransport ? true : void 0
|
|
4476
|
+
supportsHostTransport: options.hostTransport ? true : void 0,
|
|
4477
|
+
supportsPresentation: options.supportsPresentation ? true : void 0
|
|
4426
4478
|
};
|
|
4427
4479
|
this._editor = this._connection.get(webEditorInterface);
|
|
4428
4480
|
this._clientTransport = this._connection.get(webEditorClientTransportInterface);
|
|
4481
|
+
this._presentation = this._connection.get(webEditorPresentationInterface);
|
|
4429
4482
|
this._connection.register(webEditorHostInterface, {
|
|
4430
4483
|
initialized: (params) => {
|
|
4431
4484
|
if (params.contentType !== this._contentType) this._onError(`Editor contentType "${params.contentType}" does not match host "${this._contentType}"`);
|
|
@@ -4435,6 +4488,7 @@ var WebEditorHost = class {
|
|
|
4435
4488
|
this._acknowledgedClientRevision = 0;
|
|
4436
4489
|
this._pushFullUpdate();
|
|
4437
4490
|
for (const message of this._pendingHostTransportMessages.splice(0)) this._clientTransport.message({ message });
|
|
4491
|
+
this._pushPresentationMode();
|
|
4438
4492
|
this._onDidInitialize.fire({ capabilities: params.capabilities });
|
|
4439
4493
|
return {
|
|
4440
4494
|
protocolVersion: "web-editor-host/0.12",
|
|
@@ -4479,6 +4533,10 @@ var WebEditorHost = class {
|
|
|
4479
4533
|
this._onDidReportSize.fire({ height: params.height });
|
|
4480
4534
|
}
|
|
4481
4535
|
});
|
|
4536
|
+
if (options.supportsPresentation) this._connection.register(webEditorPresentationHostInterface, {
|
|
4537
|
+
setPreferences: (preferences) => this._onDidSetPresentationPreferences.fire(preferences),
|
|
4538
|
+
exitFullView: () => this._onDidRequestExitFullView.fire()
|
|
4539
|
+
});
|
|
4482
4540
|
if (options.hostTransport) {
|
|
4483
4541
|
this._connection.register(webEditorHostTransportInterface, { message: ({ message }) => options.hostTransport.sendMessage(message) });
|
|
4484
4542
|
this._hostTransportSubscription = options.hostTransport.onMessage((message) => {
|
|
@@ -4513,6 +4571,15 @@ var WebEditorHost = class {
|
|
|
4513
4571
|
getReadOnly() {
|
|
4514
4572
|
return this._readOnly;
|
|
4515
4573
|
}
|
|
4574
|
+
/**
|
|
4575
|
+
* Tell the editor how the host presents it. Sent to editors that support
|
|
4576
|
+
* presentation once they initialized, and again after they reconnect.
|
|
4577
|
+
*/
|
|
4578
|
+
setPresentationMode(mode) {
|
|
4579
|
+
if (this._presentationMode === mode) return;
|
|
4580
|
+
this._presentationMode = mode;
|
|
4581
|
+
this._pushPresentationMode();
|
|
4582
|
+
}
|
|
4516
4583
|
setReadOnly(readOnly) {
|
|
4517
4584
|
if (this._readOnly === readOnly) return;
|
|
4518
4585
|
this._readOnly = readOnly;
|
|
@@ -4547,6 +4614,8 @@ var WebEditorHost = class {
|
|
|
4547
4614
|
this._onDidChangeText.dispose();
|
|
4548
4615
|
this._onDidInitialize.dispose();
|
|
4549
4616
|
this._onDidReportSize.dispose();
|
|
4617
|
+
this._onDidSetPresentationPreferences.dispose();
|
|
4618
|
+
this._onDidRequestExitFullView.dispose();
|
|
4550
4619
|
this._pendingHostTransportMessages.length = 0;
|
|
4551
4620
|
this._connection.close();
|
|
4552
4621
|
}
|
|
@@ -4575,6 +4644,10 @@ var WebEditorHost = class {
|
|
|
4575
4644
|
acknowledgedClientRevision: this._acknowledgedClientRevision
|
|
4576
4645
|
});
|
|
4577
4646
|
}
|
|
4647
|
+
_pushPresentationMode() {
|
|
4648
|
+
if (!this._editorInitialized || !this._capabilities.supportsPresentation || !this._editorCapabilities?.supportsPresentation || this._presentationMode === void 0) return;
|
|
4649
|
+
this._presentation.changed({ mode: this._presentationMode });
|
|
4650
|
+
}
|
|
4578
4651
|
_acknowledgeAndRestore(clientRevision) {
|
|
4579
4652
|
this._acknowledgedClientRevision = Math.max(this._acknowledgedClientRevision, clientRevision);
|
|
4580
4653
|
this._pushFullUpdate(true);
|
|
@@ -4727,12 +4800,16 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4727
4800
|
_connection;
|
|
4728
4801
|
_host;
|
|
4729
4802
|
_hostTransportProxy;
|
|
4803
|
+
_presentationHost;
|
|
4730
4804
|
_onError;
|
|
4731
4805
|
_hostTransport;
|
|
4732
4806
|
_content = void 0;
|
|
4733
4807
|
_readOnly = false;
|
|
4734
4808
|
_options = void 0;
|
|
4735
4809
|
_hostCapabilities;
|
|
4810
|
+
_connected = false;
|
|
4811
|
+
_presentationMode;
|
|
4812
|
+
_presentationPreferences;
|
|
4736
4813
|
_pendingHostTransportMessages = [];
|
|
4737
4814
|
_hostTransportActivated = false;
|
|
4738
4815
|
_clientRevision = 0;
|
|
@@ -4747,6 +4824,9 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4747
4824
|
onDidChangeReadOnly = this._onDidChangeReadOnly.event;
|
|
4748
4825
|
_onDidChangeOptions = new Emitter();
|
|
4749
4826
|
onDidChangeOptions = this._onDidChangeOptions.event;
|
|
4827
|
+
_onDidChangePresentationMode = new Emitter();
|
|
4828
|
+
/** The embedding host changed how it presents this editor. See {@link getPresentationMode}. */
|
|
4829
|
+
onDidChangePresentationMode = this._onDidChangePresentationMode.event;
|
|
4750
4830
|
_onDidReceiveHostMessage = new Emitter();
|
|
4751
4831
|
/** Resolves once the host has acknowledged `initialized`. */
|
|
4752
4832
|
onDidConnect;
|
|
@@ -4760,6 +4840,7 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4760
4840
|
this._onError = options.onError ?? ((m, d) => console.error("WebEditorClient:", m, d));
|
|
4761
4841
|
this._host = this._connection.get(webEditorHostInterface);
|
|
4762
4842
|
this._hostTransportProxy = this._connection.get(webEditorHostTransportInterface);
|
|
4843
|
+
this._presentationHost = this._connection.get(webEditorPresentationHostInterface);
|
|
4763
4844
|
this._connection.register(webEditorInterface, {
|
|
4764
4845
|
update: (params) => this._handleUpdate(params),
|
|
4765
4846
|
applyContentEdits: (params) => this._handleApplyContentEdits(params),
|
|
@@ -4767,6 +4848,11 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4767
4848
|
return { schema: options.getContentSchema ? await options.getContentSchema() : null };
|
|
4768
4849
|
}
|
|
4769
4850
|
});
|
|
4851
|
+
this._connection.register(webEditorPresentationInterface, { changed: ({ mode }) => {
|
|
4852
|
+
if (mode === this._presentationMode) return;
|
|
4853
|
+
this._presentationMode = mode;
|
|
4854
|
+
this._onDidChangePresentationMode.fire({ mode });
|
|
4855
|
+
} });
|
|
4770
4856
|
this._connection.register(webEditorClientTransportInterface, { message: ({ message }) => {
|
|
4771
4857
|
if (this._hostTransportActivated) this._onDidReceiveHostMessage.fire(message);
|
|
4772
4858
|
else this._pendingHostTransportMessages.push(message);
|
|
@@ -4774,9 +4860,14 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4774
4860
|
this.onDidConnect = this._host.initialized({
|
|
4775
4861
|
protocolVersion: "web-editor/0.12",
|
|
4776
4862
|
contentType: options.contentType ?? "text",
|
|
4777
|
-
capabilities:
|
|
4863
|
+
capabilities: {
|
|
4864
|
+
...options.capabilities,
|
|
4865
|
+
supportsPresentation: true
|
|
4866
|
+
}
|
|
4778
4867
|
}).then((r) => {
|
|
4779
4868
|
this._hostCapabilities = r.capabilities;
|
|
4869
|
+
this._connected = true;
|
|
4870
|
+
if (this._presentationPreferences) this.setPresentationPreferences(this._presentationPreferences);
|
|
4780
4871
|
if (r.capabilities?.supportsHostTransport) this._hostTransport = {
|
|
4781
4872
|
onMessage: (listener) => {
|
|
4782
4873
|
const disposable = this._onDidReceiveHostMessage.event(listener);
|
|
@@ -4841,17 +4932,39 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4841
4932
|
});
|
|
4842
4933
|
}
|
|
4843
4934
|
/**
|
|
4844
|
-
* Report the editor's
|
|
4845
|
-
*
|
|
4935
|
+
* Report the editor's preferred content height (px): the height it needs to
|
|
4936
|
+
* show its content without scrolling, independent of the frame's current
|
|
4937
|
+
* height. A host embedding this editor in an iframe sizes the frame to it.
|
|
4846
4938
|
*/
|
|
4847
4939
|
reportSize(height) {
|
|
4848
4940
|
this._host.reportSize({ height });
|
|
4849
4941
|
}
|
|
4942
|
+
/**
|
|
4943
|
+
* How an embedding host currently presents this editor, or `undefined` when
|
|
4944
|
+
* the host does not present it inline (for example a standalone editor).
|
|
4945
|
+
*/
|
|
4946
|
+
getPresentationMode() {
|
|
4947
|
+
return this._presentationMode;
|
|
4948
|
+
}
|
|
4949
|
+
/**
|
|
4950
|
+
* Ask a presenting host for presentation controls (resize grips, full view).
|
|
4951
|
+
* Replaces earlier preferences; sent once connected, and ignored by hosts
|
|
4952
|
+
* that do not present the editor inline.
|
|
4953
|
+
*/
|
|
4954
|
+
setPresentationPreferences(preferences) {
|
|
4955
|
+
this._presentationPreferences = preferences;
|
|
4956
|
+
if (this._connected && this._hostCapabilities?.supportsPresentation) this._presentationHost.setPreferences(preferences);
|
|
4957
|
+
}
|
|
4958
|
+
/** Ask a presenting host to leave full view. */
|
|
4959
|
+
exitFullView() {
|
|
4960
|
+
if (this._connected && this._hostCapabilities?.supportsPresentation) this._presentationHost.exitFullView({});
|
|
4961
|
+
}
|
|
4850
4962
|
dispose() {
|
|
4851
4963
|
this._onDidChangeContent.dispose();
|
|
4852
4964
|
this._onDidApplyHostEdits.dispose();
|
|
4853
4965
|
this._onDidChangeReadOnly.dispose();
|
|
4854
4966
|
this._onDidChangeOptions.dispose();
|
|
4967
|
+
this._onDidChangePresentationMode.dispose();
|
|
4855
4968
|
this._onDidReceiveHostMessage.dispose();
|
|
4856
4969
|
this._pendingHostTransportMessages.length = 0;
|
|
4857
4970
|
this._connection.close();
|
|
@@ -5104,6 +5217,6 @@ var VsCodeAppHostClient = class {
|
|
|
5104
5217
|
}
|
|
5105
5218
|
};
|
|
5106
5219
|
//#endregion
|
|
5107
|
-
export { EmbeddedAppHandle, VsCodeAppHostClient, WebEditorClient, WebEditorHost, WindowMessageTransport, applyContentEdits, applyTextEdits, createWindowParentConnection, decodeFromEditor, encodeForEditor, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorClientTransportInterface, webEditorHostInterface, webEditorHostTransportInterface, webEditorInterface };
|
|
5220
|
+
export { EmbeddedAppHandle, VsCodeAppHostClient, WebEditorClient, WebEditorHost, WindowMessageTransport, applyContentEdits, applyTextEdits, createWindowParentConnection, decodeFromEditor, encodeForEditor, vscodeAppEmbeddingEventsInterface, vscodeAppHostInterface, webEditorClientTransportInterface, webEditorHostInterface, webEditorHostTransportInterface, webEditorInterface, webEditorPresentationHostInterface, webEditorPresentationInterface };
|
|
5108
5221
|
|
|
5109
5222
|
//# sourceMappingURL=index.js.map
|