RayEditor is a modern, customizable, and lightweight WYSIWYG content editor built with pure JavaScript. It offers a seamless writing experience with support for rich text formatting, code blocks, media uploads, and more. Perfect for blogs, CMS platforms, documentation tools, and any web application requiring rich content editing.
- Bold, Italic, Underline, Strikethrough Standard rich text styling options.
- Uppercase, Lowercase, Toggle Case Easily transform selected text casing.
- Subscript & Superscript Great for scientific and mathematical content.
- Headings Supports H1 to H6.
- Ordered & Unordered Lists Create structured content effortlessly.
- Quickly revert or reapply actions as needed.
- Change casing for selected text using one click.
- Inline Code Highlight code snippets inline.
- Code Blocks Insert multi-line formatted code blocks.
- Text Color Pick a color for text.
- Background Color Highlight text with background color.
- Upload and insert images.
- Configurable upload URL and file size limits.
- Resize, drag, and remove images easily.
- Upload and attach documents or media files.
- Size limits and upload endpoints are customizable.
- When enabled, type the configured tag, @ by default, and any alphanumeric character (and underscores _ ) to create a tag that can then be used by your own code to make interactible.
- Or configure the
mentionElement: "a"option and thementionUrl:""to have the mention link to a specific page.
- Optionally configure RayEditor to insert the stylesheet into the DOM so you don't have to manage it manually.
- Multiple types of toolbars. Current options: "
default" | "inline" - Inline toolbars are hidden until the editor area is focused and will hide again once focus is completely lost from the editor and the toolbar.
- Automatically calculates the width of the toolbar area and tries to shrink the total buttons to fit on a single line. Useful when using the inline toolbar style so the toolbar is smaller overall.
- Options:
overflowMenu:true|false
- Allows viewing or editing the HTML source code of the editor area with the press of a button.
- Options:
showSource:true|false
- Add Row: Add a new row below the selected row.
- Delete Row: Remove the selected row.
- Add Column: Add a new column to the right of the selected cell.
- Delete Column: Remove the selected column.
- Remove Table: Delete the entire table.
<!-- RayEditor CSS -->
<link rel="stylesheet" href="https://rohanyeole.com/static/css/ray_editor/ray-editor.css">
<!-- RayEditor JS -->
<script src='https://rohanyeole.com/static/js/ray_editor/ray-editor.js'></script><div id="content"></div>document.addEventListener('DOMContentLoaded', () => {
const editor = new RayEditor('content', {
bold: true,
italic: true,
underline: true,
strikethrough: true,
redo: true,
undo: true,
headings: true,
lowercase: true,
uppercase: true,
superscript: true,
subscript: true,
orderedList: true,
unorderedList: true,
toggleCase: true,
codeBlock: true,
codeInline: true,
imageUpload: {
imageUploadUrl: '/upload-blog-file/',
imageMaxSize: 20 * 1024 * 1024 // 20MB
},
fileUpload: {
fileUploadUrl: '/upload-file/',
fileMaxSize: 20 * 1024 * 1024 // 20MB
},
textColor: true,
backgroundColor: true,
link: true,
table: true,
textAlignment:true,
mentions: {
enableMentions: false,
mentionElement: "span",
mentionUrl:"",
mentionTag:""
},
initStyles: false,
stylesheetUrl: "",
hideWatermark: false,
toolbarType: "default",
overflowMenu: false,
showSource: true
});
});{
"url":"path of uploaded file or image"
}
E.g
{
"url" : "https://rohanyeole.com/static/file/somename.png"
}
-
Toolbar Buttons: Toggle each tool individually via boolean flags.
-
imageUpload:
imageUploadUrl: Upload endpoint for images.imageMaxSize: Max file size in bytes.
-
fileUpload:
fileUploadUrl: Upload endpoint for files.fileMaxSize: Max file size in bytes.
-
Mentions: Replace tags such as "@username" with an HTML element.
-
enableMentions: Default: false - Enables the mention functionality. -
mentionUrl: The relative or absolute path you want to link to. The tagged value will be appended to the end of the url defined. Ex. `mentionUrl:"/user/" = "/user/{username}" -
mentionElement: Default: span - The element that will replace any text beginning with the definedmentionTag.Options: a | span
-
mentionTag: Define the tag that is required to activate the mention. Can be one or more characters.- Default: "@"
-
-
Custom Stylesheets & Automatic Stylesheet Insertion
-
initStyles: Default: false - Whether or not to automatically insert the stylesheet into the HTML DOM.- Options true | false
-
stylesheetUrl: Default: "" - IfinitStyles:truethen will insert this url (relative or absolute path) into the DOM to load custom stylesheets. -
If left unset, defaults to the "main" branch CDN url.
-
-
Toolbar Options
-
toolbarType: Default: "default" - Change the style of the toolbar. Inline toolbars are hidden by default and will display when the editor area is focused.- Options: default | inline
-
- Lightweight and dependency-free.
- Highly customizable.
- Extendable and framework-agnostic.
- Easy to integrate and use.
- GitHub: yeole-rohan/ray-editor
- CDN: jsDelivr - rayeditor
