New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-editable-elements

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-editable-elements

>

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

field

NPM

Components and hooks to build a WYSIWYG editor. In edition mode (through editorContext), each element can be edited.

Install

npm install --save react-editable-elements

Usage

import * as React from 'react'

import { field, useEditableText, editorContext, withEditorContext } from 'react-editable-elements'

const Example = () => {

	const { toggleEditionMode } = useContext(editorContext)
	const exampleText = useEditableText(initValue, handleUpdate)

	function handleUpdate(data){
		// Here you can update your database (or anything you want)
	}

	return (
		<div>
			<button onClick={toggleEditionMode}>Toggle edition mode</button>
			<field.p {...exampleText}>
		</div>
	)
}

export default withEditorContext(Example)

Docs

Note : react-editable-elements is currently under development

available elements :

field.h1
field.h2
field.h3
field.h4
field.h5
field.h6
field.p
field.img

incoming elements :

field.table

hX have to be used with useInlineText(defaultValue, updateCallback)

p has to be used with useEditableText(defaultValue, updateCallback)

img have to be used with useDroppableImage(defaultValue, updateCallback)

Editable Background Image

const Component = () => {

	const background = useDroppableBackground(defaultImage, handleUpdate)

	function handleUpdate(data){
		// Here you can update your database (or anything you want)
	}

	return (
		<div style={{
			...background.style
			}}
			{...background.handlers}
		>
			Hello world
		</div>
	)
}

Then, in edit mode, just drop your image. She'll be displayed and the handleUpdate callback will be called with the image (File object) in argument.

License

MIT © anthonyjeamme

FAQs

Package last updated on 24 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts