[web] Conditionally show items in insert figure toolbar (#33721)

Removes the options for inserting an image from another project or by downloading an external URL if the features are disabled.

GitOrigin-RevId: ffa64e5929e254d8a236c8e9aca4eb8210f444c9
This commit is contained in:
Miguel Serrano
2026-05-19 08:04:21 +00:00
committed by Copybot
parent 99148d5956
commit b79d432deb
@@ -36,6 +36,11 @@ export const useToolbarMenuBarEditorCommands = () => {
) )
}, []) }, [])
const {
hasLinkedProjectFileFeature,
hasLinkedProjectOutputFileFeature,
hasLinkUrlFeature,
} = getMeta('ol-ExposedSettings')
useCommandProvider(() => { useCommandProvider(() => {
if (!editorIsVisible) { if (!editorIsVisible) {
return return
@@ -124,6 +129,20 @@ export const useToolbarMenuBarEditorCommands = () => {
openFigureModal(FigureModalSource.FILE_TREE) openFigureModal(FigureModalSource.FILE_TREE)
}, },
}, },
]
}, [view, t, editorIsVisible, openFigureModal, trackedWrite, isTeXFile])
useCommandProvider(() => {
if (!editorIsVisible) {
return
}
if (!isTeXFile || !trackedWrite) {
return
}
if (!hasLinkedProjectFileFeature || !hasLinkedProjectOutputFileFeature) {
return
}
return [
{ {
label: t('from_another_project'), label: t('from_another_project'),
id: 'insert-figure-from-another-project', id: 'insert-figure-from-another-project',
@@ -131,6 +150,28 @@ export const useToolbarMenuBarEditorCommands = () => {
openFigureModal(FigureModalSource.OTHER_PROJECT) openFigureModal(FigureModalSource.OTHER_PROJECT)
}, },
}, },
]
}, [
t,
editorIsVisible,
openFigureModal,
trackedWrite,
isTeXFile,
hasLinkedProjectFileFeature,
hasLinkedProjectOutputFileFeature,
])
useCommandProvider(() => {
if (!editorIsVisible) {
return
}
if (!isTeXFile || !trackedWrite) {
return
}
if (!hasLinkUrlFeature) {
return
}
return [
{ {
label: t('from_url'), label: t('from_url'),
id: 'insert-figure-from-url', id: 'insert-figure-from-url',
@@ -138,6 +179,25 @@ export const useToolbarMenuBarEditorCommands = () => {
openFigureModal(FigureModalSource.FROM_URL) openFigureModal(FigureModalSource.FROM_URL)
}, },
}, },
]
}, [
t,
editorIsVisible,
openFigureModal,
trackedWrite,
isTeXFile,
hasLinkUrlFeature,
])
useCommandProvider(() => {
if (!editorIsVisible) {
return
}
if (!isTeXFile || !trackedWrite) {
return
}
return [
{ {
id: 'insert-table', id: 'insert-table',
label: t('table'), label: t('table'),
@@ -278,16 +338,7 @@ export const useToolbarMenuBarEditorCommands = () => {
}, },
}, },
] ]
}, [ }, [view, t, editorIsVisible, trackedWrite, isTeXFile, canComment, comment])
view,
t,
editorIsVisible,
openFigureModal,
trackedWrite,
isTeXFile,
canComment,
comment,
])
const { toggleSymbolPalette } = useEditorPropertiesContext() const { toggleSymbolPalette } = useEditorPropertiesContext()
const symbolPaletteAvailable = getMeta('ol-symbolPaletteAvailable') const symbolPaletteAvailable = getMeta('ol-symbolPaletteAvailable')