TinyMCE paste: choose text defaults, image handling, and cleanup timing

TinyMCE includes core paste functionality. Set paste_as_text when plain text should be the default, smart_paste when URL recognition should be enabled or disabled, and paste_data_images for inline data-URL images. These are separate decisions. The premium PowerPaste plugin has its own capabilities and does not share every core option. Copy and paste options

A fictional service bulletin accepts a paragraph copied from a supplier portal. The bulletin needs the words and a manually reviewed reference link. It should not inherit the portal's colored spans or turn a pasted image URL into an image. Start with that content policy before adding cleanup callbacks.

Set the default authors will encounter

Merge this fragment into the application's existing TinyMCE initialization:

const bulletinPasteOptions = {
  paste_as_text: true,
  smart_paste: false,
  paste_data_images: false,
  paste_block_drop: true
};

paste_as_text sets the default state of Edit → Paste as text. It is not a server-side guarantee that every saved document contains only text. Other editing actions, imports, or application requests can introduce markup.

With smart_paste enabled, TinyMCE recognizes URL-like text as a link and may replace an image URL with an image. Disabling it lets the bulletin author review the reference before creating a link. This does not disable every link-related plugin or the editor's explicit link command.

paste_data_images: false removes inline data-URL images from pasted content. It does not implement an image-upload service or reject every remotely linked image. The option's documented current default is true, so choose it explicitly if inline images conflict with the bulletin's policy.

Decide whether dragging should bypass the paste route

TinyMCE documents browser limitations that prevent its paste filtering from handling dragged-and-dropped content in the same way. Setting paste_block_drop: true disables dropping content into the editor while leaving copy and paste enabled.

For the bulletin, that is a reasonable way to keep the documented paste route consistent. An image-heavy authoring application may need a deliberate upload workflow instead. Do not promise that paste settings validate content received by a server or filter every separate import path.

The Word-to-CKEditor guide addresses preserving Office structures with a different editor. This TinyMCE task is choosing core clipboard behavior and the timing of local cleanup; adding Office conversion is a separate requirement.

Choose string processing or parsed-node processing

paste_preprocess receives content as a string before insertion. paste_postprocess receives a parsed DOM structure, still before insertion. For a narrow rule such as removing supplier tracking attributes, working with parsed nodes avoids treating HTML structure as a plain string replacement.

This optional fragment removes one specific attribute in the pasted fragment:

const bulletinPasteCleanup = {
  paste_postprocess: (editor, args) => {
    args.node.querySelectorAll('[data-supplier-track]').forEach(node => {
      node.removeAttribute('data-supplier-track');
    });
  }
};

It does not remove unrelated markup, sanitize all unsafe content, or alter material already stored in the document. Merge it into the same initialization only if this particular attribute is an actual input requirement. Keep the application's normal content validation and output sanitization.

For a rich-text policy, first test with paste_as_text: false in a disposable configuration so the relevant markup reaches the parsed-node callback. Under the bulletin's plain-text default, the attribute may already be absent; an empty match list then does not show that the cleanup code removed it.

Test the policy with distinct inputs

Use a short source paragraph with a bold phrase and a reference URL, an image URL pasted as text, and an actual copied image. Paste each through the normal browser command. Check the final words, whether a link or image was created, and what HTML the editor returns.

Then try dropping the same source content: with drop blocking enabled, it should not enter through that route. Keep these checks separate so a successful paragraph paste cannot stand in for image handling or drop blocking.

Save and reopen the bulletin through the actual application. The TinyMCE extraction guide explains how to capture its current HTML. Before delivery, read the supplier sentence and open the deliberately added reference link. The bulletin should retain the information readers need without inheriting unrelated portal presentation.

Keep reading