本文整理汇总了TypeScript中tinymce/core/api/dom/DOMUtils.getParent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getParent函数的具体用法?TypeScript getParent怎么用?TypeScript getParent使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getParent函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: TreeWalker
const findBlockPattern = (dom: DOMUtils, patterns: BlockPattern[], rng: Range): Option<BlockPattern> => {
const block = dom.getParent(rng.startContainer, dom.isBlock);
if (!(dom.is(block, 'p') && isElement(block))) {
return Option.none();
}
const walker = new TreeWalker(block, block);
let node: Node;
let firstTextNode: Text;
while ((node = walker.next())) {
if (isText(node)) {
firstTextNode = node;
break;
}
}
if (!firstTextNode) {
return Option.none();
}
const pattern = findPattern(patterns, firstTextNode.data);
if (!pattern) {
return Option.none();
}
if (Tools.trim(block.textContent).length === pattern.start.length) {
return Option.none();
}
return Option.some(pattern);
};
示例2: function
const switchRowType = function (dom: DOMUtils, rowElm: HTMLElement, toType) {
const tableElm = dom.getParent(rowElm, 'table');
const oldParentElm = rowElm.parentNode;
let parentElm = dom.select(toType, tableElm as Element)[0];
if (!parentElm) {
parentElm = dom.create(toType);
if (tableElm.firstChild) {
// caption tag should be the first descendant of the table tag (see TINY-1167)
if (tableElm.firstChild.nodeName === 'CAPTION') {
dom.insertAfter(parentElm, tableElm.firstChild);
} else {
tableElm.insertBefore(parentElm, tableElm.firstChild);
}
} else {
tableElm.appendChild(parentElm);
}
}
parentElm.appendChild(rowElm);
if (!oldParentElm.hasChildNodes()) {
dom.remove(oldParentElm);
}
};
示例3: findInlinePatternRec
const findNestedInlinePatterns = (dom: DOMUtils, patterns: InlinePattern[], rng: Range, space: boolean): InlinePatternMatch[] => {
if (rng.collapsed === false) {
return [];
}
const block = dom.getParent(rng.startContainer, dom.isBlock);
return findInlinePatternRec(dom, patterns, rng.startContainer, rng.startOffset - (space ? 1 : 0), block).getOr([]);
};
示例4: function
suite.test('getParent', function () {
DOM.add(document.body, 'div', { id : 'test' });
DOM.get('test').innerHTML = '<div><span>ab<a id="test2" href="">abc</a>c</span></div>';
LegacyUnit.equal(DOM.getParent('test2', eqNodeName('SPAN')).nodeName, 'SPAN');
LegacyUnit.equal(DOM.getParent('test2', eqNodeName('BODY')).nodeName, 'BODY');
LegacyUnit.equal(DOM.getParent('test2', eqNodeName('BODY'), document.body), null);
LegacyUnit.equal(DOM.getParent('test2', eqNodeName('X')), null);
LegacyUnit.equal(DOM.getParent('test2', 'SPAN').nodeName, 'SPAN');
LegacyUnit.equal(DOM.getParent('test2', 'body', DOM.get('test')), null);
DOM.get('test').innerHTML = '';
DOM.remove('test');
});
示例5:
const sameBlockParent = (spot: Spot) => dom.getParent(spot.node, dom.isBlock) === block;