本文整理汇总了TypeScript中@ephox/agar.Keyboard.sKeyup方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Keyboard.sKeyup方法的具体用法?TypeScript Keyboard.sKeyup怎么用?TypeScript Keyboard.sKeyup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/agar.Keyboard
的用法示例。
在下文中一共展示了Keyboard.sKeyup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const sTypeChar = function (doc, chr) {
return GeneralSteps.sequence([
Keyboard.sKeydown(doc, chr, {}),
Keyboard.sKeypress(doc, chr, {}),
sInsertCharAtSelection(doc, chr),
Keyboard.sKeyup(doc, chr, {})
]);
};
示例2: TinyApis
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
const tinyActions = TinyActions(editor);
let count;
// hijack editor.selection.normalize() to count how many times it will be invoked
const backupNormalize = editor.selection.normalize;
const normalize = function () {
count = count === undefined ? 1 : count + 1;
backupNormalize.apply(this, arguments);
};
editor.selection.normalize = normalize;
const sResetNormalizeCounter = function () {
return Step.sync(function () {
count = 0;
});
};
const sAssertNormalizeCounter = function (expected) {
return Step.sync(function () {
Assertions.assertEq('checking normalization counter', expected, count);
});
};
const sClickBody = function (editor) {
return Step.sync(function () {
const target = editor.getBody();
editor.fire('mousedown', { target });
editor.fire('mouseup', { target });
editor.fire('click', { target });
});
};
Pipeline.async({}, [
tinyApis.sFocus,
Logger.t('Test normalization for floated images', GeneralSteps.sequence([
tinyApis.sSetContent('<p>a<img src="about:blank" style="float: right"></p>'),
tinyApis.sSetSelection([0], 1, [0], 2),
Step.sync(function () {
const selection = editor.selection.getSel();
Assertions.assertEq('Anchor node should be the paragraph not the text node', 'P', selection.anchorNode.nodeName);
Assertions.assertEq('Anchor offset should be the element index', 1, selection.anchorOffset);
})
])),
Logger.t('Normalize on key events when range is collapsed', GeneralSteps.sequence([
tinyApis.sSetContent('<p>a</p><p>b</p>'),
tinyApis.sSetSelection([], 1, [], 1),
tinyActions.sContentKeystroke(Keys.escape(), {}),
tinyApis.sAssertSelection([1, 0], 0, [1, 0], 0)
])),
Logger.t('Normalize on mouse events when range is expanded', GeneralSteps.sequence([
tinyApis.sSetContent('<p>a</p><p>b</p>'),
tinyApis.sSetSelection([], 0, [], 1),
sClickBody(editor),
tinyApis.sAssertSelection([0, 0], 0, [0, 0], 1)
])),
Logger.t('Normalize on mouse events when range is collapsed', GeneralSteps.sequence([
tinyApis.sSetContent('<p>a</p><p>b</p>'),
tinyApis.sSetSelection([], 1, [], 1),
sClickBody(editor),
tinyApis.sAssertSelection([1, 0], 0, [1, 0], 0)
])),
Logger.t('Normalization during operations with modifier keys, should run only once in the end when user releases modifier key.', GeneralSteps.sequence([
sResetNormalizeCounter(),
tinyApis.sSetContent('<p><b>a</b><i>a</i></p>'),
tinyApis.sSetSelection([0, 0, 0], 0, [0, 0], 0),
Keyboard.sKeyup(Element.fromDom(editor.getDoc()), Keys.left(), { shift: true }),
sAssertNormalizeCounter(0),
Keyboard.sKeyup(Element.fromDom(editor.getDoc()), 17, {}), // single ctrl
sAssertNormalizeCounter(1),
tinyApis.sAssertSelection([0, 0], 0, [0, 0], 0)
]))
], onSuccess, onFailure);
}, {
示例3: function
const sKeyUp = function (editor, key) {
const iDoc = Element.fromDom(editor.getDoc());
return Keyboard.sKeyup(iDoc, key, {});
};