SuperAPI AI 工具集

unlayer-integration

通用与其它

查看项目

更新于 10-15 23:58

技能介绍

用途:把 Unlayer 编辑器(邮件、页面、弹窗、文档构建器)集成进 Web 应用,提供 React、Vue、Angular 官方封装及纯 JavaScript 嵌入方式,各封装共享同一底层 API,仅编辑器实例获取方式不同。独立的 Image Editor 或 @unlayer/react-image-editor 不在此范围内。

主要能力:通过 ref/ViewChild/全局 unlayer 对象访问编辑器实例,调用 loadDesign 加载已保存的设计 JSON,调用 exportHtml 同时导出设计 JSON 与渲染后的 HTML;支持通过 options 传入 projectId、displayMode 等初始化项。

安装与用法:React 用 npm i react-email-editor,通过 useRef 访问 ref.current?.editor;Vue 用 npm i vue-email-editor,通过 this.$refs.emailEditor.editor;Angular 用 npm i angular-email-editor,通过 @ViewChild 访问 this.emailEditor.editor;纯 JS 引入 https://editor.unlayer.com/embed.js 后调用 unlayer.init 并使用全局对象。多实例需使用 unlayer.createEditor() 而非 init()。安装前先用 npm view <package> version 确认版本存在,不要固定未验证的版本号。所有编辑器方法都需等待 editor:ready 事件或 onReady 回调后再调用。

后端建议保存并返回 { design: object, html: string },design 用于后续编辑。容器至少 1024px 宽、700px 高;缺少 projectId 时需从控制台 Project > Settings 获取。

限制:资料未提供收费、价格、平台支持范围及效果数据。