Giter VIP home page Giter VIP logo

Comments (23)

reggie-mcmurtrey avatar reggie-mcmurtrey commented on September 21, 2024 15

I would be happy if I could right click a file and chose "open in text editor". That or have a button to click in the details view that was "Open in text editor". Just some way to open most any file in the text editor without having to manually add each extension.

from files_texteditor.

joshmorel avatar joshmorel commented on September 21, 2024 5

I answered my own question by reading the docs. But yes it requires admin intervention on the server so a standard user would need to ask currently.

From the server (Ubuntu):

sudo -u www-user vim /var/www/nextcloud/config/mimetypemapping.json

Add this, replacing 'wiki' with whatever your extension is, adding entries to the array as required.

{
        "wiki": ["text/plain"]
}

Whenever a new file is added you can view it like plain text. However, for existing files the user needs to re-upload them.

From the client machine (Linux/OS-x):

touch $(find /full/path/to/sync/Nextcloud/ -name "*.wiki")

Now they will all re-upload and be viewable as text from a web browser.

For syntax highlight... yes I'll think more about that.

from files_texteditor.

 avatar commented on September 21, 2024 5

I agree with reggie-mcmurtrey that a right-click or detail menu option to open any file in a text editor would handle most cases and should definitely be considered. Separately, having a list of mimetypes that open in a text editor by default is good. I don't think these approaches conflict, though, and would like to have both. That way, most of the ordinary text files will open by default in a text editor, but the user always has the option to open some non-standard file name in an editor if they choose.

from files_texteditor.

tYYGH avatar tYYGH commented on September 21, 2024 4

Basically, we would need what we have on the desktop:

  • a way to map a file to a mime-type, like the file command does (the extension is a hint at best; think about files like README, or miscellaneous custom extensions applied to XML files…)
  • a way for each App to tell what mime types are handled by this App (if any)
  • a default mapping from mime type to App
  • a way for the user to override the App to open for a given mime type, and conversely to reset the setting to its default value.

from files_texteditor.

joshmorel avatar joshmorel commented on September 21, 2024 3

Ditto to spartachetto's request. My use case is .wiki files. I am using vimwiki for creating a personal knowledge base and I will mostly work on this on vim on my desktop. However, I may want to reference these remotely - so being able to preview as if 'txt' file (instead of needing to download) would be really nice.

If there were a way for the admin to tell Nextcloud to treat ".wiki" or whatever like "text" that would be what I'm looking for.

from files_texteditor.

Spartachetto avatar Spartachetto commented on September 21, 2024 2

To be honest I do not know how to modify the lines and use the code in my environment.

It is true that I could learn, but do you really think that this is enough user-friendly???

There are different users need, not only coders could be interested in editing "weird" mimetypes...

By the way, Thank you for your very fast answer!

from files_texteditor.

K-Ko avatar K-Ko commented on September 21, 2024 2

Any progress in customizing file extensions?

For also .sql is important ...

from files_texteditor.

rNoz avatar rNoz commented on September 21, 2024 2

I think the best option will be to allow its configuration via admin/settings, because there are plenty of extensions that we could use (.org, .list, .toml, etc)

from files_texteditor.

despens avatar despens commented on September 21, 2024 1

I like to share SQL queries with nextcloud, file extension is .sql and the editor even supports syntax highlighting. But only offers to download the file instead of live-editing.

from files_texteditor.

tYYGH avatar tYYGH commented on September 21, 2024 1

Same request. The file extension I am interested in is .adoc (AsciiDoc).
Cheers,

from files_texteditor.

nickvergessen avatar nickvergessen commented on September 21, 2024

You can add your mimetypes here:
https://github.com/nextcloud/files_texteditor/blob/master/js/editor.js#L243-L254

Not sure if it makes a lot of sense to make this configurable in any way

from files_texteditor.

nickvergessen avatar nickvergessen commented on September 21, 2024

Well if you say which mime types you want to add we can have a look

from files_texteditor.

Spartachetto avatar Spartachetto commented on September 21, 2024

I have two different situations in mind:

  • files formats that I usually want to open in the editor like R and Rmd. For this kind of files I would love Syntax Highlighting and I also opened the issue #16
  • files formats that I usually want to download but each now and then I would like to open, like a gpx

To have the possibility of opening the first mimetypes would be already really good
The second group of mimetypes is quite difficult to detail and is really cherry topping on the cake!!!

from files_texteditor.

nickvergessen avatar nickvergessen commented on September 21, 2024

For markdown there is an additional app which also has a "live demo" then:
https://github.com/icewind1991/files_markdown (it's an addon to the files_texteditor)

from files_texteditor.

Spartachetto avatar Spartachetto commented on September 21, 2024

sorry, my mistake!

from files_texteditor.

DMW007 avatar DMW007 commented on September 21, 2024

I found out that the texteditor associates a lot of common extensions to itself - like ps1 for powershell scripts. But it seems that they're not updated for a caching issue. Try update the cache manually, and you may notice that a lot of entrys were refreshed like here:

root@c54e549e02cb:/var/www/html# sudo -u www-data php occ maintenance:mimetype:update-db --repair-filecache
Added mimetype "application/x-text" to database
Updated 40 filecache rows for mimetype "application/x-text"
Added 1 new mimetypes
Updated 40 filecache rows

You may combine this with the custom mime mapping suggested here, if you want syntax highlighting for extensions that the editor doesn't know by default. I was able to create custom mappings in config/mimetypemapping.json like this:

{
    "sql": ["application/x-text"]
}

This solution works for already existing files, too. Re-uploading them is not necessary here after cache update :)

from files_texteditor.

Spartachetto avatar Spartachetto commented on September 21, 2024

While other mime-types keep getting asked (#42 ), I'd like to explain why I have doubts on command line use and config file s editing.

There are several users that use a managed instance of Nextcloud. They can have access to the admin user, but they usually do not have access to the command line or to the config files. A practical way to manage mime-types in this scenario would be great

from files_texteditor.

bobberb avatar bobberb commented on September 21, 2024

I have a few orgmode files that are plaintext. Do I use "text/org" or something else?

from files_texteditor.

theonlytruth avatar theonlytruth commented on September 21, 2024

I also would like to open .ino files in the online text editor.

from files_texteditor.

ludenticus avatar ludenticus commented on September 21, 2024

It'd be useful to open beancount files...

from files_texteditor.

Spartachetto avatar Spartachetto commented on September 21, 2024

@MartinConsultingServicesInc comment reminded me of something (#15 (comment) ) 😄

from files_texteditor.

Sheepings avatar Sheepings commented on September 21, 2024

For some of us who have a range of different file types which does not open with the code editor/text editor. I sure would like to see the ability to open files in an editor instead of just being offered to download them. For unknown extensions, the default action is to download a file when its clicked. This is not what I'd prefer.

For files like .cs or .aspx file types, there is no option to open them in a default text editor. How would one go about mapping file types to make them open in a text/code editor?

from files_texteditor.

ionum avatar ionum commented on September 21, 2024

editor.js in folder app/files_texteditor/build/ tries to load "./js/supported_mimetypes.json" but fails. fallback-mimetypes are hardcoded in editor.js. Where should supported_mimetypes.json be placed to be read from editor.js?

from files_texteditor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.