@vscode/markdown-editor 0.0.2-51 → 0.0.2-53
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/commands.d.ts +65 -0
- package/dist/commands.js +159 -0
- package/dist/commands.js.map +1 -0
- package/dist/index.d.ts +21 -4
- package/dist/index.js +1731 -1862
- package/dist/index.js.map +1 -1
- package/dist/web-editors.d.ts +189 -4
- package/dist/web-editors.js +1751 -1355
- package/dist/web-editors.js.map +1 -1
- package/package.json +10 -2
package/dist/web-editors.d.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
import { ContentType } from '@vscode/web-editors';
|
|
2
|
+
import { IDisposable } from './_observables/index';
|
|
3
|
+
|
|
4
|
+
export declare interface CodeBlockEditorProviderDefinition {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly selector: CodeBlockEditorSelector;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare type CodeBlockEditorProviderSelection<T> = {
|
|
10
|
+
readonly kind: 'match';
|
|
11
|
+
readonly provider: T;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'ambiguous';
|
|
14
|
+
readonly providers: readonly T[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export declare type CodeBlockEditorSelector = {
|
|
18
|
+
readonly language: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly languagePrefix: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
1
23
|
/**
|
|
2
24
|
* Build an {@link IEmbeddedCodeEditorFactory} that renders matching code blocks
|
|
3
25
|
* with the sample web editor embedded in an iframe.
|
|
@@ -28,6 +50,8 @@ declare interface IEmbeddedCodeEditor {
|
|
|
28
50
|
* is how edits the editor itself originated are prevented from echoing back.
|
|
29
51
|
*/
|
|
30
52
|
setContent(content: string): void;
|
|
53
|
+
/** Update whether the embedded editor may change its content. */
|
|
54
|
+
setReadOnly?(readOnly: boolean): void;
|
|
31
55
|
/**
|
|
32
56
|
* Optional synchronous height (px) to reserve for `content` *before* the
|
|
33
57
|
* editor has laid out. Return `undefined` to let the editor size itself
|
|
@@ -53,13 +77,15 @@ declare interface IEmbeddedCodeEditorFactory {
|
|
|
53
77
|
create(language: string, initialContent: string): IEmbeddedCodeEditor | undefined;
|
|
54
78
|
}
|
|
55
79
|
|
|
56
|
-
|
|
57
|
-
/** The guest bundle source (an IIFE/ESM string), inlined into the iframe. */
|
|
58
|
-
readonly bundleJs: string;
|
|
80
|
+
declare interface IframeEmbeddedEditorBaseOptions {
|
|
59
81
|
/** Decide whether this factory handles `language`. */
|
|
60
82
|
readonly handlesLanguage: (language: string) => boolean;
|
|
83
|
+
/** Content representation used by the guest. Default `text`. */
|
|
84
|
+
readonly contentType?: ContentType;
|
|
85
|
+
/** Nonce applied to author and host-injected scripts for an inherited parent CSP. */
|
|
86
|
+
readonly scriptNonce?: string;
|
|
61
87
|
/** Theme CSS injected into the iframe `<head>` (e.g. `--vscode-*` variables). */
|
|
62
|
-
readonly themeCss?: string;
|
|
88
|
+
readonly themeCss?: string | (() => string);
|
|
63
89
|
/**
|
|
64
90
|
* Optional synchronous height (px) reserved from content before the guest
|
|
65
91
|
* measures itself. Return `undefined` to let the guest size the frame.
|
|
@@ -67,6 +93,29 @@ export declare interface IframeEmbeddedEditorOptions {
|
|
|
67
93
|
readonly estimateHeight?: (content: string) => number | undefined;
|
|
68
94
|
}
|
|
69
95
|
|
|
96
|
+
export declare type IframeEmbeddedEditorOptions = IframeEmbeddedEditorBaseOptions & ({
|
|
97
|
+
/** Self-contained HTML document loaded into the sandboxed iframe. */
|
|
98
|
+
readonly html: string;
|
|
99
|
+
readonly bundleJs?: never;
|
|
100
|
+
} | {
|
|
101
|
+
/** @deprecated Use `html`. Retained for the sample fixture. */
|
|
102
|
+
readonly bundleJs: string;
|
|
103
|
+
readonly html?: never;
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
export declare interface IframeEmbeddedEditorProvider extends CodeBlockEditorProviderDefinition {
|
|
107
|
+
readonly resolve: (language: string) => Promise<ResolvedIframeEmbeddedEditor | undefined>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export declare type IframeEmbeddedEditorProviderSelector = CodeBlockEditorSelector;
|
|
111
|
+
|
|
112
|
+
declare interface IframeSandboxOptions {
|
|
113
|
+
readonly forms?: boolean;
|
|
114
|
+
readonly downloads?: boolean;
|
|
115
|
+
readonly pointerLock?: boolean;
|
|
116
|
+
readonly clipboardWrite?: boolean;
|
|
117
|
+
}
|
|
118
|
+
|
|
70
119
|
declare class OffsetRange {
|
|
71
120
|
readonly start: number;
|
|
72
121
|
readonly endExclusive: number;
|
|
@@ -94,6 +143,59 @@ declare class OffsetRange {
|
|
|
94
143
|
toString(): string;
|
|
95
144
|
}
|
|
96
145
|
|
|
146
|
+
declare class PhysicalIframe implements IDisposable {
|
|
147
|
+
private readonly _descriptor;
|
|
148
|
+
private readonly _frameRoot;
|
|
149
|
+
private readonly _scriptNonce;
|
|
150
|
+
private readonly _themeCss;
|
|
151
|
+
readonly iframe: HTMLIFrameElement;
|
|
152
|
+
editor: VirtualizedIframeEmbeddedEditor | undefined;
|
|
153
|
+
readonly pool: PhysicalIframePool;
|
|
154
|
+
private _host;
|
|
155
|
+
private _transport;
|
|
156
|
+
private _pendingEditor;
|
|
157
|
+
private _disposed;
|
|
158
|
+
private readonly _onWindowMessage;
|
|
159
|
+
constructor(pool: PhysicalIframePool, _descriptor: ResolvedIframeEmbeddedEditor, frameLayer: HTMLElement, _frameRoot: HTMLElement, _scriptNonce: string | undefined, _themeCss: string | (() => string) | undefined);
|
|
160
|
+
bind(editor: VirtualizedIframeEmbeddedEditor): void;
|
|
161
|
+
unbind(): void;
|
|
162
|
+
layout(editor: VirtualizedIframeEmbeddedEditor): void;
|
|
163
|
+
dispose(): void;
|
|
164
|
+
private _setup;
|
|
165
|
+
private _getThemeCss;
|
|
166
|
+
private _postTheme;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
declare class PhysicalIframePool implements IDisposable {
|
|
170
|
+
private readonly _frameLayer;
|
|
171
|
+
private readonly _frameRoot;
|
|
172
|
+
private readonly _scriptNonce;
|
|
173
|
+
private readonly _themeCss;
|
|
174
|
+
readonly descriptor: ResolvedIframeEmbeddedEditor;
|
|
175
|
+
private readonly _frames;
|
|
176
|
+
constructor(descriptor: ResolvedIframeEmbeddedEditor, _frameLayer: HTMLElement, _frameRoot: HTMLElement, _scriptNonce: string | undefined, _themeCss: string | (() => string) | undefined);
|
|
177
|
+
get leasedFrames(): number;
|
|
178
|
+
get idleFrames(): number;
|
|
179
|
+
acquire(editor: VirtualizedIframeEmbeddedEditor): void;
|
|
180
|
+
release(editor: VirtualizedIframeEmbeddedEditor): void;
|
|
181
|
+
park(iframe: HTMLIFrameElement): void;
|
|
182
|
+
dispose(): void;
|
|
183
|
+
layout(): void;
|
|
184
|
+
private _createFrame;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export declare interface ResolvedIframeEmbeddedEditor {
|
|
188
|
+
readonly cacheKey?: string;
|
|
189
|
+
readonly html: string;
|
|
190
|
+
readonly contentType?: ContentType;
|
|
191
|
+
readonly initialHeight?: number;
|
|
192
|
+
readonly sandbox?: IframeSandboxOptions;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export declare type ResolvedIframeEmbeddedEditorSandbox = IframeSandboxOptions;
|
|
196
|
+
|
|
197
|
+
export declare function selectCodeBlockEditorProvider<T extends CodeBlockEditorProviderDefinition>(providers: readonly T[], language: string): CodeBlockEditorProviderSelection<T> | undefined;
|
|
198
|
+
|
|
97
199
|
declare class StringEdit {
|
|
98
200
|
static readonly empty: StringEdit;
|
|
99
201
|
static single(replacement: StringReplacement): StringEdit;
|
|
@@ -127,4 +229,87 @@ declare class StringReplacement {
|
|
|
127
229
|
toString(): string;
|
|
128
230
|
}
|
|
129
231
|
|
|
232
|
+
declare class VirtualizedIframeEmbeddedEditor implements IEmbeddedCodeEditor {
|
|
233
|
+
private readonly _factory;
|
|
234
|
+
readonly provider: IframeEmbeddedEditorProvider;
|
|
235
|
+
readonly element: HTMLElement;
|
|
236
|
+
onEdit?: (edit: StringEdit) => void;
|
|
237
|
+
readonly estimateHeight: () => number;
|
|
238
|
+
frame: PhysicalIframe | undefined;
|
|
239
|
+
disposed: boolean;
|
|
240
|
+
visible: boolean;
|
|
241
|
+
readonly language: string;
|
|
242
|
+
private readonly _frameHost;
|
|
243
|
+
private _content;
|
|
244
|
+
private _readOnly;
|
|
245
|
+
private _pool;
|
|
246
|
+
private _resolved;
|
|
247
|
+
constructor(_factory: VirtualizedIframeEmbeddedEditorFactory, provider: IframeEmbeddedEditorProvider, language: string, initialContent: string, initialHeight: number, generation: number);
|
|
248
|
+
setContent(content: string): void;
|
|
249
|
+
setReadOnly(readOnly: boolean): void;
|
|
250
|
+
setVisible(visible: boolean): void;
|
|
251
|
+
resolve(pool: PhysicalIframePool | undefined): void;
|
|
252
|
+
invalidate(): void;
|
|
253
|
+
bindFrame(frame: PhysicalIframe): void;
|
|
254
|
+
unbindFrame(height: number): void;
|
|
255
|
+
applyGuestText(text: string): void;
|
|
256
|
+
applyHeight(height: number): void;
|
|
257
|
+
observeLayout(observer: ResizeObserver): void;
|
|
258
|
+
hasFocus(): boolean;
|
|
259
|
+
get content(): string;
|
|
260
|
+
get readOnly(): boolean;
|
|
261
|
+
get frameHost(): HTMLElement;
|
|
262
|
+
dispose(): void;
|
|
263
|
+
private _renderFallback;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export declare interface VirtualizedIframeEmbeddedEditorDiagnostics {
|
|
267
|
+
readonly logicalEditors: number;
|
|
268
|
+
readonly leasedFrames: number;
|
|
269
|
+
readonly idleFrames: number;
|
|
270
|
+
readonly descriptorCacheEntries: number;
|
|
271
|
+
readonly descriptorCacheHits: number;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export declare class VirtualizedIframeEmbeddedEditorFactory implements IEmbeddedCodeEditorFactory, IDisposable {
|
|
275
|
+
private readonly _options;
|
|
276
|
+
private readonly _frameLayer;
|
|
277
|
+
private _frameRoot;
|
|
278
|
+
private _restoreFrameRootPosition;
|
|
279
|
+
private _layoutObserver;
|
|
280
|
+
private _layoutFrame;
|
|
281
|
+
private readonly _observer;
|
|
282
|
+
private readonly _logicalEditors;
|
|
283
|
+
private readonly _pools;
|
|
284
|
+
private readonly _descriptorCache;
|
|
285
|
+
private readonly _rejectedProviders;
|
|
286
|
+
private _providers;
|
|
287
|
+
private _generation;
|
|
288
|
+
private _descriptorCacheHits;
|
|
289
|
+
private _disposed;
|
|
290
|
+
constructor(_options: VirtualizedIframeEmbeddedEditorOptions);
|
|
291
|
+
updateProviders(providers: readonly IframeEmbeddedEditorProvider[]): void;
|
|
292
|
+
get diagnostics(): VirtualizedIframeEmbeddedEditorDiagnostics;
|
|
293
|
+
create(language: string, initialContent: string): IEmbeddedCodeEditor | undefined;
|
|
294
|
+
dispose(): void;
|
|
295
|
+
remove(editor: VirtualizedIframeEmbeddedEditor): void;
|
|
296
|
+
resolve(editor: VirtualizedIframeEmbeddedEditor, generation: number): Promise<void>;
|
|
297
|
+
private _rejectEditor;
|
|
298
|
+
private _ensureFrameRoot;
|
|
299
|
+
private _setFrameRoot;
|
|
300
|
+
private readonly _scheduleLayout;
|
|
301
|
+
private _disposePools;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export declare interface VirtualizedIframeEmbeddedEditorOptions {
|
|
305
|
+
readonly providers: readonly IframeEmbeddedEditorProvider[];
|
|
306
|
+
readonly root?: Element | Document | null;
|
|
307
|
+
readonly frameRoot?: HTMLElement;
|
|
308
|
+
readonly scriptNonce?: string;
|
|
309
|
+
readonly themeCss?: string | (() => string);
|
|
310
|
+
readonly defaultHeight?: number;
|
|
311
|
+
readonly onAmbiguous?: (language: string, providers: readonly CodeBlockEditorProviderDefinition[]) => void;
|
|
312
|
+
readonly onDidChange?: () => void;
|
|
313
|
+
}
|
|
314
|
+
|
|
130
315
|
export { }
|