@vscode/markdown-editor 0.0.2-130 → 0.0.2-132

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.
@@ -72,6 +72,8 @@ declare interface IEmbeddedCodeEditorFactory {
72
72
  * back to the default (highlighting / {@link BlockViewOptions.renderCustomCodeBlock}).
73
73
  */
74
74
  create(language: string, infoString: string, initialContent: string): IEmbeddedCodeEditor | undefined;
75
+ /** Reposition overlays after the document's layout has been measured. */
76
+ layout?(): void;
75
77
  }
76
78
 
77
79
  export declare type IframeEditorPresentationMode = 'inline' | 'full-width' | 'full-view';
@@ -142,6 +144,7 @@ declare class PhysicalIframe implements IDisposable {
142
144
  private _reportedHeight;
143
145
  private _disposed;
144
146
  private readonly _onWindowMessage;
147
+ private readonly _surface;
145
148
  private readonly _toolbar;
146
149
  private readonly _fullWidthButton;
147
150
  private readonly _fullViewButton;
@@ -332,6 +335,7 @@ export declare class VirtualizedIframeEmbeddedEditorFactory implements IEmbedded
332
335
  private _ensureFrameRoot;
333
336
  private _setFrameRoot;
334
337
  private readonly _scheduleLayout;
338
+ layout(): void;
335
339
  private _disposePools;
336
340
  }
337
341
 
@@ -7126,11 +7126,13 @@ class Wl {
7126
7126
  }
7127
7127
  _scheduleLayout = () => {
7128
7128
  this._layoutFrame || (this._layoutFrame = requestAnimationFrame(() => {
7129
- this._layoutFrame = 0;
7130
- for (const e of this._pools.values())
7131
- e.layout();
7129
+ this._layoutFrame = 0, this.layout();
7132
7130
  }));
7133
7131
  };
