mirror of
https://github.com/outline/outline.git
synced 2026-11-28 16:19:46 +03:00
fix: resolve remaining TypeScript compilation errors
- Fixed resolve function type assertion in actions/index.ts - Updated ContentEditable event handling with proper type guards - Fixed Collection component direction type conversion to uppercase - Added proper PaginationParams typing in Drafts and Home components - Changed action icon type from ReactElement to ReactNode for compatibility
This commit is contained in:
1 parent
042fd0fcb9
commit
f153968b75
5 files changed
+35
-25
No files matched your search
+5
-13
@@ -15,7 +15,7 @@ function resolve<T>(
|
||||
value: T | ((context: ActionContext) => T),
|
||||
context: ActionContext
|
||||
): T {
|
||||
return typeof value === "function" ? value(context) : value;
|
||||
return typeof value === "function" ? (value as (context: ActionContext) => T)(context) : value;
|
||||
}
|
||||
|
||||
export function createAction(definition: Optional<Action, "id">): Action {
|
||||
@@ -93,19 +93,11 @@ export function actionToKBar(
|
||||
return [];
|
||||
}
|
||||
|
||||
const resolvedIcon = action.icon
|
||||
? resolve<React.ReactElement>(action.icon, context)
|
||||
: undefined;
|
||||
const resolvedChildren = action.children
|
||||
? resolve<Action[]>(action.children, context)
|
||||
: undefined;
|
||||
const resolvedSection = action.section
|
||||
? resolve<string>(action.section, context)
|
||||
: undefined;
|
||||
const resolvedIcon = action.icon ? resolve<React.ReactNode>(action.icon, context) : undefined;
|
||||
const resolvedChildren = action.children ? resolve<Action[]>(action.children, context) : undefined;
|
||||
const resolvedSection = action.section ? resolve<string>(action.section, context) : undefined;
|
||||
const resolvedName = resolve<string>(action.name, context);
|
||||
const resolvedPlaceholder = action.placeholder
|
||||
? resolve<string>(action.placeholder, context)
|
||||
: undefined;
|
||||
const resolvedPlaceholder = action.placeholder ? resolve<string>(action.placeholder, context) : undefined;
|
||||
|
||||
const children = resolvedChildren
|
||||
? flattenDeep(resolvedChildren.map((a) => actionToKBar(a, context))).filter(
|
||||
|
||||
@@ -106,12 +106,7 @@ const ContentEditable = React.forwardRef(function _ContentEditable(
|
||||
|
||||
const text = event.currentTarget.textContent || "";
|
||||
|
||||
if (
|
||||
maxLength &&
|
||||
"key" in event &&
|
||||
isPrintableKeyEvent(event as React.KeyboardEvent<HTMLSpanElement>) &&
|
||||
text.length >= maxLength
|
||||
) {
|
||||
if (maxLength && 'key' in event && isPrintableKeyEvent(event as React.KeyboardEvent<HTMLSpanElement>) && text.length >= maxLength) {
|
||||
event?.preventDefault();
|
||||
return;
|
||||
}
|
||||
@@ -121,7 +116,16 @@ const ContentEditable = React.forwardRef(function _ContentEditable(
|
||||
onChange?.(text);
|
||||
}
|
||||
|
||||
callback?.(event as any);
|
||||
// Type assertion to handle the union type callback
|
||||
if (callback) {
|
||||
if ('key' in event) {
|
||||
(callback as React.KeyboardEventHandler<HTMLSpanElement>)(event as React.KeyboardEvent<HTMLSpanElement>);
|
||||
} else if ('relatedTarget' in event) {
|
||||
(callback as React.FocusEventHandler<HTMLSpanElement>)(event as React.FocusEvent<HTMLSpanElement>);
|
||||
} else {
|
||||
(callback as React.FormEventHandler<HTMLSpanElement>)(event as React.FormEvent<HTMLSpanElement>);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// This is to account for being within a React.Suspense boundary, in this
|
||||
|
||||
@@ -288,6 +288,9 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
fetch={documents.fetchAlphabetical}
|
||||
options={{
|
||||
collectionId: collection.id,
|
||||
parentDocumentId: null,
|
||||
sort: collection.sort.field,
|
||||
direction: collection.sort.direction.toUpperCase() as "ASC" | "DESC",
|
||||
}}
|
||||
/>
|
||||
</Route>
|
||||
@@ -302,6 +305,9 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
fetch={documents.fetchLeastRecentlyUpdated}
|
||||
options={{
|
||||
collectionId: collection.id,
|
||||
parentDocumentId: null,
|
||||
sort: collection.sort.field,
|
||||
direction: collection.sort.direction.toUpperCase() as "ASC" | "DESC",
|
||||
}}
|
||||
/>
|
||||
</Route>
|
||||
@@ -319,8 +325,11 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
fetch={documents.fetchRecentlyPublished}
|
||||
options={{
|
||||
collectionId: collection.id,
|
||||
parentDocumentId: null,
|
||||
sort: collection.sort.field,
|
||||
direction: collection.sort.direction.toUpperCase() as "ASC" | "DESC",
|
||||
showPublished: true,
|
||||
}}
|
||||
showPublished
|
||||
/>
|
||||
</Route>
|
||||
<Route
|
||||
@@ -337,6 +346,9 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
fetch={documents.fetchRecentlyUpdated}
|
||||
options={{
|
||||
collectionId: collection.id,
|
||||
parentDocumentId: null,
|
||||
sort: collection.sort.field,
|
||||
direction: collection.sort.direction.toUpperCase() as "ASC" | "DESC",
|
||||
}}
|
||||
/>
|
||||
</Route>
|
||||
@@ -354,7 +366,7 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
collectionId: collection.id,
|
||||
parentDocumentId: null,
|
||||
sort: collection.sort.field,
|
||||
direction: collection.sort.direction,
|
||||
direction: collection.sort.direction.toUpperCase() as "ASC" | "DESC",
|
||||
}}
|
||||
showParentDocuments
|
||||
/>
|
||||
@@ -372,7 +384,7 @@ const CollectionScene = observer(function _CollectionScene() {
|
||||
collectionId: collection.id,
|
||||
parentDocumentId: null,
|
||||
sort: collection.sort.field,
|
||||
direction: collection.sort.direction,
|
||||
direction: collection.sort.direction.toUpperCase() as "ASC" | "DESC",
|
||||
statusFilter: [StatusFilter.Archived],
|
||||
}}
|
||||
showParentDocuments
|
||||
|
||||
@@ -17,6 +17,7 @@ import Subheading from "~/components/Subheading";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import NewDocumentMenu from "~/menus/NewDocumentMenu";
|
||||
import DateFilter from "./Search/components/DateFilter";
|
||||
import { PaginationParams } from "~/types";
|
||||
|
||||
function Drafts() {
|
||||
const { t } = useTranslation();
|
||||
@@ -43,7 +44,7 @@ function Drafts() {
|
||||
};
|
||||
|
||||
const isFiltered = collectionId || dateFilter;
|
||||
const options = {
|
||||
const options: PaginationParams = {
|
||||
dateFilter,
|
||||
collectionId,
|
||||
};
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ import { usePinnedDocuments } from "~/hooks/usePinnedDocuments";
|
||||
import usePolicy from "~/hooks/usePolicy";
|
||||
import useStores from "~/hooks/useStores";
|
||||
import NewDocumentMenu from "~/menus/NewDocumentMenu";
|
||||
import { PaginationParams } from "~/types";
|
||||
|
||||
function Home() {
|
||||
const { documents, ui } = useStores();
|
||||
@@ -79,7 +80,7 @@ function Home() {
|
||||
fetch={documents.fetchOwned}
|
||||
options={{
|
||||
userId,
|
||||
}}
|
||||
} as PaginationParams}
|
||||
empty={
|
||||
<Empty>{t("You haven’t created any documents yet")}</Empty>
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user