本文整理汇总了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();
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:46,代码来源:NormalizeRange.ts
示例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);
});
开发者ID:tinymce,项目名称:tinymce,代码行数:5,代码来源:LineReaderTest.ts
示例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);
});
开发者ID:abstask,项目名称:tinymce,代码行数:6,代码来源:TableCellsTest.ts
注:本文中的tinymce/core/caret/CaretPosition.CaretPosition函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论