本文整理汇总了TypeScript中@ephox/dom-globals.Range.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Range.default方法的具体用法?TypeScript Range.default怎么用?TypeScript Range.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/dom-globals.Range
的用法示例。
在下文中一共展示了Range.default方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createRange
.map(function (newEndPos) {
if (!CaretUtils.isInSameBlock(startPos, endPos, rootNode) && CaretUtils.isInSameBlock(startPos, newEndPos, rootNode)) {
return createRange(startPos.container(), startPos.offset(), newEndPos.container(), newEndPos.offset());
} else {
return rng;
}
}).getOr(rng);
示例2: getNodeRange
const selectNode = (editor, node: Element): Range => {
const e = editor.fire('BeforeObjectSelected', { target: node });
if (e.isDefaultPrevented()) {
return null;
}
return getNodeRange(node);
};
示例3: createRange
const toRange = (): Range => {
let range;
range = createRange(container.ownerDocument);
range.setStart(container, offset);
range.setEnd(container, offset);
return range;
};
示例4: normalizeRange
const getNormalizedRangeEndPoint = (direction: number, root: Node, range: Range): CaretPosition => {
const normalizedRange = normalizeRange(direction, root, range);
if (direction === -1) {
return CaretPosition.fromRangeStart(normalizedRange);
}
return CaretPosition.fromRangeEnd(normalizedRange);
};
示例5: return
return () => {
const newRng = getVerticalRange(editor, down);
if (newRng) {
editor.selection.setRng(newRng);
return true;
} else {
return false;
}
};
示例6: renderCaretAtRange
const renderRangeCaret = (editor: Editor, range: Range, scrollIntoView: boolean): Range => {
if (!range || !range.collapsed) {
return range;
}
const caretRange = renderCaretAtRange(editor, range, scrollIntoView);
if (caretRange) {
return caretRange;
}
return range;
};
示例7: showCaret
const renderCaretAtRange = (editor: Editor, range: Range, scrollIntoView: boolean): Range => {
const normalizedRange = CaretUtils.normalizeRange(1, editor.getBody(), range);
const caretPosition = CaretPosition.fromRangeStart(normalizedRange);
const caretPositionNode = caretPosition.getNode();
if (isContentEditableFalse(caretPositionNode)) {
return showCaret(1, editor, caretPositionNode, !caretPosition.isAtEnd(), false);
}
const caretPositionBeforeNode = caretPosition.getNode(true);
if (isContentEditableFalse(caretPositionBeforeNode)) {
return showCaret(1, editor, caretPositionBeforeNode, false, false);
}
// TODO: Should render caret before/after depending on where you click on the page forces after now
const ceRoot = editor.dom.getParent(caretPosition.getNode(), (node) => isContentEditableFalse(node) || isContentEditableTrue(node));
if (isContentEditableFalse(ceRoot)) {
return showCaret(1, editor, ceRoot, false, scrollIntoView);
}
return null;
};
示例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);
}
}
}
});