本文整理汇总了TypeScript中@ephox/mcagar.ApiChains.cSetCursor方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ApiChains.cSetCursor方法的具体用法?TypeScript ApiChains.cSetCursor怎么用?TypeScript ApiChains.cSetCursor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/mcagar.ApiChains
的用法示例。
在下文中一共展示了ApiChains.cSetCursor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
UnitTest.asynctest('browser.tinymce.core.keyboard.EnterKeyInlineTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
Theme();
const settings = {
skin_url: '/project/js/tinymce/skins/lightgray',
inline: true
};
Pipeline.async({}, [
Logger.t('Pressing shift+enter in brMode inside a h1 should insert a br', Chain.asStep({}, [
Editor.cFromHtml('<h1>ab</h1>', Merger.merge(settings, { forced_root_block: false })),
ApiChains.cFocus,
ApiChains.cSetCursor([0], 1),
ActionChains.cContentKeystroke(Keys.enter(), { shift: true }),
ApiChains.cAssertContent('a<br />b'),
Editor.cRemove
]))
], function () {
success();
}, failure);
});
示例2: table
TinyLoader.setup(function (editor, onSuccess, onFailure) {
Pipeline.async({}, [
Logger.t('FakeCaret before/after table', GeneralSteps.sequence(browser.isEdge() || browser.isFirefox() ? [
Logger.t('Move fake caret left before table', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 0),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.left()),
ApiChains.cAssertContentStructure(buildBody([ caretBefore(), table('1'), visualCaretBefore() ])),
ApiChains.cAssertSelection([0], 0, [0], 0)
])),
Logger.t('Move fake caret right after table', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.right()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretAfter(), visualCaretAfter() ])),
ApiChains.cAssertSelection([1], 0, [1], 0)
])),
Logger.t('Move fake caret right after table then right again before other table', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table><table><tbody><tr><td>2</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
ApiChains.cAssertContentStructure(buildBody([ table('1'), table('2') ])),
ActionChains.cContentKeystroke(Keys.right()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretAfter(), table('2'), visualCaretAfter() ])),
ApiChains.cAssertSelection([1], 0, [1], 0),
ActionChains.cContentKeystroke(Keys.right()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretBefore(), table('2'), visualCaretBefore() ])),
ApiChains.cAssertSelection([1], 0, [1], 0)
])),
Logger.t('Move fake caret left before table then left again after other table', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table><table><tbody><tr><td>2</td></tr></tbody></table>'),
ApiChains.cSetCursor([1, 0, 0, 0, 0], 0),
ApiChains.cAssertContentStructure(buildBody([ table('1'), table('2') ])),
ActionChains.cContentKeystroke(Keys.left()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretBefore(), table('2'), visualCaretBefore() ])),
ApiChains.cAssertSelection([1], 0, [1], 0),
ActionChains.cContentKeystroke(Keys.left()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretAfter(), table('2'), visualCaretAfter() ])),
ApiChains.cAssertSelection([1], 0, [1], 0)
])),
Logger.t('Move fake up for when table is first element', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 0),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.up()),
ApiChains.cAssertContentStructure(buildBody([ block, table('1') ])),
ApiChains.cAssertSelection([0], 0, [0], 0)
])),
Logger.t('Move fake down for when table is last element', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.down()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), block ])),
ApiChains.cAssertSelection([1], 0, [1], 0)
])),
Logger.t('Move fake up for when table is first element but not when caret is not as start', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.up()),
ApiChains.cAssertContentStructure(buildBody([ block, table('1') ])),
ApiChains.cAssertSelection([0], 0, [0], 0)
])),
Logger.t('Move fake down for when table is last element but not when caret is not as end', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 0),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.down()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), block ])),
ApiChains.cAssertSelection([1], 0, [1], 0)
]))] : []
)),
Logger.t('Table cell navigation', GeneralSteps.sequence([
Logger.t('Should move to the cell above the current cell on key up', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent(`
<table>
<tbody>
<tr><td>1</td><td>2</td></tr>
<tr><td>2</td><td>3</td></tr>
</tbody>
</table>
`),
ApiChains.cSetCursor([0, 0, 1, 1, 0], 0),
ActionChains.cContentKeystroke(Keys.up()),
ApiChains.cAssertSelection([0, 0, 0, 1, 0], 0, [0, 0, 0, 1, 0], 0)
])),
Logger.t('Should move to the cell below the current cell on key down', Chain.asStep(editor, [
ApiChains.cFocus,
//.........这里部分代码省略.........
示例3:
const cSetCursor = (path, offset) => NamedChain.read('editor', ApiChains.cSetCursor(path, offset));
示例4: Theme
UnitTest.asynctest('Remove context menu on focusout', (success, failure) => {
Theme();
const inputElmCell = Cell<Element>(null);
const sAddInput = Step.sync(() => {
const input = Element.fromTag('input');
inputElmCell.set(input);
Insert.append(Body.body(), input);
});
const sRemoveInput = Step.sync(() => {
Remove.remove(inputElmCell.get());
});
const cFocusInput = Chain.op(() => {
Focus.focus(inputElmCell.get());
});
const cWaitForContextmenuState = (state: boolean) => Chain.control(
Chain.op(() => {
const contextToolbar = UiFinder.findIn(Body.body(), '.tox-pop');
Assertions.assertEq('no context toolbar', state, contextToolbar.isValue());
}),
Guard.tryUntil('Wait for context menu to appear.', 100, 3000)
);
const html = '<p>One <a href="http://tiny.cloud">link</a> Two</p>';
const setup = (ed: Editor) => {
ed.ui.registry.addButton('alpha', {
text: 'Alpha',
onAction: Fun.noop
});
ed.ui.registry.addContextToolbar('test-toolbar', {
predicate: (node) => {
return node.nodeName && node.nodeName.toLowerCase() === 'a'; },
items: 'alpha'
});
};
Pipeline.async({}, [
sAddInput,
Logger.t('iframe editor focusout should remove context menu', Chain.asStep({}, [
McEditor.cFromHtml(html, { setup, base_url: '/project/tinymce/js/tinymce' }),
ApiChains.cFocus,
ApiChains.cSetCursor([ 0, 1, 0 ], 1),
cWaitForContextmenuState(true),
cFocusInput,
cWaitForContextmenuState(false),
McEditor.cRemove
])),
Logger.t('inline editor focusout should remove context menu', Chain.asStep({}, [
McEditor.cFromHtml(html, { setup, inline: true, base_url: '/project/tinymce/js/tinymce' }),
ApiChains.cFocus,
ApiChains.cSetCursor([ 1, 0 ], 1),
cWaitForContextmenuState(true),
cFocusInput,
cWaitForContextmenuState(false),
McEditor.cRemove
])),
sRemoveInput
], () => success(), failure);
});
示例5: table
TinyLoader.setup(function (editor, onSuccess, onFailure) {
Pipeline.async({}, browser.isEdge() || browser.isFirefox() ? [
Logger.t('Move fake caret left before table', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 0),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.left()),
ApiChains.cAssertContentStructure(buildBody([ caretBefore(), table('1'), visualCaretBefore() ])),
ApiChains.cAssertSelection([0], 0, [0], 0)
])),
Logger.t('Move fake caret right after table', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.right()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretAfter(), visualCaretAfter() ])),
ApiChains.cAssertSelection([1], 0, [1], 0)
])),
Logger.t('Move fake caret right after table then right again before other table', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table><table><tbody><tr><td>2</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
ApiChains.cAssertContentStructure(buildBody([ table('1'), table('2') ])),
ActionChains.cContentKeystroke(Keys.right()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretAfter(), table('2'), visualCaretAfter() ])),
ApiChains.cAssertSelection([1], 0, [1], 0),
ActionChains.cContentKeystroke(Keys.right()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretBefore(), table('2'), visualCaretBefore() ])),
ApiChains.cAssertSelection([1], 0, [1], 0)
])),
Logger.t('Move fake caret left before table then left again after other table', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table><table><tbody><tr><td>2</td></tr></tbody></table>'),
ApiChains.cSetCursor([1, 0, 0, 0, 0], 0),
ApiChains.cAssertContentStructure(buildBody([ table('1'), table('2') ])),
ActionChains.cContentKeystroke(Keys.left()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretBefore(), table('2'), visualCaretBefore() ])),
ApiChains.cAssertSelection([1], 0, [1], 0),
ActionChains.cContentKeystroke(Keys.left()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretAfter(), table('2'), visualCaretAfter() ])),
ApiChains.cAssertSelection([1], 0, [1], 0)
])),
Logger.t('Move fake up for when table is first element', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 0),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.up()),
ApiChains.cAssertContentStructure(buildBody([ caretBefore(), table('1'), visualCaretBefore() ])),
ApiChains.cAssertSelection([0], 0, [0], 0)
])),
Logger.t('Move fake down for when table is last element', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.down()),
ApiChains.cAssertContentStructure(buildBody([ table('1'), caretAfter(), visualCaretAfter() ])),
ApiChains.cAssertSelection([1], 0, [1], 0)
])),
Logger.t('Move fake up for when table is first element but not when caret is not as start', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 1),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.up()),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ApiChains.cAssertSelection([0, 0, 0, 0, 0], 1, [0, 0, 0, 0, 0], 1)
])),
Logger.t('Move fake down for when table is last element but not when caret is not as end', Chain.asStep(editor, [
ApiChains.cFocus,
ApiChains.cSetContent('<table><tbody><tr><td>1</td></tr></tbody></table>'),
ApiChains.cSetCursor([0, 0, 0, 0, 0], 0),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ActionChains.cContentKeystroke(Keys.down()),
ApiChains.cAssertContentStructure(buildBody([ table('1') ])),
ApiChains.cAssertSelection([0, 0, 0, 0, 0], 0, [0, 0, 0, 0, 0], 0)
]))
] : [], onSuccess, onFailure);
}, {