本文整理汇总了TypeScript中tinymce/core/api/Editor.getDoc函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getDoc函数的具体用法?TypeScript getDoc怎么用?TypeScript getDoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDoc函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: Cell
const setupEvents = (editor: Editor) => {
const contentWindow = editor.getWin();
const initialDocEle = editor.getDoc().documentElement;
const lastWindowDimensions = Cell(Position(contentWindow.innerWidth, contentWindow.innerHeight));
const lastDocumentDimensions = Cell(Position(initialDocEle.offsetWidth, initialDocEle.offsetHeight));
const resize = () => {
// Don't use the initial doc ele, as there's a small chance it may have changed
const docEle = editor.getDoc().documentElement;
// Check if the window or document dimensions have changed and if so then trigger a content resize event
const outer = lastWindowDimensions.get();
const inner = lastDocumentDimensions.get();
if (outer.left() !== contentWindow.innerWidth || outer.top() !== contentWindow.innerHeight) {
lastWindowDimensions.set(Position(contentWindow.innerWidth, contentWindow.innerHeight));
Events.fireResizeContent(editor);
} else if (inner.left() !== docEle.offsetWidth || inner.top() !== docEle.offsetHeight) {
lastDocumentDimensions.set(Position(docEle.offsetWidth, docEle.offsetHeight));
Events.fireResizeContent(editor);
}
};
DOM.bind(contentWindow, 'resize', resize);
// Bind to async load events and trigger a content resize event if the size has changed
const elementLoad = DomEvent.capture(Element.fromDom(editor.getBody()), 'load', resize);
editor.on('remove', () => {
elementLoad.unbind();
DOM.unbind(contentWindow, 'resize', resize);
});
};
开发者ID:tinymce,项目名称:tinymce,代码行数:33,代码来源:Iframe.ts
示例2: function
editor.on('init', function (e) {
const model = generate();
const globallyUniqueSelectors = {};
const selectorFilter = compileFilter(Settings.getSelectorFilter(editor));
const groups = compileUserDefinedGroups(Settings.getCssGroups(editor));
const processSelector = function (selector: string, group: StyleGroup) {
if (isUniqueSelector(editor, selector, group, globallyUniqueSelectors)) {
markUniqueSelector(editor, selector, group, globallyUniqueSelectors);
const format = convertSelectorToFormat(editor, editor.plugins.importcss, selector, group);
if (format) {
const formatName = format.name || DOMUtils.DOM.uniqueId();
editor.formatter.register(formatName, format);
// NOTE: itemDefaults has been removed as it was not supported by bridge and its concept
// is handled elsewhere.
return Tools.extend({}, {
title: format.title,
format: formatName
});
}
}
return null;
};
Tools.each(getSelectors(editor, editor.getDoc(), compileFilter(Settings.getFileFilter(editor))), function (selector: string) {
if (selector.indexOf('.mce-') === -1) {
if (!selectorFilter || selectorFilter(selector)) {
const selectorGroups = getGroupsBySelector(groups, selector);
if (selectorGroups.length > 0) {
Tools.each(selectorGroups, function (group) {
const menuItem = processSelector(selector, group);
if (menuItem) {
model.addItemToGroup(group.title, menuItem);
}
});
} else {
const menuItem = processSelector(selector, null);
if (menuItem) {
model.addItem(menuItem);
}
}
}
}
});
const items = model.toFormats();
editor.fire('addStyleModifications', {
items,
replace: !Settings.shouldAppend(editor)
});
});
开发者ID:tinymce,项目名称:tinymce,代码行数:56,代码来源:ImportCss.ts
示例3: getTableFromCell
getTableFromCell(cell).each((table) => {
const doc = Element.fromDom(editor.getDoc());
const generators = TableFill.paste(doc);
const targets = TableTargets.pasteRows(selections, table, cell, clonedRows, generators);
execute(table, targets).each((rng) => {
editor.selection.setRng(rng);
editor.focus();
cellSelection.clear(table);
});
});
开发者ID:tinymce,项目名称:tinymce,代码行数:10,代码来源:Commands.ts
示例4: function
editor.on('paste', function (e: EditorEvent<ClipboardEvent & { ieFake: boolean }>) {
// Getting content from the Clipboard can take some time
const clipboardTimer = new Date().getTime();
const clipboardContent = getClipboardContent(editor, e);
const clipboardDelay = new Date().getTime() - clipboardTimer;
const isKeyBoardPaste = (new Date().getTime() - keyboardPasteTimeStamp - clipboardDelay) < 1000;
const plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState;
let internal = hasContentType(clipboardContent, InternalHtml.internalHtmlMime());
keyboardPastePlainTextState = false;
if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) {
pasteBin.remove();
return;
}
if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) {
pasteBin.remove();
return;
}
// Not a keyboard paste prevent default paste and try to grab the clipboard contents using different APIs
if (!isKeyBoardPaste) {
e.preventDefault();
}
// Try IE only method if paste isn't a keyboard paste
if (Env.ie && (!isKeyBoardPaste || e.ieFake) && !hasContentType(clipboardContent, 'text/html')) {
pasteBin.create();
editor.dom.bind(pasteBin.getEl(), 'paste', function (e) {
e.stopPropagation();
});
editor.getDoc().execCommand('Paste', false, null);
clipboardContent['text/html'] = pasteBin.getHtml();
}
// If clipboard API has HTML then use that directly
if (hasContentType(clipboardContent, 'text/html')) {
e.preventDefault();
// if clipboard lacks internal mime type, inspect html for internal markings
if (!internal) {
internal = InternalHtml.isMarked(clipboardContent['text/html']);
}
insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
} else {
Delay.setEditorTimeout(editor, function () {
insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
}, 0);
}
});
开发者ID:tinymce,项目名称:tinymce,代码行数:55,代码来源:Clipboard.ts
示例5: if
const resize = () => {
// Don't use the initial doc ele, as there's a small chance it may have changed
const docEle = editor.getDoc().documentElement;
// Check if the window or document dimensions have changed and if so then trigger a content resize event
const outer = lastWindowDimensions.get();
const inner = lastDocumentDimensions.get();
if (outer.left() !== contentWindow.innerWidth || outer.top() !== contentWindow.innerHeight) {
lastWindowDimensions.set(Position(contentWindow.innerWidth, contentWindow.innerHeight));
Events.fireResizeContent(editor);
} else if (inner.left() !== docEle.offsetWidth || inner.top() !== docEle.offsetHeight) {
lastDocumentDimensions.set(Position(docEle.offsetWidth, docEle.offsetHeight));
Events.fireResizeContent(editor);
}
};
开发者ID:tinymce,项目名称:tinymce,代码行数:15,代码来源:Iframe.ts
示例6: function
TableLookup.table(cell).each((table) => {
const elements = Arr.filter(Elements.fromHtml(e.content), function (content) {
return Node.name(content) !== 'meta';
});
if (elements.length === 1 && Node.name(elements[0]) === 'table') {
e.preventDefault();
const doc = Element.fromDom(editor.getDoc());
const generators = TableFill.paste(doc);
const targets = TableTargets.paste(cell, elements[0], generators);
actions.pasteCells(table, targets).each(function (rng) {
editor.selection.setRng(rng);
editor.focus();
cellSelection.clear(table);
});
}
});
开发者ID:tinymce,项目名称:tinymce,代码行数:19,代码来源:Clipboard.ts
示例7: function
return function (table, target) {
Util.removeDataStyle(table);
const wire = lazyWire();
const doc = Element.fromDom(editor.getDoc());
const direction = TableDirection(Direction.directionAt);
const generators = TableFill.cellOperations(mutate, doc, cloneFormats);
return guard(table) ? operation(wire, table, target, generators, direction).bind(function (result) {
Arr.each(result.newRows(), function (row) {
fireNewRow(editor, row.dom());
});
Arr.each(result.newCells(), function (cell) {
fireNewCell(editor, cell.dom());
});
return result.cursor().map(function (cell) {
const rng = editor.dom.createRng();
rng.setStart(cell.dom(), 0);
rng.setEnd(cell.dom(), 0);
return rng;
});
}) : Option.none();
};
开发者ID:tinymce,项目名称:tinymce,代码行数:21,代码来源:TableActions.ts
示例8: function
const getCaretRangeFromEvent = function (editor: Editor, e: MouseEvent) {
return RangeUtils.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc());
};
开发者ID:tinymce,项目名称:tinymce,代码行数:3,代码来源:DragDrop.ts
示例9:
const sKeyboardBackspace = (editor: Editor) => {
return Keyboard.sKeystroke(Element.fromDom(editor.getDoc()), Keys.backspace(), {});
};
开发者ID:tinymce,项目名称:tinymce,代码行数:3,代码来源:TableDeleteTest.ts
示例10: toggleScrolling
const resize = (editor: Editor, oldSize: Cell<number>) => {
let deltaSize, resizeHeight, contentHeight;
const dom = editor.dom;
const doc = editor.getDoc();
if (!doc) {
return;
}
if (isFullscreen(editor)) {
toggleScrolling(editor, true);
return;
}
const docEle = doc.documentElement;
const resizeBottomMargin = Settings.getAutoResizeBottomMargin(editor);
resizeHeight = Settings.getAutoResizeMinHeight(editor);
// Calculate outer height of the doc element using CSS styles
const marginTop = parseCssValueToInt(dom, docEle, 'margin-top', true);
const marginBottom = parseCssValueToInt(dom, docEle, 'margin-bottom', true);
contentHeight = docEle.offsetHeight + marginTop + marginBottom + resizeBottomMargin;
// Make sure we have a valid height
// Note: Previously we had to do some fallbacks here for IE/Webkit, as the height calculation above didn't work.
// However using the latest supported browsers (IE 11 & Safari 11), the fallbacks were no longer needed and were removed.
if (contentHeight < 0) {
contentHeight = 0;
}
// Determine the size of the chroming (menubar, toolbar, etc...)
const containerHeight = editor.getContainer().offsetHeight;
const contentAreaHeight = editor.getContentAreaContainer().offsetHeight;
const chromeHeight = containerHeight - contentAreaHeight;
// Don't make it smaller than the minimum height
if (contentHeight + chromeHeight > Settings.getAutoResizeMinHeight(editor)) {
resizeHeight = contentHeight + chromeHeight;
}
// If a maximum height has been defined don't exceed this height
const maxHeight = Settings.getAutoResizeMaxHeight(editor);
if (maxHeight && resizeHeight > maxHeight) {
resizeHeight = maxHeight;
toggleScrolling(editor, true);
} else {
toggleScrolling(editor, false);
}
// Resize content element
if (resizeHeight !== oldSize.get()) {
deltaSize = resizeHeight - oldSize.get();
dom.setStyle(editor.getContainer(), 'height', resizeHeight + 'px');
oldSize.set(resizeHeight);
// WebKit doesn't decrease the size of the body element until the iframe gets resized
// So we need to continue to resize the iframe down until the size gets fixed
if (Env.webkit && deltaSize < 0) {
resize(editor, oldSize);
}
}
};
开发者ID:tinymce,项目名称:tinymce,代码行数:62,代码来源:Resize.ts
注:本文中的tinymce/core/api/Editor.getDoc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论