ui/client/features/pages-editor/services/PreviewSource
The preview transport behind a small interface, so the iframe + postMessage implementation can be swapped (e.g.
Cockpit client (features), v0.8. Source: ui/client/features/pages-editor/services/PreviewSource.ts.
Interfaces#
PreviewSource#
Defined in: ui/client/features/pages-editor/services/PreviewSource.ts:8
Properties#
url
readonlyurl:string
Defined in: ui/client/features/pages-editor/services/PreviewSource.ts:10
Page being previewed.
Methods#
onSelect()
onSelect(
handler): () =>void
Defined in: ui/client/features/pages-editor/services/PreviewSource.ts:12
Subscribe to element selections (a raw data-cx-src value). Returns an unsubscribe.
Parameters
handler
(src) => void
Returns
() => void
onSignal()
onSignal(
handler): () =>void
Defined in: ui/client/features/pages-editor/services/PreviewSource.ts:14
Subscribe to the plugin's ready and the app's error messages. Returns an unsubscribe.
Parameters
handler
(signal) => void
Returns
() => void
Type Aliases#
PreviewSignal#
PreviewSignal = {
type:"ready"; } | {message:string;type:"error"; }
Defined in: ui/client/features/pages-editor/services/PreviewSource.ts:6
What the previewed app tells the Cockpit besides a selection: the preview plugin is loaded (ready),
or the app threw an uncaught error (error). Nothing else crosses.
Functions#
createIframePreviewSource()#
createIframePreviewSource(
url,getFrameWindow):PreviewSource
Defined in: ui/client/features/pages-editor/services/PreviewSource.ts:19
iframe transport: accepts construct:* messages only from the given
iframe's window AND only from the previewed URL's origin.
Parameters#
url
string
getFrameWindow
() => Window | null | undefined