How to use the @ckeditor/ckeditor5-utils/src/dom/getancestors function in @ckeditor/ckeditor5-utils

To help you get started, we’ve selected a few @ckeditor/ckeditor5-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ckeditor / ckeditor5-engine / src / view / domconverter.js View on Github external
getParentUIElement( domNode ) {
		const ancestors = getAncestors( domNode );

		// Remove domNode from the list.
		ancestors.pop();

		while ( ancestors.length ) {
			const domNode = ancestors.pop();
			const viewNode = this._domToViewMapping.get( domNode );

			if ( viewNode && viewNode.is( 'uiElement' ) ) {
				return viewNode;
			}
		}

		return null;
	}
github ckeditor / ckeditor5-engine / src / view / domconverter.js View on Github external
function _hasDomParentOfType( node, types, boundaryParent ) {
	let parents = getAncestors( node );

	if ( boundaryParent ) {
		parents = parents.slice( parents.indexOf( boundaryParent ) + 1 );
	}

	return parents.some( parent => parent.tagName && types.includes( parent.tagName.toLowerCase() ) );
}
github ckeditor / ckeditor5-engine / src / view / domconverter.js View on Github external
_getTouchingInlineDomNode( node, getNext ) {
		if ( !node.parentNode ) {
			return null;
		}

		const direction = getNext ? 'nextNode' : 'previousNode';
		const document = node.ownerDocument;
		const topmostParent = getAncestors( node )[ 0 ];

		const treeWalker = document.createTreeWalker( topmostParent, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, {
			acceptNode( node ) {
				if ( isText( node ) ) {
					return NodeFilter.FILTER_ACCEPT;
				}

				if ( node.tagName == 'BR' ) {
					return NodeFilter.FILTER_ACCEPT;
				}

				return NodeFilter.FILTER_SKIP;
			}
		} );

		treeWalker.currentNode = node;