本文整理汇总了TypeScript中@ephox/dom-globals.Node.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Node.default方法的具体用法?TypeScript Node.default怎么用?TypeScript Node.default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/dom-globals.Node
的用法示例。
在下文中一共展示了Node.default方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
};
示例3: normalizedParent
const normalizedParent = (node: Node): Node => {
const parentNode = node.parentNode;
if (isBogus(parentNode)) {
return normalizedParent(parentNode);
}
return parentNode;
};
示例4: function
editor.on('touchend', function (e) {
const contentEditableRoot = getContentEditableRoot(editor, e.target);
if (isContentEditableFalse(contentEditableRoot)) {
if (!moved) {
e.preventDefault();
setContentEditableSelection(CefUtils.selectNode(editor, contentEditableRoot));
}
}
});
示例5: resolvePathItem
container = ArrUtils.reduce(path, function (result, value) {
value = /([\w\-\(\)]+)\[([0-9]+)\]/.exec(value);
if (!value) {
return null;
}
if (value[1] === 'text()') {
value[1] = '#text';
}
return resolvePathItem(result, value[1], parseInt(value[2], 10));
}, root);
示例6: createComplex
const createComplexRng = (n: HtmlItem | string, startPos: number[], endPos: number[]): {root: HTMLElement, range: Range} => {
const root = document.createElement('div');
const ele = createComplex(n);
root.appendChild(ele);
const select = (node: Node, pos: number[]) => pos.length === 0 ? node : select(node.childNodes[pos[0]], pos.slice(1));
const startOffset = startPos.pop();
const start = select(ele, startPos);
const endOffset = endPos.pop();
const end = select(ele, endPos);
const range = document.createRange();
range.setStart(start, startOffset);
range.setEnd(end, endOffset);
return { root, range };
};
示例7: getChildNodes
const normalizedNodeIndex = (node: Node): number => {
let nodes, index, numTextFragments;
nodes = getChildNodes(normalizedParent(node));
index = ArrUtils.findIndex(nodes, equal(node), node);
nodes = nodes.slice(0, index + 1);
numTextFragments = ArrUtils.reduce(nodes, function (result, node, i) {
if (isText(node) && isText(nodes[i - 1])) {
result++;
}
return result;
}, 0);
nodes = ArrUtils.filter(nodes, NodeType.matchNodeNames(node.nodeName));
index = ArrUtils.findIndex(nodes, equal(node), node);
return index - numTextFragments;
};
示例8: getContentEditableRoot
editor.on('mousedown', (e: MouseEvent) => {
let contentEditableRoot;
const targetElm = e.target as Element;
if (targetElm !== rootNode && targetElm.nodeName !== 'HTML' && !editor.dom.isChildOf(targetElm, rootNode)) {
return;
}
if (EditorView.isXYInContentArea(editor, e.clientX, e.clientY) === false) {
return;
}
contentEditableRoot = getContentEditableRoot(editor, targetElm);
if (contentEditableRoot) {
if (isContentEditableFalse(contentEditableRoot)) {
e.preventDefault();
setContentEditableSelection(CefUtils.selectNode(editor, contentEditableRoot));
} else {
removeContentEditableSelection();
// Check that we're not attempting a shift + click select within a contenteditable='true' element
if (!(isContentEditableTrue(contentEditableRoot) && e.shiftKey) && !RangePoint.isXYWithinRange(e.clientX, e.clientY, editor.selection.getRng())) {
hideFakeCaret();
editor.selection.placeCaretAt(e.clientX, e.clientY);
}
}
} else if (isFakeCaretTarget(targetElm) === false) {
// Remove needs to be called here since the mousedown might alter the selection without calling selection.setRng
// and therefore not fire the AfterSetSelectionRange event.
removeContentEditableSelection();
hideFakeCaret();
const caretInfo = LineUtils.closestCaret(rootNode, e.clientX, e.clientY);
if (caretInfo) {
if (!hasBetterMouseTarget(e.target, caretInfo.node)) {
e.preventDefault();
const range = showCaret(1, caretInfo.node as HTMLElement, caretInfo.before, false);
editor.getBody().focus();
setRange(range);
}
}
}
});