react-ace
react-ace copied to clipboard
PHP syntax is not working?
Problem
I'm not getting any syntax highlighting with PHP mode + PHP worker at all
Sample code to reproduce your issue
import React from 'react'
import AceEditor from 'react-ace'
import 'ace-builds/src-min-noconflict/mode-php'
import 'ace-builds/src-min-noconflict/theme-textmate'
import ace from 'ace-builds/src-noconflict/ace'
ace.config.set(
"basePath",
"https://cdn.jsdelivr.net/npm/[email protected]/src-noconflict/"
)
const Editor = ({ onEditorChange, code }) => {
return(
<>
<AceEditor
value={code}
style={{width: '100%', height: '100%'}}
mode="php"
theme="textmate"
onChange={(val) => onEditorChange(val)}
name="algoEditor"
editorProps={{ $blockScrolling: true }}
/>
</>
)
}
export default Editor
I think it highlights only if you have <?php tags
@cristeacosmin is right you would need to have valid php syntax for code to highlight