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


TypeScript Editor.addMenuItem方法代码示例

本文整理汇总了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());
      });
    }
  });
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:45,代码来源:Buttons.ts

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

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

示例4: function

 Arr.each(menuItems, function (name) {
   editor.addMenuItem(name, { text: name });
 });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:3,代码来源:MenubarTest.ts

示例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>';
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:MenuItems.ts


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