本文整理汇总了TypeScript中tinymce/core/api/dom/DOMUtils.DOMUtils.getParent方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DOMUtils.getParent方法的具体用法?TypeScript DOMUtils.getParent怎么用?TypeScript DOMUtils.getParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinymce/core/api/dom/DOMUtils.DOMUtils
的用法示例。
在下文中一共展示了DOMUtils.getParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: function
const moveStart = function (dom: DOMUtils, selection: Selection, rng: Range) {
const offset = rng.startOffset;
let container = rng.startContainer, walker, node, nodes;
if (rng.startContainer === rng.endContainer) {
if (isInlineBlock(rng.startContainer.childNodes[rng.startOffset])) {
return;
}
}
// Move startContainer/startOffset in to a suitable node
if (container.nodeType === 1) {
nodes = container.childNodes;
if (offset < nodes.length) {
container = nodes[offset];
walker = new TreeWalker(container, dom.getParent(container, dom.isBlock));
} else {
container = nodes[nodes.length - 1];
walker = new TreeWalker(container, dom.getParent(container, dom.isBlock));
walker.next(true);
}
for (node = walker.current(); node; node = walker.next()) {
if (node.nodeType === 3 && !isWhiteSpaceNode(node)) {
rng.setStart(node, 0);
selection.setRng(rng);
return;
}
}
}
};
示例3: TreeWalker
const hasBrBeforeAfter = (dom: DOMUtils, node: Node, left: boolean) => {
const walker = new TreeWalker(node, dom.getParent(node.parentNode, dom.isBlock) || dom.getRoot());
while ((node = walker[left ? 'prev' : 'next']())) {
if (NodeType.isBr(node)) {
return true;
}
}
};
示例4: function
const trimBrsFromTableCell = function (dom: DOMUtils, elm: DomElement) {
Option.from(dom.getParent(elm, 'td,th')).map(Element.fromDom).each(PaddingBr.trimBlockTrailingBr);
};
示例5: function
//.........这里部分代码省略.........
let failed;
// Try executing the native command
try {
execNativeCommand(command);
} catch (ex) {
// Command failed
failed = true;
}
// Chrome reports the paste command as supported however older IE:s will return false for cut/paste
if (command === 'paste' && !doc.queryCommandEnabled(command)) {
failed = true;
}
// Present alert message about clipboard access not being available
if (failed || !doc.queryCommandSupported(command)) {
let msg = editor.translate(
'Your browser doesn\'t support direct access to the clipboard. ' +
'Please use the Ctrl+X/C/V keyboard shortcuts instead.'
);
if (Env.mac) {
msg = msg.replace(/Ctrl\+/g, '\u2318+');
}
editor.notificationManager.open({ text: msg, type: 'error' });
}
},
// Override unlink command
'unlink' () {
if (selection.isCollapsed()) {
const elm = editor.dom.getParent(editor.selection.getStart(), 'a');
if (elm) {
editor.dom.remove(elm, true);
}
return;
}
formatter.remove('link');
},
// Override justify commands to use the text formatter engine
'JustifyLeft,JustifyCenter,JustifyRight,JustifyFull,JustifyNone' (command) {
let align = command.substring(7);
if (align === 'full') {
align = 'justify';
}
// Remove all other alignments first
each('left,center,right,justify'.split(','), function (name) {
if (align !== name) {
formatter.remove('align' + name);
}
});
if (align !== 'none') {
toggleFormat('align' + align);
}
},
// Override list commands to fix WebKit bug
'InsertUnorderedList,InsertOrderedList' (command) {