MCPcopy Index your code
hub / github.com/cedaro/shiny-code / componentDidMount

Method componentDidMount

blocks/code/code-editor.js:16–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14 }
15
16 componentDidMount() {
17 const { language, firstLineNumber, highlightLines, showLineNumbers, theme } = this.props;
18
19 const editor = wp.codeEditor.initialize( this.textarea, {
20 codemirror: {
21 continueComments: true,
22 direction: 'ltr',
23 firstLineNumber: firstLineNumber,
24 gutters: [ 'CodeMirror-lint-markers' ],
25 indentUnit: 4,
26 indentWithTabs: true,
27 inputStyle: 'contenteditable',
28 lineNumbers: showLineNumbers,
29 lineWrapping: false,
30 mode: language || null,
31 styleActiveLine: true,
32 theme: theme,
33 viewportMargin: Infinity,
34 }
35 } );
36
37 editor.codemirror.on( 'change', () => {
38 this.props.onChange( editor.codemirror.getValue() );
39 } );
40
41 editor.codemirror.on( 'gutterClick', ( doc, line ) => {
42 this.props.onLineNumberClick( line );
43 } );
44
45 this.editor = editor;
46 this.highlightLines( highlightLines );
47 this.updateLanguageSettings( language );
48 }
49
50 componentDidUpdate( prevProps, prevState ) {
51 if ( this.props.language !== prevProps.language ) {

Callers

nothing calls this directly

Calls 2

highlightLinesMethod · 0.95

Tested by

no test coverage detected