Ver Fonte

ref: minor stuff

Sven há 1 ano atrás
pai
commit
3b116a62b8
4 ficheiros alterados com 20 adições e 17 exclusões
  1. 14 11
      src/features/index.ts
  2. 1 1
      src/menu/menu_old.css
  3. 1 1
      src/menu/menu_old.ts
  4. 4 4
      src/utils/misc.ts

+ 14 - 11
src/features/index.ts

@@ -52,17 +52,20 @@ const adornments = {
  * **Optional props:**
  * | Property | Description |
  * | :-- | :-- |
- * | `disable(newValue: any)`                    | for type `toggle` only - function that will be called when the feature is disabled - can be a synchronous or asynchronous function |
- * | `change(prevValue: any, newValue: any)`     | for types `number`, `select`, `slider` and `hotkey` only - function that will be called when the value is changed |
- * | `click: () => void`                         | for type `button` only - function that will be called when the button is clicked |
- * | `helpText(): string / () => string`         | function that returns an HTML string or the literal string itself that will be the help text for this feature - writing as function is useful for pluralizing or inserting values into the translation at runtime - if not set, translation with key `feature_helptext_featureKey` will be used instead, if available |
- * | `textAdornment(): string / Promise<string>` | function that returns an HTML string that will be appended to the text in the config menu as an adornment element - TODO: to be replaced in the big menu rework |
- * | `advanced`                                  | if true, the feature will only be shown if the advanced mode feature has been turned on |
- * | `hidden`                                    | if true, the feature will not be shown in the settings - default is undefined (false) |
- * | `min`                                       | Only if type is `number` or `slider` - Overwrites the default of the `min` property of the HTML input element |
- * | `max`                                       | Only if type is `number` or `slider` - Overwrites the default of the `max` property of the HTML input element |
- * | `step`                                      | Only if type is `number` or `slider` - Overwrites the default of the `step` property of the HTML input element |
- * | `unit: string / (val: number) => string`    | Only if type is `number` or `slider` - The unit text that is displayed next to the input element, i.e. "px" |
+ * | `disable: (newValue: any) => void`                | for type `toggle` only - function that will be called when the feature is disabled - can be a synchronous or asynchronous function |
+ * | `change: (prevValue: any, newValue: any)` => void | for types `number`, `select`, `slider` and `hotkey` only - function that will be called when the value is changed |
+ * | `click: () => void`                               | for type `button` only - function that will be called when the button is clicked |
+ * | `helpText: string / () => string`                 | function that returns an HTML string or the literal string itself that will be the help text for this feature - writing as function is useful for pluralizing or inserting values into the translation at runtime - if not set, translation with key `feature_helptext_featureKey` will be used instead, if available |
+ * | `textAdornment: () => string / Promise<string>`   | function that returns an HTML string that will be appended to the text in the config menu as an adornment element - TODO: to be replaced in the big menu rework |
+ * | `unit: string / (val: number) => string`          | Only if type is `number` or `slider` - The unit text that is displayed next to the input element, i.e. "px" |
+ * | `min: number`                                     | Only if type is `number` or `slider` - Overwrites the default of the `min` property of the HTML input element |
+ * | `max: number`                                     | Only if type is `number` or `slider` - Overwrites the default of the `max` property of the HTML input element |
+ * | `step: number`                                    | Only if type is `number` or `slider` - Overwrites the default of the `step` property of the HTML input element |
+ * | `options: SelectOption[] / () => SelectOption[]`  | Only if type is `select` - function that returns an array of objects with `value` and `label` properties |
+ * | `advanced: boolean`                               | if true, the feature will only be shown if the advanced mode feature has been turned on |
+ * | `hidden: boolean`                                 | if true, the feature will not be shown in the settings - default is undefined (false) |
+ * | `valueHidden: boolean`                            | If true, the value of the feature will be hidden in the settings and via the plugin interface - default is undefined (false) |
+ * | `normalize: (val: any) => any`                    | Function that will be called to normalize the value before it is saved - useful for trimming strings or other simple operations |
  *   
  * **Notes:**
  * - If no `disable()` or `change()` function is present, the page needs to be reloaded for the changes to take effect

+ 1 - 1
src/menu/menu_old.css

@@ -84,7 +84,7 @@
 }
 
 #bytm-cfg-menu-bg .bytm-menu-title {
-  transform: translate(0px, -5px);
+  transform: translate(0px, -6px);
 }
 
 #bytm-menu-subtitle-cont {

+ 1 - 1
src/menu/menu_old.ts

@@ -606,7 +606,7 @@ async function addCfgMenu() {
   versionEl.role = "button";
   versionEl.tabIndex = 0;
   versionEl.ariaLabel = versionEl.title = t("version_tooltip", scriptInfo.version, buildNumber);
-  versionEl.textContent = `v${scriptInfo.version} (${buildNumber})${mode === "development" ? " [dev build]" : ""}`;
+  versionEl.textContent = `v${scriptInfo.version} (${buildNumber})${mode === "development" ? " [DEV]" : ""}`;
   const versionElemClicked = async (e: MouseEvent | KeyboardEvent) => {
     e.preventDefault();
     e.stopPropagation();

+ 4 - 4
src/utils/misc.ts

@@ -118,9 +118,9 @@ export async function resourceToHTMLString(resource: ResourceKey) {
   }
 }
 
-/** Parses a markdown string and turns it into an HTML string - doesn't sanitize against XSS! */
-export function parseMarkdown(md: string) {
-  return marked.parse(md, {
+/** Parses a markdown string using marked and turns it into an HTML string with default settings - doesn't sanitize against XSS! */
+export function parseMarkdown(mdString: string) {
+  return marked.parse(mdString, {
     async: true,
     gfm: true,
   });
@@ -155,6 +155,6 @@ export async function getChangelogHtmlWithDetails() {
     return changelogHtml;
   }
   catch(err) {
-    return `Error: ${err}`;
+    return `Error while preparing changelog: ${err}`;
   }
 }