Adds browser behavior to HTML rendered from Lynkow content, accessible via lynkow.enhancements: copy buttons on code blocks, inline script execution, height sync for embedded Lynkow widgets, and CSS that keeps inline text alignment. The client starts it in the browser, and it also enhances content added later. Every method is a no-op on the server.

Restyle code blocks by overriding the --lynkow-code-* CSS custom properties. A light class or data-theme="light" on <html> selects the light variant.

Access via: lynkow.enhancements

Methods

3 methods

destroy

TypeScript
destroy(): void

Stops every enhancement and removes the styles and script copies the service added to <head>. Safe to call repeatedly, and init() starts the enhancements again.

Returns: void

TypeScript
useEffect(() => {
  lynkow.enhancements.init()
  return () => lynkow.enhancements.destroy()
}, [])

init

TypeScript
init(options: EnhancementsInitOptions): void

Starts the enhancements on the page and on content added later. The client calls it in the browser just after createClient() returns. Later calls do nothing until destroy(), so to change the options after startup call destroy(), then init(options).

Parameter

Type

Description

options

EnhancementsInitOptions

codeBlocks and activateScripts toggles, see EnhancementsInitOptions

Returns: void

TypeScript
// Your own highlighter renders code blocks.
lynkow.enhancements.destroy()
lynkow.enhancements.init({ codeBlocks: false })

isInitialized

TypeScript
isInitialized(): boolean

Returns true once init() has run, until destroy(). Always false on the server.

Returns: boolean

TypeScript
if (!lynkow.enhancements.isInitialized()) {
  lynkow.enhancements.init()
}