这样

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="//repo.bfw.wiki/bfwrepo/css/grapes.0.21.1.css">
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/grapes.0.21.1.js"></script>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/grapesjs-preset-webpage.1.0.2.js"></script>
<style>
body, html {
height: 100%;
margin: 0;
}
#gjs {
border: 3px solid #444;
}
</style>
</head>
<body>
<div id="gjs" style="height:100%;"></div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const editor = grapesjs.init({
container: '#gjs',
fromElement: true,
height: '100%',
width: 'auto',
plugins: ['gjs-preset-webpage'],
pluginsOpts: {
'gjs-preset-webpage': {}
}
});
// Initial content
editor.setComponents(`
<div>
<p id="selectable-link">Click here to select a link</p>
</div>
`);
const links = [
{ label: 'Google', value: 'https://www.google.com' },
{ label: 'Facebook', value: 'https://www.facebook.com' },
{ label: 'Twitter', value: 'https://www.twitter.com' }
];
// Extend the Component Manager to add a custom trait for href
editor.Components.addType('link', {
model: {
defaults: {
traits: [
// Replace href trait with a dropdown
{
type: 'select',
label: 'Href',
name: 'href',
options: links.map(link => ({ value: link.value, name: link.label }))
}
]
}
}
});
// Apply the custom link component type to <a> elements
editor.DomComponents.addType('link', {
isComponent: el => el.tagName === 'A',
model: {
defaults: {
tagName: 'a',
draggable: true,
droppable: true,
traits: [
{
type: 'select',
label: 'Href',
name: 'href',
options: links.map(link => ({ value: link.value, name: link.label }))
}
]
}
}
});
// Convert the initial text element to a link component when selected
editor.on('component:selected', (component) => {
if (component.getAttributes().id === 'selectable-link') {
component.set({ tagName: 'a', draggable: true, droppable: true });
component.addTraits([
{
type: 'select',
label: 'Href',
name: 'href',
options: links.map(link => ({ value: link.value, name: link.label }))
}
]);
}
});
});
</script>
</body>
</html>
网友回复
同一个中英混合文本不同大模型计算tokens长度一致吗?
Browser Use / Playwright / Puppeteer 与Chrome DevTools Protocol(CDP)的关系?
能否在三维空间调用ai的api实现vrm模型执行任意的姿势动作与行走完成任务?
如何让openclaw小龙虾自动帮你打电话聊客户?
各大公司推出的claw是否是为了大家消费自己的大模型tokens?
云服务器什么配置才能部署openclaw?
为啥ai生成视频模型只能5秒10秒或15秒生成,不能一次生成1分钟1i小时呢?
技术上如何解决被曝光的ai投毒geo行为?
有没有哪个大模型可以根据声音和文字描述生成带声音的视频?
如何实现华为手机终端设备之间隔空握拳抓取传送信息?


