本文整理匯總了TypeScript中@ephox/dom-globals.Range.setStartAfter方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Range.setStartAfter方法的具體用法?TypeScript Range.setStartAfter怎麽用?TypeScript Range.setStartAfter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/dom-globals.Range
的用法示例。
在下文中一共展示了Range.setStartAfter方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
const setContentEditableSelection = function (range: Range, forward?: boolean) {
let node;
const $ = editor.$;
const dom = editor.dom;
let $realSelectionContainer, sel,
startContainer, startOffset, endOffset, e, caretPosition, targetClone, origTargetClone;
if (!range) {
return null;
}
if (range.collapsed) {
if (!isRangeInCaretContainer(range)) {
if (forward === false) {
caretPosition = getNormalizedRangeEndPoint(-1, range);
if (isFakeCaretTarget(caretPosition.getNode(true))) {
return showCaret(-1, caretPosition.getNode(true), false, false);
}
if (isFakeCaretTarget(caretPosition.getNode())) {
return showCaret(-1, caretPosition.getNode(), !caretPosition.isAtEnd(), false);
}
} else {
caretPosition = getNormalizedRangeEndPoint(1, range);
if (isFakeCaretTarget(caretPosition.getNode())) {
return showCaret(1, caretPosition.getNode(), !caretPosition.isAtEnd(), false);
}
if (isFakeCaretTarget(caretPosition.getNode(true))) {
return showCaret(1, caretPosition.getNode(true), false, false);
}
}
}
return null;
}
startContainer = range.startContainer;
startOffset = range.startOffset;
endOffset = range.endOffset;
// Normalizes <span cE=false>[</span>] to [<span cE=false></span>]
if (startContainer.nodeType === 3 && startOffset === 0 && isContentEditableFalse(startContainer.parentNode)) {
startContainer = startContainer.parentNode;
startOffset = dom.nodeIndex(startContainer);
startContainer = startContainer.parentNode;
}
if (startContainer.nodeType !== 1) {
return null;
}
if (endOffset === startOffset + 1) {
node = startContainer.childNodes[startOffset];
}
if (!isContentEditableFalse(node)) {
return null;
}
targetClone = origTargetClone = node.cloneNode(true);
e = editor.fire('ObjectSelected', { target: node, targetClone });
if (e.isDefaultPrevented()) {
return null;
}
$realSelectionContainer = SelectorFind.descendant(SugarElement.fromDom(editor.getBody()), '#' + realSelectionId).fold(
function () {
return $([]);
},
function (elm) {
return $([elm.dom()]);
}
);
targetClone = e.targetClone;
if ($realSelectionContainer.length === 0) {
$realSelectionContainer = $(
'<div data-mce-bogus="all" class="mce-offscreen-selection"></div>'
).attr('id', realSelectionId);
$realSelectionContainer.appendTo(editor.getBody());
}
range = editor.dom.createRng();
// WHY is IE making things so hard! Copy on <i contentEditable="false">x</i> produces: <em>x</em>
// This is a ridiculous hack where we place the selection from a block over the inline element
// so that just the inline element is copied as is and not converted.
if (targetClone === origTargetClone && Env.ie) {
$realSelectionContainer.empty().append('<p style="font-size: 0" data-mce-bogus="all">\u00a0</p>').append(targetClone);
range.setStartAfter($realSelectionContainer[0].firstChild.firstChild);
range.setEndAfter(targetClone);
} else {
$realSelectionContainer.empty().append('\u00a0').append(targetClone).append('\u00a0');
range.setStart($realSelectionContainer[0].firstChild, 1);
range.setEnd($realSelectionContainer[0].lastChild, 0);
}
//.........這裏部分代碼省略.........