本文整理汇总了TypeScript中@ephox/agar.Step.stateful方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Step.stateful方法的具体用法?TypeScript Step.stateful怎么用?TypeScript Step.stateful使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/agar.Step
的用法示例。
在下文中一共展示了Step.stateful方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const mTeardownKeyLogger = function (body, expected) {
return Step.stateful(function (state, next, die) {
Assertions.assertEq('Checking key log outside context (on teardown)', expected, state.log);
state.onKeydown.unbind();
next({});
});
};
示例2: function
const mAssertSetSelectionEventArgs = function (editor, expectedForward) {
return Step.stateful(function (value: any, next, die) {
Assertions.assertEq('Should be expected forward flag', expectedForward, value.eventArgs.get().forward);
assertSelectAllRange(editor, value.eventArgs.get().range);
next(value);
});
};
示例3: function
const mShowKeyboard = function (selector, index) {
const keyboardHeight = 200;
return Step.stateful(function (value, next, die) {
const pageBody = iframe.dom().contentWindow.document.body;
const editorBody = pageBody.querySelector('iframe').contentWindow.document.body;
const target: any = Option.from(editorBody.querySelectorAll(selector)[index]).map(Element.fromDom).getOrDie('no index ' + index + ' for selector: ' + selector);
WindowSelection.setExact(editorBody.ownerDocument.defaultView, target, 0, target, 0);
const socket = pageBody.querySelector('.tinymce-mobile-editor-socket');
socket.scrollTop = target.dom().getBoundingClientRect().top - 100 - keyboardHeight;
pageBody.style.setProperty('margin-bottom', '2000px');
pageBody.ownerDocument.defaultView.scrollTo(0, keyboardHeight);
//
const cursorY = getCursorY(target);
const newValue = Merger.deepMerge(
value,
{
target,
cursorY
}
);
// tslint:disable-next-line:no-console
console.log('newValue', newValue);
next(newValue);
});
};
示例4: function
const mCreateRange = function (startPath, startOffset, endPath, endOffset) {
return Step.stateful(function (value, next, die) {
const startContainer = Hierarchy.follow(Element.fromDom(viewBlock.get()), startPath).getOrDie();
const endContainer = Hierarchy.follow(Element.fromDom(viewBlock.get()), endPath).getOrDie();
const rng = document.createRange();
rng.setStart(startContainer.dom(), startOffset);
rng.setEnd(endContainer.dom(), endOffset);
next(rng);
});
};
示例5: function
const mAssertScrollIntoViewEventInfo = function (editor, expectedElementSelector, expectedAlignToTop) {
return Step.stateful(function (value: any, next, die) {
const expectedTarget = Element.fromDom(editor.dom.select(expectedElementSelector)[0]);
const actualTarget = Element.fromDom(value.state.get().elm);
Assertions.assertDomEq('Target should be expected element', expectedTarget, actualTarget);
Assertions.assertEq('Align to top should be expected value', expectedAlignToTop, value.state.get().alignToTop);
editor.off('ScrollIntoView', value.handler);
next({});
});
};
示例6: TinyApis
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
Pipeline.async({}, [
tinyApis.sFocus,
Logger.t('SetSelectionRange event', GeneralSteps.sequence([
mBindEvent(editor, 'SetSelectionRange'),
tinyApis.sSetContent('<p>a</p>'),
sSetRng(editor, undefined),
mAssertSetSelectionEventArgs(editor, undefined),
sSetRng(editor, true),
mAssertSetSelectionEventArgs(editor, true),
sSetRng(editor, false),
mAssertSetSelectionEventArgs(editor, false),
mUnbindEvent(editor, 'SetSelectionRange')
])),
Logger.t('AfterSetSelectionRange event', GeneralSteps.sequence([
mBindEvent(editor, 'AfterSetSelectionRange'),
tinyApis.sSetContent('<p>a</p>'),
sSetRng(editor, undefined),
Step.stateful(function (value, next, die) {
Assertions.assertEq('', 'undefined', typeof value.eventArgs.get().forward);
next(value);
}),
sSetRng(editor, true),
mAssertSetSelectionEventArgs(editor, true),
sSetRng(editor, false),
mAssertSetSelectionEventArgs(editor, false),
mUnbindEvent(editor, 'AfterSetSelectionRange')
])),
Logger.t('GetSelectionRange event', GeneralSteps.sequence([
mBindEventMutator(editor, 'GetSelectionRange', selectAll),
tinyApis.sSetContent('<p>a</p>'),
tinyApis.sSetCursor([0, 0], 0),
sGetRng(editor),
Step.stateful(function (value, next, die) {
assertSelectAllRange(editor, editor.selection.getRng());
assertSelectAllRange(editor, value.eventArgs.get().range);
next(value);
}),
mUnbindEvent(editor, 'GetSelectionRange')
]))
], onSuccess, onFailure);
}, {