本文整理匯總了TypeScript中@ephox/agar.Chain.injectThunked方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Chain.injectThunked方法的具體用法?TypeScript Chain.injectThunked怎麽用?TypeScript Chain.injectThunked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/agar.Chain
的用法示例。
在下文中一共展示了Chain.injectThunked方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
UnitTest.asynctest('browser.tinymce.core.focus.CefFocusTest', function (success, failure) {
Theme();
const sCreateInlineEditor = function (html) {
return Chain.asStep({}, [
McEditor.cFromHtml(html, {
inline: true,
base_url: '/project/tinymce/js/tinymce'
})
]);
};
const sAssertSelection = function (editorIndex, startPath, startOffset, endPath, endOffset) {
return Step.sync(function () {
const editor = EditorManager.get(editorIndex);
const startContainer = Hierarchy.follow(Element.fromDom(editor.getBody()), startPath).getOrDie();
const endContainer = Hierarchy.follow(Element.fromDom(editor.getBody()), endPath).getOrDie();
const rng = editor.selection.getRng();
Assertions.assertDomEq('Should be expected from start container', startContainer, Element.fromDom(rng.startContainer));
Assertions.assertEq('Should be expected from start offset', startOffset, rng.startOffset);
Assertions.assertDomEq('Should be expected end container', endContainer, Element.fromDom(rng.endContainer));
Assertions.assertEq('Should be expected end offset', endOffset, rng.endOffset);
});
};
const sRemoveEditors = Chain.asStep({}, [
Chain.injectThunked(() => EditorManager.get(1)),
McEditor.cRemove,
Chain.injectThunked(() => EditorManager.get(0)),
McEditor.cRemove
]);
Pipeline.async({}, [
Logger.t('Focus editors', GeneralSteps.sequence([
sCreateInlineEditor('<div class="tinymce"><p contenteditable="false">a</p></div>'),
sCreateInlineEditor('<div class="tinymce"><p contenteditable="false">b</p></div>'),
Step.sync(function () {
EditorManager.get(0).getBody().focus();
EditorManager.get(1).getBody().focus();
}),
Waiter.sTryUntil('Wait for selection to move', sAssertSelection(1, [0], 0, [0], 0), 10, 3000),
Step.sync(function () {
const caretElm0 = EditorManager.get(0).getBody().querySelector('[data-mce-caret]');
const caretElm1 = EditorManager.get(1).getBody().querySelector('[data-mce-caret]');
Assertions.assertEq('Should not be a caret element present editor 0', false, !!caretElm0);
Assertions.assertEq('Should be a caret element present editor 1', true, !!caretElm1);
}),
sRemoveEditors
]))
], function () {
success();
}, failure);
});
示例2: function
const sTestIsXYInContentArea = function (editor, deltaX, deltaY) {
const dx1 = - 25 - deltaX;
const dy1 = -25 - deltaY;
const dx2 = - 5 - deltaX;
const dy2 = - 5 - deltaY;
return Step.label('Check points relative to deltaX=' + deltaX + ' deltaY=' + deltaY, Chain.asStep({}, [
Chain.fromParent(
Chain.label(
'Calculate bounding rectangle',
Chain.injectThunked(() => getIframeClientRect(editor))
), [
Chain.label(
'Check 〈bottom right〉 + (' + dx1 + ', ' + dy1 + ') is inside editor',
Chain.op((rect) => Assertions.assertEq(
'Should be inside the area since the scrollbars are excluded',
true,
EditorView.isXYInContentArea(editor, rect.width + dx1, rect.height + dy1)
))
),
Chain.label(
'Check 〈bottom right〉 + (' + dx2 + ', ' + dy2 + ') is ' + (hiddenScrollbar ? 'inside' : 'outside') + ' editor',
Chain.op((rect) => Assertions.assertEq(
(hiddenScrollbar ?
'Should be inside the area since the scrollbars are hidden' :
'Should be outside the area since the cordinate is on the scrollbars'),
hiddenScrollbar,
EditorView.isXYInContentArea(editor, rect.width + dx2, rect.height + dy2)
))
)
]
)
]));
};