Simditor Modify indent leading line indent

Source: Internet
Author: User

The default text indent behavior in Simditor is handled using the Margin-left style, so if the text is too long to fold, it is indented backwards together. This is not very good for displaying Chinese documents, so some simditor code has been modified to achieve the first line indent function.

The specific steps are as follows:

First modify some HTML tags so that they allow the use of the text-indent style, the code in the formatter _init method

-      P: [' Margin-left ', ' text-align '],
-      H1: [' margin-left ', ' text-align '],
-      h2: [' margin-left ', ' Text-align '],
-      h3: [' Margin-left ', ' text-align '],
-      h4: [' margin-left ', ' text-align ']
+      P: [' Margin-left ', ' text-align ', ' text-indent '],
+      H1: [' margin-left ', ' text-align ', ' text-indent '],
+      h2: [' margin-left ', ' text-align ', ' text-indent '],
+      h3: [' Margin-left ', ' text-align ', ' text-indent ' ],
+      h4: [' margin-left ', ' text-align ', ' text-indent ']

Modify the indentation Indentblock method to replace the margin-left used in the Text-indent

-      marginleft = parseint ($blockEl. css (' margin-left ')) | | 0;
-      MarginLeft = (Math.Round (marginleft/this.opts.indentwidth) + 1) * this.opts.indentWidth;
-      $blockEl. CSS (' margin-left ', marginleft);
+      $blockEl. css (' text-indent ', ' 32px ');

Modify the indentation Outdentblock method to replace the margin-left used in the Text-indent

-      marginleft = parseint ($blockEl. css (' margin-left ')) | | 0;
-      marginleft = Math.max (Math.Round (marginleft/this.opts.indentwidth)-1, 0) * this.opts.indentWidth;
-      $blockEl. CSS (' margin-left ', marginleft = = 0?) ": marginleft);
+      $blockEl. css (' text-indent ', ' 0px ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.