7132
+ layout() {
7133
+ for (const e of this._pools.values())
7134
+ e.layout();
7135
+ }
7134
7136
  _disposePools() {
7135
7137
  for (const e of this._pools.values())
7136
7138
  e.dispose();
@@ -7323,9 +7325,9 @@ class Fl {
7323
7325
  }
7324
7326
  class Dl {
7325
7327
  constructor(e, n, r, i, o, s, a, c) {
7326
- this._descriptor = n, this._hostTransport = r, this._frameRoot = o, this._scriptNonce = s, this._themeCss = a, this._iframeBootstrapUrl = c, this.pool = e;
7328
+ this._descriptor = n, this._hostTransport = r, this._frameRoot = o, this._scriptNonce = s, this._themeCss = a, this._iframeBootstrapUrl = c, this.pool = e, this._surface = document.createElement("div"), this._surface.className = "md-iframe-surface";
7327
7329
  const u = document.createElement("iframe");
7328
- u.setAttribute("sandbox", Wr(n.sandbox)), u.setAttribute("allow", n.sandbox?.clipboardWrite ? "clipboard-write" : ""), u.style.width = "100%", u.style.border = "none", u.style.display = "block", u.style.position = "absolute", u.style.pointerEvents = "auto", u.style.background = "transparent", u.style.height = `${n.initialHeight ?? 120}px`, e.park(u), u.addEventListener("blur", () => {
7330
+ u.setAttribute("sandbox", Wr(n.sandbox)), u.setAttribute("allow", n.sandbox?.clipboardWrite ? "clipboard-write" : ""), u.style.width = "100%", u.style.border = "none", u.style.display = "block", u.style.position = "absolute", u.style.pointerEvents = "auto", u.style.background = "var(--md-iframe-background, #fff)", u.style.height = `${n.initialHeight ?? 120}px`, e.park(u), u.addEventListener("blur", () => {
7329
7331
  const d = this.editor;
7330
7332
  d && !d.visible && this.pool.release(d);
7331
7333
  }), this.iframe = u, u.className = "md-iframe-frame", this._toolbar = document.createElement("div"), this._toolbar.className = "md-iframe-toolbar", this._toolbar.setAttribute("data-md-editor-chrome", ""), this._toolbar.setAttribute("role", "toolbar"), this._toolbar.setAttribute("aria-label", "Embedded editor presentation"), this._resetHeightButton = this._addButton("Automatic height", "discard", () => this.editor?.resetHeight()), this._fullWidthButton = this._addButton("Full width", "arrow-both", () => this.editor?.toggleFullWidth()), this._fullViewButton = this._addButton("Full view", "screen-full", () => this.editor?.toggleFullView()), this._toolbar.addEventListener("keydown", (d) => {
@@ -7358,7 +7360,7 @@ class Dl {
7358
7360
  return;
7359
7361
  }
7360
7362
  l?.type !== Xe || typeof l.height != "number" || !Number.isFinite(l.height) || this._applyReportedHeight(l.height);
7361
- }, window.addEventListener("message", this._onWindowMessage), i.appendChild(u), i.append(this._toolbar, this._resizeHandle), this._toolbar.hidden = !0, this._resizeHandle.hidden = !0, queueMicrotask(() => this._setup());
7363
+ }, window.addEventListener("message", this._onWindowMessage), this._surface.append(u, this._toolbar, this._resizeHandle), i.appendChild(this._surface), this._surface.hidden = !0, this._toolbar.hidden = !0, this._resizeHandle.hidden = !0, queueMicrotask(() => this._setup());
7362
7364
  }
7363
7365
  iframe;
7364
7366
  editor;
@@ -7369,6 +7371,7 @@ class Dl {
7369
7371
  _reportedHeight;
7370
7372
  _disposed = !1;
7371
7373
  _onWindowMessage;
7374
+ _surface;
7372
7375
  _toolbar;
7373
7376
  _fullWidthButton;
7374
7377
  _fullViewButton;
@@ -7390,7 +7393,7 @@ class Dl {
7390
7393
  return;
7391
7394
  e.exitFullView(), this._endResize();
7392
7395
  const n = e.estimateHeight();
7393
- this.editor = void 0, e.mountActions(), e.unbindFrame(n), this.pool.park(this.iframe), this._toolbar.hidden = !0, this._resizeHandle.hidden = !0;
7396
+ this.editor = void 0, e.mountActions(), e.unbindFrame(n), this.pool.park(this.iframe), this._surface.hidden = !0, this._toolbar.hidden = !0, this._resizeHandle.hidden = !0;
7394
7397
  }
7395
7398
  layout(e) {
7396
7399
  if (this.editor !== e)
@@ -7399,8 +7402,10 @@ class Dl {
7399
7402
  this._frameRoot,
7400
7403
  s.left - (i ? 0 : r.left),
7401
7404
  (o ? s.top : n.top) - (i ? 0 : r.top)
7402
- ), c = st(this._frameRoot, s.width, s.height), u = a.y + (i ? window.scrollY : this._frameRoot.scrollTop), d = a.x + (i ? window.scrollX : this._frameRoot.scrollLeft), l = c.x, h = o ? Math.max(1, c.y) : e.inlineHeight, p = o ? "10" : "";
7403
- this.iframe.style.zIndex = p, this._toolbar.style.zIndex = o ? "11" : "1", this._resizeHandle.style.zIndex = p, this.iframe.style.top = `${u}px`, this.iframe.style.left = `${d}px`, this.iframe.style.right = "", this.iframe.style.width = `${l}px`, this.iframe.style.height = `${h}px`, this._toolbar.hidden = e.toolbarHeight === 0, this._toolbar.classList.toggle("md-iframe-toolbar-full-view", o), e.mountActions(this._toolbar.hidden ? void 0 : this._toolbar), this._toolbar.style.top = `${u + 6}px`, this._toolbar.style.left = `${d + l - 6}px`, this._toolbar.style.maxWidth = `${Math.max(0, l - 12)}px`, this._toolbar.style.height = `${e.toolbarHeight}px`, this._fullWidthButton.hidden = !e.presentation.fullWidth || o, this._fullWidthButton.setAttribute("aria-pressed", String(e.mode === "full-width")), this._fullViewButton.hidden = !e.presentation.fullView, this._setButtonAppearance(this._fullViewButton, o ? "Exit full view" : "Full view", o ? "screen-normal" : "screen-full"), this._fullViewButton.setAttribute("aria-pressed", String(o)), this._resetHeightButton.hidden = !e.presentation.resizable || o, this._resizeHandle.hidden = !e.presentation.resizable || o, this._resizeHandle.style.top = `${u + h}px`, this._resizeHandle.style.left = `${d}px`, this._resizeHandle.style.width = `${l}px`, this._resizeHandle.style.height = `${e.handleHeight}px`, this._resizeHandle.setAttribute("aria-valuenow", String(Math.round(h))), this._resizeHandle.setAttribute("aria-valuemin", String(e.presentation.minHeight ?? 1)), this._resizeHandle.setAttribute("aria-valuemax", String(Ut));
7405
+ ), c = st(this._frameRoot, s.width, s.height), u = a.y + (i ? window.scrollY : this._frameRoot.scrollTop), d = a.x + (i ? window.scrollX : this._frameRoot.scrollLeft), l = c.x, h = o ? Math.max(1, c.y) : e.inlineHeight;
7406
+ this._surface.hidden = !1, this._surface.style.top = `${u}px`, this._surface.style.left = `${d}px`, this._surface.style.width = `${l}px`, this._surface.style.height = `${h + (o ? 0 : e.handleHeight)}px`, this._surface.style.zIndex = o ? "10" : "";
7407
+ const p = o ? "10" : "";
7408
+ this.iframe.style.zIndex = p, this._toolbar.style.zIndex = o ? "11" : "1", this._resizeHandle.style.zIndex = p, this.iframe.style.top = "0", this.iframe.style.left = "0", this.iframe.style.right = "", this.iframe.style.width = `${l}px`, this.iframe.style.height = `${h}px`, this._toolbar.hidden = e.toolbarHeight === 0, this._toolbar.classList.toggle("md-iframe-toolbar-full-view", o), e.mountActions(this._toolbar.hidden ? void 0 : this._toolbar), this._toolbar.style.top = "6px", this._toolbar.style.left = `${l - 6}px`, this._toolbar.style.maxWidth = `${Math.max(0, l - 12)}px`, this._toolbar.style.height = `${e.toolbarHeight}px`, this._fullWidthButton.hidden = !e.presentation.fullWidth || o, this._fullWidthButton.setAttribute("aria-pressed", String(e.mode === "full-width")), this._fullViewButton.hidden = !e.presentation.fullView, this._setButtonAppearance(this._fullViewButton, o ? "Exit full view" : "Full view", o ? "screen-normal" : "screen-full"), this._fullViewButton.setAttribute("aria-pressed", String(o)), this._resetHeightButton.hidden = !e.presentation.resizable || o, this._resizeHandle.hidden = !e.presentation.resizable || o, this._resizeHandle.style.top = `${h}px`, this._resizeHandle.style.left = "0", this._resizeHandle.style.width = `${l}px`, this._resizeHandle.style.height = `${e.handleHeight}px`, this._resizeHandle.setAttribute("aria-valuenow", String(Math.round(h))), this._resizeHandle.setAttribute("aria-valuemin", String(e.presentation.minHeight ?? 1)), this._resizeHandle.setAttribute("aria-valuemax", String(Ut));
7404
7409
  }
7405
7410
  get reportedHeight() {
7406
7411
  return this._reportedHeight;
@@ -7441,7 +7446,7 @@ class Dl {
7441
7446
  this._drag = void 0, this.editor && (this.editor.resizing = !1), this.iframe.style.pointerEvents = "auto", e && this._resizeHandle.hasPointerCapture(e.pointerId) && this._resizeHandle.releasePointerCapture(e.pointerId);
7442
7447
  }
7443
7448
  dispose() {
7444
- this._disposed || (this._disposed = !0, this.unbind(), window.removeEventListener("message", this._onWindowMessage), this._host?.dispose(), this._transport?.dispose(), this._hostTransport?.dispose(), this.iframe.remove(), this._toolbar.remove(), this._resizeHandle.remove());
7449
+ this._disposed || (this._disposed = !0, this.unbind(), window.removeEventListener("message", this._onWindowMessage), this._host?.dispose(), this._transport?.dispose(), this._hostTransport?.dispose(), this.iframe.remove(), this._toolbar.remove(), this._resizeHandle.remove(), this._surface.remove());
7445
7450
  }
7446
7451
  _setup() {
7447
7452
  if (this._disposed)