Index

editor

MMO.editor · 21 symbols · generated 30 Sep 2026

constant

DEFAULT_TOOLS

editor.js:14

The toolbar a <mmo-editor> shows when its tools attribute is not set. | separates two groups.

MMO.editor.DEFAULT_TOOLS = 'undo,redo|format|bold,italic,underline,strike,code|color,highlight|link|ul,ol,quote|align|image,table,hr|clear|source';
Namespace
MMO.editor
constant

INLINE_TOOLS

editor.js:20

What an [mmo-editor="inline"] region keeps: a single line, text formatting only.

MMO.editor.INLINE_TOOLS = 'bold,italic,underline,strike,code,color,highlight,link,clear';
Namespace
MMO.editor
constant

DROPPED_TAGS

editor.js:42

The tags removed together with everything they hold: code, embedded documents, and the head of a pasted page.

MMO.editor.DROPPED_TAGS = ['SCRIPT', 'STYLE', 'TEMPLATE', 'IFRAME', 'OBJECT', 'EMBED', 'NOSCRIPT', 'META', 'LINK', 'TITLE', 'HEAD', 'SVG', 'MATH', 'SELECT', 'TEXTAREA', 'BUTTON', 'INPUT'];
Namespace
MMO.editor
constant

EMPTY_DROPPED_TAGS

editor.js:60

The tags MMO.editor.sanitize removes when they hold nothing at all.

MMO.editor.EMPTY_DROPPED_TAGS = ['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'BLOCKQUOTE', 'PRE', 'UL', 'OL', 'B', 'I', 'U', 'S', 'SUB', 'SUP', 'CODE', 'MARK', 'SPAN', 'A'];
Namespace
MMO.editor
constant

BLOCK_TAGS

editor.js:66

The tags that make a block of text: what formatBlock changes, and what a selection is aligned in.

MMO.editor.BLOCK_TAGS = ['P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'BLOCKQUOTE', 'PRE', 'LI', 'TD', 'TH', 'DIV'];
Namespace
MMO.editor
function

sanitize

editor.js:79

Clean html so that it only holds what the editor can produce (MMO.editor.ALLOWED_TAGS).

function MMO.editor.sanitize(html, inline = false)
Namespace
MMO.editor
Everything that comes in goes through here: the initial content, `value`, a paste, a drop and the source view. It is what keeps a paste from Word or from another site from bringing its fonts, classes and scripts along -- and what keeps an `onerror=` or a `javascript:` link out of the page.
htmlstring | Nodethe markup, or a node whose CONTENT is cleaned in place
inline = falsebooleantrue to keep text formatting only (an [mmo-editor="inline"] region)
returnsstringthe clean html
MMO.editor.sanitize('<p onclick="x()">Hi <font color="red">there</font></p>'); // '<p>Hi there</p>'
function

sanitizeChildren

editor.js:97

[internal] MMO.editor.sanitize, on the children of one node

function MMO.editor.sanitizeChildren(node, inline, inPre = false)
Namespace
MMO.editor
nodeNode
inlineboolean
inPre = false
function

isBlock

editor.js:164
function MMO.editor.isBlock(node)
Namespace
MMO.editor
node?Node
returnsbooleantrue for an element that makes a block of its own (a paragraph, a list, a table ...)
function

sanitizeAttributes

editor.js:172

[internal] Keep the attributes MMO.editor.ALLOWED_TAGS lists for this tag, with safe values only.

function MMO.editor.sanitizeAttributes(el)
Namespace
MMO.editor
elElement
function

isSafeUrl

editor.js:210
function MMO.editor.isSafeUrl(url, image = false)
Namespace
MMO.editor
urlstring
image = falsebooleantrue for an <img src>, which may also be an image data: url
returnsbooleanfalse for javascript: and any other scheme that is not a document or an image
function

escape

editor.js:223
function MMO.editor.escape(text)
Namespace
MMO.editor
textstring
returnsstringthe text, safe to put in html
function

textToHtml

editor.js:234

Turn plain text into paragraphs: a blank line ends one, a single newline is a line break.

function MMO.editor.textToHtml(text, inline = false)
Namespace
MMO.editor
textstring
inline = falsebooleantrue to keep everything on one line
returnsstringhtml
MMO.editor.textToHtml('a\nb\n\nc'); // '<p>a<br>b</p><p>c</p>'
function

serializeRange

editor.js:255

Where a range starts and ends inside a root, as child indexes: it can be put back on a copy of the same html (MMO.editor.History), where the nodes themselves are gone.

function MMO.editor.serializeRange(range, root)
Namespace
MMO.editor
rangeRange
rootNode
returns?{start: Array<number>, startOffset: number, end: Array<number>, endOffset: number} null when the range is outside the root
function

unserializeRange

editor.js:276

The opposite of MMO.editor.serializeRange

function MMO.editor.unserializeRange(data, root)
Namespace
MMO.editor
data?Object
rootNode
returns?Rangenull when the html changed too much for the path to lead anywhere
function

getRange

editor.js:302
function MMO.editor.getRange()
Namespace
MMO.editor
returns?Rangethe current selection's first range
function

setRange

editor.js:311

Replace the current selection

function MMO.editor.setRange(range)
Namespace
MMO.editor
rangeRange
function

closestBlock

editor.js:322
function MMO.editor.closestBlock(node, root)
Namespace
MMO.editor
node?Node
rootNodewhere to stop looking
returns?Elementthe block (MMO.editor.BLOCK_TAGS) holding the node, inside root
function

closest

editor.js:335
function MMO.editor.closest(node, selector, root)
Namespace
MMO.editor
node?Node
selectorstring
rootNodewhere to stop looking
returns?Elementthe closest element matching the selector, the node included, inside root
constant

IS_MAC

editor.js:348
MMO.editor.IS_MAC = /Mac|iPhone|iPad/.test(navigator.platform ?? navigator.userAgent);
Namespace
MMO.editor
function

matchShortcut

editor.js:357

Test a keyboard event against a shortcut, modifiers included: Mod+b is not Mod+Shift+b.

function MMO.editor.matchShortcut(event, shortcut)
Namespace
MMO.editor
eventKeyboardEvent
shortcutstringkeys separated by +: Mod (control, or command on a mac), Control, Alt, Shift, Meta, then the key
returnsboolean
MMO.editor.matchShortcut(event, 'Mod+Shift+z');
function

shortcutLabel

editor.js:377
function MMO.editor.shortcutLabel(shortcut)
Namespace
MMO.editor
shortcutstringMMO.editor.matchShortcut
returnsstringhow the shortcut reads on this system
MMO.editor.shortcutLabel('Mod+Shift+z'); // 'Ctrl+Shift+Z', or '⌘⇧Z' on a mac