本文整理汇总了TypeScript中@ephox/dom-globals.Node类的典型用法代码示例。如果您正苦于以下问题:TypeScript Node类的具体用法?TypeScript Node怎么用?TypeScript Node使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: TreeWalker
const findNode = (node: Node, direction: number, predicateFn: (node: Node) => boolean, rootNode: Node, shallow?: boolean) => {
const walker = new TreeWalker(node, rootNode);
if (isBackwards(direction)) {
if (isContentEditableFalse(node) || isCaretContainerBlock(node)) {
node = skipCaretContainers(walker.prev, true);
if (predicateFn(node)) {
return node;
}
}
while ((node = skipCaretContainers(walker.prev, shallow))) {
if (predicateFn(node)) {
return node;
}
}
}
if (isForwards(direction)) {
if (isContentEditableFalse(node) || isCaretContainerBlock(node)) {
node = skipCaretContainers(walker.next, true);
if (predicateFn(node)) {
return node;
}
}
while ((node = skipCaretContainers(walker.next, shallow))) {
if (predicateFn(node)) {
return node;
}
}
}
return null;
};
示例2: if
const insertAfter = (node: Node) => {
if (isText(node.nextSibling)) {
if (startsWithCaretContainer(node.nextSibling)) {
return node.nextSibling;
} else {
node.nextSibling.insertData(0, Zwsp.ZWSP);
return node.nextSibling;
}
} else if (isText(node)) {
if (endsWithCaretContainer(node)) {
return node;
} else {
node.appendData(Zwsp.ZWSP);
return node;
}
} else {
const newNode = createZwsp(node);
if (node.nextSibling) {
node.parentNode.insertBefore(newNode, node.nextSibling);
} else {
node.parentNode.appendChild(newNode);
}
return newNode;
}
};
示例3: isElement
const isCaretContainerBlock = (node: Node): boolean => {
if (isText(node)) {
node = node.parentNode;
}
return isElement(node) && node.hasAttribute('data-mce-caret');
};
示例4:
const nodeAtIndex = (container: Node, offset: number): Node => {
if (container.hasChildNodes() && offset < container.childNodes.length) {
return container.childNodes[offset];
}
return null;
};
示例5: function
const isAtomicContentEditableFalse = (node: Node): boolean => {
if (!isNonUiContentEditableFalse(node)) {
return false;
}
return Arr.foldl(Arr.from(node.getElementsByTagName('*')), function (result, elm) {
return result || isContentEditableTrue(elm);
}, false) !== true;
};
示例6: normalizedParent
const normalizedParent = (node: Node): Node => {
const parentNode = node.parentNode;
if (isBogus(parentNode)) {
return normalizedParent(parentNode);
}
return parentNode;
};
示例7: function
editor.on('touchend', function (e) {
const contentEditableRoot = getContentEditableRoot(editor, e.target);
if (isContentEditableFalse(contentEditableRoot)) {
if (!moved) {
e.preventDefault();
setContentEditableSelection(CefUtils.selectNode(editor, contentEditableRoot));
}
}
});
示例8: function
const getNode = function (container: Node, offset: number): Node {
if (container.nodeType === 1 && container.hasChildNodes()) {
if (offset >= container.childNodes.length) {
offset = container.childNodes.length - 1;
}
container = container.childNodes[offset];
}
return container;
};
示例9: function
const bindEventDelegate = function (editor: Editor, eventName: string) {
let eventRootElm, delegate;
if (!editor.delegates) {
editor.delegates = {};
}
if (editor.delegates[eventName] || editor.removed) {
return;
}
eventRootElm = getEventTarget(editor, eventName);
if (editor.settings.event_root) {
if (!customEventRootDelegates) {
customEventRootDelegates = {};
editor.editorManager.on('removeEditor', function () {
let name;
if (!editor.editorManager.activeEditor) {
if (customEventRootDelegates) {
for (name in customEventRootDelegates) {
editor.dom.unbind(getEventTarget(editor, name));
}
customEventRootDelegates = null;
}
}
});
}
if (customEventRootDelegates[eventName]) {
return;
}
delegate = function (e) {
const target = e.target;
const editors = editor.editorManager.get();
let i = editors.length;
while (i--) {
const body = editors[i].getBody();
if (body === target || DOM.isChildOf(target, body)) {
fireEvent(editors[i], eventName, e);
}
}
};
customEventRootDelegates[eventName] = delegate;
DOM.bind(eventRootElm, eventName, delegate);
} else {
delegate = function (e) {
fireEvent(editor, eventName, e);
};
DOM.bind(eventRootElm, eventName, delegate);
editor.delegates[eventName] = delegate;
}
};