这样
<!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>
网友回复
python如何实现声纹识别用户进行验证?
在哪可找到各种影视经典角色的配音并克隆音色根据文本说话?
阿里通义大模型哪些是支持多模态的api的ai模型?
js如何实现浏览器中离线语音唤醒语音聊天小助手?
浏览器中如何将WebM视频转成mp4视频?
parlant如何改成qwen 的apikey与baseurl?
如何写一个chrome插件实现截屏自动生成步骤图文教程转成pdf或网页?
python如何通过阿里云的api对域名进行解析和ecs主机服务器进行启动停止等操作?
Tesla Robotaxi可以让特斯拉车自动无人驾驶跑滴滴为车主赚钱,国内以后也会这样吗?
有没有可以监控安卓手机上的app打开后偷偷摸摸做了啥的监控软件?