React-web-editor mudah digunakan. Itu dirancang ramah pengguna!
React-Web-editor ringan dan sederhana.
React-Web-editor ramah reaksi. Anda dapat menggunakan kait untuk komponen Anda sendiri.
React-Web-Editor memiliki alat untuk disesuaikan.
Itu dibangun menggunakan webpack sehingga Anda dapat sepenuhnya mengontrol manajemen konfigurasi dan ekstensi proyek dengan pengaturan khusus.
npm - i react - web - editor import { StyleEditorBlock , TextEditorBlock , ... } from "react-web-editor;atau Anda dapat mengimpor seperti di bawah ini
import ReactWebEditor from "react-web-editor" ; | Versi | Log |
|---|---|
| 2.2.0 | Tingkatkan UI, perbaiki penggunaan kait |
| 2.1.0 | Tingkatkan fitur seret dan lepas |
| 2.0.0 | Buat papan yang dapat diedit, pembaruan bug minor |
| 1.2.0 | Tingkatkan Editor Teks untuk menginisialisasi opsi |
| 1.1.0 | Upgrade Editor untuk menggunakan unit seperti "REM" |
| ~ 1.0.5 | Gunakan helm, perbarui helm ke async |
| ~ 1.0.2 | Tingkatkan fitur seret dan lepas, selesaikan bug UI minor |
| 1.0.0 | Tambahkan Editor Teks |
| 0.1.6 | Tingkatkan Fitur Editor Gaya |
| ~ 0.1.5 | Selesaikan bug menghilang selanjutnya.js |
Komponen -komponen ini dirancang agar ramah pengguna. Komponen Kontrol dengan Mudah Menggunakan Tidak Lebih Dari Props.
Style Editor Component (SEC) adalah komponen blok yang dapat mengubah ukuran dan lokasi komponen. Penggunaan lain yang kuat dari SEC mengunggah gambar di layar atau mengubah warna latar belakang komponen. Dengan membungkus komponen dengan SEC dan mengatur posisi komponen 'absolute', komponen dapat diedit di situs web. Komponen ini juga dapat digunakan tanpa komponen Anda sendiri.
Dua tab akan muncul di layar saat Anda mengarahkan kursor pada komponen. Tab pertama adalah tab gambar pengunggahan, yang membantu Anda menambahkan gambar. Tab kedua adalah penangan warna. Itu mengubah warna latar belakang komponen.
type StyledEditorBlockProps {
width: number ;
height: number ;
top: number ;
left: number ;
parentStyle ?: ParentStyle ; // It defines area where component can't escape. If you don't define it, then your component can move in all screen.
unit: string ;
initialColor ?: string ; // default: transparent
initialImage ?: string ; // default: none
}
type ParentStyle {
width: number ;
height: number ;
} import { StyleEditorBlock } from "react-web-editor"
...
return (
< StyleEditorBlock
width = { 200 }
height = { 300 }
left = { left }
top = { top }
parentStyle = { { width : 600 , height : 800 } }
unit = { "px" }
>
< YourOwnComponent color = { color } /> // It is just a option.
</ StyleEditorBlock >
) ; type TextEditorBlockProps {
width: number ;
height: number ;
top: number ;
left: number ;
parentStyle ?: ParentStyle ; // It defines area where component can't escape. If you don't define it, then your component can move in all screen.
unit: string ;
// Initial- props are options just for first rendering.
initialFontSize ?: number ; // default: 0.22
initialFontColor ?: string ; // default: "black"
initialFontStyle ?: InitialFontStyle ; // default: ""
initialText ?: string ; // default: ""
initialFontName ?: string ; // default: ""
}
type ParentStyle {
width: number ;
height: number ;
}
type InitialFontStyle = "twin-color-text" | "box-text" | "down-side-text" | "out-line-text" | "bubble-shadow-text" ;
type InitialFontName = "andada-pro" | "bebas-nenu" | "montecarlo" | "roboto" | "stix-two-text" | "style-script" ; import { TextEditorBlock } from "react-web-editor"
...
return (
< TextEditorBlock
width = { 200 }
height = { 300 }
left = { left }
top = { top }
parentStyle = { { width : 600 , height : 800 } }
unit = { "px" }
/>
) ; type DragAndDropTableProps {
color ?: string ;
isVertical: boolean ;
} import { DragAndDropTable } from "react-web-editor"
...
return (
< DragAndDropTable
color = { "pink" }
isVertical = { true }
>
< YourOwnComponent src = { cat } />
< YourOwnComponent src = { flower } />
< YourOwnComponent src = { bee } />
// These components can drag and drop in the DragAndDropTable component.
</ DragAndDropTable >
) ; type useDraggableProps {
left: number ;
top: number ;
width: number ;
height: number ;
dragBoardOption ?: DragBoardOption ;
unit: string ;
onDrag: Dispatcher < ComponentStyle > ; // It is a setState. Its state is Componentstyle.
}
type Dispatcher < S > = React . Dispatch < React . SetStateAction < S >> ;
type ComponentStyle {
left : number ;
top: number ;
width: number ;
height: number ;
}
type DragBoardOption {
width: number ;
height: number ;
}
// It's like a parentStyle. import { useState } from "react" ;
import { useDraggable } from "react-web-editor" ;
const [ componentStyle , setComponentStyle ] = useState ( {
width : 20 ,
height : 40 ,
top : 40 ,
left : 40 ,
} ) ;
// this state can be used for your own component.
const {
handleDragEnd , // onMouseUp handler
handleDragStart , // onMouseDown handler
} = useDraggable ( {
... componentStyle ,
onDrag : setComponentStyle ,
unit : "px" ,
} ) ;| kembali | penggunaan |
|---|---|
| HandledragStart | Penangan Onmousedown |
| Handledragend | Onmouseup Handler |
Komponen ini dapat digunakan dengan DraggableHandler, dan EditorBlockWrapper.
Ini mengembalikan ubah ukuran penangan. Ini dapat digunakan dengan "ReSizhandlerWrapper", komponen helper untuk mengubah ukuran.
type useResizeProps {
left: number ;
top: number ;
width: number ;
height: number ;
resizeBoardOption ?: ResizeBoardOption ;
unit: string ;
onResize: Dispatcher < ComponentStyle > ; // It is a setState. Its state is Componentstyle.
}
type Dispatcher < S > = React . Dispatch < React . SetStateAction < S >> ;
type ComponentStyle {
left : number ;
top: number ;
width: number ;
height: number ;
}
type ResizeBoardOption {
width: number ;
height: number ;
}
// It's like a parentStyle. import { useState } from "react" ;
import { useResize , ResizeHandlerWrapper } from "react-web-editor" ;
const [ componentStyle , setComponentStyle ] = useState ( {
width : 20 ,
height : 40 ,
top : 40 ,
left : 40 ,
} ) ;
const { handleMouseDown } = useDraggable ( {
... componentStyle ,
onResize : setComponentStyle ,
unit : "px" ,
} ) ;| kembali | penggunaan |
|---|---|
| edown handlem | Penangan Onmousedown |
Komponen ini dapat digunakan dengan REVEICEHandlerWrapper dan EditorBlockWrapper.
UseImage Hook membantu mengunggah dan menampilkan gambar di layar.
type UseImageProps {
initialImage ?: string ;
} import { useImage } from "react-web-editor" ;
...
const { imageSrc , handleImageChange } = useImage ( { initialImage } ) ;| kembali | penggunaan |
|---|---|
| gambar | rangkaian |
| handlefilechange | Onchangehandler dari InputElement |
Hook usecolor mengembalikan penangan perubahan warna.
type UseColorProps {
initialColor ?: string ;
} import { useColor } from "react-web-editor" ;
...
const { color , handleColorChange } = useColor ( { initialColor } ) ;| kembali | penggunaan |
|---|---|
| warna | rangkaian |
| Handlecolorchange | Onchangehandler dari InputElement |
Komponen -komponen ini membantu Anda menyesuaikan dan menghasilkan komponen Anda sendiri. Anda dapat membuat perpustakaan sendiri menggunakan fitur ini. Ini memungkinkan Anda dengan mudah menangani kait dan komponen editor.
type EditableBoardProps {
width: number ;
height: number ;
backgroundColor: string ;
left ?: number ;
top ?: number ;
unit: string ;
} import { EditableBoard , StyleEditorBlock } from "react-web-editor"
...
const boardWidth = 500 ;
const boardHeight = 500 ;
const boardStyleUnit = "px" ;
return (
< EditableBoard
width = { boardWidth }
height = { boardHeight }
backgroundColor = { boardStyleUnit }
color = { "pink" }
left = { 20 }
top = { 20 }
>
< StyleEditorBlock
. . .
parentStyle = { {
width : boardWidth ,
height : boardHeight ,
} }
unit = { "px" }
/>
</ EditableBoard >
) ;Pembungkus blok editor adalah komponen gaya. Ukuran dan lokasi komponen diterima dalam alat peraga. Itu berubah secara dinamis dengan alat peraga ini. Itu dapat digunakan dengan menggunakan dan digunakan
type EditorBlockWrapperProps {
width: number ;
height: number ;
left: number ;
top: number ;
} import { useState } from "react" ;
import { EditorBlockWrapper , useDraggable } from "react-web-editor" ;
const [ componentStyle , setComponentStyle ] = useState ( {
width : 20 ,
height : 40 ,
top : 40 ,
left : 40 ,
} ) ;
// this state can be used for your own component.
const {
handleDragEnd , // onMouseUp handler
handleDragStart , // onMouseDown handler
} = useDraggable ( {
... componentStyle ,
onDrag : setComponentStyle ,
unit : "px" ,
} ) ;
return (
< EditorBlockWrapper
width = { componentStyle . width }
height = { componentStyle . height }
top = { componentStyle . top }
left = { componentStyle . left }
onMouseDown = { handleDragStart }
onMouseUp = { handleDragEnd }
>
< YourOwnComponent style = { { position : "absolute" } } >
</ EditorBlcokWrapper > // Now, This component dynamically change location.
);Komponen ini berspesialisasi untuk pengait yang menggunakannya. Ini menghasilkan simpul dalam empat arah komponen.
import { useState } from "react" ;
import { EditorBlockWrapper , ResizeHandlerWrapper , useResize } from "react-web-editor" ;
const [ componentStyle , setComponentStyle ] = useState ( {
width : 20 ,
height : 40 ,
top : 40 ,
left : 40 ,
} ) ;
// this state can be used for your own component.
const { handleMouseDown } = useDraggable ( {
... componentStyle ,
onResize : setComponentStyle ,
unit : "px" ,
} ) ;
return (
< EditorBlockWrapper
width = { componentStyle . width }
height = { componentStyle . height }
top = { componentStyle . top }
left = { componentStyle . left }
>
< ResizeHandlersWrapper >
{ DIRECTIIONS . map ( ( item ) => (
< div key = { item } className = { item } onMouseDown = { handleMouseDown } />
) ) }
</ ResizeHandlersWrapper >
</ EditorBlcokWrapper > // Now, This component can change size.
) ;