lsiten 6 anni fa
parent
commit
b2b1eafe3f
5 ha cambiato i file con 318 aggiunte e 122 eliminazioni
  1. 3 29
      src/data.json
  2. 10 0
      src/js/util/question.js
  3. 1 1
      src/js/util/util.js
  4. 267 88
      src/js/yzPage.js
  5. 37 4
      src/js/yzPageManager.js

+ 3 - 29
src/data.json

@@ -6,15 +6,15 @@
 	"layoutType": "2",
 	"sourceType": "2",
 	"prohibitType": "1",
-	"noMode": "1",
+	"noMode": "2",
 	"noCount": "9",
 	"noBoth": "0",
 	"qrCode": "cm",
 	"alias": "test-lsiten 高二 语文",
 	"cardJson": null,
 	"cardHtml": "",
-		"attention": null,
-	"examPageCnt": "102",
+	"attention": null,
+	"examPageCnt": "1",
 	"pageQus": [{
 		"sort": "1",
 		"attribute": null,
@@ -146,31 +146,5 @@
 				"rIndex": "0"
 			}]
 		}]
-	}, {
-		"sort": "5",
-		"attribute": null,
-		"content": null,
-		"annexable": "1",
-		"group": "0",
-		"pIndex": "1-2",
-		"pros": [{
-			"proId": "857",
-			"score": 60.0,
-			"pureObjective": "2",
-			"content": "",
-			"sort": "5",
-			"pnum": "",
-			"group": "0",
-			"qus": [{
-				"quId": "1413",
-				"score": 60.0,
-				"quType": "作文题",
-				"nums": null,
-				"content": "",
-				"pnum": "6",
-				"visible": true,
-				"rIndex": "0"
-			}]
-		}]
 	}]
 }

+ 10 - 0
src/js/util/question.js

@@ -61,6 +61,9 @@ questionUtils.prototype = {
         }
       }
     }
