本文整理匯總了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;
}
};