本文整理汇总了TypeScript中@ephox/mcagar.UiChains.cCloseDialog方法的典型用法代码示例。如果您正苦于以下问题:TypeScript UiChains.cCloseDialog方法的具体用法?TypeScript UiChains.cCloseDialog怎么用?TypeScript UiChains.cCloseDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@ephox/mcagar.UiChains
的用法示例。
在下文中一共展示了UiChains.cCloseDialog方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const sOpenAndCloseDialog = (label) => {
return GeneralSteps.sequence([
Chain.asStep(editor, [
tinyUi.cWaitForPopup('wait for dialog', `div:contains("${label}")`),
UiChains.cCloseDialog('div[role="dialog"]')
]),
Waiter.sTryUntil('Wait for dialog to close', UiFinder.sNotExists(TinyDom.fromDom(document.body), 'div[role="dialog"]'), 50, 5000)
]);
};
示例2: TinyUi
TinyLoader.setup((editor: Editor, onSuccess, onFailure) => {
const tinyUi = TinyUi(editor);
const cOpenDialog = Chain.fromChains([
Chain.op(() => {
return editor.execCommand('mceCodeEditor');
}),
tinyUi.cWaitForPopup('wait for dialog', 'div[role="dialog"]'),
]);
const cGetWhiteSpace = Chain.mapper(() => {
const element = editor.getElement();
return editor.dom.getStyle(element, 'white-space', true);
});
const cAssertWhiteSpace = () => {
return NamedChain.asChain([
NamedChain.direct(NamedChain.inputName(), Chain.identity, 'editor'),
NamedChain.direct('editor', cOpenDialog, 'element'),
NamedChain.direct('element', cGetWhiteSpace, 'whitespace'),
NamedChain.read('whitespace', Chain.op((whitespace) => {
Assertions.assertEq('Textarea should have "white-space: pre-wrap"', 'pre-wrap', whitespace);
}))
]);
};
const sAssertStyleExits = Chain.asStep({editor}, [
cAssertWhiteSpace(),
UiChains.cCloseDialog('div[role="dialog"]')
]);
// Test verifies that new lines and whitespaces are allowed within the textarea in Firefox and IE
Pipeline.async({}, [
Log.stepsAsStep('TBA', 'Code: Verify if "white-space: pre-wrap" style is set on the textarea', [
sAssertStyleExits
])
], onSuccess, onFailure);
}, {
示例3: TinyApis
TinyLoader.setup((editor, onSuccess, onFailure) => {
const tinyApis = TinyApis(editor);
const tinyUi = TinyUi(editor);
const doc = Element.fromDom(document);
const editorBody = Element.fromDom(editor.getBody());
const sOpenContextMenu = (target) => {
return Chain.asStep(editor, [
tinyUi.cTriggerContextMenu('trigger context menu', target, '.tox-silver-sink [role="menuitem"]'),
Chain.wait(0)
]);
};
// Assert focus is on the expected menu item
const sAssertFocusOnItem = (label, selector) => {
return FocusTools.sTryOnSelector(`Focus should be on: ${label}`, doc, selector);
};
// Wait for dialog to open and close dialog
const sWaitForAndCloseDialog = GeneralSteps.sequence([
Chain.asStep(editor, [
tinyUi.cWaitForPopup('wait for dialog', 'div[role="dialog"]'),
UiChains.cCloseDialog('div[role="dialog"]')
]),
Waiter.sTryUntil(
'Wait for dialog to close',
UiFinder.sNotExists(TinyDom.fromDom(document.body), 'div[role="dialog"]'), 50, 5000
)
]);
const sPressDownArrowKey = Keyboard.sKeydown(doc, Keys.down(), { });
const sPressEnterKey = Keyboard.sKeydown(doc, Keys.enter(), { });
const sRepeatDownArrowKey = (index) => {
return GeneralSteps.sequence(Arr.range(index, () => sPressDownArrowKey));
};
const tableHtml = '<table style="width: 100%;">' +
'<tbody>' +
'<tr>' +
'<td></td>' +
'<td></td>' +
'</tr>' +
'<tr>' +
'<td></td>' +
'<td></td>' +
'</tr>' +
'</tbody>' +
'</table>';
const imgSrc = '../img/dogleft.jpg';
const contentInTableHtml = (content: string) => {
return '<table style="width: 100%;">' +
'<tbody>' +
'<tr>' +
`<td>${content}</td>` +
'</tr>' +
'</tbody>' +
'</table>';
};
const imageInTableHtml = contentInTableHtml('<img src="' + imgSrc + '" width="160" height="100"/>');
const placeholderImageInTableHtml = contentInTableHtml('<img src="' + imgSrc + '" width="160" height="100" data-mce-placeholder="1"/>');
const linkInTableHtml = contentInTableHtml('<a href="http://tiny.cloud/">Tiny</a>');
// In Firefox we add a a bogus br element after the link that fixes a gecko link bug when,
// a link is placed at the end of block elements there is no way to move the caret behind the link.
const sAssertRemoveLinkHtmlStructure = Assertions.sAssertStructure('Assert remove link', ApproxStructure.build((s, str) => {
return s.element('body', {
children: [
s.element('p', {
children: [
s.text(str.is('Tiny')),
s.zeroOrOne(s.element('br', {}))
]
})
]
});
}), editorBody);
Pipeline.async({}, [
tinyApis.sFocus,
Log.stepsAsStep('TBA', 'Test context menus on empty editor', [
sOpenContextMenu('p'),
sAssertFocusOnItem('Link', '.tox-collection__item:contains("Link...")'),
sPressEnterKey,
sWaitForAndCloseDialog
]),
Log.stepsAsStep('TBA', 'Test context menus on a link', [
tinyApis.sSetContent('<p><a href="http://tiny.cloud/">Tiny</a></p>'),
tinyApis.sSetSelection([ 0, 0, 0 ], 'Ti'.length, [ 0, 0, 0 ], 'Ti'.length),
sOpenContextMenu('a'),
sAssertFocusOnItem('Link', '.tox-collection__item:contains("Link...")'),
sPressDownArrowKey,
sAssertFocusOnItem('Remove Link', '.tox-collection__item:contains("Remove link")'),
sPressDownArrowKey,
sAssertFocusOnItem('Open Link', '.tox-collection__item:contains("Open link")'),
sPressDownArrowKey,
//.........这里部分代码省略.........
示例4: TinyApis
TinyLoader.setup((editor, onSuccess, onFailure) => {
const tinyApis = TinyApis(editor);
const tinyUi = TinyUi(editor);
const doc = Element.fromDom(document);
const body = Body.body();
const editorBody = Element.fromDom(editor.getBody());
const sOpenContextMenu = (target: string) => {
return Chain.asStep(editor, [
tinyUi.cTriggerContextMenu('trigger context menu', target, '.tox-silver-sink [role="menuitem"]'),
Chain.wait(0)
]);
};
const sAssertFocusOnItem = (label: string, selector: string) => {
return FocusTools.sTryOnSelector(`Focus should be on: ${label}`, doc, selector);
};
const sCloseDialogAndWait = GeneralSteps.sequence([
tinyUi.sWaitForPopup('wait for dialog', 'div[role="dialog"]'),
Chain.asStep(editor, [
UiChains.cCloseDialog('div[role="dialog"]')
]),
Waiter.sTryUntil(
'Wait for dialog to close',
UiFinder.sNotExists(body, 'div[role="dialog"]'), 50, 5000
)
]);
const sPressDownArrowKey = Keyboard.sKeydown(doc, Keys.down(), { });
const sPressEnterKey = Keyboard.sKeydown(doc, Keys.enter(), { });
const sRepeatDownArrowKey = (index) => {
return GeneralSteps.sequence(Arr.range(index, () => sPressDownArrowKey));
};
// 'index' points to the context menuitems while 'subindex' points to the sub menuitems
const sSelectContextMenu = (label: string, selector: string, index: number, subindex: number) => {
return GeneralSteps.sequence([
sOpenContextMenu('td'),
sRepeatDownArrowKey(subindex),
Keyboard.sKeydown(doc, Keys.right(), {}),
sRepeatDownArrowKey(index),
sAssertFocusOnItem(label, selector),
sPressEnterKey
]);
};
const sSelectCellContextMenu = (label, selector, index) => sSelectContextMenu(label, selector, index, 0);
const sSelectRowContextMenu = (label, selector, index) => sSelectContextMenu(label, selector, index, 1);
const sSelectColumnContextMenu = (label, selector, index) => sSelectContextMenu(label, selector, index, 2);
const tableHtml = '<table style="width: 100%;">' +
'<tbody>' +
'<tr>' +
'<td></td>' +
'<td></td>' +
'</tr>' +
'<tr>' +
'<td></td>' +
'<td></td>' +
'</tr>' +
'</tbody>' +
'</table>';
const tableWithCaptionHtml = '<table style="width: 100%;">' +
'<caption>Caption</caption>' +
'<tbody>' +
'<tr>' +
'<td></td>' +
'<td></td>' +
'</tr>' +
'</tbody>' +
'</table>';
// Using a different table to test merge cells as selection using keydown (shift + arrow keys) does not work on Edge for some reason.
// TODO: Investigate why selection does not work on Edge.
const mergeTableHtml = '<table style="width: 100%;">' +
'<tbody>' +
'<tr>' +
'<td data-mce-selected="1" data-mce-first-selected="1">a1</td>' +
'<td>a2</td>' +
'</tr>' +
'<tr>' +
'<td data-mce-selected="1" data-mce-last-selected="1">b1</td>' +
'<td>b2</td>' +
'</tr>' +
'</tbody>' +
'</table>';
const sAssertHtmlStructure = (label: string, expectedHtml: string) => Assertions.sAssertStructure(label, ApproxStructure.build((s) => {
return s.element('body', {
children: [
ApproxStructure.fromHtml(expectedHtml),
s.theRest()
]
});
}), editorBody);
//.........这里部分代码省略.........
示例5: TinyApis
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
const tinyUi = TinyUi(editor);
const doc = Element.fromDom(document);
const body = Body.body();
const tableHtml = '<table style = "width: 5%;">' +
'<tbody>' +
'<tr>' +
'<td></td>' +
'</tr>' +
'</tbody>' +
'</table>';
const sAddTableAndOpenContextToolbar = (html: string) => GeneralSteps.sequence([
tinyApis.sSetContent(html),
tinyUi.sWaitForUi('Wait for table context toolbar', '.tox-toolbar button[aria-label="Table properties"]'),
]);
// Use keyboard shortcut ctrl+F9 to navigate to the context toolbar
const sPressKeyboardShortcutKey = Keyboard.sKeydown(Element.fromDom(editor.getDoc()), 120, { ctrl: true });
const sPressRightArrowKey = Keyboard.sKeydown(doc, Keys.right(), { });
const sPressTabKey = Keyboard.sKeydown(doc, Keys.tab(), { });
// Assert focus is on the expected toolbar button
const sAssertFocusOnItem = (label: string, selector: string) => {
return FocusTools.sTryOnSelector(`Focus should be on: ${label}`, doc, selector);
};
const sAssertButtonDisabled = (label: string, selector: string) => {
return tinyUi.sWaitForUi(label, `.tox-pop__dialog ${selector}:disabled`);
};
const sClickOnToolbarButton = (selector: string) => {
return Chain.asStep({}, [
Chain.fromParent(tinyUi.cWaitForPopup('wait for context toolbar', '.tox-pop__dialog div'), [
Chain.fromChains([
UiFinder.cFindIn(selector),
Mouse.cClick
])
])
]);
};
const sAssertHtmlStructure = (label, expectedHtml) => Chain.asStep({editor}, [ NamedChain.read('editor', Chain.op((editor) => {
const elm = Replication.deep(Element.fromDom(editor.getBody()));
Arr.each(SelectorFilter.descendants(elm, '*[data-mce-bogus="all"]'), Remove.remove);
const actualHtml = Html.get(elm);
Assertions.assertHtmlStructure(label, `<body>${expectedHtml}</body>`, `<body>${actualHtml}</body>`);
}))]);
const sOpenAndCloseDialog = GeneralSteps.sequence([
Chain.asStep(editor, [
tinyUi.cWaitForPopup('wait for dialog', 'div[role="dialog"]'),
UiChains.cCloseDialog('div[role="dialog"]')
]),
Waiter.sTryUntil('Wait for dialog to close', UiFinder.sNotExists(body, 'div[role="dialog"]'), 50, 5000)
]);
Pipeline.async({}, [
tinyApis.sFocus,
Log.stepsAsStep('TBA', 'Table: context toolbar keyboard navigation test', [
sAddTableAndOpenContextToolbar(tableHtml),
sPressKeyboardShortcutKey,
sAssertFocusOnItem('Table properties button', 'button[aria-label="Table properties"]'),
sPressRightArrowKey,
sAssertFocusOnItem('Delete table button', 'button[aria-label="Delete table"]'),
sPressTabKey,
sAssertFocusOnItem('Insert row above button', 'button[aria-label="Insert row before"]'),
sPressRightArrowKey,
sAssertFocusOnItem('Insert row below button', 'button[aria-label="Insert row after"]'),
sPressRightArrowKey,
sAssertFocusOnItem('Delete row button', 'button[aria-label="Delete row"]'),
sPressTabKey,
sAssertFocusOnItem('Insert column before button', 'button[aria-label="Insert column before"]'),
sPressRightArrowKey,
sAssertFocusOnItem('Insert column after button', 'button[aria-label="Insert column after"]'),
sPressRightArrowKey,
sAssertFocusOnItem('Delete column button', 'button[aria-label="Delete column"]'),
sPressTabKey,
sAssertFocusOnItem('Table properties button', 'button[aria-label="Table properties"]'),
sClickOnToolbarButton('button[aria-label="Delete table"]'),
sAssertHtmlStructure('Assert delete table', '<p><br></p>')
]),
Log.stepsAsStep('TBA', 'Table: context toolbar functionality test', [
sAddTableAndOpenContextToolbar(tableHtml),
sClickOnToolbarButton('button[aria-label="Table properties"]'),
sOpenAndCloseDialog,
sClickOnToolbarButton('button[aria-label="Insert row before"]'),
sAssertHtmlStructure('Assert insert row before', '<table><tbody><tr><td><br></td></tr><tr><td><br></td></tr></tbody></table>'),
sClickOnToolbarButton('button[aria-label="Insert row after"]'),
sAssertHtmlStructure('Assert insert row after', '<table><tbody><tr><td><br></td></tr><tr><td><br></td></tr><tr><td><br></td></tr></tbody></table>'),
sClickOnToolbarButton('button[aria-label="Delete row"]'),
sAssertHtmlStructure('Assert delete row', '<table><tbody><tr><td><br></td></tr><tr><td><br></td></tr></tbody></table>'),
sClickOnToolbarButton('button[aria-label="Insert column before"]'),
//.........这里部分代码省略.........