本文整理匯總了TypeScript中@ephox/katamari.Cell類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Cell類的具體用法?TypeScript Cell怎麽用?TypeScript Cell使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Cell類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: ModernTheme
UnitTest.asynctest('browser.tinymce.core.annotate.AnnotationChangedTest', (success, failure) => {
ModernTheme();
const changes: Cell<Array<{state: boolean, name: string, uid: string}>> = Cell([ ]);
const sAssertChanges = (message: string, expected: Array<{uid: string, state: boolean, name: string}>) => Logger.t(
message,
// Use a chain so that changes.get() can be evaluated at run-time.
Chain.asStep({ }, [
Chain.mapper((_) => {
return changes.get();
}),
Chain.op((cs: Array<{uid: string, name: string}>) => {
Assertions.assertEq('Checking changes', expected, cs);
})
])
);
const sClearChanges = Step.sync(() => {
changes.set([ ]);
});
TinyLoader.setup(function (editor: Editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
const sTestAnnotationEvents = (label: string, start: number[], soffset: number, expected: Array<{ uid: string, name: string, state: boolean}>): any => {
return GeneralSteps.sequence([
tinyApis.sSetSelection(start, soffset, start, soffset),
Waiter.sTryUntil(
label,
sAssertChanges('sTestAnnotationEvents.sAssertChanges', expected),
10,
1000
),
]);
};
const sTestChanges = GeneralSteps.sequence([
// '<p>This |is the first paragraph</p><p>This is the second.</p><p>This is| the third.</p><p>Spanning |multiple</p><p>par||ag||raphs| now</p>'
tinyApis.sSetContent([
'<p>This is the first paragraph</p>',
'<p>This is the second.</p>',
'<p>This is the third.</p>',
'<p>Spanning multiple</p>',
'<p>paragraphs now</p>'
].join('')),
tinyApis.sSetSelection([ 0, 0 ], 'This '.length, [ 0, 0 ], 'This is'.length),
sAnnotate(editor, 'alpha', 'id-one', { anything: 'comment-1' }),
tinyApis.sSetSelection([ 1, 0 ], 'T'.length, [ 1, 0 ], 'This is'.length),
sAnnotate(editor, 'alpha', 'id-two', { anything: 'comment-two' }),
tinyApis.sSetSelection([ 2, 0 ], 'This is the th'.length, [ 2, 0 ], 'This is the thir'.length),
sAnnotate(editor, 'beta', 'id-three', { something: 'comment-three' }),
tinyApis.sSetSelection([ 3, 0 ], 'Spanning '.length, [ 4, 0 ], 'paragraphs'.length),
sAnnotate(editor, 'gamma', 'id-four', { something: 'comment-four' }),
tinyApis.sSetSelection([ 4, 0, 0 ], 'par'.length, [ 4, 0, 0 ], 'parag'.length ),
sAnnotate(editor, 'delta', 'id-five', { something: 'comment-five' }),
Step.wait(1000),
sClearChanges,
sAssertHtmlContent(tinyApis, [
`<p>This <span data-mce-annotation="alpha" data-test-anything="comment-1" data-mce-annotation-uid="id-one" class="mce-annotation">is</span> the first paragraph</p>`,
`<p>T<span data-mce-annotation="alpha" data-test-anything="comment-two" data-mce-annotation-uid="id-two" class="mce-annotation">his is</span> the second.</p>`,
`<p>This is the th<span data-mce-annotation="beta" data-test-something="comment-three" data-mce-annotation-uid="id-three" class="mce-annotation">ir</span>d.</p>`,
`<p>Spanning <span data-mce-annotation="gamma" data-test-something="comment-four" data-mce-annotation-uid="id-four" class="mce-annotation">multiple</span></p>`,
`<p><span data-mce-annotation="gamma" data-test-something="comment-four" data-mce-annotation-uid="id-four" class="mce-annotation">par` +
`<span data-mce-annotation="delta" data-test-something="comment-five" data-mce-annotation-uid="id-five" class="mce-annotation delta-test">ag</span>` +
`raphs</span> now</p>`
]),
// Outside: p(0) > text(0) > "Th".length
// Inside: p(0) > span(1) > text(0) > 'i'.length
// Inside: p(1) > span(1) > text(0), 'hi'.length
// Outside: p(1) > text(2) > ' the '.length
Waiter.sTryUntil(
'Waiting for no changes',
sAssertChanges('Should be no changes', [ ]),
10,
1000
),
sTestAnnotationEvents(
'No annotation at cursor',
[ 0, 0 ], 'Th'.length,
[
{ state: false, name: 'delta', uid: null },
{ state: false, name: 'gamma', uid: null }
]
),
//.........這裏部分代碼省略.........
示例2: return
const toggleActiveState = (editor: Editor, enabledState: Cell<boolean>) => (api) => {
api.setActive(enabledState.get());
const editorEventCallback = (e) => api.setActive(e.state);
editor.on('VisualBlocks', editorEventCallback);
return () => editor.off('VisualBlocks', editorEventCallback);
};
示例3: function
const open = function (editor: Editor, headState: Cell<string>) {
const data = Parser.htmlToData(editor, headState.get());
const defaultData = {
title: '',
keywords: '',
description: '',
robots: '',
author: '',
docencoding: ''
};
const initialData = Merger.merge(defaultData, data);
editor.windowManager.open({
title: 'Metadata and Document Properties',
size: 'normal',
body: {
type: 'panel',
items: [
{
name: 'title',
type: 'input',
label: 'Title'
},
{
name: 'keywords',
type: 'input',
label: 'Keywords'
},
{
name: 'description',
type: 'input',
label: 'Description'
},
{
name: 'robots',
type: 'input',
label: 'Robots'
},
{
name: 'author',
type: 'input',
label: 'Author'
},
{
name: 'docencoding',
type: 'input',
label: 'Encoding'
},
]
},
buttons: [
{
type: 'cancel',
name: 'cancel',
text: 'Cancel'
},
{
type: 'submit',
name: 'save',
text: 'Save',
primary: true
}
],
initialData,
onSubmit: (api) => {
const nuData = api.getData();
const headHtml = Parser.dataToHtml(editor, Tools.extend(data, nuData), headState.get());
headState.set(headHtml);
api.close();
}
});
};
示例4: function
editor.on('SpellcheckStart SpellcheckEnd', function () {
self.active(startedState.get());
});
示例5:
onItemAction: (splitButtonApi, value) => {
currentLanguageState.set(value);
}
示例6:
const setPatterns = (newPatterns: Pattern[]) => {
patternsState.set(createPatternSet(newPatterns));
};
示例7: applyColour
onAction: (splitButtonApi) => {
// do something with last colour
if (lastColor.get() !== null) {
applyColour(editor, format, lastColor.get(), () => { });
}
},
示例8:
const updateSelectionState = (itemRange: ItemRange) => itemSelection.each((selection) => {
if (Compare.eq(itemRange === ItemRange.Start ? selection.start : selection.end, item)) {
selectionState.set(itemRange === ItemRange.Start);
}
});
示例9: function
const getTextMatcher = function () {
return textMatcherState.get();
};