# Paste and schema {#clipboard}

Source: [Preserve formatting on paste in a React editor · Yurich](https://leeyujoo.com/yurich/features/clipboard/)

Package: [`yurich`](https://www.npmjs.com/package/yurich)

Package version: `0.1.2`

Choose which formats to keep when pasting.

## Try it {#try-it}

Copy the sample below and paste it into the editor. Bold and the link keep their formatting. Italics become plain text.
<div class="clipboard-sample"><p data-clipboard-sample><strong>Bold text</strong> · <em>Italic text</em> · <a href="https://example.com/">Link</a></p></div>

## Add it to your editor {#setup}

Pick the formats your editor should keep by registering the corresponding extensions. The built-in paste handler reads the clipboard and applies the active schema.

```tsx
import { Bold, Code, EditorContent, EditorProvider, Heading, Link, useEditor } from 'yurich';

export function ClipboardEditor() {
  const editor = useEditor({ extensions: [Bold, Code, Heading, Link] });

  return (
    <EditorProvider editor={editor}>
      <EditorContent ariaLabel="Paste formatted text here" />
    </EditorProvider>
  );
}
```

## Behavior to account for {#behavior}

With `Heading`, `Code`, and `Link` enabled, you can copy this section from its heading through the Features link below and paste it with its formatting intact. Plain-text paste inserts text without parsing it as HTML. Dropping content into the editor is disabled. Register `Italic` if italic needs to survive paste and export.

[Features](https://leeyujoo.com/yurich/features/)
