本文整理汇总了TypeScript中tinymce/core/api/dom/DOMUtils.DOMUtils.isBlock方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DOMUtils.isBlock方法的具体用法?TypeScript DOMUtils.isBlock怎么用?TypeScript DOMUtils.isBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinymce/core/api/dom/DOMUtils.DOMUtils
的用法示例。
在下文中一共展示了DOMUtils.isBlock方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getStart
const getSelectedBlocks = (dom: DOMUtils, rng: Range, startElm?: Element, endElm?: Element): Element[] => {
let node, root;
const selectedBlocks = [];
root = dom.getRoot();
startElm = dom.getParent(startElm || getStart(root, rng, rng.collapsed), dom.isBlock) as Element;
endElm = dom.getParent(endElm || getEnd(root, rng, rng.collapsed), dom.isBlock) as Element;
if (startElm && startElm !== root) {
selectedBlocks.push(startElm);
}
if (startElm && endElm && startElm !== endElm) {
node = startElm;
const walker = new TreeWalker(startElm, root);
while ((node = walker.next()) && node !== endElm) {
if (dom.isBlock(node)) {
selectedBlocks.push(node);
}
}
}
if (endElm && startElm !== endElm && endElm !== root) {
selectedBlocks.push(endElm);
}
return selectedBlocks;
};
示例2:
const addBogus = (dom: DOMUtils, node: HTMLElement) => {
// Adds a bogus BR element for empty block elements
if (dom.isBlock(node) && !node.innerHTML && !Env.ie) {
node.innerHTML = '<br data-mce-bogus="1" />';
}
return node;
};
示例3: 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();
};