Skip to content

Commit 282ed48

Browse files
committed
fix: replace style with class.
1 parent b0a9151 commit 282ed48

File tree

3 files changed

+72
-14
lines changed

3 files changed

+72
-14
lines changed

src/template/basic.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,4 +363,31 @@ table tr td {
363363
}
364364
365365
#nice .inline-equation svg {
366-
}`;
366+
}
367+
368+
#nice .imageflow-layer1 {
369+
margin: 1em auto;
370+
white-space: normal;
371+
border: 0px none;
372+
padding: 0px;
373+
overflow: hidden;
374+
}
375+
376+
#nice .imageflow-layer2 {
377+
white-space: nowrap;
378+
width: 100%;
379+
overflow-x: scroll;
380+
}
381+
382+
#nice .imageflow-layer3 {
383+
display: inline-block;
384+
word-wrap: break-word;
385+
white-space: normal;
386+
vertical-align: middle;
387+
width: 100%;
388+
}
389+
390+
#nice .imageflow-img {
391+
display: inline-block;
392+
}
393+
`;

src/template/markdown/custom.js

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,42 @@ table tr th,
180180
/* 行内公式
181181
*/
182182
#nice .inline-equation svg {
183-
}`;
183+
}
184+
185+
/* 横屏移动外层
186+
* margin: 1em auto;
187+
* white-space: normal;
188+
* border: 0px none;
189+
* padding: 0px;
190+
* overflow: hidden;
191+
*/
192+
#nice .imageflow-layer1 {
193+
}
194+
195+
/* 横屏移动中间层
196+
* white-space: nowrap;
197+
* 100%;
198+
* overflow-x: scroll;
199+
*/
200+
#nice .imageflow-layer2 {
201+
white-space: nowrap;
202+
width: 100%;
203+
overflow-x: scroll;
204+
}
205+
206+
/* 横屏移动内层
207+
* display: inline-block
208+
* word-wrap: break-word;
209+
* white-space: normal;
210+
* vertical-align: middle;
211+
* width: 100%;
212+
*/
213+
#nice .imageflow-layer3 {
214+
}
215+
216+
/* 横屏移动图片
217+
* display: inline-block;
218+
*/
219+
#nice .imageflow-img {
220+
}
221+
`;

src/utils/markdown-it-imageflow.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
const defaultOption = {
22
limitless: false, // 限制图片数量
3-
limit: 10, // 图片数量上限,
4-
height: 300, // 组件高度
3+
limit: 10, // 图片数量上限
54
};
65

76
const imageFlowPlugin = (md, opt) => {
87
const options = opt || defaultOption;
9-
const style = {
10-
IF_layer1: `margin:1em;white-space:normal;border:none;padding:0px;overflow:hidden;height:${options.height}px;line-height:${options.height}px`,
11-
IF_layer2: `white-space:nowrap;width:100%;overflow-x:scroll;`,
12-
IF_layer3: `display:inline-block;word-wrap:break-word;white-space:normal;vertical-align:middle;width:100%;`,
13-
IF_image: `display:inline-block;`,
14-
};
158

169
const tokenize = (state, silent) => {
1710
let result = false;
@@ -54,7 +47,7 @@ const imageFlowPlugin = (md, opt) => {
5447
};
5548

5649
md.renderer.rules.imageFlow_start = () => {
57-
return `<section style=${style.IF_layer1}><section style=${style.IF_layer2}>`;
50+
return `<section class="imageflow-layer1"><section class="imageflow-layer2">`;
5851
};
5952
md.renderer.rules.imageFlow_end = () => {
6053
return `</section></section>`;
@@ -65,9 +58,9 @@ const imageFlowPlugin = (md, opt) => {
6558
let image;
6659
contents.forEach((content) => {
6760
image = content.split(/\[|\]|\(|\)|!/).filter((val) => val);
68-
wrapperContent += `<section style=${style.IF_layer3}><img alt=${image[0]} src=${image[1]} style=${
69-
style.IF_image
70-
} /></section>`;
61+
wrapperContent += `<section class="imageflow-layer3"><img alt=${image[0]} src=${
62+
image[1]
63+
} class="imageflow-img" /></section>`;
7164
});
7265

7366
return wrapperContent;

0 commit comments

Comments
 (0)