mirror of
https://github.com/docmost/docmost.git
synced 2026-08-31 02:46:27 +08:00
feat(ee): bases
Table and kanban UI, formula engine package, and the base-embed editor extension
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { createContext, useContext, type ReactNode } from "react";
|
||||
|
||||
const BaseEditableContext = createContext<boolean>(true);
|
||||
|
||||
export function BaseEditableProvider({
|
||||
editable,
|
||||
children,
|
||||
}: {
|
||||
editable: boolean;
|
||||
children: ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<BaseEditableContext.Provider value={editable}>
|
||||
{children}
|
||||
</BaseEditableContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
/** Whether the current base subtree is editable. Defaults to true outside a provider. */
|
||||
export function useBaseEditable(): boolean {
|
||||
return useContext(BaseEditableContext);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
// Row order is only needed at interaction time (shift-select range math), so
|
||||
// rows subscribe to a stable getter instead of the array itself — appending a
|
||||
// page must not re-render every mounted row.
|
||||
const GridRowOrderContext = createContext<() => string[]>(() => []);
|
||||
|
||||
export const GridRowOrderProvider = GridRowOrderContext.Provider;
|
||||
|
||||
export function useGridRowOrder(): () => string[] {
|
||||
return useContext(GridRowOrderContext);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { createContext, useContext } from "react";
|
||||
|
||||
// Rows only need the handler at click time; a stable context value keeps the
|
||||
// expand affordance out of every GridRow/GridCell memo equality check.
|
||||
const RowExpandContext = createContext<((rowId: string) => void) | null>(null);
|
||||
|
||||
export const RowExpandProvider = RowExpandContext.Provider;
|
||||
|
||||
export function useRowExpand(): ((rowId: string) => void) | null {
|
||||
return useContext(RowExpandContext);
|
||||
}
|
||||
Reference in New Issue
Block a user