|
@@ -4,172 +4,172 @@ import $ from './js/util/dom-core.js';
|
|
|
import data from './data.json';
|
|
|
let editor = new yzWebeditor({dom:document.getElementById('pages-box'), data: data});
|
|
|
|
|
|
-let conmands = [];
|
|
|
+// let conmands = [];
|
|
|
|
|
|
-const selection = editor.selection;
|
|
|
+// const selection = editor.selection;
|
|
|
|
|
|
-let cardHtml = data.cardHtml || '';
|
|
|
-if (cardHtml.length > 0) {
|
|
|
- cardHtml = JSON.parse(data.cardHtml);
|
|
|
- editor.page.parseCardHtml(cardHtml);
|
|
|
-} else {
|
|
|
- let borders = data.pageQus;
|
|
|
+// let cardHtml = data.cardHtml || '';
|
|
|
+// if (cardHtml.length > 0) {
|
|
|
+// cardHtml = JSON.parse(data.cardHtml);
|
|
|
+// editor.page.parseCardHtml(cardHtml);
|
|
|
+// } else {
|
|
|
+// let borders = data.pageQus;
|
|
|
|
|
|
- let length = borders.length;
|
|
|
- for (let i = 0; i < length; i++) {
|
|
|
- let borderItem = borders[i];
|
|
|
- let pros = borderItem.pros;
|
|
|
- let plength = pros.length;
|
|
|
- borderItem.pureObject = true;
|
|
|
- for (let j = 0; j < plength; j++) {
|
|
|
- let prosItem = pros[j];
|
|
|
- if (parseInt(prosItem.pureObjective) ===2) {
|
|
|
- borderItem.pureObject = false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// let length = borders.length;
|
|
|
+// for (let i = 0; i < length; i++) {
|
|
|
+// let borderItem = borders[i];
|
|
|
+// let pros = borderItem.pros;
|
|
|
+// let plength = pros.length;
|
|
|
+// borderItem.pureObject = true;
|
|
|
+// for (let j = 0; j < plength; j++) {
|
|
|
+// let prosItem = pros[j];
|
|
|
+// if (parseInt(prosItem.pureObjective) ===2) {
|
|
|
+// borderItem.pureObject = false;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
|
|
|
- for (let i = 0; i < length; i ++) {
|
|
|
- let borderItem = borders[i];
|
|
|
- let borderData = {
|
|
|
- annexable: borderItem.annexable,
|
|
|
- attribute: borderItem.attribute,
|
|
|
- content: borderItem.content,
|
|
|
- group: borderItem.group,
|
|
|
- pureObject: borderItem.pureObject,
|
|
|
- pros: borderItem.pros,
|
|
|
- sort: borderItem.sort
|
|
|
- }
|
|
|
- if (borderItem.pureObject) {
|
|
|
- let conmandItem = {
|
|
|
- exc: 'border',
|
|
|
- params: {
|
|
|
- type: 1,
|
|
|
- data: borderData
|
|
|
- }
|
|
|
- }
|
|
|
- conmands.push(conmandItem);
|
|
|
- } else {
|
|
|
- let conmandItem = {
|
|
|
- exc: 'border',
|
|
|
- params: {
|
|
|
- type: 2,
|
|
|
- data: borderData
|
|
|
- }
|
|
|
- }
|
|
|
- conmands.push(conmandItem);
|
|
|
- }
|
|
|
+// for (let i = 0; i < length; i ++) {
|
|
|
+// let borderItem = borders[i];
|
|
|
+// let borderData = {
|
|
|
+// annexable: borderItem.annexable,
|
|
|
+// attribute: borderItem.attribute,
|
|
|
+// content: borderItem.content,
|
|
|
+// group: borderItem.group,
|
|
|
+// pureObject: borderItem.pureObject,
|
|
|
+// pros: borderItem.pros,
|
|
|
+// sort: borderItem.sort
|
|
|
+// }
|
|
|
+// if (borderItem.pureObject) {
|
|
|
+// let conmandItem = {
|
|
|
+// exc: 'border',
|
|
|
+// params: {
|
|
|
+// type: 1,
|
|
|
+// data: borderData
|
|
|
+// }
|
|
|
+// }
|
|
|
+// conmands.push(conmandItem);
|
|
|
+// } else {
|
|
|
+// let conmandItem = {
|
|
|
+// exc: 'border',
|
|
|
+// params: {
|
|
|
+// type: 2,
|
|
|
+// data: borderData
|
|
|
+// }
|
|
|
+// }
|
|
|
+// conmands.push(conmandItem);
|
|
|
+// }
|
|
|
|
|
|
- let pros = borderItem.pros;
|
|
|
- let plength = pros.length;
|
|
|
- let maxNum = 0;
|
|
|
- let questcount = 0;
|
|
|
- for (let j = 0; j < plength; j++) {
|
|
|
- let prosItem = pros[j];
|
|
|
- let qus = prosItem.qus;
|
|
|
- let klength = qus.length;
|
|
|
- for (let k = 0; k < klength; k++) {
|
|
|
- let qusItem = JSON.parse(JSON.stringify(qus[k]));
|
|
|
- qusItem.proId = prosItem.proId;
|
|
|
- qusItem.proData = {
|
|
|
- content: prosItem.content,
|
|
|
- proId: prosItem.proId,
|
|
|
- pnum: prosItem.pnum,
|
|
|
- pureObjective: prosItem.pureObjective,
|
|
|
- score: prosItem.score,
|
|
|
- sort: prosItem.sort
|
|
|
- };
|
|
|
- let qNums = parseInt(qusItem.nums);
|
|
|
- qNums > maxNum && (maxNum = qNums);
|
|
|
- parseQuestion(qusItem);
|
|
|
- questcount++;
|
|
|
- }
|
|
|
- }
|
|
|
+// let pros = borderItem.pros;
|
|
|
+// let plength = pros.length;
|
|
|
+// let maxNum = 0;
|
|
|
+// let questcount = 0;
|
|
|
+// for (let j = 0; j < plength; j++) {
|
|
|
+// let prosItem = pros[j];
|
|
|
+// let qus = prosItem.qus;
|
|
|
+// let klength = qus.length;
|
|
|
+// for (let k = 0; k < klength; k++) {
|
|
|
+// let qusItem = JSON.parse(JSON.stringify(qus[k]));
|
|
|
+// qusItem.proId = prosItem.proId;
|
|
|
+// qusItem.proData = {
|
|
|
+// content: prosItem.content,
|
|
|
+// proId: prosItem.proId,
|
|
|
+// pnum: prosItem.pnum,
|
|
|
+// pureObjective: prosItem.pureObjective,
|
|
|
+// score: prosItem.score,
|
|
|
+// sort: prosItem.sort
|
|
|
+// };
|
|
|
+// let qNums = parseInt(qusItem.nums);
|
|
|
+// qNums > maxNum && (maxNum = qNums);
|
|
|
+// parseQuestion(qusItem);
|
|
|
+// questcount++;
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
- if (borderItem.pureObject) {
|
|
|
- let columns = 1;
|
|
|
- if (maxNum > 4) {
|
|
|
- columns = 2;
|
|
|
- } else {
|
|
|
- columns = 3;
|
|
|
- }
|
|
|
+// if (borderItem.pureObject) {
|
|
|
+// let columns = 1;
|
|
|
+// if (maxNum > 4) {
|
|
|
+// columns = 2;
|
|
|
+// } else {
|
|
|
+// columns = 3;
|
|
|
+// }
|
|
|
|
|
|
- let rows = Math.ceil(questcount / columns / 5);
|
|
|
- borderData.row = rows;
|
|
|
- borderData.column = columns;
|
|
|
- }
|
|
|
- }
|
|
|
- let commondsLength = conmands.length;
|
|
|
- asynExecCommand(0, commondsLength);
|
|
|
-}
|
|
|
+// let rows = Math.ceil(questcount / columns / 5);
|
|
|
+// borderData.row = rows;
|
|
|
+// borderData.column = columns;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// let commondsLength = conmands.length;
|
|
|
+// asynExecCommand(0, commondsLength);
|
|
|
+// }
|
|
|
|
|
|
-function checkoutCententChange() {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- while (editor.page._checkCrossing || editor.page._addParagraphStatus || editor.page._contentChangeStatus) {}
|
|
|
- resolve(true);
|
|
|
- });
|
|
|
-}
|
|
|
-async function asynExecCommand (i, length) {
|
|
|
- if (i < length) {
|
|
|
- let result = await checkoutCententChange();
|
|
|
- if (result) {
|
|
|
- editor.cmd.do(conmands[i].exc, conmands[i].params);
|
|
|
- if (conmands[i].exc === 'border' && conmands[i].params.type === 1) {
|
|
|
- editor.isDoObject = true;
|
|
|
- } else if (conmands[i].exc === 'questiontype' && conmands[i].params.type === 1){
|
|
|
- editor.isDoObject = true;
|
|
|
- } else if (conmands[i].exc === 'questiontype' && conmands[i].params.type === 2) {
|
|
|
- editor.isDoObject = true;
|
|
|
- } else {
|
|
|
- editor.isDoObject = false;
|
|
|
- }
|
|
|
- i++;
|
|
|
- }
|
|
|
- asynExecCommand(i, length);
|
|
|
- } else {
|
|
|
- editor.page._checkContentOutThrottle();
|
|
|
- }
|
|
|
-}
|
|
|
+// function checkoutCententChange() {
|
|
|
+// return new Promise((resolve, reject) => {
|
|
|
+// while (editor.page._checkCrossing || editor.page._addParagraphStatus || editor.page._contentChangeStatus) {}
|
|
|
+// resolve(true);
|
|
|
+// });
|
|
|
+// }
|
|
|
+// async function asynExecCommand (i, length) {
|
|
|
+// if (i < length) {
|
|
|
+// let result = await checkoutCententChange();
|
|
|
+// if (result) {
|
|
|
+// editor.cmd.do(conmands[i].exc, conmands[i].params);
|
|
|
+// if (conmands[i].exc === 'border' && conmands[i].params.type === 1) {
|
|
|
+// editor.isDoObject = true;
|
|
|
+// } else if (conmands[i].exc === 'questiontype' && conmands[i].params.type === 1){
|
|
|
+// editor.isDoObject = true;
|
|
|
+// } else if (conmands[i].exc === 'questiontype' && conmands[i].params.type === 2) {
|
|
|
+// editor.isDoObject = true;
|
|
|
+// } else {
|
|
|
+// editor.isDoObject = false;
|
|
|
+// }
|
|
|
+// i++;
|
|
|
+// }
|
|
|
+// asynExecCommand(i, length);
|
|
|
+// } else {
|
|
|
+// editor.page._checkContentOutThrottle();
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
-function parseQuestion (qitem) {
|
|
|
- let type = qitem.quType;
|
|
|
- switch(type) {
|
|
|
- case '单选题':
|
|
|
- case '多选题':
|
|
|
- let conmandItem1 = {
|
|
|
- exc: 'questiontype',
|
|
|
- params: {type: 1, data: qitem}
|
|
|
- }
|
|
|
- conmands.push(conmandItem1);
|
|
|
- break;
|
|
|
- case '判断题':
|
|
|
+// function parseQuestion (qitem) {
|
|
|
+// let type = qitem.quType;
|
|
|
+// switch(type) {
|
|
|
+// case '单选题':
|
|
|
+// case '多选题':
|
|
|
+// let conmandItem1 = {
|
|
|
+// exc: 'questiontype',
|
|
|
+// params: {type: 1, data: qitem}
|
|
|
+// }
|
|
|
+// conmands.push(conmandItem1);
|
|
|
+// break;
|
|
|
+// case '判断题':
|
|
|
|
|
|
- let conmandItem2 = {
|
|
|
- exc: 'questiontype',
|
|
|
- params: {type: 2, data: qitem}
|
|
|
- }
|
|
|
- conmands.push(conmandItem2);
|
|
|
- break;
|
|
|
+// let conmandItem2 = {
|
|
|
+// exc: 'questiontype',
|
|
|
+// params: {type: 2, data: qitem}
|
|
|
+// }
|
|
|
+// conmands.push(conmandItem2);
|
|
|
+// break;
|
|
|
|
|
|
- case '填空题':
|
|
|
- case '解答题':
|
|
|
- let conmandItem3 = {
|
|
|
- exc: 'questiontype',
|
|
|
- params: {type: 3, data: qitem}
|
|
|
- }
|
|
|
- conmands.push(conmandItem3);
|
|
|
- break;
|
|
|
+// case '填空题':
|
|
|
+// case '解答题':
|
|
|
+// let conmandItem3 = {
|
|
|
+// exc: 'questiontype',
|
|
|
+// params: {type: 3, data: qitem}
|
|
|
+// }
|
|
|
+// conmands.push(conmandItem3);
|
|
|
+// break;
|
|
|
|
|
|
- case '作文题':
|
|
|
- let conmandItem4 = {
|
|
|
- exc: 'questiontype',
|
|
|
- params: {type: 4, data: qitem}
|
|
|
- }
|
|
|
- conmands.push(conmandItem4);
|
|
|
- break;
|
|
|
- }
|
|
|
-}
|
|
|
+// case '作文题':
|
|
|
+// let conmandItem4 = {
|
|
|
+// exc: 'questiontype',
|
|
|
+// params: {type: 4, data: qitem}
|
|
|
+// }
|
|
|
+// conmands.push(conmandItem4);
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
|
|
|
console.log(editor);
|