MCPcopy
hub / github.com/tinymce/tinymce / paddEmptyNode

Function paddEmptyNode

modules/tinymce/src/core/main/ts/html/ParserUtils.ts:7–18  ·  view source on GitHub ↗
(settings: DomParserSettings, args: ParserArgs, isBlock: (node: AstNode) => boolean, node: AstNode)

Source from the content-addressed store, hash-verified

5import type { SchemaMap, default as Schema } from '../api/html/Schema';
6
7const paddEmptyNode = (settings: DomParserSettings, args: ParserArgs, isBlock: (node: AstNode) => boolean, node: AstNode): void => {
8 const brPreferred = settings.pad_empty_with_br || args.insert;
9 if (brPreferred && isBlock(node)) {
10 const astNode = new AstNode('br', 1);
11 if (args.insert) {
12 astNode.attr('data-mce-bogus', '1');
13 }
14 node.empty().append(astNode);
15 } else {
16 node.empty().append(new AstNode('#text', 3)).value = Unicode.nbsp;
17 }
18};
19
20const isPaddedWithNbsp = (node: AstNode): boolean =>
21 hasOnlyChild(node, '#text') && node?.firstChild?.value === Unicode.nbsp;

Callers 2

addNodeFilterFunction · 0.90
postprocessFunction · 0.90

Calls 4

attrMethod · 0.95
appendMethod · 0.80
emptyMethod · 0.80
isBlockFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…