MCPcopy Index your code
hub / github.com/tinymce/tinymce / getContainer

Function getContainer

modules/tinymce/src/core/main/ts/fmt/RemoveFormat.ts:61–86  ·  view source on GitHub ↗
(ed: Editor, rng: RangeLikeObject, start?: boolean)

Source from the content-addressed store, hash-verified

59const isChildOfInlineParent = (dom: DOMUtils, node: Node, parent: Node): boolean => dom.isChildOf(node, parent) && node !== parent && !dom.isBlock(parent);
60
61const getContainer = (ed: Editor, rng: RangeLikeObject, start?: boolean) => {
62 let container = rng[start ? 'startContainer' : 'endContainer'];
63 let offset = rng[start ? 'startOffset' : 'endOffset'];
64
65 if (NodeType.isElement(container)) {
66 const lastIdx = container.childNodes.length - 1;
67
68 if (!start && offset) {
69 offset--;
70 }
71
72 container = container.childNodes[offset > lastIdx ? lastIdx : offset];
73 }
74
75 // If start text node is excluded then walk to the next node
76 if (NodeType.isText(container) && start && offset >= container.data.length) {
77 container = new DomTreeWalker(container, ed.getBody()).next() || container;
78 }
79
80 // If end text node is excluded then walk to the previous node
81 if (NodeType.isText(container) && !start && offset === 0) {
82 container = new DomTreeWalker(container, ed.getBody()).prev() || container;
83 }
84
85 return container;
86};
87
88const normalizeTableSelection = (node: Node, start: boolean): Node => {
89 const prop = start ? 'firstChild' : 'lastChild';

Callers 1

removeRngStyleFunction · 0.85

Calls 3

getBodyMethod · 0.80
nextMethod · 0.65
prevMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…