无干扰模式使编辑器以内联模式呈现,不显示菜单栏或工具栏。大多数编辑器功能可通过以下方式访问:键盘快捷键、上下文菜单、上下文工具栏以及由quickbars插件提供的工具栏功能。

此选项在移动设备上不受支持。

启用无干扰模式

要启用基础的无干扰编辑器,请使用以下配置。

tinymce.init({
  selector: 'div.tinymce',
  plugins: [ 'quickbars' ],
  toolbar: false,
  menubar: false,
  inline: true
});

下方演示编辑器为经部分自定义的无干扰编辑器。

HTML

<div class='demo-dfree'>
  <h2 class="dfree-header mce-content-body" contenteditable="true" style="position: relative;" spellcheck="false">
    The latest and greatest from TinyMCE
  </h2>
  <br/>
  <div class="dfree-body mce-content-body" contenteditable="true" style="position: relative;" spellcheck="false">
    <p><img src="https://www.tiny.cloud/images/medium-pic.jpg" style="display: block; margin-left: auto; margin-right: auto; width: 100%;"></p>
    <br/>
    <h2>The world’s first rich text editor in the cloud</h2>

    <p>
      Have you heard about Tiny Cloud?
      It’s the first step in our journey to help you deliver great content creation experiences, no matter your level of expertise.
      50,000 developers already agree.
      They get free access to our global CDN, image proxy services and auto updates to the TinyMCE editor.
      They’re also ready for some exciting updates coming soon.
    </p>

    <p>
      One of these enhancements is <strong>Tiny Drive</strong>: imagine file management for TinyMCE, in the cloud, made super easy.
      Learn more at <a href='https://www.tiny.cloud/drive/'>tiny.cloud/drive/</a>, where you’ll find a working demo and an opportunity to provide feedback to the product team.
    </p>

    <h3>An editor for every project</h3>

    <p>
      Here are some of our customer’s most common use cases for TinyMCE:
      <ul>
        <li>Content Management Systems (<em>e.g. WordPress, Umbraco</em>)</li>
        <li>Learning Management Systems (<em>e.g. Blackboard</em>)</li>
        <li>Customer Relationship Management and marketing automation (<em>e.g. Marketo</em>)</li>
        <li>Email marketing (<em>e.g. Constant Contact</em>)</li>
        <li>Content creation in SaaS systems (<em>e.g. Eventbrite, Evernote, GoFundMe, Zendesk</em>)</li>
      </ul>
    </p>

    <p>
      And those use cases are just the start.
      TinyMCE is incredibly flexible, and with hundreds of APIs there’s likely a solution for your editor project.
      If you haven’t experienced Tiny Cloud, get started today.
      You’ll even get a free trial of our premium plugins – no credit card required!
    </p>
  </div>
</div>

CSS

.demo-dfree {
  position: relative;
  box-shadow: 0px 2px 8px 0px rgba(0, 0, 0, 0.2);
  text-align: left;
  color: #626262;
  font-size: 14px;
  padding: 20px;
}
.demo-dfree *[contentEditable="true"]:hover {
  outline: 1px solid #1976D2;
}
.demo-dfree h1 {
  color: #1976D2;
  font-size: 2em;
}
.demo-dfree h2 {
  color: #1976D2;
  font-size: 2em;
}
.demo-dfree h3 {
  font-size: 1.5em;
  color: #403f42;
  color: inherit;
}
.demo-dfree h2,
.demo-dfree h3 {
  margin-bottom: 0px;
  margin-top: 0px;
  line-height: 40px;
}
.demo-dfree ul,
.demo-dfree ol {
  padding-left: 20px;
}
.demo-dfree ul {
  list-style: disc;
}
.demo-dfree ol {
  list-style: decimal;
}
.demo-dfree a {
  text-decoration: underline;
}
.demo-dfree textarea {
  display: none;
}
.demo-dfree .dfree-header {
  font-size: 2.4em;
  text-align: center;
  margin: 10px;
}
.demo-dfree .dfree-body {
  padding: 20px;
  padding-top: 0px;
}
.demo-dfree .dfree-body p {
  margin-bottom: 10px;
}
.demo-dfree .dfree-body blockquote {
  margin-left: 30px;
  padding-left: 10px;
  margin-right: 40px;
  font-style: italic;
  border-left: 1px solid #696969;
}
.demo-dfree .dfree-body a {
  text-decoration: underline;
}
.demo-dfree .dfree-body td,
.demo-dfree .dfree-body tr {
  border: 1px solid #696969;
}

JS

const dfreeHeaderConfig = {
  selector: '.dfree-header',
  menubar: false,
  inline: true,
  toolbar: false,
  plugins: [ 'quickbars' ],
  quickbars_insert_toolbar: 'undo redo',
  quickbars_selection_toolbar: 'italic underline',
};

const dfreeBodyConfig = {
  selector: '.dfree-body',
  menubar: false,
  inline: true,
  plugins: [
    'autolink', 'codesample', 'link', 'lists',
    'media', 'powerpaste', 'table', 'image',
    'quickbars', 'codesample', 'help'
  ],
  toolbar: false,
  quickbars_insert_toolbar: 'quicktable image media codesample',
  quickbars_selection_toolbar: 'bold italic underline | blocks | blockquote quicklink',
  contextmenu: 'undo redo | inserttable | cell row column deletetable | help',
  powerpaste_word_import: 'clean',
  powerpaste_html_import: 'clean',
};

tinymce.init(dfreeHeaderConfig);
tinymce.init(dfreeBodyConfig);

相关配置选项

有关以下内容的信息: