本文整理汇总了TypeScript中@ephox/agar.GeneralSteps类的典型用法代码示例。如果您正苦于以下问题:TypeScript GeneralSteps类的具体用法?TypeScript GeneralSteps怎么用?TypeScript GeneralSteps使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeneralSteps类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: function
const sCheckP2 = function (situation) {
return GeneralSteps.sequence([
sSetP2,
sCheckInNoList(situation)
]);
};
开发者ID:abstask,项目名称:tinymce,代码行数:6,代码来源:ListTest.ts
示例2: function
UnitTest.asynctest('browser.tinymce.core.dom.ParentsTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const cCreateStructure = function (html) {
return Chain.mapper(function (_) {
return Element.fromHtml(html);
});
};
const cParentsUntil = function (startPath, rootPath, predicate) {
return Chain.mapper(function (structure) {
const startNode = Hierarchy.follow(structure, startPath).getOrDie();
const rootNode = Hierarchy.follow(structure, rootPath).getOrDie();
return Parents.parentsUntil(startNode, rootNode, predicate);
});
};
const cParents = function (startPath, rootPath) {
return Chain.mapper(function (structure) {
const startNode = Hierarchy.follow(structure, startPath).getOrDie();
const rootNode = Hierarchy.follow(structure, rootPath).getOrDie();
return Parents.parents(startNode, rootNode);
});
};
const cParentsAndSelf = function (startPath, rootPath) {
return Chain.mapper(function (structure) {
const startNode = Hierarchy.follow(structure, startPath).getOrDie();
const rootNode = Hierarchy.follow(structure, rootPath).getOrDie();
return Parents.parentsAndSelf(startNode, rootNode);
});
};
const cAssertElementNames = function (expectedNames) {
return Chain.mapper(function (parents) {
const names = Arr.map(parents, Node.name);
Assertions.assertEq('Should be expected names', expectedNames, names);
return {};
});
};
const hasName = function (name) {
return function (elm) {
return Node.name(elm) === name;
};
};
Pipeline.async({}, [
Logger.t('parentsUntil', GeneralSteps.sequence([
Logger.t('parentsUntil root', Chain.asStep({}, [
cCreateStructure('<p><b>a</b></p>'),
cParentsUntil([0, 0], [], hasName('p')),
cAssertElementNames(['b'])
])),
Logger.t('parentsUntil root on elm', Chain.asStep({}, [
cCreateStructure('<p><b><i></i></b></p>'),
cParentsUntil([0, 0], [], hasName('p')),
cAssertElementNames(['b'])
])),
Logger.t('parentsUntil root deeper', Chain.asStep({}, [
cCreateStructure('<p><b><i><u>a</u></i></b></p>'),
cParentsUntil([0, 0, 0, 0], [], hasName('p')),
cAssertElementNames(['u', 'i', 'b'])
])),
Logger.t('parentsUntil end at b', Chain.asStep({}, [
cCreateStructure('<p><b><i><u>a</u></i></b></p>'),
cParentsUntil([0, 0, 0, 0], [], hasName('b')),
cAssertElementNames(['u', 'i'])
])),
Logger.t('parentsUntil end at b', Chain.asStep({}, [
cCreateStructure('<p><b>a</b></p>'),
cParentsUntil([0, 0], [], hasName('b')),
cAssertElementNames([])
])),
Logger.t('parentsUntil root scope', Chain.asStep({}, [
cCreateStructure('<p><b><i><u>a</u></i></b></p>'),
cParentsUntil([0, 0, 0, 0], [0], hasName('p')),
cAssertElementNames(['u', 'i'])
]))
])),
Logger.t('parents', GeneralSteps.sequence([
Logger.t('parents', Chain.asStep({}, [
cCreateStructure('<p><b><i><u>a</u></i></b></p>'),
cParents([0, 0, 0, 0], []),
cAssertElementNames(['u', 'i', 'b'])
])),
Logger.t('parents scoped', Chain.asStep({}, [
cCreateStructure('<p><b><i><u>a</u></i></b></p>'),
cParents([0, 0, 0, 0], [0]),
cAssertElementNames(['u', 'i'])
]))
])),
//.........这里部分代码省略.........
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:101,代码来源:ParentsTest.ts
示例3: function
const sTypeContentAtSelection = function (doc, text) {
return GeneralSteps.sequence(Arr.map(text.split(''), Fun.curry(sTypeChar, doc)));
};
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:3,代码来源:TypeText.ts
示例4: TinyApis
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
Pipeline.async({}, [
Logger.t('getContent html', GeneralSteps.sequence([
tinyApis.sSetContent('<p>html</p>'),
Step.sync(() => {
const html = EditorContent.getContent(editor);
Assertions.assertHtml('Should be expected html', '<p>html</p>', html);
})
])),
Logger.t('getContent tree', GeneralSteps.sequence([
tinyApis.sSetContent('<p>tree</p>'),
Step.sync(() => {
const tree = EditorContent.getContent(editor, { format: 'tree' }) as Node;
Assertions.assertHtml('Should be expected tree html', '<p>tree</p>', toHtml(tree));
})
])),
Logger.t('getContent tree filtered', GeneralSteps.sequence([
Step.sync(() => {
EditorContent.setContent(editor, '<p><font size="7">x</font></p>', { format: 'raw' });
const tree = EditorContent.getContent(editor, { format: 'tree' }) as Node;
Assertions.assertHtml('Should be expected tree filtered html', '<p><span style="font-size: 300%;">x</span></p>', toHtml(tree));
})
])),
Logger.t('getContent tree using public api', GeneralSteps.sequence([
tinyApis.sSetContent('<p>html</p>'),
Step.sync(() => {
const tree = editor.getContent({ format: 'tree'}) as Node;
Assertions.assertHtml('Should be expected filtered html', '<p>html</p>', toHtml(tree));
})
])),
Logger.t('setContent html', GeneralSteps.sequence([
tinyApis.sSetContent('<p>html</p>'),
Step.sync(function () {
EditorContent.setContent(editor, '<p>new html</p>');
}),
tinyApis.sAssertContent('<p>new html</p>')
])),
Logger.t('setContent tree', GeneralSteps.sequence([
tinyApis.sSetContent('<p>tree</p>'),
Step.sync(() => {
const tree = EditorContent.getContent(editor, { format: 'tree' }) as Node;
Assertions.assertHtml('Should be expected tree html', '<p>tree</p>', toHtml(tree));
EditorContent.setContent(editor, '<p>new html</p>');
Assertions.assertHtml('Should be expected html', '<p>new html</p>', EditorContent.getContent(editor));
EditorContent.setContent(editor, tree);
Assertions.assertHtml('Should be expected tree html', '<p>tree</p>', EditorContent.getContent(editor));
})
])),
Logger.t('setContent tree filtered', GeneralSteps.sequence([
tinyApis.sSetContent('<p>tree</p>'),
Step.sync(() => {
EditorContent.setContent(editor, getFontTree());
Assertions.assertHtml('Should be expected filtered html', '<span style="font-size: 300%;">x</span>', EditorContent.getContent(editor));
})
])),
Logger.t('setContent tree using public api', GeneralSteps.sequence([
tinyApis.sSetContent('<p>tree</p>'),
Step.sync(() => {
editor.setContent(getFontTree());
Assertions.assertHtml('Should be expected filtered html', '<span style="font-size: 300%;">x</span>', EditorContent.getContent(editor));
})
]))
], onSuccess, onFailure);
}, {
开发者ID:abstask,项目名称:tinymce,代码行数:68,代码来源:EditorContentTest.ts
示例5: TinyApis
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
const tinyActions = TinyActions(editor);
Pipeline.async({}, [
tinyApis.sFocus,
Logger.t('Arrow keys anchor with text', GeneralSteps.sequence([
Logger.t('From start to end inside anchor over text', GeneralSteps.sequence([
tinyApis.sSetRawContent('<p><a href="#">x</a></p>'),
tinyApis.sSetCursor([0, 0, 0], 0),
tinyApis.sNodeChanged,
tinyActions.sContentKeystroke(Keys.right(), { }),
tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1),
sAssertCaretAtZwsp(editor)
])),
Logger.t('From start to before anchor with text', GeneralSteps.sequence([
tinyApis.sSetRawContent('<p><a href="#">x</a></p>'),
tinyApis.sSetCursor([0, 0, 0], 0),
tinyApis.sNodeChanged,
tinyActions.sContentKeystroke(Keys.left(), { }),
tinyApis.sAssertSelection([0, 0], 0, [0, 0], 0),
sAssertCaretAtZwsp(editor)
])),
Logger.t('From end to after anchor with text', GeneralSteps.sequence([
tinyApis.sSetRawContent('<p><a href="#">x</a></p>'),
tinyApis.sSetCursor([0, 0, 0], 1),
tinyApis.sNodeChanged,
tinyActions.sContentKeystroke(Keys.right(), { }),
tinyApis.sAssertSelection([0, 1], 1, [0, 1], 1),
sAssertCaretAfterZwsp(editor)
])),
Logger.t('From end to start inside anchor over text', GeneralSteps.sequence([
tinyApis.sSetRawContent('<p><a href="#">x</a></p>'),
tinyApis.sSetCursor([0, 0, 0], 1),
tinyApis.sNodeChanged,
tinyActions.sContentKeystroke(Keys.left(), { }),
tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1),
sAssertCaretAfterZwsp(editor)
]))
])),
Logger.t('Arrow keys anchor with image', GeneralSteps.sequence([
Logger.t('From start to end inside anchor over img', GeneralSteps.sequence([
tinyApis.sSetRawContent('<p><a href="#"><img src="#"></a></p>'),
tinyApis.sSetCursor([0, 0], 0),
tinyApis.sNodeChanged,
tinyActions.sContentKeystroke(Keys.right(), { }),
tinyApis.sAssertSelection([0, 0, 1], 0, [0, 0, 1], 0),
sAssertCaretAtZwsp(editor)
])),
Logger.t('From start to before on anchor with img', GeneralSteps.sequence([
tinyApis.sSetRawContent('<p><a href="#"><img src="#"></a></p>'),
tinyApis.sSetCursor([0, 0], 0),
tinyApis.sNodeChanged,
tinyActions.sContentKeystroke(Keys.left(), { }),
tinyApis.sAssertSelection([0, 0], 0, [0, 0], 0),
sAssertCaretAtZwsp(editor)
])),
Logger.t('From end to after on anchor with img', GeneralSteps.sequence([
tinyApis.sSetRawContent('<p><a href="#"><img src="#"></a></p>'),
tinyApis.sSetCursor([0, 0], 1),
tinyApis.sNodeChanged,
tinyActions.sContentKeystroke(Keys.right(), { }),
tinyApis.sAssertSelection([0, 1], 1, [0, 1], 1),
sAssertCaretAfterZwsp(editor)
])),
Logger.t('From end to start inside anchor over img', GeneralSteps.sequence([
tinyApis.sSetRawContent('<p><a href="#"><img src="#"></a></p>'),
tinyApis.sSetCursor([0, 0], 1),
tinyApis.sNodeChanged,
tinyActions.sContentKeystroke(Keys.left(), { }),
tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1),
sAssertCaretAfterZwsp(editor)
]))
])),
Logger.t('Arrow keys between blocks', GeneralSteps.sequence([
Logger.t('From end of anchor text to after anchor to start of anchor in next paragraph', GeneralSteps.sequence([
tinyApis.sSetRawContent('<p><a href="#">a</a></p><p><a href="#">b</a></p>'),
tinyApis.sSetCursor([0, 0, 0], 1),
tinyApis.sNodeChanged,
tinyActions.sContentKeystroke(Keys.right(), { }),
tinyApis.sSetCursor([0, 1], 1),
sAssertCaretAfterZwsp(editor),
tinyActions.sContentKeystroke(Keys.right(), { }),
tinyApis.sAssertSelection([1, 0, 0], 1, [1, 0, 0], 1),
sAssertCaretAfterZwsp(editor)
])),
Logger.t('From start of anchor text to before anchor to end of anchor in previous paragraph', GeneralSteps.sequence([
tinyApis.sSetRawContent('<p><a href="#">a</a></p><p><a href="#">b</a></p>'),
tinyApis.sSetCursor([1, 0, 0], 0),
tinyApis.sNodeChanged,
tinyActions.sContentKeystroke(Keys.left(), { }),
tinyApis.sSetCursor([1, 0], 0),
sAssertCaretAtZwsp(editor),
tinyActions.sContentKeystroke(Keys.left(), { }),
tinyApis.sAssertSelection([0, 0, 0], 1, [0, 0, 0], 1),
sAssertCaretAtZwsp(editor)
])),
Logger.t('From end of anchor text to after anchor to but not to next paragraph', GeneralSteps.sequence([
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:ArrowKeysInlineBoundariesTest.ts
示例6: 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);
}, {
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:81,代码来源:SelectionQuirksTest.ts
示例7: function
UnitTest.asynctest('Browser Test: ui.ButtonsTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
/*
* PURPOSE
*
* There are three buttons. Two have toggling, and one toggling button has a custom action.
* Ensure that they all fire the right actions and get updated appropriately based on broadcasts.
*/
const realm = IosRealm(Fun.noop);
const body = Body.body();
Attachment.attachSystem(body, realm.system());
// Make toolbar appear
Class.add(realm.system().element(), 'tinymce-mobile-fullscreen-maximized');
const doc = Traverse.owner(body);
TestStyles.addStyles();
const unload = function () {
TestStyles.removeStyles();
Attachment.detachSystem(realm.system());
};
/* The test editor puts execCommand and insertContent calls into the store */
const tEditor = TestEditor();
const memAlpha = Memento.record(
Buttons.forToolbarCommand(tEditor.editor(), 'alpha')
);
const memBeta = Memento.record(
Buttons.forToolbarStateCommand(tEditor.editor(), 'beta')
);
const memGamma = Memento.record(
Buttons.forToolbarStateAction(tEditor.editor(), 'gamma-class', 'gamma-query', function () {
tEditor.adder('gamma-action')();
})
);
const sClickAlpha = TestUi.sClickComponent(realm, memAlpha);
const sClickBeta = TestUi.sClickComponent(realm, memBeta);
const sClickGamma = TestUi.sClickComponent(realm, memGamma);
const sCheckComponent = function (label, state) {
return function (memento) {
return TestUi.sWaitForToggledState(label, state, realm, memento);
};
};
realm.setToolbarGroups([
{
label: 'group1',
items: [
memAlpha.asSpec(),
memBeta.asSpec(),
memGamma.asSpec()
]
}
]);
/*
* Alpha has no toggling, so just check that when the user clicks on the button, the
* editor fires execCommand with alpha
*/
const sTestAlpha = GeneralSteps.sequence([
tEditor.sAssertEq('Initially empty', [ ]),
sClickAlpha,
tEditor.sAssertEq('After clicking on alpha', [
{
method: 'execCommand',
data: {
alpha: undefined
}
}
]),
tEditor.sClear
]);
/*
* Beta has toggling, so check:
* - when the user clicks on the button, execCommand is fired
* - when the format change is broadcast, the toggled state changes
*/
const sTestBeta = GeneralSteps.sequence([
tEditor.sAssertEq('before beta, store is empty', [ ]),
sClickBeta,
tEditor.sAssertEq('After clicking on beta', [
{
method: 'execCommand',
data: {
beta: undefined
}
}
]),
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:ButtonsTest.ts
示例8: settings
TinyLoader.setup(function (editor, onSuccess, onFailure) {
Pipeline.async({}, [
Logger.t('getEditorSettings tests', GeneralSteps.sequence([
Logger.t('Override defaults plugins', Step.sync(function () {
const settings = EditorSettings.getEditorSettings(
editor,
'id',
'documentBaseUrl',
{
defaultSetting: 'a',
plugins: ['a']
},
{
validate: false,
userSetting: 'b'
}
);
Assertions.assertEq('Should have the specified id', 'id', settings.id);
Assertions.assertEq('Should have the specified documentBaseUrl', 'documentBaseUrl', settings.document_base_url);
Assertions.assertEq('Should have the specified userSetting', 'b', settings.userSetting);
Assertions.assertEq('Should have the forced validate setting', true, settings.validate);
Assertions.assertEq('Should have the default theme', 'modern', settings.theme);
Assertions.assertEq('Should have the specified default plugin', 'a', settings.plugins);
Assertions.assertEq('Should have the default setting', 'a', settings.defaultSetting);
})),
Logger.t('Override defaults with forced_plugins using arrays', Step.sync(function () {
const defaultSettings = {
forced_plugins: ['a', 'b']
};
const userSettings = {
plugins: ['c', 'd']
};
const settings = EditorSettings.getEditorSettings(editor, 'id', 'documentBaseUrl', defaultSettings, userSettings);
Assertions.assertEq('Should be both forced and user plugins', 'a b c d', settings.plugins);
})),
Logger.t('Override defaults with forced_plugins using strings', Step.sync(function () {
const defaultSettings = {
forced_plugins: 'a b'
};
const userSettings = {
plugins: 'c d'
};
const settings = EditorSettings.getEditorSettings(editor, 'id', 'documentBaseUrl', defaultSettings, userSettings);
Assertions.assertEq('Should be both forced and user plugins', 'a b c d', settings.plugins);
})),
Logger.t('Override defaults with forced_plugins using mixed types and spaces', Step.sync(function () {
const defaultSettings = {
forced_plugins: ' a b'
};
const userSettings = {
plugins: [' c ', ' d e ']
};
const settings = EditorSettings.getEditorSettings(editor, 'id', 'documentBaseUrl', defaultSettings, userSettings);
Assertions.assertEq('Should be both forced and user plugins', 'a b c d e', settings.plugins);
})),
Logger.t('Override defaults with just default forced_plugins', Step.sync(function () {
const defaultSettings = {
forced_plugins: ['a', 'b']
};
const userSettings = {
};
const settings = EditorSettings.getEditorSettings(editor, 'id', 'documentBaseUrl', defaultSettings, userSettings);
Assertions.assertEq('Should be just default plugins', 'a b', settings.plugins);
})),
Logger.t('Override defaults with just user plugins', Step.sync(function () {
const defaultSettings = {
};
const userSettings = {
plugins: ['a', 'b']
};
const settings = EditorSettings.getEditorSettings(editor, 'id', 'documentBaseUrl', defaultSettings, userSettings);
Assertions.assertEq('Should be just user plugins', 'a b', settings.plugins);
})),
Logger.t('Override defaults with forced_plugins should not be possible to override', Step.sync(function () {
const defaultSettings = {
forced_plugins: ['a', 'b']
};
//.........这里部分代码省略.........
开发者ID:aha-app,项目名称:tinymce-word-paste-filter,代码行数:101,代码来源:EditorSettingsTest.ts
示例9: TinyApis
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
const tinyUi = TinyUi(editor);
Pipeline.async({}, [
Logger.t('ul to ol, cursor only in parent', GeneralSteps.sequence([
tinyApis.sSetContent('<ul><li>a</li><ul><li>b</li></ul></ul>'),
tinyApis.sSetCursor([0, 0, 0], 0),
tinyUi.sClickOnToolbar('click numlist button', 'div[aria-label="Numbered list"] > button'),
tinyApis.sAssertContent('<ol><li>a</li><ul><li>b</li></ul></ol>'),
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 0, 0], 0)
])),
Logger.t('ul to ol, selection from parent to sublist', GeneralSteps.sequence([
tinyApis.sSetContent('<ul><li>a</li><ol><li>b</li></ol></ul>'),
tinyApis.sSetSelection([0, 0, 0], 0, [0, 1, 0, 0], 1),
tinyUi.sClickOnToolbar('click numlist button', 'div[aria-label="Numbered list"] > button'),
tinyApis.sAssertContent('<ol><li>a</li><ol><li>b</li></ol></ol>'),
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 1, 0, 0], 1)
])),
Logger.t('ol to ul, cursor only in parent', GeneralSteps.sequence([
tinyApis.sSetContent('<ol><li>a</li><ol><li>b</li></ol></ol>'),
tinyApis.sSetCursor([0, 0, 0], 0),
tinyUi.sClickOnToolbar('click bullist button', 'div[aria-label="Bullet list"] > button'),
tinyApis.sAssertContent('<ul><li>a</li><ol><li>b</li></ol></ul>'),
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 0, 0], 0)
])),
Logger.t('ol to ul, selection from parent to sublist', GeneralSteps.sequence([
tinyApis.sSetContent('<ol><li>a</li><ul><li>b</li></ul></ol>'),
tinyApis.sSetSelection([0, 0, 0], 0, [0, 1, 0, 0], 1),
tinyUi.sClickOnToolbar('click bullist button', 'div[aria-label="Bullet list"] > button'),
tinyApis.sAssertContent('<ul><li>a</li><ul><li>b</li></ul></ul>'),
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 1, 0, 0], 1)
])),
Logger.t('alpha to ol, cursor only in parent', GeneralSteps.sequence([
tinyApis.sSetContent('<ul style="list-style-type: lower-alpha;"><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ul>'),
tinyApis.sSetCursor([0, 0, 0], 0),
tinyUi.sClickOnToolbar('click bullist button', 'div[aria-label="Numbered list"] > button'),
tinyApis.sAssertContent('<ol><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ol>'),
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 0, 0], 0)
])),
Logger.t('alpha to ol, selection from parent to sublist', GeneralSteps.sequence([
tinyApis.sSetContent('<ul style="list-style-type: lower-alpha;"><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ul>'),
tinyApis.sSetSelection([0, 0, 0], 0, [0, 1, 0, 0], 1),
tinyUi.sClickOnToolbar('click bullist button', 'div[aria-label="Numbered list"] > button'),
tinyApis.sAssertContent('<ol><li>a</li><ol><li>b</li></ol></ol>'),
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 1, 0, 0], 1)
])),
Logger.t('alpha to ul, cursor only in parent', GeneralSteps.sequence([
tinyApis.sSetContent('<ol style="list-style-type: lower-alpha;"><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ol>'),
tinyApis.sSetCursor([0, 0, 0], 0),
tinyUi.sClickOnToolbar('click bullist button', 'div[aria-label="Bullet list"] > button'),
tinyApis.sAssertContent('<ul><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ul>'),
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 0, 0], 0)
])),
Logger.t('alpha to ul, selection from parent to sublist', GeneralSteps.sequence([
tinyApis.sSetContent('<ol style="list-style-type: lower-alpha;"><li>a</li><ol style="list-style-type: lower-alpha;"><li>b</li></ol></ol>'),
tinyApis.sSetSelection([0, 0, 0], 0, [0, 1, 0, 0], 1),
tinyUi.sClickOnToolbar('click bullist button', 'div[aria-label="Bullet list"] > button'),
tinyApis.sAssertContent('<ul><li>a</li><ul><li>b</li></ul></ul>'),
tinyApis.sAssertSelection([0, 0, 0], 0, [0, 1, 0, 0], 1)
]))
], onSuccess, onFailure);
}, {
开发者ID:abstask,项目名称:tinymce,代码行数:63,代码来源:ChangeListStyleTest.ts
示例10: function
//.........这里部分代码省略.........
EditorManager.init({
selector: '#elm-2',
skin_url: '/project/js/tinymce/skins/lightgray'
}).then(function (result) {
Assertions.assertEq('Should be an result that is zero length', 0, result.length);
Env.ie = oldIeValue;
teardown(done);
});
});
suite.asyncTest('target (each editor should have a different target)', function (_, done) {
const maxCount = document.querySelectorAll('.elm-even').length;
const elm1 = document.getElementById('elm-1');
let count = 0;
const targets = [];
EditorManager.init({
selector: '.elm-even',
target: elm1,
skin_url: '/project/js/tinymce/skins/lightgray',
init_instance_callback (ed) {
LegacyUnit.equal(ed.targetElm !== elm1, true, 'target option ignored');
LegacyUnit.equal(Tools.inArray(ed.targetElm, targets), -1);
targets.push(ed.targetElm);
if (++count >= maxCount) {
teardown(done);
}
}
});
});
const getSkinCssFilenames = function () {
return Arr.bind(SelectorFilter.descendants(Element.fromDom(document), 'link'), function (link) {
const href = Attr.get(link, 'href');
const fileName = href.split('/').slice(-1).join('');
const isSkin = href.indexOf('lightgray/') > -1;
return isSkin ? [ fileName ] : [ ];
});
};
const mCreateInlineModeMultipleInstances = Step.stateful(function (value, next, die) {
viewBlock.update('<div class="tinymce-editor"><p>a</p></div><div class="tinymce-editor"><p>b</p></div>');
EditorManager.init({
selector: '.tinymce-editor',
inline: true,
skin_url: '/project/js/tinymce/skins/lightgray'
}).then(next, die);
});
const mAssertEditors = Step.stateful(function (editors: any[], next, die) {
Assertions.assertHtml('Editor contents should be the first div content', '<p>a</p>', editors[0].getContent());
Assertions.assertHtml('Editor contents should be the second div content', '<p>b</p>', editors[1].getContent());
Assertions.assertEq('Editor container should be null', null, editors[0].editorContainer);
Assertions.assertEq('Editor container should be null', null, editors[1].editorContainer);
Assertions.assertEq(
'Should only be two skin files the skin and the content for inline mode',
['skin.min.css', 'content.inline.min.css'],
getSkinCssFilenames()
);
const targets = Arr.map(editors, function (editor) {
return editor.getElement();
});
Assertions.assertEq('Targets should be two since there are two editors', 2, targets.length);
next(targets);
});
const sRemoveAllEditors = Step.sync(function () {
EditorManager.remove();
});
const mAssertTargets = Step.stateful(function (targets: any[], next, die) {
Assertions.assertEq('Targets should be two since there are two editors', 2, targets.length);
Arr.each(targets, function (target) {
Assertions.assertEq('Target parent should not be null', true, target.parentNode !== null);
});
next({});
});
setup();
Pipeline.async({}, [
Logger.t('Initialize multiple inline editors and remove them', GeneralSteps.sequence([
mCreateInlineModeMultipleInstances,
mAssertEditors,
sRemoveAllEditors,
mAssertTargets
]))
], function () {
viewBlock.detach();
success();
}, failure);
});
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:EditorInitializationTest.ts
注:本文中的@ephox/agar.GeneralSteps类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论