Trilium Frontend API
    Preparing search index...

    Interface DataProcessor

    The data processor interface. It should be implemented by actual data processors.

    Each data processor implements a certain format of the data. For example, {@glink features/markdown Markdown data processor} will convert the data (a Markdown string) to a module:engine/view/documentfragment~ViewDocumentFragment document fragment and back.

    Note: While the CKEditor 5 architecture supports changing the data format, in most scenarios we do recommend sticking to the default format which is HTML (supported by the module:engine/dataprocessor/htmldataprocessor~HtmlDataProcessor). HTML remains the best standard for rich-text data.

    And please do remember – using Markdown does not automatically make your application/website secure.

    interface DataProcessor {
        skipComments?: boolean;
        registerRawContentMatcher(pattern: MatcherPattern): void;
        toData(viewFragment: ViewDocumentFragment): string;
        toView(data: string): ViewDocumentFragment;
        useFillerType(type: "default" | "marked"): void;
    }

    Implemented by

    Index

    Properties

    skipComments?: boolean

    If false, comment nodes will be converted to $comment. Otherwise comment nodes are ignored.

    Methods

    • Registers a module:engine/view/matcher~MatcherPattern for view elements whose content should be treated as raw data and its content should be converted to a module:engine/view/element~ViewElement#getCustomProperty custom property of a view element called "$rawContent" while converting #toView to view.

      Parameters

      • pattern: MatcherPattern

        Pattern matching all view elements whose content should be treated as plain text.

      Returns void

    • Converts a module:engine/view/documentfragment~ViewDocumentFragment document fragment to data.

      Parameters

      Returns string

    • Converts the data to a module:engine/view/documentfragment~ViewDocumentFragment document fragment.

      Parameters

      • data: string

        The data to be processed.

      Returns ViewDocumentFragment

    • If the processor is set to use marked fillers, it will insert &nbsp; fillers wrapped in <span> elements (<span data-cke-filler="true">&nbsp;</span>) instead of regular &nbsp; characters.

      This mode allows for more precise handling of block fillers (so they do not leak into the editor content) but bloats the editor data with additional markup.

      This mode may be required by some features and will be turned on by them automatically.

      Parameters

      • type: "default" | "marked"

        Whether to use the default or marked &nbsp; block fillers.

      Returns void