Skip to content

feat: v1.5.0 review fixes and new options#30

Open
mcanouil wants to merge 3 commits into
mainfrom
feat/v1.5.0-review-fixes
Open

feat: v1.5.0 review fixes and new options#30
mcanouil wants to merge 3 commits into
mainfrom
feat/v1.5.0-review-fixes

Conversation

@mcanouil
Copy link
Copy Markdown
Owner

@mcanouil mcanouil commented May 28, 2026

Acts on the quarto-elevator (v1.4.0) section of the monorepo review.
Fixes the JavaScript-escaping bug that breaks the generated init script when anchor IDs or audio paths contain ", \, <, or newlines, surfaces a clear warning when the bundled default ding.mp3 is missing, and adds the requested enhancements: volume, loop control, built-in named sounds, a keyboard shortcut, and a document-level disable.
Bumps the extension to v1.5.0.

  • fix: JavaScript-escape anchor IDs and audio paths (elevator.lua).
    A new escape_js_string helper in _modules/string.lua escapes \\, ", ', control characters, and </ so payloads cannot break out of the surrounding inline <script> tag.

  • fix: Warn (once per render) when the bundled default ding.mp3 resource cannot be located alongside the extension.

  • fix: HTML-escape the button text so markup in the text argument is rendered as plain text rather than dropped or interpreted.

  • feat: volume attribute.
    Clamps to [0.0, 1.0]; warns on out-of-range or non-numeric input.
    Implemented by temporarily wrapping window.Audio during new Elevator(...) because Elevator.js holds its audio objects in private closure variables.

  • feat: loop-audio attribute.
    Defaults to true (matching Elevator.js's own default).
    When false, the wrapped Audio ignores Elevator.js's internal setAttribute('loop', 'false') (which would otherwise still enable looping because loop is a boolean attribute).

  • feat: Built-in named sounds.
    audio=ding and end=ding resolve to the bundled ding.mp3.

  • feat: shortcut attribute.
    Binds a single KeyboardEvent.key value (e.g., "t", "Escape") that triggers the elevator from anywhere on the page, except inside <input>, <textarea>, <select>, or contenteditable elements.

  • feat: Document-level disable.
    elevator: false (or elevator: { enabled: false }) in YAML metadata suppresses every {{< elevator >}} invocation in that document.

  • docs: Document new attributes (volume, loop-audio, shortcut), built-in named sounds, and the global disable in README.md, example.qmd, _schema.yml, and _snippets.json.

  • docs: Fix a broken link in README.md (_extensions/elevator/BossaBossa.mp3 to BossaBossa.mp3; the file ships at the repo root, not inside the extension).

  • docs: Bump quarto add ...@1.5.0 references.

  • refactor: Add escape_js_string to _modules/string.lua.

  • refactor: Sync _modules/string.lua and _modules/html.lua @module headers with the canonical style ("name").

  • refactor: Ship _modules/logging.lua from the canonical module set so the filter can call quarto.log.warning with the standard [elevator] ... prefix.

  • refactor: Drop the chatty console.log("Elevator: Initializing...") and "Found ..." debug lines from the generated script; keep the "not found" diagnostics so failures remain visible.

Address the v1.4.0 monorepo review findings and ship the requested
enhancements as a single v1.5.0 release.

Bug fixes
- JavaScript-escape anchor IDs and audio paths via a new
  escape_js_string helper so values containing backslashes, quotes,
  newlines, or </ cannot break out of the inline <script> tag.
- Warn (once per render) when the bundled default ding.mp3 cannot be
  located alongside the extension.
- HTML-escape the button text so markup in the text argument is
  rendered as plain text.

New features
- volume attribute clamped to [0.0, 1.0] with a warning on
  out-of-range or non-numeric input.
- loop-audio attribute that genuinely disables looping by wrapping
  window.Audio around Elevator.js construction.
- Built-in named sounds: audio=ding and end=ding resolve to the
  bundled ding.mp3.
- shortcut attribute binding a single KeyboardEvent.key value,
  ignored inside form fields and contenteditable elements.
- Document-level disable via elevator: false (or
  elevator: { enabled: false }) in YAML metadata.

Docs and scaffolding
- Document the new attributes, named sounds, and global disable in
  README.md, example.qmd, _schema.yml, and _snippets.json.
- Fix the BossaBossa.mp3 link in README.md (file ships at repo root).
- Ship _modules/logging.lua and sync module headers with the
  canonical style.
@mcanouil mcanouil self-assigned this May 28, 2026
@mcanouil mcanouil added the Type: Enhancement 💡 Issues related to enhancements, improvements, new features, or new analyses label May 28, 2026
mcanouil added 2 commits May 28, 2026 23:05
- Drop the module-level globally_disabled cache.
  Re-reading meta on each call is cheap, removes a stale-state risk
  across documents in a project, and shrinks the helper to four lines.
- Inline the needs_audio_wrap flag.
  The condition is short and only used once.
- Unify the custom-button and Quarto back-to-top wiring blocks behind
  a single build_wiring helper that takes a config table.
  The back-to-top variant supplies pre_init_js for the onclick reset
  and omits missing_label so the else branch is skipped.
- Replace em dashes with colons in the build_wiring docstring.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Enhancement 💡 Issues related to enhancements, improvements, new features, or new analyses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant