MCPcopy
hub / github.com/tinymce/tinymce / postprocess

Function postprocess

modules/tinymce/src/core/main/ts/api/html/DomParser.ts:246–280  ·  view source on GitHub ↗
(node: AstNode)

Source from the content-addressed store, hash-verified

244 };
245
246 const postprocess = (node: AstNode) => {
247 if (node.type === 1) {
248 // Check for empty nodes here, because children will have been processed and (if necessary) emptied / removed already
249 const elementRule = schema.getElementRule(node.name);
250 if (validate && elementRule) {
251 const isNodeEmpty = isEmpty(schema, nonEmptyElements, whitespaceElements, node);
252
253 if (elementRule.paddInEmptyBlock && isNodeEmpty && isTextRootBlockEmpty(node)) {
254 paddEmptyNode(settings, args, isBlock, node);
255 } else if (elementRule.removeEmpty && isNodeEmpty) {
256 if (isBlock(node)) {
257 node.remove();
258 } else {
259 node.unwrap();
260 }
261 } else if (elementRule.paddEmpty && (isNodeEmpty || isPaddedWithNbsp(node))) {
262 paddEmptyNode(settings, args, isBlock, node);
263 }
264 }
265 } else if (node.type === 3) {
266 // Removing trailing whitespace here, so that all whitespace in nodes to the right of us has already been fixed
267 if (!hasWhitespaceParent(node)) {
268 let text = node.value ?? '';
269 if (node.next && isBlock(node.next) || isAtEdgeOfBlock(node, false)) {
270 text = text.replace(endWhiteSpaceRegExp, '');
271 }
272
273 if (text.length === 0) {
274 node.remove();
275 } else {
276 node.value = text;
277 }
278 }
279 }
280 };
281
282 return [ preprocess, postprocess ];
283};

Callers 1

walkTreeFunction · 0.85

Calls 10

isEmptyFunction · 0.90
paddEmptyNodeFunction · 0.90
isPaddedWithNbspFunction · 0.90
isTextRootBlockEmptyFunction · 0.85
hasWhitespaceParentFunction · 0.85
isAtEdgeOfBlockFunction · 0.85
unwrapMethod · 0.80
replaceMethod · 0.80
isBlockFunction · 0.70
removeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…