lsiten il y a 6 ans
Parent
commit
b6f73fbf31

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "lsiten-editor-v2",
-  "version": "1.2.2",
+  "version": "1.2.8",
   "description": "answer sheet",
   "main": "src/js/yzWebeditor.js",
   "scripts": {

+ 208 - 154
src/data.json

@@ -1,235 +1,289 @@
 {
 	"schoolId": "109",
-	"id": "4",
-	"subjectId": "4",
-	"paperSize": "A4",
-	"layoutType": "1",
+	"id": "557",
+	"subjectId": "1871",
+	"paperSize": "A3",
+	"layoutType": "3",
+	"layoutMode": 2,
 	"sourceType": "2",
 	"prohibitType": "1",
-	"noMode": "2",
-	"noCount": "9",
-	"noBoth": "0",
-	"qrCode": "4",
-	"alias": "回归测试 高一 理综",
+	"noMode": "1",
+	"noCount": "14",
+	"noBoth": "1",
+	"qrCode": "gF",
+	"alias": "测试作文 高一 语文",
 	"cardJson": null,
 	"cardHtml": "",
 	"attention": null,
 	"examPageCnt": "0",
-	"subjectName": "理综",
+	"subjectName": "语文",
 	"pageQus": [
 		{
-			"sort": "1",
-			"attribute": null,
-			"content": null,
 			"annexable": "1",
 			"group": "0",
-			"pIndex": "",
+			"pIndex": "1",
 			"pros": [
 				{
-					"proId": "29",
-					"score": 30.0,
-					"pureObjective": "1",
 					"content": "",
+					"group": "0",
+					"pnum": "",
+					"proId": "931",
+					"pureObjective": "1",
+					"qus": [
+						{
+							"content": "",
+							"nums": "3",
+							"pnum": "2",
+							"quId": "1514",
+							"quType": "单选题",
+							"rIndex": "0",
+							"score": 5,
+							"visible": false
+						},
+						{
+							"content": "",
+							"nums": "2",
+							"pnum": "3",
+							"quId": "1515",
+							"quType": "判断题",
+							"rIndex": "0",
+							"score": 5,
+							"visible": false
+						}
+					],
+					"score": 20,
 					"sort": "1",
+					"titleType": "注音释义"
+				},
+				{
+					"content": "",
+					"group": "0",
 					"pnum": "",
+					"proId": "1325",
+					"pureObjective": "1",
+					"qus": [
+						{
+							"content": "",
+							"nums": "2",
+							"pnum": "6",
+							"quId": "2260",
+							"quType": "单选题",
+							"rIndex": "1-1",
+							"score": 5,
+							"visible": true
+						}
+					],
+					"score": 5,
+					"sort": "2",
+					"titleType": "选择题"
+				},
+				{
+					"content": "",
 					"group": "0",
+					"pnum": "",
+					"proId": "1571",
+					"pureObjective": "1",
 					"qus": [
 						{
-							"quId": "58",
-							"score": 10.0,
+							"content": "",
+							"nums": "4",
+							"pnum": "7",
+							"quId": "2788",
 							"quType": "单选题",
+							"rIndex": "1-1",
+							"score": 5,
+							"visible": true
+						}
+					],
+					"score": 5,
+					"sort": "3",
+					"titleType": "选择题"
+				},
+				{
+					"content": "",
+					"group": "0",
+					"pnum": "",
+					"proId": "1572",
+					"pureObjective": "1",
+					"qus": [
+						{
+							"content": "",
 							"nums": "4",
+							"pnum": "8",
+							"quId": "2789",
+							"quType": "单选题",
+							"rIndex": "1-1",
+							"score": 5,
+							"visible": true
+						}
+					],
+					"score": 5,
+					"sort": "4",
+					"titleType": "选择题"
+				},
+				{
+					"content": "",
+					"group": "0",
+					"pnum": "",
+					"proId": "1573",
+					"pureObjective": "1",
+					"qus": [
+						{
 							"content": "",
-							"pnum": "1",
-							"visible": false,
-							"rIndex": "0"
-						},
+							"nums": "4",
+							"pnum": "9",
+							"quId": "2790",
+							"quType": "单选题",
+							"rIndex": "1-1",
+							"score": 5,
+							"visible": true
+						}
+					],
+					"score": 5,
+					"sort": "5",
+					"titleType": "选择题"
+				},
+				{
+					"content": "",
+					"group": "0",
+					"pnum": "",
+					"proId": "1297",
+					"pureObjective": "1",
+					"qus": [
 						{
-							"quId": "59",
-							"score": 10.0,
-							"quType": "多选题",
-							"nums": "3",
 							"content": "",
-							"pnum": "2",
-							"visible": false,
-							"rIndex": "0"
+							"nums": "4",
+							"pnum": "10",
+							"quId": "2231",
+							"quType": "单选题",
+							"rIndex": "1-1",
+							"score": 5,
+							"visible": true
 						}
-					]
+					],
+					"score": 5,
+					"sort": "6",
+					"titleType": "选择题"
 				}
-			]
+			],
+			"sort": "1"
 		},
 		{
-			"sort": "2",
-			"attribute": null,
-			"content": null,
 			"annexable": "1",
 			"group": "0",
-			"pIndex": "",
+			"pIndex": "1",
 			"pros": [
 				{
-					"proId": "29",
-					"score": 30.0,
-					"pureObjective": "2",
 					"content": "",
-					"sort": "1",
-					"pnum": "",
 					"group": "0",
+					"pnum": "",
+					"proId": "870",
+					"pureObjective": "2",
 					"qus": [
 						{
-							"quId": "58",
-							"score": 10.0,
-							"quType": "单选题",
-							"nums": "4",
 							"content": "",
 							"pnum": "1",
-							"visible": true,
-							"rIndex": "0"
-						},
-						{
-							"quId": "59",
-							"score": 10.0,
-							"quType": "多选题",
-							"nums": "3",
-							"content": "",
-							"pnum": "2",
-							"visible": true,
-							"rIndex": "0"
-						},
-						{
-							"quId": "60",
-							"score": 10.0,
-							"quType": "填空题",
-							"nums": "1",
-							"content": "",
-							"pnum": "3",
-							"visible": true,
-							"rIndex": "0"
+							"quId": "1440",
+							"quType": "解答题",
+							"rIndex": "0",
+							"score": 5,
+							"visible": true
 						}
-					]
+					],
+					"score": 5,
+					"sort": "1",
+					"titleType": "改错题"
 				}
-			]
+			],
+			"sort": "2"
 		},
 		{
-			"sort": "3",
-			"attribute": null,
-			"content": null,
 			"annexable": "1",
 			"group": "0",
-			"pIndex": "",
+			"pIndex": "1",
 			"pros": [
 				{
-					"proId": "23",
-					"score": 60.0,
-					"pureObjective": "2",
 					"content": "",
-					"sort": "2",
-					"pnum": "",
 					"group": "0",
+					"pnum": "",
+					"proId": "931",
+					"pureObjective": "2",
 					"qus": [
 						{
-							"quId": "44",
-							"score": 10.0,
-							"quType": "填空题",
-							"nums": "1",
 							"content": "",
-							"pnum": "4",
-							"visible": true,
-							"rIndex": "0"
-						},
-						{
-							"quId": "45",
-							"score": 10.0,
-							"quType": "填空题",
-							"nums": "1",
-							"content": "",
-							"pnum": "5",
-							"visible": true,
-							"rIndex": "0"
+							"nums": "3",
+							"pnum": "2",
+							"quId": "1514",
+							"quType": "单选题",
+							"rIndex": "0",
+							"score": 5,
+							"visible": true
 						},
 						{
-							"quId": "46",
-							"score": 10.0,
-							"quType": "填空题",
-							"nums": "1",
 							"content": "",
-							"pnum": "6",
-							"visible": true,
-							"rIndex": "0"
-						},
-						{
-							"quId": "47",
-							"score": 10.0,
-							"quType": "填空题",
 							"nums": "2",
-							"content": "",
-							"pnum": "7",
-							"visible": true,
-							"rIndex": "0"
+							"pnum": "3",
+							"quId": "1515",
+							"quType": "判断题",
+							"rIndex": "0",
+							"score": 5,
+							"visible": true
 						},
 						{
-							"quId": "48",
-							"score": 10.0,
-							"quType": "填空题",
-							"nums": "1",
 							"content": "",
-							"pnum": "8",
-							"visible": true,
-							"rIndex": "0"
+							"nums": "1",
+							"pnum": "4",
+							"quId": "1516",
+							"quType": "填空题",
+							"rIndex": "0",
+							"score": 5,
+							"visible": true
 						},
 						{
-							"quId": "49",
-							"score": 10.0,
-							"quType": "填空题",
-							"nums": "2",
 							"content": "",
-							"pnum": "9",
-							"visible": true,
-							"rIndex": "0"
+							"pnum": "5",
+							"quId": "1517",
+							"quType": "解答题",
+							"rIndex": "0",
+							"score": 5,
+							"visible": true
 						}
-					]
+					],
+					"score": 20,
+					"sort": "2",
+					"titleType": "注音释义"
 				}
-			]
+			],
+			"sort": "3"
 		},
 		{
-			"sort": "4",
-			"attribute": null,
-			"content": null,
 			"annexable": "1",
 			"group": "0",
-			"pIndex": "",
+			"pIndex": "1-2",
 			"pros": [
 				{
-					"proId": "26",
-					"score": 20.0,
-					"pureObjective": "2",
 					"content": "",
-					"sort": "3",
-					"pnum": "",
 					"group": "0",
+					"pnum": "",
+					"proId": "1231",
+					"pureObjective": "2",
 					"qus": [
 						{
-							"quId": "54",
-							"score": 10.0,
-							"quType": "填空题",
-							"nums": "1",
-							"content": "",
-							"pnum": "10",
-							"visible": true,
-							"rIndex": "0"
-						},
-						{
-							"quId": "55",
-							"score": 10.0,
-							"quType": "填空题",
-							"nums": "1",
 							"content": "",
 							"pnum": "11",
-							"visible": true,
-							"rIndex": "0"
+							"quId": "2153",
+							"quType": "作文题",
+							"rIndex": "0",
+							"score": 50,
+							"visible": true
 						}
-					]
+					],
+					"score": 50,
+					"sort": "8",
+					"titleType": "材料作文"
 				}
-			]
+			],
+			"sort": "4"
 		}
 	]
 }

