vuepress-plugin-md-power 1.0.0-rc.81 → 1.0.0-rc.82
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.
|
@@ -106,12 +106,13 @@ onUnmounted(() => {
|
|
|
106
106
|
z-index: 1;
|
|
107
107
|
box-sizing: border-box;
|
|
108
108
|
display: block;
|
|
109
|
-
padding:
|
|
109
|
+
padding: 20px 24px;
|
|
110
110
|
overflow-x: auto;
|
|
111
111
|
font-family: var(--vp-font-family-mono);
|
|
112
112
|
font-size: var(--vp-code-font-size);
|
|
113
113
|
-webkit-hyphens: none;
|
|
114
114
|
hyphens: none;
|
|
115
|
+
line-height: var(--vp-code-line-height);
|
|
115
116
|
color: transparent;
|
|
116
117
|
text-align: left;
|
|
117
118
|
word-break: normal;
|
|
@@ -139,7 +140,7 @@ onUnmounted(() => {
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
:deep(div[class*="language-"].line-numbers-mode) + .code-repl-input {
|
|
142
|
-
padding-left:
|
|
143
|
-
margin-left:
|
|
143
|
+
padding-left: 24px;
|
|
144
|
+
margin-left: 32px;
|
|
144
145
|
}
|
|
145
146
|
</style>
|
package/lib/node/index.js
CHANGED
|
@@ -198,6 +198,7 @@ var nanoid2 = customAlphabet2("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW
|
|
|
198
198
|
var iconDataCache = /* @__PURE__ */ new Map();
|
|
199
199
|
var URL_CONTENT_RE = /(url\([\s\S]+?\))/;
|
|
200
200
|
var CSS_PATH = "internal/md-power/icons.css";
|
|
201
|
+
var locate;
|
|
201
202
|
function resolveOption(opt) {
|
|
202
203
|
const options = typeof opt === "object" ? opt : {};
|
|
203
204
|
options.prefix ??= "vp-mdi";
|
|
@@ -239,18 +240,17 @@ function createIconCSSWriter(app, opt) {
|
|
|
239
240
|
function addIcon(iconName) {
|
|
240
241
|
if (!isInstalled)
|
|
241
242
|
return;
|
|
242
|
-
if (cache.has(iconName))
|
|
243
|
-
|
|
243
|
+
if (cache.has(iconName)) {
|
|
244
|
+
const item2 = cache.get(iconName);
|
|
245
|
+
return `${item2.className}${item2.background ? " bg" : ""}`;
|
|
246
|
+
}
|
|
244
247
|
const item = {
|
|
245
248
|
className: `${prefix}-${nanoid2()}`,
|
|
246
|
-
|
|
249
|
+
...genIcon(iconName)
|
|
247
250
|
};
|
|
248
251
|
cache.set(iconName, item);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
writeCss();
|
|
252
|
-
});
|
|
253
|
-
return item.className;
|
|
252
|
+
writeCss();
|
|
253
|
+
return `${item.className}${item.background ? " bg" : ""}`;
|
|
254
254
|
}
|
|
255
255
|
async function initIcon() {
|
|
256
256
|
if (!opt)
|
|
@@ -259,18 +259,23 @@ function createIconCSSWriter(app, opt) {
|
|
|
259
259
|
logger.error("[plugin-md-power]: `@iconify/json` not found! Please install `@iconify/json` first.");
|
|
260
260
|
return;
|
|
261
261
|
}
|
|
262
|
+
if (!locate) {
|
|
263
|
+
const mod = await interopDefault(import("@iconify/json"));
|
|
264
|
+
locate = mod.locate;
|
|
265
|
+
}
|
|
262
266
|
return await writeCss();
|
|
263
267
|
}
|
|
264
268
|
return { addIcon, writeCss, initIcon };
|
|
265
269
|
}
|
|
266
270
|
function getDefaultContent(options) {
|
|
267
271
|
const { prefix, size, color } = options;
|
|
268
|
-
return `[class^="${prefix}-"]
|
|
269
|
-
[class*=" ${prefix}-"] {
|
|
272
|
+
return `[class^="${prefix}-"] {
|
|
270
273
|
display: inline-block;
|
|
271
274
|
width: ${size};
|
|
272
275
|
height: ${size};
|
|
273
276
|
vertical-align: middle;
|
|
277
|
+
}
|
|
278
|
+
[class^="${prefix}-"]:not(.bg) {
|
|
274
279
|
color: inherit;
|
|
275
280
|
background-color: ${color};
|
|
276
281
|
-webkit-mask: var(--svg) no-repeat;
|
|
@@ -278,33 +283,42 @@ function getDefaultContent(options) {
|
|
|
278
283
|
-webkit-mask-size: 100% 100%;
|
|
279
284
|
mask-size: 100% 100%;
|
|
280
285
|
}
|
|
286
|
+
[class^="${prefix}-"].bg {
|
|
287
|
+
background-color: transparent;
|
|
288
|
+
background-image: var(--svg);
|
|
289
|
+
background-repeat: no-repeat;
|
|
290
|
+
background-size: 100% 100%;
|
|
291
|
+
}
|
|
281
292
|
`;
|
|
282
293
|
}
|
|
283
|
-
|
|
284
|
-
async function genIconContent(iconName, cb) {
|
|
294
|
+
function genIcon(iconName) {
|
|
285
295
|
if (!locate) {
|
|
286
|
-
|
|
287
|
-
locate = mod.locate;
|
|
296
|
+
return { content: "", background: false };
|
|
288
297
|
}
|
|
289
298
|
const [collect, name] = iconName.split(":");
|
|
290
299
|
let iconJson = iconDataCache.get(collect);
|
|
291
300
|
if (!iconJson) {
|
|
292
301
|
const filename = locate(collect);
|
|
293
302
|
try {
|
|
294
|
-
iconJson = JSON.parse(
|
|
303
|
+
iconJson = JSON.parse(fs.readFileSync(filename, "utf-8"));
|
|
295
304
|
iconDataCache.set(collect, iconJson);
|
|
296
305
|
} catch {
|
|
297
306
|
logger.warn(`[plugin-md-power] Can not find icon, ${collect} is missing!`);
|
|
298
307
|
}
|
|
299
308
|
}
|
|
300
309
|
const data = getIconData(iconJson, name);
|
|
301
|
-
if (!data)
|
|
302
|
-
|
|
310
|
+
if (!data) {
|
|
311
|
+
logger.error(`[plugin-md-power] Can not read icon in ${collect}, ${name} is missing!`);
|
|
312
|
+
return { content: "", background: false };
|
|
313
|
+
}
|
|
303
314
|
const content = getIconContentCSS(data, {
|
|
304
315
|
height: data.height || 24
|
|
305
316
|
});
|
|
306
317
|
const match = content.match(URL_CONTENT_RE);
|
|
307
|
-
return
|
|
318
|
+
return {
|
|
319
|
+
content: match ? match[1] : "",
|
|
320
|
+
background: !data.body.includes("currentColor")
|
|
321
|
+
};
|
|
308
322
|
}
|
|
309
323
|
function existsSync(fp) {
|
|
310
324
|
try {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuepress-plugin-md-power",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.82",
|
|
5
5
|
"description": "The Plugin for VuePress 2 - markdown power",
|
|
6
6
|
"author": "pengzhanbo <volodymyr@foxmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"markdown-it-container": "^4.0.0",
|
|
48
48
|
"nanoid": "^5.0.7",
|
|
49
49
|
"shiki": "^1.10.3",
|
|
50
|
-
"tm-grammars": "^1.13.
|
|
51
|
-
"tm-themes": "^1.5.
|
|
52
|
-
"vue": "^3.4.
|
|
50
|
+
"tm-grammars": "^1.13.13",
|
|
51
|
+
"tm-themes": "^1.5.5",
|
|
52
|
+
"vue": "^3.4.33"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@iconify/json": "^2.2.
|
|
55
|
+
"@iconify/json": "^2.2.229",
|
|
56
56
|
"@types/markdown-it": "^14.1.1"
|
|
57
57
|
},
|
|
58
58
|
"publishConfig": {
|