|
@@ -19,57 +19,20 @@ export async function answerPointHandle() {
|
|
|
node.dataset.order = 0;
|
|
|
|
|
|
document.execCommand("insertHTML", false, node.outerHTML);
|
|
|
-
|
|
|
- const answerPoints = this.$refs.editor.querySelectorAll(
|
|
|
- "[data-is-answer-point]"
|
|
|
- );
|
|
|
- // console.log(answerPoints);
|
|
|
- const answerPointsChanged = [];
|
|
|
- [...answerPoints].forEach((answerPoint, index) => {
|
|
|
- answerPointsChanged.push(+answerPoint.dataset.order); // 发现是0时,在answer里面增加一个元素
|
|
|
- answerPoint.dataset.order = index + 1;
|
|
|
- answerPoint.src = getAnswerPointImg(index + 1);
|
|
|
- });
|
|
|
- // console.log({ answerPointsChanged });
|
|
|
- this.$emit("emitJSON");
|
|
|
- this.$emit("answer-point-changed", answerPointsChanged);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 答题点拖动后更新,通过判断是否有 [data-is-answer-point-x] 来判断是否是拖动
|
|
|
* 因为drag会触发两次input,第一次事件是删除,要忽略第一次事件
|
|
|
*
|
|
|
- * @param {InputEvent} event
|
|
|
* @this {Object} VEditor 因为VEditor会带很多选项,所以绑定this传过来
|
|
|
*/
|
|
|
-export async function answerPointDragHandle(event) {
|
|
|
- // console.log(event);
|
|
|
- if (!["insertFromDrop", "deleteContentBackward"].includes(event.inputType)) {
|
|
|
- // 只监听drop事件,因为会造成删除
|
|
|
- return;
|
|
|
- }
|
|
|
- const answerPointX = this.$refs.editor.querySelectorAll(
|
|
|
- "[data-is-answer-point-x]"
|
|
|
- );
|
|
|
- // console.log(answerPointX);
|
|
|
+export async function answerPointRebuild() {
|
|
|
const answerPoints = this.$refs.editor.querySelectorAll(
|
|
|
"[data-is-answer-point]"
|
|
|
);
|
|
|
- // console.log(answerPoints);
|
|
|
- // 没有答题点也会进入这里
|
|
|
- if (answerPoints.length === 0 || answerPointX.length > 0) {
|
|
|
- this.$emit("emitJSON");
|
|
|
- this.$emit("answer-point-changed", []);
|
|
|
- return;
|
|
|
- }
|
|
|
- // console.log("is drag", answerPoints);
|
|
|
- const answerPointsChanged = [];
|
|
|
[...answerPoints].forEach((answerPoint, index) => {
|
|
|
- answerPointsChanged.push(+answerPoint.dataset.order); // 发现是0时,在answer里面增加一个元素
|
|
|
answerPoint.dataset.order = index + 1;
|
|
|
answerPoint.src = getAnswerPointImg(index + 1);
|
|
|
});
|
|
|
- // console.log({ answerPointsChanged });
|
|
|
- this.$emit("emitJSON");
|
|
|
- this.$emit("answer-point-changed", answerPointsChanged);
|
|
|
}
|