vitepress-theme-element-plus 0.0.5 → 0.0.7

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/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { mdExternalLinkIcon } from "./markdown/plugins/external-link-icon.mjs";
2
2
  import { mdTableWrapper } from "./markdown/plugins/table-wrapper.mjs";
3
3
  import { mdTag } from "./markdown/plugins/tag.mjs";
4
+ import { mdElementPlusTaskList } from "./markdown/plugins/task-list.mjs";
4
5
  import { mdTooltip } from "./markdown/plugins/tooltip.mjs";
5
- export { mdExternalLinkIcon, mdTableWrapper, mdTag, mdTooltip };
6
+ export { mdExternalLinkIcon, mdTableWrapper, mdTag, mdElementPlusTaskList as mdTaskList, mdTooltip };
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  import mdExternalLinkIcon from "./markdown/plugins/external-link-icon.mjs";
2
2
  import mdTableWrapper from "./markdown/plugins/table-wrapper.mjs";
3
3
  import mdTag from "./markdown/plugins/tag.mjs";
4
+ import { mdElementPlusTaskList } from "./markdown/plugins/task-list.mjs";
4
5
  import mdTooltip from "./markdown/plugins/tooltip.mjs";
5
6
 
6
- export { mdExternalLinkIcon, mdTableWrapper, mdTag, mdTooltip };
7
+ export { mdExternalLinkIcon, mdTableWrapper, mdTag, mdElementPlusTaskList as mdTaskList, mdTooltip };
@@ -0,0 +1,13 @@
1
+ import { PluginWithOptions } from "markdown-it";
2
+
3
+ //#region node/markdown/plugins/task-list.d.ts
4
+ interface ElementPlusTaskListOptions {
5
+ disabled?: boolean;
6
+ itemClass?: string;
7
+ listClass?: string;
8
+ checkboxClass?: string;
9
+ labelClass?: string;
10
+ }
11
+ declare const mdElementPlusTaskList: PluginWithOptions<ElementPlusTaskListOptions>;
12
+ //#endregion
13
+ export { mdElementPlusTaskList };
@@ -0,0 +1,51 @@
1
+ //#region node/markdown/plugins/task-list.ts
2
+ function startsWithTask(token) {
3
+ return token.type === "inline" && /^\[[x \u00A0]\][ \u00A0]/i.test(token.content);
4
+ }
5
+ function isTaskListItem(tokens, index) {
6
+ return startsWithTask(tokens[index]) && tokens[index - 1]?.type === "paragraph_open" && tokens[index - 2]?.type === "list_item_open";
7
+ }
8
+ function html(state, content) {
9
+ const token = new state.Token("html_inline", "", 0);
10
+ token.content = content;
11
+ return token;
12
+ }
13
+ function addClass(token, className) {
14
+ if (!token) return;
15
+ const current = token.attrGet("class");
16
+ if (!current) {
17
+ token.attrSet("class", className);
18
+ return;
19
+ }
20
+ if (current.split(/\s+/).includes(className)) return;
21
+ token.attrSet("class", `${current} ${className}`);
22
+ }
23
+ const mdElementPlusTaskList = (md, { disabled = true, itemClass = "ep-task-list__item", listClass = "ep-task-list", checkboxClass = "ep-task-list__checkbox", labelClass = "ep-task-list__label" } = {}) => {
24
+ md.core.ruler.after("inline", "ep-task-list", (state) => {
25
+ const { tokens, env } = state;
26
+ env.epTaskId ||= 0;
27
+ for (let i = 2; i < tokens.length; i++) {
28
+ if (!isTaskListItem(tokens, i)) continue;
29
+ const inlineToken = tokens[i];
30
+ const listItemToken = tokens[i - 2];
31
+ const parentListToken = tokens.findLast((token, idx) => idx < i - 2 && token.level === listItemToken.level - 1 && token.type.endsWith("list_open"));
32
+ addClass(listItemToken, itemClass);
33
+ addClass(parentListToken, listClass);
34
+ const textToken = inlineToken.children?.find((child) => child.type === "text");
35
+ if (!textToken) continue;
36
+ const checked = /^\[x\]/i.test(textToken.content);
37
+ textToken.content = textToken.content.replace(/^\[[x \u00A0]\][ \u00A0]?/i, "");
38
+ const id = `ep-task-${env.epTaskId++}`;
39
+ const input = `<span class="el-checkbox__input${checked ? " is-checked" : ""}${disabled ? " is-disabled" : ""}">
40
+ <span class="el-checkbox__inner"></span>
41
+ <input id="${id}" class="el-checkbox__original" type="checkbox" ${checked ? "checked" : ""} ${disabled ? "disabled" : ""} aria-checked="${checked ? "true" : "false"}" role="presentation">
42
+ </span>`;
43
+ inlineToken.children.unshift(html(state, `<label class="el-checkbox ${checkboxClass}" for="${id}" role="checkbox" aria-checked="${checked ? "true" : "false"}">`), html(state, `${input}<span class="el-checkbox__label ${labelClass}">`));
44
+ inlineToken.children.push(html(state, "</span></label>"));
45
+ }
46
+ return true;
47
+ });
48
+ };
49
+
50
+ //#endregion
51
+ export { mdElementPlusTaskList };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitepress-theme-element-plus",
3
3
  "type": "module",
