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


TypeScript Editor.getDoc方法代码示例

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


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

示例1: function

  editor.on('paste', function (e) {
    // Getting content from the Clipboard can take some time
    const clipboardTimer = new Date().getTime();
    const clipboardContent = getClipboardContent(editor, e);
    const clipboardDelay = new Date().getTime() - clipboardTimer;

    const isKeyBoardPaste = (new Date().getTime() - keyboardPasteTimeStamp - clipboardDelay) < 1000;
    const plainTextMode = pasteFormat.get() === 'text' || keyboardPastePlainTextState;
    let internal = hasContentType(clipboardContent, InternalHtml.internalHtmlMime());

    // Reset ephemeral flags
    pasteFormat.set(undefined);
    keyboardPastePlainTextState = false;

    if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) {
      pasteBin.remove();
      return;
    }

    if (!hasHtmlOrText(clipboardContent) && pasteImageData(editor, e, getLastRng())) {
      pasteBin.remove();
      return;
    }

    // Not a keyboard paste prevent default paste and try to grab the clipboard contents using different APIs
    if (!isKeyBoardPaste) {
      e.preventDefault();
    }

    // Try IE only method if paste isn't a keyboard paste
    if (Env.ie && (!isKeyBoardPaste || e.ieFake) && !hasContentType(clipboardContent, 'text/html')) {
      pasteBin.create();

      editor.dom.bind(pasteBin.getEl(), 'paste', function (e) {
        e.stopPropagation();
      });

      editor.getDoc().execCommand('Paste', false, null);
      clipboardContent['text/html'] = pasteBin.getHtml();
    }

    // If clipboard API has HTML then use that directly
    if (hasContentType(clipboardContent, 'text/html')) {
      e.preventDefault();

      // if clipboard lacks internal mime type, inspect html for internal markings
      if (!internal) {
        internal = InternalHtml.isMarked(clipboardContent['text/html']);
      }

      insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
    } else {
      // Since we never use the pastebin on Red Sweater branch, we want to prevent the default in both cases
      // to avoid a double-paste behavior.
      e.preventDefault();
      Delay.setEditorTimeout(editor, function () {
        insertClipboardContent(clipboardContent, isKeyBoardPaste, plainTextMode, internal);
      }, 0);
    }
  });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:60,代码来源:Clipboard.ts

示例2: function

const appendStyle = function (editor: Editor, text: string) {
  const head = Element.fromDom(editor.getDoc().head);
  const tag = Element.fromTag('style');
  Attr.set(tag, 'type', 'text/css');
  Insert.append(tag, Element.fromText(text));
  Insert.append(head, tag);
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:7,代码来源:InitContentBody.ts

示例3: catch

const setEditorCommandState = (editor: Editor, cmd: string, state: boolean) => {
  try {
    editor.getDoc().execCommand(cmd, false, state);
  } catch (ex) {
    // Ignore
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:7,代码来源:Mode.ts

示例4: function

 const disableGeckoResize = function () {
   try {
     // Disable object resizing on Gecko
     editor.getDoc().execCommand('enableObjectResizing', false, false);
   } catch (ex) {
     // Ignore
   }
 };
开发者ID:danielpunkass,项目名称:tinymce,代码行数:8,代码来源:ControlSelection.ts

示例5: function

  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;
  };
开发者ID:danielpunkass,项目名称:tinymce,代码行数:58,代码来源:EditorCommands.ts

示例6: function

  editor.on('renderFormatsMenu', function (e) {
    const globallyUniqueSelectors = {};
    const selectorFilter = compileFilter(Settings.getSelectorFilter(editor)), ctrl = e.control;
    const groups = compileUserDefinedGroups(Settings.getCssGroups(editor));

    const processSelector = function (selector: string, group: StyleGroup) {
      if (isUniqueSelector(editor, selector, group, globallyUniqueSelectors)) {
        markUniqueSelector(editor, selector, group, globallyUniqueSelectors);

        const format = convertSelectorToFormat(editor, editor.plugins.importcss, selector, group);
        if (format) {
          const formatName = format.name || DOMUtils.DOM.uniqueId();
          editor.formatter.register(formatName, format);

          return Tools.extend({}, ctrl.settings.itemDefaults, {
            text: format.title,
            format: formatName
          });
        }
      }

      return null;
    };

    if (!Settings.shouldAppend(editor)) {
      ctrl.items().remove();
    }

    Tools.each(getSelectors(editor, e.doc || editor.getDoc(), compileFilter(Settings.getFileFilter(editor))), function (selector: string) {
      if (selector.indexOf('.mce-') === -1) {
        if (!selectorFilter || selectorFilter(selector)) {
          const selectorGroups = getGroupsBySelector(groups, selector);

          if (selectorGroups.length > 0) {
            Tools.each(selectorGroups, function (group) {
              const menuItem = processSelector(selector, group);
              if (menuItem) {
                group.item.menu.push(menuItem);
              }
            });
          } else {
            const menuItem = processSelector(selector, null);
            if (menuItem) {
              ctrl.add(menuItem);
            }
          }
        }
      }
    });

    Tools.each(groups, function (group) {
      if (group.item.menu.length > 0) {
        ctrl.add(group.item);
      }
    });

    e.control.renderNew();
  });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:58,代码来源:ImportCss.ts

示例7: execute

 table.bind(function (table) {
   const doc = Element.fromDom(editor.getDoc());
   const generators = TableFill.paste(doc);
   const targets = TableTargets.pasteRows(selections, table, cell, clonedRows, generators);
   execute(table, targets).each(function (rng) {
     editor.selection.setRng(rng);
     editor.focus();
     cellSelection.clear(table);
   });
 });
开发者ID:danielpunkass,项目名称:tinymce,代码行数:10,代码来源:Commands.ts

示例8: function

const getEventTarget = function (editor: Editor, eventName: string): Node {
  if (eventName === 'selectionchange') {
    return editor.getDoc();
  }

  // Need to bind mousedown/mouseup etc to document not body in iframe mode
  // Since the user might click on the HTML element not the BODY
  if (!editor.inline && /^mouse|touch|click|contextmenu|drop|dragover|dragend/.test(eventName)) {
    return editor.getDoc().documentElement;
  }

  // Bind to event root instead of body if it's defined
  if (editor.settings.event_root) {
    if (!editor.eventRoot) {
      editor.eventRoot = DOM.select(editor.settings.event_root)[0];
    }

    return editor.eventRoot;
  }

  return editor.getBody();
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:22,代码来源:EditorObservable.ts


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