feat: add openUrl bridge action, allow-popups sandbox, fix white iframe corners
- Add allow-popups to DB card iframe sandbox attribute - Add host.openUrl capability, openUrl action type, and bridge handler - Add openUrl() wrapper to plugin-side bridge SDK - Add openUrl handler in DbInlineCard (window.open on behalf of iframe) - Fix white corners: borderRadius + overflow:hidden + colorScheme:dark on iframe element
This commit is contained in:
@@ -106,6 +106,12 @@ export function DbInlineCard({
|
||||
if (path) navigate(path)
|
||||
return { ok: true }
|
||||
},
|
||||
openUrl: (params) => {
|
||||
const url = typeof params.url === 'string' ? params.url : ''
|
||||
const target = typeof params.target === 'string' ? params.target : '_blank'
|
||||
if (url) window.open(url, target)
|
||||
return { ok: true }
|
||||
},
|
||||
sendMessage: (params) => {
|
||||
const text = typeof params.text === 'string' ? params.text : ''
|
||||
if (text) onSendMessage?.(text)
|
||||
@@ -144,10 +150,11 @@ export function DbInlineCard({
|
||||
<iframe
|
||||
ref={iframeRef}
|
||||
srcDoc={srcDoc}
|
||||
sandbox="allow-scripts"
|
||||
sandbox="allow-scripts allow-popups"
|
||||
style={{
|
||||
display: 'block', width: '100%', height, border: 'none',
|
||||
background: 'transparent', marginTop: 8,
|
||||
borderRadius: 10, overflow: 'hidden', colorScheme: 'dark',
|
||||
}}
|
||||
title={template.name}
|
||||
/>
|
||||
|
||||
@@ -48,6 +48,7 @@ export const PLUGIN_BRIDGE_SDK = `(function(){
|
||||
params:function(){return launchParams;},
|
||||
navigate:function(path){return send('navigate',{path:path});},
|
||||
openSurface:function(opts){return send('openSurface',opts||{});},
|
||||
openUrl:function(url,target){return send('openUrl',{url:url,target:target||'_blank'});},
|
||||
sendMessage:function(text){return send('sendMessage',{text:text});},
|
||||
requestFullscreen:function(){return send('requestFullscreen',{});},
|
||||
setMaximized:function(v){return send('setMaximized',{maximized:!!v});},
|
||||
|
||||
@@ -33,6 +33,7 @@ export const BRIDGE_PROTOCOL_VERSION = 1 as const
|
||||
export type PluginCapability =
|
||||
| 'host.navigate'
|
||||
| 'host.openSurface'
|
||||
| 'host.openUrl'
|
||||
| 'host.sendMessage'
|
||||
| 'host.fullscreen'
|
||||
| 'host.close'
|
||||
@@ -41,6 +42,7 @@ export type PluginCapability =
|
||||
export type PluginActionType =
|
||||
| 'navigate'
|
||||
| 'openSurface'
|
||||
| 'openUrl'
|
||||
| 'sendMessage'
|
||||
| 'requestFullscreen'
|
||||
| 'setMaximized'
|
||||
@@ -49,6 +51,7 @@ export type PluginActionType =
|
||||
const ACTION_CAPABILITY: Record<PluginActionType, PluginCapability> = {
|
||||
navigate: 'host.navigate',
|
||||
openSurface: 'host.openSurface',
|
||||
openUrl: 'host.openUrl',
|
||||
sendMessage: 'host.sendMessage',
|
||||
requestFullscreen: 'host.fullscreen',
|
||||
setMaximized: 'host.fullscreen',
|
||||
|
||||
Reference in New Issue
Block a user