本文整理汇总了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);
};
开发者ID:tinymce,项目名称:tinymce,代码行数:27,代码来源:FindPatterns.ts
示例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);
}
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:25,代码来源:RowDialog.ts
示例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([]);
};
开发者ID:tinymce,项目名称:tinymce,代码行数:9,代码来源:FindPatterns.ts
示例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');
});
开发者ID:abstask,项目名称:tinymce,代码行数:16,代码来源:DomUtilsTest.ts
示例5:
const sameBlockParent = (spot: Spot) => dom.getParent(spot.node, dom.isBlock) === block;
开发者ID:tinymce,项目名称:tinymce,代码行数:1,代码来源:FindPatterns.ts
注:本文中的tinymce/core/api/dom/DOMUtils.getParent函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论