Просмотр исходного кода

Remove hidden comment button from editor toolbar (#17386)

GitOrigin-RevId: 61b3725a7b2112c6e5abca0349b1be910e97266a
Alf Eaton 2 лет назад
Родитель
Сommit
5df35093ea

+ 0 - 1
services/web/frontend/extracted-translations.json

@@ -1335,7 +1335,6 @@
   "too_many_search_results": "",
   "too_many_search_results": "",
   "too_recently_compiled": "",
   "too_recently_compiled": "",
   "took_a_while": "",
   "took_a_while": "",
-  "toolbar_add_comment": "",
   "toolbar_bullet_list": "",
   "toolbar_bullet_list": "",
   "toolbar_choose_section_heading_level": "",
   "toolbar_choose_section_heading_level": "",
   "toolbar_decrease_indent": "",
   "toolbar_decrease_indent": "",

+ 2 - 30
services/web/frontend/js/features/source-editor/components/toolbar/toolbar-items.tsx

@@ -1,15 +1,11 @@
-import { FC, memo, useCallback } from 'react'
-import { EditorSelection, EditorState } from '@codemirror/state'
-import { EditorView } from '@codemirror/view'
+import { FC, memo } from 'react'
+import { EditorState } from '@codemirror/state'
 import { useEditorContext } from '../../../../shared/context/editor-context'
 import { useEditorContext } from '../../../../shared/context/editor-context'
-import useScopeEventEmitter from '../../../../shared/hooks/use-scope-event-emitter'
-import { useLayoutContext } from '../../../../shared/context/layout-context'
 import { withinFormattingCommand } from '../../utils/tree-operations/ancestors'
 import { withinFormattingCommand } from '../../utils/tree-operations/ancestors'
 import { ToolbarButton } from './toolbar-button'
 import { ToolbarButton } from './toolbar-button'
 import { redo, undo } from '@codemirror/commands'
 import { redo, undo } from '@codemirror/commands'
 import * as commands from '../../extensions/toolbar/commands'
 import * as commands from '../../extensions/toolbar/commands'
 import { SectionHeadingDropdown } from './section-heading-dropdown'
 import { SectionHeadingDropdown } from './section-heading-dropdown'
-import { canAddComment } from '../../extensions/toolbar/comments'
 import getMeta from '../../../../utils/meta'
 import getMeta from '../../../../utils/meta'
 import { InsertFigureDropdown } from './insert-figure-dropdown'
 import { InsertFigureDropdown } from './insert-figure-dropdown'
 import { useTranslation } from 'react-i18next'
 import { useTranslation } from 'react-i18next'
@@ -34,22 +30,6 @@ export const ToolbarItems: FC<{
   const { t } = useTranslation()
   const { t } = useTranslation()
   const { toggleSymbolPalette, showSymbolPalette } = useEditorContext()
   const { toggleSymbolPalette, showSymbolPalette } = useEditorContext()
   const isActive = withinFormattingCommand(state)
   const isActive = withinFormattingCommand(state)
-  const addCommentEmitter = useScopeEventEmitter('comment:start_adding')
-  const { setReviewPanelOpen } = useLayoutContext()
-  const addComment = useCallback(
-    (view: EditorView) => {
-      const range = view.state.selection.main
-      if (range.empty) {
-        const line = view.state.doc.lineAt(range.head)
-        view.dispatch({
-          selection: EditorSelection.range(line.from, line.to),
-        })
-      }
-      setReviewPanelOpen(true)
-      addCommentEmitter()
-    },
-    [addCommentEmitter, setReviewPanelOpen]
-  )
 
 
   const symbolPaletteAvailable = getMeta('ol-symbolPaletteAvailable')
   const symbolPaletteAvailable = getMeta('ol-symbolPaletteAvailable')
   const showGroup = (group: string) => !overflowed || overflowed.has(group)
   const showGroup = (group: string) => !overflowed || overflowed.has(group)
@@ -146,14 +126,6 @@ export const ToolbarItems: FC<{
                 command={commands.insertCite}
                 command={commands.insertCite}
                 icon="book"
                 icon="book"
               />
               />
-              <ToolbarButton
-                id="toolbar-add-comment"
-                label={t('toolbar_add_comment')}
-                command={addComment}
-                disabled={!canAddComment(state)}
-                icon="comment"
-                hidden // enable this if an alternative to the floating "Add Comment" button is needed
-              />
               <InsertFigureDropdown />
               <InsertFigureDropdown />
               <TableInserterDropdown />
               <TableInserterDropdown />
             </div>
             </div>

+ 0 - 14
services/web/frontend/js/features/source-editor/extensions/toolbar/comments.ts

@@ -1,14 +0,0 @@
-import { EditorState } from '@codemirror/state'
-
-export const canAddComment = (state: EditorState) => {
-  // TODO: permissions.comment
-
-  // allow an empty selection if there's content on the line
-  const range = state.selection.main
-  if (range.empty) {
-    return state.doc.lineAt(range.head).text.length > 0
-  }
-
-  // always allow a non-empty selection
-  return true
-}

+ 0 - 1
services/web/locales/en.json

@@ -1927,7 +1927,6 @@
   "too_many_search_results": "There are more than 100 results. Please refine your search.",
   "too_many_search_results": "There are more than 100 results. Please refine your search.",
   "too_recently_compiled": "This project was compiled very recently, so this compile has been skipped.",
   "too_recently_compiled": "This project was compiled very recently, so this compile has been skipped.",
   "took_a_while": "That took a while...",
   "took_a_while": "That took a while...",
-  "toolbar_add_comment": "Add Comment",
   "toolbar_bullet_list": "Bullet List",
   "toolbar_bullet_list": "Bullet List",
   "toolbar_choose_section_heading_level": "Choose section heading level",
   "toolbar_choose_section_heading_level": "Choose section heading level",
   "toolbar_decrease_indent": "Decrease Indent",
   "toolbar_decrease_indent": "Decrease Indent",