Every extension

smartPaste

Behaviour takes options 1.76 kB gzipped

Paste what was meant, not what was copied.

A spreadsheet copied as text is tabs and newlines; a README copied from a terminal is Markdown; both arrive as a paragraph with the punctuation in it. This looks at plain text before the editor does and, when the shape is unmistakable, builds the table or parses the Markdown instead. Anything with real HTML on the clipboard is left to the parser, which already reads a table copied from a browser.

Needs the table nodes for the table half and whatever nodes the Markdown names for the other: a heading pasted into an editor with no heading extension stays text, because that editor cannot hold one.

Adding it

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

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

There is no separate package · smartPaste 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.

Options

Field Type
tables boolean Tab-separated and comma-separated text becomes a table. Default true.
csv boolean Comma-separated text counts as a table too. Default true.
headerRow boolean The first row of a pasted table is a header row. Default true.
markdown boolean Text that reads as Markdown is parsed as Markdown. Default true.

← All 81 extensions

Edit this page on GitHub