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


TypeScript Editor.execCommand方法代码示例

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


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

示例1:

  editor.undoManager.transact(function () {
    if (editor.selection.isCollapsed() === false) {
      editor.execCommand('Delete');
    }

    InsertNewLine.insert(editor, event);
  });
开发者ID:mdgbayly,项目名称:tinymce,代码行数:7,代码来源:EnterKey.ts

示例2: function

    editor.on('focus', function () {
      if (!autoUrlDetectState) {
        autoUrlDetectState = true;

        try {
          editor.execCommand('AutoUrlDetect', false, true);
        } catch (ex) {
          // Ignore
        }
      }
    });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:11,代码来源:Keys.ts

示例3: setFocusedRange

          editor.undoManager.transact(function () {
            if (dropContent['mce-internal']) {
              editor.execCommand('Delete');
            }

            setFocusedRange(editor, rng);

            content = Utils.trimHtml(content);

            if (!dropContent['text/html']) {
              clipboard.pasteText(content);
            } else {
              clipboard.pasteHtml(content, internal);
            }
          });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:15,代码来源:DragDrop.ts

示例4: function

 return function () {
   editor.execCommand('mceToggleFormat', false, fmt);
 };
开发者ID:danielpunkass,项目名称:tinymce,代码行数:3,代码来源:FormatUtils.ts

示例5:

 editor.undoManager.transact(function () {
   firstTextNode.deleteData(0, pattern.start.length);
   editor.execCommand(pattern.cmd);
 });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:4,代码来源:PatternApplication.ts

示例6: function

 }, function () {
   editor.execCommand('mceInsertLink', false, url);
 });
开发者ID:abstask,项目名称:tinymce,代码行数:3,代码来源:SmartPaste.ts

示例7: function

export default function (editor: Editor) {
  let dom: DOMUtils, selection: Selection, formatter;
  const commands = { state: {}, exec: {}, value: {} };
  let settings = editor.settings,
    bookmark;

  editor.on('PreInit', function () {
    dom = editor.dom;
    selection = editor.selection;
    settings = editor.settings;
    formatter = editor.formatter;
  });

  /**
   * Executes the specified command.
   *
   * @method execCommand
   * @param {String} command Command to execute.
   * @param {Boolean} ui Optional user interface state.
   * @param {Object} value Optional value for command.
   * @param {Object} args Optional extra arguments to the execCommand.
   * @return {Boolean} true/false if the command was found or not.
   */
  const execCommand = function (command, ui, value, args) {
    let func, customCommand, state = false;

    if (editor.removed) {
      return;
    }

    if (!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint)$/.test(command) && (!args || !args.skip_focus)) {
      editor.focus();
    } else {
      SelectionBookmark.restore(editor);
    }

    args = editor.fire('BeforeExecCommand', { command, ui, value });
    if (args.isDefaultPrevented()) {
      return false;
    }

    customCommand = command.toLowerCase();
    if ((func = commands.exec[customCommand])) {
      func(customCommand, ui, value);
      editor.fire('ExecCommand', { command, ui, value });
      return true;
    }

    // Plugin commands
    each(editor.plugins, function (p) {
      if (p.execCommand && p.execCommand(command, ui, value)) {
        editor.fire('ExecCommand', { command, ui, value });
        state = true;
        return false;
      }
    });

    if (state) {
      return state;
    }

    // Theme commands
    if (editor.theme && editor.theme.execCommand && editor.theme.execCommand(command, ui, value)) {
      editor.fire('ExecCommand', { command, ui, value });
      return true;
    }

    // Browser commands
    try {
      state = editor.getDoc().execCommand(command, ui, value);
    } catch (ex) {
      // Ignore old IE errors
    }

    if (state) {
      editor.fire('ExecCommand', { command, ui, value });
      return true;
    }

    return false;
  };

  /**
   * Queries the current state for a command for example if the current selection is "bold".
   *
   * @method queryCommandState
   * @param {String} command Command to check the state of.
   * @return {Boolean/Number} true/false if the selected contents is bold or not, -1 if it's not found.
   */
  const queryCommandState = function (command) {
    let func;

    if (editor.quirks.isHidden() || editor.removed) {
      return;
    }

    command = command.toLowerCase();
    if ((func = commands.state[command])) {
      return func(command);
    }
//.........这里部分代码省略.........
开发者ID:danielpunkass,项目名称:tinymce,代码行数:101,代码来源:EditorCommands.ts

示例8: function

const insertLink = function (editor: Editor, url: string) {
  editor.execCommand('mceInsertLink', false, { href: url });
  collapseSelectionToEnd(editor);
};
开发者ID:abstask,项目名称:tinymce,代码行数:4,代码来源:Actions.ts

示例9: setTimeout

 setTimeout(() => { // detach
   editor.execCommand('Delete');
 }, 0);
开发者ID:danielpunkass,项目名称:tinymce,代码行数:3,代码来源:CutCopy.ts


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