PlainTextSerializer
@blobs/sdk / serializers / PlainTextSerializer
Defined in: serializers/PlainTextSerializer.ts:18
Serializer for plain-text content.
toHTML emits one <div> per line (or <br>-delimited spans, depending
on useDivGaps config) so that contenteditable preserves line breaks;
toContent collapses that back into a string with \n line breaks. When
preserveWhitespace is enabled, leading and consecutive spaces are
encoded as so they survive the HTML round-trip.
Extends
Extended by
Constructors
Constructor
new PlainTextSerializer(
config?):PlainTextSerializer
Defined in: serializers/PlainTextSerializer.ts:24
Parameters
config?
Optional SerializerConfig overrides.
Returns
PlainTextSerializer
Overrides
Properties
config
protectedconfig:SerializerConfig
Defined in: serializers/BaseSerializer.ts:35
Effective configuration (defaults merged with constructor overrides).
Inherited from
format
readonlyformat:ContentFormat='text'
Defined in: serializers/PlainTextSerializer.ts:19
The content format this serializer handles.
Overrides
Methods
configure()
configure(
config):void
Defined in: serializers/BaseSerializer.ts:62
Merges new options into the current configuration.
Parameters
config
Partial config to apply.
Returns
void
Inherited from
getConfig()
getConfig():
SerializerConfig
Defined in: serializers/BaseSerializer.ts:69
Returns a defensive copy of the current configuration.
Returns
Inherited from
escapeHTML()
protectedescapeHTML(text):string
Defined in: serializers/BaseSerializer.ts:76
Escape HTML special characters
Parameters
text
string
Returns
string
Inherited from
unescapeHTML()
protectedunescapeHTML(html):string
Defined in: serializers/BaseSerializer.ts:90
Unescape HTML entities back to characters
Parameters
html
string
Returns
string
Inherited from
createLineBreak()
protectedcreateLineBreak():string
Defined in: serializers/BaseSerializer.ts:105
Create a line break element based on config
Returns
string
Inherited from
BaseSerializer.createLineBreak
wrapParagraph()
protectedwrapParagraph(content,className?):string
Defined in: serializers/BaseSerializer.ts:116
Create a paragraph wrapper
Parameters
content
string
className?
string
Returns
string
Inherited from
stripTags()
protectedstripTags(html):string
Defined in: serializers/BaseSerializer.ts:124
Strip all HTML tags from a string
Parameters
html
string
Returns
string
Inherited from
normalizeWhitespace()
protectednormalizeWhitespace(text):string
Defined in: serializers/BaseSerializer.ts:131
Normalize whitespace in content
Parameters
text
string
Returns
string
Inherited from
BaseSerializer.normalizeWhitespace
divBreaksToNewlines()
protecteddivBreaksToNewlines(html):string
Defined in: serializers/BaseSerializer.ts:141
Convert contenteditable div breaks to newlines
Parameters
html
string
Returns
string
Inherited from
BaseSerializer.divBreaksToNewlines
parseHTML()
protectedparseHTML(html):string
Defined in: serializers/BaseSerializer.ts:161
Parse HTML using DOMParser if available, fallback to regex
Parameters
html
string
Returns
string
Inherited from
toContent()
toContent(
html):ParsedContent
Defined in: serializers/PlainTextSerializer.ts:33
Converts contenteditable HTML to plain text with \n line breaks.
Parameters
html
string
HTML emitted by the editor.
Returns
Overrides
toHTML()
toHTML(
content):RenderedHTML
Defined in: serializers/PlainTextSerializer.ts:62
Converts plain text to HTML, preserving line breaks and (optionally) exact whitespace.
Parameters
content
string
Plain-text content to render.