react-ace icon indicating copy to clipboard operation
react-ace copied to clipboard

Can't load snippets/python.js file

Open TimonPeng opened this issue 10 years ago • 2 comments

When I set up enableSnippets: true, the page can not load the snippets/python.js file, how can I fix it?

Thanks very much.

TimonPeng avatar Nov 18 '16 19:11 TimonPeng

@TimonPeng Can you give a code example? Also, did you make sure to include ext-language_tools (https://github.com/ajaxorg/ace/blob/master/demo/autocompletion.html)

drewen avatar May 13 '17 12:05 drewen

@TimonPeng you can import the snippets and mode directly through brace along with the language_tools. Here is an example below

import React from 'react';
import { render } from 'react-dom';
import brace from 'brace';
import AceEditor from 'react-ace';

import 'brace/mode/python';
import 'brace/snippets/python';
import 'brace/ext/language_tools';
import 'brace/theme/github';

function onChange(newValue) {
  console.log('change',newValue);
}

// Render editor
render(
  <AceEditor
    mode="python"
    theme="github"
    onChange={onChange}
    name="UNIQUE_ID_OF_DIV"
    editorProps={{$blockScrolling: true}}
    enableBasicAutocompletion={true}
    enableLiveAutocompletion={true}
    enableSnippets={true}
    />,
  document.getElementById('example')
);

securingsincity avatar May 28 '17 00:05 securingsincity