dnde
v 07,2021)
電子メールエディターをドラッグアンドドロップします
# Yarn
yarn add dnd-email-editor
# NPM
npm install dnd-email-editor
コンポーネントに渡すことができる小道具:
| 小道具 | タイプ | デフォルト | オプション | 説明 |
|---|---|---|---|---|
preview | ブール | true | 真実 | 内蔵プレビューボタンを表示/非表示にします。 |
showUndoRedo | ブール | true | 真実 | 組み込みの元に戻す/redoボタンを表示/非表示にします。 以下のAPIメソッドから undoredoを使用して、独自のundoredの機能を作成できます |
エディターはこれらのAPIメソッドを公開します
getHtml -HTMLコンテンツとして設計をエクスポートしますgetJson json文字列としてエクスポートすると、この文字列はloadJsonで使用できますloadJson json stringから既存のデザインをロードしますundoredoアクションを元に戻してやり直します import Editor from 'dnd-email-editor' ;
return < Editor / >;useRefを使用してrefをセットアップし、エディターに渡す const ref = React . useRef ( null ) ;
return < Editor ref = { ref } / > ;getHtml() 、 getJson() 、 loadJson() 、 undoredo使用します const logValues = ( ) => {
if ( ref . current ) {
const html = ref . current . getHtml ( ) ;
const json = ref . current . getJson ( ) ;
console . log ( html , json ) ;
}
} ;
const loadJson = ( json : string ) => {
if ( ref . current ) {
ref . current . loadJson ( json ) ;
}
} ;
const performUndoAction = ( ) => {
if ( ref . current ) {
ref . current . undoActionCallback ( ) ;
// to check if undo is possible
console . log ( 'is undo empty: ' , ref . current . isUndoEmpty ( ) ) ;
}
} ;
const performRedoAction = ( ) => {
if ( ref . current ) {
ref . current . redoActionCallback ( ) ;
// to check if redo is possible
console . log ( 'is redo empty: ' , ref . current . isRedoEmpty ( ) ) ;
}
} ;Inorder TypeScriptを使用してクールな定義を取得するには、タイプをREFに渡すだけです
import Editor from 'dnd-email-editor';
const ExampleComponent = () => {
- const ref = useRef(null);
+ const ref = useRef<Editor>(null);
return (
<Editor ref={ref}/>
);
}メールはa normal html webpageとは大きく異なるため、ウェブサイトの作成に役立つがメールではない非常に多くのドラッグアンドドロップエディターがあります。
mail editorsが利用可能であっても、 open-sourceではなく支払われます。そのような例の1つは、オフェンスルスであると主張unlayerていますが、そうではありません。
open-sourceとして呼び出します上記の理由と私は一般的にdrag-n-dropエディターに触発されたので、私はそれを作ることにしました。
Undo / Redoて行き来します