-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mahesh Patil <[email protected]>
- Loading branch information
1 parent
7559e57
commit 93e845c
Showing
3 changed files
with
85 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,78 @@ | ||
import * as monaco from '@monaco-editor/react'; | ||
import { editor } from 'monaco-editor'; | ||
|
||
const options: editor.IStandaloneEditorConstructionOptions = { | ||
const options:editor.IStandaloneEditorConstructionOptions = { | ||
minimap: { enabled: false }, | ||
wordWrap: 'on', | ||
wordWrap: "on", | ||
automaticLayout:true, | ||
scrollBeyondLastLine: false, | ||
}; | ||
|
||
const concertoKeywords = [ | ||
'map', 'concept', 'from', 'optional', 'default', 'range', 'regex', 'length', 'abstract', | ||
'namespace', 'import', 'enum', 'scalar', 'extends', 'default', 'participant', 'asset', | ||
'o', 'identified by', 'transaction', 'event' | ||
]; | ||
|
||
const concertoTypes = ['String', 'Integer', 'Double', 'DateTime', 'Long', 'Boolean']; | ||
|
||
export default function ConcertoEditor({ value, onChange }: { value: string, onChange?: (value: string | undefined) => void }) { | ||
} | ||
const concertoKeywords = ['map','concept','from','optional','default','range','regex','length','abstract','namespace','import', 'enum', 'scalar', 'extends', 'default', 'participant','asset', 'o','identified by','transaction','event']; | ||
const concertoTypes = ['String','Integer','Double','DateTime','Long','Boolean'] | ||
|
||
function handleEditorWillMount(monaco: monaco.Monaco) { | ||
monaco.languages.register({ | ||
id: 'concerto', | ||
extensions: ['.cto'], | ||
aliases: ['Concerto', 'concerto'], | ||
mimetypes: ['application/vnd.accordproject.concerto'], | ||
}); | ||
export default function ConcertoEditor( {value, onChange} : {value: string, onChange?: (value:string|undefined) => void} ) { | ||
|
||
monaco.languages.setMonarchTokensProvider('concerto', { | ||
keywords: concertoKeywords, | ||
typeKeywords: concertoTypes, | ||
operators: ['=', '{', '}', '@', '"'], | ||
symbols: /[=}{@"]+/, | ||
escapes: /\\(?:[btnfru"'\\]|\\u[0-9A-Fa-f]{4})/, | ||
tokenizer: { | ||
root: [ | ||
{ include: '@whitespace' }, | ||
[/[a-zA-Z_]\w*/, { | ||
cases: { | ||
'@keywords': 'keyword', | ||
'@typeKeywords': 'type', | ||
'@default': 'identifier', | ||
function handleEditorWillMount(monaco:monaco.Monaco) { | ||
monaco.languages.register({ | ||
id: 'concerto', | ||
extensions: ['.cto'], | ||
aliases: ['Concerto', 'concerto'], | ||
mimetypes: ['application/vnd.accordproject.concerto'], | ||
}); | ||
|
||
monaco.languages.setMonarchTokensProvider('concerto', { | ||
keywords: concertoKeywords, | ||
typeKeywords: concertoTypes, | ||
operators: ['=', '{', '}', '@', '"'], | ||
symbols: /[=}{@"]+/, | ||
escapes: /\\(?:[btnfru"'\\]|\\u[0-9A-Fa-f]{4})/, | ||
tokenizer: { | ||
root: [ | ||
{ include: '@whitespace' }, | ||
[/[a-zA-Z_]\w*/, { | ||
cases: { | ||
'@keywords': 'keyword', | ||
'@typeKeywords': 'type', | ||
'@default': 'identifier', | ||
}, | ||
}], | ||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-terminated string | ||
[/"/, 'string', '@string'], | ||
], | ||
string: [ | ||
[/[^\\"]+/, 'string'], | ||
[/@escapes/, 'string.escape'], | ||
[/\\./, 'string.escape.invalid'], | ||
[/"/, 'string', '@pop'], | ||
], | ||
whitespace: [ | ||
[/\s+/, 'white'], | ||
[/(\/\/.*)/, 'comment'], | ||
], | ||
}, | ||
}], | ||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-terminated string | ||
[/"/, 'string', '@string'], | ||
], | ||
string: [ | ||
[/[^\\"]+/, 'string'], | ||
[/@escapes/, 'string.escape'], | ||
[/\\./, 'string.escape.invalid'], | ||
[/"/, 'string', '@pop'], | ||
], | ||
whitespace: [ | ||
[/\s+/, 'white'], | ||
[/(\/\/.*)/, 'comment'], | ||
], | ||
}, | ||
}); | ||
|
||
monaco.editor.defineTheme('concertoTheme', { | ||
base: 'vs', | ||
inherit: true, | ||
rules: [ | ||
{ token: 'keyword', foreground: 'cd2184' }, | ||
{ token: 'type', foreground: '008080' }, | ||
{ token: 'identifier', foreground: '000000' }, | ||
{ token: 'string', foreground: '008000' }, | ||
{ token: 'string.escape', foreground: '800000' }, | ||
{ token: 'comment', foreground: '808080' }, | ||
{ token: 'white', foreground: 'FFFFFF' }, | ||
], | ||
colors: {}, | ||
}); | ||
|
||
monaco.editor.setTheme('concertoTheme'); | ||
} | ||
|
||
return ( | ||
}); | ||
monaco.editor.defineTheme('concertoTheme', { | ||
base: 'vs', | ||
inherit: true, | ||
rules: [ | ||
{ token: 'keyword', foreground: 'cd2184' }, | ||
{ token: 'type', foreground: '008080' }, | ||
{ token: 'identifier', foreground: '000000' }, | ||
{ token: 'string', foreground: '008000' }, | ||
{ token: 'string.escape', foreground: '800000' }, | ||
{ token: 'comment', foreground: '808080' }, | ||
{ token: 'white', foreground: 'FFFFFF' }, | ||
], | ||
colors: {}, | ||
}); | ||
|
||
monaco.editor.setTheme('concertoTheme'); | ||
} | ||
|
||
return ( | ||
<div className="editorwrapper"> | ||
<monaco.Editor | ||
options={options} | ||
language='concerto' | ||
height="60vh" | ||
value={value} | ||
onChange={onChange} | ||
beforeMount={handleEditorWillMount} | ||
/> | ||
<monaco.Editor options={ options } | ||
language='concerto' height="60vh" value={value} onChange={onChange} beforeMount={handleEditorWillMount}/> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
import * as monaco from '@monaco-editor/react'; | ||
import { editor } from 'monaco-editor'; | ||
|
||
const options: editor.IStandaloneEditorConstructionOptions = { | ||
const options:editor.IStandaloneEditorConstructionOptions = { | ||
minimap: { enabled: false }, | ||
wordWrap: 'on', | ||
automaticLayout: true, | ||
wordWrap: "on", | ||
automaticLayout:true, | ||
scrollBeyondLastLine: false, | ||
}; | ||
} | ||
|
||
export default function JSONEditor({ value, onChange }: { value: string, onChange?: (value: string | undefined) => void }) { | ||
return ( | ||
export default function JSONEditor( {value, onChange} : {value: string, onChange?: (value:string|undefined) => void} ) { | ||
|
||
return ( | ||
<div className="editorwrapper"> | ||
<monaco.Editor | ||
options={options} | ||
language='json' | ||
height="60vh" | ||
value={value} | ||
onChange={onChange} | ||
/> | ||
<monaco.Editor options={ options } | ||
language='json' height="60vh" value={value} onChange={onChange} /> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
import * as monaco from '@monaco-editor/react'; | ||
import { editor } from 'monaco-editor'; | ||
|
||
const options: editor.IStandaloneEditorConstructionOptions = { | ||
const options:editor.IStandaloneEditorConstructionOptions = { | ||
minimap: { enabled: false }, | ||
wordWrap: 'on', | ||
wordWrap: "on", | ||
automaticLayout:true, | ||
scrollBeyondLastLine: false, | ||
}; | ||
} | ||
|
||
export default function MarkdownEditor({ value, onChange }: { value: string, onChange?: (value: string | undefined) => void }) { | ||
export default function MarkdownEditor( {value, onChange} : {value: string, onChange?: (value:string|undefined) => void} ) { | ||
return ( | ||
<div className="editorwrapper"> | ||
<monaco.Editor | ||
options={options} | ||
height="60vh" | ||
value={value} | ||
onChange={onChange} | ||
/> | ||
<monaco.Editor options={ options } | ||
language='markdown' height="60vh" value={value} onChange={onChange}/> | ||
</div> | ||
); | ||
} | ||
} |