本文整理汇总了TypeScript中tinymce/core/api/Editor.Editor.getWin方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Editor.getWin方法的具体用法?TypeScript Editor.getWin怎么用?TypeScript Editor.getWin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinymce/core/api/Editor.Editor
的用法示例。
在下文中一共展示了Editor.getWin方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const scrollBy = (editor: Editor, dx: number, dy: number) => {
if (editor.inline) {
editor.getBody().scrollLeft += dx;
editor.getBody().scrollTop += dy;
} else {
editor.getWin().scrollBy(dx, dy);
}
};
示例2: function
const scrollElementIntoView = function (editor: Editor, elm: HTMLElement, alignToTop: boolean) {
let y, viewPort;
const dom = editor.dom;
const root = dom.getRoot();
let viewPortY, viewPortH, offsetY = 0;
if (fireScrollIntoViewEvent(editor, elm, alignToTop)) {
return;
}
if (!NodeType.isElement(elm)) {
return;
}
if (alignToTop === false) {
offsetY = elm.offsetHeight;
}
if (root.nodeName !== 'BODY') {
const scrollContainer = editor.selection.getScrollContainer();
if (scrollContainer) {
y = getPos(elm).y - getPos(scrollContainer).y + offsetY;
viewPortH = scrollContainer.clientHeight;
viewPortY = scrollContainer.scrollTop;
if (y < viewPortY || y + 25 > viewPortY + viewPortH) {
scrollContainer.scrollTop = y < viewPortY ? y : y - viewPortH + 25;
}
return;
}
}
viewPort = dom.getViewPort(editor.getWin());
y = dom.getPos(elm).y + offsetY;
viewPortY = viewPort.y;
viewPortH = viewPort.h;
if (y < viewPort.y || y + 25 > viewPortY + viewPortH) {
editor.getWin().scrollTo(0, y < viewPortY ? y : y - viewPortH + 25);
}
};
示例3: getContentEditableHost
const focusEditor = (editor: Editor) => {
const selection: Selection = editor.selection, contentEditable = editor.settings.content_editable;
const body = editor.getBody();
let rng = selection.getRng();
editor.quirks.refreshContentEditable();
// Move focus to contentEditable=true child if needed
const contentEditableHost = getContentEditableHost(editor, selection.getNode());
if (editor.$.contains(body, contentEditableHost)) {
focusBody(contentEditableHost);
normalizeSelection(editor, rng);
activateEditor(editor);
return;
}
if (editor.bookmark !== undefined && hasFocus(editor) === false) {
SelectionBookmark.getRng(editor).each(function (bookmarkRng) {
editor.selection.setRng(bookmarkRng);
rng = bookmarkRng;
});
}
// Focus the window iframe
if (!contentEditable) {
// WebKit needs this call to fire focusin event properly see #5948
// But Opera pre Blink engine will produce an empty selection so skip Opera
if (!Env.opera) {
focusBody(body);
}
editor.getWin().focus();
}
// Focus the body as well since it's contentEditable
if (Env.gecko || contentEditable) {
focusBody(body);
normalizeSelection(editor, rng);
}
activateEditor(editor);
};
示例4: getCaretRect
const create = (editor: Editor, lastRngCell, pasteBinDefaultContent: string) => {
const dom = editor.dom, body = editor.getBody();
const viewport = editor.dom.getViewPort(editor.getWin());
let scrollTop = viewport.y, top = 20;
let pasteBinElm;
let scrollContainer;
lastRngCell.set(editor.selection.getRng());
const lastRng = lastRngCell.get();
if (editor.inline) {
scrollContainer = editor.selection.getScrollContainer();
// Can't always rely on scrollTop returning a useful value.
// It returns 0 if the browser doesn't support scrollTop for the element or is non-scrollable
if (scrollContainer && scrollContainer.scrollTop > 0) {
scrollTop = scrollContainer.scrollTop;
}
}
/**
* Returns the rect of the current caret if the caret is in an empty block before a
* BR we insert a temporary invisible character that we get the rect this way we always get a proper rect.
*
* TODO: This might be useful in core.
*/
function getCaretRect(rng) {
let rects, textNode, node;
const container = rng.startContainer;
rects = rng.getClientRects();
if (rects.length) {
return rects[0];
}
if (!rng.collapsed || container.nodeType !== 1) {
return;
}
node = container.childNodes[lastRng.startOffset];
// Skip empty whitespace nodes
while (node && node.nodeType === 3 && !node.data.length) {
node = node.nextSibling;
}
if (!node) {
return;
}
// Check if the location is |<br>
// TODO: Might need to expand this to say |<table>
if (node.tagName === 'BR') {
textNode = dom.doc.createTextNode('\uFEFF');
node.parentNode.insertBefore(textNode, node);
rng = dom.createRng();
rng.setStartBefore(textNode);
rng.setEndAfter(textNode);
rects = rng.getClientRects();
dom.remove(textNode);
}
if (rects.length) {
return rects[0];
}
}
// Calculate top cordinate this is needed to avoid scrolling to top of document
// We want the paste bin to be as close to the caret as possible to avoid scrolling
if (lastRng.getClientRects) {
const rect = getCaretRect(lastRng);
if (rect) {
// Client rects gets us closes to the actual
// caret location in for example a wrapped paragraph block
top = scrollTop + (rect.top - dom.getPos(body).y);
} else {
top = scrollTop;
// Check if we can find a closer location by checking the range element
let container = lastRng.startContainer;
if (container) {
if (container.nodeType === 3 && container.parentNode !== body) {
container = container.parentNode;
}
if (container.nodeType === 1) {
top = dom.getPos(container, scrollContainer || body).y;
}
}
}
}
// Create a pastebin
pasteBinElm = editor.dom.add(editor.getBody(), 'div', {
'id': 'mcepastebin',
'contentEditable': true,
//.........这里部分代码省略.........
示例5: function
const initContentBody = function (editor: Editor, skipWrite?: boolean) {
const settings = editor.settings;
const targetElm = editor.getElement();
let doc = editor.getDoc(), body, contentCssText;
// Restore visibility on target element
if (!settings.inline) {
editor.getElement().style.visibility = editor.orgVisibility;
}
// Setup iframe body
if (!skipWrite && !settings.content_editable) {
doc.open();
doc.write(editor.iframeHTML);
doc.close();
}
if (settings.content_editable) {
editor.on('remove', function () {
const bodyEl = this.getBody();
DOM.removeClass(bodyEl, 'mce-content-body');
DOM.removeClass(bodyEl, 'mce-edit-focus');
DOM.setAttrib(bodyEl, 'contentEditable', null);
});
DOM.addClass(targetElm, 'mce-content-body');
editor.contentDocument = doc = settings.content_document || document;
editor.contentWindow = settings.content_window || window;
editor.bodyElement = targetElm;
// Prevent leak in IE
settings.content_document = settings.content_window = null;
// TODO: Fix this
settings.root_name = targetElm.nodeName.toLowerCase();
}
// It will not steal focus while setting contentEditable
body = editor.getBody();
body.disabled = true;
editor.readonly = settings.readonly;
if (!editor.readonly) {
if (editor.inline && DOM.getStyle(body, 'position', true) === 'static') {
body.style.position = 'relative';
}
body.contentEditable = editor.getParam('content_editable_state', true);
}
body.disabled = false;
editor.editorUpload = EditorUpload(editor);
editor.schema = Schema(settings);
editor.dom = DOMUtils(doc, {
keep_values: true,
url_converter: editor.convertURL,
url_converter_scope: editor,
hex_colors: settings.force_hex_style_colors,
class_filter: settings.class_filter,
update_styles: true,
root_element: editor.inline ? editor.getBody() : null,
collect: settings.content_editable,
schema: editor.schema,
contentCssCors: Settings.shouldUseContentCssCors(editor),
onSetAttrib (e) {
editor.fire('SetAttrib', e);
}
});
editor.parser = createParser(editor);
editor.serializer = Serializer(settings, editor);
editor.selection = Selection(editor.dom, editor.getWin(), editor.serializer, editor);
editor.annotator = Annotator(editor);
editor.formatter = Formatter(editor);
editor.undoManager = UndoManager(editor);
editor._nodeChangeDispatcher = new NodeChange(editor);
editor._selectionOverrides = SelectionOverrides(editor);
DetailsElement.setup(editor);
MultiClickSelection.setup(editor);
KeyboardOverrides.setup(editor);
ForceBlocks.setup(editor);
editor.fire('PreInit');
if (!settings.browser_spellcheck && !settings.gecko_spellcheck) {
doc.body.spellcheck = false; // Gecko
DOM.setAttrib(body, 'spellcheck', 'false');
}
editor.quirks = Quirks(editor);
editor.fire('PostRender');
if (settings.directionality) {
body.dir = settings.directionality;
}
if (settings.nowrap) {
//.........这里部分代码省略.........