Clipboard - Plain text

Plain text will be processed before it is pasted in a document. The pasted text is split into chunks. The input string is split on every newline character ("/n") and optional carriage return character ("\r") in front of it. The chunks are then processed by the input and output processors.

Default configuration

Fonto Editor has a default configuration for pasting plain text. This configuration is active when no other configuration is set. This configuration can handle "hardened" soft-wraps. These are usually exported by PDF readers at positions where the content wraps to another line.

The default configuration takes the following steps to handle these "hardened" soft-wraps:

  • Lines that contain words are given a "Paragraph" label

  • Lines not ending with a "." (dot) are joined with the following line to remove any "hardened" soft-wraps

  • Paragraphs are outputted as the configurable paragraph element

  • If that fails, they are outputted as plain text

Make it work

The only thing the standard configuration requires is that the paragraph-node-name-for-pasting is set. If you are configuring a DITA editor using the fontoxml-dita add-on, you're all set as the add-on sets this configuration value for you.

If you are configuring an editor that uses another schema, you will have to set this configuration option yourself:

config/configuration.js

JavaScript

import configurationManager from 'fontoxml-configuration/src/configurationManager.js';

configurationManager.set('paragraph-node-name-for-pasting', 'p');

Custom configuration

The default configuration is very simple. Usually, there is more markup that can be extracted from pasted content. This can be done by looking for specific characters or sequences of characters.

A custom configuration consists of two parts. An array containing input processors and an array containing output processors. The input processors take the raw chunks and are able to annotate them by putting a label on the chunk. The output processors take the annotated chunks and output their contents to be pasted in the document. This output can either be plain text or one or more elements.

A single chunk can have more than one label. This is useful, for example, for lists. When an output processor tries to insert a list, but is unable to do so because of schema limitations, it can fall back to inserting a paragraph or even plain text.

Processors

The platform provides a few standard input and output processors which can be used to create your own import and export pipelines.

Input processors

The following output processors are supplied by the platform:

By adhering to the PipelinedImporterInputProcessor interface, it is possible to write these processors on the application level.

Output processors

The following input processors are supplied by the platform:

By adhering to the PipelinedImporterOutputProcessor interface, it is possible to write these processors on the application level.