Customizing Smart Paste SupportEdit online
The Smart Paste feature preserves certain style and structure information when copying content from some of the most common applications and pasting into frameworks (document types) that support Smart Paste in Oxygen XML Editor plugin. For other document types, the default behavior of the paste operation is to keep only the text content without the styling.
The style of the pasted content can be customized by editing an XSLT stylesheet for a particular document type (framework). The XSLT stylesheet must accept an XHTML flavor of the copied content as input, and transform it to the equivalent XML markup that is appropriate for the target document type of the paste operation.
How to Customize the Smart Paste Mapping
- Make sure the particular framework contains a folder named
resources in the following path
structure:
/frameworks/[Document Type]/resources
- Create an XSLT file named xhtml2content.xsl and save it in the
resources folder for the particular framework.
For example: /frameworks/[Document Type]/resources/xhtml2content.xsl
- Add your customized styling in the XSLT file.Tip: The built-in DITA framework includes a xhtml2ditaDriver.xsl file (in [OXYGEN_INSTALL_DIR]/frameworks/dita/resources) that imports various other stylesheets that apply cleanup and handle the conversion from the pasted HTML content to DITA. If you are using a custom extension of the DITA framework, you can copy the entire contents of the built-in dita/resources folder and customize the stylesheets according to your needs.
- You can test modifications done in the stylesheet by pasting content without having to restart Oxygen XML Editor plugin.
Result: When you paste content from external applications (such as a web browser or and Office document) to a document that is opened in Author mode, and that matches the particular framework, the styling from the xhtml2content.xsl stylesheet will be applied on the clipboard contents.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns="urn:hl7-org:v3" exclude-result-prefixes="xsl xhtml"> <xsl:output method="xml" indent="no" omit-xml-declaration="yes"/> <xsl:template match="xhtml:b | xhtml:strong"> <content styleCode="bold" > <xsl:apply-templates select="@* | node()"/> </content> </xsl:template> <xsl:template match="*"> <xsl:apply-templates select="@* | node()"/> </xsl:template> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
For information about configuring how URLs are handled when they are dropped or pasted in Author mode, see Handling When URLs or XHTML Fragments are Dropped or Pasted in Author Mode.