当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Editor.addButton方法代码示例

本文整理汇总了TypeScript中tinymce/core/api/Editor.Editor.addButton方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Editor.addButton方法的具体用法?TypeScript Editor.addButton怎么用?TypeScript Editor.addButton使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tinymce/core/api/Editor.Editor的用法示例。


在下文中一共展示了Editor.addButton方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

const addToEditor = function (editor: Editor, panel: InlitePanel) {
  editor.addButton('quicklink', {
    icon: 'link',
    tooltip: 'Insert/Edit link',
    stateSelector: 'a[href]',
    onclick () {
      panel.showForm(editor, 'quicklink');
    }
  });

  editor.addButton('quickimage', {
    icon: 'image',
    tooltip: 'Insert image',
    onclick () {
      Picker.pickFile().then(function (files) {
        const blob = files[0];

        Conversions.blobToBase64(blob).then(function (base64) {
          Actions.insertBlob(editor, base64, blob);
        });
      });
    }
  });

  editor.addButton('quicktable', {
    icon: 'table',
    tooltip: 'Insert table',
    onclick () {
      panel.hide();
      Actions.insertTable(editor, 2, 2);
    }
  });

  addHeaderButtons(editor);
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:35,代码来源:Buttons.ts

示例2: 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());
      });
    }
  });
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:45,代码来源:Buttons.ts

示例3: 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'
  });
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:18,代码来源:Buttons.ts

示例4: 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
  });
};
开发者ID:abstask,项目名称:tinymce,代码行数:19,代码来源:Buttons.ts

示例5: prompt

    setup: (ed: Editor) => {
      ed.addButton('annotate-alpha', {
        text: 'Annotate',
        onclick: () => {
          const comment = prompt('Comment with?');
          ed.annotator.annotate('alpha', {
            comment
          });
          ed.focus();
        },

        onpostrender: (ctrl) => {
          const button = ctrl.control;
          ed.on('init', () => {
            ed.annotator.annotationChanged('alpha', (state, name, obj) => {
              if (! state) {
                button.active(false);
              } else {
                button.active(true);
              }
            });
          });
        }
      });

      ed.on('init', () => {
        ed.annotator.register('alpha', {
          persistent: true,
          decorate: (uid, data) => {
            return {
              attributes: {
                'data-mce-comment': data.comment
              }
            };
          }
        });

      });
    },
开发者ID:danielpunkass,项目名称:tinymce,代码行数:39,代码来源:AnnotationsDemo.ts

示例6: function

const addButtons = function (editor: Editor) {
  const menuItems = [];
  each('inserttable tableprops deletetable | cell row column'.split(' '), function (name) {
    if (name === '|') {
      menuItems.push({ text: '-' });
    } else {
      menuItems.push(editor.menuItems[name]);
    }
  });

  editor.addButton('table', {
    type: 'menubutton',
    title: 'Table',
    menu: menuItems
  });

  function cmd(command: string) {
    return function () {
      editor.execCommand(command);
    };
  }

  editor.addButton('tableprops', {
    title: 'Table properties',
    onclick: cmd('mceTableProps'),
    icon: 'table'
  });

  editor.addButton('tabledelete', {
    title: 'Delete table',
    onclick: cmd('mceTableDelete')
  });

  editor.addButton('tablecellprops', {
    title: 'Cell properties',
    onclick: cmd('mceTableCellProps')
  });

  editor.addButton('tablemergecells', {
    title: 'Merge cells',
    onclick: cmd('mceTableMergeCells')
  });

  editor.addButton('tablesplitcells', {
    title: 'Split cell',
    onclick: cmd('mceTableSplitCells')
  });

  editor.addButton('tableinsertrowbefore', {
    title: 'Insert row before',
    onclick: cmd('mceTableInsertRowBefore')
  });

  editor.addButton('tableinsertrowafter', {
    title: 'Insert row after',
    onclick: cmd('mceTableInsertRowAfter')
  });

  editor.addButton('tabledeleterow', {
    title: 'Delete row',
    onclick: cmd('mceTableDeleteRow')
  });

  editor.addButton('tablerowprops', {
    title: 'Row properties',
    onclick: cmd('mceTableRowProps')
  });

  editor.addButton('tablecutrow', {
    title: 'Cut row',
    onclick: cmd('mceTableCutRow')
  });

  editor.addButton('tablecopyrow', {
    title: 'Copy row',
    onclick: cmd('mceTableCopyRow')
  });

  editor.addButton('tablepasterowbefore', {
    title: 'Paste row before',
    onclick: cmd('mceTablePasteRowBefore')
  });

  editor.addButton('tablepasterowafter', {
    title: 'Paste row after',
    onclick: cmd('mceTablePasteRowAfter')
  });

  editor.addButton('tableinsertcolbefore', {
    title: 'Insert column before',
    onclick: cmd('mceTableInsertColBefore')
  });

  editor.addButton('tableinsertcolafter', {
    title: 'Insert column after',
    onclick: cmd('mceTableInsertColAfter')
  });

  editor.addButton('tabledeletecol', {
    title: 'Delete column',
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:Buttons.ts


注:本文中的tinymce/core/api/Editor.Editor.addButton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。