4
- "version": "0.0.5",
4
+ "version": "0.0.7",
5
5
  "description": "A VitePress theme for Element Plus",
6
6
  "author": "Hezhengxu",
7
7
  "license": "MIT",
package/styles/base.scss CHANGED
@@ -35,3 +35,15 @@ body {
35
35
  main {
36
36
  display: block;
37
37
  }
38
+
39
+ a,
40
+ area,
41
+ button,
42
+ [role=button],
43
+ input,
44
+ label,
45
+ select,
46
+ summary,
47
+ textarea {
48
+ touch-action: manipulation
49
+ }
@@ -159,4 +159,73 @@
159
159
  margin: 20px 0;
160
160
  }
161
161
  }
162
+
163
+ blockquote {
164
+ margin: 1rem 0;
165
+ border-left: .2rem solid var(--el-border-color);
166
+ padding: .25rem 0 .25rem 1rem;
167
+ font-size: 1rem;
168
+ color: var(--text-color-lighter)
169
+ }
170
+
171
+ blockquote>p {
172
+ margin: 0
173
+ }
174
+
175
+ form {
176
+ margin: 0
177
+ }
178
+
179
+ details summary {
180
+ margin: 16px 0;
181
+ font-size: 18px;
182
+ font-weight: 600;
183
+ cursor: pointer
184
+ }
185
+
186
+ figure {
187
+ margin: 0
188
+ }
189
+
190
+ img {
191
+ max-width: 100%
192
+ }
193
+
194
+ ul,
195
+ ol {
196
+ padding-left: 1.25em;
197
+ }
198
+
199
+ li>ul,
200
+ li>ol {
201
+ margin: 0
202
+ }
203
+
204
+ p,
205
+ ol,
206
+ ul {
207
+ margin: 1rem 0;
208
+ line-height: 1.7;
209
+ list-style-type: disc
210
+ }
211
+
212
+ ol>li {
213
+ list-style: auto
214
+ }
215
+
216
+ .ep-task-list {
217
+ padding-left: 0;
218
+
219
+ &>li {
220
+ list-style: none;
221
+ }
222
+ }
223
+
224
+ hr {
225
+ margin-top: 20px;
226
+ margin-bottom: 20px;
227
+ border: 0;
228
+ border-top: 1px solid var(--el-border-color-lighter);
229
+ }
162
230
  }
231
+
@@ -1,6 +1,6 @@
1
1
  .vp-tag {
2
- --vp-tag-color: var(--el-color-primary);
3
- --vp-tag-border-color: var(--el-color-primary);
2
+ --vp-tag-color: var(--vp-c-brand);
3
+ --vp-tag-border-color: var(--vp-c-brand);
4
4
 
5
5
  display: inline-block;
6
6
  padding: 0 7px;