Skip to content

feat(core): add getStyledPassageElement for vanilla Bible HTML (YPE-5721) - #392

Closed
cameronapak wants to merge 4 commits into
mainfrom
cursor/cp/ype-5721-styled-passage-cdd9
Closed

feat(core): add getStyledPassageElement for vanilla Bible HTML (YPE-5721)#392
cameronapak wants to merge 4 commits into
mainfrom
cursor/cp/ype-5721-styled-passage-cdd9

Conversation

@cameronapak

@cameronapak cameronapak commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Closes YPE-5721.

Summary

Adds BibleClient.getStyledPassageElement({ versionId, usfm, fontId? }) so vanilla JS partners can append a styled Scripture DOM node without assembling Bible CSS, font stylesheet URLs, or copyright markup themselves.

Also lands getFontStylesheetUrl from closed (unmerged) PR #391 so this helper can reuse the Fonts API URL builder. That helper stays public.

Status

Behavior

  • Fetches via existing getPassage (html + transform default) and getVersion
  • Returns a detached element with data-yv-sdk and data-slot="yv-bible-renderer"
  • Sets passage HTML via innerHTML; copyright via textContent ("" if missing)
  • Injects CDN bible.css + font stylesheet into document.head once (deduped by href)
  • Reads appKey / apiHost from the existing ApiClient; default fontId is 1
  • Throws a clear browser-only error when document is missing
  • Propagates version-refuse / API errors from the underlying clients

Out of scope

Test plan

  • Unit/MSW + jsdom: element tokens, passage HTML, copyright textContent
  • Stylesheet inject once; second call does not duplicate links but returns a fresh element
  • Missing document throws; refuse/API errors propagate; optional fontId changes font href only
  • pnpm --filter @youversion/platform-core test
  • Patch changeset for @youversion/platform-core
Open in Web Open in Cursor 

Co-authored-by: Cameron Pak <cameronandrewpak@gmail.com>
@changeset-bot

changeset-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9bd7461

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@youversion/platform-core Patch
@youversion/platform-react-hooks Patch
@youversion/platform-react-ui Patch
vite-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Land the Fonts API stylesheet URL helper from PR 391 so partners can
build CDN font stylesheet URLs from an app key and font id.
@cameronapak cameronapak self-assigned this Sep 9, 2026
Return a detached styled Bible passage element for vanilla JS partners,
injecting CDN bible.css and the Fonts API stylesheet once per document.
Narrow the sibling module surface so only the assemble path is imported
by BibleClient; helpers stay unexported from the package entry.
@cameronapak

Copy link
Copy Markdown
Collaborator Author

I've decided this isn't needed at this time. We can teach users how to import the CSS files manually. I'd rather not deploy another impure function

@cameronapak cameronapak closed this Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants