@@ -57,7 +57,6 @@ import { ILabelService } from 'vs/platform/label/common/label';
57
57
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService' ;
58
58
import { NotebookRendererMessagingService } from 'vs/workbench/contrib/notebook/browser/services/notebookRendererMessagingServiceImpl' ;
59
59
import { INotebookRendererMessagingService } from 'vs/workbench/contrib/notebook/common/notebookRendererMessagingService' ;
60
- import { getNotebookEditorFromEditorPane } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
61
60
62
61
// Editor Controller
63
62
import 'vs/workbench/contrib/notebook/browser/controller/coreActions' ;
@@ -115,8 +114,8 @@ import { NotebookLoggingService } from 'vs/workbench/contrib/notebook/browser/se
115
114
import product from 'vs/platform/product/common/product' ;
116
115
import { AccessibilityHelpAction , AccessibleViewAction } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution' ;
117
116
import { NOTEBOOK_IS_ACTIVE_EDITOR , NOTEBOOK_OUTPUT_FOCUSED } from 'vs/workbench/contrib/notebook/common/notebookContextKeys' ;
118
- import { runAccessibilityHelpAction } from 'vs/workbench/contrib/notebook/browser/notebookAccessibilityHelp ' ;
119
- import { AccessibleViewType , IAccessibleViewService } from 'vs/workbench/contrib/accessibility/browser/accessibleView' ;
117
+ import { runAccessibilityHelpAction , showAccessibleOutput } from 'vs/workbench/contrib/notebook/browser/notebookAccessibility ' ;
118
+ import { IAccessibleViewService } from 'vs/workbench/contrib/accessibility/browser/accessibleView' ;
120
119
121
120
/*--------------------------------------------------------------------------------------------- */
122
121
@@ -697,75 +696,13 @@ class NotebookAccessibleViewContribution extends Disposable {
697
696
super ( ) ;
698
697
this . _register ( AccessibleViewAction . addImplementation ( 100 , 'notebook' , accessor => {
699
698
const accessibleViewService = accessor . get ( IAccessibleViewService ) ;
699
+ const editorService = accessor . get ( IEditorService ) ;
700
700
701
- const activePane = accessor . get ( IEditorService ) . activeEditorPane ;
702
- const notebookEditor = getNotebookEditorFromEditorPane ( activePane ) ;
703
- const notebookViewModel = notebookEditor ?. getViewModel ( ) ;
704
- const selections = notebookViewModel ?. getSelections ( ) ;
705
- notebookViewModel ?. getCellIndex ;
706
- const notebookDocument = notebookViewModel ?. notebookDocument ;
707
-
708
- if ( ! selections || ! notebookDocument || ! notebookEditor ?. textModel ) {
709
- return false ;
710
- }
711
-
712
- const viewCell = notebookViewModel . viewCells [ selections [ 0 ] . start ] ;
713
- let outputContent = '' ;
714
- const decoder = new TextDecoder ( ) ;
715
- for ( let i = 0 ; i < viewCell . outputsViewModels . length ; i ++ ) {
716
- const outputViewModel = viewCell . outputsViewModels [ i ] ;
717
- const outputTextModel = viewCell . model . outputs [ i ] ;
718
- const [ mimeTypes , pick ] = outputViewModel . resolveMimeTypes ( notebookEditor . textModel , undefined ) ;
719
- const mimeType = mimeTypes [ pick ] . mimeType ;
720
- let buffer = outputTextModel . outputs . find ( output => output . mime === mimeType ) ;
721
-
722
- if ( ! buffer || mimeType . startsWith ( 'image' ) ) {
723
- buffer = outputTextModel . outputs . find ( output => ! output . mime . startsWith ( 'image' ) ) ;
724
- }
725
-
726
- let text = `${ mimeType } ` ; // default in case we can't get the text value for some reason.
727
- if ( buffer ) {
728
- const charLimit = 100_000 ;
729
- text = decoder . decode ( buffer . data . slice ( 0 , charLimit ) . buffer ) ;
730
-
731
- if ( buffer . data . byteLength > charLimit ) {
732
- text = text + '...(truncated)' ;
733
- }
734
-
735
- if ( mimeType . endsWith ( 'error' ) ) {
736
- text = text . replace ( / \\ u 0 0 1 b \[ [ 0 - 9 ; ] * m / gi, '' ) . replaceAll ( '\\n' , '\n' ) ;
737
- }
738
- }
739
-
740
- const index = viewCell . outputsViewModels . length > 1
741
- ? `Cell output ${ i + 1 } of ${ viewCell . outputsViewModels . length } \n`
742
- : '' ;
743
- outputContent = outputContent . concat ( `${ index } ${ text } \n` ) ;
744
- }
745
-
746
- if ( ! outputContent ) {
747
- return false ;
748
- }
749
-
750
- accessibleViewService . show ( {
751
- verbositySettingKey : 'notebook' ,
752
- provideContent ( ) : string { return outputContent ; } ,
753
- onClose ( ) {
754
- notebookEditor ?. setFocus ( selections [ 0 ] ) ;
755
- activePane ?. focus ( ) ;
756
- } ,
757
- options : {
758
- ariaLabel : nls . localize ( 'NotebookCellOutputAccessibleView' , "Notebook Cell Output Accessible View" ) ,
759
- language : 'plaintext' ,
760
- type : AccessibleViewType . View
761
- }
762
- } ) ;
763
- return true ;
701
+ return showAccessibleOutput ( accessibleViewService , editorService ) ;
764
702
} , NOTEBOOK_OUTPUT_FOCUSED ) ) ;
765
703
}
766
704
}
767
705
768
-
769
706
const workbenchContributionsRegistry = Registry . as < IWorkbenchContributionsRegistry > ( WorkbenchExtensions . Workbench ) ;
770
707
workbenchContributionsRegistry . registerWorkbenchContribution ( NotebookContribution , LifecyclePhase . Starting ) ;
771
708
workbenchContributionsRegistry . registerWorkbenchContribution ( CellContentProvider , LifecyclePhase . Starting ) ;
0 commit comments