Socket
Book a DemoInstallSign in
Socket

social-editor

Package Overview
Dependencies
Maintainers
0
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

social-editor

A headless editor framework for building editors like facebook and twitter with @mentions, #hashtags and auto-linking support, based on Prosemirror.

1.3.6
latest
npmnpm
Version published
Weekly downloads
94
38.24%
Maintainers
0
Weekly downloads
 
Created
Source

Social Editor

A headless editor framework for building editors like facebook and twitter with @mentions, #hashtags and auto-linking support, based on Prosemirror.

preview

Usage

Install

yarn add social-editor```  
  
or  
  
```bash  
npm install social-editor```  
  
### Import  
```javascript  
<!--  Including file   -->  
<script type="text/javascript" src="social-editor-box/dist/SocialEditor.js"></script>  
<!--or-->  
import SocialEditor from "social-editor";  
<!--  Editor Element   -->  
<div id="app"></div>  
// creating instance of a plugin  
let elem = document.getElementById('app');  
let editor = new SocialEditor(elem, {  
	//options
	getSuggestions: (type, text, done) => {  
		if (type === 'mention') {  
			// pass dummy mention suggestions  
			done([  
			{name: 'Seerat', username: '@seerat', id: '123124', tab:'facebook', verification_status: true, fan_count: '12M', picture: 'https://www.w3schools.com/howto/img_avatar.png' },  
			{name: 'John Doe', username: '@johndoe', id: '123123', tab:'facebook', verification_status: true, fan_count: '12M', picture: 'https://www.w3schools.com/howto/img_avatar.png' },  
			])  
		} else if (type === 'tag') {  
		// pass dummy tag suggestions  
			done([{tag: 'WikiLeaks'}, {tag: 'NetNeutrality'}])  
		}  
	},
	getMentionSuggestionsHTML: items => '<div class="suggestion-item-list">'+  
	   items.map(i => '<div class="suggestion-item">'+i.name+'</div>').join('')+  
	   '</div>',  
	getTagSuggestionsHTML: items => '<div class="suggestion-item-list">'+  
	    items.map(i => '<div class="suggestion-item">'+i.tag+'</div>').join('')+  
	    '</div>',
	//...
})  

Check out options for configuration

Example

  • Codesandbox

Options

OptionTypeDefaultDescriptionRequired
placeholderstring'Type Anything Here!'Specifies a short hint that describes the expected value of a social text areafalse
initialValuestring<empty string>Specifies the value of social text areafalse
maxnumber0Specifies the maximum value for an social text area (Note: 0 === no-limit)false
twitterTextbooleanfalseSpecifies to use twitterText library to tokenize and parse text intend of native parserfalse
getMentionSuggestionsHTMLfunction() => {}Specifies a html template for rendered mentionsfalse
getTagSuggestionsHTMLfunction() => {}Specifies a html template for rendered tagsfalse
getSuggestionsfunction() => {}Specifies the data for suggestionsfalse
getSuggestionsLoaderfunction() => {}Specifies the html for waitng loaderfalse

Events

OptionParamsDescription
onUpdate{ text, html,templateText,count,links,hashtags }Emits when change occurs in social text area
onCreate-Emits when social text area is in ready state
onPaste-Emits when content pasted in social text area

Used By

ContentStudio

Contribution Guide

  • Use npm install command to install dependencies.
  • Execute command npm run start to run webpack development server and top open preview in the browser.
  • Execute command npm run build to create plugin distribution files in the dist directory.
  • Tweak configuration inside config folder if necessary.
  • Configure plugin API using this documentation.

Keywords

editor

FAQs

Package last updated on 20 Sep 2024

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.