本文整理匯總了TypeScript中tinymce/plugins/wordcount/Plugin.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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') {
//.........這裏部分代碼省略.........
示例2: PageBreakPlugin
PageBreakPlugin();
PastePlugin();
PreviewPlugin();
PrintPlugin();
SavePlugin();
SearchReplacePlugin();
SpellCheckerPlugin();
TabFocusPlugin();
TablePlugin();
TemplatePlugin();
TextColorPlugin();
TextPatternPlugin();
TocPlugin();
VisualBlocksPlugin();
VisualCharsPlugin();
WordCountPlugin();
ModernTheme();
export default function () {
const config = {
theme: 'modern',
plugins: [
'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker toc',
'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
'save table contextmenu directionality emoticons template paste textcolor importcss colorpicker textpattern codesample'
],
/*
menubar: 'file edit insert view format table tools',
menu: {
file: { title: 'File', items: 'newdocument' },
edit: { title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall' },
示例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();
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'),
//.........這裏部分代碼省略.........
示例4: Plugin
UnitTest.asynctest('browser.tinymce.plugins.wordcount.ApiTest', (success, failure) => {
Plugin();
Theme();
TinyLoader.setup((editor, onSuccess, onFailure) => {
const makeStep = (label, content, numWords) => {
return Logger.t(`${label} in ${content}`, Step.sync(() => {
editor.setContent(content);
const result = editor.plugins.wordcount.getCount();
Assertions.assertEq('Assert number of words is ' + numWords, result, numWords);
}));
};
Pipeline.async({}, Log.steps('TBA', 'WordCount: Test content other than simple words are ignored for wordcount', [
makeStep('Simple word count', '<p>My sentence is this.</p>', 4),
makeStep('Does not count dashes', '<p>Something -- ok</p>', 2),
makeStep('Does not count asterisks, non-word characters', '<p>* something\n\u00b7 something else</p>', 3),
makeStep('Does count numbers', '<p>Something 123 ok</p>', 3),
makeStep('Does not count htmlentities', '<p>It’s my life – – – don\'t you forget.</p>', 6),
makeStep('Counts hyphenated words as one word', '<p>Hello some-word here.</p>', 3),
makeStep('Counts words between blocks as two words', '<p>Hello</p><p>world</p>', 2),
]), onSuccess, onFailure);
}, {
plugins: 'wordcount',
theme: 'silver',
base_url: '/project/tinymce/js/tinymce'
}, success, failure);
});
示例5: Plugin
UnitTest.asynctest('browser.tinymce.plugins.wordcount.PluginTest', (success, failure) => {
Plugin();
Theme();
TinyLoader.setup(function (editor: Editor, onSuccess, onFailure) {
const sAssertGetText = (node: Node, expected) => {
return Step.sync(() => {
const actual = WordCount.getText(node, editor.schema);
RawAssertions.assertEq('should be the same', expected, actual);
});
};
const c = (html) => editor.dom.create('div', {}, html);
Pipeline.async({}, [
sAssertGetText(c('<p></p>'), ''),
sAssertGetText(c('<p>a b</p>'), 'a b'),
sAssertGetText(c('<p>a b</p>'), 'a\u00a0b'),
sAssertGetText(c('<p>a\uFEFFb</p>'), 'a\uFEFFb'),
sAssertGetText(c('<p><span>a</span> b</p>'), 'a b'),
sAssertGetText(c('<p>a</p><p>b</p>'), 'a b')
], onSuccess, onFailure);
}, {
plugins: 'wordcount',
theme: 'silver',
base_url: '/project/tinymce/js/tinymce'
}, success, failure);
});
示例6: function
UnitTest.asynctest('browser.tinymce.plugins.wordcount.PluginTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
Plugin();
Theme();
const sReset = function (tinyApis) {
return GeneralSteps.sequence([
tinyApis.sSetContent(''),
sWaitForWordcount(0)
], 0);
};
const sAssertWordcount = function (num) {
return Step.sync(function () {
const countEl = DOMUtils.DOM.select('.mce-wordcount')[0];
const value = countEl ? countEl.innerText : '';
Assertions.assertEq('wordcount', num + ' WORDS', value.toUpperCase());
});
};
const sWaitForWordcount = function (num) {
return Waiter.sTryUntil('wordcount did not change', sAssertWordcount(num), 100, 3000);
};
const sFakeTyping = function (editor, str) {
return Step.sync(function () {
editor.getBody().innerHTML = '<p>' + str + '</p>';
Keyboard.keystroke(Keys.space(), {}, TinyDom.fromDom(editor.getBody()));
});
};
const sTestSetContent = function (tinyApis) {
return GeneralSteps.sequence([
sReset(tinyApis),
tinyApis.sSetContent('<p>hello world</p>'),
sWaitForWordcount(2)
], 0);
};
const sTestKeystroke = function (editor, tinyApis) {
return GeneralSteps.sequence([
sReset(tinyApis),
sFakeTyping(editor, 'a b c'),
sAssertWordcount(0),
sWaitForWordcount(3)
], 0);
};
const sExecCommand = function (editor, command) {
return Step.sync(function () {
editor.execCommand(command);
});
};
const sSetRawContent = function (editor, content) {
return Step.sync(function () {
editor.getBody().innerHTML = content;
});
};
const sTestUndoRedo = function (editor, tinyApis) {
return GeneralSteps.sequence([
sReset(tinyApis),
tinyApis.sSetContent('<p>a b c</p>'),
sWaitForWordcount(3),
sExecCommand(editor, 'undo'),
sWaitForWordcount(0),
sExecCommand(editor, 'redo'),
sWaitForWordcount(3),
sSetRawContent(editor, '<p>hello world</p>'),
sExecCommand(editor, 'mceAddUndoLevel'),
sWaitForWordcount(2)
], 0);
};
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
Pipeline.async({}, [
sTestSetContent(tinyApis),
sTestKeystroke(editor, tinyApis),
sTestUndoRedo(editor, tinyApis)
], onSuccess, onFailure);
}, {
plugins: 'wordcount',
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});
示例7: function
UnitTest.asynctest('browser.tinymce.plugins.wordcount.ApiTest', function () {
const success = arguments[arguments.length - 2];
const failure = arguments[arguments.length - 1];
const suite = LegacyUnit.createSuite();
Plugin();
Theme();
suite.test('Blank document has 0 words', function (editor) {
editor.setContent('');
const result = editor.plugins.wordcount.getCount();
LegacyUnit.equal(result, 0);
});
suite.test('Simple word count', function (editor) {
editor.setContent('<p>My sentence is this.</p>');
const result = editor.plugins.wordcount.getCount();
LegacyUnit.equal(result, 4);
});
suite.test('Does not count dashes', function (editor) {
editor.setContent('<p>Something -- ok</p>');
const result = editor.plugins.wordcount.getCount();
LegacyUnit.equal(result, 2);
});
suite.test('Does not count asterisks, non-word characters', function (editor) {
editor.setContent('<p>* something\n\u00b7 something else</p>');
const result = editor.plugins.wordcount.getCount();
LegacyUnit.equal(result, 3);
});
suite.test('Does count numbers', function (editor) {
editor.setContent('<p>Something 123 ok</p>');
const result = editor.plugins.wordcount.getCount();
LegacyUnit.equal(result, 3);
});
suite.test('Does not count htmlentities', function (editor) {
editor.setContent('<p>It’s my life – – – don\'t you forget.</p>');
const result = editor.plugins.wordcount.getCount();
LegacyUnit.equal(result, 6);
});
suite.test('Counts hyphenated words as one word', function (editor) {
editor.setContent('<p>Hello some-word here.</p>');
const result = editor.plugins.wordcount.getCount();
LegacyUnit.equal(result, 3);
});
suite.test('Counts words between blocks as two words', function (editor) {
editor.setContent('<p>Hello</p><p>world</p>');
const result = editor.plugins.wordcount.getCount();
LegacyUnit.equal(result, 2);
});
suite.test('Counts words in table', function (editor) {
editor.setContent(`
<table style="width: 100%; border-collapse: collapse;" border="1">
<tbody>
<tr>
<td style="width: 50%;">a</td>
<td style="width: 50%;">b</td>
</tr>
</tbody>
</table>
`);
const result = editor.plugins.wordcount.getCount();
LegacyUnit.equal(result, 2);
});
TinyLoader.setup(function (editor, onSuccess, onFailure) {
Pipeline.async({}, suite.toSteps(editor), onSuccess, onFailure);
}, {
plugins: 'wordcount',
skin_url: '/project/js/tinymce/skins/lightgray'
}, success, failure);
});
示例8: Plugin
UnitTest.asynctest('browser.tinymce.plugins.wordcount.PluginTest', (success, failure) => {
Plugin();
Theme();
const sReset = function (tinyApis) {
return Logger.t('Reset content', GeneralSteps.sequence([
tinyApis.sSetContent(''),
sWaitForWordcount(0)
]));
};
const sAssertWordcount = function (num) {
return Logger.t(`Assert word count ${num}`, Step.sync(function () {
const countEl = DOMUtils.DOM.select('.tox-statusbar__wordcount')[0];
const value = countEl ? countEl.innerText : '';
Assertions.assertEq('wordcount', num + ' WORDS', value.toUpperCase());
}));
};
const sAssertContent = (tinyApis, expected) => {
return GeneralSteps.sequence(Log.steps('TBA', 'asserting contents after undo', [
tinyApis.sAssertContent(expected)
]));
};
const sWaitForWordcount = function (num) {
return Waiter.sTryUntil('wordcount did not change', sAssertWordcount(num), 100, 3000);
};
const sFakeTyping = function (editor, str) {
return Logger.t(`Fake typing ${str}`, Step.sync(function () {
editor.getBody().innerHTML = '<p>' + str + '</p>';
Keyboard.keystroke(Keys.space(), {}, TinyDom.fromDom(editor.getBody()));
}));
};
const sTestSetContent = function (tinyApis) {
return GeneralSteps.sequence(Log.steps('TBA', 'WordCount: Set test content and assert word count', [
sReset(tinyApis),
tinyApis.sSetContent('<p>hello world</p>'),
sWaitForWordcount(2)
]));
};
const sTestKeystroke = function (editor, tinyApis) {
return GeneralSteps.sequence(Log.steps('TBA', 'WordCount: Test keystroke and assert word count', [
sReset(tinyApis),
sFakeTyping(editor, 'a b c'),
sAssertWordcount(0),
sWaitForWordcount(3)
]));
};
const sExecCommand = function (editor, command) {
return Logger.t(`Execute ${command}`, Step.sync(function () {
editor.execCommand(command);
}));
};
const sTestUndoRedo = function (editor, tinyApis) {
return GeneralSteps.sequence(Log.steps('TBA', 'WordCount: Test undo and redo', [
sReset(tinyApis),
tinyApis.sSetContent('<p>a b c</p>'),
sWaitForWordcount(3),
sExecCommand(editor, 'undo'),
sAssertContent(tinyApis, ''),
sWaitForWordcount(0),
sExecCommand(editor, 'redo'),
sAssertContent(tinyApis, '<p>a b c</p>'),
sWaitForWordcount(3),
tinyApis.sSetRawContent('<p>hello world</p>'),
sExecCommand(editor, 'mceAddUndoLevel'),
sWaitForWordcount(2)
]));
};
TinyLoader.setup(function (editor, onSuccess, onFailure) {
const tinyApis = TinyApis(editor);
Pipeline.async({}, [
sTestSetContent(tinyApis),
sTestKeystroke(editor, tinyApis),
sTestUndoRedo(editor, tinyApis)
], onSuccess, onFailure);
}, {
plugins: 'wordcount',
theme: 'silver',
base_url: '/project/tinymce/js/tinymce'
}, success, failure);
});