本文整理汇总了TypeScript中tinymce/core/api/Editor.Editor.addMenuItem方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Editor.addMenuItem方法的具体用法?TypeScript Editor.addMenuItem怎么用?TypeScript Editor.addMenuItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tinymce/core/api/Editor.Editor
的用法示例。
在下文中一共展示了Editor.addMenuItem方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
const register = function (editor: Editor, pluginUrl: string, startedState: Cell<boolean>, textMatcherState: Cell<DomTextMatcher>, currentLanguageState: Cell<string>, lastSuggestionsState: Cell<LastSuggestion>) {
const languageMenuItems = buildMenuItems('Language', getItems(editor));
const startSpellchecking = function () {
Actions.spellcheck(editor, pluginUrl, startedState, textMatcherState, lastSuggestionsState, currentLanguageState);
};
const buttonArgs: any = {
tooltip: 'Spellcheck',
onclick: startSpellchecking,
onPostRender (e) {
const ctrl = e.control;
editor.on('SpellcheckStart SpellcheckEnd', function () {
ctrl.active(startedState.get());
});
}
};
if (languageMenuItems.length > 1) {
buttonArgs.type = 'splitbutton';
buttonArgs.menu = languageMenuItems;
buttonArgs.onshow = updateSelection(editor, currentLanguageState);
buttonArgs.onselect = function (e) {
currentLanguageState.set(e.control.settings.data);
};
}
editor.addButton('spellchecker', buttonArgs);
editor.addMenuItem('spellchecker', {
text: 'Spellcheck',
context: 'tools',
onclick: startSpellchecking,
selectable: true,
onPostRender () {
const self = this;
self.active(startedState.get());
editor.on('SpellcheckStart SpellcheckEnd', function () {
self.active(startedState.get());
});
}
});
};
示例2: onclick
const register = (editor: Editor, started: Cell<boolean>) => {
editor.addButton('restoredraft', {
title: 'Restore last draft',
onclick () {
Storage.restoreLastDraft(editor);
},
onPostRender: postRender(editor, started)
});
editor.addMenuItem('restoredraft', {
text: 'Restore last draft',
onclick () {
Storage.restoreLastDraft(editor);
},
onPostRender: postRender(editor, started),
context: 'file'
});
};
示例3: function
const register = function (editor: Editor, clipboard: Clipboard) {
const postRender = Fun.curry(stateChange, editor, clipboard);
editor.addButton('pastetext', {
active: false,
icon: 'pastetext',
tooltip: 'Paste as text',
cmd: 'mceTogglePlainTextPaste',
onPostRender: postRender
});
editor.addMenuItem('pastetext', {
text: 'Paste as text',
selectable: true,
active: clipboard.pasteFormat,
cmd: 'mceTogglePlainTextPaste',
onPostRender: postRender
});
};
示例4: function
Arr.each(menuItems, function (name) {
editor.addMenuItem(name, { text: name });
});
示例5: function
const addMenuItems = function (editor: Editor, selections: Selections) {
let targets = Option.none();
const tableCtrls = [];
const cellCtrls = [];
const mergeCtrls = [];
const unmergeCtrls = [];
const noTargetDisable = function (ctrl) {
ctrl.disabled(true);
};
const ctrlEnable = function (ctrl) {
ctrl.disabled(false);
};
const pushTable = function () {
const self = this;
tableCtrls.push(self);
targets.fold(function () {
noTargetDisable(self);
}, function (targets) {
ctrlEnable(self);
});
};
const pushCell = function () {
const self = this;
cellCtrls.push(self);
targets.fold(function () {
noTargetDisable(self);
}, function (targets) {
ctrlEnable(self);
});
};
const pushMerge = function () {
const self = this;
mergeCtrls.push(self);
targets.fold(function () {
noTargetDisable(self);
}, function (targets) {
self.disabled(targets.mergable().isNone());
});
};
const pushUnmerge = function () {
const self = this;
unmergeCtrls.push(self);
targets.fold(function () {
noTargetDisable(self);
}, function (targets) {
self.disabled(targets.unmergable().isNone());
});
};
const setDisabledCtrls = function () {
targets.fold(function () {
Arr.each(tableCtrls, noTargetDisable);
Arr.each(cellCtrls, noTargetDisable);
Arr.each(mergeCtrls, noTargetDisable);
Arr.each(unmergeCtrls, noTargetDisable);
}, function (targets) {
Arr.each(tableCtrls, ctrlEnable);
Arr.each(cellCtrls, ctrlEnable);
Arr.each(mergeCtrls, function (mergeCtrl) {
mergeCtrl.disabled(targets.mergable().isNone());
});
Arr.each(unmergeCtrls, function (unmergeCtrl) {
unmergeCtrl.disabled(targets.unmergable().isNone());
});
});
};
editor.on('init', function () {
editor.on('nodechange', function (e) {
const cellOpt = Option.from(editor.dom.getParent(editor.selection.getStart(), 'th,td'));
targets = cellOpt.bind(function (cellDom) {
const cell = Element.fromDom(cellDom);
const table = TableLookup.table(cell);
return table.map(function (table) {
return TableTargets.forMenu(selections, table, cell);
});
});
setDisabledCtrls();
});
});
const generateTableGrid = function () {
let html = '';
html = '<table role="grid" class="mce-grid mce-grid-border" aria-readonly="true">';
for (let y = 0; y < 10; y++) {
html += '<tr>';
for (let x = 0; x < 10; x++) {
html += '<td role="gridcell" tabindex="-1"><a id="mcegrid' + (y * 10 + x) + '" href="#" ' +
'data-mce-x="' + x + '" data-mce-y="' + y + '"></a></td>';
//.........这里部分代码省略.........