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