Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax the fileType function to permit Monaco (and ACE) to work with more file types #102

Closed
Steve-Mcl opened this issue Jan 3, 2021 · 2 comments
Assignees
Labels
enhancement Improvements to code or new features
Milestone

Comments

@Steve-Mcl
Copy link

Software Version
Node.JS All
npm NA
Node-RED ALL
uibuilder node 3.0.0
OS All
Browser All

Hi Julian, as discussed here, is it possible you can relax the fileType function to permit Monaco (and ACE) to work with more file types?

@TotallyInformation
Copy link
Owner

The function that does the work is here:

/** Return a file type from a file name (or default to txt)
* ftype can be used in ACE editor modes */
function fileType(fname) {
var fparts = fname.split('.')
if (fparts.length > 1) {
var ftype = 'text'
var fext = fparts[1].toLowerCase().trim()
switch (fext) {
case 'js':
ftype = 'javascript'
break
case 'html':
case 'css':
case 'json':
ftype = fext
break
case 'vue':
ftype = 'html'
break
case 'md':
ftype = 'markdown'
break
case 'yaml':
case 'yml':
ftype = 'yaml'
break
default:
// txt
}
return ftype
} else {
return 'text'
}
} // --- End of fileType --- //

I will change the default entry to return the fext value rather than 'text'.

Assuming that doesn't create any issues, it will be incorporated into the next release.

@TotallyInformation TotallyInformation added the enhancement Improvements to code or new features label Jan 11, 2021
@TotallyInformation TotallyInformation self-assigned this Jan 11, 2021
@TotallyInformation TotallyInformation added this to the v3.0.2 milestone Jan 11, 2021
TotallyInformation added a commit that referenced this issue Jan 11, 2021
@TotallyInformation
Copy link
Owner

Fixed.

Minor issue remains that you can "edit" binary files like images - I probably should stop that :-)

Also note that this change highlighted a couple of small bugs related to trying to edit dotfiles. Now also fixed. See #105 and #106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to code or new features
Projects
None yet
Development

No branches or pull requests

2 participants