Gathering detailed insights and metrics for react-tinymce-mention
Gathering detailed insights and metrics for react-tinymce-mention
Gathering detailed insights and metrics for react-tinymce-mention
Gathering detailed insights and metrics for react-tinymce-mention
@Mentions functionality for TinyMCE, built with React and Redux
npm install react-tinymce-mention
Typescript
Module System
NPM Version
60.3
Supply Chain
93.9
Quality
71.8
Maintenance
50
Vulnerability
98.9
License
JavaScript (99.19%)
Shell (0.59%)
HTML (0.21%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
20 Stars
468 Commits
15 Forks
5 Watchers
2 Branches
2 Contributors
Updated on Aug 15, 2024
Latest Version
0.3.0
Package Id
react-tinymce-mention@0.3.0
Size
1.35 MB
NPM Version
1.4.28
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
19
33
Provides a simple yet flexible interface for adding @mention
functionality into the TinyMCE rich text editor, built with React.js and Redux. Supports data sources that are simple Arrays as well as Promises, allows for data transformations, and exposes an interface for defining your own custom dropdown select menu.
Out of the box support for all major browsers and IE 9-11, and will work with IE8 assuming your app implements a polyfill before the plugin is loaded (see https://babeljs.io/docs/usage/polyfill for instructions).
Works best with react-tinymce, but will work in any environment where window.tinymce
is available.
(NOTE: While this plugin is currently coupled with TinyMCE, extracting it from the current implementation should be fairly simple and we plan on releasing adaptors for other editors in the future.)
npm install --save react-tinymce-mention
1import React from 'react'; 2import Mention from 'react-tinymce-mention'; 3import Editor from './components/Editor'; 4 5React.render( 6 <div> 7 <Editor /> 8 <Mention dataSource={[ 9 'hello', 10 'how', 11 'are', 12 'you' 13 ]} 14 /> 15 </div> 16, document.getElementById('root') 17);
In the simplest case, only dataSource
is required; the list containing @mention
matches is rendered with a default set of components that you can hijack via stylesheet classes. See src/mention/test-pages/simple.js
for a working example.
asyncDataSource
)1import React from 'react'; 2import Mention from 'react-tinymce-mention'; 3import Editor from './components/Editor'; 4import CustomList from './components/CustomList'; 5import CustomRTEMention from './components/CustomRTEMention'; 6import complexDataSource from './api/complexDataSource'; 7 8React.render( 9 <div> 10 <Editor /> 11 <Mention 12 delimiter={'@'} 13 dataSource={complexDataSource} 14 transformFn={dataSource => { 15 return dataSource.map(result => { 16 const { fullName } = result; 17 18 // When transforming your dataSource, a `displayLabel` and 19 // `searchKey` is required 20 return { 21 displayLabel: fullName, 22 searchKey: fullName 23 }; 24 }); 25 }} 26 customListRenderer={({ clickFn, fetching, highlightIndex, matchedSources }) => { 27 return ( 28 <CustomList 29 fetching={fetching} 30 highlightIndex={highlightIndex} 31 matchedSources={matchedSources} 32 onClick={clickFn} 33 /> 34 ); 35 }} 36 customRTEMention={({ delimiter, displayLabel, id, tinymceId }) => { 37 return ( 38 <CustomRTEMention 39 delimiter={delimiter} 40 displayLabel={displayLabel} 41 id={id} 42 tinymceId={tinymceId} 43 /> 44 ); 45 }} 46 onAdd={({ changed, mentions }) => { 47 console.log('Added', changed, mentions) 48 }} 49 onRemove={({ changed, mentions }) => { 50 console.log('Removed', changed, mentions); 51 }} 52 showDebugger={true} 53 /> 54 </div> 55, document.getElementById('root') 56);
In the advanced use-case you can define a
dataSource
- Array or Promisedelimiter
- Either '@' (default) or '#'.transformFn
- a function that processes your dataSource before it is injected into the plugin.customListRenderer
- A function that returns a component, allowing you to define your own dropdown list.customRTEMention
- A component that represents what is inserted into the TinyMCE input window. (Note: TinyMCE is aggressive about cleaning up markup as well as the format, so follow something similar to the example)onAdd
- A function that is called whenever you select a mention and it is inserted into the editor.onRemove
- Similar to the above, this function is called whenever a mention is removed.showDebugger
- Useful when developing a custom dropdown list, enabling this switch allows you to see all of the items available for selection as well as the mentions that have been currently selected.See src/mention/test-pages/advanced.js
for a working example.
1import React from 'react'; 2import Mention from 'react-tinymce-mention'; 3import axios from 'axios'; 4import Editor from './components/Editor'; 5 6React.render( 7 <div> 8 <Editor /> 9 <Mention 10 showDebugger={true} 11 delimiter={'#'} 12 dataSource={axios.get('/public/api/complex.json')} 13 transformFn={dataSource => { 14 return dataSource.data.map(result => { 15 const { fullName } = result; 16 return { 17 searchKey: fullName, 18 displayLabel: fullName 19 }; 20 }); 21 }} 22 /> 23 </div> 24, document.getElementById('root'));
In this example, if you pass in a Promise one of the hard requirements is that the array you return from your transformFn
conforms to the above -- a searchKey
and displayLabel
is required. If you forget these properties an error will be thrown.
See src/mention/test-pages/promise.js
for a working example.
1import React from 'react'; 2import Mention from 'react-tinymce-mention'; 3import axios from 'axios'; 4import Editor from './components/Editor'; 5import CustomList from './components/CustomList'; 6 7React.render( 8 <div> 9 <Editor /> 10 <Mention 11 showDebugger={true} 12 delimiter={'@'} 13 asyncDataSource={query => { 14 return new Promise(resolve => { 15 axios.get(`/public/api/complex.json?q=${query}`) 16 .then(response => { 17 resolve(transformDataSource(response.data)); 18 }); 19 }); 20 }} 21 customListRenderer={({ clickFn, fetching, highlightIndex, matchedSources }) => { 22 return ( 23 <CustomList 24 fetching={fetching} 25 highlightIndex={highlightIndex} 26 matchedSources={matchedSources} 27 onClick={clickFn} 28 /> 29 ); 30 }} 31 /> 32 </div> 33, document.getElementById('root')); 34 35function transformDataSource(dataSource) { 36 return dataSource.map(result => { 37 const { fullName } = result; 38 return { 39 searchKey: fullName, 40 displayLabel: fullName 41 }; 42 }); 43}
Lastly, if you would like to implement a Mention component that queries a an API when the user types, define an asynDataSource
. As with the Promise example above, your final dataSource will need to conform to the searchKey
and displayLabel
requirement.
See src/mention/test-pages/async.js
for a working example.
If you are not using react-tinymce
and find that editor errors out stating that it can't find the Mention plugin to load, try initializing the plugin before your instance of TinyMCE.
Example implementations have been given in src/mention/test-pages
. To enable, uncomment the relevant line in src/index.js
and save.
npm install
npm test (or) npm run test-watch
npm start
open http://localhost:3333
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 2/25 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More