mirror of
https://github.com/zadam/trilium.git
synced 2025-12-29 02:34:25 +01:00
chore(scripts/preact): address review
This commit is contained in:
parent
2561c7ca0d
commit
1554085d7a
@ -1,6 +1,5 @@
|
||||
import { h, VNode } from "preact";
|
||||
|
||||
import Component from "../components/component.js";
|
||||
import BasicWidget, { ReactWrappedWidget } from "../widgets/basic_widget.js";
|
||||
import RightPanelWidget from "../widgets/right_panel_widget.js";
|
||||
import froca from "./froca.js";
|
||||
|
||||
@ -538,7 +538,6 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, orig
|
||||
return `!@#Function: ${p.toString()}`;
|
||||
}
|
||||
return p;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -567,7 +566,6 @@ function FrontendScriptApi(this: Api, startNote: FNote, currentNote: FNote, orig
|
||||
return ret.executionResult;
|
||||
}
|
||||
throw new Error(`server error: ${ret.error}`);
|
||||
|
||||
};
|
||||
|
||||
this.runOnBackend = async (func, params = []) => {
|
||||
|
||||
@ -9,9 +9,9 @@ import Collapsible from "../widgets/react/Collapsible";
|
||||
import Dropdown from "../widgets/react/Dropdown";
|
||||
import FormCheckbox from "../widgets/react/FormCheckbox";
|
||||
import FormDropdownList from "../widgets/react/FormDropdownList";
|
||||
import { FormFileUploadActionButton,FormFileUploadButton } from "../widgets/react/FormFileUpload";
|
||||
import { FormFileUploadActionButton, FormFileUploadButton } from "../widgets/react/FormFileUpload";
|
||||
import FormGroup from "../widgets/react/FormGroup";
|
||||
import { FormDropdownDivider, FormDropdownSubmenu,FormListItem } from "../widgets/react/FormList";
|
||||
import { FormDropdownDivider, FormDropdownSubmenu, FormListItem } from "../widgets/react/FormList";
|
||||
import FormRadioGroup from "../widgets/react/FormRadioGroup";
|
||||
import FormText from "../widgets/react/FormText";
|
||||
import FormTextArea from "../widgets/react/FormTextArea";
|
||||
|
||||
@ -57,9 +57,8 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedCompon
|
||||
optChild(condition: boolean, ...components: (T | VNode)[]) {
|
||||
if (condition) {
|
||||
return this.child(...components);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
id(id: string) {
|
||||
@ -246,9 +245,8 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedCompon
|
||||
getClosestNtxId() {
|
||||
if (this.$widget) {
|
||||
return this.$widget.closest("[data-ntx-id]").attr("data-ntx-id");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
cleanup() {}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { Tooltip } from "bootstrap";
|
||||
import { ComponentChildren } from "preact";
|
||||
import { CSSProperties, memo } from "preact/compat";
|
||||
import { useCallback,useEffect, useMemo, useRef } from "preact/hooks";
|
||||
import { ComponentChildren, CSSProperties } from "preact";
|
||||
import { useCallback, useEffect, useMemo, useRef } from "preact/hooks";
|
||||
|
||||
import { escapeQuotes } from "../../services/utils";
|
||||
import { useUniqueName } from "./hooks";
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import "./RightPanelContainer.css";
|
||||
|
||||
import Split from "@triliumnext/split.js";
|
||||
import { isValidElement, VNode } from "preact";
|
||||
import { VNode } from "preact";
|
||||
import { useEffect, useRef } from "preact/hooks";
|
||||
|
||||
import appContext from "../../components/app_context";
|
||||
@ -10,7 +10,6 @@ import { WidgetsByParent } from "../../services/bundle";
|
||||
import { t } from "../../services/i18n";
|
||||
import options from "../../services/options";
|
||||
import { DEFAULT_GUTTER_SIZE } from "../../services/resizer";
|
||||
import BasicWidget from "../basic_widget";
|
||||
import Button from "../react/Button";
|
||||
import { useActiveNoteContext, useLegacyWidget, useNoteProperty, useTriliumOptionBool, useTriliumOptionJson } from "../react/hooks";
|
||||
import Icon from "../react/Icon";
|
||||
@ -67,7 +66,7 @@ function useItems(rightPaneVisible: boolean, widgetsByParent: WidgetsByParent) {
|
||||
el: <HighlightsList />,
|
||||
enabled: noteType === "text" && highlightsList.length > 0,
|
||||
},
|
||||
...widgetsByParent.getLegacyWidgets("right-pane").map((widget, i) => ({
|
||||
...widgetsByParent.getLegacyWidgets("right-pane").map((widget) => ({
|
||||
el: <CustomLegacyWidget key={widget._noteId} originalWidget={widget as LegacyRightPanelWidget} />,
|
||||
enabled: true,
|
||||
position: widget.position
|
||||
|
||||
@ -360,7 +360,6 @@ class BNote extends AbstractBeccaEntity<BNote> {
|
||||
return this.__attributeCache.filter((attr) => attr.name === name);
|
||||
}
|
||||
return this.__attributeCache;
|
||||
|
||||
}
|
||||
|
||||
private __ensureAttributeCacheIsAvailable() {
|
||||
@ -697,7 +696,6 @@ class BNote extends AbstractBeccaEntity<BNote> {
|
||||
return this.ownedAttributes.filter((attr) => attr.name === name);
|
||||
}
|
||||
return this.ownedAttributes;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -750,7 +748,6 @@ class BNote extends AbstractBeccaEntity<BNote> {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
});
|
||||
|
||||
this.parents = this.parentBranches.map((branch) => branch.parentNote).filter((note) => !!note) as BNote[];
|
||||
@ -1183,7 +1180,6 @@ class BNote extends AbstractBeccaEntity<BNote> {
|
||||
return a.isHidden ? 1 : -1;
|
||||
}
|
||||
return a.notePath.length - b.notePath.length;
|
||||
|
||||
});
|
||||
|
||||
return notePaths;
|
||||
@ -1722,7 +1718,6 @@ class BNote extends AbstractBeccaEntity<BNote> {
|
||||
return "bx bx-data";
|
||||
}
|
||||
return NOTE_TYPE_ICONS[this.type];
|
||||
|
||||
}
|
||||
|
||||
// TODO: Deduplicate with fnote
|
||||
|
||||
@ -114,7 +114,6 @@ function getParams(params?: ScriptParams) {
|
||||
return p.substr(13);
|
||||
}
|
||||
return JSON.stringify(p);
|
||||
|
||||
})
|
||||
.join(",");
|
||||
}
|
||||
@ -227,10 +226,10 @@ export function buildJsx(contentRaw: string | Buffer) {
|
||||
production: true
|
||||
});
|
||||
|
||||
let code = output.code;
|
||||
let code = output.code;
|
||||
|
||||
// Rewrite ESM-like exports to `module.exports =`.
|
||||
code = output.code.replaceAll(
|
||||
code = code.replaceAll(
|
||||
/\bexports\s*\.\s*default\s*=\s*/g,
|
||||
'module.exports = '
|
||||
);
|
||||
@ -241,7 +240,7 @@ export function buildJsx(contentRaw: string | Buffer) {
|
||||
'const $1 = api.preact;'
|
||||
);
|
||||
|
||||
// Rewrite ESM-like imports to internal API, to `const { foo } = api.preact`
|
||||
// Rewrite ESM-like imports to internal API, to `const { foo } = api`
|
||||
code = code.replaceAll(
|
||||
/(?:var|let|const)\s+(\w+)\s*=\s*require\(['"]trilium:api['"]\);?/g,
|
||||
'const $1 = api;'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user