本文整理匯總了TypeScript中tinymce/core/caret/CaretPosition.CaretPosition函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript CaretPosition函數的具體用法?TypeScript CaretPosition怎麽用?TypeScript CaretPosition使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CaretPosition函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: TreeWalker
const findTextNodeRelative = (dom: DOMUtils, isAfterNode: boolean, collapsed: boolean, left: boolean, startNode: Node): Option<CaretPosition> => {
let walker, lastInlineElement, parentBlockContainer;
const body = dom.getRoot();
let node;
const nonEmptyElementsMap = dom.schema.getNonEmptyElements();
parentBlockContainer = dom.getParent(startNode.parentNode, dom.isBlock) || body;
// Lean left before the BR element if it's the only BR within a block element. Gecko bug: #6680
// This: <p><br>|</p> becomes <p>|<br></p>
if (left && NodeType.isBr(startNode) && isAfterNode && dom.isEmpty(parentBlockContainer)) {
return Option.some(CaretPosition(startNode.parentNode, dom.nodeIndex(startNode)));
}
// Walk left until we hit a text node we can move to or a block/br/img
walker = new TreeWalker(startNode, parentBlockContainer);
while ((node = walker[left ? 'prev' : 'next']())) {
// Break if we hit a non content editable node
if (dom.getContentEditableParent(node) === 'false' || isCeFalseCaretContainer(node, body)) {
return Option.none();
}
// Found text node that has a length
if (NodeType.isText(node) && node.nodeValue.length > 0) {
if (hasParentWithName(node, body, 'A') === false) {
return Option.some(CaretPosition(node, left ? node.nodeValue.length : 0));
}
return Option.none();
}
// Break if we find a block or a BR/IMG/INPUT etc
if (dom.isBlock(node) || nonEmptyElementsMap[node.nodeName.toLowerCase()]) {
return Option.none();
}
lastInlineElement = node;
}
// Only fetch the last inline element when in caret mode for now
if (collapsed && lastInlineElement) {
return Option.some(CaretPosition(lastInlineElement, 0));
}
return Option.none();
};
示例2: CaretPosition
return Chain.mapper(function (scope: any) {
const container = Hierarchy.follow(Element.fromDom(scope.get()), path).getOrDie();
const pos = CaretPosition(container.dom(), offset);
return getPositionsBelow(scope.get(), pos);
});
示例3: CaretPosition
return Chain.mapper(function (viewBlock) {
const table = SelectorFind.descendant(Element.fromDom(viewBlock.get()), 'table').getOrDie('Could not find table').dom();
const container = Hierarchy.follow(Element.fromDom(viewBlock.get()), path).getOrDie();
const pos = CaretPosition(container.dom(), offset);
return findClosestPositionInBelowCell(table, pos);
});