image-exporter 1.0.4 → 1.0.5
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.
|
@@ -3494,8 +3494,15 @@ async function getImageOptions(element, config) {
|
|
|
3494
3494
|
try {
|
|
3495
3495
|
const label = element.dataset.label || config.defaultImageLabel;
|
|
3496
3496
|
if (label === "") return config.defaultImageLabel;
|
|
3497
|
+
const endsWithSpecial = label.endsWith("@#x");
|
|
3498
|
+
let cleanedLabel = label;
|
|
3497
3499
|
const regex = /[^a-zA-Z0-9-_]/g;
|
|
3498
|
-
|
|
3500
|
+
if (endsWithSpecial) {
|
|
3501
|
+
cleanedLabel = label.slice(0, -3).replace(regex, "") + "@#x";
|
|
3502
|
+
} else {
|
|
3503
|
+
cleanedLabel = label.replace(regex, "");
|
|
3504
|
+
}
|
|
3505
|
+
return cleanedLabel;
|
|
3499
3506
|
} catch (error) {
|
|
3500
3507
|
console.error(error);
|
|
3501
3508
|
return config.defaultImageLabel;
|
|
@@ -3499,8 +3499,15 @@
|
|
|
3499
3499
|
try {
|
|
3500
3500
|
const label = element.dataset.label || config.defaultImageLabel;
|
|
3501
3501
|
if (label === "") return config.defaultImageLabel;
|
|
3502
|
+
const endsWithSpecial = label.endsWith("@#x");
|
|
3503
|
+
let cleanedLabel = label;
|
|
3502
3504
|
const regex = /[^a-zA-Z0-9-_]/g;
|
|
3503
|
-
|
|
3505
|
+
if (endsWithSpecial) {
|
|
3506
|
+
cleanedLabel = label.slice(0, -3).replace(regex, "") + "@#x";
|
|
3507
|
+
} else {
|
|
3508
|
+
cleanedLabel = label.replace(regex, "");
|
|
3509
|
+
}
|
|
3510
|
+
return cleanedLabel;
|
|
3504
3511
|
} catch (error) {
|
|
3505
3512
|
console.error(error);
|
|
3506
3513
|
return config.defaultImageLabel;
|
package/package.json
CHANGED
|
@@ -55,11 +55,20 @@ export async function getImageOptions(
|
|
|
55
55
|
|
|
56
56
|
if (label === "") return config.defaultImageLabel;
|
|
57
57
|
|
|
58
|
+
// Check if the label ends with '@#x'
|
|
59
|
+
const endsWithSpecial = label.endsWith("@#x");
|
|
60
|
+
let cleanedLabel = label;
|
|
61
|
+
|
|
58
62
|
// Allowed characters: a-z, A-Z, 0-9, -, _
|
|
59
|
-
// Remove all other characters using regex
|
|
63
|
+
// Remove all other characters using regex, except '@#x' at the end
|
|
60
64
|
const regex = /[^a-zA-Z0-9-_]/g;
|
|
65
|
+
if (endsWithSpecial) {
|
|
66
|
+
cleanedLabel = label.slice(0, -3).replace(regex, "") + "@#x";
|
|
67
|
+
} else {
|
|
68
|
+
cleanedLabel = label.replace(regex, "");
|
|
69
|
+
}
|
|
61
70
|
|
|
62
|
-
return
|
|
71
|
+
return cleanedLabel;
|
|
63
72
|
} catch (error) {
|
|
64
73
|
console.error(error);
|
|
65
74
|
return config.defaultImageLabel;
|
package/src/types.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export interface Config extends ImageOptions {
|
|
|
30
30
|
/** Enable window logging for use by external scripts. */
|
|
31
31
|
enableWindowLogging: boolean;
|
|
32
32
|
/** Enable verbose logging for debugging. */
|
|
33
|
-
loggingLevel:
|
|
33
|
+
loggingLevel: LoggingLevel;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export interface ParsedImageOptions extends ImageOptions {
|
|
@@ -48,3 +48,4 @@ export type Format = "jpg" | "png" | "svg";
|
|
|
48
48
|
export type Scale = number | number[];
|
|
49
49
|
export type Quality = number;
|
|
50
50
|
export type IncludeScaleInLabel = boolean;
|
|
51
|
+
export type LoggingLevel = "none" | "info" | "error" | "verbose";
|