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 ');