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


TypeScript Editor.setContent方法代码示例

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


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

示例1:

const restoreDraft = (editor: Editor) => {
  const prefix = Settings.getAutoSavePrefix(editor);

  if (hasDraft(editor)) {
    editor.setContent(LocalStorage.getItem(prefix + 'draft'), { format: 'raw' });
    Events.fireRestoreDraft(editor);
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:8,代码来源:Storage.ts

示例2: function

const applyToEditor = function (editor: Editor, level: UndoLevel, before: boolean) {
  if (level.type === UndoLevelType.Fragmented) {
    Fragments.write(level.fragments, editor.getBody());
  } else {
    editor.setContent(level.content, { format: 'raw' });
  }

  editor.selection.moveToBookmark(before ? level.beforeBookmark : level.bookmark);
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:9,代码来源:Levels.ts

示例3:

const deleteImage = (editor: Editor, image: HTMLElement) => {
  if (image) {
    const elm = editor.dom.is(image.parentNode, 'figure.image') ? image.parentNode : image;

    editor.dom.remove(elm);
    editor.focus();
    editor.nodeChanged();

    if (editor.dom.isEmpty(editor.getBody())) {
      editor.setContent('');
      editor.selection.setCursorLocation();
    }
  }
};
开发者ID:danielpunkass,项目名称:tinymce,代码行数:14,代码来源:ImageSelection.ts

示例4: function


//.........这里部分代码省略.........
    // Override commands to use the text formatter engine
    'Bold,Italic,Underline,Strikethrough,Superscript,Subscript' (command) {
      toggleFormat(command);
    },

    // Override commands to use the text formatter engine
    'ForeColor,HiliteColor' (command, ui, value) {
      toggleFormat(command, value);
    },

    'FontName' (command, ui, value) {
      FontCommands.fontNameAction(editor, value);
    },

    'FontSize' (command, ui, value) {
      FontCommands.fontSizeAction(editor, value);
    },

    'RemoveFormat' (command) {
      formatter.remove(command);
    },

    'mceBlockQuote' () {
      toggleFormat('blockquote');
    },

    'FormatBlock' (command, ui, value) {
      return toggleFormat(value || 'p');
    },

    'mceCleanup' () {
      const bookmark = selection.getBookmark();

      editor.setContent(editor.getContent());
      selection.moveToBookmark(bookmark);
    },

    'mceRemoveNode' (command, ui, value) {
      const node = value || selection.getNode();

      // Make sure that the body node isn't removed
      if (node !== editor.getBody()) {
        storeSelection();
        editor.dom.remove(node, true);
        restoreSelection();
      }
    },

    'mceSelectNodeDepth' (command, ui, value) {
      let counter = 0;

      dom.getParent(selection.getNode(), function (node) {
        if (node.nodeType === 1 && counter++ === value) {
          selection.select(node);
          return false;
        }
      }, editor.getBody());
    },

    'mceSelectNode' (command, ui, value) {
      selection.select(value);
    },

    'mceInsertContent' (command, ui, value) {
      InsertContent.insertAtCaret(editor, value);
    },
开发者ID:danielpunkass,项目名称:tinymce,代码行数:67,代码来源:EditorCommands.ts


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