1.1.3 • Published 6 years ago
react-newsletter v1.1.3
react-newsletter
Edit newsletters in your React application
Install
npm install --save react-newsletterDocs / API reference
Available components:
- ReactNewsletterProvider
- Injects HTML5 DnD Backend support
- TemplateComponent
- Items you will be able to drag and drop
- Based on ReactDND.DragSource
- ReactNewsletter
- The canvas contains Droppable areas and dropped items
- CardDragLayer
- Element appearence while dragging
- Based on ReactDND.DragLayer
Props:
ReactNewsletterProvider
Just wrap you root component with it
TemplateComponent
type: string: a type of yout iteminitialValue: any: initial valueclassName?: string: classes pushed to the root JSX element (div) of the TemplateComponentstyle?: Object: style pushed to the root JSX element (div) of the TemplateComponentallSelectedItems?: Array<{type: string, value: any}>: provides an opportuinity to drag and drop several selected items
ReactNewsletter
items: Array<Item>: dropped items- Item
id: numbervalue: stringtype: stringstaticTemplate?: boolean:trueto forbid to an item be draggableshouldNotRenderDNDAreaBefore?: boolean
- Item
itemsOnChange: (Array<Item>) => void: changes handlertemplates: Array<Template>: your templates- Template:
name: stringtype: stringcomponent: React componentinitialValue: anygetHTML: () => string
- Template:
onDroppedCallback?: () => void: called right after an item has been dropped
CardDragLayer
component: React componentitem: ItemmoveableDragLayerStyles: wrapper style of all items being draggeddragLayerItemStyles: style of a single item which is being dragged
Meta
To debug locally
yarn starthere in the root- go to your project and run
npm link $PATH_TO/react-newsletter
To update and publish changes
npm version <update_type>(semver)npm publish
Have questions?
Welcome to issues or contact @alienalein13
TODO
- Types (migrate to TS probably)
- Tests
- Implement getHTML function for the whole newsletter
License
MIT © Webscope.io