|
@@ -192,8 +192,6 @@ import {createBottomHref} from "./utils/common"
|
|
|
frontH1Posiiton = this.addDocForm.Content.indexOf('<h1',searchPosition)
|
|
|
// 右闭合标签
|
|
|
frontH1RightPosiiton = this.addDocForm.Content.indexOf('>',frontH1Posiiton)
|
|
|
- // 对应的</h1>的位置 原本用的</h1>,后来发现> 和 </h1>之间会掺其他标签
|
|
|
- backH1Posiiton = this.addDocForm.Content.indexOf('<',frontH1RightPosiiton)
|
|
|
|
|
|
if(frontH1Posiiton == -1) return
|
|
|
|
|
@@ -201,6 +199,10 @@ import {createBottomHref} from "./utils/common"
|
|
|
// console.log(frontH1Posiiton,firstLevel,'firstLevel');
|
|
|
this.addDocForm.Content = this.addDocForm.Content.substring(0, frontH1Posiiton+3)
|
|
|
+" "+anchorText + this.addDocForm.Content.substring(frontH1RightPosiiton);
|
|
|
+ // 再次获取右闭合标签
|
|
|
+ frontH1RightPosiiton = this.addDocForm.Content.indexOf('>',frontH1Posiiton)
|
|
|
+ // 对应的</h1>的位置 原本用的</h1>,后来发现> 和 </h1>之间会掺其他标签
|
|
|
+ backH1Posiiton = this.addDocForm.Content.indexOf('<',frontH1RightPosiiton)
|
|
|
// 获取标题
|
|
|
let AnchorTitle = this.addDocForm.Content.substring(frontH1RightPosiiton+1,backH1Posiiton)
|
|
|
|
|
@@ -219,13 +221,16 @@ import {createBottomHref} from "./utils/common"
|
|
|
while (!(H2Posiiton==-1 || H2Posiiton>nextH1Posiiton)) {
|
|
|
// 右闭合标签
|
|
|
H2RightPosiiton = this.addDocForm.Content.indexOf('>',H2Posiiton)
|
|
|
- // 对应的</h2>的位置 原本用的</h2>,后来发现> 和 </h2>之间会掺其他标签
|
|
|
- backH2Posiiton = this.addDocForm.Content.indexOf('<',H2RightPosiiton)
|
|
|
+
|
|
|
// 找到了,并且位置小于下一个h1的位置
|
|
|
let anchorTextH2=`id="doc_anchor_${firstLevel}_${secondLevel}"`
|
|
|
// console.log(H2Posiiton,secondLevel,'secondLevel');
|
|
|
this.addDocForm.Content = this.addDocForm.Content.substring(0, H2Posiiton+3)
|
|
|
+" "+anchorTextH2 + this.addDocForm.Content.substring(H2RightPosiiton);
|
|
|
+ // 再次获取右闭合标签
|
|
|
+ H2RightPosiiton = this.addDocForm.Content.indexOf('>',H2Posiiton)
|
|
|
+ // 对应的</h2>的位置 原本用的</h2>,后来发现> 和 </h2>之间会掺其他标签
|
|
|
+ backH2Posiiton = this.addDocForm.Content.indexOf('<',H2RightPosiiton)
|
|
|
// 获取标题
|
|
|
let AnchorTitleLevelTwo = this.addDocForm.Content.substring(H2RightPosiiton+1,backH2Posiiton)
|
|
|
this.anchorData[firstLevel-1].Child.push(
|