mirror of
https://github.com/TriliumNext/Trilium.git
synced 2025-12-11 05:45:26 -06:00
feat(popup_editor): hide some unwanted floating buttons
This commit is contained in:
parent
015d70afb6
commit
15c088ec21
@ -64,7 +64,15 @@ export const MOBILE_FLOATING_BUTTONS: FloatingButtonsList = [
|
|||||||
RelationMapButtons,
|
RelationMapButtons,
|
||||||
ExportImageButtons,
|
ExportImageButtons,
|
||||||
Backlinks
|
Backlinks
|
||||||
]
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Floating buttons that should be hidden in popup editor (Quick edit).
|
||||||
|
*/
|
||||||
|
export const POPUP_HIDDEN_FLOATING_BUTTONS: FloatingButtonsList = [
|
||||||
|
InAppHelpButton,
|
||||||
|
ToggleReadOnlyButton
|
||||||
|
];
|
||||||
|
|
||||||
function RefreshBackendLogButton({ note, parentComponent, noteContext, isDefaultViewMode }: FloatingButtonContext) {
|
function RefreshBackendLogButton({ note, parentComponent, noteContext, isDefaultViewMode }: FloatingButtonContext) {
|
||||||
const isEnabled = (note.noteId === "_backendLog" || note.type === "render") && isDefaultViewMode;
|
const isEnabled = (note.noteId === "_backendLog" || note.type === "render") && isDefaultViewMode;
|
||||||
@ -102,7 +110,7 @@ function ToggleReadOnlyButton({ note, viewType, isDefaultViewMode }: FloatingBut
|
|||||||
function EditButton({ note, noteContext }: FloatingButtonContext) {
|
function EditButton({ note, noteContext }: FloatingButtonContext) {
|
||||||
const [animationClass, setAnimationClass] = useState("");
|
const [animationClass, setAnimationClass] = useState("");
|
||||||
const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext);
|
const {isReadOnly, enableEditing} = useIsNoteReadOnly(note, noteContext);
|
||||||
|
|
||||||
const isReadOnlyInfoBarDismissed = false; // TODO
|
const isReadOnlyInfoBarDismissed = false; // TODO
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useContext, useEffect, useRef, useState } from "preact/hooks";
|
import { useContext, useEffect, useMemo, useRef, useState } from "preact/hooks";
|
||||||
import Modal from "../react/Modal";
|
import Modal from "../react/Modal";
|
||||||
import "./PopupEditor.css";
|
import "./PopupEditor.css";
|
||||||
import { useNoteContext, useTriliumEvent } from "../react/hooks";
|
import { useNoteContext, useTriliumEvent } from "../react/hooks";
|
||||||
@ -13,13 +13,18 @@ import StandaloneRibbonAdapter from "../ribbon/components/StandaloneRibbonAdapte
|
|||||||
import FormattingToolbar from "../ribbon/FormattingToolbar";
|
import FormattingToolbar from "../ribbon/FormattingToolbar";
|
||||||
import PromotedAttributes from "../PromotedAttributes";
|
import PromotedAttributes from "../PromotedAttributes";
|
||||||
import FloatingButtons from "../FloatingButtons";
|
import FloatingButtons from "../FloatingButtons";
|
||||||
import { DESKTOP_FLOATING_BUTTONS, MOBILE_FLOATING_BUTTONS } from "../FloatingButtonsDefinitions";
|
import { DESKTOP_FLOATING_BUTTONS, MOBILE_FLOATING_BUTTONS, POPUP_HIDDEN_FLOATING_BUTTONS } from "../FloatingButtonsDefinitions";
|
||||||
import utils from "../../services/utils";
|
import utils from "../../services/utils";
|
||||||
|
|
||||||
export default function PopupEditor() {
|
export default function PopupEditor() {
|
||||||
const [ shown, setShown ] = useState(false);
|
const [ shown, setShown ] = useState(false);
|
||||||
const parentComponent = useContext(ParentComponent);
|
const parentComponent = useContext(ParentComponent);
|
||||||
const [ noteContext, setNoteContext ] = useState(new NoteContext("_popup-editor"));
|
const [ noteContext, setNoteContext ] = useState(new NoteContext("_popup-editor"));
|
||||||
|
const isMobile = utils.isMobile();
|
||||||
|
const items = useMemo(() => {
|
||||||
|
const baseItems = isMobile ? MOBILE_FLOATING_BUTTONS : DESKTOP_FLOATING_BUTTONS;
|
||||||
|
return baseItems.filter(item => !POPUP_HIDDEN_FLOATING_BUTTONS.includes(item));
|
||||||
|
}, [ isMobile ]);
|
||||||
|
|
||||||
useTriliumEvent("openInPopup", async ({ noteIdOrPath }) => {
|
useTriliumEvent("openInPopup", async ({ noteIdOrPath }) => {
|
||||||
const noteContext = new NoteContext("_popup-editor");
|
const noteContext = new NoteContext("_popup-editor");
|
||||||
@ -54,7 +59,7 @@ export default function PopupEditor() {
|
|||||||
>
|
>
|
||||||
<PromotedAttributes />
|
<PromotedAttributes />
|
||||||
<StandaloneRibbonAdapter component={FormattingToolbar} />
|
<StandaloneRibbonAdapter component={FormattingToolbar} />
|
||||||
<FloatingButtons items={utils.isMobile() ? MOBILE_FLOATING_BUTTONS : DESKTOP_FLOATING_BUTTONS} />
|
<FloatingButtons items={items} />
|
||||||
<NoteDetail />
|
<NoteDetail />
|
||||||
<NoteList media="screen" displayOnlyCollections />
|
<NoteList media="screen" displayOnlyCollections />
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user