How to paste text in Writer merging styles (i.e., of the pasted text and the document style)

Update: I decided to delete the previous file and start afresh. Now it seems Writer is pasting the text respecting the document’s paragraph spacing. I don’t know if maybe I misconfigured the styles in the deleted document, but now it seems to work well.

Hi there!

I’ve been using Trilium notes GitHub - zadam/trilium: Build your personal knowledge base with Trilium Notes to write draft documents.

I’ve made some style changes to that draft text (italics, bold, etc.) that must be kept when copying and pasting text to Writer, where I’ll produce the final text.

Trilium is an Electron app that uses CK Editor 5 Feature-rich editor - CKEditor 5 demo , thus when I copy text from it I believe it’s the same as copying from a HTML file.

My problem is that when pasting I only get 3 options, and none of them keep the text formatting (italics, bold etc.) while preserving the target Writer document’s style:

  1. “Stripped HyperText Markup Language (Simple HTML)”,
  2. “HTML format without comments”,
  3. “Unformatted text”

Options 1 and 2 keep the formatting (bold, italic, underline), but don’t keep the document’s paragraph for line spacing.

Is it possible to have a “merge styles” option where I can preserve all of the document’s style/format, except for specific changes to the copied text (like bold, italic, underline, color)?

I’m on Win 10, 64 bit, latest Trilium and Writer (24.2.4.2)

Thank you for your help!


Some somewhat related threads (I changed those to “site:” because as a new user I’m not allowed to use more than 2 web links in my post):

  • site:ask.libreoffice.org/t/writer-copy-text-with-the-same-formatting-style/38844
  • site:ask.libreoffice.org/t/how-to-retain-formatting-when-pasting-text/24331
  • site:ask.libreoffice.org/t/lo-writer-misses-to-paste-merge-formatting-like-ms-word-deutsch-einfugen-format-zusammenfuhren/80642
  • site:ask.libreoffice.org/t/is-it-possible-to-merge-styles-in-writer/27483
  • site:ask.libreoffice.org/t/writer-copy-paste-table-formats/24566

I am not sure what you mean by keeping paragraph spacing, the spacing from CKEditor or spacing in the receiving document.

Either way, CKEditor seems to be user friendly when just pasting normally, Bold becomes Strong Emphasis character style so I assume italics would become Emphasis character style. This means you can select the pasted text and click Format > Clear direct formatting (Ctrl+M) and the paragraph spacing will change to that defined in Body Text or other paragraph style, e.g. Heading 1, that is defined in the receiving document.

If you don’t like the spacing above or below in the relevant style in the receiving document, then right click the paragraph style in the Styles pane, and select Edit style

[Edit]
The Export to Word works adequately for Word but has layout issues if opened in Writer.

Thanks! I think this was the solution. My previous file used a template, I think when I pasted the text it used a different, custom style for the section I was working on (“Research paper contents” instead of the “Default Paragraph Style”). So when I pasted the text, it’d convert it to Default Paragraph Style, even though it was in a section that should have a different style. But clicking on Edit Style and editing it as you described made me realize there were multiple styles. By editing it there this can be solved

A word of warning, Default Paragraph Style is not intended for use in a document. It is there to make global changes to the child styles. The intended paragraph style for the main body of the document is Body Text.

Where your document has a custom style, then CKEditor will still paste the main body as Body Text rather than Research paper contents. The Body Text is easily changed to Research paper contents by

  • Click Edit > Find and Replace (Ctrl+H)
  • In the dialogue that opens tick the box Paragraph styles
    • In Find, select Body Text
    • In Replace, select Research paper contents
  • Click button Replace All

The Writer Guide has more information on styles, download from English documentation | LibreOffice Documentation - LibreOffice User Guides