@bylqwjc/media-editor-image
v1.0.44
Published
媒体编辑器框架无关图片运行时:把 React+Filerobot 封进 mountImageEditor(el, opts) 命令式 API,Vue / React / 原生 JS 共用,消费方无需装 React
Readme
@media-editor/image
框架无关图片编辑器运行时。内部封装 React、ReactDOM 和 Filerobot,业务应用不需要自己安装或改造图片编辑器内部 UI。
安装
pnpm add @media-editor/image @media-editor/styles使用
import { mountImageEditor } from '@media-editor/image';
import '@media-editor/image/style.css';
import '@media-editor/styles/theme.css';
import '@media-editor/styles/filerobot.css';
const handle = mountImageEditor(el, {
source: fileOrUrl,
locale: 'zh',
theme: 'auto',
onSave: async (result, designState) => {
await saveImageToYourApp(result, designState);
},
});
handle.update({ source: nextFileOrUrl });
handle.destroy();Lazy
import { mountImageEditorLazy, preloadImageEditor } from '@media-editor/image/lazy';
preloadImageEditor();
await mountImageEditorLazy(el, options);选项
source: 图片 URL、File、Blob 或 data URL。locale:zh、en、es或zh-Hant。theme:auto、light或dark。fullscreen:false可关闭内置全屏,也可传{ target, buttonContainer, mode }。onSave: 用户点击保存后的回调。onClose: 用户关闭编辑器后的回调。
