本文整理汇总了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;
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:35,代码来源:CaretUtils.ts
示例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;
}
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:25,代码来源:CaretContainerInline.ts
示例3: isElement
const isCaretContainerBlock = (node: Node): boolean => {
if (isText(node)) {
node = node.parentNode;
}
return isElement(node) && node.hasAttribute('data-mce-caret');
};
开发者ID:mdgbayly,项目名称:tinymce,代码行数:7,代码来源:CaretContainer.ts
示例4:
const nodeAtIndex = (container: Node, offset: number): Node => {
if (container.hasChildNodes() && offset < container.childNodes.length) {
return container.childNodes[offset];
}
return null;
};
开发者ID:mdgbayly,项目名称:tinymce,代码行数:7,代码来源:CaretWalker.ts
示例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;
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:9,代码来源:CaretCandidate.ts
示例6: normalizedParent
const normalizedParent = (node: Node): Node => {
const parentNode = node.parentNode;
if (isBogus(parentNode)) {
return normalizedParent(parentNode);
}
return parentNode;
};
开发者ID:tinymce,项目名称:tinymce,代码行数:9,代码来源:CaretBookmark.ts
示例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));
}
}
});
开发者ID:danielpunkass,项目名称:tinymce,代码行数:10,代码来源:SelectionOverrides.ts
示例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;
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:11,代码来源:RangeNodes.ts
示例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;
}
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:60,代码来源:EditorObservable.ts
注:本文中的@ephox/dom-globals.Node类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论