paste-from-office/filters/replacetabswithinprewithspaces
module
Functions
replaceTabsWithinPreWithSpaces( documentFragment, writer, tabWidth ) → voidinternalmodule:paste-from-office/filters/replacetabswithinprewithspaces~replaceTabsWithinPreWithSpacesReplaces 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 : ViewDocumentFragmentThe
data.contentelement obtained from the clipboard.writer : ViewUpcastWriterThe upcast writer used to manipulate the view structure.
tabWidth : numberThe number of spaces to replace each tab with. Defaults to 8.
Returns
void