返回介绍

Table of Contents plugin

发布于 2019-05-06 06:50:38 字数 2537 浏览 965 评论 0 收藏 0

toc plugin will generate basic Table of Contents and insert it into the editor at the current cursor position. Items for the table will be taken from the headers found in the content.

Type: String

Example
tinymce.init({
  selector: "textarea",  // change this value according to your HTML
  plugins: "toc",
  toolbar: "toc",
  menubar: "insert"
});

Table of Contents will have a simple HTML structure - a wrapper div element, a header with editable title and unordered nested list with navigation links. Nesting depth is customisable.

Internally plugin doesn’t apply any inline styles. Basic formatting can be added via Boilerplate Content CSS, that can be customised to your needs.

/* Basic styles for Table of Contents plugin (toc) */
.mce-toc {
	border: 1px solid gray;
}

.mce-toc h2 {
	margin: 4px;
}

.mce-toc li {
	list-style-type: none;
}

Options

toc_depth

By default headers in the content will be inspected only three levels deep, so - H1 through H3. But it is possible to change this behaviour by setting toc_depth to any number in 1-9 range, therefore matching all the headers beginning with H1 and all the way down to H9.

Type: Number

Default Value: 3

Example
tinymce.init({
  selector: "textarea",
  plugins: "toc",
  toolbar: "toc",
  toc_depth: 3
});

toc_header

Table of contents has a header and by default it will be marked up with H2 tag. With toc_header option you can change it to some other tag.

Type: String

Default Value: H2

Example
tinymce.init({
  selector: "textarea",
  plugins: "toc",
  toolbar: "toc",
  toc_header: "div" // case doesn't matter
});

toc_class

With toc_class you can change the class name that gets assigned to the wrapper div. Please note that you will have to alter Boilerplate Content CSS) accordingly.

Type: String

Default Value: mce-toc

Example
tinymce.init({
  selector: "textarea",
  plugins: "toc",
  toolbar: "toc",
  toc_class: "our-toc"
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文