@vscode/web-editors 0.0.2-103 → 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 +126 -10
- 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)."
|
|
@@ -4168,9 +4194,12 @@ const webEditorHostInterface = defineInterface({
|
|
|
4168
4194
|
basedOnServerRevision: number().int().nonnegative()
|
|
4169
4195
|
})),
|
|
4170
4196
|
/**
|
|
4171
|
-
* The editor reports its
|
|
4172
|
-
*
|
|
4173
|
-
*
|
|
4197
|
+
* The editor reports its preferred content height (px): the height it needs
|
|
4198
|
+
* to show its content without scrolling, independent of the frame's current
|
|
4199
|
+
* height. Measure the content, not the viewport or document, which follow
|
|
4200
|
+
* the frame. An embedding host that reserves block space (e.g. an iframe
|
|
4201
|
+
* with no intrinsic height) sizes the frame to it and uses it as the
|
|
4202
|
+
* automatic height that user resizing snaps back to.
|
|
4174
4203
|
*/
|
|
4175
4204
|
reportSize: notificationType(object({ height: number().nonnegative() }))
|
|
4176
4205
|
});
|
|
@@ -4194,6 +4223,23 @@ const webEditorClientTransportInterface = defineInterface({
|
|
|
4194
4223
|
id: "web-editor-client-transport",
|
|
4195
4224
|
description: "Optional messages the web editor host sends to the editor."
|
|
4196
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
|
+
});
|
|
4197
4243
|
/** Per-scope registration: `registered` (toolbar button) and `isDefault` (auto-open). */
|
|
4198
4244
|
const zScopeRegistration = object({
|
|
4199
4245
|
registered: boolean(),
|
|
@@ -4392,6 +4438,7 @@ var WebEditorHost = class {
|
|
|
4392
4438
|
_connection;
|
|
4393
4439
|
_editor;
|
|
4394
4440
|
_clientTransport;
|
|
4441
|
+
_presentation;
|
|
4395
4442
|
_contentType;
|
|
4396
4443
|
_jsonFormat;
|
|
4397
4444
|
_onError;
|
|
@@ -4399,6 +4446,7 @@ var WebEditorHost = class {
|
|
|
4399
4446
|
_hostTransportSubscription;
|
|
4400
4447
|
_text;
|
|
4401
4448
|
_readOnly;
|
|
4449
|
+
_presentationMode;
|
|
4402
4450
|
_serverRevision = 0;
|
|
4403
4451
|
_acknowledgedClientRevision = 0;
|
|
4404
4452
|
_editorInitialized = false;
|
|
@@ -4410,6 +4458,12 @@ var WebEditorHost = class {
|
|
|
4410
4458
|
onDidInitialize = this._onDidInitialize.event;
|
|
4411
4459
|
_onDidReportSize = new Emitter();
|
|
4412
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;
|
|
4413
4467
|
constructor(options) {
|
|
4414
4468
|
this._connection = options.connection;
|
|
4415
4469
|
this._contentType = options.contentType ?? "text";
|
|
@@ -4419,10 +4473,12 @@ var WebEditorHost = class {
|
|
|
4419
4473
|
this._onError = options.onError ?? ((m, d) => console.error("WebEditorHost:", m, d));
|
|
4420
4474
|
this._capabilities = {
|
|
4421
4475
|
...options.capabilities ?? { supportsForceUpdate: true },
|
|
4422
|
-
supportsHostTransport: options.hostTransport ? true : void 0
|
|
4476
|
+
supportsHostTransport: options.hostTransport ? true : void 0,
|
|
4477
|
+
supportsPresentation: options.supportsPresentation ? true : void 0
|
|
4423
4478
|
};
|
|
4424
4479
|
this._editor = this._connection.get(webEditorInterface);
|
|
4425
4480
|
this._clientTransport = this._connection.get(webEditorClientTransportInterface);
|
|
4481
|
+
this._presentation = this._connection.get(webEditorPresentationInterface);
|
|
4426
4482
|
this._connection.register(webEditorHostInterface, {
|
|
4427
4483
|
initialized: (params) => {
|
|
4428
4484
|
if (params.contentType !== this._contentType) this._onError(`Editor contentType "${params.contentType}" does not match host "${this._contentType}"`);
|
|
@@ -4432,6 +4488,7 @@ var WebEditorHost = class {
|
|
|
4432
4488
|
this._acknowledgedClientRevision = 0;
|
|
4433
4489
|
this._pushFullUpdate();
|
|
4434
4490
|
for (const message of this._pendingHostTransportMessages.splice(0)) this._clientTransport.message({ message });
|
|
4491
|
+
this._pushPresentationMode();
|
|
4435
4492
|
this._onDidInitialize.fire({ capabilities: params.capabilities });
|
|
4436
4493
|
return {
|
|
4437
4494
|
protocolVersion: "web-editor-host/0.12",
|
|
@@ -4476,6 +4533,10 @@ var WebEditorHost = class {
|
|
|
4476
4533
|
this._onDidReportSize.fire({ height: params.height });
|
|
4477
4534
|
}
|
|
4478
4535
|
});
|
|
4536
|
+
if (options.supportsPresentation) this._connection.register(webEditorPresentationHostInterface, {
|
|
4537
|
+
setPreferences: (preferences) => this._onDidSetPresentationPreferences.fire(preferences),
|
|
4538
|
+
exitFullView: () => this._onDidRequestExitFullView.fire()
|
|
4539
|
+
});
|
|
4479
4540
|
if (options.hostTransport) {
|
|
4480
4541
|
this._connection.register(webEditorHostTransportInterface, { message: ({ message }) => options.hostTransport.sendMessage(message) });
|
|
4481
4542
|
this._hostTransportSubscription = options.hostTransport.onMessage((message) => {
|
|
@@ -4510,6 +4571,15 @@ var WebEditorHost = class {
|
|
|
4510
4571
|
getReadOnly() {
|
|
4511
4572
|
return this._readOnly;
|
|
4512
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
|
+
}
|
|
4513
4583
|
setReadOnly(readOnly) {
|
|
4514
4584
|
if (this._readOnly === readOnly) return;
|
|
4515
4585
|
this._readOnly = readOnly;
|
|
@@ -4544,6 +4614,8 @@ var WebEditorHost = class {
|
|
|
4544
4614
|
this._onDidChangeText.dispose();
|
|
4545
4615
|
this._onDidInitialize.dispose();
|
|
4546
4616
|
this._onDidReportSize.dispose();
|
|
4617
|
+
this._onDidSetPresentationPreferences.dispose();
|
|
4618
|
+
this._onDidRequestExitFullView.dispose();
|
|
4547
4619
|
this._pendingHostTransportMessages.length = 0;
|
|
4548
4620
|
this._connection.close();
|
|
4549
4621
|
}
|
|
@@ -4572,6 +4644,10 @@ var WebEditorHost = class {
|
|
|
4572
4644
|
acknowledgedClientRevision: this._acknowledgedClientRevision
|
|
4573
4645
|
});
|
|
4574
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
|
+
}
|
|
4575
4651
|
_acknowledgeAndRestore(clientRevision) {
|
|
4576
4652
|
this._acknowledgedClientRevision = Math.max(this._acknowledgedClientRevision, clientRevision);
|
|
4577
4653
|
this._pushFullUpdate(true);
|
|
@@ -4724,12 +4800,16 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4724
4800
|
_connection;
|
|
4725
4801
|
_host;
|
|
4726
4802
|
_hostTransportProxy;
|
|
4803
|
+
_presentationHost;
|
|
4727
4804
|
_onError;
|
|
4728
4805
|
_hostTransport;
|
|
4729
4806
|
_content = void 0;
|
|
4730
4807
|
_readOnly = false;
|
|
4731
4808
|
_options = void 0;
|
|
4732
4809
|
_hostCapabilities;
|
|
4810
|
+
_connected = false;
|
|
4811
|
+
_presentationMode;
|
|
4812
|
+
_presentationPreferences;
|
|
4733
4813
|
_pendingHostTransportMessages = [];
|
|
4734
4814
|
_hostTransportActivated = false;
|
|
4735
4815
|
_clientRevision = 0;
|
|
@@ -4744,6 +4824,9 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4744
4824
|
onDidChangeReadOnly = this._onDidChangeReadOnly.event;
|
|
4745
4825
|
_onDidChangeOptions = new Emitter();
|
|
4746
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;
|
|
4747
4830
|
_onDidReceiveHostMessage = new Emitter();
|
|
4748
4831
|
/** Resolves once the host has acknowledged `initialized`. */
|
|
4749
4832
|
onDidConnect;
|
|
@@ -4757,6 +4840,7 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4757
4840
|
this._onError = options.onError ?? ((m, d) => console.error("WebEditorClient:", m, d));
|
|
4758
4841
|
this._host = this._connection.get(webEditorHostInterface);
|
|
4759
4842
|
this._hostTransportProxy = this._connection.get(webEditorHostTransportInterface);
|
|
4843
|
+
this._presentationHost = this._connection.get(webEditorPresentationHostInterface);
|
|
4760
4844
|
this._connection.register(webEditorInterface, {
|
|
4761
4845
|
update: (params) => this._handleUpdate(params),
|
|
4762
4846
|
applyContentEdits: (params) => this._handleApplyContentEdits(params),
|
|
@@ -4764,6 +4848,11 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4764
4848
|
return { schema: options.getContentSchema ? await options.getContentSchema() : null };
|
|
4765
4849
|
}
|
|
4766
4850
|
});
|
|
4851
|
+
this._connection.register(webEditorPresentationInterface, { changed: ({ mode }) => {
|
|
4852
|
+
if (mode === this._presentationMode) return;
|
|
4853
|
+
this._presentationMode = mode;
|
|
4854
|
+
this._onDidChangePresentationMode.fire({ mode });
|
|
4855
|
+
} });
|
|
4767
4856
|
this._connection.register(webEditorClientTransportInterface, { message: ({ message }) => {
|
|
4768
4857
|
if (this._hostTransportActivated) this._onDidReceiveHostMessage.fire(message);
|
|
4769
4858
|
else this._pendingHostTransportMessages.push(message);
|
|
@@ -4771,9 +4860,14 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4771
4860
|
this.onDidConnect = this._host.initialized({
|
|
4772
4861
|
protocolVersion: "web-editor/0.12",
|
|
4773
4862
|
contentType: options.contentType ?? "text",
|
|
4774
|
-
capabilities:
|
|
4863
|
+
capabilities: {
|
|
4864
|
+
...options.capabilities,
|
|
4865
|
+
supportsPresentation: true
|
|
4866
|
+
}
|
|
4775
4867
|
}).then((r) => {
|
|
4776
4868
|
this._hostCapabilities = r.capabilities;
|
|
4869
|
+
this._connected = true;
|
|
4870
|
+
if (this._presentationPreferences) this.setPresentationPreferences(this._presentationPreferences);
|
|
4777
4871
|
if (r.capabilities?.supportsHostTransport) this._hostTransport = {
|
|
4778
4872
|
onMessage: (listener) => {
|
|
4779
4873
|
const disposable = this._onDidReceiveHostMessage.event(listener);
|
|
@@ -4838,17 +4932,39 @@ var WebEditorClient = class WebEditorClient {
|
|
|
4838
4932
|
});
|
|
4839
4933
|
}
|
|
4840
4934
|
/**
|
|
4841
|
-
* Report the editor's
|
|
4842
|
-
*
|
|
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.
|
|
4843
4938
|
*/
|
|
4844
4939
|
reportSize(height) {
|
|
4845
4940
|
this._host.reportSize({ height });
|
|
4846
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
|
+
}
|
|
4847
4962
|
dispose() {
|
|
4848
4963
|
this._onDidChangeContent.dispose();
|
|
4849
4964
|
this._onDidApplyHostEdits.dispose();
|
|
4850
4965
|
this._onDidChangeReadOnly.dispose();
|
|
4851
4966
|
this._onDidChangeOptions.dispose();
|
|
4967
|
+
this._onDidChangePresentationMode.dispose();
|
|
4852
4968
|
this._onDidReceiveHostMessage.dispose();
|
|
4853
4969
|
this._pendingHostTransportMessages.length = 0;
|
|
4854
4970
|
this._connection.close();
|
|
@@ -5101,6 +5217,6 @@ var VsCodeAppHostClient = class {
|
|
|
5101
5217
|
}
|
|
5102
5218
|
};
|
|
5103
5219
|
//#endregion
|
|
5104
|
-
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 };
|
|
5105
5221
|
|
|
5106
5222
|
//# sourceMappingURL=index.js.map
|