@vscode/markdown-editor 0.0.2-120 → 0.0.2-122
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/README.md +19 -12
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/web-editors.d.ts +5 -1
- package/dist/web-editors.js +15 -6
- package/dist/web-editors.js.map +1 -1
- package/package.json +2 -2
- package/src/view/editor.css +16 -2
package/dist/web-editors.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ declare class PhysicalIframe implements IDisposable {
|
|
|
138
138
|
dispose(): void;
|
|
139
139
|
private _setup;
|
|
140
140
|
private _getThemeCss;
|
|
141
|
-
|
|
141
|
+
updateTheme(): void;
|
|
142
142
|
private _applyReportedHeight;
|
|
143
143
|
}
|
|
144
144
|
|
|
@@ -159,6 +159,7 @@ declare class PhysicalIframePool implements IDisposable {
|
|
|
159
159
|
park(iframe: HTMLIFrameElement): void;
|
|
160
160
|
dispose(): void;
|
|
161
161
|
layout(): void;
|
|
162
|
+
updateTheme(): void;
|
|
162
163
|
private _createFrame;
|
|
163
164
|
}
|
|
164
165
|
|
|
@@ -259,6 +260,7 @@ export declare class VirtualizedIframeEmbeddedEditorFactory implements IEmbedded
|
|
|
259
260
|
private _layoutObserver;
|
|
260
261
|
private _layoutFrame;
|
|
261
262
|
private readonly _observer;
|
|
263
|
+
private readonly _themeSubscription;
|
|
262
264
|
private readonly _logicalEditors;
|
|
263
265
|
private readonly _pools;
|
|
264
266
|
private readonly _descriptorCache;
|
|
@@ -287,6 +289,8 @@ export declare interface VirtualizedIframeEmbeddedEditorOptions {
|
|
|
287
289
|
readonly frameRoot?: HTMLElement;
|
|
288
290
|
readonly scriptNonce?: string;
|
|
289
291
|
readonly themeCss?: string | (() => string);
|
|
292
|
+
/** Notify existing frames when the CSS returned by themeCss changes. */
|
|
293
|
+
readonly onDidChangeTheme?: (listener: () => void) => IDisposable;
|
|
290
294
|
/** Optional same-origin document URL to load before writing the iframe content. */
|
|
291
295
|
readonly iframeBootstrapUrl?: string;
|
|
292
296
|
readonly defaultHeight?: number;
|
package/dist/web-editors.js
CHANGED
|
@@ -6999,7 +6999,10 @@ class Dl {
|
|
|
6999
6999
|
this._options = t, this._providers = t.providers, this._frameLayer = document.createElement("div"), this._frameLayer.style.position = "absolute", this._frameLayer.style.inset = "0", this._frameLayer.style.height = "0", this._frameLayer.style.pointerEvents = "none", this._frameLayer.style.zIndex = "1", t.frameRoot && this._setFrameRoot(t.frameRoot), this._observer = typeof IntersectionObserver > "u" ? void 0 : new IntersectionObserver((n) => {
|
|
7000
7000
|
for (const r of n)
|
|
7001
7001
|
Array.from(this._logicalEditors).find((i) => i.element === r.target)?.setVisible(r.isIntersecting);
|
|
7002
|
-
}, { root: t.root ?? null })
|
|
7002
|
+
}, { root: t.root ?? null }), this._themeSubscription = t.onDidChangeTheme?.(() => {
|
|
7003
|
+
for (const n of this._pools.values())
|
|
7004
|
+
n.updateTheme();
|
|
7005
|
+
});
|
|
7003
7006
|
}
|
|
7004
7007
|
_frameLayer;
|
|
7005
7008
|
_frameRoot;
|
|
@@ -7007,6 +7010,7 @@ class Dl {
|
|
|
7007
7010
|
_layoutObserver;
|
|
7008
7011
|
_layoutFrame = 0;
|
|
7009
7012
|
_observer;
|
|
7013
|
+
_themeSubscription;
|
|
7010
7014
|
_logicalEditors = /* @__PURE__ */ new Set();
|
|
7011
7015
|
_pools = /* @__PURE__ */ new Map();
|
|
7012
7016
|
_descriptorCache = /* @__PURE__ */ new Map();
|
|
@@ -7056,7 +7060,7 @@ class Dl {
|
|
|
7056
7060
|
}
|
|
7057
7061
|
dispose() {
|
|
7058
7062
|
if (!this._disposed) {
|
|
7059
|
-
this._disposed = !0, this._observer?.disconnect(), this._layoutObserver?.disconnect(), cancelAnimationFrame(this._layoutFrame), window.removeEventListener("resize", this._scheduleLayout);
|
|
7063
|
+
this._disposed = !0, this._observer?.disconnect(), this._themeSubscription?.dispose(), this._layoutObserver?.disconnect(), cancelAnimationFrame(this._layoutFrame), window.removeEventListener("resize", this._scheduleLayout);
|
|
7060
7064
|
for (const t of Array.from(this._logicalEditors))
|
|
7061
7065
|
t.dispose();
|
|
7062
7066
|
this._disposePools(), this._frameLayer.remove(), this._frameRoot && this._restoreFrameRootPosition !== void 0 && (this._frameRoot.style.position = this._restoreFrameRootPosition);
|
|
@@ -7168,7 +7172,7 @@ class Rl {
|
|
|
7168
7172
|
}
|
|
7169
7173
|
applyHeight(t) {
|
|
7170
7174
|
const n = Ft(t);
|
|
7171
|
-
this.element.style.minHeight = `${n}px`, this.frame && (this.frame.iframe.style.height = `${n}px`, this.frame.layout(this));
|
|
7175
|
+
this.element.style.minHeight = `${n}px`, this._frameHost.style.height = `${n}px`, this.frame && (this.frame.iframe.style.height = `${n}px`, this.frame.layout(this));
|
|
7172
7176
|
}
|
|
7173
7177
|
observeLayout(t) {
|
|
7174
7178
|
t.observe(this.element);
|
|
@@ -7189,6 +7193,7 @@ class Rl {
|
|
|
7189
7193
|
this.disposed || (this.disposed = !0, this._factory.remove(this), this.element.remove());
|
|
7190
7194
|
}
|
|
7191
7195
|
_renderFallback() {
|
|
7196
|
+
this._frameHost.style.height = "";
|
|
7192
7197
|
const t = document.createElement("pre"), n = document.createElement("code");
|
|
7193
7198
|
n.textContent = this._content, t.appendChild(n), this._frameHost.replaceChildren(t);
|
|
7194
7199
|
}
|
|
@@ -7228,6 +7233,10 @@ class Nl {
|
|
|
7228
7233
|
for (const t of this._frames)
|
|
7229
7234
|
t.editor && t.layout(t.editor);
|
|
7230
7235
|
}
|
|
7236
|
+
updateTheme() {
|
|
7237
|
+
for (const t of this._frames)
|
|
7238
|
+
t.updateTheme();
|
|
7239
|
+
}
|
|
7231
7240
|
_createFrame() {
|
|
7232
7241
|
const t = this.descriptor.hostTransport ? this._provider.createHostTransport?.(this.descriptor.runtimeKey) : void 0, n = new Cl(
|
|
7233
7242
|
this,
|
|
@@ -7282,7 +7291,7 @@ class Cl {
|
|
|
7282
7291
|
layout(t) {
|
|
7283
7292
|
if (this.editor !== t)
|
|
7284
7293
|
return;
|
|
7285
|
-
const n = t.
|
|
7294
|
+
const n = t.frameHost.getBoundingClientRect(), r = this._frameRoot.getBoundingClientRect(), o = this._frameRoot === document.body, i = o ? n.top + window.scrollY : n.top - r.top + this._frameRoot.scrollTop, s = o ? n.left + window.scrollX : n.left - r.left + this._frameRoot.scrollLeft;
|
|
7286
7295
|
this.iframe.style.top = `${i}px`, this.iframe.style.left = `${s}px`, this.iframe.style.right = "", this.iframe.style.width = `${n.width}px`;
|
|
7287
7296
|
}
|
|
7288
7297
|
dispose() {
|
|
@@ -7304,7 +7313,7 @@ class Cl {
|
|
|
7304
7313
|
initialText: r?.content ?? "",
|
|
7305
7314
|
readOnly: r?.readOnly ?? !1,
|
|
7306
7315
|
hostTransport: this._hostTransport
|
|
7307
|
-
}), this._host.onDidChangeText(({ text: i }) => this.editor?.applyGuestText(i)), this._host.onDidReportSize(({ height: i }) => this._applyReportedHeight(i)), this.iframe.addEventListener("load", () => this.
|
|
7316
|
+
}), this._host.onDidChangeText(({ text: i }) => this.editor?.applyGuestText(i)), this._host.onDidReportSize(({ height: i }) => this._applyReportedHeight(i)), this.iframe.addEventListener("load", () => this.updateTheme(), { once: !0 });
|
|
7308
7317
|
const o = Zl(
|
|
7309
7318
|
this._descriptor.html,
|
|
7310
7319
|
this._descriptor.resourceBaseUrl,
|
|
@@ -7319,7 +7328,7 @@ class Cl {
|
|
|
7319
7328
|
_getThemeCss() {
|
|
7320
7329
|
return typeof this._themeCss == "function" ? this._themeCss() : this._themeCss;
|
|
7321
7330
|
}
|
|
7322
|
-
|
|
7331
|
+
updateTheme() {
|
|
7323
7332
|
const t = this._getThemeCss();
|
|
7324
7333
|
t !== void 0 && this.iframe.contentWindow?.postMessage({ type: Xe, themeCss: t }, "*");
|
|
7325
7334
|
}
|