-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
enableReadOnlyMode & refactor upload_url to a class #195
Conversation
juanbits
commented
Mar 7, 2024
- enableReadOnlyMode to disabled fields (close ckeditor is enabled on disabled textareas #192)
- Refactor upload_file function to a class to can be overrided for the user
- Enable image file rename using uuid via settings variable
- Allow use custom upload_url via settings variable
… & other improvements
Feat/disable editor disabled fields
subtitles format
format
format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just a small comment about the renaming from file
to image
|
||
urlpatterns = [ | ||
path("image_upload/", views.upload_file, name="ck_editor_5_upload_file"), | ||
path("image_upload/", UploadImageView.as_view(), name="ck_editor_5_upload_image"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a potentially breaking change if anyone uses reverse("ck_editor_5_upload_file")
(I do :) ). Is this renaming from file
to image
really necessary? If it is it should be marked as a breaking change somehow, there currently is no changelog but we probably should introduce one at some point. What do you think @hvlads ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@goapunk Well i decided to rename to image to be more semantic, considering the endpoint only allow upload images. Maybe is a good idea an this point create the changelog file and at least include the improvements in the next release, maybe the info:
- rename url name
- change view from function to class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the tests is failing for me now
@@ -19,7 +19,7 @@ def test_upload_file(admin_client, file): | |||
def test_upload_file_to_google_cloud(admin_client, file, settings): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test is oddly now failing for me but I think that's because it was not actually using storages.backends.gcloud.GoogleCloudStorage
. I added some print statements and on master it uses articles.storage.CustomStorage
, somehow override_settings
was not working and now is. I'm not entirely sure why. Maybe we can remove this test as I personally don't want to make a request to the google cloud servers every time I run the tests. What do you think @hvlads ?
@@ -89,6 +89,9 @@ function createEditors(element = document.body) { | |||
wordCountWrapper.innerHTML = ''; | |||
wordCountWrapper.appendChild(wordCountPlugin.wordCountContainer); | |||
} | |||
if(editorEl.hasAttribute("disabled")){ | |||
editor.enableReadOnlyMode( 'docs-snippet' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on the code. Is it intended to use the same id for all editors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hvlads sorry. I don't understand
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the lockId: string | symbol
parameter:
This parameter serves as a unique identifier for setting the editor into a read-only state. It's essential to ensure that each lock Id
is unique within your codebase.
editor.enableReadOnlyMode( 'my-feature-id' );
editor.enableReadOnlyMode( 'my-other-feature-id' );
// ...
editor.disableReadOnlyMode( 'my-feature-id' );
editor.isReadOnly; // true
.
editor.disableReadOnlyMode( 'my-other-feature-id' );
editor.isReadOnly; // false
.
Parameters
lockId : string | symbol
A unique ID for setting the editor to the read-only state.
In the loop, you're adding "docs-snippet" to all editors with the "disabled" attribute.
Shouldn't we do this?
const lockId = docs-snippet-${i}
;
editor.enableReadOnlyMode(lockId);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Juanita, do you need any assistance with this? Also, I wanted to confirm if the class UploadImage View is still relevant now that files are being uploaded as well. Let me know if you need any clarification. Thanks!