本文整理匯總了TypeScript中tinymce/core/caret/FakeCaret.isFakeCaretTarget函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isFakeCaretTarget函數的具體用法?TypeScript isFakeCaretTarget怎麽用?TypeScript isFakeCaretTarget使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isFakeCaretTarget函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getClientRects
const closestCaret = (root: HTMLElement, clientX: number, clientY: number): CaretInfo => {
let closestNodeRect;
const contentEditableFalseNodeRects = getClientRects(getFakeCaretTargets(root));
const targetNodeRects = Arr.filter(contentEditableFalseNodeRects, (rect) => clientY >= rect.top && clientY <= rect.bottom);
closestNodeRect = findClosestClientRect(targetNodeRects, clientX);
if (closestNodeRect) {
closestNodeRect = findClosestClientRect(findLineNodeRects(root, closestNodeRect), clientX);
if (closestNodeRect && isFakeCaretTarget(closestNodeRect.node)) {
return caretInfo(closestNodeRect, clientX);
}
}
return null;
};
示例2: before
const normalizeRange = (direction: number, root: Node, range: Range): Range => {
let node, container, offset, location;
const leanLeft = Fun.curry(lean, true, root);
const leanRight = Fun.curry(lean, false, root);
container = range.startContainer;
offset = range.startOffset;
if (CaretContainer.isCaretContainerBlock(container)) {
if (!isElement(container)) {
container = container.parentNode;
}
location = container.getAttribute('data-mce-caret');
if (location === 'before') {
node = container.nextSibling;
if (isFakeCaretTarget(node)) {
return before(node);
}
}
if (location === 'after') {
node = container.previousSibling;
if (isFakeCaretTarget(node)) {
return after(node);
}
}
}
if (!range.collapsed) {
return range;
}
if (NodeType.isText(container)) {
if (isCaretContainer(container)) {
if (direction === 1) {
node = leanRight(container);
if (node) {
return before(node);
}
node = leanLeft(container);
if (node) {
return after(node);
}
}
if (direction === -1) {
node = leanLeft(container);
if (node) {
return after(node);
}
node = leanRight(container);
if (node) {
return before(node);
}
}
return range;
}
if (CaretContainer.endsWithCaretContainer(container) && offset >= container.data.length - 1) {
if (direction === 1) {
node = leanRight(container);
if (node) {
return before(node);
}
}
return range;
}
if (CaretContainer.startsWithCaretContainer(container) && offset <= 1) {
if (direction === -1) {
node = leanLeft(container);
if (node) {
return after(node);
}
}
return range;
}
if (offset === container.data.length) {
node = leanRight(container);
if (node) {
return before(node);
}
return range;
}
if (offset === 0) {
node = leanLeft(container);
if (node) {
return after(node);
}
//.........這裏部分代碼省略.........
示例3: function
suite.test('isFakeCaretTarget', function () {
LegacyUnit.equal(false, isFakeCaretTarget(Element.fromHtml('<p></p>').dom()), 'Should not need a fake caret');
LegacyUnit.equal(true, isFakeCaretTarget(Element.fromHtml('<p contenteditable="false"></p>').dom()), 'Should always need a fake caret');
LegacyUnit.equal(isFakeCaretTableBrowser(), isFakeCaretTarget(Element.fromHtml('<table></table>').dom()), 'Should on some browsers need a fake caret');
});