@replit/codemirror-lang-solidity
v6.0.2
Published
Solidity language support for CM6
Downloads
167,618
Maintainers
Keywords
Readme
CodeMirror Solidity Language Support
A CodeMirror extension that provides Solidity syntax highlighting and language support.
Usage
import { basicSetup } from 'codemirror';
import { EditorView } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import { solidity } from '@replit/codemirror-lang-solidity';
const doc = `
pragma solidity ^0.8.10;
contract EtherWallet {
address payable public owner;
constructor() {
owner = payable(msg.sender);
}
receive() external payable {}
function withdraw(uint _amount) external {
require(msg.sender == owner, "caller is not owner");
payable(msg.sender).transfer(_amount);
}
function getBalance() external view returns (uint) {
return address(this).balance;
}
}
`
new EditorView({
state: EditorState.create({
doc,
extensions: [
basicSetup,
solidity,
],
}),
parent: document.querySelector('#editor'),
});