Jelajahi Sumber

Add comment option in editor toolbar (#22849)

* Add comment option in editor toolbar

* move addComment to commands

GitOrigin-RevId: 690b70f67abe5653f28ec9ec61deb3f201a78131
Domagoj Kriskovic 1 tahun lalu
induk
melakukan
36f2e52167

+ 10 - 0
services/web/frontend/js/features/source-editor/components/toolbar/toolbar-items.tsx

@@ -12,6 +12,7 @@ import { MathDropdown } from './math-dropdown'
 import { TableInserterDropdown } from './table-inserter-dropdown'
 import { TableInserterDropdown } from './table-inserter-dropdown'
 import { withinFormattingCommand } from '@/features/source-editor/utils/tree-operations/formatting'
 import { withinFormattingCommand } from '@/features/source-editor/utils/tree-operations/formatting'
 import { bsVersion } from '@/features/utils/bootstrap-5'
 import { bsVersion } from '@/features/utils/bootstrap-5'
+import { isSplitTestEnabled } from '@/utils/splitTestUtils'
 
 
 const isMac = /Mac/.test(window.navigator?.platform)
 const isMac = /Mac/.test(window.navigator?.platform)
 
 
@@ -124,6 +125,15 @@ export const ToolbarItems: FC<{
                 command={commands.wrapInHref}
                 command={commands.wrapInHref}
                 icon={bsVersion({ bs5: 'add_link', bs3: 'link' })}
                 icon={bsVersion({ bs5: 'add_link', bs3: 'link' })}
               />
               />
+              {isSplitTestEnabled('review-panel-redesign') && (
+                <ToolbarButton
+                  id="toolbar-add-comment"
+                  label={t('add_comment')}
+                  disabled={state.selection.main.empty}
+                  command={commands.addComment}
+                  icon={bsVersion({ bs5: 'add_comment', bs3: 'comment' })}
+                />
+              )}
               <ToolbarButton
               <ToolbarButton
                 id="toolbar-ref"
                 id="toolbar-ref"
                 label={t('toolbar_insert_cross_reference')}
                 label={t('toolbar_insert_cross_reference')}

+ 4 - 0
services/web/frontend/js/features/source-editor/extensions/toolbar/commands.ts

@@ -155,3 +155,7 @@ export const toggleSearch: Command = view => {
   }
   }
   return true
   return true
 }
 }
+
+export const addComment = () => {
+  window.dispatchEvent(new Event('add-new-review-comment'))
+}