本文整理汇总了TypeScript中@ephox/katamari.Fun类的典型用法代码示例。如果您正苦于以下问题:TypeScript Fun类的具体用法?TypeScript Fun怎么用?TypeScript Fun使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fun类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const toRect = function (rect) {
return {
left: Fun.constant(rect.left),
top: Fun.constant(rect.top),
right: Fun.constant(rect.right),
bottom: Fun.constant(rect.bottom),
width: Fun.constant(rect.width),
height: Fun.constant(rect.height)
};
};
示例2: function
return Future.nu(function (callback) {
const getCurrent = Fun.curry(getScrollTop, element);
const update = function (newScroll) {
element.dom().scrollTop = newScroll;
Css.set(element, 'top', (getTop(element) + ANIMATION_STEP) + 'px');
};
const finish = function (/* dest */) {
element.dom().scrollTop = destination;
Css.set(element, 'top', finalTop + 'px');
callback(destination);
};
animator.animate(getCurrent, destination, ANIMATION_STEP, update, finish, ANIMATION_RATE);
});
示例3:
const insertSpaceOrNbspAtSelection = (editor: Editor): boolean => {
const pos = CaretPosition.fromRangeStart(editor.selection.getRng());
const root = Element.fromDom(editor.getBody());
if (editor.selection.isCollapsed()) {
const isInlineTarget = Fun.curry(InlineUtils.isInlineTarget, editor);
const caretPosition = CaretPosition.fromRangeStart(editor.selection.getRng());
return BoundaryLocation.readLocation(isInlineTarget, editor.getBody(), caretPosition)
.bind(locationToCaretPosition(root))
.bind(insertInlineBoundarySpaceOrNbsp(root, pos))
.exists(setSelection(editor));
} else {
return false;
}
};
示例4: function
const sTestScenario = function (rawScenario) {
const scenario = ValueSchema.asRawOrDie('Checking scenario', ValueSchema.objOf([
FieldSchema.strict('label'),
FieldSchema.defaulted('content', ''),
FieldSchema.defaulted('node', Element.fromText('')),
FieldSchema.strictObjOf('fields', [
FieldSchema.option('url'),
FieldSchema.option('text'),
FieldSchema.option('title'),
FieldSchema.option('target')
]),
FieldSchema.strict('expected'),
FieldSchema.defaulted('beforeExecute', Step.pass),
FieldSchema.defaulted('mutations', Fun.constant(Step.pass))
]), rawScenario);
return Logger.t(
scenario.label,
GeneralSteps.sequence([
tEditor.sPrepareState(scenario.node.dom(), scenario.content),
sClickLink,
TestUi.sSetFieldOptValue(scenario.fields.url),
sClickNext,
sAssertTextFocused,
TestUi.sSetFieldOptValue(scenario.fields.text),
sClickNext,
sAssertTitleFocused,
TestUi.sSetFieldOptValue(scenario.fields.title),
sClickNext,
sAssertTargetFocused,
TestUi.sSetFieldOptValue(scenario.fields.target),
sClickPrev,
sAssertTitleFocused,
sClickPrev,
sAssertTextFocused,
sClickPrev,
sAssertUrlFocused,
scenario.beforeExecute,
Keyboard.sKeydown(doc, Keys.enter(), { }),
tEditor.sAssertEq('Checking insert content', scenario.expected),
scenario.mutations(scenario.node),
tEditor.sClear
])
);
};
示例5: isTreeNode
const setContent = (editor: Editor, content: Content, args: SetContentArgs = {}): Content => {
args.format = args.format ? args.format : defaultFormat;
args.set = true;
args.content = isTreeNode(content) ? '' : content;
if (!isTreeNode(content) && !args.no_events) {
editor.fire('BeforeSetContent', args);
content = args.content;
}
return Option.from(editor.getBody())
.fold(
Fun.constant(content),
(body) => isTreeNode(content) ? setContentTree(editor, body, content, args) : setContentString(editor, body, content, args)
);
};
示例6: function
const findLocationTraverse = function (forward, isInlineTarget, rootNode, fromLocation, pos) {
const from = InlineUtils.normalizePosition(forward, pos);
const to = CaretFinder.fromPosition(forward, rootNode, from).map(Fun.curry(InlineUtils.normalizePosition, forward));
const location = to.fold(
function () {
return fromLocation.map(outside);
},
function (to) {
return readLocation(isInlineTarget, rootNode, to)
.map(Fun.curry(betweenInlines, forward, isInlineTarget, rootNode, from, to))
.filter(Fun.curry(skipNoMovement, fromLocation));
}
);
return location.filter(isValidLocation);
};
示例7:
const deriveReplacing = (spec, component: AlloyComponent) => {
if (component.hasConfigured(Representing)) {
/* TODO type this
[{
dom: {
tag: 'div',
classes: [ 'my-class' ],
innerHtml: text
}
} ... ];
*/
return {
updateButton: Fun.curry(Replacing.set, component)
};
}
};
示例8: function
export default function () {
const store = TestStore();
const editorState = {
start: Cell(null),
content: Cell('')
};
const sPrepareState = function (node, content) {
return Step.sync(function () {
editorState.start.set(node);
editorState.content.set(content);
});
};
const editor = {
selection: {
getStart: editorState.start.get,
getContent: editorState.content.get,
select: Fun.noop
},
insertContent (data) {
store.adder({ method: 'insertContent', data })();
},
execCommand (name, ui, args) {
store.adder({ method: 'execCommand', data: Objects.wrap(name, args) })();
},
dom: {
createHTML (tag, attributes, innerText) {
return { tag, attributes, innerText };
},
encode: Fun.identity
},
focus: Fun.noop
};
return {
editor: Fun.constant(editor),
adder: store.adder,
assertEq: store.assertEq,
sAssertEq: store.sAssertEq,
sClear: store.sClear,
sPrepareState
};
}
示例9: getWinFromFrame
return getWinFromFrame(frame).map(function (win) {
const html = Element.fromDom(doc.dom().documentElement);
const getCursorBox = editor.getCursorBox.getOrThunk(function () {
return function () {
return WindowSelection.get(win).bind(function (sel) {
return WindowSelection.getFirstRect(win, sel).orThunk(function () {
return tryFallbackBox(win);
});
});
};
});
const setSelection = editor.setSelection.getOrThunk(function () {
return function (start, soffset, finish, foffset) {
WindowSelection.setExact(win, start, soffset, finish, foffset);
};
});
const clearSelection = editor.clearSelection.getOrThunk(function () {
return function () {
WindowSelection.clear(win);
};
});
return {
body: Fun.constant(body),
doc: Fun.constant(doc),
win: Fun.constant(win),
html: Fun.constant(html),
getSelection: Fun.curry(getSelectionFromFrame, frame),
setSelection,
clearSelection,
frame: Fun.constant(frame),
onKeyup: getOrListen(editor, doc, 'onKeyup', 'keyup'),
onNodeChanged: getOrListen(editor, doc, 'onNodeChanged', 'selectionchange'),
onDomChanged: editor.onDomChanged, // consider defaulting with MutationObserver
onScrollToCursor: editor.onScrollToCursor,
onScrollToElement: editor.onScrollToElement,
onToReading: editor.onToReading,
onToEditing: editor.onToEditing,
onToolbarScrollStart: editor.onToolbarScrollStart,
onTouchContent: editor.onTouchContent,
onTapContent: editor.onTapContent,
onTouchToolstrip: editor.onTouchToolstrip,
getCursorBox
};
});