编辑型组件分为两种,可编辑组件、可编辑元素。
可编辑元素组件(名称不固定) | 基础元素组件 | 基础元素引用 | 可编辑方法 | 可编辑方法引用 |
---|---|---|---|---|
EditableImage | Image | @fe-plugin/components/lib/templates/cmps/image | withEditableImage | import { withEditableImage, withEditableButton, withEditableText, withEditableDialog, withEditableInput, withEditableTextarea, withEditableFileUploader, withEditableShape } from "@fe-plugin/components/lib/templates/editable-element"; |
EditableButton | Button | @fe-plugin/components/lib/templates/cmps/button | withEditableButton | |
EditableText | <p>、<article>标签 | 原生标签 | withEditableText | |
EditableDialog | Dialog | @fe-plugin/components/lib/templates/cmps/dialog | withEditableDialog | |
EditableInput | Input | @fe-plugin/components/lib/templates/cmps/input | withEditableInput | |
EditableTextarea | Textarea | @fe-plugin/components/lib/templates/cmps/textarea | withEditableTextarea | |
EditableFileUploader | FileUploader | @fe-plugin/components/lib/templates/cmps/file-uploader | withEditableFileUploader | |
EditableShape | Shape | @fe-plugin/components/lib/templates/cmps/shape | withEditableShape |
构建可编辑组件、可编辑元素
import React from "react"; import { withEditableComponent } from "@fe-plugin/components/lib/templates/editable-component"; import { withEditableText } from "@fe-plugin/components/lib/templates/editable-element"; import BaseButton from "@fe-plugin/components/lib/templates/cmps/button"; // 创建一个可编辑组件 const EditableComponent = withEditableComponent(); // 根据元素配置的key值创建一个可编辑元素 const EditableButton = withEditableButton("元素key值")((element) => { return <BaseButton data={element} style={element.style} />; }); // 编辑器组件的渲染(一个带有可编辑按钮元素的组件) function EditerCmpRender() { return ( <EditableComponent> <EditableButton /> </EditableComponent> ); } |
渲染引擎渲染组件,有main模块引用,需要与编辑器可编辑组件对应渲染,并且需要附加逻辑。
基础组件名称 | 渲染组件引入 |
---|---|
Button | @fe-plugin/components/lib/h5/cmps/button |
Image | @fe-plugin/components/lib/h5/cmps/image |
Text | @fe-plugin/components/lib/h5/cmps/text |
Dialog | @fe-plugin/components/lib/h5/cmps/Dialog |
Input | @fe-plugin/components/lib/h5/cmps/input |
Textarea | @fe-plugin/components/lib/h5/cmps/textarea |
FileUploader | @fe-plugin/components/lib/h5/cmps/file-uploader |
公共组件名称 | 渲染组件引入 |
ConfirmDialog 确认弹窗 | @fe-plugin/components/lib/h5/confirm-dialog |
QrCode 二维码组件 | @fe-plugin/components/lib/h5/qrcode |
import React from "react"; import Button from "@fe-plugin/components/lib/h5/cmps/button"; export default function RenderButton(props) { const handleClick = () => { console.log("处理按钮的点击事件"); }; //从外部到element元素数据 填充 return <Button data={props.element} onClick={handleClick} />; } |
(待补充)