本文整理汇总了TypeScript中tinymce/plugins/template/Plugin.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: TemplatePlugin
UnitTest.asynctest('browser.tinymce.plugins.template.SelectedContentTest', (success, failure) => {
TemplatePlugin();
TinyLoader.setup((editor, onSuccess, onFailure) => {
const tinyApis = TinyApis(editor);
const dialogSelector = 'div.tox-dialog';
const toolbarButtonSelector = '[role="toolbar"] button[aria-label="Insert template"]';
const docBody = Element.fromDom(document.body);
Pipeline.async({}, [
Log.stepsAsStep('TBA', 'Template: Test selectedcontent replacement with default class', [
tinyApis.sSetContent('Text'),
tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<h1 class="selcontent">This will be replaced</h1>' }]),
Mouse.sClickOn(Element.fromDom(editor.getContainer()), toolbarButtonSelector),
UiFinder.sWaitForVisible('Waited for dialog to be visible', docBody, dialogSelector),
Mouse.sClickOn(docBody, 'button.tox-button:contains(Save)'),
Waiter.sTryUntil('Dialog should close', UiFinder.sNotExists(docBody, dialogSelector), 100, 3000),
tinyApis.sAssertContent('<h1 class="selcontent">Text</h1>')
]),
Log.stepsAsStep('TBA', 'Template: Test selectedcontent replacement with custom class', [
tinyApis.sSetContent('Text'),
tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
tinyApis.sSetSetting('template_selected_content_classes', 'customSelected'),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<h1 class="customSelected">This will be replaced/h1>' }]),
Mouse.sClickOn(Element.fromDom(editor.getContainer()), toolbarButtonSelector),
UiFinder.sWaitForVisible('Waited for dialog to be visible', docBody, dialogSelector),
Mouse.sClickOn(docBody, 'button.tox-button:contains(Save)'),
Waiter.sTryUntil('Dialog should close', UiFinder.sNotExists(docBody, dialogSelector), 100, 3000),
tinyApis.sAssertContent('<h1 class="customSelected">Text</h1>')
])
], onSuccess, onFailure);
}, {
theme: 'silver',
plugins: 'template',
toolbar: 'template',
base_url: '/project/tinymce/js/tinymce',
}, success, failure);
});
示例2: function
UnitTest.asynctest('browser.tinymce.plugins.template.SelectedContentTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
ModernTheme();
TemplatePlugin();
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyUi = TinyUi(editor);
const tinyApis = TinyApis(editor);
Pipeline.async({}, [
Logger.t('test selectedcontent replacement with default class', GeneralSteps.sequence([
tinyApis.sSetContent('Text'),
tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<h1 class="selcontent">This will be replaced</h1>' }]),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<h1 class="selcontent">Text</h1>')
])),
Logger.t('test selectedcontent replacement with custom class', GeneralSteps.sequence([
tinyApis.sSetContent('Text'),
tinyApis.sSetSelection([0, 0], 0, [0, 0], 4),
tinyApis.sSetSetting('template_selected_content_classes', 'customSelected'),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<h1 class="customSelected">This will be replaced/h1>' }]),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<h1 class="customSelected">Text</h1>')
]))
], onSuccess, onFailure);
}, {
plugins: 'template',
toolbar: 'template',
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});
示例3: function
export default function () {
AdvListPlugin();
AnchorPlugin();
AutoLinkPlugin();
AutoResizePlugin();
AutoSavePlugin();
BbCodePlugin();
CharMapPlugin();
CodePlugin();
CodeSamplePlugin();
ColorPickerPlugin();
ContextMenuPlugin();
DirectionalityPlugin();
EmoticonsPlugin();
FullPagePlugin();
FullScreenPlugin();
HrPlugin();
ImagePlugin();
ImageToolsPlugin();
ImportCssPlugin();
InsertDatetimePlugin();
LegacyOutputPlugin();
LinkPlugin();
ListsPlugin();
MediaPlugin();
NonBreakingPlugin();
NonEditablePlugin();
PageBreakPlugin();
PastePlugin();
PreviewPlugin();
PrintPlugin();
SavePlugin();
SearchReplacePlugin();
SpellCheckerPlugin();
TabFocusPlugin();
TablePlugin();
TemplatePlugin();
TextColorPlugin();
TextPatternPlugin();
TocPlugin();
VisualBlocksPlugin();
VisualCharsPlugin();
WordCountPlugin();
ModernTheme();
MobileTheme();
HelpPlugin();
PluginManager.urls.emoticons = '../../../../js/tinymce/plugins/emoticons';
const settings = {
skin_url: '../../../../js/tinymce/skins/lightgray',
codesample_content_css: '../../../../js/tinymce/plugins/codesample/css/prism.css',
visualblocks_content_css: '../../../../js/tinymce/plugins/visualblocks/css/visualblocks.css',
images_upload_url: 'd',
selector: 'textarea',
// rtl_ui: true,
link_list: [
{ title: 'My page 1', value: 'http://www.tinymce.com' },
{ title: 'My page 2', value: 'http://www.moxiecode.com' }
],
image_list: [
{ title: 'My page 1', value: 'http://www.tinymce.com' },
{ title: 'My page 2', value: 'http://www.moxiecode.com' }
],
image_class_list: [
{ title: 'None', value: '' },
{ title: 'Some class', value: 'class-name' }
],
importcss_append: true,
height: 400,
file_picker_callback (callback, value, meta) {
// Provide file and text for the link dialog
if (meta.filetype === 'file') {
callback('https://www.google.com/logos/google.jpg', { text: 'My text' });
}
// Provide image and alt text for the image dialog
if (meta.filetype === 'image') {
callback('https://www.google.com/logos/google.jpg', { alt: 'My alt text' });
}
// Provide alternative source and posted for the media dialog
if (meta.filetype === 'media') {
callback('movie.mp4', { source2: 'alt.ogg', poster: 'https://www.google.com/logos/google.jpg' });
}
},
spellchecker_callback (method, text, success, failure) {
const words = text.match(this.getWordCharPattern());
if (method === 'spellcheck') {
const suggestions = {};
for (let i = 0; i < words.length; i++) {
suggestions[words[i]] = ['First', 'Second'];
}
success(suggestions);
}
if (method === 'addToDictionary') {
//.........这里部分代码省略.........
示例4: TemplatePlugin
UnitTest.asynctest('browser.tinymce.plugins.template.DatesTest', (success, failure) => {
TemplatePlugin();
TinyLoader.setup((editor, onSuccess, onFailure) => {
const tinyApis = TinyApis(editor);
const docBody = Element.fromDom(document.body);
const dialogSelector = 'div.tox-dialog';
const toolbarButtonSelector = '[role="toolbar"] button[aria-label="Insert template"]';
const sDeleteSetting = (key) => {
return Logger.t('Deleting Setting ' + key, Step.sync(() => {
delete editor.settings[key];
}));
};
Pipeline.async({}, [
Log.stepsAsStep('TBA', 'Template: Test cdate in snippet with default class', [
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<p class="cdate">x</p>' }]),
tinyApis.sSetSetting('template_cdate_format', 'fake date'),
Mouse.sClickOn(Element.fromDom(editor.getContainer()), toolbarButtonSelector),
UiFinder.sWaitForVisible('Waited for dialog to be visible', docBody, dialogSelector),
Mouse.sClickOn(docBody, 'button.tox-button:contains(Save)'),
Waiter.sTryUntil('Dialog should close', UiFinder.sNotExists(docBody, dialogSelector), 100, 3000),
tinyApis.sAssertContent('<p class="cdate">fake date</p>'),
tinyApis.sSetContent('')
]),
Log.stepsAsStep('TBA', 'Template: Test cdate in snippet with custom class', [
tinyApis.sSetSetting('template_cdate_classes', 'customCdateClass'),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<p class="customCdateClass">x</p>' }]),
tinyApis.sSetSetting('template_cdate_format', 'fake date'),
Mouse.sClickOn(Element.fromDom(editor.getContainer()), toolbarButtonSelector),
UiFinder.sWaitForVisible('Waited for dialog to be visible', docBody, dialogSelector),
Mouse.sClickOn(docBody, 'button.tox-button:contains(Save)'),
Waiter.sTryUntil('Dialog should close', UiFinder.sNotExists(docBody, dialogSelector), 100, 3000),
tinyApis.sAssertContent('<p class="customCdateClass">fake date</p>'),
sDeleteSetting('template_cdate_classes'),
sDeleteSetting('templates'),
sDeleteSetting('template_cdate_format'),
tinyApis.sSetContent('')
]),
Log.stepsAsStep('TBA', 'Template: Test mdate updates with each serialization', [
tinyApis.sSetSetting(
'templates',
[{ title: 'a', description: 'b', content: '<div class="mceTmpl"><p class="mdate"></p><p class="cdate"></p></div>' }]
),
tinyApis.sSetSetting('template_mdate_format', 'fake modified date'),
tinyApis.sSetSetting('template_cdate_format', 'fake created date'),
Mouse.sClickOn(Element.fromDom(editor.getContainer()), toolbarButtonSelector),
UiFinder.sWaitForVisible('Waited for dialog to be visible', docBody, dialogSelector),
Mouse.sClickOn(docBody, 'button.tox-button:contains(Save)'),
Waiter.sTryUntil('Dialog should close', UiFinder.sNotExists(docBody, dialogSelector), 100, 3000),
tinyApis.sAssertContent('<div class="mceTmpl"><p class="mdate">fake modified date</p><p class="cdate">fake created date</p></div>'),
tinyApis.sSetSetting('template_mdate_format', 'changed modified date'),
tinyApis.sAssertContent('<div class="mceTmpl"><p class="mdate">changed modified date</p><p class="cdate">fake created date</p></div>'),
sDeleteSetting('templates'),
sDeleteSetting('template_mdate_format'),
sDeleteSetting('template_cdate_template'),
tinyApis.sSetContent('')
]),
Log.stepsAsStep('TBA', 'Template: Test mdate updates with each serialization with custom class', [
tinyApis.sSetSetting('template_mdate_classes', 'modified'),
tinyApis.sSetSetting(
'templates',
[{ title: 'a', description: 'b', content: '<div class="mceTmpl"><p class="modified"></p><p class="cdate"></p></div>' }]
),
tinyApis.sSetSetting('template_mdate_format', 'fake modified date'),
tinyApis.sSetSetting('template_cdate_format', 'fake created date'),
Mouse.sClickOn(Element.fromDom(editor.getContainer()), toolbarButtonSelector),
UiFinder.sWaitForVisible('Waited for dialog to be visible', docBody, dialogSelector),
Mouse.sClickOn(docBody, 'button.tox-button:contains(Save)'),
Waiter.sTryUntil('Dialog should close', UiFinder.sNotExists(docBody, dialogSelector), 100, 3000),
tinyApis.sAssertContent('<div class="mceTmpl"><p class="modified">fake modified date</p><p class="cdate">fake created date</p></div>'),
tinyApis.sSetSetting('template_mdate_format', 'changed modified date'),
tinyApis.sAssertContent('<div class="mceTmpl"><p class="modified">changed modified date</p><p class="cdate">fake created date</p></div>'),
sDeleteSetting('template_mdate_classes'),
sDeleteSetting('templates'),
sDeleteSetting('template_mdate_format'),
sDeleteSetting('template_cdate_template')
])
], onSuccess, onFailure);
}, {
theme: 'silver',
plugins: 'template',
toolbar: 'template',
indent: false,
base_url: '/project/tinymce/js/tinymce',
}, success, failure);
});
示例5: function
UnitTest.asynctest('browser.tinymce.plugins.template.DatesTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
ModernTheme();
TemplatePlugin();
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyUi = TinyUi(editor);
const tinyApis = TinyApis(editor);
const sDeleteSetting = function (key) {
return Step.sync(function () {
delete editor.settings[key];
});
};
Pipeline.async({}, [
Logger.t('test cdate in snippet with default class', GeneralSteps.sequence([
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<p class="cdate">x</p>' }]),
tinyApis.sSetSetting('template_cdate_format', 'fake date'),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<p class="cdate">fake date</p>'),
tinyApis.sSetContent('')
])),
Logger.t('test cdate in snippet with custom class', GeneralSteps.sequence([
tinyApis.sSetSetting('template_cdate_classes', 'customCdateClass'),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<p class="customCdateClass">x</p>' }]),
tinyApis.sSetSetting('template_cdate_format', 'fake date'),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<p class="customCdateClass">fake date</p>'),
sDeleteSetting('template_cdate_classes'),
sDeleteSetting('templates'),
sDeleteSetting('template_cdate_format'),
tinyApis.sSetContent('')
])),
Logger.t('test mdate updates with each serialization', GeneralSteps.sequence([
tinyApis.sSetSetting(
'templates',
[{ title: 'a', description: 'b', content: '<div class="mceTmpl"><p class="mdate"></p><p class="cdate"></p></div>' }]
),
tinyApis.sSetSetting('template_mdate_format', 'fake modified date'),
tinyApis.sSetSetting('template_cdate_format', 'fake created date'),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<div class="mceTmpl"><p class="mdate">fake modified date</p><p class="cdate">fake created date</p></div>'),
tinyApis.sSetSetting('template_mdate_format', 'changed modified date'),
tinyApis.sAssertContent('<div class="mceTmpl"><p class="mdate">changed modified date</p><p class="cdate">fake created date</p></div>'),
sDeleteSetting('templates'),
sDeleteSetting('template_mdate_format'),
sDeleteSetting('template_cdate_template'),
tinyApis.sSetContent('')
])),
Logger.t('test mdate updates with each serialization with custom class', GeneralSteps.sequence([
tinyApis.sSetSetting('template_mdate_classes', 'modified'),
tinyApis.sSetSetting(
'templates',
[{ title: 'a', description: 'b', content: '<div class="mceTmpl"><p class="modified"></p><p class="cdate"></p></div>' }]
),
tinyApis.sSetSetting('template_mdate_format', 'fake modified date'),
tinyApis.sSetSetting('template_cdate_format', 'fake created date'),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<div class="mceTmpl"><p class="modified">fake modified date</p><p class="cdate">fake created date</p></div>'),
tinyApis.sSetSetting('template_mdate_format', 'changed modified date'),
tinyApis.sAssertContent('<div class="mceTmpl"><p class="modified">changed modified date</p><p class="cdate">fake created date</p></div>'),
sDeleteSetting('template_mdate_classes'),
sDeleteSetting('templates'),
sDeleteSetting('template_mdate_format'),
sDeleteSetting('template_cdate_template')
]))
], onSuccess, onFailure);
}, {
plugins: 'template',
toolbar: 'template',
indent: false,
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});
示例6: function
export default function () {
AdvListPlugin();
AnchorPlugin();
AutoLinkPlugin();
AutoResizePlugin();
AutoSavePlugin();
BbCodePlugin();
CharMapPlugin();
CodePlugin();
CodeSamplePlugin();
ColorPickerPlugin();
ContextMenuPlugin();
DirectionalityPlugin();
EmoticonsPlugin();
FullPagePlugin();
FullScreenPlugin();
HrPlugin();
ImagePlugin();
ImageToolsPlugin();
ImportCssPlugin();
InsertDatetimePlugin();
LegacyOutputPlugin();
LinkPlugin();
ListsPlugin();
MediaPlugin();
NonBreakingPlugin();
NonEditablePlugin();
PageBreakPlugin();
PastePlugin();
PreviewPlugin();
PrintPlugin();
SavePlugin();
SearchReplacePlugin();
SpellCheckerPlugin();
TabFocusPlugin();
TablePlugin();
TemplatePlugin();
TextColorPlugin();
TextPatternPlugin();
TocPlugin();
VisualBlocksPlugin();
VisualCharsPlugin();
WordCountPlugin();
ModernTheme();
const cmd = function (command, value?) {
return { command, value };
};
const commands = [
cmd('Bold'),
cmd('Italic'),
cmd('Underline'),
cmd('Strikethrough'),
cmd('Superscript'),
cmd('Subscript'),
cmd('Cut'),
cmd('Copy'),
cmd('Paste'),
cmd('Unlink'),
cmd('JustifyLeft'),
cmd('JustifyCenter'),
cmd('JustifyRight'),
cmd('JustifyFull'),
cmd('JustifyNone'),
cmd('InsertUnorderedList'),
cmd('InsertOrderedList'),
cmd('ForeColor', 'red'),
cmd('HiliteColor', 'green'),
cmd('FontName', 'Arial'),
cmd('FontSize', 7),
cmd('RemoveFormat'),
cmd('mceBlockQuote'),
cmd('FormatBlock', 'h1'),
cmd('mceInsertContent', 'abc'),
cmd('mceToggleFormat', 'bold'),
cmd('mceSetContent', 'abc'),
cmd('Indent'),
cmd('Outdent'),
cmd('InsertHorizontalRule'),
cmd('mceToggleVisualAid'),
cmd('mceInsertLink', 'url'),
cmd('selectAll'),
cmd('delete'),
cmd('mceNewDocument'),
cmd('Undo'),
cmd('Redo'),
cmd('mceAutoResize'),
cmd('mceShowCharmap'),
cmd('mceCodeEditor'),
cmd('mceDirectionLTR'),
cmd('mceDirectionRTL'),
cmd('mceFullPageProperties'),
cmd('mceFullscreen'),
cmd('mceImage'),
cmd('mceInsertDate'),
cmd('mceInsertTime'),
cmd('InsertDefinitionList'),
cmd('mceNonBreaking'),
cmd('mcePageBreak'),
//.........这里部分代码省略.........
示例7: function
UnitTest.asynctest('browser.tinymce.plugins.template.TemplateSanityTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
ModernTheme();
TemplatePlugin();
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyUi = TinyUi(editor);
const tinyApis = TinyApis(editor);
Pipeline.async({}, [
Logger.t('test basic template insertion', GeneralSteps.sequence([
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<strong>c</strong>' }]),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<p><strong>c</strong></p>')
])),
Logger.t('test basic content replacement', GeneralSteps.sequence([
tinyApis.sSetContent(''),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<p>{$name} {$email}</p>' }]),
tinyApis.sSetSetting('template_replace_values', { name: 'Tester', email: 'test@test.com' }),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
tinyUi.sWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<p>Tester test@test.com</p>')
])),
Logger.t('test loading in snippet from other file', GeneralSteps.sequence([
tinyApis.sSetContent(''),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', url: '/project/src/plugins/template/test/html/test_template.html' }]),
tinyUi.sClickOnToolbar('click on template button', 'div[aria-label="Insert template"] > button'),
Chain.asStep({}, [
tinyUi.cWaitForPopup('wait for popup', 'div[role="dialog"][aria-label="Insert template"]'),
UiFinder.cWaitForState('iframe is loaded', 'iframe', function (elm) {
const iframeDoc = elm.dom().contentDocument || elm.dom().contentWindow.document;
return iframeDoc.body.firstChild !== null;
})
]),
tinyUi.sClickOnUi('click on ok button', 'div.mce-primary button'),
tinyApis.sAssertContent('<p><em>this is external</em></p>')
])),
Logger.t('test command', GeneralSteps.sequence([
tinyApis.sSetContent(''),
tinyApis.sSetSetting('template_replace_values', { name: 'Tester' }),
tinyApis.sExecCommand('mceInsertTemplate', '<p>{$name}</p>'),
tinyApis.sAssertContent('<p>Tester</p>')
]))
], onSuccess, onFailure);
}, {
plugins: 'template',
toolbar: 'template',
indent: false,
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});
示例8:
/**
* Demo.js
*
* Released under LGPL License.
* Copyright (c) 1999-2016 Ephox Corp. All rights reserved
*
* License: http://www.tinymce.com/license
* Contributing: http://www.tinymce.com/contributing
*/
import TemplatePlugin from 'tinymce/plugins/template/Plugin';
declare let tinymce: any;
TemplatePlugin();
tinymce.init({
selector: 'textarea.tinymce',
plugins: 'template code',
toolbar: 'template code',
skin_url: '../../../../../js/tinymce/skins/lightgray',
height: 600,
templates: [
{ title: 'Some title 1', description: 'Some desc 1', content: 'My content' },
{ title: 'Some title 2', description: 'Some desc 2', content: 'My other content' }
]
});
示例9: TemplatePlugin
UnitTest.asynctest('browser.tinymce.plugins.template.TemplateSanityTest', (success, failure) => {
TemplatePlugin();
SilverTheme();
TinyLoader.setup((editor, onSuccess, onFailure) => {
const tinyApis = TinyApis(editor);
const docBody = Element.fromDom(document.body);
const dialogSelector = 'div.tox-dialog';
const toolbarButtonSelector = '[role="toolbar"] button[aria-label="Insert template"]';
Pipeline.async({}, [
Log.stepsAsStep('TBA', 'Template: Test basic template insertion', [
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<strong>c</strong>' }]),
Mouse.sClickOn(Element.fromDom(editor.getContainer()), toolbarButtonSelector),
UiFinder.sWaitForVisible('Waited for dialog to be visible', docBody, dialogSelector),
Mouse.sClickOn(docBody, 'button.tox-button:contains(Save)'),
Waiter.sTryUntil('Dialog should close', UiFinder.sNotExists(docBody, dialogSelector), 100, 3000),
tinyApis.sAssertContent('<p><strong>c</strong></p>'),
]),
Log.stepsAsStep('TBA', 'Template: Test basic content replacement', [
tinyApis.sSetContent(''),
tinyApis.sSetSetting('templates', [{ title: 'a', description: 'b', content: '<p>{$name} {$email}</p>' }]),
tinyApis.sSetSetting('template_replace_values', { name: 'Tester', email: 'test@test.com' }),
Mouse.sClickOn(Element.fromDom(editor.getContainer()), toolbarButtonSelector),
UiFinder.sWaitForVisible('Waited for dialog to be visible', docBody, dialogSelector),
Mouse.sClickOn(docBody, 'button.tox-button:contains(Save)'),
Waiter.sTryUntil('Dialog should close', UiFinder.sNotExists(docBody, dialogSelector), 100, 3000),
tinyApis.sAssertContent('<p>Tester test@test.com</p>'),
]),
Log.stepsAsStep('TBA', 'Template: Test loading in snippet from other file', [
tinyApis.sSetContent(''),
tinyApis.sSetSetting('templates', [{ title: 'a', description: '<strong>b</strong>', url: '/project/tinymce/src/plugins/template/test/html/test_template.html' }]),
Mouse.sClickOn(Element.fromDom(editor.getContainer()), toolbarButtonSelector),
UiFinder.sWaitForVisible('Waited for dialog to be visible', docBody, dialogSelector),
Chain.asStep(docBody, [
UiFinder.cFindIn(dialogSelector),
UiFinder.cWaitForState('iframe is loaded', 'iframe', (elm) => {
const iframeDoc = elm.dom().contentDocument || elm.dom().contentWindow.document;
return iframeDoc.body.firstChild !== null;
})
]),
UiFinder.sExists(docBody, dialogSelector + ' p:contains("<strong>b</strong>")'),
Mouse.sClickOn(docBody, 'button.tox-button:contains(Save)'),
Waiter.sTryUntil('Dialog should close', UiFinder.sNotExists(docBody, dialogSelector), 100, 3000),
tinyApis.sAssertContent('<p><em>this is external</em></p>'),
]),
Log.stepsAsStep('TBA', 'Template: Test command', [
tinyApis.sSetContent(''),
tinyApis.sSetSetting('template_replace_values', { name: 'Tester' }),
tinyApis.sExecCommand('mceInsertTemplate', '<p>{$name}</p>'),
tinyApis.sAssertContent('<p>Tester</p>'),
])
], onSuccess, onFailure);
}, {
theme: 'silver',
plugins: 'template',
toolbar: 'template',
indent: false,
base_url: '/project/tinymce/js/tinymce',
}, success, failure);
});