mirror of
https://github.com/docmost/docmost.git
synced 2026-08-28 09:17:06 +08:00
feat: support opening property menu directly on options panel
This commit is contained in:
@@ -53,6 +53,7 @@ type PropertyMenuContentProps = {
|
|||||||
onDirtyChange?: (dirty: boolean) => void;
|
onDirtyChange?: (dirty: boolean) => void;
|
||||||
onEditFormula?: () => void;
|
onEditFormula?: () => void;
|
||||||
pageId: string;
|
pageId: string;
|
||||||
|
initialPanel?: "main" | "options";
|
||||||
};
|
};
|
||||||
|
|
||||||
type MenuPanel =
|
type MenuPanel =
|
||||||
@@ -96,9 +97,10 @@ export function PropertyMenuContent({
|
|||||||
onDirtyChange,
|
onDirtyChange,
|
||||||
onEditFormula,
|
onEditFormula,
|
||||||
pageId,
|
pageId,
|
||||||
|
initialPanel,
|
||||||
}: PropertyMenuContentProps) {
|
}: PropertyMenuContentProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [panel, setPanel] = useState<MenuPanel>("main");
|
const [panel, setPanel] = useState<MenuPanel>(initialPanel ?? "main");
|
||||||
const [renameValue, setRenameValue] = useState(property.name);
|
const [renameValue, setRenameValue] = useState(property.name);
|
||||||
const renameInputRef = useRef<HTMLInputElement>(null);
|
const renameInputRef = useRef<HTMLInputElement>(null);
|
||||||
const [optionsDirty, setOptionsDirty] = useState(false);
|
const [optionsDirty, setOptionsDirty] = useState(false);
|
||||||
@@ -117,12 +119,12 @@ export function PropertyMenuContent({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (opened) {
|
if (opened) {
|
||||||
setPanel("main");
|
setPanel(initialPanel ?? "main");
|
||||||
setRenameValue(property.name);
|
setRenameValue(property.name);
|
||||||
setOptionsDirty(false);
|
setOptionsDirty(false);
|
||||||
setPendingTargetType(null);
|
setPendingTargetType(null);
|
||||||
}
|
}
|
||||||
}, [opened, property.name]);
|
}, [opened, property.name, initialPanel]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (panel === "rename") {
|
if (panel === "rename") {
|
||||||
@@ -463,7 +465,7 @@ export function PropertyMenuContent({
|
|||||||
|
|
||||||
PropertyMenuContent.displayName = "PropertyMenuContent";
|
PropertyMenuContent.displayName = "PropertyMenuContent";
|
||||||
|
|
||||||
function MenuItem({
|
export function MenuItem({
|
||||||
icon,
|
icon,
|
||||||
label,
|
label,
|
||||||
rightIcon,
|
rightIcon,
|
||||||
|
|||||||
Reference in New Issue
Block a user