Skip to main content

Working with the Clipboard

  • 2 minutes to read

The Rich Text Editor control ships with the Copy, Cut, and Paste commands that work with the clipboard. These commands are located in the Home tab and in the context menu.

RichEdit - Document Model

Pass the command’s identifier to the control’s executeCommand(commandId) method to execute this command in code:

richEdit.executeCommand(DevExpress.RichEdit.HomeTabCommandId.Copy);
richEdit.executeCommand(DevExpress.RichEdit.HomeTabCommandId.Cut);
richEdit.executeCommand(DevExpress.RichEdit.HomeTabCommandId.Paste);

Supported Clipboard Formats

The Copy and Cut commands send content to the clipboard in plain text format (TXT). When the Rich Text Editor is in touch screen mode, the commands can send content to the clipboard in internal RichEdit format.

The Paste command supports multiple formats and inserts content from the clipboard according to the following format priority:

  1. RTF
  2. Image
  3. Internal RichEdit Format
  4. HTML[1]
  5. TXT

When the Paste command finds content in a supported format in the clipboard, the command inserts it and does not check if content in other formats is also present. This behavior can cause a pasting issue if the clipboard stores incorrect content.

Access to the Clipboard

The Copy, Cut, and Paste commands require permission to access the clipboard. Permission may be rejected for the following reasons:

FireFox Limitation
Mozilla FireFox does not allow web pages to use JavaScript to access the clipboard. This restriction prevents the Paste command from reading the clipboard content.
Insecure Connection
Browsers block access to the clipboard for a web page when the connection between the browser and the page is insecure.
Browser Settings
Browser settings can block access to the clipboard for your web page.

The following warning message appears when a user’s browser blocks access to the clipboard for the Copy, Cut, or Paste command:

Access to the clipboard is denied due to your browser's security policy. 
Instead, you can use the keyboard shortcuts:
Ctrl+X (cut), Ctrl+C (copy) and Ctrl+V (paste).
Footnotes
  1. Inserting content in HTML format may violate Content Security Policy directives. Refer to the following topic for more information: Nonce.