本文整理匯總了TypeScript中@ephox/agar.NamedChain.bundle方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript NamedChain.bundle方法的具體用法?TypeScript NamedChain.bundle怎麽用?TypeScript NamedChain.bundle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@ephox/agar.NamedChain
的用法示例。
在下文中一共展示了NamedChain.bundle方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: sAssertUrlStructure
const testChangingUrlValueWith = (sChooseItem: Step<any, any>) => Log.stepsAsStep('TBA', 'Link: Choosing something in the urlinput changes text and value', [
tinyApis.sSetContent('<h1>Header One</h1><h2 id="existing-id">Header2</h2>'),
TestLinkUi.sOpenLinkDialog,
Keyboard.sKeydown(doc, Keys.down(), { }),
UiFinder.sWaitForVisible('Waiting for dropdown', TinyDom.fromDom(document.body), '.tox-menu'),
sChooseItem,
sAssertUrlStructure((s, str, _arr) => {
return s.element('input', {
value: str.startsWith('#h_')
});
}),
sAssertInputValue('Header One', 'Text to display'),
TestLinkUi.sAssertContentPresence(tinyApis, {
'h1[id]': 0,
'h2[id]': 1
}),
TestLinkUi.sClickSave,
TestLinkUi.sAssertContentPresence(tinyApis, {
'h1[id]': 1
}),
// Check that the h1's id value is referred to by a link containing dog
Chain.asStep(TinyDom.fromDom(editor.getBody()), [
NamedChain.asChain([
NamedChain.direct(NamedChain.inputName(), UiFinder.cFindIn('h1'), 'h1'),
NamedChain.direct('h1', Chain.mapper((h1) => Attr.get(h1, 'id')), 'h1-id'),
NamedChain.bundle((obj) => {
return UiFinder.findIn(obj[NamedChain.inputName()], `a[href="#${obj['h1-id']}"]:contains("Header One")`);
})
])
])
]);
示例2: TestExtras
UnitTest.asynctest('WindowManager:inline-dialog Test', (success, failure) => {
const helpers = TestExtras();
const windowManager = WindowManager.setup(helpers.extras);
const cGetDialogLabelId = Chain.binder((dialogE: Element) => {
if (Attr.has(dialogE, 'aria-labelledby')) {
const labelId = Attr.get(dialogE, 'aria-labelledby');
return labelId.length > 0 ? Result.value(labelId) : Result.error('Dialog has zero length aria-labelledby attribute');
} else {
return Result.error('Dialog has no aria-labelledby attribute');
}
});
const sAssertDialogLabelledBy =
Chain.asStep(Body.body(), [NamedChain.asChain([
NamedChain.direct(NamedChain.inputName(), UiFinder.cFindIn('[role="dialog"]'), 'dialog'),
NamedChain.direct('dialog', cGetDialogLabelId, 'labelId'),
NamedChain.bundle((obj) => UiFinder.findIn(obj.dialog, `#${obj.labelId}`)),
])]);
const sTestDialogLabelled = (params) =>
Logger.t(
`Dialog should have "aria-labelledby" for config "${JSON.stringify(params)}"`,
GeneralSteps.sequence([
Step.sync(() => {
const dialogSpec: Types.Dialog.DialogApi<{}> = {
title: 'Silver Test Inline (Toolbar) Dialog',
body: {
type: 'panel',
items: []
},
buttons: [],
initialData: {}
};
windowManager.open(dialogSpec, params, Fun.noop );
}),
sAssertDialogLabelledBy,
])
);
Pipeline.async({}, [
TestHelpers.GuiSetup.mAddStyles(Element.fromDom(document), [
'.tox-dialog { background: white; border: 2px solid black; padding: 1em; margin: 1em; }'
]),
sTestDialogLabelled({ inline: 'toolbar' }),
sTestDialogLabelled({ inline: 'not-inline!!' }),
TestHelpers.GuiSetup.mRemoveStyles
], () => {
helpers.destroy();
success();
}, failure);
});
示例3: Theme
UnitTest.asynctest('Editor alignment toolbar buttons test', (success, failure) => {
Theme();
Pipeline.async({}, [
Log.chainsAsStep('TBA', 'Testing toolbar: toolbar alignment buttons', [
NamedChain.asChain([
NamedChain.writeValue('body', Body.body()),
NamedChain.write('editor', McEditor.cFromSettings({
toolbar: 'alignleft aligncenter alignright alignjustify alignnone',
theme: 'silver',
base_url: '/project/tinymce/js/tinymce'
})),
NamedChain.direct('body', UiFinder.cWaitForVisible('Waiting for menubar', '.tox-menubar'), '_menubar'),
NamedChain.direct('body', cExtractOnlyOne('.tox-toolbar'), 'toolbar'),
NamedChain.direct('toolbar', Assertions.cAssertStructure(
'Checking toolbar should have just alignment buttons',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-toolbar') ],
children: [
s.element('div', {
classes: [ arr.has('tox-toolbar__group') ],
children: [
s.element('button', {
attrs: { title: str.is('Align left')}
}),
s.element('button', {
attrs: { title: str.is('Align center')}
}),
s.element('button', {
attrs: { title: str.is('Align right')}
}),
s.element('button', {
attrs: { title: str.is('Justify')}
}),
s.element('button', {
attrs: { title: str.is('No alignment')}
}),
]
})
]
});
})
), Id.generate('')),
NamedChain.direct('editor', McEditor.cRemove, Id.generate('')),
NamedChain.bundle(Result.value)
])
])
], success, failure);
});
示例4: TinyApis
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
const tinyUi = TinyUi(editor);
const doc = Element.fromDom(document);
Pipeline.async({},
Log.steps('TBA', 'Charmap: Search for items, dialog height should not change when fewer items returned', [
tinyApis.sFocus,
tinyUi.sClickOnToolbar('click charmap', 'button[aria-label="Special character"]'),
Chain.asStep({}, [
tinyUi.cWaitForPopup('wait for popup', 'div[role="dialog"]'),
]),
FocusTools.sTryOnSelector('Focus should start on', doc, '[role="tab"]'),
Keyboard.sKeydown(doc, Keys.tab(), { }),
FocusTools.sTryOnSelector('Focus should have moved to input', doc, 'input'),
Chain.asStep(Body.body() , [
NamedChain.asChain([
NamedChain.direct(NamedChain.inputName(), Chain.identity, 'body'),
NamedChain.writeValue('doc', doc),
NamedChain.direct('body', UiFinder.cFindIn('[role="dialog"] [role="tabpanel"]'), 'tabpanel'),
NamedChain.direct('tabpanel', cTabPanelHeight, 'oldheight'),
NamedChain.direct('body', FocusTools.cSetActiveValue('.'), '_'),
NamedChain.direct('doc', FocusTools.cGetFocused, 'input'),
NamedChain.direct('input', cFakeEvent('input'), '_'),
// need to wait until '.tox-collection__group' has no children
NamedChain.direct('body', UiFinder.cWaitForState('wait until ', '[role="dialog"] .tox-collection__group', (e) => Traverse.childNodesCount(e) === 0), '_'),
NamedChain.direct('tabpanel', cTabPanelHeight, 'newheight'),
NamedChain.bundle((bindings) => {
// TODO: Use round pixel numbers in DialogTabHeight.ts
return parseInt(bindings.oldheight, 10) !== parseInt(bindings.newheight, 10) ?
Result.error(`Old height and new height differ. Old height: '${bindings.oldheight}' new height '${bindings.newheight}'`) :
Result.value({});
})
])
])
])
, onSuccess, onFailure);
}, {
示例5: f
const cBundleOp = (f) => {
return NamedChain.bundle((input) => {
f(input);
return Result.value(input);
});
};
示例6: cCreateEditorWithMenubar
UnitTest.asynctest('Editor (Silver) test', (success, failure) => {
// Theme();
const cCreateEditorWithMenubar = (menubar) => McagarEditor.cFromSettings({
menubar,
theme: 'silver',
base_url: '/project/tinymce/js/tinymce',
});
const cAssertIsDefaultMenubar = Assertions.cAssertStructure(
'Checking structure of tox-menubar is "default"',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-menubar') ],
children: Arr.map([ 'File', 'Edit', 'View', 'Format' ], (x) =>
s.element('button', {
children: [
s.element('span', {
html: str.is(x)
}),
// chevron
s.element('div', { })
]
})
)
});
})
);
Pipeline.async({}, [
Log.chainsAsStep('TBA', 'Testing menubar: false should not create menubar at all', [
NamedChain.asChain([
NamedChain.writeValue('body', Body.body()),
NamedChain.write('editor', cCreateEditorWithMenubar(false)),
NamedChain.direct('body', UiFinder.cWaitForVisible('Waiting for container', '.tox-tinymce'), '_tiny'),
NamedChain.direct('body', cCountNumber('.tox-menubar'), 'numMenubars'),
NamedChain.direct('numMenubars', Assertions.cAssertEq('Should be no menubars', 0), Id.generate('')),
NamedChain.direct('editor', McagarEditor.cRemove, Id.generate('')),
NamedChain.bundle(Result.value)
])
]),
Log.chainsAsStep('TBA', 'Testing menubar: true should create default menubar', [
NamedChain.asChain([
NamedChain.writeValue('body', Body.body()),
NamedChain.write('editor', cCreateEditorWithMenubar(true)),
NamedChain.direct('body', UiFinder.cWaitForVisible('Waiting for menubar', '.tox-menubar'), '_menubar'),
NamedChain.direct('body', cExtractOnlyOne('.tox-menubar'), 'menubar'),
NamedChain.direct('menubar', cAssertIsDefaultMenubar, Id.generate('')),
NamedChain.direct('editor', McagarEditor.cRemove, Id.generate('')),
NamedChain.bundle(Result.value)
])
]),
Log.chainsAsStep('TBA', 'Testing menubar: undefined should create default menubar', [
NamedChain.asChain([
NamedChain.writeValue('body', Body.body()),
NamedChain.write('editor', cCreateEditorWithMenubar(undefined)),
NamedChain.direct('body', UiFinder.cWaitForVisible('Waiting for menubar', '.tox-menubar'), '_menubar'),
NamedChain.direct('body', cExtractOnlyOne('.tox-menubar'), 'menubar'),
NamedChain.direct('menubar', cAssertIsDefaultMenubar, Id.generate('')),
NamedChain.direct('editor', McagarEditor.cRemove, Id.generate('')),
NamedChain.bundle(Result.value)
])
]),
Log.chainsAsStep('TBA', 'Testing menubar: "file edit" should create "file edit" menubar', [
NamedChain.asChain([
NamedChain.writeValue('body', Body.body()),
NamedChain.write('editor', cCreateEditorWithMenubar('file edit')),
NamedChain.direct('body', UiFinder.cWaitForVisible('Waiting for menubar', '.tox-menubar'), '_menubar'),
NamedChain.direct('body', cExtractOnlyOne('.tox-menubar'), 'menubar'),
NamedChain.direct('menubar', Assertions.cAssertStructure(
'Checking menubar should have just file and edit',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-menubar') ],
children: [
s.element('button', { }),
s.element('button', { })
]
});
})
), Id.generate('')),
NamedChain.direct('editor', McagarEditor.cRemove, Id.generate('')),
NamedChain.bundle(Result.value)
])
])
], () => success(), failure);
});
示例7: cCreateEditorWithToolbar
UnitTest.asynctest('Editor (Silver) test', (success, failure) => {
// Theme();
const cCreateEditorWithToolbar = (toolbarVal, toolbarVal1?, toolbarVal2?, toolbarVal9?, toolbarVal20?) => McagarEditor.cFromSettings({
toolbar: toolbarVal,
toolbar1: toolbarVal1,
toolbar2: toolbarVal2,
toolbar9: toolbarVal9,
toolbar20: toolbarVal20,
theme: 'silver',
base_url: '/project/tinymce/js/tinymce',
});
const cAssertIsDefaultToolbar = Assertions.cAssertStructure(
'Checking structure of tox-toolbar is "default"',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-toolbar') ],
children: Arr.map([ 1, 2, 3, 4, 5], (_) => // Technically meant to be 6 groups by default but the link and image plugins aren't loaded here so whatever
s.element('div', { classes: [ arr.has('tox-toolbar__group') ] }))
});
})
);
Pipeline.async({}, [
Log.chainsAsStep('TBA', 'Testing toolbar: false should not create toolbar at all', [
NamedChain.asChain([
NamedChain.writeValue('body', Body.body()),
NamedChain.write('editor', cCreateEditorWithToolbar(false)),
NamedChain.direct('body', UiFinder.cWaitForVisible('Waiting for menubar', '.tox-menubar'), '_menubar'),
NamedChain.direct('body', cCountNumber('.tox-toolbar'), 'numToolbars'),
NamedChain.direct('numToolbars', Assertions.cAssertEq('Should be no toolbars', 0), Id.generate('')),
NamedChain.direct('editor', McagarEditor.cRemove, Id.generate('')),
NamedChain.bundle(Result.value)
])
]),
Log.chainsAsStep('TBA', 'Testing toolbar: true should create default toolbar', [
NamedChain.asChain([
NamedChain.writeValue('body', Body.body()),
NamedChain.write('editor', cCreateEditorWithToolbar(true)),
NamedChain.direct('body', UiFinder.cWaitForVisible('Waiting for menubar', '.tox-menubar'), '_menubar'),
NamedChain.direct('body', cExtractOnlyOne('.tox-toolbar'), 'toolbar'),
NamedChain.direct('toolbar', cAssertIsDefaultToolbar, Id.generate('')),
NamedChain.direct('editor', McagarEditor.cRemove, Id.generate('')),
NamedChain.bundle(Result.value)
])
]),
Log.chainsAsStep('TBA', 'Testing toolbar: undefined should create default toolbar', [
NamedChain.asChain([
NamedChain.writeValue('body', Body.body()),
NamedChain.write('editor', cCreateEditorWithToolbar(undefined)),
NamedChain.direct('body', UiFinder.cWaitForVisible('Waiting for menubar', '.tox-menubar'), '_menubar'),
NamedChain.direct('body', cExtractOnlyOne('.tox-toolbar'), 'toolbar'),
NamedChain.direct('toolbar', cAssertIsDefaultToolbar, Id.generate('')),
NamedChain.direct('editor', McagarEditor.cRemove, Id.generate('')),
NamedChain.bundle(Result.value)
])
]),
Log.chainsAsStep('TBA', 'Testing toolbar: "bold italic" should create "bold italic" toolbar', [
NamedChain.asChain([
NamedChain.writeValue('body', Body.body()),
NamedChain.write('editor', cCreateEditorWithToolbar('bold italic')),
NamedChain.direct('body', UiFinder.cWaitForVisible('Waiting for menubar', '.tox-menubar'), '_menubar'),
NamedChain.direct('body', cExtractOnlyOne('.tox-toolbar'), 'toolbar'),
NamedChain.direct('toolbar', Assertions.cAssertStructure(
'Checking toolbar should have just bold and italic',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-toolbar') ],
children: [
s.element('div', {
classes: [ arr.has('tox-toolbar__group') ],
children: [
s.element('button', { }),
s.element('button', { })
]
})
]
});
})
), Id.generate('')),
NamedChain.direct('editor', McagarEditor.cRemove, Id.generate('')),
NamedChain.bundle(Result.value)
])
]),
Log.chainsAsStep('TBA', 'Testing toolbar: "bold italic | stufffffed | strikethrough underline" should create "bold italic | strikethrough underline" toolbar', [
NamedChain.asChain([
NamedChain.writeValue('body', Body.body()),
NamedChain.write('editor', cCreateEditorWithToolbar('bold italic | stufffffed | strikethrough underline')),
NamedChain.direct('body', UiFinder.cWaitForVisible('Waiting for menubar', '.tox-menubar'), '_menubar'),
NamedChain.direct('body', cExtractOnlyOne('.tox-toolbar'), 'toolbar'),
NamedChain.direct('toolbar', Assertions.cAssertStructure(
'Checking toolbar should have just bold and italic',
ApproxStructure.build((s, str, arr) => {
return s.element('div', {
classes: [ arr.has('tox-toolbar') ],
//.........這裏部分代碼省略.........