+ 1 - 1
src/js/plugin/commands/getBorderData.js

@@ -113,7 +113,7 @@ let borderData = function () {
     border.pIndex = uniqueArray(BorderPages[parseInt(border.sort)]).join('-');
   });
 
-  data.examPageCnt = pages.length;
+  data.pageCnt = pages.length;
   return data;
 }
 export default {

+ 182 - 10
src/js/question/questionhead.js

@@ -132,6 +132,91 @@ function generateBasicInfo (width, data, pindex) {
   return $box;
 }
 
+
+/**
+ * 生成卡头基本信息
+ * @param {string} 卡头基本信息宽度
+ */
+function generateBasicInfo_2 (width, data, pindex) {
+  let $box = $('<div class="js-basic-head-info-box"></div>')
+  $box.css('width', width).css('float', 'left').css('border-right', '1px solid #000').css('padding', '10px 0').css('position', 'relative').css('min-height', '120px');
+  let $name = $('<div></div>');
+  $name.css('width', '100%');
+  let $label = $('<div>姓名:</div>');
+  $label.css('display', 'inline-block')
+        .css('line-height', '25px')
+        .css('font-size', '14px')
+        .css('margin-right', '15px')
+        .css('width', '40px')
+        .css('text-align', 'right');
+  let $line = $('<div>&#8203;</div>');
+  $line.css('display', 'inline-block')
+        .css('width', '130px')
+        .css('line-height', '25px')
+        .css('font-size', '14px')
+        .css('border-bottom', '1px solid #000');
+  $name.append($label);
+  $name.append($line);
+
+  let $class = $('<div></div>');
+  $class.css('width', '100%');
+  let $labelclass = $('<div>班级:</div>');
+  $labelclass.css('display', 'inline-block')
+        .css('line-height', '25px')
+        .css('font-size', '14px')
+        .css('margin-top', '10px')
+        .css('margin-right', '15px')
+        .css('width', '40px')
+        .css('text-align', 'right');
+  let $lineclass = $('<div>&#8203;</div>');
+  $lineclass.css('display', 'inline-block')
+        .css('width', '130px')
+        .css('line-height', '25px')
+        .css('font-size', '14px')
+        .css('border-bottom', '1px solid #000');
+  $class.append($labelclass);
+  $class.append($lineclass);
+
+  let mode = parseInt(data.noMode);
+
+  let src = QrCode.getQrBase64('+' + data.qrCode + '' + (pindex + 1), {
+      width: 100,  // 二维码图片宽度(默认为256px)
+      height: 100,  // 二维码图片高度(默认为256px)
+      padding: 5
+    });
+  let $qrcode = $('<div class="js-lsiten-qrcode"><img src="' + src + '"/></div>');
+  $qrcode.css('position', 'absolute').css('right', '60px').css('top', '78px').css('width', '100px').css('height', '100px');
+
+  if (mode === 1) {
+    let $xh = $('<div></div>');
+    $xh.css('width', '100%').css('margin-bottom', '10px');
+    let $labelxh = $('<div>学号:</div>');
+    $labelxh.css('display', 'inline-block')
+          .css('line-height', '25px')
+          .css('font-size', '14px')
+          .css('margin-top', '10px')
+          .css('margin-right', '15px')
+          .css('width', '40px')
+          .css('text-align', 'right');
+    let $linexh = $('<div>&#8203;</div>');
+    $linexh.css('display', 'inline-block')
+          .css('width', '130px')
+          .css('line-height', '25px')
+          .css('font-size', '14px')
+          .css('border-bottom', '1px solid #000');
+    $xh.append($labelxh);
+    $xh.append($linexh);
+    $box.append($xh);
+
+    $qrcode.css('top', '15px');
+    $box.css('padding', 0)
+  }
+  $box.append($name);
+  $box.append($class);
+  $box.append($qrcode);
+  return $box;
+}
+
 /**
  * 生成条码区
  */
@@ -237,7 +322,7 @@ function headType2 (noCount, data, pindex) {
             .css('font-size', '0');
 
 
-  data.paperSize === 'A4' ? $leftBox.css('border-right', '1px solid #000'): $rightBox.css('border-left', '1px solid #000');
+  $rightBox.css('border-left', '1px solid #000');
   let $examNumberBox = generateExamNumber(noCount);
   $rightBox.append($examNumberBox);
   $body.append($rightBox);
@@ -264,12 +349,57 @@ function headType3 (noCount, data, pindex) {
   let $top = $('<div></div>');
   $top.css('overflow', 'hidden');
   let $left = $('<div></div>');
-  $left.css('float', 'left').css('width', '50%');
+  $left.css('float', 'left').css('width', '50%').css('border-right', '1px solid #000');
   let $basic = generateBasicInfo('100%', data, pindex);
   $basic.css('border', 'none').css('margin-top', '24px');
   $left.append($basic);
 
   let $right = $('<div></div>');
+  $right.css('float', 'left').css('width', '50%');
+  let $tips = $('<div class="js-answer-head-tips"></div>');
+  $tips.css('padding', '15px 0').css('float', 'left');
+  $tips.html(tipsTemplate);
+  $right.append($tips);
+  $top.append($left);
+  $top.append($right);
+  
+  let $bottom = $('<div></div>');
+  $bottom.css('overflow', 'hidden').css('border-top', '1px solid #000').css('position', 'relative').css('padding', '5px 15px').css('font-size', '0').css('min-height','293px');
+
+  let $examNumberBox = generateExamNumber(noCount);
+  $bottom.append($examNumberBox);
+
+  $body.append($top);
+  $body.append($bottom);
+
+  $head.append($title);
+  $head.append($body);
+  return $head;
+}
+
+/**
+ * 生成模板3
+ * @param {int} noCount 准考证号位数
+ * @param {JSON} data 头部信息
+ */
+function headType4 (noCount, data, pindex) {
+  let title = data.alias || '';
+  let $head = $('<div class="js-answer-header" contenteditable="false"></div>');
+  initStyleHeader($head);
+  let $title = $('<div class="js-answer-header-title" contenteditable = "true">' + title + '</div>');
+  initStyleTitle($title);
+  let $body = $('<div class="js-answer-header-body"></div>');
+  initStyleBody($body);
+
+  let $top = $('<div></div>');
+  $top.css('overflow', 'hidden');
+  let $left = $('<div></div>');
+  $left.css('float', 'left').css('width', '50%');
+  let $basic = generateBasicInfo_2('100%', data, pindex);
+  $basic.css('border', 'none').css('margin-top', '24px');
+  $left.append($basic);
+
+  let $right = $('<div></div>');
   $right.css('float', 'left').css('width', '50%').css('border-left', '1px solid #000');
   let $tips = $('<div class="js-answer-head-tips"></div>');
   $tips.css('padding', '15px 0').css('float', 'left');
@@ -292,6 +422,51 @@ function headType3 (noCount, data, pindex) {
   return $head;
 }
 
+
+/**
+ * 生成模板1
+ * @param {JSON} data 头部信息
+ */
+function headType5 (data, pindex) {
+  let title = data.alias || '';
+  let $head = $('<div class="js-answer-header" contenteditable="false"></div>');
+    initStyleHeader($head);
+    let $title = $('<div class="js-answer-header-title" contenteditable = "true">' + title + '</div>');
+    initStyleTitle($title);
+    let $body = $('<div class="js-answer-header-body"></div>');
+    initStyleBody($body);
+
+    let $tips = $('<div class="js-answer-head-tips"></div>');
+    $tips.css('padding', '5px 0');
+    $tips.html(tipsTemplate);
+
+    let $bottom = $('<div class="js-head-bottom"></div>');
+    $bottom.css('width', '100%')
+           .css('border-top', '1px solid #000')
+           .css('overflow', 'hidden')
+           .css('height', 'auto')
+           .css('font-size', '0');
+    
+    let $basicInfo = $('<div class="js-answer-head-basic"></div>');
+    $basicInfo.css('width', '50%')
+              .css('float', 'left')
+              .css('padding-bottom', '10px')
+              .css('font-size', '0');
+    let $basic = generateBasicInfo('50%', data, pindex);
+    $basic.css('border-right', 'none');
+    $bottom.append($basic);
+
+    let $barCode = generateBarCode();
+    $barCode.css('border-left', '1px solid #000');
+    $bottom.append($barCode);
+    
+    $body.append($tips);
+    $body.append($bottom);
+
+    $head.append($title);
+    $head.append($body);
+    return $head;
+}
 /** 
  * 生成准考证号框
  * @param {int} noCount 准考证号位数
@@ -381,20 +556,16 @@ let heads = {
     return headType3(noCount, data, pindex);
   },
   'A3_1_3_1': function (noCount, data, pindex) {
-    let $head = $('<div class="js-answer-header" contenteditable="false"></div>');
-    return $head;
+    return headType5(data, pindex);
   },
   'A3_1_3_2': function (noCount, data, pindex) {
-    let $head = $('<div class="js-answer-header" contenteditable="false"></div>');
-    return $head;
+    return headType5(data, pindex);
   },
   'A3_2_3_1': function (noCount, data, pindex) {
-    let $head = $('<div class="js-answer-header" contenteditable="false"></div>');
-    return $head;
+    return headType4(noCount, data, pindex);
   },
   'A3_2_3_2': function (noCount, data, pindex) {
-    let $head = $('<div class="js-answer-header" contenteditable="false"></div>');
-    return $head;
+    return headType4(noCount, data, pindex);
   }
 }
 
@@ -405,6 +576,7 @@ let heads = {
  * @param {DomElement} $page 生成头的页Dom
  */
 let generateQuestionHead = function (editor, key, $page) {
+  debugger;
   let noCount = editor.noCount;
   let currentPage = $page || editor.page.currentPage;
   let $fisrstColumn = currentPage.$colums[0];

+ 6 - 6
src/js/question/writing.js

@@ -66,16 +66,16 @@ function getColumnCount (editor) {
   let column = parseInt(editor.columnNumber);
   let maxColumn = 19;
   if (pageSize === 'A4' && column === 1) {
-    maxColumn = 17;
+    maxColumn = 21;
   }
   if (pageSize === 'A3' && column === 1) {
     maxColumn = 38;
   }
   if (pageSize === 'A3' && column === 2) {
-    maxColumn = 19;
+    maxColumn = 22;
   }
   if (pageSize === 'A3' && column === 3) {
-    maxColumn =9;
+    maxColumn =14;
   }
 
   return maxColumn;
@@ -91,7 +91,7 @@ function generateGrid (column, total) {
   let $borderBox = $('<div class="lsiten-border-box" contenteditable="false"></div>');
   let rows = Math.ceil(total / column);
   let columnIndex = 0;
-  let width = column * 34 + 'px';
+  let width = column * 32 + 'px';
   let lastColumn = column - 1;
   for (let i = 0; i < rows; i++) {
     let $row = $('<div class="js-lsiten-writting-row"></div>');
@@ -111,8 +111,8 @@ function generateGrid (column, total) {
       $column.css('border-left', '1px solid #000')
               .css('border-top', '1px solid #000')
               .css('border-bottom', '1px solid #000')
-              .css('width', '34px')
-              .css('height', '34px')
+              .css('width', '32px')
+              .css('height', '32px')
               .css('position', 'relative')
               .css('box-sizing', 'border-box')
               .css('display', 'inline-block')

+ 188 - 164
src/js/yzPage.js

@@ -82,7 +82,7 @@ yzPage.prototype = {
     let $column = this.$colums[this.currentColumn];
     let $paragraph = $('<div class="js-paragraph-view"></div>');
     $paragraph.css('margin', 0)
-              .css('padding', '0 25px')
+              .css('padding', '0 15px')
               .css('outline', 'none')
               .css('box-sizing', 'border-box')
               .css('white-space', 'pre-wrap')
@@ -196,7 +196,7 @@ yzPage.prototype = {
       let $templateb = this._placeholderTemplate();
       let left = i * cwidth - 25;
       if (i > 0) {
-        left += 15
+        left += 10;
         $template.css('left', left + 'px').css('top', '-16px');
         this.$textElem.append($template);
       }
@@ -422,14 +422,14 @@ yzPage.prototype = {
     if ($prevColumn) {
       let $paragraphs = $prevColumn.find('.js-paragraph-view');
       let lastIndex = $paragraphs.length - 1;
-      if (lastIndex) {
+      if (lastIndex >= 0) {
         prevIndex = $paragraphs[lastIndex].getAttribute('data-index');
       }
     }
     if ($nextColumn) {
       let $nextParagraphs = $nextColumn.find('.js-paragraph-view');
       let nextLastIndex = $nextParagraphs.length - 1;
-      if (nextLastIndex) {
+      if (nextLastIndex >= 0) {
         nextIndex = $nextParagraphs[nextLastIndex].getAttribute('data-index');
       }
     }
@@ -702,6 +702,29 @@ yzPage.prototype = {
     return firstChild && firstChild.className && firstChild.className.indexOf('js-answer-header') > -1;
   },
   /**
+   *  function 如果该栏没有内容,而下一栏有内容,则移动下一栏内容到该栏
+   * @param {DomElement} $column 需要检测的栏
+   */
+  _moveColumnBack: function ($column, page) {
+    page = page || this;
+    let nextColumn = page._getNextColumn($column, false);
+    if (nextColumn.column) {
+      let $paragraphs = nextColumn.column.find('.js-paragraph-view');
+      let i = $paragraphs.length - 1;
+      if (!$paragraphs[i] || ($paragraphs.length && $paragraphs.length === 1 && page.isHeadParagraph($($paragraphs[0])))) {
+        page._moveColumnBack(nextColumn.column, nextColumn.page);
+      }
+      nextColumn.column.childNodes().forEach(paragraph => {
+        if (!page.isHeadParagraph($(paragraph))) {
+          $column[0].appendChild(paragraph);
+          this.manage._needReTryBack = true;
+        }
+      })
+    } else {
+      return false;
+    }
+  },
+  /**
    * function 检测栏是否需要回退
    * @param {DomElement} $column 需要检测的栏
    */
@@ -710,183 +733,184 @@ yzPage.prototype = {
     let cSize = $column.getSizeData();
     let i = $paragraphs.length - 1;
     let $moves = [];
-    if (!$paragraphs[i]) {
-      return false;
-    }
-    let $lastParagraph = $($paragraphs[i]);
-    let lastSize = $lastParagraph.getSizeData();
-    let diff = cSize.bottom - lastSize.bottom;
-    if (diff > this.lineHeight) {
-      let nextColumn = this._getNextColumn($column, false);
-      // 如果有下一页,进行检测
-      if (nextColumn.column) {
-        let $nextParagraphs = nextColumn.column.find('.js-paragraph-view');
-        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]))) {
-              j++;
-              continue;
+    if (!$paragraphs[i] || ($paragraphs.length && $paragraphs.length === 1 && this.isHeadParagraph($($paragraphs[0])))) {
+      this._moveColumnBack($column);
+    } else {
+      let $lastParagraph = $($paragraphs[i]);
+      let lastSize = $lastParagraph.getSizeData();
+      let diff = cSize.bottom - lastSize.bottom;
+      if (diff > this.lineHeight) {
+        let nextColumn = this._getNextColumn($column, false);
+        // 如果有下一页,进行检测
+        if (nextColumn.column) {
+          let $nextParagraphs = nextColumn.column.find('.js-paragraph-view');
+          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]))) {
+                j++;
+                continue;
+              }
             }
-          }
-          if ($nextParagraphs[j]) {
-            let $paragraph = $($nextParagraphs[j]);
-            if ($paragraph && !this.isHeadParagraph($paragraph)) {
-              let pSize = $paragraph.getSizeData();
-              if (pSize.height < diff) {
-                $moves.push($paragraph);
-              } else {
-                let size = {
-                  diff: diff
+            if ($nextParagraphs[j]) {
+              let $paragraph = $($nextParagraphs[j]);
+              if ($paragraph && !this.isHeadParagraph($paragraph)) {
+                let pSize = $paragraph.getSizeData();
+                if (pSize.height < diff) {
+                  $moves.push($paragraph);
+                } else {
+                  let size = {
+                    diff: diff
+                  }
+                  this._prevParagraph($moves, $paragraph, size, $lastParagraph);
                 }
-                this._prevParagraph($moves, $paragraph, size, $lastParagraph);
               }
             }
+            j++;
           }
-          j++;
-        }
-        let lastPid = $lastParagraph.attr('data-index');
-        let lastBorderItem = $lastParagraph[0].lastChild;
-        let lastIsBorder = lastBorderItem && lastBorderItem.className && lastBorderItem.className.indexOf('js-lsiten-border') > -1;
-        $moves.forEach($paragraphITem => {
-          let currentPid = $paragraphITem.attr('data-index');
-          if (lastPid === currentPid) {
-            $paragraphITem.childNodes().forEach(item => {
-              if (item.nodeType === 3) {
-                $paragraph[0].removeChild(item);
-              } else {
-                let $item = $(item);
-                let itemClass = $item.attr('class');
-                if (itemClass && itemClass.indexOf('js-lsiten-line') > -1) {
-                  // 普通行
-                  $lastParagraph.append($item);
-                } else if (itemClass && itemClass.indexOf('js-lsiten-border') > -1) {
-                  // 框处理
-                  if (lastIsBorder) {
-                    let borderId = lastBorderItem.getAttribute('data-id');
-                    let currentBorderId = $item.attr('data-id');
+          let lastPid = $lastParagraph.attr('data-index');
+          let lastBorderItem = $lastParagraph[0].lastChild;
+          let lastIsBorder = lastBorderItem && lastBorderItem.className && lastBorderItem.className.indexOf('js-lsiten-border') > -1;
+          $moves.forEach($paragraphITem => {
+            let currentPid = $paragraphITem.attr('data-index');
+            if (lastPid === currentPid) {
+              $paragraphITem.childNodes().forEach(item => {
+                if (item.nodeType === 3) {
+                  $paragraph[0].removeChild(item);
+                } else {
+                  let $item = $(item);
+                  let itemClass = $item.attr('class');
+                  if (itemClass && itemClass.indexOf('js-lsiten-line') > -1) {
+                    // 普通行
+                    $lastParagraph.append($item);
+                  } else if (itemClass && itemClass.indexOf('js-lsiten-border') > -1) {
+                    // 框处理
+                    if (lastIsBorder) {
+                      let borderId = lastBorderItem.getAttribute('data-id');
+                      let currentBorderId = $item.attr('data-id');
 
-                    if (currentBorderId === borderId) {
-                      let borderType = parseInt($item.attr('data-type'));
-                      if (borderType === 1) {
-                        // 客观题处理
-                        $item.childNodes().forEach(objectRow => {
-                          if (!objectRow.previousSibling) {
-                            let lastRow = lastBorderItem.lastChild;
-                            let firstRowId = objectRow.getAttribute('data-id');
-                            let lastRowId = lastRow.getAttribute('data-id');
-                            if (firstRowId === lastRowId) {
-                              let objectColumns = $(objectRow).find('.js-option-column');
-                              // 以第一栏的为基准
-                              let objectFirstColumn = objectColumns[0];
-                              $(objectFirstColumn.firstChild).childNodes().forEach(objectQuestion => {
-                                if (!objectQuestion.previousSibling) {
-                                  this._mergeObjectRow(objectColumns, lastRow);
-                                }
-                              })
-                            } else {
-                              lastBorderItem.appendChild(objectRow);
+                      if (currentBorderId === borderId) {
+                        let borderType = parseInt($item.attr('data-type'));
+                        if (borderType === 1) {
+                          // 客观题处理
+                          $item.childNodes().forEach(objectRow => {
+                            if (!objectRow.previousSibling) {
+                              let lastRow = lastBorderItem.lastChild;
+                              let firstRowId = objectRow.getAttribute('data-id');
+                              let lastRowId = lastRow.getAttribute('data-id');
+                              if (firstRowId === lastRowId) {
+                                let objectColumns = $(objectRow).find('.js-option-column');
+                                // 以第一栏的为基准
+                                let objectFirstColumn = objectColumns[0];
+                                $(objectFirstColumn.firstChild).childNodes().forEach(objectQuestion => {
+                                  if (!objectQuestion.previousSibling) {
+                                    this._mergeObjectRow(objectColumns, lastRow);
+                                  }
+                                })
+                              } else {
+                                lastBorderItem.appendChild(objectRow);
+                              }
                             }
-                          }
-                        })
-                        $item.remove();
-                        this._updateObjectColumnBorder(lastBorderItem);
-                        this._updateObjectColumnHeightByBorder(lastBorderItem);
-                      } else if (borderType === 2) {
-                        $($item[0].firstChild).childNodes().forEach(borderItem => {
-                          if (borderItem.className) {
-                            if (borderItem.className.indexOf('js-lsiten-question') > -1) {
-                              let qustionType = parseInt(borderItem.getAttribute('data-type'));
-                              let lastQuestionItem = lastBorderItem.lastChild;
-                              let lastQuestionId = lastQuestionItem.getAttribute('data-id');
-                              let currentQuestionId = borderItem.getAttribute('data-id');
-                              if (lastQuestionId && currentQuestionId && currentQuestionId === lastQuestionId) {
-                                if (qustionType === 3) {
-                                  $(borderItem).childNodes().forEach(subjectItem => {
-                                    lastQuestionItem.appendChild(subjectItem);
-                                  })
-  
-                                } else if (qustionType === 4) {
-                                  $(borderItem).childNodes().forEach(writtingItem => {
-                                    if (writtingItem.className.indexOf('lsiten-title') > -1) {
-                                      let $prevWrittingTitleItem = $(lastQuestionItem).find('.lsiten-title');
-                                      let needMergeItem = true;
-                                      if (!$prevWrittingTitleItem.length) {
-                                        needMergeItem = false;
-                                        $prevWrittingTitleItem = $($prevWrittingTitleItem);
-                                      } else {
-                                        needMergeItem = false;
-                                        $prevWrittingTitleItem = $(writtingItem).clone(false);
-                                      }
-                                      $(writtingItem).childNodes().forEach(writtingTitleItem => {
-                                        $prevWrittingTitleItem[0].appendChild(writtingTitleItem);
-                                      })
-  
-                                      if (needMergeItem && !isEmptyElement($prevWrittingTitleItem[0])) {
-                                        lastQuestionItem.appendChild($prevWrittingTitleItem[0]);
-                                      }
-                                    } else if (writtingItem.className.indexOf('lsiten-border-box') > -1) {
-                                      let $prevWrittingRowsItem = $(lastQuestionItem).find('.lsiten-border-box');
-                                      let needMergeItem = true;
-                                      if (!$prevWrittingRowsItem.length) {
-                                        needMergeItem = false;
-                                        $prevWrittingRowsItem = $($prevWrittingRowsItem);
-                                      } else {
-                                        needMergeItem = false;
-                                        $prevWrittingRowsItem = $(writtingItem).clone(false);
-                                      }
-                                      $(writtingItem).childNodes().forEach(writtingRowItem => {
-                                        $prevWrittingRowsItem[0].appendChild(writtingRowItem);
-                                      })
-  
-                                      if (needMergeItem && !isEmptyElement($prevWrittingRowsItem[0])) {
-                                        lastQuestionItem.appendChild($prevWrittingRowsItem[0]);
+                          })
+                          $item.remove();
+                          this._updateObjectColumnBorder(lastBorderItem);
+                          this._updateObjectColumnHeightByBorder(lastBorderItem);
+                        } else if (borderType === 2) {
+                          $($item[0].firstChild).childNodes().forEach(borderItem => {
+                            if (borderItem.className) {
+                              if (borderItem.className.indexOf('js-lsiten-question') > -1) {
+                                let qustionType = parseInt(borderItem.getAttribute('data-type'));
+                                let lastQuestionItem = lastBorderItem.lastChild;
+                                let lastQuestionId = lastQuestionItem.getAttribute('data-id');
+                                let currentQuestionId = borderItem.getAttribute('data-id');
+                                if (lastQuestionId && currentQuestionId && currentQuestionId === lastQuestionId) {
+                                  if (qustionType === 3) {
+                                    $(borderItem).childNodes().forEach(subjectItem => {
+                                      lastQuestionItem.appendChild(subjectItem);
+                                    })
+    
+                                  } else if (qustionType === 4) {
+                                    $(borderItem).childNodes().forEach(writtingItem => {
+                                      if (writtingItem.className.indexOf('lsiten-title') > -1) {
+                                        let $prevWrittingTitleItem = $(lastQuestionItem).find('.lsiten-title');
+                                        let needMergeItem = true;
+                                        if (!$prevWrittingTitleItem.length) {
+                                          needMergeItem = false;
+                                          $prevWrittingTitleItem = $($prevWrittingTitleItem);
+                                        } else {
+                                          needMergeItem = false;
+                                          $prevWrittingTitleItem = $(writtingItem).clone(false);
+                                        }
+                                        $(writtingItem).childNodes().forEach(writtingTitleItem => {
+                                          $prevWrittingTitleItem[0].appendChild(writtingTitleItem);
+                                        })
+    
+                                        if (needMergeItem && !isEmptyElement($prevWrittingTitleItem[0])) {
+                                          lastQuestionItem.appendChild($prevWrittingTitleItem[0]);
+                                        }
+                                      } else if (writtingItem.className.indexOf('lsiten-border-box') > -1) {
+                                        let $prevWrittingRowsItem = $(lastQuestionItem).find('.lsiten-border-box');
+                                        let needMergeItem = true;
+                                        if (!$prevWrittingRowsItem.length) {
+                                          needMergeItem = false;
+                                          $prevWrittingRowsItem = $($prevWrittingRowsItem);
+                                        } else {
+                                          needMergeItem = false;
+                                          $prevWrittingRowsItem = $(writtingItem).clone(false);
+                                        }
+                                        $(writtingItem).childNodes().forEach(writtingRowItem => {
+                                          $prevWrittingRowsItem[0].appendChild(writtingRowItem);
+                                        })
+    
+                                        if (needMergeItem && !isEmptyElement($prevWrittingRowsItem[0])) {
+                                          lastQuestionItem.appendChild($prevWrittingRowsItem[0]);
+                                        }
                                       }
-                                    }
-                                  })
-                                } else {
+                                    })
+                                  } else {
+                                    $(borderItem).remove();
+                                  }
                                   $(borderItem).remove();
+                                } else {
+                                  lastBorderItem.firstChild.appendChild(borderItem);
                                 }
-                                $(borderItem).remove();
-                              } else {
+                              } 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 {
+                                $(borderItem).remove();
                               }
-                            } 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 {
-                              $(borderItem).remove();
                             }
-                          }
-                        })
-                        $item.remove();
+                          })
+                          $item.remove();
+                        }
+                      } else {
+                        $lastParagraph.append($item);                  
                       }
                     } else {
-                      $lastParagraph.append($item);                  
+                      $lastParagraph.append($item);
                     }
                   } else {
-                    $lastParagraph.append($item);
+                    $item.remove();
                   }
-                } else {
-                  $item.remove();
                 }
-              }
-            })
-            $paragraphITem.remove();
-          } else {
-            $paragraphITem.insertAfter($lastParagraph);
-          }
-        })
-        // 跨栏符检测
-        this._checkIsCross($($paragraphs[$paragraphs.length - 1]), $column);  
-        this._checkIsCross($($nextParagraphs[0]), nextColumn.column);  
-        this._updateCrossColumn($column);
-        this._updateCrossColumn(nextColumn.column);
-        this._updateObjectColumnHeight(nextColumn.column[0]); 
+              })
+              $paragraphITem.remove();
+            } else {
+              $paragraphITem.insertAfter($lastParagraph);
+            }
+          })
+          // 跨栏符检测
+          this._checkIsCross($($paragraphs[$paragraphs.length - 1]), $column);  
+          this._checkIsCross($($nextParagraphs[0]), nextColumn.column);  
+          this._updateCrossColumn($column);
+          this._updateCrossColumn(nextColumn.column);
+          this._updateObjectColumnHeight(nextColumn.column[0]); 
+        }
       }
     }
   },
@@ -1594,8 +1618,8 @@ yzPage.prototype = {
     'A3': '970px'
   },
   _pagesWidth: {
-    'A4': 653,
-    'A3': 1447
+    'A4': 713,
+    'A3': 1507
   }
 }
 

+ 20 - 6
src/js/yzPageManager.js

@@ -15,7 +15,9 @@ let yzPageManager = function (editor) {
   // enter键状态
   this._event = null;
   this._checkPageOutStatus = false;  
-  this._checkPageBackStatus = false;  
+  this._checkPageBackStatus = false;
+  // 是否需要再次计算回退
+  this._needReTryBack = false;
 
   // 输入法监听 
   this.inputType = false;
@@ -91,7 +93,7 @@ yzPageManager.prototype = {
     this.$el.css('width', this._pagesWidth[this.editor.pageSize])
             .css('background', '#ffffff')
             .css('position', 'relative')
-            .css('padding', '70px!important')
+            .css('padding', '70px 40px!important')
             .css('box-sizing', 'border-box')
             .css('min-width', '0')
             .css('box-shadow', '0 2px 7px rgba(0,0,0,.1)')
@@ -186,6 +188,11 @@ yzPageManager.prototype = {
       callback();
     }
     this._checkPageBackStatus = false;
+
+    if (this._needReTryBack) {
+      this._needReTryBack = false;
+      Jquery(this.$el[0]).trigger('removeContent');
+    }
   },
 
   _checkRemovePage() {
@@ -365,7 +372,7 @@ yzPageManager.prototype = {
             let $paragraph = $('<div class="js-paragraph-view js-pure-text"></div>');
             $paragraph.append(gennerOneLine());
             $paragraph.css('margin', 0)
-                      .css('padding', '0 25px')
+                      .css('padding', '0 15px')
                       .css('outline', 'none')
                       .css('position', 'relative')
                       .css('box-sizing', 'border-box')
@@ -639,7 +646,7 @@ yzPageManager.prototype = {
         if (type === questionType) {
           questions.push(lastQuestion);
   
-          if (borderContent.childNodes.length === 1 && prevLastParagraph.indexOf('js-split-paragraph') > -1) {
+          if (borderContent.childNodes.length === 1) {
             let prevQuestions = this._findPrevQustions($(lastBorder), type);
             questions = questions.concat(prevQuestions);
           }
@@ -758,7 +765,7 @@ yzPageManager.prototype = {
           if (type === questionType) {
             questions.push(firstQuestion);
     
-            if (borderContent.childNodes.length === 1 && nextFirstParagraph.indexOf('js-split-paragraph') > -1) {
+            if (borderContent.childNodes.length === 1) {
               let nextQuestions = this._findNextQustions($(firstBorder), type);
               questions = questions.concat(nextQuestions);
             }
@@ -1040,7 +1047,7 @@ yzPageManager.prototype = {
                     let lastIndex = $prevQuestions.length - 1;
                     let questionBasic = lastIndex >= 0 ? $prevQuestions[lastIndex] : $writting[0];
                     let $borderBasic = $(questionBasic).parent();
-                    let lineHeight = $borderBasic.parent()[0].getAttribute('data-blineheight');
+                    let lineHeight = $borderBasic.parent()[0].getAttribute('data-blineheight') || 25;
                     $prevQuestions.forEach(item => {
                       let $item = $(item);
                       let $borderContent = $item.parent();
@@ -1088,6 +1095,7 @@ yzPageManager.prototype = {
                     _this._updatePositionInfo(null, $onelineBasic);
                   } else {
                     let $borderWrittingContent = $writting.parent();
+                    let lineHeight = $borderWrittingContent.parent()[0].getAttribute('data-blineheight') || 25;
                     $writting.remove();
                     let $onelineBasic = gennerOneLine(false, lineHeight);
                     $borderWrittingContent.append($onelineBasic);
@@ -1099,6 +1107,12 @@ yzPageManager.prototype = {
                       nums: total,
                       visible: true
                   }});
+
+
+                  Jquery(_this.$el[0]).trigger('addContent', () => {
+                    Jquery(_this.$el[0]).trigger('removeContent')
+                  });
+                  
                 }
                 $success.on('click', function () {
                   sureClick();