@datawhale/prosemirror-render 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{AttachmentBlock-ChMNTUOo.mjs → AttachmentBlock-BTIBSu4p.js} +2 -2
- package/dist/AttachmentBlock-W05YY8zN.cjs +1 -0
- package/dist/{AttachmentInline-tbC8BJBy.mjs → AttachmentInline-BF7QTLxZ.js} +2 -2
- package/dist/AttachmentInline-CgV-t0WF.cjs +1 -0
- package/dist/{AttachmentMenu-B5x8P9_n.mjs → AttachmentMenu-BjM7LAlw.js} +1 -1
- package/dist/AttachmentMenu-vc18PNLc.cjs +1 -0
- package/dist/{Callout-Cu6HI-xq.mjs → Callout-BH6_xPHP.js} +2 -2
- package/dist/Callout-BgG8-zJn.cjs +1 -0
- package/dist/{CellOutput-DiKZlIFa.js → CellOutput-CXb77W7X.cjs} +1 -1
- package/dist/{CellOutput-C33VK0df.mjs → CellOutput-DJqn5MJH.js} +1 -1
- package/dist/{CodeBlock-DWniNUQB.js → CodeBlock-BejcPvxj.cjs} +1 -1
- package/dist/{CodeBlock-Cjuxuq7B.mjs → CodeBlock-D9lrTXj3.js} +1 -1
- package/dist/FoldBlock-CMDkkdoU.cjs +1 -0
- package/dist/{FoldBlock-DRdlU-DX.mjs → FoldBlock-CZwxKsSG.js} +2 -2
- package/dist/{Grid-GfmJxM93.mjs → Grid-B53O57Vv.js} +1 -1
- package/dist/Grid-Cw9joyDF.cjs +1 -0
- package/dist/IFrame-CP2oHuDb.cjs +1 -0
- package/dist/{IFrame-CaAOVLGN.mjs → IFrame-DRvqa1hl.js} +1 -1
- package/dist/Image-B9Rer9RA.cjs +1 -0
- package/dist/{Image-C8v5dCij.mjs → Image-BjIZuyk1.js} +1 -1
- package/dist/{MathDisplay-CoGsFzXW.mjs → MathDisplay-BficZWEq.js} +2 -2
- package/dist/MathDisplay-D5rx_pee.cjs +1 -0
- package/dist/{MathInline-0xTZoIIq.mjs → MathInline-Ca8s53fu.js} +2 -2
- package/dist/MathInline-DZ86cc6g.cjs +1 -0
- package/dist/{McChoices-Aj394G5E.mjs → McChoices-B8W03KdG.js} +1 -1
- package/dist/McChoices-CW1gsp_V.cjs +1 -0
- package/dist/McQuestion-DwBWk5S2.cjs +1 -0
- package/dist/{McQuestion-DvD-J47M.mjs → McQuestion-WyxeDFjM.js} +1 -1
- package/dist/McSolution-BtY7RBEb.cjs +1 -0
- package/dist/{McSolution-C5sTXz3y.mjs → McSolution-CRahjdmW.js} +1 -1
- package/dist/{MultipleChoice-Dv-k1zUU.mjs → MultipleChoice-BgGHy-NW.js} +4 -4
- package/dist/MultipleChoice-mFFm3sQv.cjs +1 -0
- package/dist/{Paragraph-DGcZy8t_.mjs → Paragraph-C3uQVRMm.js} +1 -1
- package/dist/Paragraph-CU-CMQz2.cjs +1 -0
- package/dist/{SlotNode-6OpoUcOa.mjs → SlotNode-BThSEhpr.js} +1 -1
- package/dist/SlotNode-ivBAGFTX.cjs +1 -0
- package/dist/Text-3RT27QJn.cjs +1 -0
- package/dist/{Text-Br_pcGz4.mjs → Text-cG9dlJgd.js} +1 -1
- package/dist/{index-DVmWCrQE.mjs → index-C97tUvOp.js} +30 -30
- package/dist/index-DuVSDVpW.cjs +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/package.json +8 -2
- package/dist/AttachmentBlock-DsmJP3Kw.js +0 -1
- package/dist/AttachmentInline-Dc3dp0g-.js +0 -1
- package/dist/AttachmentMenu-ExoCOe4B.js +0 -1
- package/dist/Callout-DPdOqTb4.js +0 -1
- package/dist/FoldBlock-ZPMf0QsR.js +0 -1
- package/dist/Grid-QToZdaRT.js +0 -1
- package/dist/IFrame-DcCpSoDC.js +0 -1
- package/dist/Image-cHL85CXs.js +0 -1
- package/dist/MathDisplay-CESKZV46.js +0 -1
- package/dist/MathInline-C_1SJUVz.js +0 -1
- package/dist/McChoices-B4euzY7M.js +0 -1
- package/dist/McQuestion-Dq0aM5tC.js +0 -1
- package/dist/McSolution-N79CllH9.js +0 -1
- package/dist/MultipleChoice-DTCF3Q8m.js +0 -1
- package/dist/Paragraph-CzRSCJNr.js +0 -1
- package/dist/SlotNode-DMG0R6Vf.js +0 -1
- package/dist/Text-DlUfrsNI.js +0 -1
- package/dist/index-D2CtpNvR.js +0 -1
- package/src/apis/monitor.ts +0 -8
- package/src/apis/tingwu.ts +0 -22
- package/src/apis/types.ts +0 -45
- package/src/components/TreeRecursive.vue +0 -47
- package/src/components/TreeRender.vue +0 -404
- package/src/components/collections/async/AsyncError.vue +0 -17
- package/src/components/collections/async/AsyncLoading.vue +0 -1
- package/src/components/collections/attachment/AttachmentBlock.vue +0 -561
- package/src/components/collections/attachment/AttachmentInline.vue +0 -90
- package/src/components/collections/attachment/AttachmentMenu.vue +0 -359
- package/src/components/collections/attachment/VideoDetail.vue +0 -375
- package/src/components/collections/attachment/index.ts +0 -6
- package/src/components/collections/basic/Blockquote.vue +0 -15
- package/src/components/collections/basic/BulletList.vue +0 -15
- package/src/components/collections/basic/HardBreak.vue +0 -11
- package/src/components/collections/basic/Heading.vue +0 -15
- package/src/components/collections/basic/HorizontalRule.vue +0 -11
- package/src/components/collections/basic/ListItem.vue +0 -15
- package/src/components/collections/basic/OrderedList.vue +0 -15
- package/src/components/collections/basic/Paragraph.vue +0 -19
- package/src/components/collections/basic/Text.vue +0 -73
- package/src/components/collections/basic/index.ts +0 -13
- package/src/components/collections/callout/Callout.vue +0 -77
- package/src/components/collections/callout/index.ts +0 -5
- package/src/components/collections/code/CellOutput.vue +0 -72
- package/src/components/collections/code/CodeBlock.vue +0 -83
- package/src/components/collections/code/index.ts +0 -6
- package/src/components/collections/fold/FoldBlock.vue +0 -130
- package/src/components/collections/fold/index.ts +0 -5
- package/src/components/collections/grid/Grid.vue +0 -70
- package/src/components/collections/grid/index.ts +0 -5
- package/src/components/collections/iframe/IFrame.vue +0 -19
- package/src/components/collections/iframe/index.ts +0 -5
- package/src/components/collections/img/Image.vue +0 -318
- package/src/components/collections/img/index.ts +0 -5
- package/src/components/collections/index.ts +0 -29
- package/src/components/collections/math/MathDisplay.vue +0 -42
- package/src/components/collections/math/MathInline.vue +0 -42
- package/src/components/collections/math/index.ts +0 -6
- package/src/components/collections/multipleChoice/McChoices.vue +0 -72
- package/src/components/collections/multipleChoice/McQuestion.vue +0 -61
- package/src/components/collections/multipleChoice/McSolution.vue +0 -47
- package/src/components/collections/multipleChoice/MultipleChoice.vue +0 -62
- package/src/components/collections/multipleChoice/index.ts +0 -8
- package/src/components/collections/table/TableCell.vue +0 -20
- package/src/components/collections/table/TableContainer.vue +0 -32
- package/src/components/collections/table/TableHeader.vue +0 -15
- package/src/components/collections/table/TableRow.vue +0 -15
- package/src/components/collections/table/index.ts +0 -8
- package/src/components/collections/utils.ts +0 -17
- package/src/components/collections/wrapper/Doc.vue +0 -15
- package/src/components/collections/wrapper/SlotNode.vue +0 -5
- package/src/components/collections/wrapper/index.ts +0 -6
- package/src/components/index.ts +0 -1
- package/src/icons/Attachment/CardView.vue +0 -21
- package/src/icons/Attachment/Code/Bat.vue +0 -26
- package/src/icons/Attachment/Code/C.vue +0 -26
- package/src/icons/Attachment/Code/Cpp.vue +0 -26
- package/src/icons/Attachment/Code/Css.vue +0 -34
- package/src/icons/Attachment/Code/Go.vue +0 -26
- package/src/icons/Attachment/Code/Html.vue +0 -34
- package/src/icons/Attachment/Code/Java.vue +0 -42
- package/src/icons/Attachment/Code/Js.vue +0 -26
- package/src/icons/Attachment/Code/Json.vue +0 -26
- package/src/icons/Attachment/Code/Jsx.vue +0 -30
- package/src/icons/Attachment/Code/Md.vue +0 -26
- package/src/icons/Attachment/Code/Php.vue +0 -26
- package/src/icons/Attachment/Code/Python.vue +0 -30
- package/src/icons/Attachment/Code/Rb.vue +0 -26
- package/src/icons/Attachment/Code/Sh.vue +0 -30
- package/src/icons/Attachment/Code/Sql.vue +0 -30
- package/src/icons/Attachment/Code/Swift.vue +0 -26
- package/src/icons/Attachment/Code/Ts.vue +0 -26
- package/src/icons/Attachment/Code/Tsx.vue +0 -30
- package/src/icons/Attachment/Code/Vue.vue +0 -24
- package/src/icons/Attachment/Excel.vue +0 -26
- package/src/icons/Attachment/Eye.vue +0 -15
- package/src/icons/Attachment/FullScreen.vue +0 -15
- package/src/icons/Attachment/InlineView.vue +0 -21
- package/src/icons/Attachment/Pdf.vue +0 -25
- package/src/icons/Attachment/Ppt.vue +0 -26
- package/src/icons/Attachment/PreviewView.vue +0 -21
- package/src/icons/Attachment/UnknownFile.vue +0 -26
- package/src/icons/Attachment/VideoIcon.vue +0 -25
- package/src/icons/Attachment/VideoPlay.vue +0 -15
- package/src/icons/Attachment/Word.vue +0 -26
- package/src/icons/Code/Confirm.vue +0 -38
- package/src/icons/Code/Paste.vue +0 -8
- package/src/icons/Common/Choice.vue +0 -28
- package/src/icons/Common/Close.vue +0 -15
- package/src/icons/Common/Comment.vue +0 -16
- package/src/icons/Common/CopyAnchorLink.vue +0 -15
- package/src/icons/Common/Delete.vue +0 -15
- package/src/icons/Common/Download.vue +0 -15
- package/src/icons/Common/FoldClose.vue +0 -9
- package/src/icons/Common/FoldOpen.vue +0 -9
- package/src/icons/Common/Plate.vue +0 -23
- package/src/icons/Common/Question.vue +0 -8
- package/src/icons/Common/ShareTextLink.vue +0 -15
- package/src/index.ts +0 -3
- package/src/types.ts +0 -236
- package/src/utils/common.ts +0 -6
- package/src/utils/emoji.ts +0 -3715
- package/src/utils/globalStatus.ts +0 -19
- package/src/utils/shiki.ts +0 -25
- package/src/utils/useAttachment.ts +0 -215
- package/tsconfig.build.json +0 -10
- package/tsconfig.json +0 -23
- package/vite.config.ts +0 -24
- /package/dist/{Blockquote-BamWUQND.mjs → Blockquote-BamWUQND.js} +0 -0
- /package/dist/{Blockquote-CQSBFnsu.js → Blockquote-CQSBFnsu.cjs} +0 -0
- /package/dist/{BulletList-BQTUD69X.mjs → BulletList-BQTUD69X.js} +0 -0
- /package/dist/{BulletList-CFjF3U-l.js → BulletList-CFjF3U-l.cjs} +0 -0
- /package/dist/{Doc-6s4VMDsx.mjs → Doc-6s4VMDsx.js} +0 -0
- /package/dist/{Doc-D2yvlSII.js → Doc-D2yvlSII.cjs} +0 -0
- /package/dist/{HardBreak-B2tFO31P.mjs → HardBreak-B2tFO31P.js} +0 -0
- /package/dist/{HardBreak-Dbf5Zg5o.js → HardBreak-Dbf5Zg5o.cjs} +0 -0
- /package/dist/{Heading-BElRvhGn.mjs → Heading-BElRvhGn.js} +0 -0
- /package/dist/{Heading-BUnffIAz.js → Heading-BUnffIAz.cjs} +0 -0
- /package/dist/{HorizontalRule-BRG45oT0.mjs → HorizontalRule-BRG45oT0.js} +0 -0
- /package/dist/{HorizontalRule-CE09LZGf.js → HorizontalRule-CE09LZGf.cjs} +0 -0
- /package/dist/{ListItem-BrjxeGxz.js → ListItem-BrjxeGxz.cjs} +0 -0
- /package/dist/{ListItem-X0T7a_z8.mjs → ListItem-X0T7a_z8.js} +0 -0
- /package/dist/{OrderedList-B8v1gchv.mjs → OrderedList-B8v1gchv.js} +0 -0
- /package/dist/{OrderedList-DMl3tvwP.js → OrderedList-DMl3tvwP.cjs} +0 -0
- /package/dist/{TableCell-BY9gdldc.js → TableCell-BY9gdldc.cjs} +0 -0
- /package/dist/{TableCell-Bp52L368.mjs → TableCell-Bp52L368.js} +0 -0
- /package/dist/{TableContainer-C5KXY6f7.js → TableContainer-C5KXY6f7.cjs} +0 -0
- /package/dist/{TableContainer-C9PhNGlz.mjs → TableContainer-C9PhNGlz.js} +0 -0
- /package/dist/{TableHeader-BTuqvorM.js → TableHeader-BTuqvorM.cjs} +0 -0
- /package/dist/{TableHeader-C7KKz3e1.mjs → TableHeader-C7KKz3e1.js} +0 -0
- /package/dist/{TableRow-D4F6AKFt.js → TableRow-D4F6AKFt.cjs} +0 -0
- /package/dist/{TableRow-OzpVq1qW.mjs → TableRow-OzpVq1qW.js} +0 -0
- /package/dist/{emoji-Bk6FG72F.js → emoji-Bk6FG72F.cjs} +0 -0
- /package/dist/{emoji-CmOToDEU.mjs → emoji-CmOToDEU.js} +0 -0
- /package/dist/{katex-CS0ZfoxP.js → katex-CS0ZfoxP.cjs} +0 -0
- /package/dist/{katex-r9TeExgs.mjs → katex-r9TeExgs.js} +0 -0
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="image-container" :style="{ alignItems: node.attrs.align }">
|
|
3
|
-
<div class="image-wrapper" :style="{ width: restrictedWidth }">
|
|
4
|
-
<img :src="node.attrs.src" :alt="node.attrs.caption ? node.attrs.caption : '图片'" @click="enlarge" />
|
|
5
|
-
</div>
|
|
6
|
-
<input type="text" v-if="node.attrs.caption" class="image-caption" :value="node.attrs.caption" disabled />
|
|
7
|
-
<Teleport to="body">
|
|
8
|
-
<Transition name="modal">
|
|
9
|
-
<div v-show="showModal" class="modal-mask" @click="closeModal">
|
|
10
|
-
<div class="modal-close">×</div>
|
|
11
|
-
<img class="modal-body" :src="currentImageNode?.attrs.src" :width="currentImgWidth" :height="currentImgHeight"
|
|
12
|
-
alt="图片" />
|
|
13
|
-
<div class="modal-footer">
|
|
14
|
-
<div class="prev-image" :class="{ disabled: currentIndex === 0 }" @click.stop="prevImage">‹</div>
|
|
15
|
-
<div class="zoom-out" :class="{ disabled: percentage <= 10 }" @click.stop="zoomOut">-</div>
|
|
16
|
-
<div class="percentage">{{ percentage.toFixed(0) }}%</div>
|
|
17
|
-
<div class="zoom-in" :class="{ disabled: percentage >= 500 }" @click.stop="zoomIn">+</div>
|
|
18
|
-
<div class="next-image" :class="{ disabled: currentIndex === imageNodes.length - 1 }"
|
|
19
|
-
@click.stop="nextImage">
|
|
20
|
-
›
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
</Transition>
|
|
25
|
-
</Teleport>
|
|
26
|
-
</div>
|
|
27
|
-
</template>
|
|
28
|
-
|
|
29
|
-
<script setup lang="ts">
|
|
30
|
-
import { type Ref, computed, inject, ref } from 'vue';
|
|
31
|
-
import { imageNodesKey } from '@datawhale/dipwap-render/utils/globalStatus';
|
|
32
|
-
import type { PMImg } from '@datawhale/dipwap-types/index';
|
|
33
|
-
|
|
34
|
-
const { node } = defineProps<{
|
|
35
|
-
node: PMImg;
|
|
36
|
-
}>();
|
|
37
|
-
|
|
38
|
-
const imageNodes = inject<Ref<PMImg[]>>(imageNodesKey, ref([]));
|
|
39
|
-
|
|
40
|
-
const restrictedWidth = computed(() => {
|
|
41
|
-
const attrsWidth = node.attrs.width as string;
|
|
42
|
-
if (attrsWidth && attrsWidth.endsWith('%') && !attrsWidth.startsWith('0')) {
|
|
43
|
-
const curWidth = parseFloat(attrsWidth.slice(0, -1));
|
|
44
|
-
return Math.max(Math.min(curWidth, 100), 10) + '%';
|
|
45
|
-
} else {
|
|
46
|
-
return '80%';
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// 图片放大相关功能实现
|
|
51
|
-
const imgWidth = ref<number>(0); // 原始图片宽度
|
|
52
|
-
const imgHeight = ref<number>(0); // 原始图片高度
|
|
53
|
-
const showModal = ref<boolean>(false);
|
|
54
|
-
const percentage = ref<number>(100); // 放大百分比
|
|
55
|
-
const currentImageNode = ref<PMImg | null>(null); // 当前浏览的图片节点
|
|
56
|
-
const currentImgWidth = ref<number>(0); // 当前浏览的图片的宽度
|
|
57
|
-
const currentImgHeight = ref<number>(0); // 当前浏览的图片的高度
|
|
58
|
-
const currentIndex = ref<number>(0); // 当前浏览的图片的索引
|
|
59
|
-
|
|
60
|
-
async function updateImageInfo(index: number) {
|
|
61
|
-
currentImageNode.value = imageNodes.value[index]!;
|
|
62
|
-
const img = new Image();
|
|
63
|
-
img.src = imageNodes.value[index]!.attrs.src;
|
|
64
|
-
await img.decode();
|
|
65
|
-
imgWidth.value = img.naturalWidth;
|
|
66
|
-
imgHeight.value = img.height;
|
|
67
|
-
if (!imgWidth.value || !imgHeight.value) return;
|
|
68
|
-
calculateSize();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const enlarge = async () => {
|
|
72
|
-
// 初始化放大时,设置 `currentImage`并计算percentage
|
|
73
|
-
currentIndex.value = imageNodes.value.findIndex((imgNode) => imgNode.attrs.src === node.attrs.src);
|
|
74
|
-
await updateImageInfo(currentIndex.value);
|
|
75
|
-
showModal.value = true;
|
|
76
|
-
document.body.style.overflow = 'hidden'; // 打开模态框时禁止页面内容滚动
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// 图片切换功能实现
|
|
80
|
-
const prevImage = async () => {
|
|
81
|
-
if (currentIndex.value > 0) {
|
|
82
|
-
currentIndex.value -= 1;
|
|
83
|
-
await updateImageInfo(currentIndex.value);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const nextImage = async () => {
|
|
88
|
-
if (currentIndex.value < imageNodes.value.length - 1) {
|
|
89
|
-
currentIndex.value += 1;
|
|
90
|
-
await updateImageInfo(currentIndex.value);
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const calculateSize = () => {
|
|
95
|
-
// 视口宽高
|
|
96
|
-
const windowWidth = window.innerWidth;
|
|
97
|
-
const windowHeight = window.innerHeight;
|
|
98
|
-
// 计算按原比例放大后的图片宽高(适应屏幕大小)
|
|
99
|
-
// 如果宽度为90vw时,高度等比放大后仍在屏幕高度90%的范围内,则使宽度为90vw,并计算等比放大后高度
|
|
100
|
-
// 如果宽度为90vw时,高度等比放大后超出屏幕高度的90%,则使高度为屏幕宽度的90%,并计算等比放大后的宽度
|
|
101
|
-
const tempHeight = ((windowWidth * 0.9) / imgWidth.value) * imgHeight.value;
|
|
102
|
-
if (tempHeight <= windowHeight * 0.9) {
|
|
103
|
-
currentImgWidth.value = windowWidth * 0.9;
|
|
104
|
-
currentImgHeight.value = tempHeight;
|
|
105
|
-
} else {
|
|
106
|
-
currentImgWidth.value = ((windowHeight * 0.9) / imgHeight.value) * imgWidth.value;
|
|
107
|
-
currentImgHeight.value = windowHeight * 0.9;
|
|
108
|
-
}
|
|
109
|
-
percentage.value = (currentImgWidth.value / imgWidth.value) * 100;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const zoomOut = () => {
|
|
113
|
-
if (percentage.value <= 10) return;
|
|
114
|
-
// 使百分比为10的倍数
|
|
115
|
-
if (percentage.value % 10 !== 0) {
|
|
116
|
-
percentage.value = Math.floor(percentage.value / 10) * 10;
|
|
117
|
-
} else {
|
|
118
|
-
percentage.value -= 10;
|
|
119
|
-
}
|
|
120
|
-
currentImgWidth.value = (percentage.value / 100) * imgWidth.value;
|
|
121
|
-
currentImgHeight.value = (percentage.value / 100) * imgHeight.value;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const zoomIn = () => {
|
|
125
|
-
if (percentage.value >= 500) return;
|
|
126
|
-
if (percentage.value % 10 !== 0) {
|
|
127
|
-
percentage.value = Math.ceil(percentage.value / 10) * 10;
|
|
128
|
-
} else {
|
|
129
|
-
percentage.value += 10;
|
|
130
|
-
}
|
|
131
|
-
currentImgWidth.value = (percentage.value / 100) * imgWidth.value;
|
|
132
|
-
currentImgHeight.value = (percentage.value / 100) * imgHeight.value;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const closeModal = () => {
|
|
136
|
-
showModal.value = false;
|
|
137
|
-
document.body.style.overflow = '';
|
|
138
|
-
};
|
|
139
|
-
</script>
|
|
140
|
-
|
|
141
|
-
<style scoped lang="scss">
|
|
142
|
-
.image-container {
|
|
143
|
-
display: flex;
|
|
144
|
-
flex-direction: column;
|
|
145
|
-
margin-bottom: 16px;
|
|
146
|
-
|
|
147
|
-
// ========== 图片及图片的高亮框 ==========
|
|
148
|
-
.image-wrapper {
|
|
149
|
-
position: relative;
|
|
150
|
-
box-sizing: border-box;
|
|
151
|
-
border: 1px solid transparent;
|
|
152
|
-
margin-bottom: 8px;
|
|
153
|
-
max-width: 100%;
|
|
154
|
-
|
|
155
|
-
&::before {
|
|
156
|
-
content: '';
|
|
157
|
-
position: absolute;
|
|
158
|
-
top: 0;
|
|
159
|
-
left: 0;
|
|
160
|
-
right: 0;
|
|
161
|
-
bottom: 0;
|
|
162
|
-
border: 1px solid;
|
|
163
|
-
border-color: inherit;
|
|
164
|
-
pointer-events: none;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
&:hover {
|
|
168
|
-
cursor: zoom-in;
|
|
169
|
-
|
|
170
|
-
&::before {
|
|
171
|
-
border: 2px solid #c2d4ff;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
img {
|
|
176
|
-
width: 100%;
|
|
177
|
-
height: 100%;
|
|
178
|
-
-webkit-touch-callout: none;
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.image-caption {
|
|
183
|
-
all: unset;
|
|
184
|
-
display: inline;
|
|
185
|
-
text-align: center;
|
|
186
|
-
font-size: 16px;
|
|
187
|
-
margin: 0 auto;
|
|
188
|
-
background-color: transparent;
|
|
189
|
-
width: 100%;
|
|
190
|
-
transition: border-color 0.3s ease;
|
|
191
|
-
color: rgb(100, 106, 115);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/** 以下为放大效果 **/
|
|
196
|
-
.modal-mask {
|
|
197
|
-
position: fixed;
|
|
198
|
-
z-index: 100000;
|
|
199
|
-
top: 0;
|
|
200
|
-
left: 0;
|
|
201
|
-
width: 100%;
|
|
202
|
-
height: 100%;
|
|
203
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
204
|
-
display: flex;
|
|
205
|
-
flex-direction: column;
|
|
206
|
-
justify-content: center;
|
|
207
|
-
align-items: center;
|
|
208
|
-
transition: opacity 0.3s ease;
|
|
209
|
-
|
|
210
|
-
.modal-close {
|
|
211
|
-
position: absolute;
|
|
212
|
-
top: 2rem;
|
|
213
|
-
right: 2rem;
|
|
214
|
-
width: 3rem;
|
|
215
|
-
height: 3rem;
|
|
216
|
-
line-height: 2.8rem;
|
|
217
|
-
text-align: center;
|
|
218
|
-
color: #fff;
|
|
219
|
-
font-size: 2rem;
|
|
220
|
-
font-weight: bold;
|
|
221
|
-
border-radius: 50%;
|
|
222
|
-
z-index: 9999;
|
|
223
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
224
|
-
cursor: pointer;
|
|
225
|
-
user-select: none;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.modal-body {
|
|
229
|
-
display: block;
|
|
230
|
-
transition: all 0.3s ease;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
.modal-footer {
|
|
234
|
-
position: absolute;
|
|
235
|
-
bottom: 20px;
|
|
236
|
-
left: calc(50vw - 80px);
|
|
237
|
-
display: flex;
|
|
238
|
-
justify-content: center;
|
|
239
|
-
align-items: center;
|
|
240
|
-
width: 160px;
|
|
241
|
-
height: 40px;
|
|
242
|
-
background-color: rgba(0, 0, 0, 0.5);
|
|
243
|
-
cursor: default;
|
|
244
|
-
user-select: none;
|
|
245
|
-
|
|
246
|
-
.zoom-in,
|
|
247
|
-
.zoom-out {
|
|
248
|
-
width: 39px;
|
|
249
|
-
height: 100%;
|
|
250
|
-
line-height: 37px;
|
|
251
|
-
text-align: center;
|
|
252
|
-
color: #fff;
|
|
253
|
-
font-size: 30px;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
.zoom-in {
|
|
257
|
-
border-left: 1px solid #fff;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
.zoom-out {
|
|
261
|
-
border-right: 1px solid #fff;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
.disabled {
|
|
265
|
-
color: rgb(100, 100, 100);
|
|
266
|
-
cursor: not-allowed;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
.percentage {
|
|
270
|
-
width: 80px;
|
|
271
|
-
height: 100%;
|
|
272
|
-
display: flex;
|
|
273
|
-
justify-content: center;
|
|
274
|
-
align-items: center;
|
|
275
|
-
color: #fff;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
.prev-image,
|
|
279
|
-
.next-image {
|
|
280
|
-
width: 39px;
|
|
281
|
-
height: 100%;
|
|
282
|
-
line-height: 37px;
|
|
283
|
-
text-align: center;
|
|
284
|
-
color: #fff;
|
|
285
|
-
font-size: 30px;
|
|
286
|
-
cursor: pointer;
|
|
287
|
-
user-select: none;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
.prev-image {
|
|
291
|
-
border-right: 1px solid #fff;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.next-image {
|
|
295
|
-
border-left: 1px solid #fff;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
.disabled {
|
|
299
|
-
color: rgb(100, 100, 100);
|
|
300
|
-
cursor: not-allowed;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.modal-enter-from {
|
|
306
|
-
opacity: 0;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
.modal-leave-to {
|
|
310
|
-
opacity: 0;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
.modal-enter-from .modal-body,
|
|
314
|
-
.modal-leave-to .modal-body {
|
|
315
|
-
-webkit-transform: scale(1.1);
|
|
316
|
-
transform: scale(1.1);
|
|
317
|
-
}
|
|
318
|
-
</style>
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// 这里各个mapper的import和使用都按照字典序排序
|
|
2
|
-
// 以后有新增时也按照字典序排序,好看一点,也便于查找
|
|
3
|
-
import { attachmentMapper } from './attachment/index.js';
|
|
4
|
-
import { basicMapper } from './basic/index.js';
|
|
5
|
-
import { calloutMapper } from './callout/index.js';
|
|
6
|
-
import { codeMapper } from './code/index.js';
|
|
7
|
-
import { foldBlockMapper } from './fold/index.js';
|
|
8
|
-
import { gridMapper } from './grid/index.js';
|
|
9
|
-
import { iframeMapper } from './iframe/index.js';
|
|
10
|
-
import { imgMapper } from './img/index.js';
|
|
11
|
-
import { mathMapper } from './math/index.js';
|
|
12
|
-
import { multipleChoiceMapper } from './multipleChoice/index.js';
|
|
13
|
-
import { tableMapper } from './table/index.js';
|
|
14
|
-
import { wrapperMapper } from './wrapper/index.js';
|
|
15
|
-
|
|
16
|
-
export const componentMapper: Record<string, any> = {
|
|
17
|
-
...attachmentMapper, // 附件和视频类型
|
|
18
|
-
...basicMapper, // 基础类型,包括各种字体样式
|
|
19
|
-
...calloutMapper, // 高亮块
|
|
20
|
-
...codeMapper, // 代码块
|
|
21
|
-
...foldBlockMapper, // 折叠块
|
|
22
|
-
...gridMapper, // 分栏
|
|
23
|
-
...imgMapper, // 图片
|
|
24
|
-
...mathMapper, // 数学公式
|
|
25
|
-
...multipleChoiceMapper, //选择题
|
|
26
|
-
...tableMapper, // 表格
|
|
27
|
-
...wrapperMapper, // 容器
|
|
28
|
-
...iframeMapper, // iframe
|
|
29
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="math-display">
|
|
3
|
-
<div class="math-render" v-html="content"></div>
|
|
4
|
-
</div>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { ref } from 'vue';
|
|
9
|
-
import type { PMMath } from '@datawhale/dipwap-types/index';
|
|
10
|
-
|
|
11
|
-
const { node } = defineProps<{
|
|
12
|
-
node: PMMath;
|
|
13
|
-
}>();
|
|
14
|
-
|
|
15
|
-
const content = ref('');
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
const { default: katex } = await import('katex');
|
|
19
|
-
content.value = katex.renderToString(node.content[0]!.text, {
|
|
20
|
-
displayMode: true,
|
|
21
|
-
strict: (errorCode: string) => (errorCode === 'unicodeTextInMathMode' ? 'ignore' : 'warn'),
|
|
22
|
-
});
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error(error);
|
|
25
|
-
}
|
|
26
|
-
</script>
|
|
27
|
-
|
|
28
|
-
<style scoped lang="scss">
|
|
29
|
-
.math-display {
|
|
30
|
-
min-width: 0.95em;
|
|
31
|
-
min-height: 0.95em;
|
|
32
|
-
font-size: 0.95em;
|
|
33
|
-
font-family:
|
|
34
|
-
Consolas,
|
|
35
|
-
Ubuntu Mono,
|
|
36
|
-
monospace;
|
|
37
|
-
|
|
38
|
-
.math-render :deep(.katex-display) {
|
|
39
|
-
margin: 0;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
</style>
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span class="math-inline">
|
|
3
|
-
<span class="math-render" v-html="content"></span>
|
|
4
|
-
</span>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { ref } from 'vue';
|
|
9
|
-
import type { PMInlineMath } from '@datawhale/dipwap-types/index';
|
|
10
|
-
|
|
11
|
-
const { node } = defineProps<{
|
|
12
|
-
node: PMInlineMath;
|
|
13
|
-
}>();
|
|
14
|
-
|
|
15
|
-
const content = ref('');
|
|
16
|
-
|
|
17
|
-
try {
|
|
18
|
-
const { default: katex } = await import('katex');
|
|
19
|
-
content.value = katex.renderToString(node.content[0]!.text, {
|
|
20
|
-
displayMode: false,
|
|
21
|
-
strict: (errorCode: string) => (errorCode === 'unicodeTextInMathMode' ? 'ignore' : 'warn'),
|
|
22
|
-
});
|
|
23
|
-
} catch (error) {
|
|
24
|
-
console.error(error);
|
|
25
|
-
}
|
|
26
|
-
</script>
|
|
27
|
-
|
|
28
|
-
<style scoped lang="scss">
|
|
29
|
-
.math-inline {
|
|
30
|
-
min-width: 1em;
|
|
31
|
-
min-height: 1em;
|
|
32
|
-
font-size: 0.95em;
|
|
33
|
-
font-family:
|
|
34
|
-
Consolas,
|
|
35
|
-
Ubuntu Mono,
|
|
36
|
-
monospace;
|
|
37
|
-
.math-render {
|
|
38
|
-
display: inline-block;
|
|
39
|
-
font-size: 0.85em;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
</style>
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="mc-choices-header">
|
|
3
|
-
<div class="choices-header-bar">
|
|
4
|
-
<Choice class="header-icon" />
|
|
5
|
-
<span class="header-text">选项</span>
|
|
6
|
-
</div>
|
|
7
|
-
<div class="choice-list">
|
|
8
|
-
<label class="choice-item" v-for="(child, index) in node.content" :key="index">
|
|
9
|
-
<input type="radio" :value="index" v-model="selectedModel" :disabled="submitted" />
|
|
10
|
-
<span class="prefix">{{ String.fromCharCode(65 + index) }}.</span>
|
|
11
|
-
<TreeRecursive :node="child" />
|
|
12
|
-
</label>
|
|
13
|
-
</div>
|
|
14
|
-
</div>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script setup lang="ts">
|
|
18
|
-
import TreeRecursive from '@datawhale/dipwap-render/components/TreeRecursive.vue';
|
|
19
|
-
import Choice from '@datawhale/dipwap-render/icons/Common/Choice.vue';
|
|
20
|
-
import type { PMMCChoices } from '@datawhale/dipwap-types/index';
|
|
21
|
-
|
|
22
|
-
defineProps<{
|
|
23
|
-
node: PMMCChoices;
|
|
24
|
-
submitted: boolean;
|
|
25
|
-
}>();
|
|
26
|
-
|
|
27
|
-
const selectedModel = defineModel<number | null>('selected');
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<style scoped lang="scss">
|
|
31
|
-
.mc-choices-header {
|
|
32
|
-
.choices-header-bar {
|
|
33
|
-
display: flex;
|
|
34
|
-
align-items: center;
|
|
35
|
-
padding: 10px 15px;
|
|
36
|
-
border-radius: 5px;
|
|
37
|
-
background-color: #e1e1e8;
|
|
38
|
-
.header-icon {
|
|
39
|
-
height: 24px;
|
|
40
|
-
width: 24px;
|
|
41
|
-
margin-right: 8px;
|
|
42
|
-
}
|
|
43
|
-
.header-text {
|
|
44
|
-
font-size: 18px;
|
|
45
|
-
font-weight: 700;
|
|
46
|
-
font-family: Arial, sans-serif;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
.choice-list {
|
|
50
|
-
display: flex;
|
|
51
|
-
flex-direction: column;
|
|
52
|
-
background-color: #fff;
|
|
53
|
-
padding: 8px 0px;
|
|
54
|
-
|
|
55
|
-
.choice-item {
|
|
56
|
-
display: flex;
|
|
57
|
-
flex-direction: row;
|
|
58
|
-
align-items: center;
|
|
59
|
-
justify-content: flex-start;
|
|
60
|
-
padding: 0px 12px;
|
|
61
|
-
input[type='radio'] {
|
|
62
|
-
cursor: pointer;
|
|
63
|
-
}
|
|
64
|
-
.prefix {
|
|
65
|
-
font-weight: bold;
|
|
66
|
-
width: 1.5em;
|
|
67
|
-
margin-left: 12px;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
</style>
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="mc-question-header">
|
|
3
|
-
<div class="question-header">
|
|
4
|
-
<Question class="icon" />
|
|
5
|
-
<span class="header-text">题目</span>
|
|
6
|
-
</div>
|
|
7
|
-
<div class="question-content">
|
|
8
|
-
<TreeRecursive v-for="child in node.content" :node="child" :key="useId()" />
|
|
9
|
-
</div>
|
|
10
|
-
</div>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script setup lang="ts">
|
|
14
|
-
import { useId } from 'vue';
|
|
15
|
-
import TreeRecursive from '@datawhale/dipwap-render/components/TreeRecursive.vue';
|
|
16
|
-
import Question from '@datawhale/dipwap-render/icons/Common/Question.vue';
|
|
17
|
-
import type { PMMCQuestion } from '@datawhale/dipwap-types/index';
|
|
18
|
-
|
|
19
|
-
defineProps<{
|
|
20
|
-
node: PMMCQuestion;
|
|
21
|
-
}>();
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<style scoped lang="scss">
|
|
25
|
-
.mc-question-header {
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-direction: column;
|
|
28
|
-
border-radius: 12px;
|
|
29
|
-
.question-header {
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
padding: 10px 15px;
|
|
33
|
-
background-color: #e1e1e8;
|
|
34
|
-
border-radius: 12px;
|
|
35
|
-
.icon {
|
|
36
|
-
height: 24px;
|
|
37
|
-
width: 24px;
|
|
38
|
-
margin-right: 8px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.header-text {
|
|
42
|
-
font-size: 18px;
|
|
43
|
-
font-weight: 700;
|
|
44
|
-
font-family: Arial, sans-serif;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.question-content {
|
|
49
|
-
padding: 12px 16px;
|
|
50
|
-
background-color: #fff;
|
|
51
|
-
|
|
52
|
-
:deep(p:first-child) {
|
|
53
|
-
margin-top: 0;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
:deep(p:last-child) {
|
|
57
|
-
margin-bottom: 0;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
</style>
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="mc-solution">
|
|
3
|
-
<div :class="['solution-content', correct ? 'correct' : 'wrong']">
|
|
4
|
-
<TreeRecursive v-for="child in node.content" :node="child" :key="useId()" />
|
|
5
|
-
</div>
|
|
6
|
-
</div>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup lang="ts">
|
|
10
|
-
import { useId } from 'vue';
|
|
11
|
-
import TreeRecursive from '@datawhale/dipwap-render/components/TreeRecursive.vue';
|
|
12
|
-
import type { PMMCSolution } from '@datawhale/dipwap-types/index';
|
|
13
|
-
|
|
14
|
-
defineProps<{
|
|
15
|
-
node: PMMCSolution;
|
|
16
|
-
correct: boolean;
|
|
17
|
-
}>();
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<style scoped lang="scss">
|
|
21
|
-
.mc-solution {
|
|
22
|
-
margin: 12px;
|
|
23
|
-
.solution-content {
|
|
24
|
-
border-radius: 4px;
|
|
25
|
-
padding: 12px 16px;
|
|
26
|
-
font-size: 14px;
|
|
27
|
-
color: #333;
|
|
28
|
-
|
|
29
|
-
:deep(p:first-child) {
|
|
30
|
-
margin-top: 0;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
:deep(p:last-child) {
|
|
34
|
-
margin-bottom: 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
&.correct {
|
|
38
|
-
background-color: #eef8ea;
|
|
39
|
-
border: 1.5px solid #83c17e;
|
|
40
|
-
}
|
|
41
|
-
&.wrong {
|
|
42
|
-
background-color: #fdecea;
|
|
43
|
-
border: 1.5px solid #f08b83;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
</style>
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="multiple-choice">
|
|
3
|
-
<McQuestion :node="node.content[0]" />
|
|
4
|
-
|
|
5
|
-
<McChoices v-model:selected="selected" :node="node.content[1]" :submitted="submitted" />
|
|
6
|
-
|
|
7
|
-
<div class="submit-area" v-if="!submitted">
|
|
8
|
-
<button class="submit-button" :disabled="selected === null" @click="submit">提交答案</button>
|
|
9
|
-
</div>
|
|
10
|
-
|
|
11
|
-
<McSolution v-if="submitted" :node="node.content[2]" :correct="isCorrect" />
|
|
12
|
-
</div>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
import { ref } from 'vue';
|
|
17
|
-
import type { PMMultipleChoice } from '@datawhale/dipwap-types/index';
|
|
18
|
-
import McChoices from './McChoices.vue';
|
|
19
|
-
import McQuestion from './McQuestion.vue';
|
|
20
|
-
import McSolution from './McSolution.vue';
|
|
21
|
-
|
|
22
|
-
const props = defineProps<{
|
|
23
|
-
node: PMMultipleChoice;
|
|
24
|
-
}>();
|
|
25
|
-
|
|
26
|
-
const selected = ref<number | null>(null);
|
|
27
|
-
const submitted = ref(false);
|
|
28
|
-
const isCorrect = ref(false);
|
|
29
|
-
|
|
30
|
-
const submit = () => {
|
|
31
|
-
submitted.value = true;
|
|
32
|
-
const correctIndex = props.node.content[1].attrs.correctIndex;
|
|
33
|
-
isCorrect.value = selected.value === correctIndex;
|
|
34
|
-
};
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<style scoped lang="scss">
|
|
38
|
-
.multiple-choice {
|
|
39
|
-
border: 2px solid rgb(128, 124, 124);
|
|
40
|
-
border-radius: 8px;
|
|
41
|
-
margin: 20px 0;
|
|
42
|
-
background-color: rgb(225, 225, 232);
|
|
43
|
-
.submit-area {
|
|
44
|
-
padding: 12px;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.submit-button {
|
|
48
|
-
padding: 6px 12px;
|
|
49
|
-
background-color: #4caf50;
|
|
50
|
-
color: white;
|
|
51
|
-
border: none;
|
|
52
|
-
border-radius: 4px;
|
|
53
|
-
font-weight: bold;
|
|
54
|
-
cursor: pointer;
|
|
55
|
-
|
|
56
|
-
&:disabled {
|
|
57
|
-
background-color: #929292;
|
|
58
|
-
cursor: not-allowed;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
</style>
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { customDefineAsyncComponent } from '../utils';
|
|
2
|
-
|
|
3
|
-
export const multipleChoiceMapper: Record<string, any> = {
|
|
4
|
-
multipleChoice: customDefineAsyncComponent(() => import('./MultipleChoice.vue')),
|
|
5
|
-
mcQuestion: customDefineAsyncComponent(() => import('./McQuestion.vue')),
|
|
6
|
-
mcChoices: customDefineAsyncComponent(() => import('./McChoices.vue')),
|
|
7
|
-
mcSolution: customDefineAsyncComponent(() => import('./McSolution.vue')),
|
|
8
|
-
};
|