@openpresentation/opf-editor 0.24.3 → 0.25.0

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.
@@ -83,16 +83,19 @@ export interface PresentButtonOptions {
83
83
  density?: "comfortable" | "touch";
84
84
  /** The accessible name (default "Present"). */
85
85
  label?: string;
86
+ /** `"quiet"` (default): a transparent icon button like the toolbar's undo and redo. `"primary"`: the filled accent look of the Export trigger. */
87
+ variant?: "quiet" | "primary";
86
88
  }
87
89
 
88
90
  export interface PresentButton {
89
91
  readonly element: HTMLButtonElement;
90
92
  setDisabled(reason?: boolean | string): void;
91
93
  setDensity(density: "comfortable" | "touch"): void;
94
+ setVariant(variant: "quiet" | "primary"): void;
92
95
  destroy(): void;
93
96
  }
94
97
 
95
- /** The icon-only Present button: a Lucide Presentation icon, `aria-label="Present"`, title "Present (F5)", styled like the Export trigger. */
98
+ /** The icon-only Present button: a Lucide Presentation icon, `aria-label="Present"`, title "Present (F5)". Quiet by default (a transparent icon button like undo and redo); `variant: "primary"` styles it like the Export trigger. */
96
99
  export declare function createPresentButton(container: HTMLElement, options?: PresentButtonOptions): PresentButton;
97
100
 
98
101
  /**
package/dist/presenter.js CHANGED
@@ -372,9 +372,10 @@ function isInteractiveTarget(target) {
372
372
  * Mount the Present button in `container`: an icon-only button (Lucide Presentation) named "Present", titled "Present (F5)".
373
373
  *
374
374
  * Options: `onPresent(event)`, `disabled` (`true`, or a string that says why and is the title), `density` (`"comfortable"` 32px, or `"touch"` 40px)
375
- * and `label` (the accessible name, default "Present"). A disabled button stays focusable (`aria-disabled`) and does nothing.
375
+ * `label` (the accessible name, default "Present") and `variant` (`"quiet"`, the default: a transparent icon button like the toolbar's undo and redo,
376
+ * or `"primary"`: the filled accent look of the Export trigger). A disabled button stays focusable (`aria-disabled`) and does nothing.
376
377
  *
377
- * Returns `{ element, setDisabled(reason), setDensity(density), destroy() }`.
378
+ * Returns `{ element, setDisabled(reason), setDensity(density), setVariant(variant), destroy() }`.
378
379
  */
379
380
  export function createPresentButton(container, options = {}) {
380
381
  if (!container?.ownerDocument) throw new TypeError("A DOM container is required.");
@@ -384,7 +385,7 @@ export function createPresentButton(container, options = {}) {
384
385
  let destroyed = false;
385
386
  const button = el(doc, "button", {
386
387
  type: "button", class: "opf-present-button opf-ui", "aria-label": label, title: "Present (F5)", "aria-keyshortcuts": "F5",
387
- "data-density": options.density === "touch" ? "touch" : "comfortable",
388
+ "data-density": options.density === "touch" ? "touch" : "comfortable", "data-variant": options.variant === "primary" ? "primary" : "quiet",
388
389
  }, icon(doc, "Presentation", 16));
389
390
  const paint = () => {
390
391
  if (disabledReason) { button.setAttribute("aria-disabled", "true"); button.title = disabledReason; }
@@ -404,6 +405,7 @@ export function createPresentButton(container, options = {}) {
404
405
  paint();
405
406
  },
406
407
  setDensity(next) { button.dataset.density = next === "touch" ? "touch" : "comfortable"; },
408
+ setVariant(next) { button.dataset.variant = next === "primary" ? "primary" : "quiet"; },
407
409
  destroy() { destroyed = true; button.remove(); },
408
410
  };
409
411
  }
@@ -9,6 +9,7 @@ import {
9
9
  import { listSwitchOptions } from "./switches.js";
10
10
  import { layoutRegionSummary } from "./layout-templates.js";
11
11
  import { groupLayoutChoices } from "./layout-templates.js";
12
+ import { buildLayoutDiagram } from "./layout-diagram.js";
12
13
  import { switchDimension } from "./switches.js";
13
14
 
14
15
  let instances = 0;
@@ -521,13 +522,8 @@ export function createSlideManager(container, options) {
521
522
  template.replaceChildren(); currentPreview.replaceChildren();
522
523
  if (choice?.record?.preview && typeof choice.record.preview === "string") {
523
524
  template.append(el("img", { src: choice.record.preview, alt: `${choice.label} template preview` }));
524
- } else if (Array.isArray(choice?.record?.areas)) {
525
- const diagram = el("div", { class: "opf-layout-diagram" });
526
- diagram.style.gridTemplateAreas = choice.record.areas.map((row) => `"${row.join(" ")}"`).join(" ");
527
- diagram.style.gridTemplateColumns = `repeat(${choice.record.areas[0]?.length ?? 1}, 1fr)`;
528
- const areas = [...new Set(choice.record.areas.flat())].filter((area) => area !== ".");
529
- for (const area of areas) { const part = el("span", { text: area }); part.style.gridArea = area; diagram.append(part); }
530
- template.append(diagram);
525
+ } else if (Array.isArray(choice?.record?.regions)) {
526
+ template.append(buildLayoutDiagram(document, choice.record));
531
527
  }
532
528
  if (choice && options.renderLayoutPreview) {
533
529
  try { currentPreview.innerHTML = options.renderLayoutPreview(deck(), current(), choice) ?? ""; }