|
|
@@ -123,6 +123,7 @@
|
|
|
:inline="true"
|
|
|
:item-index="i + '#' + j"
|
|
|
toolbar="fontselect fontsizeselect forecolor backcolor | underline | bold italic strikethrough alignleft aligncenter alignright image media link"
|
|
|
+ @createParsedTextInfoPinyin="handleParsedTextPinyin($event, i, j)"
|
|
|
/>
|
|
|
<el-input v-else v-model="li.content" @blur="handleBlurCon" />
|
|
|
<el-button size="mini" @click="editCell(li.cell)">设置</el-button>
|
|
|
@@ -219,10 +220,15 @@
|
|
|
<tr v-for="(item, j) in row" :key="item.mark">
|
|
|
<td class="pinyin-cell">
|
|
|
<PinyinText
|
|
|
+ :id="'table_pinyin_text_' + i + '_' + j"
|
|
|
+ :key="i + '_' + j"
|
|
|
ref="PinyinText"
|
|
|
:paragraph-list="item.paragraph_list"
|
|
|
:rich-text-list="item.rich_text_list"
|
|
|
:pinyin-position="data.property.pinyin_position"
|
|
|
+ :pinyin-size="data?.unified_attrib?.pinyin_size"
|
|
|
+ :font-size="data?.unified_attrib?.font_size"
|
|
|
+ :font-family="data?.unified_attrib?.font"
|
|
|
@fillCorrectPinyin="fillCorrectPinyin($event, i, j)"
|
|
|
/>
|
|
|
</td>
|
|
|
@@ -365,28 +371,42 @@ export default {
|
|
|
},
|
|
|
'data.property.view_pinyin': {
|
|
|
handler(val) {
|
|
|
+ // 下面都是原来的处理方式
|
|
|
+ // let text = '';
|
|
|
+ // this.data.option_list.forEach((item) => {
|
|
|
+ // item.forEach((items) => {
|
|
|
+ // text += `${items.content.replace(/<[^>]+>/g, '')}\n`;
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // if (!isEnable(val)) {
|
|
|
+ // this.data.paragraph_list = [];
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // if (isEnable(val) && text && this.data.paragraph_list.length <= 0) {
|
|
|
+ // this.data.paragraph_list_parameter.text = text;
|
|
|
+ // this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case =
|
|
|
+ // this.data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case;
|
|
|
+ // this.data.option_list.forEach((item, index) => {
|
|
|
+ // item.forEach((items, indexs) => {
|
|
|
+ // this.createParsedTextInfoPinyin(items.content, `${index}#${indexs}`);
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+
|
|
|
if (this.property.isSilentPropertyWatch) return;
|
|
|
- let text = '';
|
|
|
- this.data.option_list.forEach((item) => {
|
|
|
- item.forEach((items) => {
|
|
|
- text += `${items.content.replace(/<[^>]+>/g, '')}\n`;
|
|
|
- });
|
|
|
- });
|
|
|
- this.optionWordDataMap = {};
|
|
|
- this.optionWordDataSourceMap = {};
|
|
|
- if (!isEnable(val)) {
|
|
|
- this.data.paragraph_list = [];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (isEnable(val) && text && this.data.paragraph_list.length <= 0) {
|
|
|
- this.data.paragraph_list_parameter.text = text;
|
|
|
- this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case =
|
|
|
- this.data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case;
|
|
|
- this.data.option_list.forEach((item, index) => {
|
|
|
- item.forEach((items, indexs) => {
|
|
|
- this.createParsedTextInfoPinyin(items.content, `${index}#${indexs}`);
|
|
|
+ if (!this.isEnable(val)) {
|
|
|
+ this.data.option_list.forEach((row) => {
|
|
|
+ row.forEach((item) => {
|
|
|
+ item.paragraph_list = [];
|
|
|
+ item.paragraph_list_parameter = {
|
|
|
+ text: '',
|
|
|
+ pinyin_proofread_word_list: [],
|
|
|
+ };
|
|
|
});
|
|
|
});
|
|
|
+ this.optionWordDataMap = {};
|
|
|
+ this.optionWordDataSourceMap = {};
|
|
|
+ return;
|
|
|
}
|
|
|
this.handleViewPinyin().finally(() => {
|
|
|
this.inited = true;
|
|
|
@@ -394,31 +414,31 @@ export default {
|
|
|
},
|
|
|
deep: true,
|
|
|
},
|
|
|
- 'data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case': {
|
|
|
- handler(val, oldVal) {
|
|
|
- if (val === oldVal) return;
|
|
|
- let text = '';
|
|
|
- this.data.option_list.forEach((item) => {
|
|
|
- item.forEach((items) => {
|
|
|
- text += `${items.content.replace(/<[^>]+>/g, '')}\n`;
|
|
|
- });
|
|
|
- });
|
|
|
- if (!isEnable(this.data.property.view_pinyin)) {
|
|
|
- this.data.paragraph_list = [];
|
|
|
- return;
|
|
|
- }
|
|
|
- if (text && isEnable(this.data.property.view_pinyin)) {
|
|
|
- this.data.paragraph_list_parameter.text = text;
|
|
|
- this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case = val;
|
|
|
- this.data.option_list.forEach((item, index) => {
|
|
|
- item.forEach((items, indexs) => {
|
|
|
- this.createParsedTextInfoPinyin(items.content, `${index}#${indexs}`);
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- deep: true,
|
|
|
- },
|
|
|
+ // 'data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case': {
|
|
|
+ // handler(val, oldVal) {
|
|
|
+ // if (val === oldVal) return;
|
|
|
+ // let text = '';
|
|
|
+ // this.data.option_list.forEach((item) => {
|
|
|
+ // item.forEach((items) => {
|
|
|
+ // text += `${items.content.replace(/<[^>]+>/g, '')}\n`;
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // if (!isEnable(this.data.property.view_pinyin)) {
|
|
|
+ // this.data.paragraph_list = [];
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // if (text && isEnable(this.data.property.view_pinyin)) {
|
|
|
+ // this.data.paragraph_list_parameter.text = text;
|
|
|
+ // this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case = val;
|
|
|
+ // this.data.option_list.forEach((item, index) => {
|
|
|
+ // item.forEach((items, indexs) => {
|
|
|
+ // this.createParsedTextInfoPinyin(items.content, `${index}#${indexs}`);
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ // deep: true,
|
|
|
+ // },
|
|
|
'data.vocabulary': {
|
|
|
handler(val) {
|
|
|
if (!val) return;
|
|
|
@@ -489,6 +509,7 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
async handleViewPinyin(isPrompt = false) {
|
|
|
+ this.data.has_identify = 'true';
|
|
|
if (isPrompt) {
|
|
|
try {
|
|
|
await this.$confirm('刷新将会重置分词和拼音,是否刷新?', '提示', {
|
|
|
@@ -500,7 +521,106 @@ export default {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- this.identifyText();
|
|
|
+ try {
|
|
|
+ if (!this.isEnable(this.data.property.view_pinyin)) {
|
|
|
+ this.data.option_list.forEach((row) => {
|
|
|
+ row.forEach((item) => {
|
|
|
+ item.paragraph_list = [];
|
|
|
+ item.paragraph_list_parameter = {
|
|
|
+ text: '',
|
|
|
+ pinyin_proofread_word_list: [],
|
|
|
+ };
|
|
|
+ item.model_essay = [];
|
|
|
+ // this.data.answer_list[index][indexs].answer_list = [];
|
|
|
+ if (item.content) {
|
|
|
+ let inputIndex = 0;
|
|
|
+ item.content
|
|
|
+ .split(/<(p|div)[^>]*>(.*?)<\/(p|div)>/g)
|
|
|
+ .filter((s) => s && !s.match(/^(p|div)$/))
|
|
|
+ .forEach((itemss) => {
|
|
|
+ if (itemss.charCodeAt() === 10) return;
|
|
|
+ let strArr = itemss.split(/_{3,}/g);
|
|
|
+ strArr.forEach((itemS, index) => {
|
|
|
+ item.model_essay.push({
|
|
|
+ value: itemS,
|
|
|
+ type: 'text',
|
|
|
+ });
|
|
|
+ if (index !== strArr.length - 1) {
|
|
|
+ item.model_essay.push({
|
|
|
+ value: '',
|
|
|
+ type: 'input',
|
|
|
+ mark: getRandomNumber(),
|
|
|
+ inputIndex,
|
|
|
+ write_base64: '',
|
|
|
+ audio_answer_list: [],
|
|
|
+ });
|
|
|
+ inputIndex += 1;
|
|
|
+ this.$set(item, 'hasInput', true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // // 去除所有的 font-size 样式
|
|
|
+ // .replace(/font-size:\s*\d+(\.\d+)?px;/gi, '')
|
|
|
+ // // 匹配 class 名为 rich-fill 的 span 标签和三个以上的_,并将它们组成数组
|
|
|
+ // .replace(/<span class="rich-fill".*?>(.*?)<\/span>|([_]{3,})/gi, '###$1$2###');
|
|
|
+ });
|
|
|
+ }
|
|
|
+ item.crossAnswer = 'normal';
|
|
|
+ });
|
|
|
+ });
|
|
|
+ this.optionWordDataMap = {};
|
|
|
+ this.optionWordDataSourceMap = {};
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const tasks = [];
|
|
|
+ this.data.option_list.forEach((row, i) => {
|
|
|
+ row.forEach((item, j) => {
|
|
|
+ const text = item.content;
|
|
|
+ if (!text) return;
|
|
|
+ let obj = {
|
|
|
+ text: text,
|
|
|
+ pinyin_proofread_word_list: [],
|
|
|
+ };
|
|
|
+ this.$set(item, 'paragraph_list_parameter', obj);
|
|
|
+ tasks.push(
|
|
|
+ this.createParsedTextInfoPinyin(text, i, j).then(({ parsed_text, rich_text }) => {
|
|
|
+ this.$set(this.optionWordDataMap, item.mark, buildWordProofreadData(parsed_text?.paragraph_list || []));
|
|
|
+ this.$set(this.optionWordDataSourceMap, item.mark, text);
|
|
|
+ let list = rich_text.text_list;
|
|
|
+ list.forEach((item) => {
|
|
|
+ let inputIndex = 0;
|
|
|
+ if (item.word_list) {
|
|
|
+ item.word_list.forEach((items, index) => {
|
|
|
+ let isUnderline = /^_{3,}$/.test(items.text);
|
|
|
+ if (isUnderline) {
|
|
|
+ let obj = {
|
|
|
+ value: '',
|
|
|
+ type: 'input',
|
|
|
+ mark: getRandomNumber(),
|
|
|
+ inputIndex,
|
|
|
+ write_base64: '',
|
|
|
+ audio_answer_list: [],
|
|
|
+ };
|
|
|
+ inputIndex++;
|
|
|
+ item.word_list[index] = { ...items, ...obj };
|
|
|
+ } else {
|
|
|
+ items.type = 'text';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ item.type = 'text';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.$set(item, 'rich_text_list', list);
|
|
|
+ }),
|
|
|
+ );
|
|
|
+ });
|
|
|
+ });
|
|
|
+ await Promise.all(tasks);
|
|
|
+ } finally {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ // this.identifyText();
|
|
|
},
|
|
|
// 识别文本
|
|
|
identifyText(editIndex) {
|
|
|
@@ -562,102 +682,102 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
// 获取拼音解析文本
|
|
|
- createParsedTextInfoPinyin(text, editIndex, flag) {
|
|
|
- if (text === '') {
|
|
|
- this.data.paragraph_list_parameter.pinyin_proofread_word_list = [];
|
|
|
- return;
|
|
|
- }
|
|
|
- // .replace(/<[^>]+>/g, '')
|
|
|
- this.data.paragraph_list_parameter.text = text;
|
|
|
- this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case =
|
|
|
- this.data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case;
|
|
|
- this.data.paragraph_list_parameter.is_rich_text = 'true';
|
|
|
- if (flag) this.loading = true;
|
|
|
- PinyinBuild_OldFormat(this.data.paragraph_list_parameter).then((res) => {
|
|
|
- if (flag) {
|
|
|
- this.loading = false;
|
|
|
- }
|
|
|
- if (res.parsed_text) {
|
|
|
- const mergedData = res.parsed_text.paragraph_list.map((outerArr, i) =>
|
|
|
- outerArr.map((innerArr, j) =>
|
|
|
- innerArr.map((newItem, k) => {
|
|
|
- // 从 originalData 中找到对应的项
|
|
|
- const originalItem = this.data.paragraph_list[i]?.[j]?.[k];
|
|
|
-
|
|
|
- // 如果 originalItem 有 activeTextStyle,就合并到 newItem
|
|
|
- if (originalItem?.activeTextStyle) {
|
|
|
- return {
|
|
|
- ...newItem,
|
|
|
- activeTextStyle: originalItem.activeTextStyle,
|
|
|
- };
|
|
|
- }
|
|
|
- // 否则直接返回 newItem
|
|
|
- return newItem;
|
|
|
- }),
|
|
|
- ),
|
|
|
- );
|
|
|
- this.data.paragraph_list = mergedData;
|
|
|
- if (editIndex) {
|
|
|
- let arr = editIndex.split('#');
|
|
|
- let list = res.rich_text.text_list;
|
|
|
- list.forEach((item) => {
|
|
|
- let inputIndex = 0;
|
|
|
- if (item.word_list) {
|
|
|
- item.word_list.forEach((items, index) => {
|
|
|
- let isUnderline = /^_{3,}$/.test(items.text);
|
|
|
- if (isUnderline) {
|
|
|
- let obj = {
|
|
|
- value: '',
|
|
|
- type: 'input',
|
|
|
- mark: getRandomNumber(),
|
|
|
- inputIndex,
|
|
|
- write_base64: '',
|
|
|
- audio_answer_list: [],
|
|
|
- };
|
|
|
- inputIndex++;
|
|
|
- item.word_list[index] = { ...items, ...obj };
|
|
|
- } else {
|
|
|
- items.type = 'text';
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- item.type = 'text';
|
|
|
- }
|
|
|
- });
|
|
|
- this.$set(this.data.option_list[arr[0]][arr[1]], 'rich_text_list', list);
|
|
|
- } else {
|
|
|
- this.$set(this.data, 'rich_text_list', res.rich_text.text_list);
|
|
|
- }
|
|
|
- let pinyin_index = 0;
|
|
|
- this.data.option_list.forEach((item, index) => {
|
|
|
- item.forEach((items, indexs) => {
|
|
|
- items.model_pinyin = [];
|
|
|
- let inputIndex = 0;
|
|
|
- if (items.content && mergedData[pinyin_index] && mergedData[pinyin_index][0]) {
|
|
|
- mergedData[pinyin_index][0].forEach((itemP) => {
|
|
|
- let isUnderline = /^_{3,}$/.test(itemP.text);
|
|
|
- if (isUnderline) {
|
|
|
- items.model_pinyin.push({
|
|
|
- value: '',
|
|
|
- type: 'input',
|
|
|
- mark: getRandomNumber(),
|
|
|
- inputIndex,
|
|
|
- });
|
|
|
- inputIndex++;
|
|
|
- } else {
|
|
|
- items.model_pinyin.push(itemP);
|
|
|
- }
|
|
|
- });
|
|
|
- pinyin_index++;
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- if (this.editContentIndex) {
|
|
|
- this.editContentIndex = '';
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
+ // createParsedTextInfoPinyin(text, editIndex, flag) {
|
|
|
+ // if (text === '') {
|
|
|
+ // this.data.paragraph_list_parameter.pinyin_proofread_word_list = [];
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // // .replace(/<[^>]+>/g, '')
|
|
|
+ // this.data.paragraph_list_parameter.text = text;
|
|
|
+ // this.data.paragraph_list_parameter.is_first_sentence_first_hz_pinyin_first_char_upper_case =
|
|
|
+ // this.data.property.is_first_sentence_first_hz_pinyin_first_char_upper_case;
|
|
|
+ // this.data.paragraph_list_parameter.is_rich_text = 'true';
|
|
|
+ // if (flag) this.loading = true;
|
|
|
+ // PinyinBuild_OldFormat(this.data.paragraph_list_parameter).then((res) => {
|
|
|
+ // if (flag) {
|
|
|
+ // this.loading = false;
|
|
|
+ // }
|
|
|
+ // if (res.parsed_text) {
|
|
|
+ // const mergedData = res.parsed_text.paragraph_list.map((outerArr, i) =>
|
|
|
+ // outerArr.map((innerArr, j) =>
|
|
|
+ // innerArr.map((newItem, k) => {
|
|
|
+ // // 从 originalData 中找到对应的项
|
|
|
+ // const originalItem = this.data.paragraph_list[i]?.[j]?.[k];
|
|
|
+
|
|
|
+ // // 如果 originalItem 有 activeTextStyle,就合并到 newItem
|
|
|
+ // if (originalItem?.activeTextStyle) {
|
|
|
+ // return {
|
|
|
+ // ...newItem,
|
|
|
+ // activeTextStyle: originalItem.activeTextStyle,
|
|
|
+ // };
|
|
|
+ // }
|
|
|
+ // // 否则直接返回 newItem
|
|
|
+ // return newItem;
|
|
|
+ // }),
|
|
|
+ // ),
|
|
|
+ // );
|
|
|
+ // this.data.paragraph_list = mergedData;
|
|
|
+ // if (editIndex) {
|
|
|
+ // let arr = editIndex.split('#');
|
|
|
+ // let list = res.rich_text.text_list;
|
|
|
+ // list.forEach((item) => {
|
|
|
+ // let inputIndex = 0;
|
|
|
+ // if (item.word_list) {
|
|
|
+ // item.word_list.forEach((items, index) => {
|
|
|
+ // let isUnderline = /^_{3,}$/.test(items.text);
|
|
|
+ // if (isUnderline) {
|
|
|
+ // let obj = {
|
|
|
+ // value: '',
|
|
|
+ // type: 'input',
|
|
|
+ // mark: getRandomNumber(),
|
|
|
+ // inputIndex,
|
|
|
+ // write_base64: '',
|
|
|
+ // audio_answer_list: [],
|
|
|
+ // };
|
|
|
+ // inputIndex++;
|
|
|
+ // item.word_list[index] = { ...items, ...obj };
|
|
|
+ // } else {
|
|
|
+ // items.type = 'text';
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // } else {
|
|
|
+ // item.type = 'text';
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // this.$set(this.data.option_list[arr[0]][arr[1]], 'rich_text_list', list);
|
|
|
+ // } else {
|
|
|
+ // this.$set(this.data, 'rich_text_list', res.rich_text.text_list);
|
|
|
+ // }
|
|
|
+ // let pinyin_index = 0;
|
|
|
+ // this.data.option_list.forEach((item, index) => {
|
|
|
+ // item.forEach((items, indexs) => {
|
|
|
+ // items.model_pinyin = [];
|
|
|
+ // let inputIndex = 0;
|
|
|
+ // if (items.content && mergedData[pinyin_index] && mergedData[pinyin_index][0]) {
|
|
|
+ // mergedData[pinyin_index][0].forEach((itemP) => {
|
|
|
+ // let isUnderline = /^_{3,}$/.test(itemP.text);
|
|
|
+ // if (isUnderline) {
|
|
|
+ // items.model_pinyin.push({
|
|
|
+ // value: '',
|
|
|
+ // type: 'input',
|
|
|
+ // mark: getRandomNumber(),
|
|
|
+ // inputIndex,
|
|
|
+ // });
|
|
|
+ // inputIndex++;
|
|
|
+ // } else {
|
|
|
+ // items.model_pinyin.push(itemP);
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // pinyin_index++;
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // });
|
|
|
+ // if (this.editContentIndex) {
|
|
|
+ // this.editContentIndex = '';
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // },
|
|
|
// // 填充校对后的拼音
|
|
|
// fillCorrectPinyin({ selectContent: { text, pinyin, activeTextStyle }, i, j, k }) {
|
|
|
// this.data.paragraph_list_parameter.pinyin_proofread_word_list.push({
|
|
|
@@ -710,10 +830,44 @@ export default {
|
|
|
colIndex,
|
|
|
'option_list',
|
|
|
saveArr,
|
|
|
- );
|
|
|
+ ).then(({ rich_text }) => {
|
|
|
+ let list = rich_text.text_list;
|
|
|
+ list.forEach((item) => {
|
|
|
+ let inputIndex = 0;
|
|
|
+ if (item.word_list) {
|
|
|
+ item.word_list.forEach((items, index) => {
|
|
|
+ let isUnderline = /^_{3,}$/.test(items.text);
|
|
|
+ if (isUnderline) {
|
|
|
+ let obj = {
|
|
|
+ value: '',
|
|
|
+ type: 'input',
|
|
|
+ mark: getRandomNumber(),
|
|
|
+ inputIndex,
|
|
|
+ write_base64: '',
|
|
|
+ audio_answer_list: [],
|
|
|
+ };
|
|
|
+ inputIndex++;
|
|
|
+ item.word_list[index] = { ...items, ...obj };
|
|
|
+ } else {
|
|
|
+ items.type = 'text';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ item.type = 'text';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.$set(this.data.option_list[rowIndex][colIndex], 'rich_text_list', list);
|
|
|
+ });
|
|
|
this.$set(this.optionWordDataMap, option.mark, buildWordProofreadData(parsed_text?.paragraph_list || []));
|
|
|
this.$set(this.optionWordDataSourceMap, option.mark, option.content || '');
|
|
|
},
|
|
|
+ handleParsedTextPinyin(text, i, j) {
|
|
|
+ if (!this.isEnable(this.data.property.view_pinyin)) return;
|
|
|
+ if (this.data.option_list?.length > 0 && this.data.option_list[0].paragraph_list?.length > 0) return;
|
|
|
+ if (!text) return;
|
|
|
+ this.data.option_list[i][j].paragraph_list_parameter.text = text.replace(/<[^>]+>/g, '').replace(/ /g, ' ');
|
|
|
+ this.createParsedTextInfoPinyin(text, i, j);
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|