Every extension

textTransform

Behaviour 0.96 kB gzipped

Change the case of the selection, or of the word under the caret.

Five commands: `uppercase`, `lowercase`, `capitalize` (the first letter of every word, the rest untouched), `sentenceCase` (the first letter of the selection and of every sentence after a full stop, everything else down) and `toggleCase` (all capitals go down, anything else goes up). With nothing selected each works on the word the caret is in.

The text is rewritten one text node at a time, so a bold word stays bold and a link stays a link. Locale-aware casing is used, which is why `ß` becomes `SS` and the selection is mapped afterwards rather than assumed to be the same width. A command that would change nothing returns false.

Adding it

import { createEditor, document, paragraph, text, textTransform } from '@matrajs/core'

const editor = createEditor({
  extensions: [document, paragraph, text, textTransform],
  element: document.querySelector('#editor'),
})

There is no separate package · textTransform is already in @matrajs/core, and an extension you do not import is not in your bundle. document, paragraph and text are the floor every document needs.

Commands

← All 81 extensions

Edit this page on GitHub