本文整理汇总了TypeScript中tinymce/core/api/dom/DOMUtils.select函数的典型用法代码示例。如果您正苦于以下问题:TypeScript select函数的具体用法?TypeScript select怎么用?TypeScript select使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了select函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const markerRange = (ids: {start: string, end?: string}) => {
const start = Option.from(dom.select('#' + ids.start)[0]);
const end = Option.from(dom.select('#' + ids.end)[0]);
return Options.lift(start, end, (start, end) => {
const range = dom.createRng();
range.setStartAfter(start);
if (!isCollapsed(start, end, dom.getRoot())) {
range.setEndBefore(end);
} else {
range.collapse(true);
}
return range;
});
};
示例2: function
suite.test('select', function () {
DOM.add(document.body, 'div', { id : 'test' });
DOM.setHTML('test', '<div>test 1</div><div>test 2 <div>test 3</div></div><div>test 4</div>');
LegacyUnit.equal(DOM.select('div', 'test').length, 4);
LegacyUnit.equal(DOM.select('div', 'test').reverse !== undefined, true);
DOM.setHTML('test', '<div class="test1 test2 test3">test 1</div><div class="test2">test 2 <div>test 3</div></div><div>test 4</div>');
LegacyUnit.equal(DOM.select('div.test2', 'test').length, 2);
DOM.setHTML('test', '<div class="test1 test2 test3">test 1</div><div class="test2">test 2 <div>test 3</div></div><div>test 4</div>');
LegacyUnit.equal(DOM.select('div div', 'test').length, 1); // Issue: http://bugs.webkit.org/show_bug.cgi?id=17461
// alert(DOM.select('div div', 'test').length +","+DOM.get('test').querySelectorAll('div div').length);
DOM.remove('test');
});
示例3: 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);
}
};
示例4: function
const getTDTHOverallStyle = function (dom: DOMUtils, elm: Element, name: string): string {
const cells = dom.select('td,th', elm);
let firstChildStyle: string;
const checkChildren = function (firstChildStyle: string, elms: Element[]) {
for (let i = 0; i < elms.length; i++) {
const currentStyle = dom.getStyle(elms[i], name);
if (typeof firstChildStyle === 'undefined') {
firstChildStyle = currentStyle;
}
if (firstChildStyle !== currentStyle) {
return '';
}
}
return firstChildStyle;
};
firstChildStyle = checkChildren(firstChildStyle, cells);
return firstChildStyle;
};