本文整理汇总了TypeScript中@ephox/dom-globals.Element类的典型用法代码示例。如果您正苦于以下问题:TypeScript Element类的具体用法?TypeScript Element怎么用?TypeScript Element使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Element类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const insertAt = function (elm: Element, html: string, index: number) {
const fragment = createFragment(html);
if (elm.hasChildNodes() && index < elm.childNodes.length) {
const target = elm.childNodes[index];
target.parentNode.insertBefore(fragment, target);
} else {
elm.appendChild(fragment);
}
};
示例2: trimBogusBr
const showCaretContainerBlock = (caretContainer: Element): Element => {
if (caretContainer && caretContainer.hasAttribute('data-mce-caret')) {
trimBogusBr(caretContainer);
caretContainer.removeAttribute('data-mce-caret');
caretContainer.removeAttribute('data-mce-bogus');
caretContainer.removeAttribute('style');
caretContainer.removeAttribute('_moz_abspos');
return caretContainer;
}
return null;
};
示例3:
const trimBogusBr = (elm: Element): void => {
const brs = elm.getElementsByTagName('br');
const lastBr = brs[brs.length - 1];
if (NodeType.isBogus(lastBr)) {
lastBr.parentNode.removeChild(lastBr);
}
};
示例4: 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;
};
示例5: function
Delay.setEditorTimeout(self, function () {
const focusedEditor = editorManager.focusedEditor;
// Still the same editor the blur was outside any editor UI
if (!isUIElement(self, getActiveElement()) && focusedEditor === self) {
self.fire('blur', { focusedEditor: null });
editorManager.focusedEditor = null;
}
});
示例6: function
const validInsertion = function (editor: Editor, value: string, parentNode: DomElement) {
// Should never insert content into bogus elements, since these can
// be resize handles or similar
if (parentNode.getAttribute('data-mce-bogus') === 'all') {
parentNode.parentNode.insertBefore(editor.dom.createFragment(value), parentNode);
} else {
// Check if parent is empty or only has one BR element then set the innerHTML of that parent
const node = parentNode.firstChild;
const node2 = parentNode.lastChild;
if (!node || (node === node2 && node.nodeName === 'BR')) {///
editor.dom.setHTML(parentNode, value);
} else {
selectionSetContent(editor, value);
}
}
};
示例7: function
const preProcess = function (editor: Editor, node: Element, args) {
let impl, doc, oldDoc;
const dom = editor.dom;
node = node.cloneNode(true) as Element;
// Nodes needs to be attached to something in WebKit/Opera
// This fix will make DOM ranges and make Sizzle happy!
impl = document.implementation;
if (impl.createHTMLDocument) {
// Create an empty HTML document
doc = impl.createHTMLDocument('');
// Add the element or it's children if it's a body element to the new document
Tools.each(node.nodeName === 'BODY' ? node.childNodes : [node], function (node) {
doc.body.appendChild(doc.importNode(node, true));
});
// Grab first child or body element for serialization
if (node.nodeName !== 'BODY') {
node = doc.body.firstChild;
} else {
node = doc.body;
}
// set the new document in DOMUtils so createElement etc works
oldDoc = dom.doc;
dom.doc = doc;
}
Events.firePreProcess(editor, Merger.merge(args, { node }));
if (oldDoc) {
dom.doc = oldDoc;
}
return node;
};
示例8: function
const create = (editor: Editor, lastRngCell, pasteBinDefaultContent: string) => {
const dom = editor.dom, body = editor.getBody();
let pasteBinElm;
lastRngCell.set(editor.selection.getRng());
// Create a pastebin
pasteBinElm = editor.dom.add(getPasteBinParent(editor), 'div', {
'id': 'mcepastebin',
'class': 'mce-pastebin',
'contentEditable': true,
'data-mce-bogus': 'all',
'style': 'position: fixed; top: 50%; width: 10px; height: 10px; overflow: hidden; opacity: 0'
}, pasteBinDefaultContent);
// Move paste bin out of sight since the controlSelection rect gets displayed otherwise on IE and Gecko
if (Env.ie || Env.gecko) {
dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) === 'rtl' ? 0xFFFF : -0xFFFF);
}
// Prevent focus events from bubbeling fixed FocusManager issues
dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function (e) {
e.stopPropagation();
});
delegatePasteEvents(editor, pasteBinElm, pasteBinDefaultContent);
pasteBinElm.focus();
editor.selection.select(pasteBinElm, true);
};
示例9: CaretWalker
const exitPreBlock = (editor, direction: HDirection, range: Range): void => {
let pre, caretPos, newBlock;
const caretWalker = CaretWalker(editor.getBody());
const getNextVisualCaretPosition = Fun.curry(getVisualCaretPosition, caretWalker.next);
const getPrevVisualCaretPosition = Fun.curry(getVisualCaretPosition, caretWalker.prev);
if (range.collapsed && editor.settings.forced_root_block) {
pre = editor.dom.getParent(range.startContainer, 'PRE');
if (!pre) {
return;
}
if (direction === 1) {
caretPos = getNextVisualCaretPosition(CaretPosition.fromRangeStart(range));
} else {
caretPos = getPrevVisualCaretPosition(CaretPosition.fromRangeStart(range));
}
if (!caretPos) {
newBlock = createTextBlock(editor);
if (direction === 1) {
editor.$(pre).after(newBlock);
} else {
editor.$(pre).before(newBlock);
}
editor.selection.select(newBlock, true);
editor.selection.collapse();
}
}
};