NEWCKEditor AI is here!
Sign up (with export icon)

paste-from-office/filters/replacetabswithinprewithspaces

Api-module iconmodule

Functions

  • Chevron-right icon

    replaceTabsWithinPreWithSpaces( documentFragment, writer, tabWidth ) → void
    internal

    Replaces tab characters with spaces in text nodes that are inside elements styled with white-space: pre-wrap.

    This is a workaround for incorrect detection of pre-like formatting in the DOM converter for pasted Google Docs documents. When an element uses white-space: pre-wrap, the editor reduces tab characters to a single space, causing inconsistent spacing in pasted content. This function replaces tabs with spaces to ensure visual consistency. This is intended as a temporary solution.

    See: https://github.com/ckeditor/ckeditor5/issues/18995

    Parameters

    documentFragment : ViewDocumentFragment

    The data.content element obtained from the clipboard.

    writer : ViewUpcastWriter

    The upcast writer used to manipulate the view structure.

    tabWidth : number

    The number of spaces to replace each tab with. Defaults to 8.

    Returns

    void