xdan / jodit

Jodit - Best WYSIWYG Editor for You
https://xdsoft.net/jodit/
MIT License
1.62k stars 342 forks source link

FileBrowser - Multiple Sources #1092

Open WatchfulEyeOfZod opened 4 months ago

WatchfulEyeOfZod commented 4 months ago

Jodit Version: 4.0

Browser: Chrome OS: Mac Is React App: False

When the configuration for the jodit-connector contains multiple sources, the File Browser UI does not provide a way to change between them. Once you enter one source, all subsequent commands are for that source.

Code

// Configuration from Custom (Python) Jodit Connector
config = {
     // ...
     'sources' : {
           'Area One' : {
                'root' : '/tmp/JoditBackend/ROOT/abc/',
                'baseurl' : 'http://localhost:8000/ROOT/abc/',
                'maxFileSize' : '100kb',
                'createThumb' : False,
                'extensions' : ['jpg','txt']
            },
           'Area Two' : {
                'root' : '/tmp/JoditBackend/ROOT/xxx/',
                'baseurl' : 'http://localhost:8000/ROOT/xxx/',
                'maxFileSize' : '100kb',
                'createThumb' : False,
                'extensions' : ['jpg','txt']
            },
            'More Files' : {
                'title': "Cool Files Here",
                'root' : '/tmp/JoditBackend/ROOT2/',
                'baseurl' : 'http://localhost:8000/ROOT2/',
                'maxFileSize' : '100kb',
                'createThumb' : False,
                'extensions' : ['jpg','txt','pdf']
            }
        },
     // ...
}

When the Jodit File browser UI is first loaded, all 3 sources are visible:

image

Once you click on a folder in one of the sources (e.g def in "Area One" source), the other sources are no longer accessible.

image

Note - I can modify the back end to always return the sources, however, it onlyt seems possible to "switch sources" when you click on a path within another source - so if there are no folders in the source, there is nothing to click on.

Also note: the filebrowser on the Jodit Web Site (https://xdsoft.net/jodit/pro/#filebrowser) seems to show the folders in a tree view, while the filebrowser module from Jodit 4.0 does not render it that way.

Expected behavior:

An ability to switch between sources or a "home" button that takes you back to all the sources for the FileBrowser should be presented...

Actual behavior:

Once you are in a specific source, there seems to be no way to leave.

WatchfulEyeOfZod commented 4 months ago

After some additional testing, it appears that if the back end returns a "." in the folder list, then the user can get back from a selected "source" to a list that includes all sources:

All Sources:

image

Clicking on "FolderInArea2", You get to the contents there with a ".." to navigate back to the root of the source:

image

Once you click on the ".." you are placed in the root of the source:

image

...And the "." will take you back to all the sources being displayed.

The issue with this approach is:

  1. If you upload while in the "all sources list", it does not really know where the file should be uploaded - and therefore goes to "default" source.
  2. There is no way to upload to a source that does not have folders in it (for example Area One in my attached screenshots) . The "." has no effect
  3. it is not very intuitive to click on the "." to go back to the "sources" list.

Sorry for the complicated description - this is hard to describe...

Perhaps "allow the name of the source" to be clicked on to "select it" and collapse the others using an accordion view when a source is selected?