本文整理汇总了TypeScript中tinymce/core/api/dom/DOMUtils.DOMUtils.get方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DOMUtils.get方法的具体用法?TypeScript DOMUtils.get怎么用?TypeScript DOMUtils.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinymce/core/api/dom/DOMUtils.DOMUtils
的用法示例。
在下文中一共展示了DOMUtils.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: if
const restoreEndPoint = (dom: DOMUtils, suffix: string, bookmark: IdBookmark) => {
let marker = dom.get(bookmark.id + '_' + suffix), node, idx, next, prev;
const keep = bookmark.keep;
let container, offset;
if (marker) {
node = marker.parentNode;
if (suffix === 'start') {
if (!keep) {
idx = dom.nodeIndex(marker);
} else {
if (marker.hasChildNodes()) {
node = marker.firstChild;
idx = 1;
} else if (isValidTextNode(marker.nextSibling)) {
node = marker.nextSibling;
idx = 0;
} else if (isValidTextNode(marker.previousSibling)) {
node = marker.previousSibling;
idx = marker.previousSibling.data.length;
} else {
node = marker.parentNode;
idx = dom.nodeIndex(marker) + 1;
}
}
container = node;
offset = idx;
} else {
if (!keep) {
idx = dom.nodeIndex(marker);
} else {
if (marker.hasChildNodes()) {
node = marker.firstChild;
idx = 1;
} else if (isValidTextNode(marker.previousSibling)) {
node = marker.previousSibling;
idx = marker.previousSibling.data.length;
} else {
node = marker.parentNode;
idx = dom.nodeIndex(marker);
}
}
container = node;
offset = idx;
}
if (!keep) {
prev = marker.previousSibling;
next = marker.nextSibling;
// Remove all marker text nodes
Tools.each(Tools.grep(marker.childNodes), (node) => {
if (NodeType.isText(node)) {
node.nodeValue = node.nodeValue.replace(/\uFEFF/g, '');
}
});
// Remove marker but keep children if for example contents where inserted into the marker
// Also remove duplicated instances of the marker for example by a
// split operation or by WebKit auto split on paste feature
while ((marker = dom.get(bookmark.id + '_' + suffix))) {
dom.remove(marker, true);
}
// If siblings are text nodes then merge them unless it's Opera since it some how removes the node
// and we are sniffing since adding a lot of detection code for a browser with 3% of the market
// isn't worth the effort. Sorry, Opera but it's just a fact
if (prev && next && prev.nodeType === next.nodeType && NodeType.isText(prev) && !Env.opera) {
idx = prev.nodeValue.length;
prev.appendData(next.nodeValue);
dom.remove(next);
if (suffix === 'start') {
container = prev;
offset = idx;
} else {
container = prev;
offset = idx;
}
}
}
return Option.some(CaretPosition(container, offset));
} else {
return Option.none();
}
};