+    if (isEmptyElement($border[0])) {
+      $border.remove();
+    }
     if ($nextBorder.childNodes().length > 0) {
       $nextBorder[0].firstChild.style.borderTop = 'none';
       return $nextBorder;
@@ -178,6 +181,13 @@ questionUtils.prototype = {
             if (borderSize.bottom >= csize.bottom) {
               this.insertDom($nextContent, $line);
             }
+          } else if (line.className.indexOf('js-lsiten-options-box') > -1) {
+            // 选作题组
+            let $line = $(line);
+            let borderSize = $border.getSizeData();
+            if (borderSize.bottom >= csize.bottom) {
+              this.insertDom($nextContent, $line);
+            }
           } else if (line.className.indexOf('js-lsiten-question') > -1) {
             let $line = $(line);
             let questionType = parseInt($line.attr('data-type'));

+ 1 - 1
src/js/util/util.js

@@ -86,7 +86,7 @@ export function getParentNodeByClass (enode, className) {
   }
 }
 export function getParentByClassname($el, classname) {
-    if (!$el) {
+    if (!$el || !$el.length) {
       return null;
     }
     if ($el.getNodeName().toLowerCase() === 'body' ) {

+ 267 - 88
src/js/yzPage.js

@@ -277,11 +277,41 @@ yzPage.prototype = {
           }
           nextColumn.page._checkColumnOut(nextColumn.column);
           // 跨栏符检测
-          this._updateCrossColumn(nextColumn.column);          
+          this._updateCrossColumn(nextColumn.column);
+          this._updateObjectColumnHeight(nextColumn.column[0]);       
         }
         // 跨栏符检测
         this._updateCrossColumn($column);
       }
+
+
+     
+  },
+  /**
+   * function 更新客观题栏高
+   */
+  _updateObjectColumnHeight: function (checkColumn) {
+     let cententHeight = 0;
+     let contentIndex = 0;
+     let updateNextPara = this._cycleFindParagraph(checkColumn.firstChild);
+     if (updateNextPara) {
+       $(updateNextPara).find('.js-option-column').forEach(column => {
+         let contentSize = $(column.firstChild).getSizeData();
+         if (contentIndex === 0) {
+           cententHeight = contentSize.height;
+         }
+         $(column).css('min-height', cententHeight + 'px');
+         contentIndex++;
+       });
+       // 更新栏高 结束    
+       let rowIndex = 0;
+       $(updateNextPara).find('.js-options-row').forEach(row => {
+         if (rowIndex > 0) {
+           $(row).css('border-top', '1px solid #000');
+         }
+         rowIndex++;
+       })
+     }
   },
   /**
    * function 插入段落
@@ -329,10 +359,41 @@ yzPage.prototype = {
         let nextBorderId = firstFirst.getAttribute('data-id');
         if (borderId === nextBorderId) {
           // 如果两个框是同一个框
-          let insertLastQuestion = insertLast.firstChild.lastChild;
-          let firstFirstQuestion = firstFirst.firstChild.firstChild;
-          this._mergeSplitBorder(insertLastQuestion, firstFirstQuestion, $(insertLast));
-          this._insertDomBeforeByFirst($Allparagraph, firstFirst);
+          let borderType = parseInt(firstFirst.getAttribute('data-type'));
+          if (borderType === 1) {
+            let objectLastRow = insertLast.lastChild;
+            let objectFirstRow = firstFirst.firstChild;
+            let lastRowId = objectLastRow.getAttribute('data-id');
+            let firstRowId = objectFirstRow.getAttribute('data-id');
+            if (lastRowId === firstRowId) {
+              let lastRowColumns = $(objectLastRow).find('.js-option-column');
+              let firstRowColumns = $(objectFirstRow).find('.js-option-column');
+              let rowColumnLength = lastRowColumns.length;
+              for (let rowColumnIndex = 0; rowColumnIndex < rowColumnLength; rowColumnIndex++) {
+                if (firstRowColumns[rowColumnIndex].firstChild && firstRowColumns[rowColumnIndex].firstChild.firstChild) {
+                  this._insertDomBeforeByFirst($(lastRowColumns[rowColumnIndex].firstChild), firstRowColumns[rowColumnIndex].firstChild.firstChild);
+                } else {
+                  if (lastRowColumns[rowColumnIndex].firstChild && firstRowColumns[rowColumnIndex].firstChild) {
+                    let lastRowColumnsChilds = $(lastRowColumns[rowColumnIndex].firstChild).childNodes();
+                    let lastRowColumnsChildsIndex = lastRowColumnsChilds.length - 1;
+                    while(lastRowColumnsChildsIndex >= 0) {
+                      firstRowColumns[rowColumnIndex].firstChild.appendChild(lastRowColumnsChilds[lastRowColumnsChildsIndex]);
+                      lastRowColumnsChildsIndex--;
+                    }
+                  }
+                }
+              }
+              $(objectLastRow).remove();
+              this._insertDomBeforeByFirst($(insertLast), objectFirstRow);
+            } else {
+              this._insertDomBeforeByFirst($(insertLast), objectFirstRow);
+            }
+          } else {
+            let insertLastQuestion = insertLast.firstChild.lastChild;
+            let firstFirstQuestion = firstFirst.firstChild.firstChild;
+            this._mergeSplitBorder(insertLastQuestion, firstFirstQuestion, $(insertLast));
+            this._insertDomBeforeByFirst($Allparagraph, firstFirst);
+          }
         } else {
           // 如果不是同一个框
           this._insertDomBeforeByFirst($Allparagraph, firstFirst);               
@@ -360,7 +421,11 @@ yzPage.prototype = {
     }
     if (lQuestion.className && lQuestion.className.indexOf('js-lsiten-line') > -1) {
       // 普通行处理
-      this._insertDomBeforeByFirst($Allborder, fQuestion);
+      this._insertDomBeforeByFirst($($Allborder[0].firstChild), fQuestion);
+      $Allborder.remove();
+    } else if (lQuestion.className && lQuestion.className.indexOf('js-lsiten-options-box') > -1) {
+      // 选作题组
+      this._insertDomBeforeByFirst($($Allborder[0].firstChild), fQuestion);
       $Allborder.remove();
     } else if (lQuestion.className && lQuestion.className.indexOf('js-lsiten-question') > -1) {
       // 主观题才需要合并
@@ -481,9 +546,17 @@ yzPage.prototype = {
       // 如果有下一页,进行检测
       if (nextColumn.column) {
         let $nextParagraphs = nextColumn.column.find('.js-paragraph-view');
-        while (i >=0 ) {
-          if ($nextParagraphs[i]) {
-            let $paragraph = $($nextParagraphs[i]);
+        let j = 0;
+        let nextParagraphLength = $nextParagraphs.length || 0;
+        while (j < nextParagraphLength) {
+          if (j > 0) {
+            let prevIndex = j - 1;
+            if ($nextParagraphs[prevIndex] && !isEmptyElement($nextParagraphs[prevIndex]) && !this.isHeadParagraph($($nextParagraphs[prevIndex]))) {
+              return true;
+            }
+          }
+          if ($nextParagraphs[j]) {
+            let $paragraph = $($nextParagraphs[j]);
             if ($paragraph && !this.isHeadParagraph($paragraph)) {
               let pSize = $paragraph.getSizeData();
               if (pSize.height < diff) {
@@ -496,11 +569,11 @@ yzPage.prototype = {
               }
             }
           }
-          i--;
+          j++;
         }
         let lastPid = $lastParagraph.attr('data-index');
         let lastBorderItem = $lastParagraph[0].lastChild;
-        let lastIsBorder = lastBorderItem.className && lastBorderItem.className.indexOf('js-lsiten-border') > -1;
+        let lastIsBorder = lastBorderItem && lastBorderItem.className && lastBorderItem.className.indexOf('js-lsiten-border') > -1;
         $moves.forEach($paragraphITem => {
           let currentPid = $paragraphITem.attr('data-index');
           if (lastPid === currentPid) {
@@ -578,6 +651,9 @@ yzPage.prototype = {
                             } else {
                               lastBorderItem.firstChild.appendChild(borderItem);
                             }
+                          } else if (itemClass && itemClass.indexOf('js-lsiten-options-box') > -1) {
+                            // 选作题组【回退】
+                            lastBorderItem.firstChild.appendChild(borderItem);
                           } else if (borderItem.className.indexOf('js-lsiten-line') > -1) {
                             lastBorderItem.firstChild.appendChild(borderItem);
                           } else {
@@ -640,7 +716,14 @@ yzPage.prototype = {
               }
             } else if (itemClass && itemClass.indexOf('js-lsiten-border') > -1) {
               // 框处理
-              this._prevBorder($prevParagraph, size, $item, $lastParagraph, true);
+              let borderType = parseInt($item.attr('data-type'));
+              if (borderType === 1) {
+                // 客观题处理
+                this._prevObjectBorder($prevParagraph, size, $item, $lastParagraph, true);                
+              } else if (borderType === 2) {
+                // 主观观题处理                
+                this._prevBorder($prevParagraph, size, $item, $lastParagraph, true);
+              }
             } else {
               $item.remove();
             }
@@ -663,7 +746,13 @@ yzPage.prototype = {
               }
             } else if (itemClass && itemClass.indexOf('js-lsiten-border') > -1) {
               // 框处理
-              this._prevBorder($prevParagraph, size, $item, $lastParagraph, false);
+              let borderType = parseInt($item.attr('data-type'));
+              if (borderType === 1) {
+                // 客观题处理
+                this._prevObjectBorder($prevParagraph, size, $item, $lastParagraph, false);                
+              } else if (borderType === 2) {
+                this._prevBorder($prevParagraph, size, $item, $lastParagraph, false);
+              }
             } else {
               $item.remove();
             }
@@ -691,7 +780,13 @@ yzPage.prototype = {
             }
           } else if (itemClass && itemClass.indexOf('js-lsiten-border') > -1) {
             // 框处理
-            this._prevBorder($prevParagraph, size, $item, $lastParagraph, false);
+            let borderType = parseInt($item.attr('data-type'));
+            if (borderType === 1) {
+              // 客观题处理
+              this._prevObjectBorder($prevParagraph, size, $item, $lastParagraph, false);                
+            } else if (borderType === 2) {
+              this._prevBorder($prevParagraph, size, $item, $lastParagraph, false);
+            }
           } else {
             $item.remove();
           }
@@ -703,7 +798,28 @@ yzPage.prototype = {
       }
     }
   },
-
+/**
+   * function 处理需要上移的框
+   * @param {DomElement} $prevParagraph 前移段落暂存
+   * @param {object} size 可移空间
+   * @param {DomElement} $border 需要处理的框
+   * @param {DomElement} $lastParagraph 最后一段dom
+   * @param {boolean} 是否需要合并
+   */
+  _prevObjectBorder: function ($prevParagraph, size, $border, $lastParagraph, isMerge) {
+    let lastCentent = $lastParagraph[0].lastChild;
+    if (lastCentent && lastCentent.className && lastCentent.className.indexOf('js-lsiten-border') > -1) {
+      let prevBid = $border.attr('data-id');
+      let bid = $(lastCentent).attr('data-id');
+      if (prevBid === bid) {
+        let $prevBorder = $border.clone(false);
+        if (isMerge) {
+          $prevBorder = $($prevParagraph[0].lastChild);
+          
+        }
+      }
+    }
+  },
   /**
    * function 处理需要上移的框
    * @param {DomElement} $prevParagraph 前移段落暂存
@@ -714,7 +830,7 @@ yzPage.prototype = {
    */
   _prevBorder: function ($prevParagraph, size, $border, $lastParagraph, isMerge) {   
     let lastCentent = $lastParagraph[0].lastChild;
-    if (lastCentent.className && lastCentent.className.indexOf('js-lsiten-border') > -1) {
+    if (lastCentent && lastCentent.className && lastCentent.className.indexOf('js-lsiten-border') > -1) {
       let prevBid = $border.attr('data-id');
       let bid = $(lastCentent).attr('data-id');
       if (prevBid === bid) {
@@ -743,38 +859,48 @@ yzPage.prototype = {
           $prevBorder.append($prevBorderContent);
           size.diff -= borderOutSize;
           $borderContent.childNodes().forEach(item => {
-            if (item.className) {
-              if (item.className.indexOf('js-lsiten-question') > -1) {
-                let qustionType = parseInt(item.getAttribute('data-type'));
-                if (qustionType === 3) {
-                  this._prevSubjectQuestion($prevSubject, size, $(item), false);
-                  if (!isEmptyElement($prevSubject)) {
-                    $prevBorderContent.appendChild($prevSubject[0]);
+            if (!item.previousSibling) {
+              if (item.className) {
+                if (item.className.indexOf('js-lsiten-question') > -1) {
+                  let qustionType = parseInt(item.getAttribute('data-type'));
+                  if (qustionType === 3) {
+                    let $prevSubject = $(item).clone(false);
+                    this._prevSubjectQuestion($prevSubject, size, $(item), false);
+                    if (!isEmptyElement($prevSubject)) {
+                      $prevBorderContent[0].appendChild($prevSubject[0]);
+                    }
+                  } else if (qustionType === 4) {
+                    let $prevWritting = $(item).clone(false);                 
+                    this._prevWrittingQuestion($prevWritting, size, $(item), false);
+                    if (!isEmptyElement($prevWritting)) {
+                      $prevBorderContent[0].appendChild($prevWritting[0]);
+                    }
+                  } else {
+                    let height = $(item).getSizeData().height;
+                    if (height < size.diff) {
+                      $prevBorderContent[0].appendChild(item);
+                      size.diff -= height;
+                    }
                   }
-                } else if (qustionType === 4) {
-                  let $prevWritting = $(item).clone(false);                 
-                  this._prevWrittingQuestion($prevWritting, size, $(item), false);
-                  if (!isEmptyElement($prevWritting)) {
-                    $prevBorderContent.appendChild($prevWritting[0]);
+                } else if (item.className.indexOf('js-lsiten-line') > -1) {
+                  let height = $(item).getSizeData().height;
+                  if (height < size.diff) {
+                    $prevBorderContent[0].appendChild(item);
+                    size.diff -= height;
                   }
-                } else {
+                } else if (item.className.indexOf('js-lsiten-options-box') > -1) {
+                  // 选作题组【回退】
                   let height = $(item).getSizeData().height;
                   if (height < size.diff) {
-                    $prevBorderContent.appendChild(item);
+                    $prevBorderContent[0].appendChild(item);
                     size.diff -= height;
                   }
-                }
-              } else if (item.className.indexOf('js-lsiten-line') > -1) {
-                let height = $(item).getSizeData().height;
-                if (height < size.diff) {
-                  $prevBorderContent.appendChild(item);
-                  size.diff -= height;
+                } else {
+                  $(item).remove();
                 }
               } else {
-                $(item).remove();
+                item && item.parentNode.removeChild(item);
               }
-            } else {
-              item && item.parentNode.removeChild(item);
             }
           })
           size.diff += borderOutSize;
@@ -784,10 +910,61 @@ yzPage.prototype = {
         }
       }
     } else {
-      let borderSize= $border.getSizeData();
-      if (borderSize.height < size.diff) {
-        $prevParagraph.append($border);
-        size.diff -= borderSize.height;
+      // 框的padding+margin+border
+      let borderOutSize = 22;
+      let $prevBorder = $border.clone(false);
+      let $borderContent = $($border[0].firstChild);
+      let $prevBorderContent = $borderContent.clone(false);
+      $prevBorder.append($prevBorderContent);
+      size.diff -= borderOutSize;
+      $borderContent.childNodes().forEach(item => {
+        if (!item.previousSibling) {
+          if (item.className) {
+            if (item.className.indexOf('js-lsiten-question') > -1) {
+              let qustionType = parseInt(item.getAttribute('data-type'));
+              if (qustionType === 3) {
+                let $prevSubject = $(item).clone(false);                 
+                this._prevSubjectQuestion($prevSubject, size, $(item), false);
+                if (!isEmptyElement($prevSubject)) {
+                  $prevBorderContent.appendChild($prevSubject[0]);
+                }
+              } else if (qustionType === 4) {
+                let $prevWritting = $(item).clone(false);                 
+                this._prevWrittingQuestion($prevWritting, size, $(item), false);
+                if (!isEmptyElement($prevWritting)) {
+                  $prevBorderContent.appendChild($prevWritting[0]);
+                }
+              } else {
+                let height = $(item).getSizeData().height;
+                if (height < size.diff) {
+                  $prevBorderContent.appendChild(item);
+                  size.diff -= height;
+                }
+              }
+            } else if (item.className.indexOf('js-lsiten-line') > -1) {
+              let height = $(item).getSizeData().height;
+              if (height < size.diff) {
+                $prevBorderContent[0].appendChild(item);
+                size.diff -= height;
+              }
+            } else if (item.className.indexOf('js-lsiten-options-box') > -1) {
+              // 选作题组【回退】
+              let height = $(item).getSizeData().height;
+              if (height < size.diff) {
+                $prevBorderContent[0].appendChild(item);
+                size.diff -= height;
+              }
+            } else {
+              $(item).remove();
+            }
+          } else {
+            item && item.parentNode.removeChild(item);
+          }
+        }
+      })
+      size.diff += borderOutSize;
+      if (!isEmptyElement($prevBorderContent[0])) {
+        $prevParagraph.append($prevBorder);
       }
     }
     if (isEmptyElement($border[0].firstChild)) {
@@ -806,25 +983,48 @@ yzPage.prototype = {
     let lastQuestion = $lastBorder[0].firstChild.lastChild;
     let $borderContent = $($border[0].firstChild);
     $borderContent.childNodes().forEach(item => {
-      if (item.className) {
-        if (item.className.indexOf('js-lsiten-question') > -1) {
-          let qustionType = parseInt(item.getAttribute('data-type'));
-          let questionId = item.getAttribute('data-id');
-          if (lastQuestion.className && lastQuestion.className.indexOf('js-lsiten-question') > -1) {
-            let lastQuestionId = lastQuestion.getAttribute('data-id');
-            if (questionId && lastQuestionId && lastQuestionId === questionId) {
-              // 需要合并2个小问
-              if (qustionType === 3) {
-                this._prevSubjectQuestion($(lastQuestion), size, $(item), true);
-              } else if (qustionType === 4) {
-                this._prevWrittingQuestion($(lastQuestion), size, $(item), true);
+      if (!item.previousSibling) {
+        if (item.className) {
+          if (item.className.indexOf('js-lsiten-question') > -1) {
+            let qustionType = parseInt(item.getAttribute('data-type'));
+            let questionId = item.getAttribute('data-id');
+            if (lastQuestion.className && lastQuestion.className.indexOf('js-lsiten-question') > -1) {
+              let lastQuestionId = lastQuestion.getAttribute('data-id');
+              if (questionId && lastQuestionId && lastQuestionId === questionId) {
+                // 需要合并2个小问
+                if (qustionType === 3) {
+                  this._prevSubjectQuestion($(lastQuestion), size, $(item), true);
+                } else if (qustionType === 4) {
+                  this._prevWrittingQuestion($(lastQuestion), size, $(item), true);
+                } else {
+                  let height = $(item).getSizeData().height;
+                  if (height < size.diff) {
+                    $prevBorder[0].firstChild.appendChild(item);
+                    size.diff -= height;
+                  }
+                }
               } else {
-                let height = $(item).getSizeData().height;
-                if (height < size.diff) {
-                  $prevBorder[0].firstChild.appendChild(item);
-                  size.diff -= height;
+                if (qustionType === 3) {
+                  let $prevSubject = $(item).clone(false);
+                  this._prevSubjectQuestion($prevSubject, size, $(item), false);
+                  if (!isEmptyElement($prevSubject[0])) {
+                    $prevBorder[0].firstChild.appendChild($prevSubject[0]);
+                  }
+                } else if (qustionType === 4) {
+                  let $prevWritting = $(item).clone(false);
+                  this._prevWrittingQuestion($prevWritting, size, $(item), false);
+                  if (!isEmptyElement($prevWritting[0])) {
+                    $prevBorder[0].firstChild.appendChild($prevWritting[0]);
+                  }
+                } else {
+                  let height = $(item).getSizeData().height;
+                  if (height < size.diff) {
+                    $prevBorder[0].firstChild.appendChild(item);
+                    size.diff -= height;
+                  }
                 }
               }
+              
             } else {
               if (qustionType === 3) {
                 let $prevSubject = $(item).clone(false);
@@ -846,39 +1046,18 @@ yzPage.prototype = {
                 }
               }
             }
-            
-          } else {
-            if (qustionType === 3) {
-              let $prevSubject = $(item).clone(false);
-              this._prevSubjectQuestion($prevSubject, size, $(item), false);
-              if (!isEmptyElement($prevSubject[0])) {
-                $prevBorder[0].firstChild.appendChild($prevSubject[0]);
-              }
-            } else if (qustionType === 4) {
-              let $prevWritting = $(item).clone(false);
-              this._prevWrittingQuestion($prevWritting, size, $(item), false);
-              if (!isEmptyElement($prevWritting[0])) {
-                $prevBorder[0].firstChild.appendChild($prevWritting[0]);
-              }
-            } else {
-              let height = $(item).getSizeData().height;
-              if (height < size.diff) {
-                $prevBorder[0].firstChild.appendChild(item);
-                size.diff -= height;
-              }
+          } else if (item.className.indexOf('js-lsiten-line') > -1) {
+            let height = $(item).getSizeData().height;
+            if (height < size.diff) {
+              $prevBorder[0].firstChild.appendChild(item);
+              size.diff -= height;
             }
-          }
-        } else if (item.className.indexOf('js-lsiten-line') > -1) {
-          let height = $(item).getSizeData().height;
-          if (height < size.diff) {
-            $prevBorder[0].firstChild.appendChild(item);
-            size.diff -= height;
+          } else {
+            $(item).remove();
           }
         } else {
-          $(item).remove();
+          item && item.parentNode.removeChild(item);
         }
-      } else {
-        item && item.parentNode.removeChild(item);
       }
     })
   },

+ 37 - 4
src/js/yzPageManager.js

@@ -30,10 +30,38 @@ yzPageManager.prototype = {
   constructor: yzPageManager,
   _init: function () {
     this._initStyles();
-    this._addPage();
+    if (!this.editor.cardHtml ||  this.editor.cardHtml.length < 1) {
+      this._addPage();
+    }
     this._initEvents();
   },
   /**
+   * function 初始化编辑后的数据
+   */
+  parseCardHtml: function (cardHtml) {
+    const editor = this.editor;
+    this._initStatus = true;
+    this._removePages();
+    cardHtml.forEach(pageHtml => {
+      let $pageHtml = $(pageHtml);
+      this._addPage($pageHtml);
+    });
+    this.pages.forEach(page => {
+      page.$colums.forEach($colum => {
+        page._updateCrossColumn($colum);
+      })
+    })
+  },
+  /**
+   * function 删除所有页面
+   */
+  _removePages: function () {
+    this.currentPage = null;
+    this.pages = [];
+    this.$el.html('');
+    this.pageIndex = 0;
+  },
+  /**
    * function 初始化页面的样式
    */
   _initStyles: function () {
@@ -51,12 +79,14 @@ yzPageManager.prototype = {
   /**
    * function 添加一页
    */
-  _addPage: function () {
+  _addPage: function ($page) {
     this._addBreakPlaceholder();    
-    let page = new yzPage(this, '');
+    let page = new yzPage(this,  $page || null);
     this.pages.push(page);
     this.pageIndex++;
-    page.addHeader();
+    if (!$page) {
+      page.addHeader();
+    }
     return page;
   },
   /**
@@ -306,6 +336,9 @@ yzPageManager.prototype = {
    */
   _updatePositionInfo: function (e, $ele) {
     let $target = $ele || $(e.target || e.toElement);
+    if (!$target) {
+      return false;
+    }
     let $border = getParentByClassname($target, 'js-lsiten-border');
     let $line = getParentByClassname($target, 'js-lsiten-line');
     let $paragraph = getParentByClassname($target, 'js-paragraph-view');